Skip to content

Commit

Permalink
Add insert sizes for CRAM
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Nov 9, 2018
1 parent d19cf20 commit 4f281f5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/JBrowse/Store/SeqFeature/CRAM.js
Expand Up @@ -85,6 +85,7 @@ define( [
'JBrowse/Store/DeferredFeaturesMixin',
'JBrowse/Store/SeqFeature/GlobalStatsEstimationMixin',
'JBrowse/Store/SeqFeature/_PairCache',
'JBrowse/Store/SeqFeature/_InsertSizeCache',
'JBrowse/Model/XHRBlob',
'JBrowse/Model/SimpleFeature',
],
Expand All @@ -97,6 +98,7 @@ define( [
DeferredFeaturesMixin,
GlobalStatsEstimationMixin,
PairCache,
InsertSizeCache,
XHRBlob,
SimpleFeature,
) {
Expand Down Expand Up @@ -169,6 +171,7 @@ return declare( [ SeqFeatureStore, DeferredStatsMixin, DeferredFeaturesMixin, Gl
})

this.storeTimeout = args.storeTimeout || 3000;
this.insertSizeCache = new InsertSizeCache(args);
},

// process the parsed SAM header from the cram file
Expand Down Expand Up @@ -294,10 +297,13 @@ return declare( [ SeqFeatureStore, DeferredStatsMixin, DeferredFeaturesMixin, Gl
.then(records => {
if(query.viewAsPairs) {
const recs = records.map(f => this._cramRecordToFeature(f))
recs.forEach(r => this.insertSizeCache.insertFeat(r))
this.pairFeatures(query, recs, featCallback, endCallback, errorCallback)
} else {
for(let i = 0; i < records.length; i++) {
featCallback(this._cramRecordToFeature(records[i]))
let feat = this._cramRecordToFeature(records[i])
this.insertSizeCache.insertFeat(feat);
featCallback(feat)
}
}
endCallback()
Expand All @@ -310,6 +316,10 @@ return declare( [ SeqFeatureStore, DeferredStatsMixin, DeferredFeaturesMixin, Gl
})
},

getInsertSizeStats() {
return this.insertSizeCache.getInsertSizeStats()
},

_cramRecordToFeature(record) {
return new CramSlightlyLazyFeature(record, this)
},
Expand Down

0 comments on commit 4f281f5

Please sign in to comment.