@gmod/bam 1.1.18 → 2.0.1
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/CHANGELOG.md +66 -25
- package/README.md +95 -57
- package/dist/bai.d.ts +34 -15
- package/dist/bai.js +87 -91
- package/dist/bai.js.map +1 -1
- package/dist/bamFile.d.ts +33 -27
- package/dist/bamFile.js +132 -130
- package/dist/bamFile.js.map +1 -1
- package/dist/chunk.d.ts +4 -8
- package/dist/chunk.js +2 -8
- package/dist/chunk.js.map +1 -1
- package/dist/csi.d.ts +74 -10
- package/dist/csi.js +78 -90
- package/dist/csi.js.map +1 -1
- package/dist/htsget.d.ts +5 -8
- package/dist/htsget.js +75 -49
- package/dist/htsget.js.map +1 -1
- package/dist/index.d.ts +5 -6
- package/dist/index.js +11 -11
- package/dist/index.js.map +1 -1
- package/dist/indexFile.d.ts +0 -6
- package/dist/indexFile.js +0 -35
- package/dist/indexFile.js.map +1 -1
- package/dist/nullIndex.d.ts +7 -0
- package/dist/nullIndex.js +33 -0
- package/dist/nullIndex.js.map +1 -0
- package/dist/record.d.ts +2 -2
- package/dist/record.js +34 -25
- package/dist/record.js.map +1 -1
- package/dist/sam.js +11 -7
- package/dist/sam.js.map +1 -1
- package/dist/util.d.ts +13 -1
- package/dist/util.js +47 -15
- package/dist/util.js.map +1 -1
- package/dist/virtualOffset.js.map +1 -1
- package/esm/bai.d.ts +34 -15
- package/esm/bai.js +86 -91
- package/esm/bai.js.map +1 -1
- package/esm/bamFile.d.ts +33 -27
- package/esm/bamFile.js +124 -120
- package/esm/bamFile.js.map +1 -1
- package/esm/chunk.d.ts +4 -8
- package/esm/chunk.js +2 -8
- package/esm/chunk.js.map +1 -1
- package/esm/csi.d.ts +74 -10
- package/esm/csi.js +85 -93
- package/esm/csi.js.map +1 -1
- package/esm/htsget.d.ts +5 -8
- package/esm/htsget.js +68 -43
- package/esm/htsget.js.map +1 -1
- package/esm/index.d.ts +5 -6
- package/esm/index.js +5 -6
- package/esm/index.js.map +1 -1
- package/esm/indexFile.d.ts +0 -6
- package/esm/indexFile.js +0 -22
- package/esm/indexFile.js.map +1 -1
- package/esm/nullIndex.d.ts +7 -0
- package/esm/nullIndex.js +16 -0
- package/esm/nullIndex.js.map +1 -0
- package/esm/record.d.ts +2 -2
- package/esm/record.js +34 -25
- package/esm/record.js.map +1 -1
- package/esm/sam.js +11 -7
- package/esm/sam.js.map +1 -1
- package/esm/util.d.ts +13 -1
- package/esm/util.js +40 -14
- package/esm/util.js.map +1 -1
- package/esm/virtualOffset.js.map +1 -1
- package/package.json +19 -21
- package/src/bai.ts +99 -102
- package/src/bamFile.ts +174 -198
- package/src/chunk.ts +6 -20
- package/src/csi.ts +102 -111
- package/src/htsget.ts +81 -61
- package/src/index.ts +5 -7
- package/src/indexFile.ts +0 -27
- package/src/nullIndex.ts +18 -0
- package/src/record.ts +34 -25
- package/src/sam.ts +11 -7
- package/src/util.ts +54 -13
- package/src/declare.d.ts +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
|
-
## [
|
|
1
|
+
## [2.0.1](https://github.com/GMOD/bam-js/compare/v2.0.0...v2.0.1) (2024-2-20)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
- Update to buffer-crc32 1.0.0
|
|
6
|
+
- Fix BAM header parsing of refNames containing a :
|
|
2
7
|
|
|
8
|
+
# [2.0.0](https://github.com/GMOD/bam-js/compare/v1.1.18...v2.0.0) (2023-06-08)
|
|
3
9
|
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
- explicit buffer import ([#98](https://github.com/GMOD/bam-js/issues/98))
|
|
13
|
+
([66de9f4](https://github.com/GMOD/bam-js/commit/66de9f4ce30e3ff647d5297f093695e92ec9227c))
|
|
14
|
+
|
|
15
|
+
* Add explicit buffer import
|
|
16
|
+
* Remove cross-fetch and object.entries polyfills
|
|
17
|
+
* Improve typescripting
|
|
18
|
+
* Remove chunkSizeLimit and fetchSizeLimit
|
|
19
|
+
|
|
20
|
+
## [1.1.18](https://github.com/GMOD/bam-js/compare/v1.1.17...v1.1.18) (2022-12-17)
|
|
4
21
|
|
|
5
22
|
- Use es2015 for nodejs build
|
|
6
23
|
|
|
@@ -14,7 +31,8 @@
|
|
|
14
31
|
|
|
15
32
|
## [1.1.15](https://github.com/GMOD/bam-js/compare/v1.1.14...v1.1.15) (2022-03-18)
|
|
16
33
|
|
|
17
|
-
- Fix for htsget failing with message 'input must be buffer, number, or string,
|
|
34
|
+
- Fix for htsget failing with message 'input must be buffer, number, or string,
|
|
35
|
+
received object'
|
|
18
36
|
- Speed improvement by caching chunks of features
|
|
19
37
|
|
|
20
38
|
## [1.1.14](https://github.com/GMOD/bam-js/compare/v1.1.13...v1.1.14) (2022-03-14)
|
|
@@ -29,7 +47,8 @@
|
|
|
29
47
|
|
|
30
48
|
## [1.1.12](https://github.com/GMOD/bam-js/compare/v1.1.11...v1.1.12) (2022-02-17)
|
|
31
49
|
|
|
32
|
-
- Add blocksForRange method to BamFile class to help stats estimation in JBrowse
|
|
50
|
+
- Add blocksForRange method to BamFile class to help stats estimation in JBrowse
|
|
51
|
+
2
|
|
33
52
|
|
|
34
53
|
<a name="1.1.11"></a>
|
|
35
54
|
|
|
@@ -49,7 +68,8 @@
|
|
|
49
68
|
## [1.1.9](https://github.com/GMOD/bam-js/compare/v1.1.8...v1.1.9) (2021-12-14)
|
|
50
69
|
|
|
51
70
|
- Add ESM module export in package.json (smaller bundle size for consumers)
|
|
52
|
-
- Cache BAI readFile result for compatibility with node.js native filehandles
|
|
71
|
+
- Cache BAI readFile result for compatibility with node.js native filehandles
|
|
72
|
+
(which otherwise fail if re-reading the filehandle twice)
|
|
53
73
|
|
|
54
74
|
<a name="1.1.8"></a>
|
|
55
75
|
|
|
@@ -67,7 +87,8 @@
|
|
|
67
87
|
|
|
68
88
|
## [1.1.6](https://github.com/GMOD/bam-js/compare/v1.1.5...v1.1.6) (2021-02-20)
|
|
69
89
|
|
|
70
|
-
- Add qualRaw function on records for getting raw qual score array instead of
|
|
90
|
+
- Add qualRaw function on records for getting raw qual score array instead of
|
|
91
|
+
string
|
|
71
92
|
|
|
72
93
|
<a name="1.1.5"></a>
|
|
73
94
|
|
|
@@ -80,7 +101,8 @@
|
|
|
80
101
|
## [1.1.4](https://github.com/GMOD/bam-js/compare/v1.1.3...v1.1.4) (2020-12-11)
|
|
81
102
|
|
|
82
103
|
- Add canMergeBlocks to CSI code (already existed in BAI)
|
|
83
|
-
- Add suggestion from @jrobinso about reg2bins modification for memory saving
|
|
104
|
+
- Add suggestion from @jrobinso about reg2bins modification for memory saving
|
|
105
|
+
(Thanks!)
|
|
84
106
|
- Add getHeaderText() method for getting a text string of the header data
|
|
85
107
|
|
|
86
108
|
<a name="1.1.3"></a>
|
|
@@ -119,7 +141,8 @@
|
|
|
119
141
|
## [1.0.41](https://github.com/GMOD/bam-js/compare/v1.0.40...v1.0.41) (2020-08-19)
|
|
120
142
|
|
|
121
143
|
- Add htsget example
|
|
122
|
-
- Support opts object to getHeader allowing things like auth headers to be
|
|
144
|
+
- Support opts object to getHeader allowing things like auth headers to be
|
|
145
|
+
passed right off the bat
|
|
123
146
|
|
|
124
147
|
<a name="1.0.40"></a>
|
|
125
148
|
|
|
@@ -129,14 +152,16 @@
|
|
|
129
152
|
|
|
130
153
|
## [1.0.39](https://github.com/GMOD/bam-js/compare/v1.0.38...v1.0.39) (2020-07-30)
|
|
131
154
|
|
|
132
|
-
- Don't use origin master in the follow-tags postpublish command for cleaner
|
|
155
|
+
- Don't use origin master in the follow-tags postpublish command for cleaner
|
|
156
|
+
version publishing
|
|
133
157
|
|
|
134
158
|
<a name="1.0.38"></a>
|
|
135
159
|
|
|
136
160
|
## [1.0.38](https://github.com/GMOD/bam-js/compare/v1.0.37...v1.0.38) (2020-07-30)
|
|
137
161
|
|
|
138
162
|
- Direct construction of qual/seq toString
|
|
139
|
-
- Improve performance of the uniqueID calculation for pathological cases where
|
|
163
|
+
- Improve performance of the uniqueID calculation for pathological cases where
|
|
164
|
+
there are tons of bins
|
|
140
165
|
|
|
141
166
|
<a name="1.0.37"></a>
|
|
142
167
|
|
|
@@ -148,31 +173,36 @@
|
|
|
148
173
|
|
|
149
174
|
## [1.0.36](https://github.com/GMOD/bam-js/compare/v1.0.35...v1.0.36) (2020-03-05)
|
|
150
175
|
|
|
151
|
-
- Adds a shortcut to stop parsing chunks after a record is detected to be
|
|
176
|
+
- Adds a shortcut to stop parsing chunks after a record is detected to be
|
|
177
|
+
outside the requested range while decoding
|
|
152
178
|
|
|
153
179
|
<a name="1.0.35"></a>
|
|
154
180
|
|
|
155
181
|
## [1.0.35](https://github.com/GMOD/bam-js/compare/v1.0.34...v1.0.35) (2020-02-04)
|
|
156
182
|
|
|
157
|
-
- Update scheme used to calculate unique fileOffset based IDs using
|
|
183
|
+
- Update scheme used to calculate unique fileOffset based IDs using
|
|
184
|
+
@gmod/bgzf-filehandle updates
|
|
158
185
|
|
|
159
186
|
<a name="1.0.34"></a>
|
|
160
187
|
|
|
161
188
|
## [1.0.34](https://github.com/GMOD/bam-js/compare/v1.0.33...v1.0.34) (2020-01-24)
|
|
162
189
|
|
|
163
|
-
- Small fix for using id() instead of .get('id') for weird SAM records
|
|
190
|
+
- Small fix for using id() instead of .get('id') for weird SAM records
|
|
191
|
+
containing ID field
|
|
164
192
|
|
|
165
193
|
<a name="1.0.33"></a>
|
|
166
194
|
|
|
167
195
|
## [1.0.33](https://github.com/GMOD/bam-js/compare/v1.0.32...v1.0.33) (2020-01-24)
|
|
168
196
|
|
|
169
|
-
- Perform decoding of entire chunk up front to aid caching, reverts change in
|
|
197
|
+
- Perform decoding of entire chunk up front to aid caching, reverts change in
|
|
198
|
+
1.0.29
|
|
170
199
|
|
|
171
200
|
<a name="1.0.32"></a>
|
|
172
201
|
|
|
173
202
|
## [1.0.32](https://github.com/GMOD/bam-js/compare/v1.0.31...v1.0.32) (2019-11-16)
|
|
174
203
|
|
|
175
|
-
- Add a speed improvement for long reads by pre-allocating sequence/quality
|
|
204
|
+
- Add a speed improvement for long reads by pre-allocating sequence/quality
|
|
205
|
+
scores array
|
|
176
206
|
|
|
177
207
|
<a name="1.0.31"></a>
|
|
178
208
|
|
|
@@ -190,7 +220,8 @@
|
|
|
190
220
|
|
|
191
221
|
## [1.0.29](https://github.com/GMOD/bam-js/compare/v1.0.28...v1.0.29) (2019-10-31)
|
|
192
222
|
|
|
193
|
-
- Decoding of the BAM records at time of use instead of entire chunk decoded up
|
|
223
|
+
- Decoding of the BAM records at time of use instead of entire chunk decoded up
|
|
224
|
+
front
|
|
194
225
|
- Alternate chunk merging strategy inspired by igv.js code
|
|
195
226
|
|
|
196
227
|
<a name="1.0.28"></a>
|
|
@@ -243,32 +274,40 @@
|
|
|
243
274
|
|
|
244
275
|
## [1.0.21](https://github.com/GMOD/bam-js/compare/v1.0.20...v1.0.21) (2019-08-06)
|
|
245
276
|
|
|
246
|
-
- Add a fix for the small chunk unpacking re-seeking in the same bgzf block
|
|
277
|
+
- Add a fix for the small chunk unpacking re-seeking in the same bgzf block
|
|
278
|
+
repeatedly (#35)
|
|
247
279
|
|
|
248
280
|
<a name="1.0.20"></a>
|
|
249
281
|
|
|
250
282
|
## [1.0.20](https://github.com/GMOD/bam-js/compare/v1.0.19...v1.0.20) (2019-06-06)
|
|
251
283
|
|
|
252
|
-
- Added a method for smaller chunk unpacking, by modifying the header parsing to
|
|
253
|
-
|
|
284
|
+
- Added a method for smaller chunk unpacking, by modifying the header parsing to
|
|
285
|
+
return smaller chunks and the bgzf unzipping to respect chunk boundaries (#30)
|
|
286
|
+
- Use fileOffset as bam feature ID which previously was crc32 of the BAM buffer
|
|
287
|
+
which consequently speeds up processing and allows exact duplicate features
|
|
254
288
|
|
|
255
289
|
## [1.0.19](https://github.com/GMOD/bam-js/compare/v1.0.18...v1.0.19) (2019-05-30)
|
|
256
290
|
|
|
257
|
-
- Added lineCount and hasRefSeq functions to BamFile, each accepting a string
|
|
291
|
+
- Added lineCount and hasRefSeq functions to BamFile, each accepting a string
|
|
292
|
+
seqName
|
|
258
293
|
- Fixed aborting on index retrieval code
|
|
259
294
|
|
|
260
295
|
## [1.0.18](https://github.com/GMOD/bam-js/compare/v1.0.17...v1.0.18) (2019-05-01)
|
|
261
296
|
|
|
262
|
-
- Bump generic-filehandle to 1.0.9 to fix error with using native fetch (global
|
|
263
|
-
|
|
297
|
+
- Bump generic-filehandle to 1.0.9 to fix error with using native fetch (global
|
|
298
|
+
fetch needed to be bound)
|
|
299
|
+
- Bump abortable-promise-cache to 1.0.1 version to fix error with using native
|
|
300
|
+
fetch and abort signals
|
|
264
301
|
|
|
265
302
|
## [1.0.17](https://github.com/GMOD/bam-js/compare/v1.0.16...v1.0.17) (2019-04-28)
|
|
266
303
|
|
|
267
|
-
- Fix wrong number of arguments being passed to the readRefSeqs file read()
|
|
304
|
+
- Fix wrong number of arguments being passed to the readRefSeqs file read()
|
|
305
|
+
invocation resulting in bad range requests
|
|
268
306
|
|
|
269
307
|
## [1.0.16](https://github.com/GMOD/bam-js/compare/v1.0.15...v1.0.16) (2019-04-28)
|
|
270
308
|
|
|
271
|
-
- Added indexCov algorithm to retrieve approximate coverage of the BAM inferred
|
|
309
|
+
- Added indexCov algorithm to retrieve approximate coverage of the BAM inferred
|
|
310
|
+
from the size of the BAI linear index bins
|
|
272
311
|
- Fixed abortSignal on read() calls
|
|
273
312
|
- Updated API to allow bamUrl/baiUrl/csiUrl
|
|
274
313
|
|
|
@@ -314,7 +353,8 @@
|
|
|
314
353
|
## [1.0.9](https://github.com/GMOD/bam-js/compare/v1.0.8...v1.0.9) (2018-11-16)
|
|
315
354
|
|
|
316
355
|
- Allow bases other than ACGT to be decoded
|
|
317
|
-
- Make viewAsPairs only resolve pairs on given refSeq unless pairAcrossChr is
|
|
356
|
+
- Make viewAsPairs only resolve pairs on given refSeq unless pairAcrossChr is
|
|
357
|
+
enabled for query
|
|
318
358
|
|
|
319
359
|
<a name="1.0.8"></a>
|
|
320
360
|
|
|
@@ -332,7 +372,8 @@
|
|
|
332
372
|
|
|
333
373
|
## [1.0.6](https://github.com/GMOD/bam-js/compare/v1.0.5...v1.0.6) (2018-10-19)
|
|
334
374
|
|
|
335
|
-
- Add bugfix for where bytes for an invalid request returns 0 resulting in pako
|
|
375
|
+
- Add bugfix for where bytes for an invalid request returns 0 resulting in pako
|
|
376
|
+
unzip errors
|
|
336
377
|
|
|
337
378
|
<a name="1.0.5"></a>
|
|
338
379
|
|
package/README.md
CHANGED
|
@@ -4,12 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```bash
|
|
8
|
+
$ npm install --save @gmod/bam
|
|
9
|
+
```
|
|
8
10
|
|
|
9
11
|
## Usage
|
|
10
12
|
|
|
11
|
-
```
|
|
12
|
-
const { BamFile } = require('@gmod/bam')
|
|
13
|
+
```typescript
|
|
14
|
+
const { BamFile } = require('@gmod/bam')
|
|
15
|
+
// or import {BamFile} from '@gmod/bam'
|
|
13
16
|
|
|
14
17
|
const t = new BamFile({
|
|
15
18
|
bamPath: 'test.bam',
|
|
@@ -22,9 +25,10 @@ var header = await t.getHeader()
|
|
|
22
25
|
var records = await t.getRecordsForRange('ctgA', 0, 50000)
|
|
23
26
|
```
|
|
24
27
|
|
|
25
|
-
The `bamPath` argument only works on nodejs
|
|
28
|
+
The `bamPath` argument only works on nodejs. In the browser, you should pass
|
|
29
|
+
`bamFilehandle` with a generic-filehandle e.g. `RemoteFile`
|
|
26
30
|
|
|
27
|
-
```
|
|
31
|
+
```typescript
|
|
28
32
|
const { RemoteFile } = require('generic-filehandle')
|
|
29
33
|
const bam = new BamFile({
|
|
30
34
|
bamFilehandle: new RemoteFile('yourfile.bam'), // or a full http url
|
|
@@ -32,15 +36,16 @@ const bam = new BamFile({
|
|
|
32
36
|
})
|
|
33
37
|
```
|
|
34
38
|
|
|
35
|
-
Input are 0-based half-open coordinates (note: not the same as samtools view
|
|
39
|
+
Input are 0-based half-open coordinates (note: not the same as samtools view
|
|
40
|
+
coordinate inputs!)
|
|
36
41
|
|
|
37
42
|
## Usage with htsget
|
|
38
43
|
|
|
39
|
-
Since 1.0.41 we support htsget
|
|
44
|
+
Since 1.0.41 we support usage of the htsget protocol
|
|
40
45
|
|
|
41
46
|
Here is a small code snippet for this
|
|
42
47
|
|
|
43
|
-
```
|
|
48
|
+
```typescript
|
|
44
49
|
const { HtsgetFile } = require('@gmod/bam')
|
|
45
50
|
|
|
46
51
|
const ti = new HtsgetFile({
|
|
@@ -51,64 +56,87 @@ await ti.getHeader()
|
|
|
51
56
|
const records = await ti.getRecordsForRange(1, 2000000, 2000001)
|
|
52
57
|
```
|
|
53
58
|
|
|
59
|
+
Our implementation makes some assumptions about how the protocol is implemented,
|
|
60
|
+
so let us know if it doesn't work for your use case
|
|
61
|
+
|
|
54
62
|
## Documentation
|
|
55
63
|
|
|
56
64
|
### BAM constructor
|
|
57
65
|
|
|
58
66
|
The BAM class constructor accepts arguments
|
|
59
67
|
|
|
60
|
-
- bamPath
|
|
61
|
-
|
|
62
|
-
-
|
|
63
|
-
|
|
64
|
-
-
|
|
65
|
-
- cacheSize - limit on number of chunks to cache. default: 50
|
|
66
|
-
- yieldThreadTime - the interval at which the code yields to the main thread
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
- `bamPath`/`bamUrl`/`bamFilehandle` - a string file path to a local file or a
|
|
69
|
+
class object with a read method
|
|
70
|
+
- `csiPath`/`csiUrl`/`csiFilehandle` - a CSI index for the BAM file, required
|
|
71
|
+
for long chromosomes greater than 2^29 in length
|
|
72
|
+
- `baiPath`/`baiUrl`/`baiFilehandle` - a BAI index for the BAM file
|
|
73
|
+
- `cacheSize` - limit on number of chunks to cache. default: 50
|
|
74
|
+
- `yieldThreadTime` - the interval at which the code yields to the main thread
|
|
75
|
+
when it is parsing a lot of data. default: 100ms. Set to 0 to performed no
|
|
76
|
+
yielding
|
|
77
|
+
|
|
78
|
+
Note: filehandles implement the Filehandle interface from
|
|
79
|
+
https://www.npmjs.com/package/generic-filehandle. This module offers the path
|
|
80
|
+
and url arguments as convenience methods for supplying the LocalFile and
|
|
81
|
+
RemoteFile
|
|
69
82
|
|
|
70
83
|
### async getRecordsForRange(refName, start, end, opts)
|
|
71
84
|
|
|
72
85
|
Note: you must run getHeader before running getRecordsForRange
|
|
73
86
|
|
|
74
|
-
- refName - a string for the chrom to fetch from
|
|
75
|
-
- start - a 0
|
|
76
|
-
- end - a 0
|
|
77
|
-
- opts.signal - an AbortSignal to indicate stop processing
|
|
78
|
-
- opts.viewAsPairs - re-dispatches requests to find mate pairs. default: false
|
|
79
|
-
- opts.pairAcrossChr - control the viewAsPairs option behavior to pair across
|
|
80
|
-
|
|
87
|
+
- `refName` - a string for the chrom to fetch from
|
|
88
|
+
- `start` - a 0-based half open start coordinate
|
|
89
|
+
- `end` - a 0-based half open end coordinate
|
|
90
|
+
- `opts.signal` - an AbortSignal to indicate stop processing
|
|
91
|
+
- `opts.viewAsPairs` - re-dispatches requests to find mate pairs. default: false
|
|
92
|
+
- `opts.pairAcrossChr` - control the viewAsPairs option behavior to pair across
|
|
93
|
+
chromosomes. default: false
|
|
94
|
+
- `opts.maxInsertSize` - control the viewAsPairs option behavior to limit
|
|
95
|
+
distance within a chromosome to fetch. default: 200kb
|
|
81
96
|
|
|
82
97
|
### async \*streamRecordsForRange(refName, start, end, opts)
|
|
83
98
|
|
|
84
|
-
This is a async generator function that takes the same signature as
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
99
|
+
This is a async generator function that takes the same signature as
|
|
100
|
+
`getRecordsForRange` but results can be processed using
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
for await (const chunk of file.streamRecordsForRange(
|
|
104
|
+
refName,
|
|
105
|
+
start,
|
|
106
|
+
end,
|
|
107
|
+
opts,
|
|
108
|
+
)) {
|
|
109
|
+
}
|
|
110
|
+
```
|
|
88
111
|
|
|
89
|
-
The getRecordsForRange simply wraps this process by concatenating chunks into
|
|
112
|
+
The `getRecordsForRange` simply wraps this process by concatenating chunks into
|
|
113
|
+
an array
|
|
90
114
|
|
|
91
115
|
### async getHeader(opts: {....anything to pass to generic-filehandle opts})
|
|
92
116
|
|
|
93
|
-
This obtains the header from HtsgetFile or BamFile
|
|
117
|
+
This obtains the header from `HtsgetFile` or `BamFile`. Retrieves BAM file and
|
|
118
|
+
BAI/CSI header if applicable, or API request for refnames from htsget
|
|
94
119
|
|
|
95
120
|
### async indexCov(refName, start, end)
|
|
96
121
|
|
|
97
|
-
- refName - a string for the chrom to fetch from
|
|
98
|
-
- start - a 0
|
|
99
|
-
- end - a 0
|
|
122
|
+
- `refName` - a string for the chrom to fetch from
|
|
123
|
+
- `start` - a 0-based half open start coordinate (optional)
|
|
124
|
+
- `end` - a 0-based half open end coordinate (optional)
|
|
100
125
|
|
|
101
|
-
Returns features of the form {start, end, score} containing estimated feature
|
|
126
|
+
Returns features of the form {start, end, score} containing estimated feature
|
|
127
|
+
density across 16kb windows in the genome
|
|
102
128
|
|
|
103
|
-
### async lineCount(refName)
|
|
129
|
+
### async lineCount(refName: string)
|
|
104
130
|
|
|
105
|
-
- refName - a string for the chrom to fetch from
|
|
131
|
+
- `refName` - a string for the chrom to fetch from
|
|
106
132
|
|
|
107
|
-
Returns number of features on refName, uses special pseudo-bin from the BAI/CSI
|
|
133
|
+
Returns number of features on refName, uses special pseudo-bin from the BAI/CSI
|
|
134
|
+
index (e.g. bin 37450 from bai, returning n_mapped from SAM spec pdf) or -1 if
|
|
135
|
+
refName not exist in sample
|
|
108
136
|
|
|
109
|
-
### async hasRefSeq(refName)
|
|
137
|
+
### async hasRefSeq(refName: string)
|
|
110
138
|
|
|
111
|
-
- refName - a string for the chrom to check
|
|
139
|
+
- `refName` - a string for the chrom to check
|
|
112
140
|
|
|
113
141
|
Returns whether we have this refName in the sample
|
|
114
142
|
|
|
@@ -121,41 +149,51 @@ You can access data feature.get('field') to get the value of a feature attribute
|
|
|
121
149
|
|
|
122
150
|
Example
|
|
123
151
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
152
|
+
```typescript
|
|
153
|
+
feature.get('seq_id') // numerical sequence id corresponding to position in the sam header
|
|
154
|
+
feature.get('start') // 0-based half open start coordinate
|
|
155
|
+
feature.get('end') // 0-based half open end coordinate
|
|
156
|
+
```
|
|
127
157
|
|
|
128
158
|
#### Fields
|
|
129
159
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
160
|
+
```typescript
|
|
161
|
+
feature.get('name') // QNAME
|
|
162
|
+
feature.get('seq') // feature sequence
|
|
163
|
+
feature.get('qual') // qualities
|
|
164
|
+
feature.get('cigar') // cigar string
|
|
165
|
+
feature.get('MD') // MD string
|
|
166
|
+
feature.get('SA') // supplementary alignments
|
|
167
|
+
feature.get('template_length') // TLEN
|
|
168
|
+
feature.get('length_on_ref') // derived from CIGAR using standard algorithm
|
|
169
|
+
```
|
|
138
170
|
|
|
139
171
|
#### Flags
|
|
140
172
|
|
|
141
|
-
|
|
173
|
+
```typescript
|
|
174
|
+
feature.get('flags') // see https://broadinstitute.github.io/picard/explain-flags.html
|
|
175
|
+
```
|
|
142
176
|
|
|
143
177
|
#### Tags
|
|
144
178
|
|
|
145
179
|
BAM tags such as MD can be obtained via
|
|
146
180
|
|
|
147
|
-
|
|
181
|
+
```typescript
|
|
182
|
+
feature.get('MD')
|
|
183
|
+
```
|
|
148
184
|
|
|
149
185
|
A full list of tags that can be obtained can be obtained via
|
|
150
186
|
|
|
151
187
|
feature._tags()
|
|
152
188
|
|
|
153
|
-
The feature format may change in future versions to be more raw data records,
|
|
189
|
+
The feature format may change in future versions to be more raw data records,
|
|
190
|
+
but this will be a major version bump
|
|
154
191
|
|
|
155
|
-
|
|
192
|
+
#### Note
|
|
156
193
|
|
|
157
|
-
|
|
194
|
+
The reason that we hide the data behind this ".get" function is that we lazily
|
|
195
|
+
decode records on demand, which can reduce memory consumption.
|
|
158
196
|
|
|
159
|
-
|
|
197
|
+
## License
|
|
160
198
|
|
|
161
|
-
|
|
199
|
+
MIT © [Colin Diesh](https://github.com/cmdcolin)
|
package/dist/bai.d.ts
CHANGED
|
@@ -1,26 +1,45 @@
|
|
|
1
|
-
|
|
1
|
+
import VirtualOffset from './virtualOffset';
|
|
2
2
|
import Chunk from './chunk';
|
|
3
|
-
import IndexFile from './indexFile';
|
|
4
3
|
import { BaseOpts } from './util';
|
|
4
|
+
import IndexFile from './indexFile';
|
|
5
5
|
export default class BAI extends IndexFile {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
setupP?: ReturnType<BAI['_parse']>;
|
|
7
|
+
lineCount(refId: number, opts?: BaseOpts): Promise<number>;
|
|
8
|
+
_parse(opts?: BaseOpts): Promise<{
|
|
9
|
+
bai: boolean;
|
|
10
|
+
firstDataLine: VirtualOffset | undefined;
|
|
11
|
+
maxBlockSize: number;
|
|
12
|
+
indices: {
|
|
13
|
+
binIndex: {
|
|
14
|
+
[key: string]: Chunk[];
|
|
15
|
+
};
|
|
16
|
+
linearIndex: VirtualOffset[];
|
|
17
|
+
stats?: {
|
|
18
|
+
lineCount: number;
|
|
19
|
+
} | undefined;
|
|
20
|
+
}[];
|
|
21
|
+
refCount: number;
|
|
14
22
|
}>;
|
|
15
23
|
indexCov(seqId: number, start?: number, end?: number, opts?: BaseOpts): Promise<{
|
|
16
24
|
start: number;
|
|
17
25
|
end: number;
|
|
18
26
|
score: number;
|
|
19
27
|
}[]>;
|
|
20
|
-
/**
|
|
21
|
-
* calculate the list of bins that may overlap with region [beg,end) (zero-based half-open)
|
|
22
|
-
* @returns {Array[number]}
|
|
23
|
-
*/
|
|
24
|
-
reg2bins(beg: number, end: number): number[][];
|
|
25
28
|
blocksForRange(refId: number, min: number, max: number, opts?: BaseOpts): Promise<Chunk[]>;
|
|
29
|
+
parse(opts?: BaseOpts): Promise<{
|
|
30
|
+
bai: boolean;
|
|
31
|
+
firstDataLine: VirtualOffset | undefined;
|
|
32
|
+
maxBlockSize: number;
|
|
33
|
+
indices: {
|
|
34
|
+
binIndex: {
|
|
35
|
+
[key: string]: Chunk[];
|
|
36
|
+
};
|
|
37
|
+
linearIndex: VirtualOffset[];
|
|
38
|
+
stats?: {
|
|
39
|
+
lineCount: number;
|
|
40
|
+
} | undefined;
|
|
41
|
+
}[];
|
|
42
|
+
refCount: number;
|
|
43
|
+
}>;
|
|
44
|
+
hasRefSeq(seqId: number, opts?: BaseOpts): Promise<boolean>;
|
|
26
45
|
}
|