Skip to content

Commit

Permalink
Fix block cache for small bam edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobinso committed Jan 11, 2023
1 parent c659fe3 commit 59bcaea
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions js/bam/bgzBlockLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ class BGZBlockLoader {
} else {

const c = this.cache
if (c && (c.startBlock <= startBlock && c.endBlock >= endBlock)) {
//console.log("Complete overlap")
if (c &&
c.startBlock <= startBlock &&
(c.endBlock >= endBlock || skipEnd && c.nextEndBlock === endBlock)) {
console.log("Complete overlap")
const startOffset = startBlock - c.startBlock
const endOffset = endBlock - c.startBlock
return inflateBlocks(c.buffer, startOffset, endOffset)
Expand Down Expand Up @@ -127,12 +129,13 @@ class BGZBlockLoader {
}

// If skipEnd === true we need to find boundary of last block in cache
let nextEndBlock = endBlock
if(skipEnd) {
const boundaries = findBlockBoundaries(buffer)
endBlock = boundaries[boundaries.length - 1]
}

this.cache = {startBlock, endBlock, buffer}
this.cache = {startBlock, endBlock, nextEndBlock, buffer}
return inflateBlocks(buffer)
}
}
Expand Down

0 comments on commit 59bcaea

Please sign in to comment.