Skip to content

Commit b4dfb91

Browse files
author
Xiaoyi Cao
committed
Some updates
* Reduced default console message level. * Changed auto-scale in bigWig display. * Fixed interaction-track-dom.
1 parent 22824d0 commit b4dfb91

File tree

6 files changed

+154
-40
lines changed

6 files changed

+154
-40
lines changed

give/html/components/bower_components/genemo-data-components/basic-func/basicFunc.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,12 @@ var GIVe = (function (give) {
109109
!!(navigator.userAgent.match(/Trident/) ||
110110
navigator.userAgent.match(/rv 11/)))) {
111111
// IE detected (should be IE 11), fix the json return issue
112-
console.log('You are currently using IE 11 to visit this site. ' +
113-
'Some part of the site may behave differently and if you encounter ' +
114-
'any problems, please use the info on \'About us\' page to ' +
115-
'contact us.')
112+
give._verboseConsole(
113+
'You are currently using IE 11 to visit this site. ' +
114+
'Some part of the site may behave differently and if you encounter ' +
115+
'any problems, please use the info on \'About us\' page to ' +
116+
'contact us.', give.VERBOSE_MAJ_ERROR
117+
)
116118
responses = JSON.parse(responses)
117119
}
118120
responseFunc.call(thisVar, responses, xhr.status)
@@ -194,6 +196,22 @@ var GIVe = (function (give) {
194196
}
195197
}
196198

