-
Notifications
You must be signed in to change notification settings - Fork 199
/
Alignments2.js
174 lines (156 loc) · 5.75 KB
/
Alignments2.js
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
define( [
'dojo/_base/declare',
'dojo/_base/array',
'dojo/promise/all',
'JBrowse/Util',
'JBrowse/View/Track/CanvasFeatures',
'JBrowse/View/Track/_AlignmentsMixin'
],
function(
declare,
array,
all,
Util,
CanvasFeatureTrack,
AlignmentsMixin
) {
return declare( [ CanvasFeatureTrack, AlignmentsMixin ], {
_defaultConfig: function() {
var c = Util.deepUpdate(
dojo.clone( this.inherited(arguments) ),
{
glyph: 'JBrowse/View/FeatureGlyph/Alignment',
maxFeatureGlyphExpansion: 0,
maxFeatureScreenDensity: 15,
hideDuplicateReads: true,
hideQCFailingReads: true,
hideSecondary: true,
hideSupplementary: true,
hideUnmapped: true,
hideUnsplicedReads: false,
hideMissingMatepairs: false,
hideForwardStrand: false,
hideReverseStrand: false,
useXS: false,
useReverseTemplate: false,
useXSOption: true,
useReverseTemplateOption: true,
viewAsPairs: false,
readCloud: false,
histograms: {
description: 'coverage depth',
binsPerBlock: 200
},
style: {
showLabels: false
}
}
);
return c;
},
_trackMenuOptions: function() {
var thisB = this;
var displayOptions = [];
if(this.config.useReverseTemplateOption) {
displayOptions.push({
label: 'Use reversed template',
type: 'dijit/CheckedMenuItem',
checked: this.config.useReverseTemplate,
onClick: function(event) {
thisB.config.useReverseTemplate = this.get('checked');
thisB.browser.publish('/jbrowse/v1/v/tracks/replace', [thisB.config]);
}
});
}
if(this.config.useXSOption) {
displayOptions.push({
label: 'Use XS',
type: 'dijit/CheckedMenuItem',
checked: this.config.useXS,
onClick: function(event) {
thisB.config.useXS = this.get('checked');
thisB.browser.publish('/jbrowse/v1/v/tracks/replace', [thisB.config]);
}
});
}
displayOptions.push({
label: 'View normal',
type: 'dijit/RadioMenuItem',
group: 'g2',
onClick: function(event) {
thisB.config.viewAsPairs = false
thisB.config.readCloud = false
thisB.config.glyph = 'JBrowse/View/FeatureGlyph/Alignment'
thisB.browser.publish('/jbrowse/v1/v/tracks/replace', [thisB.config]);
}
});
displayOptions.push({
label: 'View as pairs',
type: 'dijit/RadioMenuItem',
group: 'g2',
onClick: function(event) {
thisB.config.viewAsPairs = true
thisB.config.readCloud = false
thisB.config.glyph = 'JBrowse/View/FeatureGlyph/PairedAlignment'
thisB.browser.publish('/jbrowse/v1/v/tracks/replace', [thisB.config]);
}
});
displayOptions.push({
label: 'View pairs as read cloud',
type: 'dijit/RadioMenuItem',
group: 'g2',
onClick: function(event) {
thisB.config.viewAsPairs = true
thisB.config.readCloud = true
thisB.config.glyph = 'JBrowse/View/FeatureGlyph/PairedAlignment'
thisB.browser.publish('/jbrowse/v1/v/tracks/replace', [thisB.config]);
}
});
return all([ this.inherited(arguments), this._alignmentsFilterTrackMenuOptions(), displayOptions ])
.then( function( options ) {
var o = options.shift();
options.unshift({ type: 'dijit/MenuSeparator' } );
return o.concat.apply( o, options );
});
},
// override getLayout to access addRect method
_getLayout: function() {
var layout = this.inherited(arguments);
if(this.config.readCloud) {
layout = declare.safeMixin(layout, {
addRect: function() {
this.pTotalHeight = this.maxHeight;
return 0;
}
});
}
return layout;
},
fillBlock: function( args ) {
if(this.config.viewAsPairs) {
let supermethod = this.getInherited(arguments)
var initial = new Promise((resolve, reject) => {
var reg = this.browser.view.visibleRegion()
var len = reg.end - reg.start
const region = {
ref: this.refSeq.name,
start: Math.max( 0, reg.start ),
end: reg.end,
viewAsPairs: true
}
region.start = Math.max( 0, region.start )
region.end = region.end
this.store.getPairedRanges(region, range => {
region.start = Math.max(0, range.min - len)
region.end = range.max + len
this.store.getFeatures(region, function() {}, resolve, reject)
}, reject)
}).then(() => {
supermethod.apply(this, [args])
})
} else {
this.inherited(arguments);
}
}
});
});