@gmod/tabix 1.5.14 → 1.6.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/CHANGELOG.md +9 -5
- package/README.md +182 -35
- package/dist/chunk.js +0 -1
- package/dist/chunk.js.map +1 -1
- package/dist/csi.d.ts +1 -1
- package/dist/csi.js +132 -128
- package/dist/csi.js.map +1 -1
- package/dist/indexFile.js +15 -41
- package/dist/indexFile.js.map +1 -1
- package/dist/tabix-bundle.js +2 -0
- package/dist/tabix-bundle.js.LICENSE.txt +8 -0
- package/dist/tabixIndexedFile.d.ts +49 -25
- package/dist/tabixIndexedFile.js +214 -195
- package/dist/tabixIndexedFile.js.map +1 -1
- package/dist/tbi.js +169 -173
- package/dist/tbi.js.map +1 -1
- package/dist/util.d.ts +7 -6
- package/dist/util.js +9 -19
- package/dist/util.js.map +1 -1
- package/dist/virtualOffset.d.ts +0 -1
- package/dist/virtualOffset.js +0 -13
- package/dist/virtualOffset.js.map +1 -1
- package/esm/chunk.js +0 -1
- package/esm/chunk.js.map +1 -1
- package/esm/csi.d.ts +1 -1
- package/esm/csi.js +4 -4
- package/esm/csi.js.map +1 -1
- package/esm/indexFile.js +1 -1
- package/esm/indexFile.js.map +1 -1
- package/esm/tabixIndexedFile.d.ts +49 -25
- package/esm/tabixIndexedFile.js +134 -90
- package/esm/tabixIndexedFile.js.map +1 -1
- package/esm/tbi.js +6 -5
- package/esm/tbi.js.map +1 -1
- package/esm/util.d.ts +7 -6
- package/esm/util.js +6 -5
- package/esm/util.js.map +1 -1
- package/esm/virtualOffset.d.ts +0 -1
- package/esm/virtualOffset.js +0 -13
- package/esm/virtualOffset.js.map +1 -1
- package/package.json +24 -19
- package/src/chunk.ts +0 -1
- package/src/csi.ts +6 -5
- package/src/indexFile.ts +1 -1
- package/src/tabixIndexedFile.ts +141 -106
- package/src/tbi.ts +7 -6
- package/src/util.ts +7 -6
- package/src/virtualOffset.ts +7 -21
package/esm/csi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csi.js","sourceRoot":"","sources":["../src/csi.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAE7C,OAAO,aAAa,EAAE,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,KAAK,MAAM,SAAS,CAAA;AAC3B,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAErD,OAAO,SAAsB,MAAM,aAAa,CAAA;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,CAAC,IAAI,IAAI,CAAA;AACxB,CAAC;AACD,SAAS,MAAM,CAAC,GAAW,EAAE,IAAY;IACvC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,IAAI,IAAI,CAAC,CAAA;AACpC,CAAC;AAED,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ,SAAS;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;IACD,KAAK,CAAC,SAAS,CAAC,OAAe,EAAE,OAAgB,EAAE;QACjD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACxC,
|
|
1
|
+
{"version":3,"file":"csi.js","sourceRoot":"","sources":["../src/csi.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,EAAE,KAAK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EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC7D,OAAO,IAAI,CAAA;IACb,CAAC;IASD,cAAc,CACZ,UAAqC,EACrC,aAA4B;QAE5B,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,UAAU,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,CAAC;gBAC5C,CAAC,CAAC,aAAa;gBACf,CAAC,CAAC,UAAU,CAAA;QAChB,CAAC;aAAM,CAAC;YACN,OAAO,aAAa,CAAA;QACtB,CAAC;IACH,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,OAAgB,EAAE;QAC5B,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAU,EAAE,EAAE;gBACnD,IAAI,CAAC,MAAM,GAAG,SAAS,CAAA;gBACvB,MAAM,CAAC,CAAA;YACT,CAAC,CAAC,CAAA;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,KAAa,EAAE,OAAgB,EAAE;;QAC/C,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAClC,OAAO,CAAC,CAAC,CAAA,MAAA,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,0CAAE,QAAQ,CAAA,CAAA;IACvC,CAAC;CACF"}
|
|
@@ -11,41 +11,59 @@ interface GetLinesOpts {
|
|
|
11
11
|
export default class TabixIndexedFile {
|
|
12
12
|
private filehandle;
|
|
13
13
|
private index;
|
|
14
|
-
private chunkSizeLimit;
|
|
15
|
-
private yieldTime;
|
|
16
14
|
private renameRefSeq;
|
|
17
15
|
private chunkCache;
|
|
18
16
|
/**
|
|
19
17
|
* @param {object} args
|
|
18
|
+
*
|
|
20
19
|
* @param {string} [args.path]
|
|
20
|
+
*
|
|
21
21
|
* @param {filehandle} [args.filehandle]
|
|
22
|
+
*
|
|
22
23
|
* @param {string} [args.tbiPath]
|
|
24
|
+
*
|
|
23
25
|
* @param {filehandle} [args.tbiFilehandle]
|
|
26
|
+
*
|
|
24
27
|
* @param {string} [args.csiPath]
|
|
28
|
+
*
|
|
25
29
|
* @param {filehandle} [args.csiFilehandle]
|
|
26
|
-
*
|
|
27
|
-
* @param {
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
+
*
|
|
31
|
+
* @param {url} [args.url]
|
|
32
|
+
*
|
|
33
|
+
* @param {csiUrl} [args.csiUrl]
|
|
34
|
+
*
|
|
35
|
+
* @param {tbiUrl} [args.tbiUrl]
|
|
36
|
+
*
|
|
37
|
+
* @param {function} [args.renameRefSeqs] optional function with sig `string
|
|
38
|
+
* => string` to transform reference sequence names for the purpose of
|
|
39
|
+
* indexing and querying. note that the data that is returned is not altered,
|
|
40
|
+
* just the names of the reference sequences that are used for querying.
|
|
30
41
|
*/
|
|
31
|
-
constructor({ path, filehandle, tbiPath, tbiFilehandle, csiPath,
|
|
42
|
+
constructor({ path, filehandle, url, tbiPath, tbiUrl, tbiFilehandle, csiPath, csiUrl, csiFilehandle, renameRefSeqs, chunkCacheSize, }: {
|
|
32
43
|
path?: string;
|
|
33
44
|
filehandle?: GenericFilehandle;
|
|
45
|
+
url?: string;
|
|
34
46
|
tbiPath?: string;
|
|
47
|
+
tbiUrl?: string;
|
|
35
48
|
tbiFilehandle?: GenericFilehandle;
|
|
36
49
|
csiPath?: string;
|
|
50
|
+
csiUrl?: string;
|
|
37
51
|
csiFilehandle?: GenericFilehandle;
|
|
38
|
-
yieldTime?: number;
|
|
39
|
-
chunkSizeLimit?: number;
|
|
40
52
|
renameRefSeqs?: (n: string) => string;
|
|
41
53
|
chunkCacheSize?: number;
|
|
42
54
|
});
|
|
43
55
|
/**
|
|
44
56
|
* @param refName name of the reference sequence
|
|
57
|
+
*
|
|
45
58
|
* @param start start of the region (in 0-based half-open coordinates)
|
|
59
|
+
*
|
|
46
60
|
* @param end end of the region (in 0-based half-open coordinates)
|
|
47
|
-
*
|
|
48
|
-
* @
|
|
61
|
+
*
|
|
62
|
+
* @param opts callback called for each line in the region. can also pass a
|
|
63
|
+
* object param containing obj.lineCallback, obj.signal, etc
|
|
64
|
+
*
|
|
65
|
+
* @returns promise that is resolved when the whole read is finished,
|
|
66
|
+
* rejected on error
|
|
49
67
|
*/
|
|
50
68
|
getLines(refName: string, s: number | undefined, e: number | undefined, opts: GetLinesOpts | GetLinesCallback): Promise<void>;
|
|
51
69
|
getMetadata(opts?: Options): Promise<{
|
|
@@ -62,31 +80,34 @@ export default class TabixIndexedFile {
|
|
|
62
80
|
format: string;
|
|
63
81
|
}>;
|
|
64
82
|
/**
|
|
65
|
-
* get a buffer containing the "header" region of
|
|
66
|
-
*
|
|
67
|
-
* non-meta line
|
|
83
|
+
* get a buffer containing the "header" region of the file, which are the
|
|
84
|
+
* bytes up to the first non-meta line
|
|
68
85
|
*/
|
|
69
|
-
getHeaderBuffer(opts?: Options): Promise<Buffer
|
|
86
|
+
getHeaderBuffer(opts?: Options): Promise<Buffer<Uint8Array<ArrayBuffer>>>;
|
|
70
87
|
/**
|
|
71
|
-
* get a string containing the "header" region of the
|
|
72
|
-
*
|
|
88
|
+
* get a string containing the "header" region of the file, is the portion up
|
|
89
|
+
* to the first non-meta line
|
|
73
90
|
*
|
|
74
91
|
* @returns {Promise} for a string
|
|
75
92
|
*/
|
|
76
93
|
getHeader(opts?: Options): Promise<string>;
|
|
77
94
|
/**
|
|
78
|
-
* get an array of reference sequence names, in the order in which
|
|
79
|
-
*
|
|
80
|
-
* to these names.
|
|
95
|
+
* get an array of reference sequence names, in the order in which they occur
|
|
96
|
+
* in the file. reference sequence renaming is not applied to these names.
|
|
81
97
|
*/
|
|
82
98
|
getReferenceSequenceNames(opts?: Options): Promise<string[]>;
|
|
83
99
|
/**
|
|
84
|
-
* @param {object} metadata metadata object from the parsed index,
|
|
85
|
-
*
|
|
100
|
+
* @param {object} metadata metadata object from the parsed index, containing
|
|
101
|
+
* columnNumbers, metaChar, and format
|
|
102
|
+
*
|
|
86
103
|
* @param {string} regionRefName
|
|
104
|
+
*
|
|
87
105
|
* @param {number} regionStart region start coordinate (0-based-half-open)
|
|
106
|
+
*
|
|
88
107
|
* @param {number} regionEnd region end coordinate (0-based-half-open)
|
|
108
|
+
*
|
|
89
109
|
* @param {array[string]} line
|
|
110
|
+
*
|
|
90
111
|
* @returns {object} like `{startCoordinate, overlaps}`. overlaps is boolean,
|
|
91
112
|
* true if line is a data line that overlaps the given region
|
|
92
113
|
*/
|
|
@@ -99,18 +120,21 @@ export default class TabixIndexedFile {
|
|
|
99
120
|
};
|
|
100
121
|
_getVcfEnd(startCoordinate: number, refSeq: string, info: any): number;
|
|
101
122
|
/**
|
|
102
|
-
* return the approximate number of data lines in the given reference
|
|
123
|
+
* return the approximate number of data lines in the given reference
|
|
124
|
+
* sequence
|
|
125
|
+
*
|
|
103
126
|
* @param refSeq reference sequence name
|
|
127
|
+
*
|
|
104
128
|
* @returns number of data lines present on that reference sequence
|
|
105
129
|
*/
|
|
106
130
|
lineCount(refName: string, opts?: Options): Promise<number>;
|
|
107
|
-
_readRegion(pos: number, size: number, opts?: Options): Promise<Buffer
|
|
131
|
+
_readRegion(pos: number, size: number, opts?: Options): Promise<Buffer<ArrayBufferLike>>;
|
|
108
132
|
/**
|
|
109
133
|
* read and uncompress the data in a chunk (composed of one or more
|
|
110
134
|
* contiguous bgzip blocks) of the file
|
|
111
135
|
*/
|
|
112
136
|
readChunk(c: Chunk, opts?: Options): Promise<{
|
|
113
|
-
buffer: Buffer
|
|
137
|
+
buffer: Buffer<Uint8Array<ArrayBuffer>>;
|
|
114
138
|
cpositions: number[];
|
|
115
139
|
dpositions: number[];
|
|
116
140
|
}>;
|
package/esm/tabixIndexedFile.js
CHANGED
|
@@ -1,36 +1,53 @@
|
|
|
1
1
|
import AbortablePromiseCache from '@gmod/abortable-promise-cache';
|
|
2
2
|
import LRU from 'quick-lru';
|
|
3
3
|
import { Buffer } from 'buffer';
|
|
4
|
-
import { LocalFile } from 'generic-filehandle';
|
|
4
|
+
import { RemoteFile, LocalFile } from 'generic-filehandle';
|
|
5
5
|
import { unzip, unzipChunkSlice } from '@gmod/bgzf-filehandle';
|
|
6
6
|
import { checkAbortSignal } from './util';
|
|
7
7
|
import TBI from './tbi';
|
|
8
8
|
import CSI from './csi';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return
|
|
9
|
+
function isASCII(str) {
|
|
10
|
+
// eslint-disable-next-line no-control-regex
|
|
11
|
+
return /^[\u0000-\u007F]*$/.test(str);
|
|
12
12
|
}
|
|
13
|
+
const decoder = typeof TextDecoder !== 'undefined' ? new TextDecoder('utf8') : undefined;
|
|
13
14
|
export default class TabixIndexedFile {
|
|
14
15
|
/**
|
|
15
16
|
* @param {object} args
|
|
17
|
+
*
|
|
16
18
|
* @param {string} [args.path]
|
|
19
|
+
*
|
|
17
20
|
* @param {filehandle} [args.filehandle]
|
|
21
|
+
*
|
|
18
22
|
* @param {string} [args.tbiPath]
|
|
23
|
+
*
|
|
19
24
|
* @param {filehandle} [args.tbiFilehandle]
|
|
25
|
+
*
|
|
20
26
|
* @param {string} [args.csiPath]
|
|
27
|
+
*
|
|
21
28
|
* @param {filehandle} [args.csiFilehandle]
|
|
22
|
-
*
|
|
23
|
-
* @param {
|
|
24
|
-
*
|
|
25
|
-
*
|
|
29
|
+
*
|
|
30
|
+
* @param {url} [args.url]
|
|
31
|
+
*
|
|
32
|
+
* @param {csiUrl} [args.csiUrl]
|
|
33
|
+
*
|
|
34
|
+
* @param {tbiUrl} [args.tbiUrl]
|
|
35
|
+
*
|
|
36
|
+
* @param {function} [args.renameRefSeqs] optional function with sig `string
|
|
37
|
+
* => string` to transform reference sequence names for the purpose of
|
|
38
|
+
* indexing and querying. note that the data that is returned is not altered,
|
|
39
|
+
* just the names of the reference sequences that are used for querying.
|
|
26
40
|
*/
|
|
27
|
-
constructor({ path, filehandle, tbiPath, tbiFilehandle, csiPath,
|
|
41
|
+
constructor({ path, filehandle, url, tbiPath, tbiUrl, tbiFilehandle, csiPath, csiUrl, csiFilehandle, renameRefSeqs = n => n, chunkCacheSize = 5 * 2 ** 20, }) {
|
|
28
42
|
if (filehandle) {
|
|
29
43
|
this.filehandle = filehandle;
|
|
30
44
|
}
|
|
31
45
|
else if (path) {
|
|
32
46
|
this.filehandle = new LocalFile(path);
|
|
33
47
|
}
|
|
48
|
+
else if (url) {
|
|
49
|
+
this.filehandle = new RemoteFile(url);
|
|
50
|
+
}
|
|
34
51
|
else {
|
|
35
52
|
throw new TypeError('must provide either filehandle or path');
|
|
36
53
|
}
|
|
@@ -64,12 +81,25 @@ export default class TabixIndexedFile {
|
|
|
64
81
|
renameRefSeqs,
|
|
65
82
|
});
|
|
66
83
|
}
|
|
84
|
+
else if (csiUrl) {
|
|
85
|
+
this.index = new CSI({
|
|
86
|
+
filehandle: new RemoteFile(csiUrl),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
else if (tbiUrl) {
|
|
90
|
+
this.index = new TBI({
|
|
91
|
+
filehandle: new RemoteFile(tbiUrl),
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
else if (url) {
|
|
95
|
+
this.index = new TBI({
|
|
96
|
+
filehandle: new RemoteFile(`${url}.tbi`),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
67
99
|
else {
|
|
68
|
-
throw new TypeError('must provide one of tbiFilehandle, tbiPath, csiFilehandle,
|
|
100
|
+
throw new TypeError('must provide one of tbiFilehandle, tbiPath, csiFilehandle, csiPath, tbiUrl, csiUrl');
|
|
69
101
|
}
|
|
70
|
-
this.chunkSizeLimit = chunkSizeLimit;
|
|
71
102
|
this.renameRefSeq = renameRefSeqs;
|
|
72
|
-
this.yieldTime = yieldTime;
|
|
73
103
|
this.chunkCache = new AbortablePromiseCache({
|
|
74
104
|
cache: new LRU({ maxSize: Math.floor(chunkCacheSize / (1 << 16)) }),
|
|
75
105
|
fill: (args, signal) => this.readChunk(args, { signal }),
|
|
@@ -77,19 +107,22 @@ export default class TabixIndexedFile {
|
|
|
77
107
|
}
|
|
78
108
|
/**
|
|
79
109
|
* @param refName name of the reference sequence
|
|
110
|
+
*
|
|
80
111
|
* @param start start of the region (in 0-based half-open coordinates)
|
|
112
|
+
*
|
|
81
113
|
* @param end end of the region (in 0-based half-open coordinates)
|
|
82
|
-
*
|
|
83
|
-
* @
|
|
114
|
+
*
|
|
115
|
+
* @param opts callback called for each line in the region. can also pass a
|
|
116
|
+
* object param containing obj.lineCallback, obj.signal, etc
|
|
117
|
+
*
|
|
118
|
+
* @returns promise that is resolved when the whole read is finished,
|
|
119
|
+
* rejected on error
|
|
84
120
|
*/
|
|
85
121
|
async getLines(refName, s, e, opts) {
|
|
86
|
-
var _a;
|
|
122
|
+
var _a, _b;
|
|
87
123
|
let signal;
|
|
88
124
|
let options = {};
|
|
89
125
|
let callback;
|
|
90
|
-
if (opts === undefined) {
|
|
91
|
-
throw new TypeError('line callback must be provided');
|
|
92
|
-
}
|
|
93
126
|
if (typeof opts === 'function') {
|
|
94
127
|
callback = opts;
|
|
95
128
|
}
|
|
@@ -98,12 +131,6 @@ export default class TabixIndexedFile {
|
|
|
98
131
|
callback = opts.lineCallback;
|
|
99
132
|
signal = opts.signal;
|
|
100
133
|
}
|
|
101
|
-
if (refName === undefined) {
|
|
102
|
-
throw new TypeError('must provide a reference sequence name');
|
|
103
|
-
}
|
|
104
|
-
if (!callback) {
|
|
105
|
-
throw new TypeError('line callback must be provided');
|
|
106
|
-
}
|
|
107
134
|
const metadata = await this.index.getMetadata(options);
|
|
108
135
|
checkAbortSignal(signal);
|
|
109
136
|
const start = s !== null && s !== void 0 ? s : 0;
|
|
@@ -116,70 +143,66 @@ export default class TabixIndexedFile {
|
|
|
116
143
|
}
|
|
117
144
|
const chunks = await this.index.blocksForRange(refName, start, end, options);
|
|
118
145
|
checkAbortSignal(signal);
|
|
119
|
-
// check the chunks for any that are over the size limit. if
|
|
120
|
-
// any are, don't fetch any of them
|
|
121
|
-
for (const chunk of chunks) {
|
|
122
|
-
const size = chunk.fetchedSize();
|
|
123
|
-
if (size > this.chunkSizeLimit) {
|
|
124
|
-
throw new Error(`Too much data. Chunk size ${size.toLocaleString()} bytes exceeds chunkSizeLimit of ${this.chunkSizeLimit.toLocaleString()}.`);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
146
|
// now go through each chunk and parse and filter the lines out of it
|
|
128
|
-
let last = Date.now();
|
|
129
147
|
for (const c of chunks) {
|
|
130
|
-
let previousStartCoordinate;
|
|
131
148
|
const { buffer, cpositions, dpositions } = await this.chunkCache.get(c.toString(), c, signal);
|
|
132
149
|
checkAbortSignal(signal);
|
|
133
150
|
let blockStart = 0;
|
|
134
151
|
let pos = 0;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
152
|
+
const str = (_a = decoder === null || decoder === void 0 ? void 0 : decoder.decode(buffer)) !== null && _a !== void 0 ? _a : buffer.toString();
|
|
153
|
+
// fast path, Buffer is just ASCII chars and not gigantor, can be
|
|
154
|
+
// converted to string and processed directly. if it is not ASCII or
|
|
155
|
+
// gigantic (chrome max str len is 512Mb), we have to decode line by line
|
|
156
|
+
const strIsASCII = buffer.length < 500000000 && isASCII(str);
|
|
157
|
+
while (blockStart < str.length) {
|
|
158
|
+
let line;
|
|
159
|
+
let n;
|
|
160
|
+
if (strIsASCII) {
|
|
161
|
+
n = str.indexOf('\n', blockStart);
|
|
162
|
+
if (n === -1) {
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
line = str.slice(blockStart, n);
|
|
139
166
|
}
|
|
140
|
-
|
|
141
|
-
|
|
167
|
+
else {
|
|
168
|
+
n = buffer.indexOf('\n', blockStart);
|
|
169
|
+
if (n === -1) {
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
const b = buffer.slice(blockStart, n);
|
|
173
|
+
line = (_b = decoder === null || decoder === void 0 ? void 0 : decoder.decode(b)) !== null && _b !== void 0 ? _b : b.toString();
|
|
174
|
+
}
|
|
175
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
142
176
|
if (dpositions) {
|
|
143
177
|
while (blockStart + c.minv.dataPosition >= dpositions[pos++]) { }
|
|
144
178
|
pos--;
|
|
145
179
|
}
|
|
146
180
|
// filter the line for whether it is within the requested range
|
|
147
181
|
const { startCoordinate, overlaps } = this.checkLine(metadata, refName, start, end, line);
|
|
148
|
-
// do a small check just to make sure that the lines are really sorted
|
|
149
|
-
// by start coordinate
|
|
150
|
-
if (previousStartCoordinate !== undefined &&
|
|
151
|
-
startCoordinate !== undefined &&
|
|
152
|
-
previousStartCoordinate > startCoordinate) {
|
|
153
|
-
throw new Error(`Lines not sorted by start coordinate (${previousStartCoordinate} > ${startCoordinate}), this file is not usable with Tabix.`);
|
|
154
|
-
}
|
|
155
|
-
previousStartCoordinate = startCoordinate;
|
|
156
182
|
if (overlaps) {
|
|
157
|
-
callback(line
|
|
158
|
-
// cpositions[pos] refers to actual file offset of a bgzip block
|
|
183
|
+
callback(line,
|
|
184
|
+
// cpositions[pos] refers to actual file offset of a bgzip block
|
|
185
|
+
// boundaries
|
|
159
186
|
//
|
|
160
|
-
// we multiply by (1 <<8) in order to make sure each block has a
|
|
161
|
-
// address space so that data in that block could never
|
|
187
|
+
// we multiply by (1 <<8) in order to make sure each block has a
|
|
188
|
+
// "unique" address space so that data in that block could never
|
|
189
|
+
// overlap
|
|
162
190
|
//
|
|
163
|
-
// then the blockStart-dpositions is an uncompressed file offset
|
|
164
|
-
// that bgzip block boundary, and since the cpositions are
|
|
165
|
-
// (1 << 8) these uncompressed offsets get a unique
|
|
191
|
+
// then the blockStart-dpositions is an uncompressed file offset
|
|
192
|
+
// from that bgzip block boundary, and since the cpositions are
|
|
193
|
+
// multiplied by (1 << 8) these uncompressed offsets get a unique
|
|
194
|
+
// space
|
|
166
195
|
cpositions[pos] * (1 << 8) +
|
|
167
196
|
(blockStart - dpositions[pos]) +
|
|
168
197
|
c.minv.dataPosition +
|
|
169
198
|
1);
|
|
170
199
|
}
|
|
171
200
|
else if (startCoordinate !== undefined && startCoordinate >= end) {
|
|
172
|
-
// the lines were overlapping the region, but now have stopped, so
|
|
173
|
-
//
|
|
174
|
-
//
|
|
201
|
+
// the lines were overlapping the region, but now have stopped, so we
|
|
202
|
+
// must be at the end of the relevant data and we can stop processing
|
|
203
|
+
// data now
|
|
175
204
|
return;
|
|
176
205
|
}
|
|
177
|
-
// yield if we have emitted beyond the yield limit
|
|
178
|
-
if (this.yieldTime && last - Date.now() > this.yieldTime) {
|
|
179
|
-
last = Date.now();
|
|
180
|
-
checkAbortSignal(signal);
|
|
181
|
-
await timeout(1);
|
|
182
|
-
}
|
|
183
206
|
blockStart = n + 1;
|
|
184
207
|
}
|
|
185
208
|
}
|
|
@@ -188,13 +211,13 @@ export default class TabixIndexedFile {
|
|
|
188
211
|
return this.index.getMetadata(opts);
|
|
189
212
|
}
|
|
190
213
|
/**
|
|
191
|
-
* get a buffer containing the "header" region of
|
|
192
|
-
*
|
|
193
|
-
* non-meta line
|
|
214
|
+
* get a buffer containing the "header" region of the file, which are the
|
|
215
|
+
* bytes up to the first non-meta line
|
|
194
216
|
*/
|
|
195
217
|
async getHeaderBuffer(opts = {}) {
|
|
196
218
|
const { firstDataLine, metaChar, maxBlockSize } = await this.getMetadata(opts);
|
|
197
219
|
checkAbortSignal(opts.signal);
|
|
220
|
+
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
|
198
221
|
const maxFetch = ((firstDataLine === null || firstDataLine === void 0 ? void 0 : firstDataLine.blockPosition) || 0) + maxBlockSize;
|
|
199
222
|
// TODO: what if we don't have a firstDataLine, and the header
|
|
200
223
|
// actually takes up more than one block? this case is not covered here
|
|
@@ -214,13 +237,13 @@ export default class TabixIndexedFile {
|
|
|
214
237
|
lastNewline = i;
|
|
215
238
|
}
|
|
216
239
|
}
|
|
217
|
-
return bytes.
|
|
240
|
+
return bytes.subarray(0, lastNewline + 1);
|
|
218
241
|
}
|
|
219
242
|
return bytes;
|
|
220
243
|
}
|
|
221
244
|
/**
|
|
222
|
-
* get a string containing the "header" region of the
|
|
223
|
-
*
|
|
245
|
+
* get a string containing the "header" region of the file, is the portion up
|
|
246
|
+
* to the first non-meta line
|
|
224
247
|
*
|
|
225
248
|
* @returns {Promise} for a string
|
|
226
249
|
*/
|
|
@@ -229,21 +252,25 @@ export default class TabixIndexedFile {
|
|
|
229
252
|
return bytes.toString('utf8');
|
|
230
253
|
}
|
|
231
254
|
/**
|
|
232
|
-
* get an array of reference sequence names, in the order in which
|
|
233
|
-
*
|
|
234
|
-
* to these names.
|
|
255
|
+
* get an array of reference sequence names, in the order in which they occur
|
|
256
|
+
* in the file. reference sequence renaming is not applied to these names.
|
|
235
257
|
*/
|
|
236
258
|
async getReferenceSequenceNames(opts = {}) {
|
|
237
259
|
const metadata = await this.getMetadata(opts);
|
|
238
260
|
return metadata.refIdToName;
|
|
239
261
|
}
|
|
240
262
|
/**
|
|
241
|
-
* @param {object} metadata metadata object from the parsed index,
|
|
242
|
-
*
|
|
263
|
+
* @param {object} metadata metadata object from the parsed index, containing
|
|
264
|
+
* columnNumbers, metaChar, and format
|
|
265
|
+
*
|
|
243
266
|
* @param {string} regionRefName
|
|
267
|
+
*
|
|
244
268
|
* @param {number} regionStart region start coordinate (0-based-half-open)
|
|
269
|
+
*
|
|
245
270
|
* @param {number} regionEnd region end coordinate (0-based-half-open)
|
|
271
|
+
*
|
|
246
272
|
* @param {array[string]} line
|
|
273
|
+
*
|
|
247
274
|
* @returns {object} like `{startCoordinate, overlaps}`. overlaps is boolean,
|
|
248
275
|
* true if line is a data line that overlaps the given region
|
|
249
276
|
*/
|
|
@@ -268,19 +295,22 @@ export default class TabixIndexedFile {
|
|
|
268
295
|
end = 8;
|
|
269
296
|
}
|
|
270
297
|
const maxColumn = Math.max(ref, start, end);
|
|
271
|
-
// this code is kind of complex, but it is fairly fast.
|
|
272
|
-
//
|
|
273
|
-
//
|
|
298
|
+
// this code is kind of complex, but it is fairly fast. basically, we want
|
|
299
|
+
// to avoid doing a split, because if the lines are really long that could
|
|
300
|
+
// lead to us allocating a bunch of extra memory, which is slow
|
|
274
301
|
let currentColumnNumber = 1; // cols are numbered starting at 1 in the index metadata
|
|
275
302
|
let currentColumnStart = 0;
|
|
276
303
|
let refSeq = '';
|
|
277
304
|
let startCoordinate = -Infinity;
|
|
278
|
-
|
|
279
|
-
|
|
305
|
+
const l = line.length;
|
|
306
|
+
for (let i = 0; i < l + 1; i++) {
|
|
307
|
+
if (line[i] === '\t' || i === l) {
|
|
280
308
|
if (currentColumnNumber === ref) {
|
|
281
309
|
if (this.renameRefSeq(line.slice(currentColumnStart, i)) !==
|
|
282
310
|
regionRefName) {
|
|
283
|
-
return {
|
|
311
|
+
return {
|
|
312
|
+
overlaps: false,
|
|
313
|
+
};
|
|
284
314
|
}
|
|
285
315
|
}
|
|
286
316
|
else if (currentColumnNumber === start) {
|
|
@@ -290,12 +320,18 @@ export default class TabixIndexedFile {
|
|
|
290
320
|
startCoordinate -= 1;
|
|
291
321
|
}
|
|
292
322
|
if (startCoordinate >= regionEnd) {
|
|
293
|
-
return {
|
|
323
|
+
return {
|
|
324
|
+
startCoordinate,
|
|
325
|
+
overlaps: false,
|
|
326
|
+
};
|
|
294
327
|
}
|
|
295
328
|
if (end === 0 || end === start) {
|
|
296
329
|
// if we have no end, we assume the feature is 1 bp long
|
|
297
330
|
if (startCoordinate + 1 <= regionStart) {
|
|
298
|
-
return {
|
|
331
|
+
return {
|
|
332
|
+
startCoordinate,
|
|
333
|
+
overlaps: false,
|
|
334
|
+
};
|
|
299
335
|
}
|
|
300
336
|
}
|
|
301
337
|
}
|
|
@@ -306,9 +342,11 @@ export default class TabixIndexedFile {
|
|
|
306
342
|
// this will never match if there is no end column
|
|
307
343
|
const endCoordinate = format === 'VCF'
|
|
308
344
|
? this._getVcfEnd(startCoordinate, refSeq, line.slice(currentColumnStart, i))
|
|
309
|
-
: parseInt(line.slice(currentColumnStart, i), 10);
|
|
345
|
+
: Number.parseInt(line.slice(currentColumnStart, i), 10);
|
|
310
346
|
if (endCoordinate <= regionStart) {
|
|
311
|
-
return {
|
|
347
|
+
return {
|
|
348
|
+
overlaps: false,
|
|
349
|
+
};
|
|
312
350
|
}
|
|
313
351
|
}
|
|
314
352
|
currentColumnStart = i + 1;
|
|
@@ -318,7 +356,10 @@ export default class TabixIndexedFile {
|
|
|
318
356
|
}
|
|
319
357
|
}
|
|
320
358
|
}
|
|
321
|
-
return {
|
|
359
|
+
return {
|
|
360
|
+
startCoordinate,
|
|
361
|
+
overlaps: true,
|
|
362
|
+
};
|
|
322
363
|
}
|
|
323
364
|
_getVcfEnd(startCoordinate, refSeq, info) {
|
|
324
365
|
let endCoordinate = startCoordinate + refSeq.length;
|
|
@@ -348,8 +389,11 @@ export default class TabixIndexedFile {
|
|
|
348
389
|
return endCoordinate;
|
|
349
390
|
}
|
|
350
391
|
/**
|
|
351
|
-
* return the approximate number of data lines in the given reference
|
|
392
|
+
* return the approximate number of data lines in the given reference
|
|
393
|
+
* sequence
|
|
394
|
+
*
|
|
352
395
|
* @param refSeq reference sequence name
|
|
396
|
+
*
|
|
353
397
|
* @returns number of data lines present on that reference sequence
|
|
354
398
|
*/
|
|
355
399
|
async lineCount(refName, opts = {}) {
|
|
@@ -358,15 +402,15 @@ export default class TabixIndexedFile {
|
|
|
358
402
|
async _readRegion(pos, size, opts = {}) {
|
|
359
403
|
const b = Buffer.alloc(size);
|
|
360
404
|
const { bytesRead, buffer } = await this.filehandle.read(b, 0, size, pos, opts);
|
|
361
|
-
return buffer.
|
|
405
|
+
return buffer.subarray(0, bytesRead);
|
|
362
406
|
}
|
|
363
407
|
/**
|
|
364
408
|
* read and uncompress the data in a chunk (composed of one or more
|
|
365
409
|
* contiguous bgzip blocks) of the file
|
|
366
410
|
*/
|
|
367
411
|
async readChunk(c, opts = {}) {
|
|
368
|
-
// fetch the uncompressed data, uncompress carefully a block at a time,
|
|
369
|
-
//
|
|
412
|
+
// fetch the uncompressed data, uncompress carefully a block at a time, and
|
|
413
|
+
// stop when done
|
|
370
414
|
const data = await this._readRegion(c.minv.blockPosition, c.fetchedSize(), opts);
|
|
371
415
|
return unzipChunkSlice(data, c);
|
|
372
416
|
}
|