@gmod/tabix 1.5.15 → 1.6.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 CHANGED
@@ -1,15 +1,19 @@
1
- ## [1.5.15](https://github.com/GMOD/tabix-js/compare/v1.5.14...v1.5.15) (2024-08-30)
1
+ ## [1.6.1](https://github.com/GMOD/tabix-js/compare/v1.6.0...v1.6.1) (2024-12-07)
2
2
 
3
3
 
4
4
 
5
- ## [1.5.14](https://github.com/GMOD/tabix-js/compare/v1.5.13...v1.5.14) (2024-07-23)
5
+ # [1.6.0](https://github.com/GMOD/tabix-js/compare/v1.5.15...v1.6.0) (2024-11-30)
6
6
 
7
7
 
8
- ### Reverts
9
8
 
10
- * Revert "Bump to eslint 9" ([9bd49b1](https://github.com/GMOD/tabix-js/commit/9bd49b1132f632b0e7847d9b95cf3cb08c424360))
9
+ ## [1.5.15](https://github.com/GMOD/tabix-js/compare/v1.5.14...v1.5.15) (2024-08-30)
11
10
 
11
+ ## [1.5.14](https://github.com/GMOD/tabix-js/compare/v1.5.13...v1.5.14) (2024-07-23)
12
+
13
+ ### Reverts
12
14
 
15
+ - Revert "Bump to eslint 9"
16
+ ([9bd49b1](https://github.com/GMOD/tabix-js/commit/9bd49b1132f632b0e7847d9b95cf3cb08c424360))
13
17
 
14
18
  ## [1.5.13](https://github.com/GMOD/tabix-js/compare/v1.5.12...v1.5.13) (2024-01-09)
15
19
 
@@ -17,8 +21,8 @@
17
21
 
18
22
  ## [1.5.12](https://github.com/GMOD/tabix-js/compare/v1.5.11...v1.5.12) (2024-01-09)
19
23
 
20
- - Add missing abort signal to the @gmod/abortable-promise-cache fetch for tabix chunks
21
- (#143)
24
+ - Add missing abort signal to the @gmod/abortable-promise-cache fetch for tabix
25
+ chunks (#143)
22
26
 
23
27
  ## [1.5.11](https://github.com/GMOD/tabix-js/compare/v1.5.10...v1.5.11) (2023-07-10)
24
28
 
package/README.md CHANGED
@@ -27,8 +27,8 @@ import { TabixIndexedFile } from '@gmod/tabix'
27
27
  You can use tabix-js without NPM also with the tabix-bundle.js. See the example
28
28
  directory for usage with script tag [example/index.html](example/index.html)
29
29
 
30
- ```
31
- <script src="https://unpkg.com/@gmod/tabix/dist/tabix-bundle.js"></script>
30
+ ```html
31
+ <script src="https://unpkg.com/@gmod/tabix/dist/tabix-bundle.js"></script>
32
32
  ```
33
33
 
34
34
  ### TabixIndexedFile constructor
@@ -47,10 +47,10 @@ const tbiIndexed = new TabixIndexedFile({
47
47
 
48
48
  ```
49
49
 
50
- You can also use CSI indexes. Note also the usage of the renameRefSeqs callback.
51
- The renameRefSeqs callback makes it so that you can use
52
- file.getLines('1',0,100,...) even when the file itself contains names like
53
- 'chr1' (can also do the reverse by customizing the renameRefSeqs callback)
50
+ You can also use CSI indexes. Note also the usage of the `renameRefSeqs`
51
+ callback. The `renameRefSeqs` callback makes it so that you can use
52
+ `file.getLines('1',0,100,...)` even when the file itself contains names like
53
+ 'chr1' (can also do the reverse by customizing the `renameRefSeqs` callback)
54
54
 
55
55
  ```typescript
56
56
  // can also open tabix files that have a .csi index
@@ -64,9 +64,15 @@ const csiIndexed = new TabixIndexedFile({
64
64
 
65
65
  #### TabixIndexedFile constructor with remote files
66
66
 
67
- The basic usage of fetching remote files is done by supplying a
68
- [generic-filehandle](https://github.com/GMOD/generic-filehandle) module
69
- RemoteFile filehandle, as seen below
67
+ ```typescript
68
+ const remoteTbiIndexed = new TabixIndexedFile({
69
+ url: 'http://yourhost/file.vcf.gz',
70
+ tbiUrl: 'http://yourhost/file.vcf.gz.tbi', // can also be csiUrl
71
+ })
72
+ ```
73
+
74
+ You can also alternatively supply a filehandle-like object with the
75
+ [generic-filehandle](https://github.com/GMOD/generic-filehandle): example
70
76
 
71
77
  ```typescript
72
78
  // use a remote file or other filehandle, note RemoteFile comes from https://github.com/GMOD/generic-filehandle
@@ -77,9 +83,9 @@ const remoteTbiIndexed = new TabixIndexedFile({
77
83
  })
78
84
  ```
79
85
 
80
- This works in both the browser and in node.js, but note that in node.js you have
81
- to also supply a custom fetch function to the RemoteFile constructor e.g. like
82
- this
86
+ This works in both the browser and in node.js, but note that in node.js you may
87
+ have to also supply a custom fetch function to the RemoteFile constructor e.g.
88
+ like this
83
89
 
84
90
  ```typescript
85
91
  // for node.js you have to manually supply a fetch function e.g. node-fetch to RemoteFile
@@ -111,8 +117,8 @@ await tbiIndexed.getLines('ctgA', 200, 300, function (line, fileOffset) {
111
117
  After running this, your `lines` array would contain an array of lines from the
112
118
  file that match your query range
113
119
 
114
- You can also supply some extra arguments to getLines with this format, but these
115
- are sort of obscure and only used in some circumstances
120
+ You can also supply some extra arguments to `getLines` with this format, but
121
+ these are sort of obscure and only used in some circumstances
116
122
 
117
123
  ```typescript
118
124
  const lines = []
@@ -133,8 +139,8 @@ Notes about the returned values of `getLines`:
133
139
  - the callback is also called with a `fileOffset` that can be used to uniquely
134
140
  identify lines based on their virtual file offset where the line is found in
135
141
  the file
136
- - if getLines is called with an undefined `end` parameter it gets all lines from
137
- start going to the end of the contig e.g.
142
+ - if `getLines` is called with an undefined `end` parameter it gets all lines
143
+ from start going to the end of the contig e.g.
138
144
 
139
145
  ```typescript
140
146
  const lines = []
@@ -142,32 +148,164 @@ await tbiIndexed.getLines('ctgA', 0, undefined, line=>lines.push(line))`
142
148
  console.log(lines)
143
149
  ```
144
150
 
145
- ### lineCount
151
+ ## API (auto-generated)
152
+
153
+ ### TabixIndexedFile
154
+
155
+ <!-- Generated by documentation.js. Update this documentation by updating the source code. -->
156
+
157
+ ##### Table of Contents
158
+
159
+ - [constructor](#constructor)
160
+ - [Parameters](#parameters)
161
+ - [getLines](#getlines)
162
+ - [Parameters](#parameters-1)
163
+ - [getHeaderBuffer](#getheaderbuffer)
164
+ - [Parameters](#parameters-2)
165
+ - [getHeader](#getheader)
166
+ - [Parameters](#parameters-3)
167
+ - [getReferenceSequenceNames](#getreferencesequencenames)
168
+ - [Parameters](#parameters-4)
169
+ - [checkLine](#checkline)
170
+ - [Parameters](#parameters-5)
171
+ - [lineCount](#linecount)
172
+ - [Parameters](#parameters-6)
173
+ - [readChunk](#readchunk)
174
+ - [Parameters](#parameters-7)
175
+
176
+ #### constructor
177
+
178
+ ##### Parameters
179
+
180
+ - `args`
181
+ **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;
182
+
183
+ - `args.path`
184
+ **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?**&#x20;
185
+ - `args.filehandle` **filehandle?**&#x20;
186
+ - `args.url`
187
+ **[url](https://developer.mozilla.org/docs/Web/API/URL/URL)?**&#x20;
188
+ - `args.tbiPath`
189
+ **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?**&#x20;
190
+ - `args.tbiUrl` **tbiUrl?**&#x20;
191
+ - `args.tbiFilehandle` **filehandle?**&#x20;
192
+ - `args.csiPath`
193
+ **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?**&#x20;
194
+ - `args.csiUrl` **csiUrl?**&#x20;
195
+ - `args.csiFilehandle` **filehandle?**&#x20;
196
+ - `args.yieldTime`
197
+ **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?**
198
+ yield to main thread after N milliseconds if reading features is taking a
199
+ long time to avoid hanging main thread (optional, default `500`)
200
+ - `args.renameRefSeqs`
201
+ **[function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?**
202
+ optional function with sig `string => string` to transform reference
203
+ sequence names for the purpose of indexing and querying. note that the data
204
+ that is returned is not altered, just the names of the reference sequences
205
+ that are used for querying. (optional, default `n=>n`)
206
+ - `args.chunkCacheSize` (optional, default `5*2**20`)
207
+
208
+ #### getLines
209
+
210
+ ##### Parameters
211
+
212
+ - `refName`
213
+ **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
214
+ name of the reference sequence
215
+ - `s`
216
+ **([number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
217
+ |
218
+ [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**&#x20;
219
+ - `e`
220
+ **([number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
221
+ |
222
+ [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**&#x20;
223
+ - `opts` **(GetLinesOpts | GetLinesCallback)** callback called for each line in
224
+ the region. can also pass a object param containing obj.lineCallback,
225
+ obj.signal, etc
226
+ - `start` start of the region (in 0-based half-open coordinates)
227
+ - `end` end of the region (in 0-based half-open coordinates)
228
+
229
+ Returns **any** promise that is resolved when the whole read is finished,
230
+ rejected on error
146
231
 
147
- ```typescript
148
- // get the approximate number of data lines in the
149
- // file for the given reference sequence, excluding header, comment, and whitespace lines
150
- // uses the extra bin from tabix
151
- const numLines = await tbiIndexed.lineCount('ctgA')
152
- // or const numLines = await tbiIndexed.lineCount('ctgA', { signal: aborter.signal })
153
- ```
232
+ #### getHeaderBuffer
154
233
 
155
- ### getHeader
234
+ get a buffer containing the "header" region of the file, which are the bytes up
235
+ to the first non-meta line
156
236
 
157
- ```typescript
158
- // get the "header text" string from the file, which is the first contiguous
159
- // set of lines in the file that all start with a "meta" character (usually #)
160
- const headerText = await tbiIndexed.getHeader()
161
- // or const headerText = await tbiIndexed.getHeader({ signal: aborter.signal })
162
- ```
237
+ ##### Parameters
163
238
 
164
- #### getHeaderBuffer
239
+ - `opts` **Options** (optional, default `{}`)
165
240
 
166
- ```typescript
167
- // or if you want a nodejs Buffer object instead, there is getHeaderBuffer()
168
- const headerBuffer = await tbiIndexed.getHeaderBuffer()
169
- // or const headerBuffer = await tbiIndexed.getHeaderBuffer({ signal: aborter.signal })
170
- ```
241
+ #### getHeader
242
+
243
+ get a string containing the "header" region of the file, is the portion up to
244
+ the first non-meta line
245
+
246
+ ##### Parameters
247
+
248
+ - `opts` **Options** (optional, default `{}`)
249
+
250
+ Returns
251
+ **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)**
252
+ for a string
253
+
254
+ #### getReferenceSequenceNames
255
+
256
+ get an array of reference sequence names, in the order in which they occur in
257
+ the file. reference sequence renaming is not applied to these names.
258
+
259
+ ##### Parameters
260
+
261
+ - `opts` **Options** (optional, default `{}`)
262
+
263
+ #### checkLine
264
+
265
+ ##### Parameters
266
+
267
+ - `metadata`
268
+ **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
269
+ metadata object from the parsed index, containing columnNumbers, metaChar, and
270
+ format
271
+ - `regionRefName`
272
+ **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
273
+ - `regionStart`
274
+ **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
275
+ region start coordinate (0-based-half-open)
276
+ - `regionEnd`
277
+ **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
278
+ region end coordinate (0-based-half-open)
279
+ - `line`
280
+ **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
281
+
282
+ Returns
283
+ **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
284
+ like `{startCoordinate, overlaps}`. overlaps is boolean, true if line is a data
285
+ line that overlaps the given region
286
+
287
+ #### lineCount
288
+
289
+ return the approximate number of data lines in the given reference sequence
290
+
291
+ ##### Parameters
292
+
293
+ - `refName`
294
+ **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
295
+ - `opts` **Options** (optional, default `{}`)
296
+ - `refSeq` reference sequence name
297
+
298
+ Returns **any** number of data lines present on that reference sequence
299
+
300
+ #### readChunk
301
+
302
+ read and uncompress the data in a chunk (composed of one or more contiguous
303
+ bgzip blocks) of the file
304
+
305
+ ##### Parameters
306
+
307
+ - `c` **Chunk**&#x20;
308
+ - `opts` **Options** (optional, default `{}`)
171
309
 
172
310
  ## Academic Use
173
311
 
package/dist/chunk.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"chunk.js","sourceRoot":"","sources":["../src/chunk.ts"],"names":[],"mappings":";;AAEA,iDAAiD;AACjD,MAAqB,KAAK;IAMxB,YACE,IAAmB,EACnB,IAAmB,EACnB,GAAW,EACX,WAAW,GAAG,SAAS;QAEvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,YAAY,GAAG,WAAW,CAAA;IACjC,CAAC;IAED,cAAc;QAEZ,OAAO,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,SAC/B,IAAI,CAAC,GACP,iBAAiB,IAAI,CAAC,WAAW,EAAE,GAAG,CAAA;IACxC,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,cAAc,EAAE,CAAA;IAC9B,CAAC;IAED,SAAS,CAAC,CAAQ;QAChB,OAAO,CACL,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;YAC3B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;YAC3B,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CACjB,CAAA;IACH,CAAC;IAED,WAAW;QACT,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACpC,OAAO,IAAI,CAAC,YAAY,CAAA;QAC1B,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAA;IACtE,CAAC;CACF;AA3CD,wBA2CC"}
1
+ {"version":3,"file":"chunk.js","sourceRoot":"","sources":["../src/chunk.ts"],"names":[],"mappings":";;AAEA,iDAAiD;AACjD,MAAqB,KAAK;IAMxB,YACE,IAAmB,EACnB,IAAmB,EACnB,GAAW,EACX,WAAW,GAAG,SAAS;QAEvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,YAAY,GAAG,WAAW,CAAA;IACjC,CAAC;IAED,cAAc;QACZ,OAAO,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,SAC/B,IAAI,CAAC,GACP,iBAAiB,IAAI,CAAC,WAAW,EAAE,GAAG,CAAA;IACxC,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,cAAc,EAAE,CAAA;IAC9B,CAAC;IAED,SAAS,CAAC,CAAQ;QAChB,OAAO,CACL,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;YAC3B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;YAC3B,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CACjB,CAAA;IACH,CAAC;IAED,WAAW;QACT,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACpC,OAAO,IAAI,CAAC,YAAY,CAAA;QAC1B,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAA;IACtE,CAAC;CACF;AA1CD,wBA0CC"}
package/dist/csi.js CHANGED
@@ -22,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
35
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
27
  };
@@ -44,10 +35,10 @@ const indexFile_1 = __importDefault(require("./indexFile"));
44
35
  const CSI1_MAGIC = 21582659; // CSI\1
45
36
  const CSI2_MAGIC = 38359875; // CSI\2
46
37
  function lshift(num, bits) {
47
- return num * Math.pow(2, bits);
38
+ return num * 2 ** bits;
48
39
  }
49
40
  function rshift(num, bits) {
50
- return Math.floor(num / Math.pow(2, bits));
41
+ return Math.floor(num / 2 ** bits);
51
42
  }
52
43
  class CSI extends indexFile_1.default {
53
44
  constructor(args) {
@@ -56,23 +47,21 @@ class CSI extends indexFile_1.default {
56
47
  this.depth = 0;
57
48
  this.minShift = 0;
58
49
  }
59
- lineCount(refName_1) {
60
- return __awaiter(this, arguments, void 0, function* (refName, opts = {}) {
61
- const indexData = yield this.parse(opts);
62
- const refId = indexData.refNameToId[refName];
63
- if (refId === undefined) {
64
- return -1;
65
- }
66
- const idx = indexData.indices[refId];
67
- if (!idx) {
68
- return -1;
69
- }
70
- const { stats } = indexData.indices[refId];
71
- if (stats) {
72
- return stats.lineCount;
73
- }
50
+ async lineCount(refName, opts = {}) {
51
+ const indexData = await this.parse(opts);
52
+ const refId = indexData.refNameToId[refName];
53
+ if (refId === undefined) {
74
54
  return -1;
75
- });
55
+ }
56
+ const idx = indexData.indices[refId];
57
+ if (!idx) {
58
+ return -1;
59
+ }
60
+ const { stats } = indexData.indices[refId];
61
+ if (stats) {
62
+ return stats.lineCount;
63
+ }
64
+ return -1;
76
65
  }
77
66
  indexCov() {
78
67
  throw new Error('CSI indexes do not support indexcov');
@@ -124,110 +113,115 @@ class CSI extends indexFile_1.default {
124
113
  return { refNameToId, refIdToName };
125
114
  }
126
115
  // fetch and parse the index
127
- _parse() {
128
- return __awaiter(this, arguments, void 0, function* (opts = {}) {
129
- const bytes = yield (0, bgzf_filehandle_1.unzip)(yield this.filehandle.readFile(opts));
130
- // check TBI magic numbers
131
- let csiVersion;
132
- if (bytes.readUInt32LE(0) === CSI1_MAGIC) {
133
- csiVersion = 1;
134
- }
135
- else if (bytes.readUInt32LE(0) === CSI2_MAGIC) {
136
- csiVersion = 2;
137
- }
138
- else {
139
- throw new Error('Not a CSI file');
140
- // TODO: do we need to support big-endian CSI files?
141
- }
142
- this.minShift = bytes.readInt32LE(4);
143
- this.depth = bytes.readInt32LE(8);
144
- this.maxBinNumber = ((1 << ((this.depth + 1) * 3)) - 1) / 7;
145
- const maxRefLength = Math.pow(2, (this.minShift + this.depth * 3));
146
- const auxLength = bytes.readInt32LE(12);
147
- const aux = auxLength && auxLength >= 30
148
- ? this.parseAuxData(bytes, 16)
149
- : {
150
- refIdToName: [],
151
- refNameToId: {},
152
- metaChar: null,
153
- columnNumbers: { ref: 0, start: 1, end: 2 },
154
- coordinateType: 'zero-based-half-open',
155
- format: 'generic',
156
- };
157
- const refCount = bytes.readInt32LE(16 + auxLength);
158
- // read the indexes for each reference sequence
159
- let firstDataLine;
160
- let currOffset = 16 + auxLength + 4;
161
- const indices = new Array(refCount).fill(0).map(() => {
162
- // the binning index
163
- const binCount = bytes.readInt32LE(currOffset);
164
- currOffset += 4;
165
- const binIndex = {};
166
- let stats; // < provided by parsing a pseudo-bin, if present
167
- for (let j = 0; j < binCount; j += 1) {
168
- const bin = bytes.readUInt32LE(currOffset);
169
- if (bin > this.maxBinNumber) {
170
- // this is a fake bin that actually has stats information
171
- // about the reference sequence in it
172
- stats = this.parsePseudoBin(bytes, currOffset + 4);
173
- currOffset += 4 + 8 + 4 + 16 + 16;
174
- }
175
- else {
176
- const loffset = (0, virtualOffset_1.fromBytes)(bytes, currOffset + 4);
177
- firstDataLine = this._findFirstData(firstDataLine, loffset);
178
- const chunkCount = bytes.readInt32LE(currOffset + 12);
116
+ async _parse(opts = {}) {
117
+ const bytes = await (0, bgzf_filehandle_1.unzip)(await this.filehandle.readFile(opts));
118
+ // check TBI magic numbers
119
+ let csiVersion;
120
+ if (bytes.readUInt32LE(0) === CSI1_MAGIC) {
121
+ csiVersion = 1;
122
+ }
123
+ else if (bytes.readUInt32LE(0) === CSI2_MAGIC) {
124
+ csiVersion = 2;
125
+ }
126
+ else {
127
+ throw new Error('Not a CSI file');
128
+ // TODO: do we need to support big-endian CSI files?
129
+ }
130
+ this.minShift = bytes.readInt32LE(4);
131
+ this.depth = bytes.readInt32LE(8);
132
+ this.maxBinNumber = ((1 << ((this.depth + 1) * 3)) - 1) / 7;
133
+ const maxRefLength = 2 ** (this.minShift + this.depth * 3);
134
+ const auxLength = bytes.readInt32LE(12);
135
+ const aux = auxLength && auxLength >= 30
136
+ ? this.parseAuxData(bytes, 16)
137
+ : {
138
+ refIdToName: [],
139
+ refNameToId: {},
140
+ metaChar: null,
141
+ columnNumbers: { ref: 0, start: 1, end: 2 },
142
+ coordinateType: 'zero-based-half-open',
143
+ format: 'generic',
144
+ };
145
+ const refCount = bytes.readInt32LE(16 + auxLength);
146
+ // read the indexes for each reference sequence
147
+ let firstDataLine;
148
+ let currOffset = 16 + auxLength + 4;
149
+ const indices = new Array(refCount).fill(0).map(() => {
150
+ // the binning index
151
+ const binCount = bytes.readInt32LE(currOffset);
152
+ currOffset += 4;
153
+ const binIndex = {};
154
+ let stats; // < provided by parsing a pseudo-bin, if present
155
+ for (let j = 0; j < binCount; j += 1) {
156
+ const bin = bytes.readUInt32LE(currOffset);
157
+ if (bin > this.maxBinNumber) {
158
+ // this is a fake bin that actually has stats information
159
+ // about the reference sequence in it
160
+ stats = this.parsePseudoBin(bytes, currOffset + 4);
161
+ currOffset += 4 + 8 + 4 + 16 + 16;
162
+ }
163
+ else {
164
+ const loffset = (0, virtualOffset_1.fromBytes)(bytes, currOffset + 4);
165
+ firstDataLine = this._findFirstData(firstDataLine, loffset);
166
+ const chunkCount = bytes.readInt32LE(currOffset + 12);
167
+ currOffset += 16;
168
+ const chunks = new Array(chunkCount);
169
+ for (let k = 0; k < chunkCount; k += 1) {
170
+ const u = (0, virtualOffset_1.fromBytes)(bytes, currOffset);
171
+ const v = (0, virtualOffset_1.fromBytes)(bytes, currOffset + 8);
179
172
  currOffset += 16;
180
- const chunks = new Array(chunkCount);
181
- for (let k = 0; k < chunkCount; k += 1) {
182
- const u = (0, virtualOffset_1.fromBytes)(bytes, currOffset);
183
- const v = (0, virtualOffset_1.fromBytes)(bytes, currOffset + 8);
184
- currOffset += 16;
185
- // this._findFirstData(data, u)
186
- chunks[k] = new chunk_1.default(u, v, bin);
187
- }
188
- binIndex[bin] = chunks;
173
+ // this._findFirstData(data, u)
174
+ chunks[k] = new chunk_1.default(u, v, bin);
189
175
  }
176
+ binIndex[bin] = chunks;
190
177
  }
191
- return { binIndex, stats };
192
- });
193
- return Object.assign(Object.assign({}, aux), { csi: true, refCount, maxBlockSize: 1 << 16, firstDataLine,
194
- csiVersion,
195
- indices, depth: this.depth, maxBinNumber: this.maxBinNumber, maxRefLength });
178
+ }
179
+ return { binIndex, stats };
196
180
  });
181
+ return {
182
+ ...aux,
183
+ csi: true,
184
+ refCount,
185
+ maxBlockSize: 1 << 16,
186
+ firstDataLine,
187
+ csiVersion,
188
+ indices,
189
+ depth: this.depth,
190
+ maxBinNumber: this.maxBinNumber,
191
+ maxRefLength,
192
+ };
197
193
  }
198
194
  parsePseudoBin(bytes, offset) {
199
195
  const lineCount = (0, util_1.longToNumber)(long_1.default.fromBytesLE(bytes.slice(offset + 28, offset + 36), true));
200
196
  return { lineCount };
201
197
  }
202
- blocksForRange(refName_1, min_1, max_1) {
203
- return __awaiter(this, arguments, void 0, function* (refName, min, max, opts = {}) {
204
- if (min < 0) {
205
- min = 0;
206
- }
207
- const indexData = yield this.parse(opts);
208
- const refId = indexData.refNameToId[refName];
209
- if (refId === undefined) {
210
- return [];
211
- }
212
- const ba = indexData.indices[refId];
213
- if (!ba) {
214
- return [];
215
- }
216
- // const { linearIndex, binIndex } = indexes
217
- const overlappingBins = this.reg2bins(min, max); // List of bin #s that overlap min, max
218
- const chunks = [];
219
- // Find chunks in overlapping bins. Leaf bins (< 4681) are not pruned
220
- for (const [start, end] of overlappingBins) {
221
- for (let bin = start; bin <= end; bin++) {
222
- if (ba.binIndex[bin]) {
223
- for (const c of ba.binIndex[bin]) {
224
- chunks.push(new chunk_1.default(c.minv, c.maxv, bin));
225
- }
198
+ async blocksForRange(refName, min, max, opts = {}) {
199
+ if (min < 0) {
200
+ min = 0;
201
+ }
202
+ const indexData = await this.parse(opts);
203
+ const refId = indexData.refNameToId[refName];
204
+ if (refId === undefined) {
205
+ return [];
206
+ }
207
+ const ba = indexData.indices[refId];
208
+ if (!ba) {
209
+ return [];
210
+ }
211
+ // const { linearIndex, binIndex } = indexes
212
+ const overlappingBins = this.reg2bins(min, max); // List of bin #s that overlap min, max
213
+ const chunks = [];
214
+ // Find chunks in overlapping bins. Leaf bins (< 4681) are not pruned
215
+ for (const [start, end] of overlappingBins) {
216
+ for (let bin = start; bin <= end; bin++) {
217
+ if (ba.binIndex[bin]) {
218
+ for (const c of ba.binIndex[bin]) {
219
+ chunks.push(new chunk_1.default(c.minv, c.maxv, bin));
226
220
  }
227
221
  }
228
222
  }
229
- return (0, util_1.optimizeChunks)(chunks, new virtualOffset_1.default(0, 0));
230
- });
223
+ }
224
+ return (0, util_1.optimizeChunks)(chunks, new virtualOffset_1.default(0, 0));
231
225
  }
232
226
  /**
233
227
  * calculate the list of bins that may overlap with region [beg,end) (zero-based half-open)
@@ -237,8 +231,8 @@ class CSI extends indexFile_1.default {
237
231
  if (beg < 1) {
238
232
  beg = 1;
239
233
  }
240
- if (end > Math.pow(2, 50)) {
241
- end = Math.pow(2, 34);
234
+ if (end > 2 ** 50) {
235
+ end = 2 ** 34;
242
236
  } // 17 GiB ought to be enough for anybody
243
237
  end -= 1;
244
238
  let l = 0;
package/dist/csi.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"csi.js","sourceRoot":"","sources":["../src/csi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAuB;AAEvB,2DAA6C;AAE7C,iEAA0D;AAC1D,oDAA2B;AAC3B,iCAAqD;AAErD,4DAAgD;AAEhD,MAAM,UAAU,GAAG,QAAQ,CAAA,CAAC,QAAQ;AACpC,MAAM,UAAU,GAAG,QAAQ,CAAA,CAAC,QAAQ;AAEpC,SAAS,MAAM,CAAC,GAAW,EAAE,IAAY;IACvC,OAAO,GAAG,GAAG,SAAA,CAAC,EAAI,IAAI,CAAA,CAAA;AACxB,CAAC;AACD,SAAS,MAAM,CAAC,GAAW,EAAE,IAAY;IACvC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,SAAA,CAAC,EAAI,IAAI,CAAA,CAAC,CAAA;AACpC,CAAC;AAED,MAAqB,GAAI,SAAQ,mBAAS;IAIxC,YAAY,IAAS;QACnB,KAAK,CAAC,IAAI,CAAC,CAAA;QACX,IAAI,CAAC,YAAY,GAAG,CAAC,CAAA;QACrB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAA;QACd,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAA;IACnB,CAAC;IACK,SAAS;6DAAC,OAAe,EAAE,OAAgB,EAAE;YACjD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;YACxC,MAAM,KAAK,GAAG,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;YAC5C,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,OAAO,CAAC,CAAC,CAAA;YACX,CAAC;YACD,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;YACpC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