-
Notifications
You must be signed in to change notification settings - Fork 199
/
IndexedStatsEstimationMixin.js
41 lines (37 loc) · 1.31 KB
/
IndexedStatsEstimationMixin.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
/**
* Mixin that adds _estimateGlobalStats method to a store, which
* samples a section of the features in the store and uses those to
* esimate the statistics of the whole data set.
*/
define([
'dojo/_base/declare',
'dojo/_base/array',
'dojo/Deferred',
'JBrowse/Errors',
'JBrowse/Store/SeqFeature/GlobalStatsEstimationMixin'
],
function( declare, array, Deferred, Errors, GlobalStats ) {
return declare( GlobalStats, {
/**
* Fetch a region of the current reference sequence and use it to
* estimate the feature density of the store.
* @private
*/
async _estimateGlobalStats(refseq) {
refseq = refseq || this.refSeq
let featCount
if (this.indexedData) {
featCount = await this.indexedData.featureCount(refseq.name)
} else if (this.bam) {
const chr = this.browser.regularizeReferenceName(refseq.name)
const chrId = this.bam.chrToIndex && this.bam.chrToIndex[chr]
featCount = await this.bam.index.featureCount(chrId, true)
}
if (featCount == -1) {
return this.inherited('_estimateGlobalStats', arguments)
}
const featureDensity = featCount / (refseq.end - refseq.start)
return { featureDensity }
}
});
});