Skip to content

Commit

Permalink
Add an upper limit to fetch size
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Nov 15, 2018
1 parent c4da153 commit 8896f7f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
9 changes: 4 additions & 5 deletions src/JBrowse/Store/SeqFeature/_InsertSizeCache.js
Expand Up @@ -12,7 +12,6 @@ return declare(null, {
this.featureCache = {}
this.insertStatsCacheMin = args.insertStatsCacheMin || 400
this.insertMaxSize = args.insertMaxSize || 50000
this.orientationType = args.orientationType || 'fr'
},

cleanFeatureCache(query) {
Expand All @@ -28,8 +27,8 @@ return declare(null, {
},

getInsertSizeStats() {
if(Object.keys(this.featureCache).length > this.insertStatsCacheMin) {
var total = Object.keys(this.featureCache).length
const total = Object.keys(this.featureCache).length
if(total > this.insertStatsCacheMin) {
var tlens = Object.entries(this.featureCache)
.map(([k, v]) => Math.abs(v))
.filter(tlen => tlen < this.insertMaxSize)
Expand All @@ -39,8 +38,8 @@ return declare(null, {
var avg = sum / total;
var sd = Math.sqrt((total * sum2 - sum*sum) / (total * total));
return {
upper: avg + 3*sd,
lower: avg - 3*sd
upper: avg + 3 * sd,
lower: avg - 3 * sd
}
}
return { upper: Infinity, lower: 0 }
Expand Down
8 changes: 4 additions & 4 deletions src/JBrowse/View/Track/Alignments2.js
Expand Up @@ -217,16 +217,16 @@ return declare( [ CanvasFeatureTrack, AlignmentsMixin ], {
}
if(this.config.viewAsPairs || this.config.viewAsSpans || this.config.colorByOrientation) {
let supermethod = this.getInherited(arguments)
const len = Math.max(args.rightBase - args.leftBase, 4000)
const len = Math.min(Math.max(args.rightBase - args.leftBase, 4000), 100000)
const region = {
ref: this.refSeq.name,
start: Math.max(0, args.leftBase),
end: args.rightBase,
viewAsPairs: true
}

const min = Math.max(0, region.start - len * 10)
const max = region.end + len * 10
const e = 30
const min = Math.max(0, region.start - len * e)
const max = region.end + len * e
this.initialCachePromise = this.initialCachePromise || new Promise((resolve, reject) => {
this.store.getFeatures({
ref: this.refSeq.name,
Expand Down

0 comments on commit 8896f7f

Please sign in to comment.