-
Notifications
You must be signed in to change notification settings - Fork 1
/
BedAnnot.pde
89 lines (63 loc) · 1.84 KB
/
BedAnnot.pde
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
//class to store a bed file (bed3)
//methods to draw it in different ways
class BedAnnot{
Table bed_table;
String glyph;
color col;
int alpha_val;
BedAnnot(String bed_file, String g, color c, int a){
bed_table = loadTable(bed_file, "header, tsv");
glyph = g;
alpha_val = a;
col = c;
println("tbale", bed_file, bed_table);
}
void draw(float radius, float x, float y){
if( glyph.equals("dot")){
drawAsDot(radius, x, y);
}
else if(glyph.equals("interval")){
drawAsInt(radius, x, y);
}
else {
println("ERROR: wrong glyph type for bed: ", glyph);
}
}
//draw as colored interval
void drawAsInt(float radius, float x, float y){
float start_angle = 0.0;
float end_angle = 0.0;
String chr_name = "";
// int startpos = 0;
// int endpos = 0;
for (TableRow row : bed_table.rows()){
chr_name = row.getString("chr");
// startpos = row.getInt("start");
// endpos = row.getInt("end");
// println(chr_name, startpos, endpos);
start_angle = genome.genToPolar(chr_name, row.getInt("start"));
end_angle = genome.genToPolar(chr_name, row.getInt("end"));
intBand(start_angle, end_angle, radius, x, y, 40, col, alpha_val);
}
}
//draw as dot in the center of the interval
void drawAsDot(float radius, float x, float y){
float start_angle = 0.0;
float end_angle = 0.0;
String chr_name = "";
// int startpos = 0;
// int endpos = 0;
for (TableRow row : bed_table.rows()){
chr_name = row.getString("chr");
// startpos = row.getInt("start");
// endpos = row.getInt("end");
// println(chr_name, startpos, endpos);
start_angle = genome.genToPolar(chr_name, row.getInt("start"));
end_angle = genome.genToPolar(chr_name, row.getInt("end"));
intMidDot(start_angle, end_angle, radius, x, y, col, alpha_val);
}
}
//draw as triangle
//draw as scatter?
//draw as line
}