-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.cs
180 lines (154 loc) · 5.67 KB
/
MainWindow.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
using System;
using Gtk;
using Pango;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using ccsviewer;
public partial class MainWindow: Gtk.Window
{
public int maxLength = 500;
int alnLength = 40;
TextTag A;
TextTag C;
TextTag G;
TextTag T;
TextTag Blank;
CCSDataSet data;
public MainWindow (CCSDataSet data) : base (Gtk.WindowType.Toplevel)
{
this.data = data;
Build ();
A = CreateTag ("red", "black");
C = CreateTag ("blue", "white");
G = CreateTag ("yellow", "black");
T = CreateTag ("green","white");
Blank = CreateTag ("white", "black");
drawAlignment();
}
public void createBelvuAlignment() {
// var seqArea = new Gtk.Layout (IntPtr.Zero);
// var columnsArea = new Gtk.Layout (IntPtr.Zero);
// var columnsHeader = new Gtk.DrawingArea ();
// var seqHeader = new Gtk.DrawingArea ();
// uint xpad = 0;
// uint ypad = 0;
//
// this.table1.Attach (columnsHeader, 0, 1, 0, 1, AttachOptions.Fill, AttachOptions.Shrink, xpad, ypad);
// this.table1.Attach (columnsArea as Gtk.Widget, 0, 1, 1, 2, AttachOptions.Fill, AttachOptions.Expand | AttachOptions.Fill, xpad, ypad);
// this.table1.Attach (seqHeader, 1, 2, 0, 1, AttachOptions.Fill, AttachOptions.Fill, xpad, ypad);
// this.table1.Attach (seqArea, 1, 2, 1, 2, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill | AttachOptions.Expand, xpad, ypad);
//
// var hScrollBar = new Gtk.HScrollbar(new Adjustment(0, 0, maxLength, 5, 0, 0));
// var vScrolBar = new VScrollbar (new Adjustment (0, 0, alnLength + 1, 1, 0, 0));
//
// this.table1.Attach (hScrollBar, 1, 2, 2, 3, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Shrink, xpad, ypad);
// this.table1.Attach (vScrolBar, 2, 3, 1, 2, AttachOptions.Shrink, AttachOptions.Fill | AttachOptions.Expand, xpad, ypad);
}
private void drawAlignment() {
// Write sequence names first
var names = String.Join ("\n", data.Reads.Select (z => z.Name));
this.textview_seqnames.Buffer.Text = names;
var seqs = String.Join ("\n", data.Reads.Select (z => z.Sequence));
this.textview_seqs.Buffer.Text = seqs;
var iter = this.textview_seqs.Buffer.GetIterAtLine (0);
int pos = 0;
int line = 0;
do {
var bp = iter.Char;
TextTag tag = null;
switch (bp) {
case "A":
tag = A;
break;
case "C":
tag = C;
break;
case "G":
tag = G;
break;
case "T":
tag = T;
break;
case "-":
tag = Blank;
break;
case "\n":
line++;
pos = 0;
break;
}
if (tag != null) {
textview_seqs.Buffer.ApplyTag (tag, iter, textview_seqs.Buffer.GetIterAtLineOffset (line, ++pos));
}
} while(iter.ForwardChar ());
}
TextTag CreateTag(string backgroundColor, string foregroundColor) {
TextTag tag = new TextTag (null);
//tag.Weight = Pango.Weight.Bold;
tag.Background = backgroundColor;
tag.Font = "Courier 14";
tag.Foreground = foregroundColor;
textview_seqs.Buffer.TagTable.Add (tag);
return tag;
}
protected void OnDeleteEvent (object sender, DeleteEventArgs a)
{
Application.Quit ();
a.RetVal = true;
}
protected void activateSignal (object sender, EventArgs e)
{
/*
var iter = this.table2.Buffer.GetIterAtLine (0);
int pos = 0;
int line = 0;
bool haveIter = true;
do {
var bp = iter.Char;
TextTag tag = null;
switch (bp)
{
case "A":
tag = A;
break;
case "C":
tag = C;
break;
case "G":
tag = G;
break;
case "T":
tag = T;
break;
}
if (tag !=null) {
table2.Buffer.ApplyTag(tag, iter, this.table2.Buffer.GetIterAtLineOffset(line, ++pos));
}
} while(iter.ForwardChar());
*/
// tag.Weight = Pango.Weight.Bold;
// tag.Background = "red";
//
// var iter = this.textview1.Buffer.GetIterAtLine (0);
// this.textview1.Buffer.InsertWithTags (ref iter, "Bold text\n", tag);
//
// FileChooserDialog fileChooser = new FileChooserDialog ("Choose an Image to View", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
// if (fileChooser.Run () == (int)ResponseType.Accept) {
//
// if(fileChooser.Filename.ToLower().EndsWith(".png") ||
// fileChooser.Filename.ToLower().EndsWith(".gif") ||
// fileChooser.Filename.ToLower().EndsWith(".jpg"))
// {
//// //Dispose of Old PixBuf
//// if (displayImage != null && displayImage.Pixbuf != null) {
//// displayImage.Pixbuf.Dispose ();
//// }
////
//// displayImage.Pixbuf = new Gdk.Pixbuf (fileChooser.Filename);
// }
// }
//
// fileChooser.Destroy ();
}
}