@gmod/bam
Version:
Parser for BAM and BAM index (bai) files
32 lines • 1.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
// little class representing a chunk in the index
class Chunk {
minv;
maxv;
bin;
// Absolute byte offset where the fetch for this chunk ends. The compressed
// size of the final BGZF block (the one at maxv.blockPosition) is unknown
// from the index, so this defaults to a full max-size block past maxv. It can
// be tightened to the next known block boundary via clampChunkEnds.
endPosition;
constructor(minv, maxv, bin, endPosition = maxv.blockPosition + (1 << 16)) {
this.minv = minv;
this.maxv = maxv;
this.bin = bin;
this.endPosition = endPosition;
}
toString() {
return `${this.minv.toString()}..${this.maxv.toString()} (bin ${this.bin}, fetchedSize ${this.fetchedSize()})`;
}
compareTo(b) {
return (this.minv.compareTo(b.minv) ||
this.maxv.compareTo(b.maxv) ||
this.bin - b.bin);
}
fetchedSize() {
return this.endPosition - this.minv.blockPosition;
}
}
exports.default = Chunk;
//# sourceMappingURL=chunk.js.map