199+
give._findPercentile = function (dataArr, upperPercentile, lowerPercentile) {
200+
function numberComp (a, b) {
201+
return a - b
202+
}
203+
lowerPercentile = lowerPercentile || upperPercentile
204+
var sortedArr = dataArr.sort(numberComp)
205+
return {
206+
upper: sortedArr[parseInt(sortedArr.length * (1 - upperPercentile))],
207+
lower: sortedArr[parseInt(sortedArr.length * lowerPercentile)]
208+
}
209+
}
210+
211+
give._maxDecimalDigits = function (number, digits) {
212+
return Number(Math.round(number + 'e' + digits) + 'e-' + digits)
213+
}
214+
197215
window.addEventListener('WebComponentsReady', function (e) {
198216
give.fireCoreSignal('content-dom-ready', null)
199217
give.fireSignal(give.TASKSCHEDULER_EVENT_NAME, {flag: 'web-component-ready'})

give/html/components/bower_components/genemo-data-components/basic-func/constants-template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var GIVe = (function (give) {
88
give.VERBOSE_DEBUG = 4
99
give.VERBOSE_DEBUG_MORE = 5
1010

11-
give.verboseLvl = give.VERBOSE_DEBUG
11+
give.verboseLvl = give.VERBOSE_MAJ_ERROR
1212

1313
give.Host = 'https://www.givengine.org'
1414

give/html/components/bower_components/genemo-data-components/chrom-b-plus-tree/chromBPlusTreeNode.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ var GIVe = (function (give) {
7878
function (revdepth, start, end, summaryCtor, nextNode, prevNode, bFactor, isroot) {
7979
// start and length is for the corresponding region
8080
if (isNaN(bFactor) || parseInt(bFactor) !== bFactor || bFactor <= 2) {
81-
console.log('Default branching factor is chosen instead of ' + bFactor)
81+
give._verboseConsole('Default branching factor is chosen instead of ' +
82+
bFactor, give.VERBOSE_DEBUG)
8283
bFactor = give.ChromBPlusTreeNode._DEFAULT_B_FACTOR
8384
}
8485
if (typeof revdepth !== 'number' || isNaN(revdepth)) {

give/html/components/bower_components/genemo-visual-components/chart-area/track-doms/bigwig-track-dom.html

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,25 @@
2121
give.TrackDOMBehavior
2222
],
2323
properties: {
24+
upperPercentile: {
25+
type: Number,
26+
value: 0.01
27+
},
28+
29+
lowerPercentile: {
30+
type: Number,
31+
value: 0.01
32+
},
33+
34+
numOfDigits: {
35+
type: Number,
36+
value: 2
37+
},
38+
39+
includeZero: {
40+
type: Boolean,
41+
value: true
42+
}
2443
},
2544
created: function () {
2645
this.MARGIN = 2
@@ -199,29 +218,30 @@
199218
var vwindow = this.mainSvg.viewWindow
200219

201220
if (this.track.data.hasOwnProperty(vwindow.chr)) {
202-
var updateExtreme = function (dataSegment) {
203-
var yvalue = dataSegment.data.value
204-
if (Math.ceil(yvalue) > this.windowMax) {
205-
this.windowMax = Math.ceil(yvalue)
206-
}
207-
if (Math.floor(yvalue) < this.windowMin) {
208-
this.windowMin = Math.floor(yvalue)
209-
}
210-
}.bind(this)
221+
this.dataPoints = this._generateSmoothedPoints()
211222

212223
if (this.autoScale) {
213224
this.windowMax = Number.NEGATIVE_INFINITY
214-
this.windowMin = Number.POSITIVE_INFINITY
215-
this.track.data[vwindow.chr].traverse(vwindow, updateExtreme, null,
216-
this.getResolution(vwindow), this, false)
225+
this.windowMin = this.includeZero ? 0 : Number.POSITIVE_INFINITY
226+
try {
227+
var extremities = give._findPercentile(this.dataPoints.map(
228+
function (dataEntry) {
229+
return dataEntry.data.value
230+
}, this), this.upperPercentile, this.lowerPercentile)
231+
if (this.windowMax < extremities.upper) {
232+
this.windowMax = extremities.upper
233+
}
234+
if (this.windowMin > extremities.lower) {
235+
this.windowMin = extremities.lower
236+
}
237+
} catch (e) {
238+
}
217239
if (this.windowMax === Number.NEGATIVE_INFINITY) {
218240
this.windowMax = 1
219241
this.windowMin = 0
220242
}
221243
}
222244

223-
this.dataPoints = this._generateSmoothedPoints()
224-
225245
if (mode === 0) {
226246
this.drawPeak(this.dataPoints)
227247
}
@@ -716,10 +736,12 @@
716736

717737
// then the text
718738
this.drawText(this.textMargin - this.MARGIN - this.scaleTickLength - this.TEXT_MARGIN_GAP,
719-
this.drawingBoundary.top + this.textSize * 0.4, this.windowMax.toString(),
739+
this.drawingBoundary.top + this.textSize * 0.4,
740+
give._maxDecimalDigits(this.windowMax, this.numOfDigits).toString(),
720741
'end', null, this.textSvg)
721742
this.drawText(this.textMargin - this.MARGIN - this.scaleTickLength - this.TEXT_MARGIN_GAP,
722-
this.drawingBoundary.bottom - this.textSize * 0.4, this.windowMin.toString(),
743+
this.drawingBoundary.bottom - this.textSize * 0.4,
744+
give._maxDecimalDigits(this.windowMin, this.numOfDigits).toString(),
723745
'end', null, this.textSvg)
724746
}
725747
},

give/html/components/bower_components/genemo-visual-components/chart-area/track-doms/interaction-track-dom.html

Lines changed: 76 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
subTrackGap: {
2929
type: Number,
30-
value: 4 // em
30+
value: 6 // em
3131
},
3232

3333
// data structure for interaction tracks:
@@ -89,6 +89,8 @@
8989
this.numOfSubs = properties.numOfSubs
9090
this.bufferWindow = []
9191
this.percentiles = this.track.getSetting('thresholdPercentile')
92+
93+
this._pendingVWs = []
9294
},
9395

9496
initSvgComponents: function () {
@@ -203,6 +205,66 @@
203205
this.initSubSvgHolders()
204206
},
205207

208+
drawDataFireWrapper: function (newVWindow) {
209+
// fire track-ready event to its container (to calculate size and do other stuff)
210+
this.changeViewWindow(newVWindow)
211+
this.drawData()
212+
this._setIsReady(true)
213+
this.fire('track-ready', {ID: this.track.getID()})
214+
if (this.callbackAfterDraw) {
215+
this.callbackAfterDraw()
216+
delete this.callbackAfterDraw
217+
}
218+
},
219+
220+
drawDataDebounceWrapper: function (newVWindow) {
221+
// debounce wrapper for drawData()
222+
this.debounce(this.updateJobName, this.drawDataFireWrapper.bind(
223+
this, newVWindow), this._drawDebounceInt)
224+
},
225+
226+
checkDataAndUpdate: function (newVWindow) {
227+
// Steps:
228+
// * run this.track.getData with drawData (debounced) as callback
229+
// * whenever drawData (debounced) is done, run updateCache
230+
// Meanwhile, run fetch data (debounced) without visible callback
231+
// * Otherwise, run fetch data with drawData (debounced) as callback
232+
233+
newVWindow = newVWindow || this._pendingVWs
234+
235+
if (this.isDebouncerActive(this.cacheUpdateJobName)) {
236+
this.cancelDebouncer(this.cacheUpdateJobName)
237+
}
238+
239+
if (!Array.isArray(newVWindow)) {
240+
newVWindow = [newVWindow]
241+
}
242+
243+
// this is to set up cache loading functions as call back after draw
244+
this.callbackAfterDraw = this.debounce.bind(
245+
this, this.cacheUpdateJobName, this.track.getData.bind(
246+
this.track,
247+
newVWindow.map(function (range) {
248+
return range.getExtension(
249+
give.TrackDOMBehaviorImpl.CacheRangeSpanProportion,
250+
null, true, this.track.ref
251+
)
252+
}, this), this.getResolution(newVWindow), null, this.id
253+
), this._cacheDebounceInt)
254+
this.track.getData(
255+
newVWindow.map(function (range) {
256+
return range.getExtension(
257+
give.TrackDOMBehaviorImpl.DefaultRangeSpanProportion,
258+
null, true, this.track.ref
259+
)
260+
}, this),
261+
this.getResolution(newVWindow),
262+
this.drawDataDebounceWrapper.bind(
263+
this, newVWindow
264+
), this.id
265+
)
266+
},
267+
206268
updateTracks: function (viewWindow, index, threshold) {
207269
// viewWindow: give.ChromRegion object or an array of give.ChromRegion objects
208270
// index: if viewWindow is a single give.ChromRegion Object, index will be the index
@@ -215,18 +277,18 @@
215277
if (viewWindow) {
216278
if (Array.isArray(viewWindow)) {
217279
// then it must have enough elements
218-
viewWindow.forEach(this.changeViewWindow, this)
280+
this._pendingVWs = viewWindow
219281
} else {
220-
this.changeViewWindow(viewWindow, index)
282+
this._pendingVWs[index] = viewWindow
221283
}
222284
}
223285

224-
if (this.subSvgs.every(function (subSvg) {
225-
return subSvg.viewWindow
286+
if (this._pendingVWs.every(function (pendingVWindow) {
287+
return pendingVWindow
226288
}, this)) {
227289
// Get data clipped by viewWindow by calling getData()
228290
// May also include data preparation
229-
this.checkDataAndUpdate()
291+
this.checkDataAndUpdate(this._pendingVWs)
230292
// Update detailed content by calling drawData()
231293
// Will be debounced to prevent lagging
232294
}
@@ -245,10 +307,15 @@
245307
},
246308

247309
changeViewWindow: function (viewWindow, index) {
248-
if (typeof (viewWindow) === 'string') {
249-
this.subSvgs[index].viewWindow = new give.ChromRegion(viewWindow, this.track.ref)
310+
if (Array.isArray(viewWindow)) {
311+
viewWindow.forEach(this.changeViewWindow, this)
250312
} else {
251-
this.subSvgs[index].viewWindow = viewWindow.clipRegion(this.track.ref).clone()
313+
if (typeof (viewWindow) === 'string') {
314+
this.subSvgs[index].viewWindow = new give.ChromRegion(viewWindow, this.track.ref)
315+
} else {
316+
this.subSvgs[index].viewWindow = viewWindow.clipRegion(this.track.ref).clone()
317+
}
318+
this._pendingVWs[index] = this.subSvgs[index].viewWindow
252319
}
253320
},
254321

give/html/components/bower_components/genemo-visual-components/chart-area/track-doms/track-dom-behavior.html

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -861,19 +861,25 @@
861861
this.cancelDebouncer(this.cacheUpdateJobName)
862862
}
863863

864+
var newVWArr = Array.isArray(newVWindow) ? newVWindow : [newVWindow]
865+
864866
// this is to set up cache loading functions as call back after draw
865867
this.callbackAfterDraw = this.debounce.bind(
866868
this, this.cacheUpdateJobName, this.track.getData.bind(
867-
this.track, newVWindow.getExtension(
868-
give.TrackDOMBehaviorImpl.CacheRangeSpanProportion,
869-
null, true, this.track.ref
870-
), this.getResolution(newVWindow), null, this.id
869+
this.track, newVWArr.map(function (range) {
870+
return range.getExtension(
871+
give.TrackDOMBehaviorImpl.CacheRangeSpanProportion,
872+
null, true, this.track.ref
873+
)
874+
}, this), this.getResolution(newVWindow), null, this.id
871875
), this._cacheDebounceInt)
872876
this.track.getData(
873-
newVWindow.getExtension(
874-
give.TrackDOMBehaviorImpl.DefaultRangeSpanProportion,
875-
null, true, this.track.ref
876-
), this.getResolution(newVWindow),
877+
newVWArr.map(function (range) {
878+
return range.getExtension(
879+
give.TrackDOMBehaviorImpl.DefaultRangeSpanProportion,
880+
null, true, this.track.ref
881+
)
882+
}, this), this.getResolution(newVWindow),
877883
this.drawDataDebounceWrapper.bind(
878884
this, newVWindow
879885
), this.id)
@@ -946,7 +952,7 @@
946952
if (typeof (viewWindow) === 'string') {
947953
return new give.ChromRegion(viewWindow, this.track.ref)
948954
} else {
949-
return viewWindow.clipRegion(this.track.ref).clone()
955+
return viewWindow.clone().clipRegion(this.track.ref)
950956
}
951957
// this.set('viewWindowString', newValue);
952958
},

0 commit comments

Comments
 (0)