@genome-spy/core 0.64.0 → 0.66.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/bundle/{index-CCJIjehY.js → AbortablePromiseCache-CcuMrnn7.js} +22 -91
- package/dist/bundle/browser-BRemItdO.js +138 -0
- package/dist/bundle/index-BatuyGAI.js +271 -0
- package/dist/bundle/index-ByuE8dvu.js +332 -0
- package/dist/bundle/index-Cq3QFUxX.js +1781 -0
- package/dist/bundle/{index-C08YCM2T.js → index-D-w7Mmt9.js} +246 -126
- package/dist/bundle/index-D28m8tSW.js +1607 -0
- package/dist/bundle/index-D74H8TTz.js +508 -0
- package/dist/bundle/index-DbJ0oeYM.js +631 -0
- package/dist/bundle/index.es.js +15034 -13842
- package/dist/bundle/index.js +223 -237
- package/dist/bundle/inflate-GtwLkvSP.js +1048 -0
- package/dist/bundle/unzip-NywezaRR.js +1492 -0
- package/dist/schema.json +22 -4
- package/dist/src/config/scaleDefaults.d.ts +8 -0
- package/dist/src/config/scaleDefaults.d.ts.map +1 -0
- package/dist/src/config/scaleDefaults.js +45 -0
- package/dist/src/data/collector.d.ts +7 -2
- package/dist/src/data/collector.d.ts.map +1 -1
- package/dist/src/data/collector.js +13 -2
- package/dist/src/data/dataFlow.d.ts +20 -42
- package/dist/src/data/dataFlow.d.ts.map +1 -1
- package/dist/src/data/dataFlow.js +57 -80
- package/dist/src/data/flowHandle.d.ts +15 -0
- package/dist/src/data/flowHandle.d.ts.map +1 -0
- package/dist/src/data/flowHandle.js +13 -0
- package/dist/src/data/flowInit.d.ts +85 -0
- package/dist/src/data/flowInit.d.ts.map +1 -0
- package/dist/src/data/flowInit.js +238 -0
- package/dist/src/data/flowInit.test.d.ts +2 -0
- package/dist/src/data/flowInit.test.d.ts.map +1 -0
- package/dist/src/data/flowOptimizer.d.ts +6 -4
- package/dist/src/data/flowOptimizer.d.ts.map +1 -1
- package/dist/src/data/flowOptimizer.js +29 -14
- package/dist/src/data/sources/lazy/axisTickSource.js +1 -1
- package/dist/src/data/sources/lazy/bamSource.js +1 -1
- package/dist/src/data/sources/lazy/bigBedSource.js +1 -1
- package/dist/src/data/sources/lazy/bigWigSource.js +1 -1
- package/dist/src/data/sources/lazy/gff3Source.d.ts +2 -6
- package/dist/src/data/sources/lazy/gff3Source.d.ts.map +1 -1
- package/dist/src/data/sources/lazy/gff3Source.js +4 -8
- package/dist/src/data/sources/lazy/indexedFastaSource.d.ts.map +1 -1
- package/dist/src/data/sources/lazy/indexedFastaSource.js +17 -17
- package/dist/src/data/sources/lazy/singleAxisLazySource.d.ts +1 -1
- package/dist/src/data/sources/lazy/singleAxisLazySource.d.ts.map +1 -1
- package/dist/src/data/sources/lazy/singleAxisLazySource.js +10 -3
- package/dist/src/data/sources/lazy/singleAxisWindowedSource.d.ts.map +1 -1
- package/dist/src/data/sources/lazy/singleAxisWindowedSource.js +5 -1
- package/dist/src/data/sources/lazy/tabixSource.js +1 -1
- package/dist/src/data/transforms/filterScoredLabels.d.ts +1 -1
- package/dist/src/data/transforms/filterScoredLabels.d.ts.map +1 -1
- package/dist/src/data/transforms/filterScoredLabels.js +1 -1
- package/dist/src/data/transforms/linearizeGenomicCoordinate.d.ts.map +1 -1
- package/dist/src/data/transforms/linearizeGenomicCoordinate.js +2 -1
- package/dist/src/encoder/encoder.d.ts +1 -1
- package/dist/src/encoder/encoder.d.ts.map +1 -1
- package/dist/src/encoder/encoder.js +1 -1
- package/dist/src/genome/scaleLocus.d.ts +39 -0
- package/dist/src/genome/scaleLocus.d.ts.map +1 -1
- package/dist/src/genome/scaleLocus.js +76 -0
- package/dist/src/genomeSpy/canvasExport.d.ts +19 -0
- package/dist/src/genomeSpy/canvasExport.d.ts.map +1 -0
- package/dist/src/genomeSpy/canvasExport.js +66 -0
- package/dist/src/genomeSpy/containerUi.d.ts +17 -0
- package/dist/src/genomeSpy/containerUi.d.ts.map +1 -0
- package/dist/src/genomeSpy/containerUi.js +78 -0
- package/dist/src/genomeSpy/eventListenerRegistry.d.ts +19 -0
- package/dist/src/genomeSpy/eventListenerRegistry.d.ts.map +1 -0
- package/dist/src/genomeSpy/eventListenerRegistry.js +38 -0
- package/dist/src/genomeSpy/inputBindingManager.d.ts +14 -0
- package/dist/src/genomeSpy/inputBindingManager.d.ts.map +1 -0
- package/dist/src/genomeSpy/inputBindingManager.js +63 -0
- package/dist/src/genomeSpy/interactionController.d.ts +40 -0
- package/dist/src/genomeSpy/interactionController.d.ts.map +1 -0
- package/dist/src/genomeSpy/interactionController.js +371 -0
- package/dist/src/genomeSpy/keyboardListenerManager.d.ts +10 -0
- package/dist/src/genomeSpy/keyboardListenerManager.d.ts.map +1 -0
- package/dist/src/genomeSpy/keyboardListenerManager.js +31 -0
- package/dist/src/genomeSpy/loadingIndicatorManager.d.ts +15 -0
- package/dist/src/genomeSpy/loadingIndicatorManager.d.ts.map +1 -0
- package/dist/src/genomeSpy/loadingIndicatorManager.js +92 -0
- package/dist/src/genomeSpy/renderCoordinator.d.ts +22 -0
- package/dist/src/genomeSpy/renderCoordinator.d.ts.map +1 -0
- package/dist/src/genomeSpy/renderCoordinator.js +118 -0
- package/dist/src/genomeSpy/viewContextFactory.d.ts +18 -0
- package/dist/src/genomeSpy/viewContextFactory.d.ts.map +1 -0
- package/dist/src/genomeSpy/viewContextFactory.js +79 -0
- package/dist/src/genomeSpy/viewDataInit.d.ts +12 -0
- package/dist/src/genomeSpy/viewDataInit.d.ts.map +1 -0
- package/dist/src/genomeSpy/viewDataInit.js +41 -0
- package/dist/src/genomeSpy/viewHierarchyConfig.d.ts +14 -0
- package/dist/src/genomeSpy/viewHierarchyConfig.d.ts.map +1 -0
- package/dist/src/genomeSpy/viewHierarchyConfig.js +24 -0
- package/dist/src/genomeSpy/viewHighlight.d.ts +5 -0
- package/dist/src/genomeSpy/viewHighlight.d.ts.map +1 -0
- package/dist/src/genomeSpy/viewHighlight.js +30 -0
- package/dist/src/genomeSpy.d.ts +17 -72
- package/dist/src/genomeSpy.d.ts.map +1 -1
- package/dist/src/genomeSpy.js +180 -789
- package/dist/src/gl/glslScaleGenerator.d.ts +1 -1
- package/dist/src/gl/webGLHelper.d.ts +2 -2
- package/dist/src/gl/webGLHelper.d.ts.map +1 -1
- package/dist/src/gl/webGLHelper.js +4 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -12
- package/dist/src/marks/mark.d.ts +1 -0
- package/dist/src/marks/mark.d.ts.map +1 -1
- package/dist/src/marks/mark.js +26 -3
- package/dist/src/{view → scales}/axisResolution.d.ts +12 -14
- package/dist/src/scales/axisResolution.d.ts.map +1 -0
- package/dist/src/{view → scales}/axisResolution.js +38 -12
- package/dist/src/scales/axisResolution.test.d.ts.map +1 -0
- package/dist/src/scales/scaleDomainAggregator.d.ts +57 -0
- package/dist/src/scales/scaleDomainAggregator.d.ts.map +1 -0
- package/dist/src/scales/scaleDomainAggregator.js +162 -0
- package/dist/src/scales/scaleDomainAggregator.test.d.ts +2 -0
- package/dist/src/scales/scaleDomainAggregator.test.d.ts.map +1 -0
- package/dist/src/scales/scaleInstanceManager.d.ts +40 -0
- package/dist/src/scales/scaleInstanceManager.d.ts.map +1 -0
- package/dist/src/scales/scaleInstanceManager.js +313 -0
- package/dist/src/scales/scaleInstanceManager.test.d.ts +2 -0
- package/dist/src/scales/scaleInstanceManager.test.d.ts.map +1 -0
- package/dist/src/scales/scaleInteractionController.d.ts +73 -0
- package/dist/src/scales/scaleInteractionController.d.ts.map +1 -0
- package/dist/src/scales/scaleInteractionController.js +336 -0
- package/dist/src/scales/scaleInteractionController.test.d.ts +2 -0
- package/dist/src/scales/scaleInteractionController.test.d.ts.map +1 -0
- package/dist/src/scales/scalePropsResolver.d.ts +23 -0
- package/dist/src/scales/scalePropsResolver.d.ts.map +1 -0
- package/dist/src/scales/scalePropsResolver.js +74 -0
- package/dist/src/{view → scales}/scaleResolution.d.ts +53 -31
- package/dist/src/scales/scaleResolution.d.ts.map +1 -0
- package/dist/src/scales/scaleResolution.js +658 -0
- package/dist/src/scales/scaleResolution.test.d.ts.map +1 -0
- package/dist/src/scales/scaleResolutionConstants.d.ts +6 -0
- package/dist/src/scales/scaleResolutionConstants.d.ts.map +1 -0
- package/dist/src/scales/scaleResolutionConstants.js +5 -0
- package/dist/src/scales/scaleRules.d.ts +16 -0
- package/dist/src/scales/scaleRules.d.ts.map +1 -0
- package/dist/src/scales/scaleRules.js +103 -0
- package/dist/src/scales/scaleRules.test.d.ts +2 -0
- package/dist/src/scales/scaleRules.test.d.ts.map +1 -0
- package/dist/src/spec/channel.d.ts +13 -18
- package/dist/src/spec/sampleView.d.ts +3 -2
- package/dist/src/spec/scale.d.ts +6 -0
- package/dist/src/types/embedApi.d.ts +5 -0
- package/dist/src/types/scaleResolutionApi.d.ts +1 -1
- package/dist/src/types/viewContext.d.ts +1 -1
- package/dist/src/view/concatView.d.ts +18 -0
- package/dist/src/view/concatView.d.ts.map +1 -1
- package/dist/src/view/concatView.js +73 -0
- package/dist/src/view/concatView.test.d.ts +2 -0
- package/dist/src/view/concatView.test.d.ts.map +1 -0
- package/dist/src/view/containerMutationHelper.d.ts +74 -0
- package/dist/src/view/containerMutationHelper.d.ts.map +1 -0
- package/dist/src/view/containerMutationHelper.js +114 -0
- package/dist/src/view/containerView.d.ts +0 -7
- package/dist/src/view/containerView.d.ts.map +1 -1
- package/dist/src/view/containerView.js +0 -10
- package/dist/src/view/facetView.d.ts.map +1 -1
- package/dist/src/view/facetView.js +0 -14
- package/dist/src/view/flowBuilder.d.ts +2 -2
- package/dist/src/view/flowBuilder.d.ts.map +1 -1
- package/dist/src/view/flowBuilder.js +21 -4
- package/dist/src/view/gridView/gridChild.d.ts +11 -0
- package/dist/src/view/gridView/gridChild.d.ts.map +1 -1
- package/dist/src/view/gridView/gridChild.js +32 -6
- package/dist/src/view/gridView/gridView.d.ts +39 -1
- package/dist/src/view/gridView/gridView.d.ts.map +1 -1
- package/dist/src/view/gridView/gridView.js +113 -42
- package/dist/src/view/gridView/gridView.test.d.ts +2 -0
- package/dist/src/view/gridView/gridView.test.d.ts.map +1 -0
- package/dist/src/view/gridView/scrollbar.d.ts +39 -8
- package/dist/src/view/gridView/scrollbar.d.ts.map +1 -1
- package/dist/src/view/gridView/scrollbar.js +184 -69
- package/dist/src/view/gridView/selectionRect.d.ts +8 -4
- package/dist/src/view/gridView/selectionRect.d.ts.map +1 -1
- package/dist/src/view/gridView/selectionRect.js +28 -3
- package/dist/src/view/gridView/selectionRect.test.d.ts +2 -0
- package/dist/src/view/gridView/selectionRect.test.d.ts.map +1 -0
- package/dist/src/view/layerView.d.ts +14 -0
- package/dist/src/view/layerView.d.ts.map +1 -1
- package/dist/src/view/layerView.js +66 -0
- package/dist/src/view/layerView.test.d.ts +2 -0
- package/dist/src/view/layerView.test.d.ts.map +1 -0
- package/dist/src/view/paramMediator.d.ts +2 -1
- package/dist/src/view/paramMediator.d.ts.map +1 -1
- package/dist/src/view/paramMediator.js +13 -1
- package/dist/src/view/testUtils.d.ts.map +1 -1
- package/dist/src/view/testUtils.js +18 -5
- package/dist/src/view/unitView.d.ts.map +1 -1
- package/dist/src/view/unitView.js +52 -12
- package/dist/src/view/view.d.ts +23 -7
- package/dist/src/view/view.d.ts.map +1 -1
- package/dist/src/view/view.js +61 -5
- package/dist/src/view/viewDispose.test.d.ts +2 -0
- package/dist/src/view/viewDispose.test.d.ts.map +1 -0
- package/dist/src/view/viewUtils.d.ts +4 -4
- package/dist/src/view/viewUtils.d.ts.map +1 -1
- package/dist/src/view/viewUtils.js +19 -15
- package/dist/src/view/viewUtils.test.d.ts +2 -0
- package/dist/src/view/viewUtils.test.d.ts.map +1 -0
- package/package.json +10 -10
- package/dist/bundle/__vite-browser-external-C--ziKoh.js +0 -8
- package/dist/bundle/_commonjsHelpers-DjF3Plf2.js +0 -26
- package/dist/bundle/index-5ajWdKly.js +0 -1319
- package/dist/bundle/index-B03-Om4z.js +0 -274
- package/dist/bundle/index-BftNdA0O.js +0 -27
- package/dist/bundle/index-Bg7C4Xat.js +0 -2750
- package/dist/bundle/index-C3QR8Lv6.js +0 -2131
- package/dist/bundle/index-DTcHjAHp.js +0 -505
- package/dist/bundle/index-DnIkxb0L.js +0 -1025
- package/dist/bundle/index-Ww3TAo6_.js +0 -71
- package/dist/bundle/index-g8iXgW0W.js +0 -651
- package/dist/bundle/long-B-FASCSo.js +0 -2387
- package/dist/bundle/remoteFile-BuaqFGWk.js +0 -94
- package/dist/src/data/collector.test.js +0 -138
- package/dist/src/data/dataFlow.test.js +0 -5
- package/dist/src/data/flow.test.js +0 -81
- package/dist/src/data/flowNode.test.js +0 -50
- package/dist/src/data/flowOptimizer.test.js +0 -204
- package/dist/src/data/formats/fasta.test.js +0 -27
- package/dist/src/data/sources/inlineSource.test.js +0 -63
- package/dist/src/data/sources/sequenceSource.test.js +0 -81
- package/dist/src/data/transforms/aggregate.test.js +0 -134
- package/dist/src/data/transforms/clone.test.js +0 -11
- package/dist/src/data/transforms/coverage.test.js +0 -238
- package/dist/src/data/transforms/filter.test.js +0 -20
- package/dist/src/data/transforms/flatten.test.js +0 -96
- package/dist/src/data/transforms/flattenDelimited.test.js +0 -90
- package/dist/src/data/transforms/flattenSequence.test.js +0 -34
- package/dist/src/data/transforms/formula.test.js +0 -25
- package/dist/src/data/transforms/identifier.test.js +0 -92
- package/dist/src/data/transforms/pileup.test.js +0 -70
- package/dist/src/data/transforms/project.test.js +0 -32
- package/dist/src/data/transforms/regexExtract.test.js +0 -70
- package/dist/src/data/transforms/regexFold.test.js +0 -201
- package/dist/src/data/transforms/sample.test.js +0 -38
- package/dist/src/data/transforms/stack.test.js +0 -91
- package/dist/src/encoder/accessor.test.js +0 -162
- package/dist/src/encoder/encoder.test.js +0 -105
- package/dist/src/genome/genome.test.js +0 -268
- package/dist/src/genome/genomes.test.js +0 -8
- package/dist/src/genome/scaleIndex.test.js +0 -78
- package/dist/src/genome/scaleLocus.test.js +0 -4
- package/dist/src/scale/scale.test.js +0 -326
- package/dist/src/scale/ticks.test.js +0 -46
- package/dist/src/selection/selection.test.js +0 -14
- package/dist/src/utils/addBaseUrl.test.js +0 -30
- package/dist/src/utils/binnedIndex.test.js +0 -201
- package/dist/src/utils/cloner.test.js +0 -35
- package/dist/src/utils/coalesce.test.js +0 -16
- package/dist/src/utils/concatIterables.test.js +0 -8
- package/dist/src/utils/domainArray.test.js +0 -130
- package/dist/src/utils/indexer.test.js +0 -49
- package/dist/src/utils/interactionEvent.test.js +0 -35
- package/dist/src/utils/iterateNestedMaps.test.js +0 -33
- package/dist/src/utils/kWayMerge.test.js +0 -30
- package/dist/src/utils/mergeObjects.test.js +0 -42
- package/dist/src/utils/numberExtractor.test.js +0 -6
- package/dist/src/utils/propertyCacher.test.js +0 -89
- package/dist/src/utils/propertyCoalescer.test.js +0 -25
- package/dist/src/utils/radixSort.test.js +0 -51
- package/dist/src/utils/reservationMap.test.js +0 -20
- package/dist/src/utils/ringBuffer.test.js +0 -39
- package/dist/src/utils/topK.test.js +0 -54
- package/dist/src/utils/trees.test.js +0 -135
- package/dist/src/utils/url.test.js +0 -28
- package/dist/src/utils/variableTools.test.js +0 -13
- package/dist/src/view/axisResolution.d.ts.map +0 -1
- package/dist/src/view/axisResolution.test.d.ts.map +0 -1
- package/dist/src/view/axisResolution.test.js +0 -206
- package/dist/src/view/flowBuilder.test.js +0 -125
- package/dist/src/view/layout/flexLayout.test.js +0 -323
- package/dist/src/view/layout/grid.test.js +0 -71
- package/dist/src/view/layout/rectangle.test.js +0 -192
- package/dist/src/view/paramMediator.test.js +0 -260
- package/dist/src/view/scaleResolution.d.ts.map +0 -1
- package/dist/src/view/scaleResolution.js +0 -1049
- package/dist/src/view/scaleResolution.test.d.ts.map +0 -1
- package/dist/src/view/scaleResolution.test.js +0 -645
- package/dist/src/view/view.test.js +0 -245
- package/dist/src/view/viewFactory.test.js +0 -25
- /package/dist/src/{view → scales}/axisResolution.test.d.ts +0 -0
- /package/dist/src/{view → scales}/scaleResolution.test.d.ts +0 -0
|
@@ -0,0 +1,631 @@
|
|
|
1
|
+
import { A as J } from "./AbortablePromiseCache-CcuMrnn7.js";
|
|
2
|
+
import { u as E, Q as U, a as K } from "./unzip-NywezaRR.js";
|
|
3
|
+
import { LocalFile as F, RemoteFile as M } from "./browser-BRemItdO.js";
|
|
4
|
+
class L {
|
|
5
|
+
constructor(e, t, n, i) {
|
|
6
|
+
this.minv = e, this.maxv = t, this.bin = n, this._fetchedSize = i;
|
|
7
|
+
}
|
|
8
|
+
toUniqueString() {
|
|
9
|
+
return `${this.minv}..${this.maxv} (bin ${this.bin}, fetchedSize ${this.fetchedSize()})`;
|
|
10
|
+
}
|
|
11
|
+
toString() {
|
|
12
|
+
return this.toUniqueString();
|
|
13
|
+
}
|
|
14
|
+
compareTo(e) {
|
|
15
|
+
return this.minv.compareTo(e.minv) || this.maxv.compareTo(e.maxv) || this.bin - e.bin;
|
|
16
|
+
}
|
|
17
|
+
fetchedSize() {
|
|
18
|
+
return this._fetchedSize !== void 0 ? this._fetchedSize : this.maxv.blockPosition + 65536 - this.minv.blockPosition;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
class j {
|
|
22
|
+
constructor({ filehandle: e, renameRefSeqs: t = (n) => n }) {
|
|
23
|
+
this.filehandle = e, this.renameRefSeq = t;
|
|
24
|
+
}
|
|
25
|
+
async getMetadata(e = {}) {
|
|
26
|
+
const { indices: t, ...n } = await this.parse(e);
|
|
27
|
+
return n;
|
|
28
|
+
}
|
|
29
|
+
_findFirstData(e, t) {
|
|
30
|
+
return e ? e.compareTo(t) > 0 ? t : e : t;
|
|
31
|
+
}
|
|
32
|
+
async parse(e = {}) {
|
|
33
|
+
return this.parseP || (this.parseP = this._parse(e).catch((t) => {
|
|
34
|
+
throw this.parseP = void 0, t;
|
|
35
|
+
})), this.parseP;
|
|
36
|
+
}
|
|
37
|
+
async hasRefSeq(e, t = {}) {
|
|
38
|
+
var i;
|
|
39
|
+
return !!((i = (await this.parse(t)).indices[e]) != null && i.binIndex);
|
|
40
|
+
}
|
|
41
|
+
_parseNameBytes(e) {
|
|
42
|
+
let t = 0, n = 0;
|
|
43
|
+
const i = [], o = {}, r = new TextDecoder("utf8");
|
|
44
|
+
for (let s = 0; s < e.length; s += 1)
|
|
45
|
+
if (!e[s]) {
|
|
46
|
+
if (n < s) {
|
|
47
|
+
const c = this.renameRefSeq(r.decode(e.subarray(n, s)));
|
|
48
|
+
i[t] = c, o[c] = t;
|
|
49
|
+
}
|
|
50
|
+
n = s + 1, t += 1;
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
refNameToId: o,
|
|
54
|
+
refIdToName: i
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const H = 65536, Z = H * H;
|
|
59
|
+
function Q(a, e = 0) {
|
|
60
|
+
const t = a[e] | a[e + 1] << 8 | a[e + 2] << 16 | a[e + 3] << 24;
|
|
61
|
+
return ((a[e + 4] | a[e + 5] << 8 | a[e + 6] << 16 | a[e + 7] << 24) >>> 0) * Z + (t >>> 0);
|
|
62
|
+
}
|
|
63
|
+
function ee(a, e) {
|
|
64
|
+
return e.minv.blockPosition - a.maxv.blockPosition < 65e3 && e.maxv.blockPosition - a.minv.blockPosition < 5e6;
|
|
65
|
+
}
|
|
66
|
+
function X(a, e) {
|
|
67
|
+
const t = [];
|
|
68
|
+
let n;
|
|
69
|
+
if (a.length === 0)
|
|
70
|
+
return a;
|
|
71
|
+
a.sort(function(i, o) {
|
|
72
|
+
const r = i.minv.blockPosition - o.minv.blockPosition;
|
|
73
|
+
return r === 0 ? i.minv.dataPosition - o.minv.dataPosition : r;
|
|
74
|
+
});
|
|
75
|
+
for (const i of a)
|
|
76
|
+
(!e || i.maxv.compareTo(e) > 0) && (n === void 0 ? (t.push(i), n = i) : ee(n, i) ? i.maxv.compareTo(n.maxv) > 0 && (n.maxv = i.maxv) : (t.push(i), n = i));
|
|
77
|
+
return t;
|
|
78
|
+
}
|
|
79
|
+
class O {
|
|
80
|
+
constructor(e, t) {
|
|
81
|
+
this.blockPosition = e, this.dataPosition = t;
|
|
82
|
+
}
|
|
83
|
+
toString() {
|
|
84
|
+
return `${this.blockPosition}:${this.dataPosition}`;
|
|
85
|
+
}
|
|
86
|
+
compareTo(e) {
|
|
87
|
+
return this.blockPosition - e.blockPosition || this.dataPosition - e.dataPosition;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function A(a, e = 0) {
|
|
91
|
+
return new O(a[e + 7] * 1099511627776 + a[e + 6] * 4294967296 + a[e + 5] * 16777216 + a[e + 4] * 65536 + a[e + 3] * 256 + a[e + 2], a[e + 1] << 8 | a[e]);
|
|
92
|
+
}
|
|
93
|
+
const te = 21582659, ne = 38359875, ie = {
|
|
94
|
+
0: "generic",
|
|
95
|
+
1: "SAM",
|
|
96
|
+
2: "VCF"
|
|
97
|
+
};
|
|
98
|
+
function se(a, e) {
|
|
99
|
+
return a * 2 ** e;
|
|
100
|
+
}
|
|
101
|
+
function W(a, e) {
|
|
102
|
+
return Math.floor(a / 2 ** e);
|
|
103
|
+
}
|
|
104
|
+
class q extends j {
|
|
105
|
+
constructor(e) {
|
|
106
|
+
super(e), this.maxBinNumber = 0, this.depth = 0, this.minShift = 0;
|
|
107
|
+
}
|
|
108
|
+
async lineCount(e, t = {}) {
|
|
109
|
+
const n = await this.parse(t), i = n.refNameToId[e];
|
|
110
|
+
if (i === void 0 || !n.indices[i])
|
|
111
|
+
return -1;
|
|
112
|
+
const { stats: r } = n.indices[i];
|
|
113
|
+
return r ? r.lineCount : -1;
|
|
114
|
+
}
|
|
115
|
+
indexCov() {
|
|
116
|
+
throw new Error("CSI indexes do not support indexcov");
|
|
117
|
+
}
|
|
118
|
+
parseAuxData(e, t) {
|
|
119
|
+
const n = new DataView(e.buffer), i = n.getInt32(t, !0), o = i & 65536 ? "zero-based-half-open" : "1-based-closed", r = ie[i & 15];
|
|
120
|
+
if (!r)
|
|
121
|
+
throw new Error(`invalid Tabix preset format flags ${i}`);
|
|
122
|
+
const s = {
|
|
123
|
+
ref: n.getInt32(t + 4, !0),
|
|
124
|
+
start: n.getInt32(t + 8, !0),
|
|
125
|
+
end: n.getInt32(t + 12, !0)
|
|
126
|
+
}, c = n.getInt32(t + 16, !0), m = c ? String.fromCharCode(c) : void 0, f = n.getInt32(t + 20, !0), x = n.getInt32(t + 24, !0), { refIdToName: d, refNameToId: l } = this._parseNameBytes(e.subarray(t + 28, t + 28 + x));
|
|
127
|
+
return {
|
|
128
|
+
refIdToName: d,
|
|
129
|
+
refNameToId: l,
|
|
130
|
+
skipLines: f,
|
|
131
|
+
metaChar: m,
|
|
132
|
+
columnNumbers: s,
|
|
133
|
+
format: r,
|
|
134
|
+
coordinateType: o
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
async _parse(e = {}) {
|
|
138
|
+
const t = await E(await this.filehandle.readFile(e)), n = new DataView(t.buffer);
|
|
139
|
+
let i;
|
|
140
|
+
if (n.getUint32(0, !0) === te)
|
|
141
|
+
i = 1;
|
|
142
|
+
else if (n.getUint32(0, !0) === ne)
|
|
143
|
+
i = 2;
|
|
144
|
+
else
|
|
145
|
+
throw new Error("Not a CSI file");
|
|
146
|
+
this.minShift = n.getInt32(4, !0), this.depth = n.getInt32(8, !0), this.maxBinNumber = ((1 << (this.depth + 1) * 3) - 1) / 7;
|
|
147
|
+
const o = 2 ** (this.minShift + this.depth * 3), r = n.getInt32(12, !0), s = r && r >= 30 ? this.parseAuxData(t, 16) : {
|
|
148
|
+
refIdToName: [],
|
|
149
|
+
refNameToId: {},
|
|
150
|
+
metaChar: void 0,
|
|
151
|
+
columnNumbers: { ref: 0, start: 1, end: 2 },
|
|
152
|
+
coordinateType: "zero-based-half-open",
|
|
153
|
+
format: "generic"
|
|
154
|
+
}, c = n.getInt32(16 + r, !0);
|
|
155
|
+
let m, f = 16 + r + 4;
|
|
156
|
+
const x = new Array(c).fill(0).map(() => {
|
|
157
|
+
const d = n.getInt32(f, !0);
|
|
158
|
+
f += 4;
|
|
159
|
+
const l = {};
|
|
160
|
+
let h;
|
|
161
|
+
for (let b = 0; b < d; b += 1) {
|
|
162
|
+
const k = n.getUint32(f, !0);
|
|
163
|
+
if (k > this.maxBinNumber)
|
|
164
|
+
h = this.parsePseudoBin(t, f + 4), f += 48;
|
|
165
|
+
else {
|
|
166
|
+
const w = A(t, f + 4);
|
|
167
|
+
m = this._findFirstData(m, w);
|
|
168
|
+
const p = n.getInt32(f + 12, !0);
|
|
169
|
+
f += 16;
|
|
170
|
+
const I = new Array(p);
|
|
171
|
+
for (let g = 0; g < p; g += 1) {
|
|
172
|
+
const u = A(t, f), S = A(t, f + 8);
|
|
173
|
+
f += 16, I[g] = new L(u, S, k);
|
|
174
|
+
}
|
|
175
|
+
l[k] = I;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return { binIndex: l, stats: h };
|
|
179
|
+
});
|
|
180
|
+
return {
|
|
181
|
+
...s,
|
|
182
|
+
csi: !0,
|
|
183
|
+
refCount: c,
|
|
184
|
+
maxBlockSize: 65536,
|
|
185
|
+
firstDataLine: m,
|
|
186
|
+
csiVersion: i,
|
|
187
|
+
indices: x,
|
|
188
|
+
depth: this.depth,
|
|
189
|
+
maxBinNumber: this.maxBinNumber,
|
|
190
|
+
maxRefLength: o
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
parsePseudoBin(e, t) {
|
|
194
|
+
return {
|
|
195
|
+
lineCount: Q(e, t + 28)
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
async blocksForRange(e, t, n, i = {}) {
|
|
199
|
+
t < 0 && (t = 0);
|
|
200
|
+
const o = await this.parse(i), r = o.refNameToId[e];
|
|
201
|
+
if (r === void 0)
|
|
202
|
+
return [];
|
|
203
|
+
const s = o.indices[r];
|
|
204
|
+
if (!s)
|
|
205
|
+
return [];
|
|
206
|
+
const c = this.reg2bins(t, n), m = [];
|
|
207
|
+
for (const [f, x] of c)
|
|
208
|
+
for (let d = f; d <= x; d++)
|
|
209
|
+
if (s.binIndex[d])
|
|
210
|
+
for (const l of s.binIndex[d])
|
|
211
|
+
m.push(new L(l.minv, l.maxv, d));
|
|
212
|
+
return X(m, new O(0, 0));
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* calculate the list of bins that may overlap with region [beg,end) (zero-based half-open)
|
|
216
|
+
*/
|
|
217
|
+
reg2bins(e, t) {
|
|
218
|
+
e -= 1, e < 1 && (e = 1), t > 2 ** 50 && (t = 2 ** 34), t -= 1;
|
|
219
|
+
let n = 0, i = 0, o = this.minShift + this.depth * 3;
|
|
220
|
+
const r = [];
|
|
221
|
+
for (; n <= this.depth; o -= 3, i += se(1, n * 3), n += 1) {
|
|
222
|
+
const s = i + W(e, o), c = i + W(t, o);
|
|
223
|
+
if (c - s + r.length > this.maxBinNumber)
|
|
224
|
+
throw new 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`);
|
|
225
|
+
r.push([s, c]);
|
|
226
|
+
}
|
|
227
|
+
return r;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
const re = 21578324, G = 14;
|
|
231
|
+
function ae(a, e) {
|
|
232
|
+
return a += 1, e -= 1, [
|
|
233
|
+
[0, 0],
|
|
234
|
+
[1 + (a >> 26), 1 + (e >> 26)],
|
|
235
|
+
[9 + (a >> 23), 9 + (e >> 23)],
|
|
236
|
+
[73 + (a >> 20), 73 + (e >> 20)],
|
|
237
|
+
[585 + (a >> 17), 585 + (e >> 17)],
|
|
238
|
+
[4681 + (a >> 14), 4681 + (e >> 14)]
|
|
239
|
+
];
|
|
240
|
+
}
|
|
241
|
+
class R extends j {
|
|
242
|
+
async lineCount(e, t = {}) {
|
|
243
|
+
var r;
|
|
244
|
+
const n = await this.parse(t), i = n.refNameToId[e];
|
|
245
|
+
return i === void 0 || !n.indices[i] ? -1 : ((r = n.indices[i].stats) == null ? void 0 : r.lineCount) ?? -1;
|
|
246
|
+
}
|
|
247
|
+
// fetch and parse the index
|
|
248
|
+
async _parse(e = {}) {
|
|
249
|
+
const t = await this.filehandle.readFile(e), n = await E(t), i = new DataView(n.buffer);
|
|
250
|
+
if (i.getUint32(0, !0) !== re)
|
|
251
|
+
throw new Error("Not a TBI file");
|
|
252
|
+
const r = i.getUint32(4, !0), s = i.getUint32(8, !0), c = s & 65536 ? "zero-based-half-open" : "1-based-closed", f = {
|
|
253
|
+
0: "generic",
|
|
254
|
+
1: "SAM",
|
|
255
|
+
2: "VCF"
|
|
256
|
+
}[s & 15];
|
|
257
|
+
if (!f)
|
|
258
|
+
throw new Error(`invalid Tabix preset format flags ${s}`);
|
|
259
|
+
const x = {
|
|
260
|
+
ref: i.getInt32(12, !0),
|
|
261
|
+
start: i.getInt32(16, !0),
|
|
262
|
+
end: i.getInt32(20, !0)
|
|
263
|
+
}, d = i.getInt32(24, !0), l = 5, h = ((1 << (l + 1) * 3) - 1) / 7, b = 2 ** (14 + l * 3), k = d ? String.fromCharCode(d) : void 0, w = i.getInt32(28, !0), p = i.getInt32(32, !0), { refNameToId: I, refIdToName: g } = this._parseNameBytes(n.slice(36, 36 + p));
|
|
264
|
+
let u = 36 + p, S;
|
|
265
|
+
return {
|
|
266
|
+
indices: new Array(r).fill(0).map(() => {
|
|
267
|
+
const T = i.getInt32(u, !0);
|
|
268
|
+
u += 4;
|
|
269
|
+
const N = {};
|
|
270
|
+
let _;
|
|
271
|
+
for (let v = 0; v < T; v += 1) {
|
|
272
|
+
const y = i.getUint32(u, !0);
|
|
273
|
+
if (u += 4, y > h + 1)
|
|
274
|
+
throw new Error("tabix index contains too many bins, please use a CSI index");
|
|
275
|
+
if (y === h + 1) {
|
|
276
|
+
const P = i.getInt32(u, !0);
|
|
277
|
+
u += 4, P === 2 && (_ = this.parsePseudoBin(n, u)), u += 16 * P;
|
|
278
|
+
} else {
|
|
279
|
+
const P = i.getInt32(u, !0);
|
|
280
|
+
u += 4;
|
|
281
|
+
const D = new Array(P);
|
|
282
|
+
for (let V = 0; V < P; V += 1) {
|
|
283
|
+
const $ = A(n, u), Y = A(n, u + 8);
|
|
284
|
+
u += 16, S = this._findFirstData(S, $), D[V] = new L($, Y, y);
|
|
285
|
+
}
|
|
286
|
+
N[y] = D;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
const z = i.getInt32(u, !0);
|
|
290
|
+
u += 4;
|
|
291
|
+
const B = new Array(z);
|
|
292
|
+
for (let v = 0; v < z; v += 1)
|
|
293
|
+
B[v] = A(n, u), u += 8, S = this._findFirstData(S, B[v]);
|
|
294
|
+
return {
|
|
295
|
+
binIndex: N,
|
|
296
|
+
linearIndex: B,
|
|
297
|
+
stats: _
|
|
298
|
+
};
|
|
299
|
+
}),
|
|
300
|
+
metaChar: k,
|
|
301
|
+
maxBinNumber: h,
|
|
302
|
+
maxRefLength: b,
|
|
303
|
+
skipLines: w,
|
|
304
|
+
firstDataLine: S,
|
|
305
|
+
columnNumbers: x,
|
|
306
|
+
coordinateType: c,
|
|
307
|
+
format: f,
|
|
308
|
+
refIdToName: g,
|
|
309
|
+
refNameToId: I,
|
|
310
|
+
maxBlockSize: 65536
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
parsePseudoBin(e, t) {
|
|
314
|
+
return {
|
|
315
|
+
lineCount: Q(e, t + 16)
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
async blocksForRange(e, t, n, i = {}) {
|
|
319
|
+
t < 0 && (t = 0);
|
|
320
|
+
const o = await this.parse(i), r = o.refNameToId[e];
|
|
321
|
+
if (r === void 0)
|
|
322
|
+
return [];
|
|
323
|
+
const s = o.indices[r];
|
|
324
|
+
if (!s)
|
|
325
|
+
return [];
|
|
326
|
+
(s.linearIndex.length > 0 ? s.linearIndex[t >> G >= s.linearIndex.length ? s.linearIndex.length - 1 : t >> G] : new O(0, 0)) || console.warn("querying outside of possible tabix range");
|
|
327
|
+
const m = ae(t, n), f = [];
|
|
328
|
+
for (const [b, k] of m)
|
|
329
|
+
for (let w = b; w <= k; w++)
|
|
330
|
+
if (s.binIndex[w])
|
|
331
|
+
for (const p of s.binIndex[w])
|
|
332
|
+
f.push(new L(p.minv, p.maxv, w));
|
|
333
|
+
const x = s.linearIndex.length;
|
|
334
|
+
let d;
|
|
335
|
+
const l = Math.min(t >> 14, x - 1), h = Math.min(n >> 14, x - 1);
|
|
336
|
+
for (let b = l; b <= h; ++b) {
|
|
337
|
+
const k = s.linearIndex[b];
|
|
338
|
+
k && (!d || k.compareTo(d) < 0) && (d = k);
|
|
339
|
+
}
|
|
340
|
+
return X(f, d);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
class he {
|
|
344
|
+
/**
|
|
345
|
+
* @param {object} args
|
|
346
|
+
*
|
|
347
|
+
* @param {string} [args.path]
|
|
348
|
+
*
|
|
349
|
+
* @param {filehandle} [args.filehandle]
|
|
350
|
+
*
|
|
351
|
+
* @param {string} [args.tbiPath]
|
|
352
|
+
*
|
|
353
|
+
* @param {filehandle} [args.tbiFilehandle]
|
|
354
|
+
*
|
|
355
|
+
* @param {string} [args.csiPath]
|
|
356
|
+
*
|
|
357
|
+
* @param {filehandle} [args.csiFilehandle]
|
|
358
|
+
*
|
|
359
|
+
* @param {url} [args.url]
|
|
360
|
+
*
|
|
361
|
+
* @param {csiUrl} [args.csiUrl]
|
|
362
|
+
*
|
|
363
|
+
* @param {tbiUrl} [args.tbiUrl]
|
|
364
|
+
*
|
|
365
|
+
* @param {function} [args.renameRefSeqs] optional function with sig `string
|
|
366
|
+
* => string` to transform reference sequence names for the purpose of
|
|
367
|
+
* indexing and querying. note that the data that is returned is not altered,
|
|
368
|
+
* just the names of the reference sequences that are used for querying.
|
|
369
|
+
*/
|
|
370
|
+
constructor({ path: e, filehandle: t, url: n, tbiPath: i, tbiUrl: o, tbiFilehandle: r, csiPath: s, csiUrl: c, csiFilehandle: m, renameRefSeqs: f, chunkCacheSize: x = 5 * 2 ** 20 }) {
|
|
371
|
+
this.cache = new U({
|
|
372
|
+
maxSize: 1e3
|
|
373
|
+
});
|
|
374
|
+
const d = f ?? ((l) => l);
|
|
375
|
+
if (t)
|
|
376
|
+
this.filehandle = t;
|
|
377
|
+
else if (e)
|
|
378
|
+
this.filehandle = new F(e);
|
|
379
|
+
else if (n)
|
|
380
|
+
this.filehandle = new M(n);
|
|
381
|
+
else
|
|
382
|
+
throw new TypeError("must provide either filehandle or path");
|
|
383
|
+
if (r)
|
|
384
|
+
this.index = new R({
|
|
385
|
+
filehandle: r,
|
|
386
|
+
renameRefSeqs: d
|
|
387
|
+
});
|
|
388
|
+
else if (m)
|
|
389
|
+
this.index = new q({
|
|
390
|
+
filehandle: m,
|
|
391
|
+
renameRefSeqs: d
|
|
392
|
+
});
|
|
393
|
+
else if (i)
|
|
394
|
+
this.index = new R({
|
|
395
|
+
filehandle: new F(i),
|
|
396
|
+
renameRefSeqs: d
|
|
397
|
+
});
|
|
398
|
+
else if (s)
|
|
399
|
+
this.index = new q({
|
|
400
|
+
filehandle: new F(s),
|
|
401
|
+
renameRefSeqs: d
|
|
402
|
+
});
|
|
403
|
+
else if (e)
|
|
404
|
+
this.index = new R({
|
|
405
|
+
filehandle: new F(`${e}.tbi`),
|
|
406
|
+
renameRefSeqs: d
|
|
407
|
+
});
|
|
408
|
+
else if (c)
|
|
409
|
+
this.index = new q({
|
|
410
|
+
filehandle: new M(c)
|
|
411
|
+
});
|
|
412
|
+
else if (o)
|
|
413
|
+
this.index = new R({
|
|
414
|
+
filehandle: new M(o)
|
|
415
|
+
});
|
|
416
|
+
else if (n)
|
|
417
|
+
this.index = new R({
|
|
418
|
+
filehandle: new M(`${n}.tbi`)
|
|
419
|
+
});
|
|
420
|
+
else
|
|
421
|
+
throw new TypeError("must provide one of tbiFilehandle, tbiPath, csiFilehandle, csiPath, tbiUrl, csiUrl");
|
|
422
|
+
this.renameRefSeq = d, this.hasCustomRenameRefSeq = f !== void 0, this.chunkCache = new J({
|
|
423
|
+
cache: new U({ maxSize: Math.floor(x / 65536) }),
|
|
424
|
+
fill: (l, h) => this.readChunk(l, { signal: h })
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* @param refName name of the reference sequence
|
|
429
|
+
*
|
|
430
|
+
* @param start start of the region (in 0-based half-open coordinates)
|
|
431
|
+
*
|
|
432
|
+
* @param end end of the region (in 0-based half-open coordinates)
|
|
433
|
+
*
|
|
434
|
+
* @param opts callback called for each line in the region. can also pass a
|
|
435
|
+
* object param containing obj.lineCallback, obj.signal, etc
|
|
436
|
+
*
|
|
437
|
+
* @returns promise that is resolved when the whole read is finished,
|
|
438
|
+
* rejected on error
|
|
439
|
+
*/
|
|
440
|
+
calculateFileOffset(e, t, n, i, o) {
|
|
441
|
+
return e[n] * 256 + (i - t[n]) + o + 1;
|
|
442
|
+
}
|
|
443
|
+
async getLines(e, t, n, i) {
|
|
444
|
+
var I;
|
|
445
|
+
let o, r = {}, s;
|
|
446
|
+
typeof i == "function" ? s = i : (r = i, s = i.lineCallback, o = i.signal);
|
|
447
|
+
const c = await this.index.getMetadata(r), m = t ?? 0, f = n ?? c.maxRefLength;
|
|
448
|
+
if (!(m <= f))
|
|
449
|
+
throw new TypeError("invalid start and end coordinates. start must be less than or equal to end");
|
|
450
|
+
if (m === f)
|
|
451
|
+
return;
|
|
452
|
+
const x = await this.index.blocksForRange(e, m, f, r), d = new TextDecoder("utf8"), l = c.format === "VCF", h = {
|
|
453
|
+
ref: c.columnNumbers.ref || 0,
|
|
454
|
+
start: c.columnNumbers.start || 0,
|
|
455
|
+
end: l ? 8 : c.columnNumbers.end || 0
|
|
456
|
+
}, b = Math.max(h.ref, h.start, h.end), k = (I = c.metaChar) == null ? void 0 : I.charCodeAt(0), w = c.coordinateType === "1-based-closed" ? -1 : 0, p = !this.hasCustomRenameRefSeq;
|
|
457
|
+
for (const g of x) {
|
|
458
|
+
const { buffer: u, cpositions: S, dpositions: C } = await this.chunkCache.get(g.toString(), g, o);
|
|
459
|
+
let T = 0, N = 0;
|
|
460
|
+
const _ = d.decode(u);
|
|
461
|
+
if (u.length == _.length)
|
|
462
|
+
for (; T < _.length; ) {
|
|
463
|
+
const B = _.indexOf(`
|
|
464
|
+
`, T);
|
|
465
|
+
if (B === -1)
|
|
466
|
+
break;
|
|
467
|
+
const v = _.slice(T, B);
|
|
468
|
+
if (C) {
|
|
469
|
+
const P = T + g.minv.dataPosition;
|
|
470
|
+
for (; N < C.length && P >= C[N]; )
|
|
471
|
+
N++;
|
|
472
|
+
}
|
|
473
|
+
const y = this.checkLine(e, m, f, v, h.ref, h.start, h.end, b, k, w, l, p);
|
|
474
|
+
if (y === null)
|
|
475
|
+
return;
|
|
476
|
+
y !== void 0 && s(v, this.calculateFileOffset(S, C, N, T, g.minv.dataPosition), y.start, y.end), T = B + 1;
|
|
477
|
+
}
|
|
478
|
+
else
|
|
479
|
+
for (; T < u.length; ) {
|
|
480
|
+
const B = u.indexOf(10, T);
|
|
481
|
+
if (B === -1)
|
|
482
|
+
break;
|
|
483
|
+
const v = u.slice(T, B), y = d.decode(v);
|
|
484
|
+
if (C) {
|
|
485
|
+
const D = T + g.minv.dataPosition;
|
|
486
|
+
for (; N < C.length && D >= C[N]; )
|
|
487
|
+
N++;
|
|
488
|
+
}
|
|
489
|
+
const P = this.checkLine(e, m, f, y, h.ref, h.start, h.end, b, k, w, l, p);
|
|
490
|
+
if (P === null)
|
|
491
|
+
return;
|
|
492
|
+
P !== void 0 && s(y, this.calculateFileOffset(S, C, N, T, g.minv.dataPosition), P.start, P.end), T = B + 1;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
async getMetadata(e = {}) {
|
|
497
|
+
return this.index.getMetadata(e);
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* get a buffer containing the "header" region of the file, which are the
|
|
501
|
+
* bytes up to the first non-meta line
|
|
502
|
+
*/
|
|
503
|
+
async getHeaderBuffer(e = {}) {
|
|
504
|
+
const { firstDataLine: t, metaChar: n, maxBlockSize: i } = await this.getMetadata(e), o = ((t == null ? void 0 : t.blockPosition) || 0) + i, r = await this.filehandle.read(o, 0, e), s = await E(r);
|
|
505
|
+
if (n) {
|
|
506
|
+
let c = -1;
|
|
507
|
+
const m = 10, f = n.charCodeAt(0);
|
|
508
|
+
for (let x = 0, d = s.length; x < d; x++) {
|
|
509
|
+
const l = s[x];
|
|
510
|
+
if (x === c + 1 && l !== f)
|
|
511
|
+
break;
|
|
512
|
+
l === m && (c = x);
|
|
513
|
+
}
|
|
514
|
+
return s.subarray(0, c + 1);
|
|
515
|
+
}
|
|
516
|
+
return s;
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* get a string containing the "header" region of the file, is the portion up
|
|
520
|
+
* to the first non-meta line
|
|
521
|
+
*/
|
|
522
|
+
async getHeader(e = {}) {
|
|
523
|
+
const t = new TextDecoder("utf8"), n = await this.getHeaderBuffer(e);
|
|
524
|
+
return t.decode(n);
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* get an array of reference sequence names, in the order in which they occur
|
|
528
|
+
* in the file. reference sequence renaming is not applied to these names.
|
|
529
|
+
*/
|
|
530
|
+
async getReferenceSequenceNames(e = {}) {
|
|
531
|
+
return (await this.getMetadata(e)).refIdToName;
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* @param {string} regionRefName
|
|
535
|
+
*
|
|
536
|
+
* @param {number} regionStart region start coordinate (0-based-half-open)
|
|
537
|
+
*
|
|
538
|
+
* @param {number} regionEnd region end coordinate (0-based-half-open)
|
|
539
|
+
*
|
|
540
|
+
* @param {string} line
|
|
541
|
+
*
|
|
542
|
+
* @param {number} refColumn column number for ref
|
|
543
|
+
*
|
|
544
|
+
* @param {number} startColumn column number for start
|
|
545
|
+
*
|
|
546
|
+
* @param {number} endColumn column number for end
|
|
547
|
+
*
|
|
548
|
+
* @param {number} maxColumn pre-calculated max column
|
|
549
|
+
*
|
|
550
|
+
* @param {number} metaCharCode pre-calculated metaChar code
|
|
551
|
+
*
|
|
552
|
+
* @param {number} coordinateOffset 0 or -1 for coordinate adjustment
|
|
553
|
+
*
|
|
554
|
+
* @param {boolean} isVCF whether this is VCF format
|
|
555
|
+
*
|
|
556
|
+
* @param {boolean} isIdentityRename whether renameRefSeq is the identity function
|
|
557
|
+
*
|
|
558
|
+
* @returns {{ start: number, end: number } | null | undefined} coordinates if overlapping, null if should stop processing, undefined otherwise
|
|
559
|
+
*/
|
|
560
|
+
checkLine(e, t, n, i, o, r, s, c, m, f, x, d) {
|
|
561
|
+
if (m !== void 0 && i.charCodeAt(0) === m)
|
|
562
|
+
return;
|
|
563
|
+
if (i.length < 500) {
|
|
564
|
+
const I = i.split(" "), g = I[o - 1];
|
|
565
|
+
if (!(d ? g === e : this.renameRefSeq(g) === e))
|
|
566
|
+
return;
|
|
567
|
+
const S = +I[r - 1] + f;
|
|
568
|
+
if (S >= n)
|
|
569
|
+
return null;
|
|
570
|
+
let C;
|
|
571
|
+
return s === 0 || s === r ? C = S + 1 : x ? C = this._getVcfEnd(S, I[3], I[s - 1]) : C = +I[s - 1], C <= t ? void 0 : { start: S, end: C };
|
|
572
|
+
}
|
|
573
|
+
let l = -1;
|
|
574
|
+
const h = [-1];
|
|
575
|
+
for (let I = 0; I < c; I++) {
|
|
576
|
+
const g = i.indexOf(" ", l + 1);
|
|
577
|
+
if (g === -1) {
|
|
578
|
+
h.push(i.length);
|
|
579
|
+
break;
|
|
580
|
+
}
|
|
581
|
+
h.push(g), l = g;
|
|
582
|
+
}
|
|
583
|
+
const b = i.slice(h[o - 1] + 1, h[o]);
|
|
584
|
+
if (!(d ? b === e : this.renameRefSeq(b) === e))
|
|
585
|
+
return;
|
|
586
|
+
const w = +i.slice(h[r - 1] + 1, h[r]) + f;
|
|
587
|
+
if (w >= n)
|
|
588
|
+
return null;
|
|
589
|
+
let p;
|
|
590
|
+
if (s === 0 || s === r ? p = w + 1 : x ? p = this._getVcfEnd(w, i.slice(h[3] + 1, h[4]), i.slice(h[s - 1] + 1, h[s])) : p = +i.slice(h[s - 1] + 1, h[s]), !(p <= t))
|
|
591
|
+
return { start: w, end: p };
|
|
592
|
+
}
|
|
593
|
+
_getVcfEnd(e, t, n) {
|
|
594
|
+
let i = e + t.length;
|
|
595
|
+
if (n.includes("SVTYPE=TRA"))
|
|
596
|
+
return e + 1;
|
|
597
|
+
if (n[0] !== ".") {
|
|
598
|
+
const r = n.indexOf("END=");
|
|
599
|
+
if (r !== -1 && (r === 0 || n[r - 1] === ";")) {
|
|
600
|
+
const s = r + 4;
|
|
601
|
+
let c = n.indexOf(";", s);
|
|
602
|
+
c === -1 && (c = n.length), i = Number.parseInt(n.slice(s, c), 10);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
return i;
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* return the approximate number of data lines in the given reference
|
|
609
|
+
* sequence
|
|
610
|
+
*
|
|
611
|
+
* @param refSeq reference sequence name
|
|
612
|
+
*
|
|
613
|
+
* @returns number of data lines present on that reference sequence
|
|
614
|
+
*/
|
|
615
|
+
async lineCount(e, t = {}) {
|
|
616
|
+
return this.index.lineCount(e, t);
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* read and uncompress the data in a chunk (composed of one or more
|
|
620
|
+
* contiguous bgzip blocks) of the file
|
|
621
|
+
*/
|
|
622
|
+
async readChunk(e, t = {}) {
|
|
623
|
+
const n = await this.filehandle.read(e.fetchedSize(), e.minv.blockPosition, t);
|
|
624
|
+
return K(n, e, this.cache);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
export {
|
|
628
|
+
q as CSI,
|
|
629
|
+
R as TBI,
|
|
630
|
+
he as TabixIndexedFile
|
|
631
|
+
};
|