@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.
Files changed (71) hide show
  1. package/README.md +109 -98
  2. package/dist/bai.d.ts +6 -3
  3. package/dist/bai.js +32 -16
  4. package/dist/bai.js.map +1 -1
  5. package/dist/bamFile.d.ts +16 -3
  6. package/dist/bamFile.js +83 -36
  7. package/dist/bamFile.js.map +1 -1
  8. package/dist/chunk.d.ts +0 -1
  9. package/dist/chunk.js +0 -5
  10. package/dist/chunk.js.map +1 -1
  11. package/dist/csi.d.ts +0 -2
  12. package/dist/csi.js +4 -11
  13. package/dist/csi.js.map +1 -1
  14. package/dist/htsget.d.ts +16 -0
  15. package/dist/htsget.js +72 -52
  16. package/dist/htsget.js.map +1 -1
  17. package/dist/index.d.ts +1 -0
  18. package/dist/indexFile.d.ts +2 -3
  19. package/dist/indexFile.js.map +1 -1
  20. package/dist/sam.js +8 -3
  21. package/dist/sam.js.map +1 -1
  22. package/dist/util.d.ts +11 -3
  23. package/dist/util.js +35 -8
  24. package/dist/util.js.map +1 -1
  25. package/dist/virtualOffset.d.ts +8 -3
  26. package/dist/virtualOffset.js +0 -3
  27. package/dist/virtualOffset.js.map +1 -1
  28. package/esm/bai.d.ts +6 -3
  29. package/esm/bai.js +32 -16
  30. package/esm/bai.js.map +1 -1
  31. package/esm/bamFile.d.ts +16 -3
  32. package/esm/bamFile.js +83 -36
  33. package/esm/bamFile.js.map +1 -1
  34. package/esm/chunk.d.ts +0 -1
  35. package/esm/chunk.js +0 -5
  36. package/esm/chunk.js.map +1 -1
  37. package/esm/csi.d.ts +0 -2
  38. package/esm/csi.js +4 -11
  39. package/esm/csi.js.map +1 -1
  40. package/esm/htsget.d.ts +16 -0
  41. package/esm/htsget.js +73 -53
  42. package/esm/htsget.js.map +1 -1
  43. package/esm/index.d.ts +1 -0
  44. package/esm/indexFile.d.ts +2 -3
  45. package/esm/indexFile.js.map +1 -1
  46. package/esm/sam.js +8 -3
  47. package/esm/sam.js.map +1 -1
  48. package/esm/util.d.ts +11 -3
  49. package/esm/util.js +35 -8
  50. package/esm/util.js.map +1 -1
  51. package/esm/virtualOffset.d.ts +8 -3
  52. package/esm/virtualOffset.js +0 -3
  53. package/esm/virtualOffset.js.map +1 -1
  54. package/package.json +3 -3
  55. package/src/bai.ts +42 -20
  56. package/src/bamFile.ts +86 -38
  57. package/src/chunk.ts +0 -8
  58. package/src/csi.ts +4 -10
  59. package/src/htsget.ts +117 -62
  60. package/src/index.ts +2 -0
  61. package/src/indexFile.ts +2 -3
  62. package/src/sam.ts +8 -3
  63. package/src/util.ts +44 -11
  64. package/src/virtualOffset.ts +9 -8
  65. package/dist/long.d.ts +0 -1
  66. package/dist/long.js +0 -17
  67. package/dist/long.js.map +0 -1
  68. package/esm/long.d.ts +0 -1
  69. package/esm/long.js +0 -14
  70. package/esm/long.js.map +0 -1
  71. package/src/long.ts +0 -16
