forked from DECIPHER-genomics/Genoverse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ion.html
216 lines (192 loc) · 10.7 KB
/
ion.html
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/genoverse.css" />
<link rel="stylesheet" type="text/css" href="css/controlPanel.css" />
<link rel="stylesheet" type="text/css" href="css/trackControls.css" />
<link rel="stylesheet" type="text/css" href="css/resizer.css" />
<link rel="stylesheet" type="text/css" href="css/tooltips.css" />
</head>
<body>
<div id="genoverse"></div>
<script type="text/javascript" src="js/lib/jquery.js"></script>
<script type="text/javascript" src="js/lib/jquery-ui.js"></script>
<script type="text/javascript" src="js/lib/jquery.mousewheel.js"></script>
<script type="text/javascript" src="js/lib/jquery.mousehold.js"></script>
<script type="text/javascript" src="js/lib/jquery.tipsy.js"></script>
<script type="text/javascript" src="js/genomes/grch37.js"></script>
<script type="text/javascript" src="js/lib/Base.js"></script>
<script type="text/javascript" src="js/lib/rtree.js"></script>
<script type="text/javascript" src="js/Genoverse.js"></script>
<script type="text/javascript" src="js/Track.js"></script>
<script type="text/javascript" src="js/Track/library/File.js"></script>
<script type="text/javascript" src="js/Track/Controller.js"></script>
<script type="text/javascript" src="js/Track/Model.js"></script>
<script type="text/javascript" src="js/Track/View.js"></script>
<script type="text/javascript" src="js/Track/library/Static.js"></script>
<script type="text/javascript" src="js/Track/library/Configurable.js"></script>
<script type="text/javascript" src="js/Track/Controller/Stranded.js"></script>
<script type="text/javascript" src="js/Track/Model/Stranded.js"></script>
<script type="text/javascript" src="js/Track/library/Chromosome.js"></script>
<script type="text/javascript" src="js/Track/library/Scaleline.js"></script>
<script type="text/javascript" src="js/Track/library/Scalebar.js"></script>
<script type="text/javascript" src="js/Track/library/Legend.js"></script>
<script type="text/javascript" src="js/Track/Model/Sequence.js"></script>
<script type="text/javascript" src="js/Track/Model/Sequence/Fasta.js"></script>
<script type="text/javascript" src="js/Track/Model/Sequence/Ensembl.js"></script>
<script type="text/javascript" src="js/Track/Model/Sequence/DAS.js"></script>
<script type="text/javascript" src="js/Track/View/Sequence.js"></script>
<script type="text/javascript" src="js/Track/Model/SequenceVariation.js"></script>
<script type="text/javascript" src="js/Track/Model/SequenceVariation/VCF.js"></script>
<script type="text/javascript" src="js/Track/Model/Gene.js"></script>
<script type="text/javascript" src="js/Track/Model/Gene/Ensembl.js"></script>
<script type="text/javascript" src="js/Track/View/Gene.js"></script>
<script type="text/javascript" src="js/Track/View/Gene/Ensembl.js"></script>
<script type="text/javascript" src="js/Track/Model/Transcript.js"></script>
<script type="text/javascript" src="js/Track/Model/Transcript/Ensembl.js"></script>
<script type="text/javascript" src="js/Track/Model/Transcript/GFF3.js"></script>
<script type="text/javascript" src="js/Track/View/Transcript.js"></script>
<script type="text/javascript" src="js/Track/View/Transcript/Ensembl.js"></script>
<script type="text/javascript" src="js/Track/Model/File.js"></script>
<script type="text/javascript" src="js/Track/Model/File/GFF.js"></script>
<script type="text/javascript" src="js/Track/Model/File/BED.js"></script>
<script type="text/javascript" src="js/Track/library/File/GFF.js"></script>
<script type="text/javascript" src="js/Track/library/File/GFF3.js"></script>
<script type="text/javascript" src="js/Track/library/File/BED.js"></script>
<script type="text/javascript" src="js/Track/library/File/VCF.js"></script>
<script language="javascript" src="js/lib/dalliance/js/utils.js"></script>
<script language="javascript" src="js/lib/dalliance/js/bin.js"></script>
<script language="javascript" src="js/lib/dalliance/js/das.js"></script>
<script language="javascript" src="js/lib/jszlib/js/inflate.js"></script>
<script language="javascript" src="js/lib/dalliance/js/bam.js"></script>
<script>
function dlog (error) {
console.log(error);
};
var genoverseConfig = {
container : '#genoverse',
width : 1024,
genome : 'grch37',
// If no genome supplied, it must have at least chromosomeSize, e.g.:
// chromosomeSize : 249250621, // chromosome 1, human
chr : 1,
start : 85742012,
end : 85742112,
plugins : [ 'controlPanel', 'karyotype', 'trackControls', 'resizer', 'tooltips', 'fileDrop' ],
tracks : [
Genoverse.Track.Scalebar,
Genoverse.Track.extend({
name : 'Sequence',
controller : Genoverse.Track.Controller.Sequence,
model : Genoverse.Track.Model.Sequence.Fasta,
view : Genoverse.Track.View.Sequence,
lineLength : 71,
resizable : 'auto'
}),
Genoverse.Track.extend({
name : 'Bam file',
bump : true,
autoHeight: true,
model : Genoverse.Track.Model.extend({
urlBam : '/data/ion/rawlib_chr1_85742012.bam',
urlBai : '/data/ion/rawlib_chr1_85742012.bam.bai',
init : function () {
var model = this;
model.initialised = $.Deferred();
makeBam(
new URLFetchable(this.urlBam),
new URLFetchable(this.urlBai),
function (bam) {
model.bam = bam;
model.initialised.resolve();
}
);
this.base();
},
getData : function (start, end) {
var model = this;
var getDataState = $.Deferred();
$.when(this.initialised).done(function(){
model.bam.fetch(model.browser.chr, start, end, function(r, e) {
if (r) {
model.receiveData(r, start, end);
getDataState.resolve();
}
if (e) {
console.log('BAM Error: ' + e);
getDataState.reject();
}
});
});
return getDataState;
},
parseData : function (data) {
for (var i = 0; i < data.length; i++) {
var feature = $.extend({}, data[i], {
id : data[i].readName,
start : data[i].pos + 1,
end : data[i].pos + 1 + data[i].seq.length,
sequence : data[i].seq,
insertions : [],
});
if (feature.cigar) {
var puffs = feature.cigar.match(/[0-9]+[A-Z]{1}/g);
var cursor = 0;
for (var j=0; j<puffs.length; j++) {
var puffSize = parseInt( puffs[j].slice(0, -1), 10 );
if (puffs[j].slice(-1) === 'I') {
// Remove insertion from the sequence string, push it into insertions array
// Cursor stays where it was
feature.insertions.push([ cursor, feature.sequence.slice(cursor, puffSize) ]);
feature.sequence = feature.sequence.slice(0, cursor) + feature.sequence.slice(cursor + puffSize);
} else if (puffs[j].slice(-1) === 'S' || puffs[j].slice(-1) === 'H') {
// Soft clipping, remove clip sequence string
// Cursor stays where it was
feature.sequence = feature.sequence.slice(0, cursor) + feature.sequence.slice(cursor + puffSize);
}
else if (puffs[j].slice(-1) === 'D') {
// Add dashes in place of deleted bases to keep the sequence aligned
feature.sequence = feature.sequence.slice(0, cursor) + Array(puffSize + 1).join('-') + feature.sequence.slice(cursor);
cursor += puffSize;
} else {
cursor += puffSize;
}
feature.end = feature.start + cursor;
}
}
this.insertFeature(feature);
}
},
}),
view : Genoverse.Track.View.Sequence.extend({
drawSequence : function (feature, context, scale, width) {
this.base(feature, context, scale, width);
var oldFont = context.font;
context.font = 'bold 12pt Courier';
for (var i = 0; i < feature.insertions.length; i++) {
var position = feature.position[scale].X + scale * feature.insertions[i][0] - 5;
context.fillStyle = 'black';
context.fillText('I', position, feature.position[scale].Y + this.labelYOffset);
}
context.font = oldFont;
}
}),
100000 : false,
2000 : {
featureHeight : 2,
view : Genoverse.Track.View.extend({
featureMargin : { top: 0, right: 0, bottom: 0, left: 0 }
}),
},
100 : {
featureHeight : 12,
},
resizable : true,
})
]
}
$(document).ready(function () { window.genoverse = new Genoverse(genoverseConfig); });
</script>
</body>
</html>