@gmod/bam 7.6.1 → 7.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +109 -98
- package/dist/bai.d.ts +6 -3
- package/dist/bai.js +32 -16
- package/dist/bai.js.map +1 -1
- package/dist/bamFile.d.ts +16 -3
- package/dist/bamFile.js +83 -36
- package/dist/bamFile.js.map +1 -1
- package/dist/chunk.d.ts +0 -1
- package/dist/chunk.js +0 -5
- package/dist/chunk.js.map +1 -1
- package/dist/csi.d.ts +0 -2
- package/dist/csi.js +4 -11
- package/dist/csi.js.map +1 -1
- package/dist/htsget.d.ts +16 -0
- package/dist/htsget.js +72 -52
- package/dist/htsget.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/indexFile.d.ts +2 -3
- package/dist/indexFile.js.map +1 -1
- package/dist/sam.js +8 -3
- package/dist/sam.js.map +1 -1
- package/dist/util.d.ts +11 -3
- package/dist/util.js +35 -8
- package/dist/util.js.map +1 -1
- package/dist/virtualOffset.d.ts +8 -3
- package/dist/virtualOffset.js +0 -3
- package/dist/virtualOffset.js.map +1 -1
- package/esm/bai.d.ts +6 -3
- package/esm/bai.js +32 -16
- package/esm/bai.js.map +1 -1
- package/esm/bamFile.d.ts +16 -3
- package/esm/bamFile.js +83 -36
- package/esm/bamFile.js.map +1 -1
- package/esm/chunk.d.ts +0 -1
- package/esm/chunk.js +0 -5
- package/esm/chunk.js.map +1 -1
- package/esm/csi.d.ts +0 -2
- package/esm/csi.js +4 -11
- package/esm/csi.js.map +1 -1
- package/esm/htsget.d.ts +16 -0
- package/esm/htsget.js +73 -53
- package/esm/htsget.js.map +1 -1
- package/esm/index.d.ts +1 -0
- package/esm/indexFile.d.ts +2 -3
- package/esm/indexFile.js.map +1 -1
- package/esm/sam.js +8 -3
- package/esm/sam.js.map +1 -1
- package/esm/util.d.ts +11 -3
- package/esm/util.js +35 -8
- package/esm/util.js.map +1 -1
- package/esm/virtualOffset.d.ts +8 -3
- package/esm/virtualOffset.js +0 -3
- package/esm/virtualOffset.js.map +1 -1
- package/package.json +3 -3
- package/src/bai.ts +42 -20
- package/src/bamFile.ts +86 -38
- package/src/chunk.ts +0 -8
- package/src/csi.ts +4 -10
- package/src/htsget.ts +117 -62
- package/src/index.ts +2 -0
- package/src/indexFile.ts +2 -3
- package/src/sam.ts +8 -3
- package/src/util.ts +44 -11
- package/src/virtualOffset.ts +9 -8
- package/dist/long.d.ts +0 -1
- package/dist/long.js +0 -17
- package/dist/long.js.map +0 -1
- package/esm/long.d.ts +0 -1
- package/esm/long.js +0 -14
- package/esm/long.js.map +0 -1
- package/src/long.ts +0 -16
package/esm/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,YAAY,CAAA;AAC9B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,YAAY,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AA8BlD,MAAM,UAAU,cAAc,CAAC,MAAe,EAAE,MAAqB;IACnE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAA;IACvB,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACZ,OAAO,MAAM,CAAA;IACf,CAAC;IAED,0DAA0D;IAC1D,IAAI,QAAiB,CAAA;IACrB,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,WAAW,GAAG,MAAM,CAAC,aAAa,CAAA;QACxC,MAAM,UAAU,GAAG,MAAM,CAAC,YAAY,CAAA;QACtC,QAAQ,GAAG,EAAE,CAAA;QACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC3B,MAAM,KAAK,GAAG,MAAM,CAA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AAC5E,6EAA6E;AAC7E,iDAAiD;AACjD,MAAM,UAAU,aAAa,CAC3B,OAAY,EACZ,KAAa,EACb,GAAW,EACX,GAAW,EACX,MAAW,EAAE;IAEb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/C,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAE,CAAA;QACrB,IAAI,CAAC,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;YACvB,IAAI,CAAC,CAAC,KAAK,IAAI,GAAG,EAAE,CAAC;gBACnB,MAAK;YACP,CAAC;iBAAM,IAAI,CAAC,CAAC,GAAG,IAAI,GAAG,EAAE,CAAC;gBACxB,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YACb,CAAC;QACH,CAAC;aAAM,IAAI,CAAC,CAAC,MAAM,GAAG,KAAK,EAAE,CAAC;YAC5B,MAAK;QACP,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
package/esm/virtualOffset.d.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The two coordinates a virtual offset packs, without the `blockPos:dataPos`
|
|
3
|
+
* string form. What every consumer that only compares positions needs — the
|
|
4
|
+
* BAI linear index stores these as raw numbers and materializes no object.
|
|
5
|
+
*/
|
|
6
|
+
export interface OffsetCoords {
|
|
2
7
|
blockPosition: number;
|
|
3
8
|
dataPosition: number;
|
|
9
|
+
}
|
|
10
|
+
export interface Offset extends OffsetCoords {
|
|
4
11
|
toString(): string;
|
|
5
|
-
compareTo(arg: Offset): number;
|
|
6
12
|
}
|
|
7
13
|
export declare class VirtualOffset {
|
|
8
14
|
blockPosition: number;
|
|
9
15
|
dataPosition: number;
|
|
10
16
|
constructor(blockPosition: number, dataPosition: number);
|
|
11
17
|
toString(): string;
|
|
12
|
-
compareTo(b: VirtualOffset): number;
|
|
13
18
|
}
|
|
14
19
|
export declare function fromBytes(bytes: Uint8Array, offset?: number): VirtualOffset;
|
package/esm/virtualOffset.js
CHANGED
|
@@ -8,9 +8,6 @@ export class VirtualOffset {
|
|
|
8
8
|
toString() {
|
|
9
9
|
return `${this.blockPosition}:${this.dataPosition}`;
|
|
10
10
|
}
|
|
11
|
-
compareTo(b) {
|
|
12
|
-
return (this.blockPosition - b.blockPosition || this.dataPosition - b.dataPosition);
|
|
13
|
-
}
|
|
14
11
|
}
|
|
15
12
|
export function fromBytes(bytes, offset = 0) {
|
|
16
13
|
return new VirtualOffset(bytes[offset + 7] * 0x10000000000 +
|
package/esm/virtualOffset.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtualOffset.js","sourceRoot":"","sources":["../src/virtualOffset.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"virtualOffset.js","sourceRoot":"","sources":["../src/virtualOffset.ts"],"names":[],"mappings":"AAcA,MAAM,OAAO,aAAa;IACjB,aAAa,CAAQ;IACrB,YAAY,CAAQ;IAC3B,YAAY,aAAqB,EAAE,YAAoB;QACrD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA,CAAC,wCAAwC;QAC3E,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA,CAAC,sCAAsC;IACzE,CAAC;IAED,QAAQ;QACN,OAAO,GAAG,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,YAAY,EAAE,CAAA;IACrD,CAAC;CACF;AACD,MAAM,UAAU,SAAS,CAAC,KAAiB,EAAE,MAAM,GAAG,CAAC;IACrD,OAAO,IAAI,aAAa,CACtB,KAAK,CAAC,MAAM,GAAG,CAAC,CAAE,GAAG,aAAa;QAChC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAE,GAAG,WAAW;QAChC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAE,GAAG,SAAS;QAC9B,KAAK,CAAC,MAAM,GAAG,CAAC,CAAE,GAAG,OAAO;QAC5B,KAAK,CAAC,MAAM,GAAG,CAAC,CAAE,GAAG,KAAK;QAC1B,KAAK,CAAC,MAAM,GAAG,CAAC,CAAE,EACpB,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAE,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAE,CAC3C,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gmod/bam",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.7.0",
|
|
4
4
|
"packageManager": "pnpm@11.15.1",
|
|
5
5
|
"description": "Parser for BAM and BAM index (bai) files",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"build": "pnpm build:esm && pnpm build:es5",
|
|
40
40
|
"benchonly": "vitest bench",
|
|
41
41
|
"bench": "./scripts/build-both-branches.sh \"$BRANCH1\" \"$BRANCH2\" && vitest bench",
|
|
42
|
-
"version": "
|
|
42
|
+
"version": "git-cliff --tag v$npm_package_version --unreleased --prepend CHANGELOG.md && git add CHANGELOG.md"
|
|
43
43
|
},
|
|
44
44
|
"keywords": [
|
|
45
45
|
"bionode",
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
"eslint": "^10.4.1",
|
|
61
61
|
"eslint-plugin-import-x": "^4.16.2",
|
|
62
62
|
"eslint-plugin-unicorn": "^65.0.0",
|
|
63
|
+
"git-cliff": "^2.13.1",
|
|
63
64
|
"prettier": "^3.8.3",
|
|
64
65
|
"rimraf": "^6.1.3",
|
|
65
|
-
"standard-changelog": "^7.0.1",
|
|
66
66
|
"typescript": "^6.0.3",
|
|
67
67
|
"typescript-eslint": "^8.61.0",
|
|
68
68
|
"vitest": "^4.1.8"
|
package/src/bai.ts
CHANGED
|
@@ -7,8 +7,17 @@ import type { ParsedIndexBase, RefIndex } from './indexFile.ts'
|
|
|
7
7
|
import type { BaseOpts } from './util.ts'
|
|
8
8
|
import type { VirtualOffset } from './virtualOffset.ts'
|
|
9
9
|
|
|
10
|
+
// The linear index as two parallel Float64Arrays rather than an array of
|
|
11
|
+
// VirtualOffset objects. A human-sized reference has one entry per 16kb window
|
|
12
|
+
// — ~15k for chr1 — and an object apiece costs roughly an order of magnitude
|
|
13
|
+
// more memory than the packed form, retained for as long as memoizeByRefId
|
|
14
|
+
// holds the reference. Both consumers want the raw numbers anyway: indexCov and
|
|
15
|
+
// clampChunkEnds read blockPosition only, and getLowestChunk builds the one
|
|
16
|
+
// VirtualOffset a query actually needs. Same shape as bgzf-filehandle's
|
|
17
|
+
// GziIndex, for the same reason.
|
|
10
18
|
interface BaiRefIndex extends RefIndex {
|
|
11
|
-
|
|
19
|
+
linearBlockPositions: Float64Array
|
|
20
|
+
linearDataPositions: Float64Array
|
|
12
21
|
}
|
|
13
22
|
|
|
14
23
|
interface BaiParsed extends ParsedIndexBase<BaiRefIndex> {
|
|
@@ -142,19 +151,27 @@ export default class BAI extends IndexFile<BaiParsed> {
|
|
|
142
151
|
|
|
143
152
|
const linearCount = dataView.getInt32(curr, true)
|
|
144
153
|
curr += 4
|
|
145
|
-
const
|
|
154
|
+
const linearBlockPositions = new Float64Array(linearCount)
|
|
155
|
+
const linearDataPositions = new Float64Array(linearCount)
|
|
146
156
|
for (let j = 0; j < linearCount; j++) {
|
|
147
|
-
|
|
157
|
+
// a virtual offset is a 48-bit block position in the high bytes and a
|
|
158
|
+
// 16-bit data position in the low two
|
|
159
|
+
linearBlockPositions[j] =
|
|
160
|
+
bytes[curr + 7]! * 0x10000000000 +
|
|
161
|
+
bytes[curr + 6]! * 0x100000000 +
|
|
162
|
+
bytes[curr + 5]! * 0x1000000 +
|
|
163
|
+
bytes[curr + 4]! * 0x10000 +
|
|
164
|
+
bytes[curr + 3]! * 0x100 +
|
|
165
|
+
bytes[curr + 2]!
|
|
166
|
+
linearDataPositions[j] = (bytes[curr + 1]! << 8) | bytes[curr]!
|
|
148
167
|
curr += 8
|
|
149
168
|
}
|
|
150
169
|
|
|
151
|
-
clampChunkEnds(
|
|
152
|
-
Object.values(binIndex).flat(),
|
|
153
|
-
linearIndex.map(v => v.blockPosition),
|
|
154
|
-
)
|
|
170
|
+
clampChunkEnds(Object.values(binIndex).flat(), linearBlockPositions)
|
|
155
171
|
return {
|
|
156
172
|
binIndex,
|
|
157
|
-
|
|
173
|
+
linearBlockPositions,
|
|
174
|
+
linearDataPositions,
|
|
158
175
|
stats,
|
|
159
176
|
}
|
|
160
177
|
}
|
|
@@ -162,7 +179,6 @@ export default class BAI extends IndexFile<BaiParsed> {
|
|
|
162
179
|
return {
|
|
163
180
|
bai: true,
|
|
164
181
|
firstDataLine,
|
|
165
|
-
maxBlockSize: 1 << 16,
|
|
166
182
|
indices: memoizeByRefId(getIndices),
|
|
167
183
|
refCount,
|
|
168
184
|
}
|
|
@@ -182,17 +198,18 @@ export default class BAI extends IndexFile<BaiParsed> {
|
|
|
182
198
|
if (!seqIdx) {
|
|
183
199
|
return []
|
|
184
200
|
}
|
|
185
|
-
const {
|
|
186
|
-
|
|
201
|
+
const { linearBlockPositions, stats } = seqIdx
|
|
202
|
+
const nintv = linearBlockPositions.length
|
|
203
|
+
if (nintv === 0) {
|
|
187
204
|
return []
|
|
188
205
|
}
|
|
189
|
-
const e = end === undefined ? (
|
|
206
|
+
const e = end === undefined ? (nintv - 1) * v : roundUp(end, v)
|
|
190
207
|
const s = start === undefined ? 0 : roundDown(start, v)
|
|
191
208
|
const depths: IndexCovEntry[] = range
|
|
192
209
|
? new Array((e - s) / v)
|
|
193
|
-
: new Array(
|
|
194
|
-
const totalSize =
|
|
195
|
-
if (e > (
|
|
210
|
+
: new Array(nintv - 1)
|
|
211
|
+
const totalSize = linearBlockPositions[nintv - 1]!
|
|
212
|
+
if (e > (nintv - 1) * v) {
|
|
196
213
|
throw new Error('query outside of range of linear index')
|
|
197
214
|
}
|
|
198
215
|
// Scale the block-delta into a read count as we go, rather than building the
|
|
@@ -200,9 +217,9 @@ export default class BAI extends IndexFile<BaiParsed> {
|
|
|
200
217
|
// multiply-then-divide order: hoisting lineCount/totalSize into a factor
|
|
201
218
|
// reassociates the arithmetic and shifts scores by an ulp.
|
|
202
219
|
const lineCount = stats?.lineCount ?? 0
|
|
203
|
-
let currentPos =
|
|
220
|
+
let currentPos = linearBlockPositions[s / v]!
|
|
204
221
|
for (let i = s / v, j = 0; i < e / v; i++, j++) {
|
|
205
|
-
const nextPos =
|
|
222
|
+
const nextPos = linearBlockPositions[i + 1]!
|
|
206
223
|
depths[j] = {
|
|
207
224
|
score: ((nextPos - currentPos) * lineCount) / totalSize,
|
|
208
225
|
start: i * v,
|
|
@@ -221,8 +238,13 @@ export default class BAI extends IndexFile<BaiParsed> {
|
|
|
221
238
|
// contain alignments in the region. Linear index entries are monotonically
|
|
222
239
|
// non-decreasing, so the first entry at minLin is the minimum.
|
|
223
240
|
protected getLowestChunk(refIndex: BaiRefIndex, min: number) {
|
|
224
|
-
const {
|
|
225
|
-
const
|
|
226
|
-
return
|
|
241
|
+
const { linearBlockPositions, linearDataPositions } = refIndex
|
|
242
|
+
const i = Math.min(min >> BAI_LINEAR_SHIFT, linearBlockPositions.length - 1)
|
|
243
|
+
return i < 0
|
|
244
|
+
? undefined
|
|
245
|
+
: {
|
|
246
|
+
blockPosition: linearBlockPositions[i]!,
|
|
247
|
+
dataPosition: linearDataPositions[i]!,
|
|
248
|
+
}
|
|
227
249
|
}
|
|
228
250
|
}
|
package/src/bamFile.ts
CHANGED
|
@@ -37,6 +37,12 @@ export const BAM_MAGIC = 21840194
|
|
|
37
37
|
|
|
38
38
|
const blockLen = 1 << 16
|
|
39
39
|
|
|
40
|
+
// Ceiling on the header read. A million contigs is roughly 10MB of compressed
|
|
41
|
+
// @SQ lines and ref-seq table, so anything past this is a corrupt header
|
|
42
|
+
// claiming a huge n_ref rather than a real one, and growing the read further
|
|
43
|
+
// just downloads the file.
|
|
44
|
+
const maxHeaderReadLen = 32 * 1024 * 1024
|
|
45
|
+
|
|
40
46
|
function resolveFilehandle(
|
|
41
47
|
filehandle?: GenericFilehandle,
|
|
42
48
|
path?: string,
|
|
@@ -226,50 +232,72 @@ export default class BamFile<T extends BamRecordLike = BAMFeature> {
|
|
|
226
232
|
|
|
227
233
|
async getHeaderPre(opts: BaseOpts = {}) {
|
|
228
234
|
if (!this.index) {
|
|
229
|
-
|
|
235
|
+
// Only reachable via `new BamFile({htsget: true})` used directly rather
|
|
236
|
+
// than through HtsgetFile, which overrides this. Throwing rather than
|
|
237
|
+
// returning undefined keeps `| undefined` off getHeader()'s public type,
|
|
238
|
+
// and makes that misuse loud instead of silently answering every query
|
|
239
|
+
// with zero records (getSeqId would find no chrToIndex).
|
|
240
|
+
throw new Error(
|
|
241
|
+
'no index to read a header from: use HtsgetFile for htsget sources',
|
|
242
|
+
)
|
|
230
243
|
}
|
|
231
244
|
const indexData = await this.index.parse(opts)
|
|
232
245
|
|
|
233
|
-
//
|
|
234
|
-
//
|
|
235
|
-
|
|
246
|
+
// The records start at firstDataLine, so reading up to it plus the bgzf
|
|
247
|
+
// block straddling it covers the header. It is undefined when the index
|
|
248
|
+
// records no data at all (header-only BAM), and it undershoots when the
|
|
249
|
+
// index leaves offsets unset, so grow the read until the ref-seq table
|
|
250
|
+
// parses. Never readFile() here: on a remote BAM that is a whole-file
|
|
251
|
+
// download to read a header.
|
|
252
|
+
let readLen =
|
|
236
253
|
indexData.firstDataLine === undefined
|
|
237
|
-
?
|
|
254
|
+
? blockLen
|
|
238
255
|
: indexData.firstDataLine.blockPosition + blockLen
|
|
239
256
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
257
|
+
let samHeader
|
|
258
|
+
let atEof = false
|
|
259
|
+
while (samHeader === undefined && !atEof && readLen <= maxHeaderReadLen) {
|
|
260
|
+
const buffer = await this.bam.read(readLen, 0, { signal: opts.signal })
|
|
261
|
+
// a short read means readLen ran past the end of the file, so there are
|
|
262
|
+
// no more bytes to grow into
|
|
263
|
+
atEof = buffer.length < readLen
|
|
264
|
+
samHeader = this.applyHeader(await unzip(buffer))
|
|
265
|
+
readLen *= 2
|
|
266
|
+
}
|
|
267
|
+
if (samHeader === undefined) {
|
|
268
|
+
throw new Error('Insufficient data for reference sequences')
|
|
269
|
+
}
|
|
270
|
+
return samHeader
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Installs the header text and ref name/id maps from the start of a
|
|
275
|
+
* decompressed BAM stream, returning the parsed SAM header lines. Returns
|
|
276
|
+
* undefined if the stream is cut off partway through the ref-seq table, so
|
|
277
|
+
* the caller can retry with more data.
|
|
278
|
+
*/
|
|
279
|
+
protected applyHeader(uncba: Uint8Array) {
|
|
245
280
|
const dataView = new DataView(
|
|
246
281
|
uncba.buffer,
|
|
247
282
|
uncba.byteOffset,
|
|
248
283
|
uncba.byteLength,
|
|
249
284
|
)
|
|
250
|
-
|
|
251
285
|
if (dataView.getInt32(0, true) !== BAM_MAGIC) {
|
|
252
286
|
throw new Error('Not a BAM file')
|
|
253
287
|
}
|
|
254
288
|
const headLen = dataView.getInt32(4, true)
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
parsed = parseRefSeqs(uncba, refSeqStart, this.renameRefSeq)
|
|
266
|
-
}
|
|
267
|
-
if (!parsed) {
|
|
268
|
-
throw new Error('Insufficient data for reference sequences')
|
|
289
|
+
const parsed = parseRefSeqs(uncba, headLen + 8, this.renameRefSeq)
|
|
290
|
+
let samHeader
|
|
291
|
+
if (parsed) {
|
|
292
|
+
const headerText = new TextDecoder('utf8').decode(
|
|
293
|
+
uncba.subarray(8, 8 + headLen),
|
|
294
|
+
)
|
|
295
|
+
this.header = headerText
|
|
296
|
+
this.chrToIndex = parsed.chrToIndex
|
|
297
|
+
this.indexToChr = parsed.indexToChr
|
|
298
|
+
samHeader = parseHeaderText(headerText)
|
|
269
299
|
}
|
|
270
|
-
|
|
271
|
-
this.indexToChr = parsed.indexToChr
|
|
272
|
-
return parseHeaderText(this.header)
|
|
300
|
+
return samHeader
|
|
273
301
|
}
|
|
274
302
|
|
|
275
303
|
getHeader(opts?: BaseOpts) {
|
|
@@ -491,13 +519,26 @@ export default class BamFile<T extends BamRecordLike = BAMFeature> {
|
|
|
491
519
|
const chunks = res[i]!
|
|
492
520
|
for (let j = 0, jl = chunks.length; j < jl; j++) {
|
|
493
521
|
const m = chunks[j]!
|
|
494
|
-
|
|
522
|
+
// Key on the virtual-offset span — the same key _cachedChunkFeatures
|
|
523
|
+
// uses. Chunk.toString() also folds in `bin` and fetchedSize(), which
|
|
524
|
+
// keeps two chunks covering an identical span apart here even though
|
|
525
|
+
// the cache below collapses them, so their records came back twice.
|
|
526
|
+
map.set(chunkCacheKey(m), m)
|
|
495
527
|
}
|
|
496
528
|
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
529
|
+
const mateChunks = [...map.values()]
|
|
530
|
+
|
|
531
|
+
// Bounded for the reason ADR 0008 bounds the main query path: a viewAsPairs
|
|
532
|
+
// query over a busy region resolves to many distinct mate chunks, and an
|
|
533
|
+
// unbounded fan-out inflates every one of them at once. Same inline pool
|
|
534
|
+
// shape as _fetchChunkFeatures — ADR 0009 measured extracting a shared
|
|
535
|
+
// mapConcurrent helper at ~11% on the hot path, so it stays inline.
|
|
536
|
+
const mateFeatLists = new Array<T[]>(mateChunks.length)
|
|
537
|
+
let next = 0
|
|
538
|
+
const readNext = async () => {
|
|
539
|
+
while (next < mateChunks.length) {
|
|
540
|
+
const ci = next++
|
|
541
|
+
const features = await this._cachedChunkFeatures(mateChunks[ci]!, opts)
|
|
501
542
|
const mateRecs = [] as T[]
|
|
502
543
|
for (let i = 0, l = features.length; i < l; i++) {
|
|
503
544
|
const feature = features[i]!
|
|
@@ -508,9 +549,11 @@ export default class BamFile<T extends BamRecordLike = BAMFeature> {
|
|
|
508
549
|
mateRecs.push(feature)
|
|
509
550
|
}
|
|
510
551
|
}
|
|
511
|
-
|
|
512
|
-
}
|
|
513
|
-
|
|
552
|
+
mateFeatLists[ci] = mateRecs
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
const workers = Math.min(MAX_CONCURRENT_CHUNK_READS, mateChunks.length)
|
|
556
|
+
await Promise.all(Array.from({ length: workers }, () => readNext()))
|
|
514
557
|
return mateFeatLists.flat()
|
|
515
558
|
}
|
|
516
559
|
|
|
@@ -538,10 +581,15 @@ export default class BamFile<T extends BamRecordLike = BAMFeature> {
|
|
|
538
581
|
}
|
|
539
582
|
}
|
|
540
583
|
|
|
584
|
+
// cpositions/dpositions are `ArrayLike`, not `number[]`, because the wasm
|
|
585
|
+
// decompressor produces them as Float64Arrays — @gmod/bgzf-filehandle spreads
|
|
586
|
+
// them into plain arrays on the way out, and this signature is what lets that
|
|
587
|
+
// copy be dropped there without a change here. Only indexed reads and
|
|
588
|
+
// `.length` are used below either way.
|
|
541
589
|
readBamFeatures(
|
|
542
590
|
ba: Uint8Array,
|
|
543
|
-
cpositions: number
|
|
544
|
-
dpositions: number
|
|
591
|
+
cpositions: ArrayLike<number>,
|
|
592
|
+
dpositions: ArrayLike<number>,
|
|
545
593
|
chunk: Chunk,
|
|
546
594
|
) {
|
|
547
595
|
let blockStart = 0
|
package/src/chunk.ts
CHANGED
|
@@ -29,14 +29,6 @@ export default class Chunk {
|
|
|
29
29
|
}, fetchedSize ${this.fetchedSize()})`
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
compareTo(b: Chunk) {
|
|
33
|
-
return (
|
|
34
|
-
this.minv.compareTo(b.minv) ||
|
|
35
|
-
this.maxv.compareTo(b.maxv) ||
|
|
36
|
-
this.bin - b.bin
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
32
|
fetchedSize() {
|
|
41
33
|
return this.endPosition - this.minv.blockPosition
|
|
42
34
|
}
|
package/src/csi.ts
CHANGED
|
@@ -83,16 +83,12 @@ export default class CSI extends IndexFile {
|
|
|
83
83
|
bytes.byteOffset,
|
|
84
84
|
bytes.byteLength,
|
|
85
85
|
)
|
|
86
|
-
|
|
86
|
+
// CSI\1 and CSI\2 are parsed identically here — v2 only adds fields this
|
|
87
|
+
// reader doesn't consume — so the version is validated, not retained.
|
|
87
88
|
const magic = dataView.getUint32(0, true)
|
|
88
|
-
|
|
89
|
-
if (magic === CSI1_MAGIC) {
|
|
90
|
-
csiVersion = 1
|
|
91
|
-
} else if (magic === CSI2_MAGIC) {
|
|
92
|
-
csiVersion = 2
|
|
93
|
-
} else {
|
|
94
|
-
throw new Error(`Not a CSI file ${magic}`)
|
|
89
|
+
if (magic !== CSI1_MAGIC && magic !== CSI2_MAGIC) {
|
|
95
90
|
// TODO: do we need to support big-endian CSI files?
|
|
91
|
+
throw new Error(`Not a CSI file ${magic}`)
|
|
96
92
|
}
|
|
97
93
|
|
|
98
94
|
this.minShift = dataView.getInt32(4, true)
|
|
@@ -170,12 +166,10 @@ export default class CSI extends IndexFile {
|
|
|
170
166
|
}
|
|
171
167
|
|
|
172
168
|
return {
|
|
173
|
-
csiVersion,
|
|
174
169
|
firstDataLine,
|
|
175
170
|
indices: memoizeByRefId(getIndices),
|
|
176
171
|
refCount,
|
|
177
172
|
csi: true,
|
|
178
|
-
maxBlockSize: 1 << 16,
|
|
179
173
|
...aux,
|
|
180
174
|
}
|
|
181
175
|
}
|