package/README.md CHANGED
@@ -1,10 +1,12 @@
1
1
  [![NPM version](https://img.shields.io/npm/v/@gmod/bam.svg?style=flat-square)](https://npmjs.org/package/@gmod/bam)
2
2
  ![Build Status](https://img.shields.io/github/actions/workflow/status/GMOD/bam-js/publish.yml?branch=main)
3
3
 
4
+ Parser for BAM files and their BAI/CSI indexes.
5
+
4
6
  ## Install
5
7
 
6
8
  ```bash
7
- $ npm install --save @gmod/bam
9
+ npm install @gmod/bam
8
10
  ```
9
11
 
10
12
  ## Usage
@@ -12,90 +14,104 @@ $ npm install --save @gmod/bam
12
14
  ```typescript
13
15
  import { BamFile } from '@gmod/bam'
14
16
 
15
- const t = new BamFile({
16
- bamPath: 'test.bam',
17
- })
18
-
19
- // note: it's required to first run getHeader before any getRecordsForRange
20
- const header = await t.getHeader()
17
+ const bam = new BamFile({ bamPath: 'test.bam' })
21
18
 
22
- // this would get same records as samtools view ctgA:1-50000
23
- const records = await t.getRecordsForRange('ctgA', 0, 50000)
19
+ // same records as `samtools view test.bam ctgA:1-50000`
20
+ const records = await bam.getRecordsForRange('ctgA', 0, 50000)
24
21
  ```
25
22
 
26
- The `bamPath` argument only works on nodejs. In the browser, you should pass
27
- `bamFilehandle` with a generic-filehandle2 e.g. `RemoteFile`
23
+ Coordinates are 0-based half-open (not the same as `samtools view` inputs).
24
+ `bamPath` reads a local file, so it is node-only; in the browser pass a
25
+ filehandle or URL instead:
28
26
 
29
27
  ```typescript
30
- import { RemoteFile } from 'generic-filehandle2'
31
28
  import { BamFile } from '@gmod/bam'
32
29
 
33
30
  const bam = new BamFile({
34
- bamFilehandle: new RemoteFile('yourfile.bam'), // or a full http url
35
- baiFilehandle: new RemoteFile('yourfile.bam.bai'), // or a full http url
31
+ bamUrl: 'https://example.com/yourfile.bam',
32
+ baiUrl: 'https://example.com/yourfile.bam.bai',
36
33
  })
37
34
  ```
38
35
 
39
- Input are 0-based half-open coordinates (note: not the same as samtools view
40
- coordinate inputs!)
41
-
42
36
  ## Usage with htsget
43
37
 
44
- Since 1.0.41 we support usage of the htsget protocol
45
-
46
- Here is a small code snippet for this
47
-
48
38
  ```typescript
49
39
  import { HtsgetFile } from '@gmod/bam'
50
40
 
51
- const ti = new HtsgetFile({
41
+ const bam = new HtsgetFile({
52
42
  baseUrl: 'http://htsnexus.rnd.dnanex.us/v1/reads',
53
43
  trackId: 'BroadHiSeqX_b37/NA12878',
54
44
  })
55
- await ti.getHeader()
56
- const records = await ti.getRecordsForRange('1', 2000000, 2000001)
45
+ const records = await bam.getRecordsForRange('1', 2000000, 2000001)
57
46
  ```
58
47
 
59
- Let us know if it doesn't work for your use case.
48
+ htsget fetches the server's range as-is, so `viewAsPairs`, `pairAcrossChr` and
49
+ `maxInsertSize` are ignored.
60
50
 
61
- Caveat: htsget `getRecordsForRange` does not honor `viewAsPairs`,
62
- `pairAcrossChr`, or `maxInsertSize`. The range is fetched from the server as-is.
51
+ For a server that requires authentication, pass a `fetch` that adds the bearer
52
+ token the spec calls for:
63
53
 
64
- ## Documentation
65
-
66
- ### BAM constructor
67
-
68
- The BAM class constructor accepts arguments
69
-
70
- - `bamPath`/`bamUrl`/`bamFilehandle` - a local file path, remote URL string, or
71
- a class object with a read method
72
- - `csiPath`/`csiUrl`/`csiFilehandle` - a CSI index for the BAM file, required
73
- for long chromosomes greater than 2^29 in length
74
- - `baiPath`/`baiUrl`/`baiFilehandle` - a BAI index for the BAM file
75
- - `recordClass` - a custom class extending BamRecord to use for records (see
76
- Custom BamRecord class section below)
77
-
78
- Note: filehandles implement the Filehandle interface from generic-filehandle2.
79
- The `path` and `url` arguments are convenience wrappers for `LocalFile` and
80
- `RemoteFile`.
81
-
82
- ### async getRecordsForRange(refName, start, end, opts)
54
+ ```typescript
55
+ const bam = new HtsgetFile({
56
+ baseUrl: 'https://htsget.example.com/reads',
57
+ trackId: 'NA12878',
58
+ fetch: (url, init) => {
59
+ const headers = new Headers(init?.headers)
60
+ headers.set('authorization', `Bearer ${token}`)
61
+ return fetch(url, { ...init, headers })
62
+ },
63
+ })
64
+ ```
83
65
 
84
- Note: requires calling `getHeader` first.
66
+ Your `fetch` is called for the ticket request and for the data-block urls the
67
+ ticket points at, so only attach credentials to hosts you trust — data blocks
68
+ may live on a third-party host, and the spec has servers put whatever those
69
+ need in each url's own `headers` field, which is applied either way.
85
70
 
86
- - `refName` - a string for the chrom to fetch from
87
- - `start` - a 0-based half open start coordinate
88
- - `end` - a 0-based half open end coordinate
89
- - `opts.signal` - an AbortSignal to indicate stop processing
90
- - `opts.viewAsPairs` - re-dispatches requests to find mate pairs. default: false
91
- - `opts.pairAcrossChr` - control the viewAsPairs option behavior to pair across
92
- chromosomes. default: false
93
- - `opts.maxInsertSize` - control the viewAsPairs option behavior to limit
94
- distance within a chromosome to fetch. default: 200kb
71
+ ## Documentation
95
72
 
96
- Records come back unfiltered. Filter the returned array yourself — the flag
97
- helpers (`record.isSecondary()` and friends) and `record.getTag(name)` cover it,
98
- and `getTag` decodes just the one tag rather than every tag on the read:
73
+ ### BamFile constructor
74
+
75
+ - `bamPath`/`bamUrl`/`bamFilehandle` - local path, remote URL, or a
76
+ generic-filehandle2 object
77
+ - `baiPath`/`baiUrl`/`baiFilehandle` - BAI index. Defaults to the `.bai` sibling
78
+ of `bamPath`/`bamUrl`
79
+ - `csiPath`/`csiUrl`/`csiFilehandle` - CSI index, required for chromosomes
80
+ longer than 2^29
81
+ - `renameRefSeqs` - `(refName: string) => string` applied to header ref names
82
+ - `recordClass` - custom class extending `BamRecord` (see below)
83
+ - `maxCacheBytes` - budget for the parsed-chunk cache, in decompressed bytes.
84
+ default: 100MB
85
+
86
+ The `path`/`url` forms are convenience wrappers for generic-filehandle2's
87
+ `LocalFile` and `RemoteFile`.
88
+
89
+ ### HtsgetFile constructor
90
+
91
+ - `baseUrl` - htsget reads endpoint, e.g. `https://htsget.example.com/reads`
92
+ - `trackId` - id of the resource under `baseUrl`
93
+ - `fetch` - `fetch` replacement for adding auth headers (see above)
94
+ - `recordClass` - custom class extending `BamRecord` (see below)
95
+
96
+ ### async getRecordsForRange(refName, start, end, opts?)
97
+
98
+ - `refName` - chromosome to fetch from
99
+ - `start`/`end` - 0-based half-open coordinates
100
+ - `opts.signal` - `AbortSignal` to stop processing
101
+ - `opts.viewAsPairs` - re-dispatch requests to find mate pairs. default: false
102
+ - `opts.pairAcrossChr` - let `viewAsPairs` pair across chromosomes. default:
103
+ false
104
+ - `opts.maxInsertSize` - distance limit for `viewAsPairs` within a chromosome.
105
+ default: 200kb
106
+ - `opts.onProgress` - `(bytesDownloaded, totalBytes?) => void`, called per BGZF
107
+ chunk for a determinate progress bar
108
+
109
+ Returned records are cached and shared between overlapping queries, so treat
110
+ them as read-only — attaching your own fields to a record mutates it for every
111
+ other query holding it.
112
+
113
+ Records come back unfiltered. Filter them yourself with the flag helpers and
114
+ `getTag`, which decodes one tag instead of all of them:
99
115
 
100
116
  ```typescript
101
117
  const records = (await bam.getRecordsForRange('chr1', 0, 100000)).filter(
@@ -105,34 +121,35 @@ const records = (await bam.getRecordsForRange('chr1', 0, 100000)).filter(
105
121
 
106
122
  ### async getHeader(opts?)
107
123
 
108
- Fetches the header from `BamFile` or `HtsgetFile`. Must be called before
109
- `getRecordsForRange`.
124
+ Returns the parsed SAM header. Called automatically by the query methods and
125
+ cached, so you only need it when you want the header itself.
126
+ `getHeaderText(opts?)` returns the raw header string.
127
+
128
+ ### async indexCov(refName, start?, end?)
110
129
 
111
- ### async indexCov(refName, start, end)
130
+ Returns `{start, end, score}` features estimating read density over 16kb
131
+ windows, derived from the BAI linear index. CSI has no linear index, so a
132
+ CSI-indexed file returns `[]`.
112
133
 
113
- - `refName` - a string for the chrom to fetch from
114
- - `start` - a 0-based half open start coordinate (optional)
115
- - `end` - a 0-based half open end coordinate (optional)
134
+ ### async lineCount(refName)
116
135
 
117
- Returns features of the form {start, end, score} containing estimated feature
118
- density across 16kb windows in the genome. BAI-only: derived from the linear
119
- index, which CSI omits — calling on a CSI-indexed file returns `[]`.
136
+ Number of records on `refName` from the index's pseudo-bin (bin 37450 in BAI,
137
+ `n_mapped` in the SAM spec), or 0 if `refName` is absent.
120
138
 
121
- ### async lineCount(refName: string)
139
+ ### async hasRefSeq(refName)
122
140
 
123
- - `refName` - a string for the chrom to fetch from
141
+ Whether `refName` is present in the file.
124
142
 
125
- Returns number of features on refName, uses special pseudo-bin from the BAI/CSI
126
- index (e.g. bin 37450 from bai, returning n_mapped from SAM spec pdf) or 0 if
127
- refName does not exist in the sample
143
+ ### async estimatedBytesForRegions(regions, opts?)
128
144
 
129
- ### async hasRefSeq(refName: string)
145
+ Compressed bytes the given `{refName, start, end}[]` would fetch — useful for
146
+ warning before a large query.
130
147
 
131
- - `refName` - a string for the chrom to check
148
+ ### clearFeatureCache()
132
149
 
133
- Returns whether we have this refName in the sample
150
+ Drops the parsed-chunk cache.
134
151
 
135
- ### BamRecord properties
152
+ ### BamRecord
136
153
 
137
154
  ```typescript
138
155
  // Core alignment fields
@@ -142,24 +159,26 @@ record.start // 0-based start coordinate
142
159
  record.end // 0-based end coordinate
143
160
  record.name // QNAME
144
161
  record.seq // sequence string
145
- record.qual // Uint8Array of quality scores (null if unmapped)
162
+ record.qual // Uint8Array of quality scores (null if SEQ is empty)
146
163
  record.CIGAR // CIGAR string e.g. "50M2I48M"
147
164
  record.flags // SAM flags integer
148
165
  record.mq // mapping quality (undefined if 255)
149
166
  record.strand // 1 or -1
150
167
  record.template_length // TLEN
151
168
 
169
+ // Mate info
170
+ record.next_refid
171
+ record.next_pos
172
+
152
173
  // Auxiliary data
153
- record.tags // object with all aux tags e.g. {MD: "100", NM: 0}
154
- record.getTag('MD') // get a single tag (more efficient than record.tags when you only need one)
155
- record.getTagRaw('MD') // get tag as Uint8Array for string tags (avoids string conversion)
156
- record.NUMERIC_MD // MD tag as Uint8Array (for fast mismatch rendering)
157
- record.NUMERIC_CIGAR // Uint32Array of packed CIGAR operations
158
- record.NUMERIC_SEQ // Uint8Array of packed sequence (4-bit encoded)
174
+ record.tags // all aux tags e.g. {MD: "100", NM: 0}
175
+ record.getTag('MD') // one tag, without decoding the rest
176
+ record.getTagRaw('MD') // string tag as Uint8Array, skipping string conversion
159
177
 
160
- // Mate info
161
- record.next_refid // mate reference id
162
- record.next_pos // mate position
178
+ // Typed-array views, for rendering without allocating strings
179
+ record.NUMERIC_MD // MD tag as Uint8Array
180
+ record.NUMERIC_CIGAR // Uint32Array of packed CIGAR operations
181
+ record.NUMERIC_SEQ // Uint8Array of 4-bit encoded sequence
163
182
 
164
183
  // Flag methods
165
184
  record.isPaired()
@@ -176,14 +195,12 @@ record.isDuplicate()
176
195
  record.isSupplementary()
177
196
 
178
197
  // Utility
179
- record.seqAt(idx) // get single base at position
180
- record.toJSON() // serialize record
198
+ record.seqAt(idx) // single base at position
199
+ record.toJSON()
181
200
  ```
182
201
 
183
202
  ### Custom BamRecord class
184
203
 
185
- You can provide your own BamRecord class to add custom properties or methods:
186
-
187
204
  ```typescript
188
205
  import { BamFile, BamRecord } from '@gmod/bam'
189
206
 
@@ -191,10 +208,6 @@ class CustomBamRecord extends BamRecord {
191
208
  get customProperty() {
192
209
  return `custom-${this.name}`
193
210
  }
194
-
195
- getDoubleStart() {
196
- return this.start * 2
197
- }
198
211
  }
199
212
 
200
213
  const bam = new BamFile<CustomBamRecord>({
@@ -202,11 +215,9 @@ const bam = new BamFile<CustomBamRecord>({
202
215
  recordClass: CustomBamRecord,
203
216
  })
204
217
 
205
- await bam.getHeader()
206
- const records = await bam.getRecordsForRange('ctgA', 0, 50000)
207
218
  // records are typed as CustomBamRecord[]
219
+ const records = await bam.getRecordsForRange('ctgA', 0, 50000)
208
220
  console.log(records[0].customProperty)
209
- console.log(records[0].getDoubleStart())
210
221
  ```
211
222
 
212
223
  ## License
package/dist/bai.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import IndexFile from './indexFile.ts';
2
2
  import type { ParsedIndexBase, RefIndex } from './indexFile.ts';
3
3
  import type { BaseOpts } from './util.ts';
4
- import type { VirtualOffset } from './virtualOffset.ts';
5
4
  interface BaiRefIndex extends RefIndex {
6
- linearIndex: VirtualOffset[];
5
+ linearBlockPositions: Float64Array;
6
+ linearDataPositions: Float64Array;
7
7
  }
8
8
  interface BaiParsed extends ParsedIndexBase<BaiRefIndex> {
9
9
  bai: true;
@@ -17,6 +17,9 @@ export default class BAI extends IndexFile<BaiParsed> {
17
17
  _parse(opts: BaseOpts): Promise<BaiParsed>;
18
18
  indexCov(seqId: number, start?: number, end?: number, opts?: BaseOpts): Promise<IndexCovEntry[]>;
19
19
  protected reg2bins(min: number, max: number): readonly [readonly [0, 0], readonly [number, number], readonly [number, number], readonly [number, number], readonly [number, number], readonly [number, number]];
20
- protected getLowestChunk(refIndex: BaiRefIndex, min: number): VirtualOffset | undefined;
20
+ protected getLowestChunk(refIndex: BaiRefIndex, min: number): {
21
+ blockPosition: number;
22
+ dataPosition: number;
23
+ } | undefined;
21
24
  }
22
25
  export {};
package/dist/bai.js CHANGED
@@ -146,22 +146,32 @@ class BAI extends indexFile_ts_1.default {
146
146
  }
147
147
  const linearCount = dataView.getInt32(curr, true);
148
148
  curr += 4;
149
- const linearIndex = new Array(linearCount);
149
+ const linearBlockPositions = new Float64Array(linearCount);
150
+ const linearDataPositions = new Float64Array(linearCount);
150
151
  for (let j = 0; j < linearCount; j++) {
151
- linearIndex[j] = (0, virtualOffset_ts_1.fromBytes)(bytes, curr);
152
+ // a virtual offset is a 48-bit block position in the high bytes and a
153
+ // 16-bit data position in the low two
154
+ linearBlockPositions[j] =
155
+ bytes[curr + 7] * 0x10000000000 +
156
+ bytes[curr + 6] * 0x100000000 +
157
+ bytes[curr + 5] * 0x1000000 +
158
+ bytes[curr + 4] * 0x10000 +
159
+ bytes[curr + 3] * 0x100 +
160
+ bytes[curr + 2];
161
+ linearDataPositions[j] = (bytes[curr + 1] << 8) | bytes[curr];
152
162
  curr += 8;
153
163
  }
154
- (0, util_ts_1.clampChunkEnds)(Object.values(binIndex).flat(), linearIndex.map(v => v.blockPosition));
164
+ (0, util_ts_1.clampChunkEnds)(Object.values(binIndex).flat(), linearBlockPositions);
155
165
  return {
156
166
  binIndex,
157
- linearIndex,
167
+ linearBlockPositions,
168
+ linearDataPositions,
158
169
  stats,
159
170
  };
160
171
  }
161
172
  return {
162
173
  bai: true,
163
174
  firstDataLine,
164
- maxBlockSize: 1 << 16,
165
175
  indices: (0, indexFile_ts_1.memoizeByRefId)(getIndices),
166
176
  refCount,
167
177
  };
@@ -174,17 +184,18 @@ class BAI extends indexFile_ts_1.default {
174
184
  if (!seqIdx) {
175
185
  return [];
176
186
  }
177
- const { linearIndex, stats } = seqIdx;
178
- if (linearIndex.length === 0) {
187
+ const { linearBlockPositions, stats } = seqIdx;
188
+ const nintv = linearBlockPositions.length;
189
+ if (nintv === 0) {
179
190
  return [];
180
191
  }
181
- const e = end === undefined ? (linearIndex.length - 1) * v : roundUp(end, v);
192
+ const e = end === undefined ? (nintv - 1) * v : roundUp(end, v);
182
193
  const s = start === undefined ? 0 : roundDown(start, v);
183
194
  const depths = range
184
195
  ? new Array((e - s) / v)
185
- : new Array(linearIndex.length - 1);
186
- const totalSize = linearIndex[linearIndex.length - 1].blockPosition;
187
- if (e > (linearIndex.length - 1) * v) {
196
+ : new Array(nintv - 1);
197
+ const totalSize = linearBlockPositions[nintv - 1];
198
+ if (e > (nintv - 1) * v) {
188
199
  throw new Error('query outside of range of linear index');
189
200
  }
190
201
  // Scale the block-delta into a read count as we go, rather than building the
@@ -192,9 +203,9 @@ class BAI extends indexFile_ts_1.default {
192
203
  // multiply-then-divide order: hoisting lineCount/totalSize into a factor
193
204
  // reassociates the arithmetic and shifts scores by an ulp.
194
205
  const lineCount = stats?.lineCount ?? 0;
195
- let currentPos = linearIndex[s / v].blockPosition;
206
+ let currentPos = linearBlockPositions[s / v];
196
207
  for (let i = s / v, j = 0; i < e / v; i++, j++) {
197
- const nextPos = linearIndex[i + 1].blockPosition;
208
+ const nextPos = linearBlockPositions[i + 1];
198
209
  depths[j] = {
199
210
  score: ((nextPos - currentPos) * lineCount) / totalSize,
200
211
  start: i * v,
@@ -211,9 +222,14 @@ class BAI extends indexFile_ts_1.default {
211
222
  // contain alignments in the region. Linear index entries are monotonically
212
223
  // non-decreasing, so the first entry at minLin is the minimum.
213
224
  getLowestChunk(refIndex, min) {
214
- const { linearIndex } = refIndex;
215
- const nintv = linearIndex.length;
216
- return linearIndex[Math.min(min >> BAI_LINEAR_SHIFT, nintv - 1)];
225
+ const { linearBlockPositions, linearDataPositions } = refIndex;
226
+ const i = Math.min(min >> BAI_LINEAR_SHIFT, linearBlockPositions.length - 1);
227
+ return i < 0
228
+ ? undefined
229
+ : {
230
+ blockPosition: linearBlockPositions[i],
231
+ dataPosition: linearDataPositions[i],
232
+ };
217
233
  }
218
234
  }
219
235
  exports.default = BAI;
package/dist/bai.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bai.js","sourceRoot":"","sources":["../src/bai.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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G,CAAC,CAAE,CAAA;YAC5C,MAAM,CAAC,CAAC,CAAC,GAAG;gBACV,KAAK,EAAE,CAAC,CAAC,OAAO,GAAG,UAAU,CAAC,GAAG,SAAS,CAAC,GAAG,SAAS;gBACvD,KAAK,EAAE,CAAC,GAAG,CAAC;gBACZ,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC;aACf,CAAA;YACD,UAAU,GAAG,OAAO,CAAA;QACtB,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;IAES,QAAQ,CAAC,GAAW,EAAE,GAAW;QACzC,OAAO,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IAC3B,CAAC;IAED,0EAA0E;IAC1E,2EAA2E;IAC3E,+DAA+D;IACrD,cAAc,CAAC,QAAqB,EAAE,GAAW;QACzD,MAAM,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,GAAG,QAAQ,CAAA;QAC9D,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,gBAAgB,EAAE,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QAC5E,OAAO,CAAC,GAAG,CAAC;YACV,CAAC,CAAC,SAAS;YACX,CAAC,CAAC;gBACE,aAAa,EAAE,oBAAoB,CAAC,CAAC,CAAE;gBACvC,YAAY,EAAE,mBAAmB,CAAC,CAAC,CAAE;aACtC,CAAA;IACP,CAAC;CACF;AA5LD,sBA4LC"}
package/dist/bamFile.d.ts CHANGED
@@ -72,14 +72,27 @@ export default class BamFile<T extends BamRecordLike = BAMFeature> {
72
72
  tag: string;
73
73
  value: string;
74
74
  }[];
75
- }[] | undefined>;
75
+ }[]>;
76
+ /**
77
+ * Installs the header text and ref name/id maps from the start of a
78
+ * decompressed BAM stream, returning the parsed SAM header lines. Returns
79
+ * undefined if the stream is cut off partway through the ref-seq table, so
80
+ * the caller can retry with more data.
81
+ */
82
+ protected applyHeader(uncba: Uint8Array): {
83
+ tag: string;
84
+ data: {
85
+ tag: string;
86
+ value: string;
87
+ }[];
88
+ }[] | undefined;
76
89
  getHeader(opts?: BaseOpts): Promise<{
77
90
  tag: string;
78
91
  data: {
79
92
  tag: string;
80
93
  value: string;
81
94
  }[];
82
- }[] | undefined>;
95
+ }[]>;
83
96
  getHeaderText(opts?: BaseOpts): Promise<string | undefined>;
84
97
  private getSeqId;
85
98
  /**
@@ -100,7 +113,7 @@ export default class BamFile<T extends BamRecordLike = BAMFeature> {
100
113
  features: T[];
101
114
  bytes: number;
102
115
  }>;
103
- readBamFeatures(ba: Uint8Array, cpositions: number[], dpositions: number[], chunk: Chunk): T[];
116
+ readBamFeatures(ba: Uint8Array, cpositions: ArrayLike<number>, dpositions: ArrayLike<number>, chunk: Chunk): T[];
104
117
  hasRefSeq(seqName: string, opts?: BaseOpts): Promise<boolean>;
105
118
  lineCount(seqName: string, opts?: BaseOpts): Promise<number>;
106
119
  indexCov(seqName: string, start?: number, end?: number): Promise<never[] | import("./bai.ts").IndexCovEntry[]>;