@gmod/tabix 3.6.0 → 3.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/dist/indexFile.d.ts +19 -23
- package/dist/indexFile.js +23 -60
- package/dist/indexFile.js.map +1 -1
- package/dist/tabix-bundle.js +1 -1
- package/dist/tabixIndexedFile.d.ts +13 -11
- package/dist/tabixIndexedFile.js +15 -47
- package/dist/tabixIndexedFile.js.map +1 -1
- package/esm/indexFile.d.ts +19 -23
- package/esm/indexFile.js +24 -61
- package/esm/indexFile.js.map +1 -1
- package/esm/tabixIndexedFile.d.ts +13 -11
- package/esm/tabixIndexedFile.js +16 -48
- package/esm/tabixIndexedFile.js.map +1 -1
- package/package.json +2 -2
- package/src/indexFile.ts +25 -64
- package/src/tabixIndexedFile.ts +20 -54
package/dist/indexFile.d.ts
CHANGED
|
@@ -49,14 +49,11 @@ export interface IndexData {
|
|
|
49
49
|
}
|
|
50
50
|
export default abstract class IndexFile {
|
|
51
51
|
filehandle: GenericFilehandle;
|
|
52
|
-
private parseP?;
|
|
53
52
|
/**
|
|
54
|
-
* The
|
|
55
|
-
*
|
|
56
|
-
* this the first query to arrive would own a read all the others depend on —
|
|
57
|
-
* see {@link parse}.
|
|
53
|
+
* The parsed index, as a shared read — see {@link parse}. One entry, never
|
|
54
|
+
* evicted, which is what a memo is.
|
|
58
55
|
*/
|
|
59
|
-
private
|
|
56
|
+
private parseCache;
|
|
60
57
|
constructor({ filehandle }: {
|
|
61
58
|
filehandle: GenericFilehandle;
|
|
62
59
|
});
|
|
@@ -124,28 +121,27 @@ export default abstract class IndexFile {
|
|
|
124
121
|
* The index is downloaded and parsed once for the life of this object, so it
|
|
125
122
|
* is the one read here that is shared between queries — and therefore the one
|
|
126
123
|
* place a cancellation can leak from the query that asked for it to a query
|
|
127
|
-
* that did not. `_parse` hands `opts` straight to `readIndexBytes`, so
|
|
128
|
-
*
|
|
129
|
-
* depends on: when it pans away, every concurrent query fails
|
|
124
|
+
* that did not. `_parse` hands `opts` straight to `readIndexBytes`, so a bare
|
|
125
|
+
* memoized promise makes the first query to arrive the owner of a read every
|
|
126
|
+
* other query depends on: when it pans away, every concurrent query fails
|
|
127
|
+
* with its abort.
|
|
130
128
|
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
129
|
+
* The same cache `ChunkCache` uses, for the same reason and with the same
|
|
130
|
+
* rule: the parse runs under a signal of its own and is cancelled only once
|
|
131
|
+
* every caller waiting on it has given up, so one query's abort is reported
|
|
132
|
+
* to that query alone and a bystander gets the parse already in flight rather
|
|
133
|
+
* than having to re-read the index. A rejection is dropped rather than
|
|
134
|
+
* cached, so a transient failure does not poison the index for the life of
|
|
135
|
+
* the file.
|
|
138
136
|
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
* split for the same reason.
|
|
137
|
+
* The fill is per call rather than on the cache so that the caller who starts
|
|
138
|
+
* the parse has its `onProgress` reach `readIndexBytes` — the index is a
|
|
139
|
+
* whole-file read, and a determinate "downloading index" bar is what that
|
|
140
|
+
* callback exists for.
|
|
144
141
|
*
|
|
145
142
|
* @internal
|
|
146
143
|
*/
|
|
147
|
-
parse(opts?: Options
|
|
148
|
-
private startParse;
|
|
144
|
+
parse(opts?: Options): Promise<IndexData>;
|
|
149
145
|
/** @internal */
|
|
150
146
|
hasRefSeq(seqId: number, opts?: Options): Promise<boolean>;
|
|
151
147
|
}
|
package/dist/indexFile.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const bgzf_filehandle_1 = require("@gmod/bgzf-filehandle");
|
|
4
|
+
const shared_read_cache_1 = require("@gmod/shared-read-cache");
|
|
4
5
|
const util_ts_1 = require("./util.js");
|
|
5
6
|
class IndexFile {
|
|
6
7
|
filehandle;
|
|
7
|
-
parseP;
|
|
8
8
|
/**
|
|
9
|
-
* The
|
|
10
|
-
*
|
|
11
|
-
* this the first query to arrive would own a read all the others depend on —
|
|
12
|
-
* see {@link parse}.
|
|
9
|
+
* The parsed index, as a shared read — see {@link parse}. One entry, never
|
|
10
|
+
* evicted, which is what a memo is.
|
|
13
11
|
*/
|
|
14
|
-
|
|
12
|
+
parseCache = new shared_read_cache_1.SharedReadCache({});
|
|
15
13
|
constructor({ filehandle }) {
|
|
16
14
|
this.filehandle = filehandle;
|
|
17
15
|
}
|
|
@@ -75,71 +73,36 @@ class IndexFile {
|
|
|
75
73
|
}
|
|
76
74
|
return (0, util_ts_1.optimizeChunks)(chunks, this.lowestOffset(ba, min, indexData));
|
|
77
75
|
}
|
|
78
|
-
// SYNC: ~/src/gmod/bam-js/src/indexFile.ts parse — same
|
|
79
|
-
//
|
|
76
|
+
// SYNC: ~/src/gmod/bam-js/src/indexFile.ts parse — same shape and the same
|
|
77
|
+
// reasoning below.
|
|
80
78
|
/**
|
|
81
79
|
* Parse the index, or join the parse already running.
|
|
82
80
|
*
|
|
83
81
|
* The index is downloaded and parsed once for the life of this object, so it
|
|
84
82
|
* is the one read here that is shared between queries — and therefore the one
|
|
85
83
|
* place a cancellation can leak from the query that asked for it to a query
|
|
86
|
-
* that did not. `_parse` hands `opts` straight to `readIndexBytes`, so
|
|
87
|
-
*
|
|
88
|
-
* depends on: when it pans away, every concurrent query fails
|
|
84
|
+
* that did not. `_parse` hands `opts` straight to `readIndexBytes`, so a bare
|
|
85
|
+
* memoized promise makes the first query to arrive the owner of a read every
|
|
86
|
+
* other query depends on: when it pans away, every concurrent query fails
|
|
87
|
+
* with its abort.
|
|
89
88
|
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
89
|
+
* The same cache `ChunkCache` uses, for the same reason and with the same
|
|
90
|
+
* rule: the parse runs under a signal of its own and is cancelled only once
|
|
91
|
+
* every caller waiting on it has given up, so one query's abort is reported
|
|
92
|
+
* to that query alone and a bystander gets the parse already in flight rather
|
|
93
|
+
* than having to re-read the index. A rejection is dropped rather than
|
|
94
|
+
* cached, so a transient failure does not poison the index for the life of
|
|
95
|
+
* the file.
|
|
97
96
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* split for the same reason.
|
|
97
|
+
* The fill is per call rather than on the cache so that the caller who starts
|
|
98
|
+
* the parse has its `onProgress` reach `readIndexBytes` — the index is a
|
|
99
|
+
* whole-file read, and a determinate "downloading index" bar is what that
|
|
100
|
+
* callback exists for.
|
|
103
101
|
*
|
|
104
102
|
* @internal
|
|
105
103
|
*/
|
|
106
|
-
|
|
107
|
-
(
|
|
108
|
-
const pending = this.parseP;
|
|
109
|
-
if (!pending) {
|
|
110
|
-
return this.startParse(opts);
|
|
111
|
-
}
|
|
112
|
-
// read before awaiting: the owner is forgotten as soon as the parse settles
|
|
113
|
-
const ownerSignal = this.parseSignal;
|
|
114
|
-
try {
|
|
115
|
-
return await pending;
|
|
116
|
-
}
|
|
117
|
-
catch (e) {
|
|
118
|
-
if (retried || !ownerSignal?.aborted || opts.signal?.aborted) {
|
|
119
|
-
throw e;
|
|
120
|
-
}
|
|
121
|
-
return this.parse(opts, true);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
startParse(opts) {
|
|
125
|
-
const pending = this._parse(opts);
|
|
126
|
-
this.parseP = pending;
|
|
127
|
-
this.parseSignal = opts.signal;
|
|
128
|
-
// Drop a rejection rather than keeping it, so one transient failure does not
|
|
129
|
-
// poison the index for the lifetime of the file. Both branches are
|
|
130
|
-
// identity-checked so a retry started after this settles is not cleared by
|
|
131
|
-
// the attempt it already replaced.
|
|
132
|
-
pending.then(() => {
|
|
133
|
-
if (this.parseP === pending) {
|
|
134
|
-
this.parseSignal = undefined;
|
|
135
|
-
}
|
|
136
|
-
}, () => {
|
|
137
|
-
if (this.parseP === pending) {
|
|
138
|
-
this.parseP = undefined;
|
|
139
|
-
this.parseSignal = undefined;
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
return pending;
|
|
104
|
+
parse(opts = {}) {
|
|
105
|
+
return this.parseCache.get('index', opts.signal, signal => this._parse({ ...opts, signal }));
|
|
143
106
|
}
|
|
144
107
|
/** @internal */
|
|
145
108
|
async hasRefSeq(seqId, opts = {}) {
|
package/dist/indexFile.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexFile.js","sourceRoot":"","sources":["../src/indexFile.ts"],"names":[],"mappings":";;AAAA,2DAA6C;
|
|
1
|
+
{"version":3,"file":"indexFile.js","sourceRoot":"","sources":["../src/indexFile.ts"],"names":[],"mappings":";;AAAA,2DAA6C;AAC7C,+DAAyD;AAEzD,uCAA0C;AAiD1C,MAA8B,SAAS;IAC9B,UAAU,CAAmB;IACpC;;;OAGG;IACK,UAAU,GAAG,IAAI,mCAAe,CAAoB,EAAE,CAAC,CAAA;IAE/D,YAAY,EAAE,UAAU,EAAqC;QAC3D,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;IAyBD;;;OAGG;IACO,KAAK,CAAC,cAAc,CAAC,IAAa;QAC1C,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;YACzC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,CAAC,CAAA;QACF,MAAM,KAAK,GAAG,MAAM,IAAA,uBAAK,EAAC,GAAG,CAAC,CAAA;QAC9B,OAAO;YACL,KAAK;YACL,QAAQ,EAAE,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC;SACzE,CAAA;IACH,CAAC;IAED,gBAAgB;IACT,KAA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