@genome-spy/app 0.74.0 → 0.76.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/dist/AbortablePromiseCache-beUIcZcW.js +96 -0
- package/dist/agentApi-CzdacisO.js +25226 -0
- package/dist/agentApi.es.js +9460 -0
- package/dist/agentShared.es.js +4742 -0
- package/dist/{blosc-oa0DlI6G.js → blosc-BX4BJ8sR.js} +1 -1
- package/dist/componentStyles-CIXoKEp0.js +2182 -0
- package/dist/dialog.es.js +377 -0
- package/dist/{esm-n0auOe11.js → esm-BH0wx5y-.js} +1 -1
- package/dist/esm-BLfLaJtE.js +121 -0
- package/dist/{esm-D-WfYOx7.js → esm-BWsx1OJ2.js} +25 -25
- package/dist/{browser-Dvlo92rx.js → esm-BY4T8YoD.js} +38 -22
- package/dist/esm-CZvS2Ldm.js +155 -0
- package/dist/esm-CdIesJ1z.js +461 -0
- package/dist/{esm-DCCYNvaz.js → esm-Cr7pLUfG.js} +50 -50
- package/dist/esm-D-y0Ce1M.js +573 -0
- package/dist/esm-DHOMWRoL.js +1426 -0
- package/dist/{esm-Cmo4qEPr.js → esm-DJUb6vy0.js} +5 -5
- package/dist/esm-DPS6pYKF.js +1248 -0
- package/dist/esm-DRZ5LLNH.js +142 -0
- package/dist/esm-DjF6pKy5.js +369 -0
- package/dist/esm-PDPkTR1_.js +1015 -0
- package/dist/esm-s_SlArJ8.js +298 -0
- package/dist/index.es.js +7910 -28759
- package/dist/index.js +1135 -736
- package/dist/lit-ymUSmGBw.js +510 -0
- package/dist/{lz4-jZ0zyLBa.js → lz4-BSYl80V8.js} +1 -1
- package/dist/parquetRead-m8-8_SpH.js +1609 -0
- package/dist/schema.json +665 -97
- package/dist/style.css +1 -1
- package/dist/viewUtils-C5htqZCm.js +14147 -0
- package/dist/{zstd-C6ksIG9r.js → zstd-BAfRM3IH.js} +1 -1
- package/package.json +30 -5
- package/src/agentApi/index.d.ts +123 -0
- package/src/agentShared/index.d.ts +97 -0
- package/src/agentShared/types.d.ts +8 -0
- package/src/appTypes.d.ts +75 -0
- package/src/bookmark/databaseSchema.d.ts +33 -0
- package/src/charts/boxplotTypes.d.ts +15 -0
- package/src/charts/sampleAttributePlotTypes.d.ts +149 -0
- package/src/coreSpecAugmentation.d.ts +29 -0
- package/src/dialog/index.d.ts +5 -0
- package/src/embedTypes.d.ts +9 -0
- package/src/index.d.ts +16 -0
- package/src/sampleView/sampleViewTypes.d.ts +174 -0
- package/src/sampleView/state/payloadTypes.d.ts +400 -0
- package/src/sampleView/state/sampleState.d.ts +76 -0
- package/src/sampleView/types.d.ts +125 -0
- package/src/spec/appSpec.d.ts +54 -0
- package/src/spec/sampleView.d.ts +487 -0
- package/src/spec/view.d.ts +124 -0
- package/src/state/paramProvenanceTypes.d.ts +215 -0
- package/src/state/selectionExpansionTypes.d.ts +77 -0
- package/src/state.d.ts +97 -0
- package/src/types/lz-string.d.ts +24 -0
- package/src/types/vega-loader.d.ts +1 -0
- package/src/utils/colorScaleSummary.d.ts +15 -0
- package/src/utils/statistics/fieldSummary.d.ts +49 -0
- package/src/vite-env.d.ts +6 -0
- package/LICENSE +0 -21
- /package/dist/{AbortablePromiseCache-3gHJdF3E.js → AbortablePromiseCache-BDH1cqFl.js} +0 -0
- /package/dist/{chunk-INHXZS53-fPMmEwMt.js → chunk-INHXZS53-DwEV9sMh.js} +0 -0
- /package/dist/{esm-BygJiwh0.js → esm-BL9SNSnj.js} +0 -0
- /package/dist/{esm-B8-vSu-c.js → esm-BwW--bVV.js} +0 -0
- /package/dist/{esm-CGX-qz1d.js → esm-Bz_92nH0.js} +0 -0
- /package/dist/{esm-CuMSzCHy.js → esm-D2_c7lXY.js} +0 -0
- /package/dist/{parquetRead-CJe1UPsz.js → parquetRead-BuEN-6yG.js} +0 -0
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
import { n as e, r as t } from "./esm-DPS6pYKF.js";
|
|
2
|
+
import { t as n } from "./esm-Bz_92nH0.js";
|
|
3
|
+
import { n as r, r as i } from "./esm-BY4T8YoD.js";
|
|
4
|
+
import { t as a } from "./AbortablePromiseCache-BDH1cqFl.js";
|
|
5
|
+
//#region ../../node_modules/@gmod/tabix/esm/chunk.js
|
|
6
|
+
var o = class {
|
|
7
|
+
constructor(e, t, n, r) {
|
|
8
|
+
this.minv = e, this.maxv = t, this.bin = n, this._fetchedSize = r;
|
|
9
|
+
}
|
|
10
|
+
toUniqueString() {
|
|
11
|
+
return `${this.minv}..${this.maxv} (bin ${this.bin}, fetchedSize ${this.fetchedSize()})`;
|
|
12
|
+
}
|
|
13
|
+
toString() {
|
|
14
|
+
return this.toUniqueString();
|
|
15
|
+
}
|
|
16
|
+
compareTo(e) {
|
|
17
|
+
return this.minv.compareTo(e.minv) || this.maxv.compareTo(e.maxv) || this.bin - e.bin;
|
|
18
|
+
}
|
|
19
|
+
fetchedSize() {
|
|
20
|
+
return this._fetchedSize === void 0 ? this.maxv.blockPosition + 65536 - this.minv.blockPosition : this._fetchedSize;
|
|
21
|
+
}
|
|
22
|
+
}, s = class {
|
|
23
|
+
constructor({ filehandle: e, renameRefSeqs: t = (e) => e }) {
|
|
24
|
+
this.filehandle = e, this.renameRefSeq = t;
|
|
25
|
+
}
|
|
26
|
+
async getMetadata(e = {}) {
|
|
27
|
+
let { indices: t, ...n } = await this.parse(e);
|
|
28
|
+
return n;
|
|
29
|
+
}
|
|
30
|
+
_findFirstData(e, t) {
|
|
31
|
+
return e ? e.compareTo(t) > 0 ? t : e : t;
|
|
32
|
+
}
|
|
33
|
+
async parse(e = {}) {
|
|
34
|
+
return this.parseP ||= this._parse(e).catch((e) => {
|
|
35
|
+
throw this.parseP = void 0, e;
|
|
36
|
+
}), this.parseP;
|
|
37
|
+
}
|
|
38
|
+
async hasRefSeq(e, t = {}) {
|
|
39
|
+
return !!(await this.parse(t)).indices[e]?.binIndex;
|
|
40
|
+
}
|
|
41
|
+
_parseNameBytes(e) {
|
|
42
|
+
let t = 0, n = 0, r = [], i = {}, a = new TextDecoder("utf8");
|
|
43
|
+
for (let o = 0; o < e.length; o += 1) if (!e[o]) {
|
|
44
|
+
if (n < o) {
|
|
45
|
+
let s = this.renameRefSeq(a.decode(e.subarray(n, o)));
|
|
46
|
+
r[t] = s, i[s] = t;
|
|
47
|
+
}
|
|
48
|
+
n = o + 1, t += 1;
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
refNameToId: i,
|
|
52
|
+
refIdToName: r
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}, c = 65536, l = c * c;
|
|
56
|
+
function u(e, t = 0) {
|
|
57
|
+
let n = e[t] | e[t + 1] << 8 | e[t + 2] << 16 | e[t + 3] << 24;
|
|
58
|
+
return ((e[t + 4] | e[t + 5] << 8 | e[t + 6] << 16 | e[t + 7] << 24) >>> 0) * l + (n >>> 0);
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region ../../node_modules/@gmod/tabix/esm/util.js
|
|
62
|
+
function d(e, t) {
|
|
63
|
+
return t.minv.blockPosition - e.maxv.blockPosition < 65e3 && t.maxv.blockPosition - e.minv.blockPosition < 5e6;
|
|
64
|
+
}
|
|
65
|
+
function f(e, t) {
|
|
66
|
+
let n = [], r;
|
|
67
|
+
if (e.length === 0) return e;
|
|
68
|
+
e.sort(function(e, t) {
|
|
69
|
+
let n = e.minv.blockPosition - t.minv.blockPosition;
|
|
70
|
+
return n === 0 ? e.minv.dataPosition - t.minv.dataPosition : n;
|
|
71
|
+
});
|
|
72
|
+
for (let i of e) (!t || i.maxv.compareTo(t) > 0) && (r === void 0 ? (n.push(i), r = i) : d(r, i) ? i.maxv.compareTo(r.maxv) > 0 && (r.maxv = i.maxv) : (n.push(i), r = i));
|
|
73
|
+
return n;
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region ../../node_modules/@gmod/tabix/esm/virtualOffset.js
|
|
77
|
+
var p = class {
|
|
78
|
+
constructor(e, t) {
|
|
79
|
+
this.blockPosition = e, this.dataPosition = t;
|
|
80
|
+
}
|
|
81
|
+
toString() {
|
|
82
|
+
return `${this.blockPosition}:${this.dataPosition}`;
|
|
83
|
+
}
|
|
84
|
+
compareTo(e) {
|
|
85
|
+
return this.blockPosition - e.blockPosition || this.dataPosition - e.dataPosition;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
function m(e, t = 0) {
|
|
89
|
+
return new p(e[t + 7] * 1099511627776 + e[t + 6] * 4294967296 + e[t + 5] * 16777216 + e[t + 4] * 65536 + e[t + 3] * 256 + e[t + 2], e[t + 1] << 8 | e[t]);
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region ../../node_modules/@gmod/tabix/esm/csi.js
|
|
93
|
+
var h = 21582659, g = 38359875, _ = {
|
|
94
|
+
0: "generic",
|
|
95
|
+
1: "SAM",
|
|
96
|
+
2: "VCF"
|
|
97
|
+
};
|
|
98
|
+
function v(e, t) {
|
|
99
|
+
return e * 2 ** t;
|
|
100
|
+
}
|
|
101
|
+
function y(e, t) {
|
|
102
|
+
return Math.floor(e / 2 ** t);
|
|
103
|
+
}
|
|
104
|
+
var b = class extends s {
|
|
105
|
+
constructor(e) {
|
|
106
|
+
super(e), this.maxBinNumber = 0, this.depth = 0, this.minShift = 0;
|
|
107
|
+
}
|
|
108
|
+
async lineCount(e, t = {}) {
|
|
109
|
+
let n = await this.parse(t), r = n.refNameToId[e];
|
|
110
|
+
if (r === void 0 || !n.indices[r]) return -1;
|
|
111
|
+
let { stats: i } = n.indices[r];
|
|
112
|
+
return i ? i.lineCount : -1;
|
|
113
|
+
}
|
|
114
|
+
indexCov() {
|
|
115
|
+
throw Error("CSI indexes do not support indexcov");
|
|
116
|
+
}
|
|
117
|
+
parseAuxData(e, t) {
|
|
118
|
+
let n = new DataView(e.buffer), r = n.getInt32(t, !0), i = r & 65536 ? "zero-based-half-open" : "1-based-closed", a = _[r & 15];
|
|
119
|
+
if (!a) throw Error(`invalid Tabix preset format flags ${r}`);
|
|
120
|
+
let o = {
|
|
121
|
+
ref: n.getInt32(t + 4, !0),
|
|
122
|
+
start: n.getInt32(t + 8, !0),
|
|
123
|
+
end: n.getInt32(t + 12, !0)
|
|
124
|
+
}, s = n.getInt32(t + 16, !0), c = s ? String.fromCharCode(s) : void 0, l = n.getInt32(t + 20, !0), u = n.getInt32(t + 24, !0), { refIdToName: d, refNameToId: f } = this._parseNameBytes(e.subarray(t + 28, t + 28 + u));
|
|
125
|
+
return {
|
|
126
|
+
refIdToName: d,
|
|
127
|
+
refNameToId: f,
|
|
128
|
+
skipLines: l,
|
|
129
|
+
metaChar: c,
|
|
130
|
+
columnNumbers: o,
|
|
131
|
+
format: a,
|
|
132
|
+
coordinateType: i
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
async _parse(t = {}) {
|
|
136
|
+
let n = await e(await this.filehandle.readFile(t)), r = new DataView(n.buffer), i;
|
|
137
|
+
if (r.getUint32(0, !0) === h) i = 1;
|
|
138
|
+
else if (r.getUint32(0, !0) === g) i = 2;
|
|
139
|
+
else throw Error("Not a CSI file");
|
|
140
|
+
this.minShift = r.getInt32(4, !0), this.depth = r.getInt32(8, !0), this.maxBinNumber = ((1 << (this.depth + 1) * 3) - 1) / 7;
|
|
141
|
+
let a = 2 ** (this.minShift + this.depth * 3), s = r.getInt32(12, !0), c = s && s >= 30 ? this.parseAuxData(n, 16) : {
|
|
142
|
+
refIdToName: [],
|
|
143
|
+
refNameToId: {},
|
|
144
|
+
metaChar: void 0,
|
|
145
|
+
columnNumbers: {
|
|
146
|
+
ref: 0,
|
|
147
|
+
start: 1,
|
|
148
|
+
end: 2
|
|
149
|
+
},
|
|
150
|
+
coordinateType: "zero-based-half-open",
|
|
151
|
+
format: "generic"
|
|
152
|
+
}, l = r.getInt32(16 + s, !0), u, d = 16 + s + 4, f = Array(l).fill(0).map(() => {
|
|
153
|
+
let e = r.getInt32(d, !0);
|
|
154
|
+
d += 4;
|
|
155
|
+
let t = {}, i;
|
|
156
|
+
for (let a = 0; a < e; a += 1) {
|
|
157
|
+
let e = r.getUint32(d, !0);
|
|
158
|
+
if (e > this.maxBinNumber) i = this.parsePseudoBin(n, d + 4), d += 48;
|
|
159
|
+
else {
|
|
160
|
+
let i = m(n, d + 4);
|
|
161
|
+
u = this._findFirstData(u, i);
|
|
162
|
+
let a = r.getInt32(d + 12, !0);
|
|
163
|
+
d += 16;
|
|
164
|
+
let s = Array(a);
|
|
165
|
+
for (let t = 0; t < a; t += 1) {
|
|
166
|
+
let r = m(n, d), i = m(n, d + 8);
|
|
167
|
+
d += 16, s[t] = new o(r, i, e);
|
|
168
|
+
}
|
|
169
|
+
t[e] = s;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
binIndex: t,
|
|
174
|
+
stats: i
|
|
175
|
+
};
|
|
176
|
+
});
|
|
177
|
+
return {
|
|
178
|
+
...c,
|
|
179
|
+
csi: !0,
|
|
180
|
+
refCount: l,
|
|
181
|
+
maxBlockSize: 65536,
|
|
182
|
+
firstDataLine: u,
|
|
183
|
+
csiVersion: i,
|
|
184
|
+
indices: f,
|
|
185
|
+
depth: this.depth,
|
|
186
|
+
maxBinNumber: this.maxBinNumber,
|
|
187
|
+
maxRefLength: a
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
parsePseudoBin(e, t) {
|
|
191
|
+
return { lineCount: u(e, t + 28) };
|
|
192
|
+
}
|
|
193
|
+
async blocksForRange(e, t, n, r = {}) {
|
|
194
|
+
t < 0 && (t = 0);
|
|
195
|
+
let i = await this.parse(r), a = i.refNameToId[e];
|
|
196
|
+
if (a === void 0) return [];
|
|
197
|
+
let s = i.indices[a];
|
|
198
|
+
if (!s) return [];
|
|
199
|
+
let c = this.reg2bins(t, n), l = [];
|
|
200
|
+
for (let [e, t] of c) for (let n = e; n <= t; n++) if (s.binIndex[n]) for (let e of s.binIndex[n]) l.push(new o(e.minv, e.maxv, n));
|
|
201
|
+
return f(l, new p(0, 0));
|
|
202
|
+
}
|
|
203
|
+
reg2bins(e, t) {
|
|
204
|
+
--e, e < 1 && (e = 1), t > 2 ** 50 && (t = 2 ** 34), --t;
|
|
205
|
+
let n = 0, r = 0, i = this.minShift + this.depth * 3, a = [];
|
|
206
|
+
for (; n <= this.depth; i -= 3, r += v(1, n * 3), n += 1) {
|
|
207
|
+
let n = r + y(e, i), o = r + y(t, i);
|
|
208
|
+
if (o - n + a.length > this.maxBinNumber) throw Error(`query ${e}-${t} is too large for current binning scheme (shift ${this.minShift}, depth ${this.depth}), try a smaller query or a coarser index binning scheme`);
|
|
209
|
+
a.push([n, o]);
|
|
210
|
+
}
|
|
211
|
+
return a;
|
|
212
|
+
}
|
|
213
|
+
}, x = 21578324, S = 14;
|
|
214
|
+
function C(e, t) {
|
|
215
|
+
return e += 1, --t, [
|
|
216
|
+
[0, 0],
|
|
217
|
+
[1 + (e >> 26), 1 + (t >> 26)],
|
|
218
|
+
[9 + (e >> 23), 9 + (t >> 23)],
|
|
219
|
+
[73 + (e >> 20), 73 + (t >> 20)],
|
|
220
|
+
[585 + (e >> 17), 585 + (t >> 17)],
|
|
221
|
+
[4681 + (e >> 14), 4681 + (t >> 14)]
|
|
222
|
+
];
|
|
223
|
+
}
|
|
224
|
+
var w = class extends s {
|
|
225
|
+
async lineCount(e, t = {}) {
|
|
226
|
+
let n = await this.parse(t), r = n.refNameToId[e];
|
|
227
|
+
return r === void 0 || !n.indices[r] ? -1 : n.indices[r].stats?.lineCount ?? -1;
|
|
228
|
+
}
|
|
229
|
+
async _parse(t = {}) {
|
|
230
|
+
let n = await e(await this.filehandle.readFile(t)), r = new DataView(n.buffer);
|
|
231
|
+
if (r.getUint32(0, !0) !== x) throw Error("Not a TBI file");
|
|
232
|
+
let i = r.getUint32(4, !0), a = r.getUint32(8, !0), s = a & 65536 ? "zero-based-half-open" : "1-based-closed", c = {
|
|
233
|
+
0: "generic",
|
|
234
|
+
1: "SAM",
|
|
235
|
+
2: "VCF"
|
|
236
|
+
}[a & 15];
|
|
237
|
+
if (!c) throw Error(`invalid Tabix preset format flags ${a}`);
|
|
238
|
+
let l = {
|
|
239
|
+
ref: r.getInt32(12, !0),
|
|
240
|
+
start: r.getInt32(16, !0),
|
|
241
|
+
end: r.getInt32(20, !0)
|
|
242
|
+
}, u = r.getInt32(24, !0), d = ((1 << 18) - 1) / 7, f = 2 ** 29, p = u ? String.fromCharCode(u) : void 0, h = r.getInt32(28, !0), g = r.getInt32(32, !0), { refNameToId: _, refIdToName: v } = this._parseNameBytes(n.slice(36, 36 + g)), y = 36 + g, b;
|
|
243
|
+
return {
|
|
244
|
+
indices: Array(i).fill(0).map(() => {
|
|
245
|
+
let e = r.getInt32(y, !0);
|
|
246
|
+
y += 4;
|
|
247
|
+
let t = {}, i;
|
|
248
|
+
for (let a = 0; a < e; a += 1) {
|
|
249
|
+
let e = r.getUint32(y, !0);
|
|
250
|
+
if (y += 4, e > d + 1) throw Error("tabix index contains too many bins, please use a CSI index");
|
|
251
|
+
if (e === d + 1) {
|
|
252
|
+
let e = r.getInt32(y, !0);
|
|
253
|
+
y += 4, e === 2 && (i = this.parsePseudoBin(n, y)), y += 16 * e;
|
|
254
|
+
} else {
|
|
255
|
+
let i = r.getInt32(y, !0);
|
|
256
|
+
y += 4;
|
|
257
|
+
let a = Array(i);
|
|
258
|
+
for (let t = 0; t < i; t += 1) {
|
|
259
|
+
let r = m(n, y), i = m(n, y + 8);
|
|
260
|
+
y += 16, b = this._findFirstData(b, r), a[t] = new o(r, i, e);
|
|
261
|
+
}
|
|
262
|
+
t[e] = a;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
let a = r.getInt32(y, !0);
|
|
266
|
+
y += 4;
|
|
267
|
+
let s = Array(a);
|
|
268
|
+
for (let e = 0; e < a; e += 1) s[e] = m(n, y), y += 8, b = this._findFirstData(b, s[e]);
|
|
269
|
+
return {
|
|
270
|
+
binIndex: t,
|
|
271
|
+
linearIndex: s,
|
|
272
|
+
stats: i
|
|
273
|
+
};
|
|
274
|
+
}),
|
|
275
|
+
metaChar: p,
|
|
276
|
+
maxBinNumber: d,
|
|
277
|
+
maxRefLength: f,
|
|
278
|
+
skipLines: h,
|
|
279
|
+
firstDataLine: b,
|
|
280
|
+
columnNumbers: l,
|
|
281
|
+
coordinateType: s,
|
|
282
|
+
format: c,
|
|
283
|
+
refIdToName: v,
|
|
284
|
+
refNameToId: _,
|
|
285
|
+
maxBlockSize: 65536
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
parsePseudoBin(e, t) {
|
|
289
|
+
return { lineCount: u(e, t + 16) };
|
|
290
|
+
}
|
|
291
|
+
async blocksForRange(e, t, n, r = {}) {
|
|
292
|
+
t < 0 && (t = 0);
|
|
293
|
+
let i = await this.parse(r), a = i.refNameToId[e];
|
|
294
|
+
if (a === void 0) return [];
|
|
295
|
+
let s = i.indices[a];
|
|
296
|
+
if (!s) return [];
|
|
297
|
+
(s.linearIndex.length > 0 ? s.linearIndex[t >> S >= s.linearIndex.length ? s.linearIndex.length - 1 : t >> S] : new p(0, 0)) || console.warn("querying outside of possible tabix range");
|
|
298
|
+
let c = C(t, n), l = [];
|
|
299
|
+
for (let [e, t] of c) for (let n = e; n <= t; n++) if (s.binIndex[n]) for (let e of s.binIndex[n]) l.push(new o(e.minv, e.maxv, n));
|
|
300
|
+
let u = s.linearIndex.length, d, m = Math.min(t >> 14, u - 1), h = Math.min(n >> 14, u - 1);
|
|
301
|
+
for (let e = m; e <= h; ++e) {
|
|
302
|
+
let t = s.linearIndex[e];
|
|
303
|
+
t && (!d || t.compareTo(d) < 0) && (d = t);
|
|
304
|
+
}
|
|
305
|
+
return f(l, d);
|
|
306
|
+
}
|
|
307
|
+
}, T = class {
|
|
308
|
+
constructor({ path: e, filehandle: t, url: o, tbiPath: s, tbiUrl: c, tbiFilehandle: l, csiPath: u, csiUrl: d, csiFilehandle: f, renameRefSeqs: p, chunkCacheSize: m = 5 * 2 ** 20 }) {
|
|
309
|
+
this.cache = new n({ maxSize: 1e3 });
|
|
310
|
+
let h = p ?? ((e) => e);
|
|
311
|
+
if (t) this.filehandle = t;
|
|
312
|
+
else if (e) this.filehandle = new r(e);
|
|
313
|
+
else if (o) this.filehandle = new i(o);
|
|
314
|
+
else throw TypeError("must provide either filehandle or path");
|
|
315
|
+
if (l) this.index = new w({
|
|
316
|
+
filehandle: l,
|
|
317
|
+
renameRefSeqs: h
|
|
318
|
+
});
|
|
319
|
+
else if (f) this.index = new b({
|
|
320
|
+
filehandle: f,
|
|
321
|
+
renameRefSeqs: h
|
|
322
|
+
});
|
|
323
|
+
else if (s) this.index = new w({
|
|
324
|
+
filehandle: new r(s),
|
|
325
|
+
renameRefSeqs: h
|
|
326
|
+
});
|
|
327
|
+
else if (u) this.index = new b({
|
|
328
|
+
filehandle: new r(u),
|
|
329
|
+
renameRefSeqs: h
|
|
330
|
+
});
|
|
331
|
+
else if (e) this.index = new w({
|
|
332
|
+
filehandle: new r(`${e}.tbi`),
|
|
333
|
+
renameRefSeqs: h
|
|
334
|
+
});
|
|
335
|
+
else if (d) this.index = new b({ filehandle: new i(d) });
|
|
336
|
+
else if (c) this.index = new w({ filehandle: new i(c) });
|
|
337
|
+
else if (o) this.index = new w({ filehandle: new i(`${o}.tbi`) });
|
|
338
|
+
else throw TypeError("must provide one of tbiFilehandle, tbiPath, csiFilehandle, csiPath, tbiUrl, csiUrl");
|
|
339
|
+
this.renameRefSeq = h, this.hasCustomRenameRefSeq = p !== void 0, this.chunkCache = new a({
|
|
340
|
+
cache: new n({ maxSize: Math.floor(m / 65536) }),
|
|
341
|
+
fill: (e, t) => this.readChunk(e, { signal: t })
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
calculateFileOffset(e, t, n, r, i) {
|
|
345
|
+
return e[n] * 256 + (r - t[n]) + i + 1;
|
|
346
|
+
}
|
|
347
|
+
async getLines(e, t, n, r) {
|
|
348
|
+
let i, a = {}, o;
|
|
349
|
+
typeof r == "function" ? o = r : (a = r, o = r.lineCallback, i = r.signal);
|
|
350
|
+
let s = await this.index.getMetadata(a), c = t ?? 0, l = n ?? s.maxRefLength;
|
|
351
|
+
if (!(c <= l)) throw TypeError("invalid start and end coordinates. start must be less than or equal to end");
|
|
352
|
+
if (c === l) return;
|
|
353
|
+
let u = await this.index.blocksForRange(e, c, l, a), d = new TextDecoder("utf8"), f = s.format === "VCF", p = {
|
|
354
|
+
ref: s.columnNumbers.ref || 0,
|
|
355
|
+
start: s.columnNumbers.start || 0,
|
|
356
|
+
end: f ? 8 : s.columnNumbers.end || 0
|
|
357
|
+
}, m = Math.max(p.ref, p.start, p.end), h = s.metaChar?.charCodeAt(0), g = s.coordinateType === "1-based-closed" ? -1 : 0, _ = !this.hasCustomRenameRefSeq;
|
|
358
|
+
for (let t of u) {
|
|
359
|
+
let { buffer: n, cpositions: r, dpositions: a } = await this.chunkCache.get(t.toString(), t, i), s = 0, u = 0, v = d.decode(n);
|
|
360
|
+
if (n.length == v.length) for (; s < v.length;) {
|
|
361
|
+
let n = v.indexOf("\n", s);
|
|
362
|
+
if (n === -1) break;
|
|
363
|
+
let i = v.slice(s, n);
|
|
364
|
+
if (a) {
|
|
365
|
+
let e = s + t.minv.dataPosition;
|
|
366
|
+
for (; u < a.length && e >= a[u];) u++;
|
|
367
|
+
}
|
|
368
|
+
let d = this.checkLine(e, c, l, i, p.ref, p.start, p.end, m, h, g, f, _);
|
|
369
|
+
if (d === null) return;
|
|
370
|
+
d !== void 0 && o(i, this.calculateFileOffset(r, a, u, s, t.minv.dataPosition), d.start, d.end), s = n + 1;
|
|
371
|
+
}
|
|
372
|
+
else for (; s < n.length;) {
|
|
373
|
+
let i = n.indexOf(10, s);
|
|
374
|
+
if (i === -1) break;
|
|
375
|
+
let v = n.slice(s, i), y = d.decode(v);
|
|
376
|
+
if (a) {
|
|
377
|
+
let e = s + t.minv.dataPosition;
|
|
378
|
+
for (; u < a.length && e >= a[u];) u++;
|
|
379
|
+
}
|
|
380
|
+
let b = this.checkLine(e, c, l, y, p.ref, p.start, p.end, m, h, g, f, _);
|
|
381
|
+
if (b === null) return;
|
|
382
|
+
b !== void 0 && o(y, this.calculateFileOffset(r, a, u, s, t.minv.dataPosition), b.start, b.end), s = i + 1;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
async getMetadata(e = {}) {
|
|
387
|
+
return this.index.getMetadata(e);
|
|
388
|
+
}
|
|
389
|
+
async getHeaderBuffer(t = {}) {
|
|
390
|
+
let { firstDataLine: n, metaChar: r, maxBlockSize: i } = await this.getMetadata(t), a = (n?.blockPosition || 0) + i, o = await e(await this.filehandle.read(a, 0, t));
|
|
391
|
+
if (r) {
|
|
392
|
+
let e = -1, t = r.charCodeAt(0);
|
|
393
|
+
for (let n = 0, r = o.length; n < r; n++) {
|
|
394
|
+
let r = o[n];
|
|
395
|
+
if (n === e + 1 && r !== t) break;
|
|
396
|
+
r === 10 && (e = n);
|
|
397
|
+
}
|
|
398
|
+
return o.subarray(0, e + 1);
|
|
399
|
+
}
|
|
400
|
+
return o;
|
|
401
|
+
}
|
|
402
|
+
async getHeader(e = {}) {
|
|
403
|
+
let t = new TextDecoder("utf8"), n = await this.getHeaderBuffer(e);
|
|
404
|
+
return t.decode(n);
|
|
405
|
+
}
|
|
406
|
+
async getReferenceSequenceNames(e = {}) {
|
|
407
|
+
return (await this.getMetadata(e)).refIdToName;
|
|
408
|
+
}
|
|
409
|
+
checkLine(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
410
|
+
if (c !== void 0 && r.charCodeAt(0) === c) return;
|
|
411
|
+
if (r.length < 500) {
|
|
412
|
+
let s = r.split(" "), c = s[i - 1];
|
|
413
|
+
if (!(d ? c === e : this.renameRefSeq(c) === e)) return;
|
|
414
|
+
let f = +s[a - 1] + l;
|
|
415
|
+
if (f >= n) return null;
|
|
416
|
+
let p;
|
|
417
|
+
return p = o === 0 || o === a ? f + 1 : u ? this._getVcfEnd(f, s[3], s[o - 1]) : +s[o - 1], p <= t ? void 0 : {
|
|
418
|
+
start: f,
|
|
419
|
+
end: p
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
let f = -1, p = [-1];
|
|
423
|
+
for (let e = 0; e < s; e++) {
|
|
424
|
+
let e = r.indexOf(" ", f + 1);
|
|
425
|
+
if (e === -1) {
|
|
426
|
+
p.push(r.length);
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
p.push(e), f = e;
|
|
430
|
+
}
|
|
431
|
+
let m = r.slice(p[i - 1] + 1, p[i]);
|
|
432
|
+
if (!(d ? m === e : this.renameRefSeq(m) === e)) return;
|
|
433
|
+
let h = +r.slice(p[a - 1] + 1, p[a]) + l;
|
|
434
|
+
if (h >= n) return null;
|
|
435
|
+
let g;
|
|
436
|
+
if (g = o === 0 || o === a ? h + 1 : u ? this._getVcfEnd(h, r.slice(p[3] + 1, p[4]), r.slice(p[o - 1] + 1, p[o])) : +r.slice(p[o - 1] + 1, p[o]), !(g <= t)) return {
|
|
437
|
+
start: h,
|
|
438
|
+
end: g
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
_getVcfEnd(e, t, n) {
|
|
442
|
+
let r = e + t.length;
|
|
443
|
+
if (n.includes("SVTYPE=TRA")) return e + 1;
|
|
444
|
+
if (n[0] !== ".") {
|
|
445
|
+
let e = n.indexOf("END=");
|
|
446
|
+
if (e !== -1 && (e === 0 || n[e - 1] === ";")) {
|
|
447
|
+
let t = e + 4, i = n.indexOf(";", t);
|
|
448
|
+
i === -1 && (i = n.length), r = Number.parseInt(n.slice(t, i), 10);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
return r;
|
|
452
|
+
}
|
|
453
|
+
async lineCount(e, t = {}) {
|
|
454
|
+
return this.index.lineCount(e, t);
|
|
455
|
+
}
|
|
456
|
+
async readChunk(e, n = {}) {
|
|
457
|
+
return t(await this.filehandle.read(e.fetchedSize(), e.minv.blockPosition, n), e, this.cache);
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
//#endregion
|
|
461
|
+
export { b as CSI, w as TBI, T as TabixIndexedFile };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { r,
|
|
1
|
+
import { n as e, r as t } from "./esm-BDFRLEuD.js";
|
|
2
|
+
import { t as n } from "./esm-CZvS2Ldm.js";
|
|
3
|
+
import { n as r, r as i } from "./esm-DRZ5LLNH.js";
|
|
4
4
|
//#region ../../node_modules/@gmod/bam/esm/chunk.js
|
|
5
5
|
var a = class {
|
|
6
6
|
constructor(e, t, n, r) {
|
|
@@ -145,8 +145,8 @@ var T = class extends v {
|
|
|
145
145
|
async lineCount(e, t) {
|
|
146
146
|
return (await this.parse(t)).indices(e)?.stats?.lineCount || 0;
|
|
147
147
|
}
|
|
148
|
-
async _parse(
|
|
149
|
-
let
|
|
148
|
+
async _parse(e) {
|
|
149
|
+
let t = await this.filehandle.readFile(), r = new DataView(t.buffer);
|
|
150
150
|
if (r.getUint32(0, !0) !== x) throw Error("Not a BAI file");
|
|
151
151
|
let i = r.getInt32(4, !0), o = ((1 << 18) - 1) / 7, s = 8, c, l = [];
|
|
152
152
|
for (let e = 0; e < i; e++) {
|
|
@@ -163,44 +163,44 @@ var T = class extends v {
|
|
|
163
163
|
for (let t = 0; t < e; t++) s += 8, s += 8;
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
let
|
|
166
|
+
let n = r.getInt32(s, !0);
|
|
167
167
|
s += 4;
|
|
168
|
-
let i = Array(
|
|
169
|
-
for (let e = 0; e <
|
|
170
|
-
let
|
|
171
|
-
s += 8, c = f(c,
|
|
168
|
+
let i = Array(n);
|
|
169
|
+
for (let e = 0; e < n; e++) {
|
|
170
|
+
let n = b(t, s);
|
|
171
|
+
s += 8, c = f(c, n), i[e] = n;
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
-
let u = new
|
|
174
|
+
let u = new n({ maxSize: 5 });
|
|
175
175
|
function p(e) {
|
|
176
|
-
let
|
|
177
|
-
if (
|
|
178
|
-
let i = r.getInt32(
|
|
179
|
-
|
|
176
|
+
let n = l[e];
|
|
177
|
+
if (n === void 0) return;
|
|
178
|
+
let i = r.getInt32(n, !0), s;
|
|
179
|
+
n += 4;
|
|
180
180
|
let u = {};
|
|
181
181
|
for (let e = 0; e < i; e += 1) {
|
|
182
|
-
let e = r.getUint32(
|
|
183
|
-
if (
|
|
182
|
+
let e = r.getUint32(n, !0);
|
|
183
|
+
if (n += 4, e === o + 1) n += 4, s = d(t, n + 16), n += 32;
|
|
184
184
|
else if (e > o + 1) throw Error("bai index contains too many bins, please use CSI");
|
|
185
185
|
else {
|
|
186
|
-
let i = r.getInt32(
|
|
187
|
-
|
|
186
|
+
let i = r.getInt32(n, !0);
|
|
187
|
+
n += 4;
|
|
188
188
|
let o = Array(i);
|
|
189
189
|
for (let r = 0; r < i; r++) {
|
|
190
|
-
let i = b(
|
|
191
|
-
|
|
192
|
-
let s = b(
|
|
193
|
-
|
|
190
|
+
let i = b(t, n);
|
|
191
|
+
n += 8;
|
|
192
|
+
let s = b(t, n);
|
|
193
|
+
n += 8, c = f(c, i), o[r] = new a(i, s, e);
|
|
194
194
|
}
|
|
195
195
|
u[e] = o;
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
let p = r.getInt32(
|
|
199
|
-
|
|
198
|
+
let p = r.getInt32(n, !0);
|
|
199
|
+
n += 4;
|
|
200
200
|
let m = Array(p);
|
|
201
201
|
for (let e = 0; e < p; e++) {
|
|
202
|
-
let r = b(
|
|
203
|
-
|
|
202
|
+
let r = b(t, n);
|
|
203
|
+
n += 8, c = f(c, r), m[e] = r;
|
|
204
204
|
}
|
|
205
205
|
return {
|
|
206
206
|
binIndex: u,
|
|
@@ -565,8 +565,8 @@ var M = class extends v {
|
|
|
565
565
|
...p(e.subarray(t + 28, t + 28 + u), this.renameRefSeq)
|
|
566
566
|
};
|
|
567
567
|
}
|
|
568
|
-
async _parse(
|
|
569
|
-
let r = await
|
|
568
|
+
async _parse(t) {
|
|
569
|
+
let r = await e(await this.filehandle.readFile(t)), i = new DataView(r.buffer), o, s = i.getUint32(0, !0);
|
|
570
570
|
if (s === O) o = 1;
|
|
571
571
|
else if (s === k) o = 2;
|
|
572
572
|
else throw Error(`Not a CSI file ${s}`);
|
|
@@ -590,7 +590,7 @@ var M = class extends v {
|
|
|
590
590
|
}
|
|
591
591
|
}
|
|
592
592
|
}
|
|
593
|
-
let _ = new
|
|
593
|
+
let _ = new n({ maxSize: 5 });
|
|
594
594
|
function v(e) {
|
|
595
595
|
let t = g[e];
|
|
596
596
|
if (t === void 0) return;
|
|
@@ -1126,38 +1126,38 @@ function B(e) {
|
|
|
1126
1126
|
return n;
|
|
1127
1127
|
}
|
|
1128
1128
|
var V = 65536, H = class {
|
|
1129
|
-
constructor({ bamFilehandle:
|
|
1130
|
-
if (this.htsget = !1, this.chunkFeatureCache = new
|
|
1131
|
-
else if (
|
|
1132
|
-
else if (a) this.bam = new
|
|
1129
|
+
constructor({ bamFilehandle: e, bamPath: t, bamUrl: a, baiPath: o, baiFilehandle: s, baiUrl: c, csiPath: l, csiFilehandle: u, csiUrl: d, htsget: f, renameRefSeqs: p = (e) => e, recordClass: m }) {
|
|
1130
|
+
if (this.htsget = !1, this.chunkFeatureCache = new n({ maxSize: 100 }), this.renameRefSeq = p, this.RecordClass = m ?? z, e) this.bam = e;
|
|
1131
|
+
else if (t) this.bam = new r(t);
|
|
1132
|
+
else if (a) this.bam = new i(a);
|
|
1133
1133
|
else if (f) this.htsget = !0, this.bam = new N();
|
|
1134
1134
|
else throw Error("unable to initialize bam");
|
|
1135
1135
|
if (u) this.index = new M({ filehandle: u });
|
|
1136
|
-
else if (l) this.index = new M({ filehandle: new
|
|
1137
|
-
else if (d) this.index = new M({ filehandle: new
|
|
1136
|
+
else if (l) this.index = new M({ filehandle: new r(l) });
|
|
1137
|
+
else if (d) this.index = new M({ filehandle: new i(d) });
|
|
1138
1138
|
else if (s) this.index = new T({ filehandle: s });
|
|
1139
|
-
else if (o) this.index = new T({ filehandle: new
|
|
1140
|
-
else if (c) this.index = new T({ filehandle: new
|
|
1141
|
-
else if (
|
|
1142
|
-
else if (a) this.index = new T({ filehandle: new
|
|
1139
|
+
else if (o) this.index = new T({ filehandle: new r(o) });
|
|
1140
|
+
else if (c) this.index = new T({ filehandle: new i(c) });
|
|
1141
|
+
else if (t) this.index = new T({ filehandle: new r(`${t}.bai`) });
|
|
1142
|
+
else if (a) this.index = new T({ filehandle: new i(`${a}.bai`) });
|
|
1143
1143
|
else if (f) this.htsget = !0;
|
|
1144
1144
|
else throw Error("unable to infer index format");
|
|
1145
1145
|
}
|
|
1146
|
-
async getHeaderPre(
|
|
1147
|
-
let n = l(
|
|
1146
|
+
async getHeaderPre(t) {
|
|
1147
|
+
let n = l(t);
|
|
1148
1148
|
if (!this.index) return;
|
|
1149
|
-
let r = await this.index.parse(n), i = r.firstDataLine === void 0 ? void 0 : r.firstDataLine.blockPosition + V, a = await
|
|
1149
|
+
let r = await this.index.parse(n), i = r.firstDataLine === void 0 ? void 0 : r.firstDataLine.blockPosition + V, a = await e(i === void 0 ? await this.bam.readFile() : await this.bam.read(i, 0)), o = new DataView(a.buffer);
|
|
1150
1150
|
if (o.getInt32(0, !0) !== 21840194) throw Error("Not a BAM file");
|
|
1151
1151
|
let s = o.getInt32(4, !0);
|
|
1152
1152
|
this.header = new TextDecoder("utf8").decode(a.subarray(8, 8 + s));
|
|
1153
1153
|
let c = s + 8;
|
|
1154
|
-
for (let
|
|
1154
|
+
for (let t = 0; t < 5; t++) {
|
|
1155
1155
|
if (this._hasEnoughRefSeqData(a, c)) {
|
|
1156
1156
|
let { chrToIndex: e, indexToChr: t } = this._parseRefSeqs(a, c);
|
|
1157
1157
|
return this.chrToIndex = e, this.indexToChr = t, B(this.header);
|
|
1158
1158
|
}
|
|
1159
1159
|
if (i === void 0) throw Error(`Insufficient data for reference sequences in ${a.length} bytes`);
|
|
1160
|
-
i *= 2, a = await
|
|
1160
|
+
i *= 2, a = await e(await this.bam.read(i, 0));
|
|
1161
1161
|
}
|
|
1162
1162
|
throw Error("Insufficient data for reference sequences after 5 retries");
|
|
1163
1163
|
}
|
|
@@ -1281,8 +1281,8 @@ var V = 65536, H = class {
|
|
|
1281
1281
|
return c;
|
|
1282
1282
|
}))).flat();
|
|
1283
1283
|
}
|
|
1284
|
-
async _readChunk({ chunk: e, opts:
|
|
1285
|
-
let { buffer: r, cpositions: i, dpositions: a } = await
|
|
1284
|
+
async _readChunk({ chunk: e, opts: n }) {
|
|
1285
|
+
let { buffer: r, cpositions: i, dpositions: a } = await t(await this.bam.read(e.fetchedSize(), e.minv.blockPosition, n), e);
|
|
1286
1286
|
return {
|
|
1287
1287
|
data: r,
|
|
1288
1288
|
cpositions: i,
|
|
@@ -1352,8 +1352,8 @@ var V = 65536, H = class {
|
|
|
1352
1352
|
};
|
|
1353
1353
|
//#endregion
|
|
1354
1354
|
//#region ../../node_modules/@gmod/bam/esm/htsget.js
|
|
1355
|
-
async function U(
|
|
1356
|
-
let r = await Promise.all(
|
|
1355
|
+
async function U(t, n) {
|
|
1356
|
+
let r = await Promise.all(t.map(async (e) => {
|
|
1357
1357
|
let { url: t, headers: r } = e;
|
|
1358
1358
|
if (t.startsWith("data:")) {
|
|
1359
1359
|
let e = await fetch(t);
|
|
@@ -1372,7 +1372,7 @@ async function U(e, n) {
|
|
|
1372
1372
|
return new Uint8Array(await a.arrayBuffer());
|
|
1373
1373
|
}
|
|
1374
1374
|
}));
|
|
1375
|
-
return m(await Promise.all(r.map((
|
|
1375
|
+
return m(await Promise.all(r.map((t) => e(t))));
|
|
1376
1376
|
}
|
|
1377
1377
|
var W = class extends H {
|
|
1378
1378
|
constructor(e) {
|