@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
|
@@ -1,651 +0,0 @@
|
|
|
1
|
-
import { A as J, L as K } from "./index-CCJIjehY.js";
|
|
2
|
-
import { b as Q } from "./index-BftNdA0O.js";
|
|
3
|
-
import { L as R } from "./__vite-browser-external-C--ziKoh.js";
|
|
4
|
-
import { R as F } from "./remoteFile-BuaqFGWk.js";
|
|
5
|
-
import { u as $, L as H, a as Z } from "./long-B-FASCSo.js";
|
|
6
|
-
function j(o) {
|
|
7
|
-
if (o.greaterThan(Number.MAX_SAFE_INTEGER) || o.lessThan(Number.MIN_SAFE_INTEGER))
|
|
8
|
-
throw new Error("integer overflow");
|
|
9
|
-
return o.toNumber();
|
|
10
|
-
}
|
|
11
|
-
class ee extends Error {
|
|
12
|
-
}
|
|
13
|
-
function _(o) {
|
|
14
|
-
if (o && o.aborted) {
|
|
15
|
-
if (typeof DOMException < "u")
|
|
16
|
-
throw new DOMException("aborted", "AbortError");
|
|
17
|
-
{
|
|
18
|
-
const e = new ee("aborted");
|
|
19
|
-
throw e.code = "ERR_ABORTED", e;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function te(o, e) {
|
|
24
|
-
return e.minv.blockPosition - o.maxv.blockPosition < 65e3 && e.maxv.blockPosition - o.minv.blockPosition < 5e6;
|
|
25
|
-
}
|
|
26
|
-
function X(o, e) {
|
|
27
|
-
const t = [];
|
|
28
|
-
let n = null;
|
|
29
|
-
return o.length === 0 ? o : (o.sort(function(i, s) {
|
|
30
|
-
const a = i.minv.blockPosition - s.minv.blockPosition;
|
|
31
|
-
return a !== 0 ? a : i.minv.dataPosition - s.minv.dataPosition;
|
|
32
|
-
}), o.forEach((i) => {
|
|
33
|
-
(!e || i.maxv.compareTo(e) > 0) && (n === null ? (t.push(i), n = i) : te(n, i) ? i.maxv.compareTo(n.maxv) > 0 && (n.maxv = i.maxv) : (t.push(i), n = i));
|
|
34
|
-
}), t);
|
|
35
|
-
}
|
|
36
|
-
class V {
|
|
37
|
-
constructor(e, t) {
|
|
38
|
-
this.blockPosition = e, this.dataPosition = t;
|
|
39
|
-
}
|
|
40
|
-
toString() {
|
|
41
|
-
return `${this.blockPosition}:${this.dataPosition}`;
|
|
42
|
-
}
|
|
43
|
-
compareTo(e) {
|
|
44
|
-
return this.blockPosition - e.blockPosition || this.dataPosition - e.dataPosition;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function T(o, e = 0, t = !1) {
|
|
48
|
-
if (t)
|
|
49
|
-
throw new Error("big-endian virtual file offsets not implemented");
|
|
50
|
-
return new V(o[e + 7] * 1099511627776 + o[e + 6] * 4294967296 + o[e + 5] * 16777216 + o[e + 4] * 65536 + o[e + 3] * 256 + o[e + 2], o[e + 1] << 8 | o[e]);
|
|
51
|
-
}
|
|
52
|
-
class D {
|
|
53
|
-
constructor(e, t, n, i = void 0) {
|
|
54
|
-
this.minv = e, this.maxv = t, this.bin = n, this._fetchedSize = i;
|
|
55
|
-
}
|
|
56
|
-
toUniqueString() {
|
|
57
|
-
return `${this.minv}..${this.maxv} (bin ${this.bin}, fetchedSize ${this.fetchedSize()})`;
|
|
58
|
-
}
|
|
59
|
-
toString() {
|
|
60
|
-
return this.toUniqueString();
|
|
61
|
-
}
|
|
62
|
-
compareTo(e) {
|
|
63
|
-
return this.minv.compareTo(e.minv) || this.maxv.compareTo(e.maxv) || this.bin - e.bin;
|
|
64
|
-
}
|
|
65
|
-
fetchedSize() {
|
|
66
|
-
return this._fetchedSize !== void 0 ? this._fetchedSize : this.maxv.blockPosition + 65536 - this.minv.blockPosition;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
class W {
|
|
70
|
-
constructor({ filehandle: e, renameRefSeqs: t = (n) => n }) {
|
|
71
|
-
this.filehandle = e, this.renameRefSeq = t;
|
|
72
|
-
}
|
|
73
|
-
async getMetadata(e = {}) {
|
|
74
|
-
const { indices: t, ...n } = await this.parse(e);
|
|
75
|
-
return n;
|
|
76
|
-
}
|
|
77
|
-
_findFirstData(e, t) {
|
|
78
|
-
return e ? e.compareTo(t) > 0 ? t : e : t;
|
|
79
|
-
}
|
|
80
|
-
async parse(e = {}) {
|
|
81
|
-
return this.parseP || (this.parseP = this._parse(e).catch((t) => {
|
|
82
|
-
throw this.parseP = void 0, t;
|
|
83
|
-
})), this.parseP;
|
|
84
|
-
}
|
|
85
|
-
async hasRefSeq(e, t = {}) {
|
|
86
|
-
var n;
|
|
87
|
-
return !!(!((n = (await this.parse(t)).indices[e]) === null || n === void 0) && n.binIndex);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
const ne = 21578324, U = 14;
|
|
91
|
-
function ie(o, e) {
|
|
92
|
-
return o += 1, e -= 1, [
|
|
93
|
-
[0, 0],
|
|
94
|
-
[1 + (o >> 26), 1 + (e >> 26)],
|
|
95
|
-
[9 + (o >> 23), 9 + (e >> 23)],
|
|
96
|
-
[73 + (o >> 20), 73 + (e >> 20)],
|
|
97
|
-
[585 + (o >> 17), 585 + (e >> 17)],
|
|
98
|
-
[4681 + (o >> 14), 4681 + (e >> 14)]
|
|
99
|
-
];
|
|
100
|
-
}
|
|
101
|
-
class y extends W {
|
|
102
|
-
async lineCount(e, t = {}) {
|
|
103
|
-
const n = await this.parse(t), i = n.refNameToId[e];
|
|
104
|
-
if (i === void 0 || !n.indices[i])
|
|
105
|
-
return -1;
|
|
106
|
-
const { stats: a } = n.indices[i];
|
|
107
|
-
return a ? a.lineCount : -1;
|
|
108
|
-
}
|
|
109
|
-
// fetch and parse the index
|
|
110
|
-
async _parse(e = {}) {
|
|
111
|
-
const t = await this.filehandle.readFile(e), n = await $(t);
|
|
112
|
-
if (_(e.signal), n.readUInt32LE(0) !== ne)
|
|
113
|
-
throw new Error("Not a TBI file");
|
|
114
|
-
const i = n.readInt32LE(4), s = n.readInt32LE(8), a = s & 65536 ? "zero-based-half-open" : "1-based-closed", f = {
|
|
115
|
-
0: "generic",
|
|
116
|
-
1: "SAM",
|
|
117
|
-
2: "VCF"
|
|
118
|
-
}[s & 15];
|
|
119
|
-
if (!f)
|
|
120
|
-
throw new Error(`invalid Tabix preset format flags ${s}`);
|
|
121
|
-
const d = {
|
|
122
|
-
ref: n.readInt32LE(12),
|
|
123
|
-
start: n.readInt32LE(16),
|
|
124
|
-
end: n.readInt32LE(20)
|
|
125
|
-
}, u = n.readInt32LE(24), h = 5, c = ((1 << (h + 1) * 3) - 1) / 7, b = 2 ** (14 + h * 3), I = u ? String.fromCharCode(u) : null, m = n.readInt32LE(28), w = n.readInt32LE(32), { refNameToId: x, refIdToName: p } = this._parseNameBytes(n.slice(36, 36 + w));
|
|
126
|
-
let l = 36 + w, g;
|
|
127
|
-
return {
|
|
128
|
-
indices: new Array(i).fill(0).map(() => {
|
|
129
|
-
const E = n.readInt32LE(l);
|
|
130
|
-
l += 4;
|
|
131
|
-
const v = {};
|
|
132
|
-
let N;
|
|
133
|
-
for (let C = 0; C < E; C += 1) {
|
|
134
|
-
const A = n.readUInt32LE(l);
|
|
135
|
-
if (l += 4, A > c + 1)
|
|
136
|
-
throw new Error("tabix index contains too many bins, please use a CSI index");
|
|
137
|
-
if (A === c + 1) {
|
|
138
|
-
const k = n.readInt32LE(l);
|
|
139
|
-
l += 4, k === 2 && (N = this.parsePseudoBin(n, l)), l += 16 * k;
|
|
140
|
-
} else {
|
|
141
|
-
const k = n.readInt32LE(l);
|
|
142
|
-
l += 4;
|
|
143
|
-
const O = new Array(k);
|
|
144
|
-
for (let M = 0; M < k; M += 1) {
|
|
145
|
-
const q = T(n, l), Y = T(n, l + 8);
|
|
146
|
-
l += 16, g = this._findFirstData(g, q), O[M] = new D(q, Y, A);
|
|
147
|
-
}
|
|
148
|
-
v[A] = O;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
const B = n.readInt32LE(l);
|
|
152
|
-
l += 4;
|
|
153
|
-
const L = new Array(B);
|
|
154
|
-
for (let C = 0; C < B; C += 1)
|
|
155
|
-
L[C] = T(n, l), l += 8, g = this._findFirstData(g, L[C]);
|
|
156
|
-
return { binIndex: v, linearIndex: L, stats: N };
|
|
157
|
-
}),
|
|
158
|
-
metaChar: I,
|
|
159
|
-
maxBinNumber: c,
|
|
160
|
-
maxRefLength: b,
|
|
161
|
-
skipLines: m,
|
|
162
|
-
firstDataLine: g,
|
|
163
|
-
columnNumbers: d,
|
|
164
|
-
coordinateType: a,
|
|
165
|
-
format: f,
|
|
166
|
-
refIdToName: p,
|
|
167
|
-
refNameToId: x,
|
|
168
|
-
maxBlockSize: 65536
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
parsePseudoBin(e, t) {
|
|
172
|
-
return { lineCount: j(H.fromBytesLE(e.slice(t + 16, t + 24), !0)) };
|
|
173
|
-
}
|
|
174
|
-
_parseNameBytes(e) {
|
|
175
|
-
let t = 0, n = 0;
|
|
176
|
-
const i = [], s = {};
|
|
177
|
-
for (let a = 0; a < e.length; a += 1)
|
|
178
|
-
if (!e[a]) {
|
|
179
|
-
if (n < a) {
|
|
180
|
-
let r = e.toString("utf8", n, a);
|
|
181
|
-
r = this.renameRefSeq(r), i[t] = r, s[r] = t;
|
|
182
|
-
}
|
|
183
|
-
n = a + 1, t += 1;
|
|
184
|
-
}
|
|
185
|
-
return { refNameToId: s, refIdToName: i };
|
|
186
|
-
}
|
|
187
|
-
async blocksForRange(e, t, n, i = {}) {
|
|
188
|
-
t < 0 && (t = 0);
|
|
189
|
-
const s = await this.parse(i), a = s.refNameToId[e];
|
|
190
|
-
if (a === void 0)
|
|
191
|
-
return [];
|
|
192
|
-
const r = s.indices[a];
|
|
193
|
-
if (!r)
|
|
194
|
-
return [];
|
|
195
|
-
(r.linearIndex.length ? r.linearIndex[t >> U >= r.linearIndex.length ? r.linearIndex.length - 1 : t >> U] : new V(0, 0)) || console.warn("querying outside of possible tabix range");
|
|
196
|
-
const d = ie(t, n), u = [];
|
|
197
|
-
for (const [m, w] of d)
|
|
198
|
-
for (let x = m; x <= w; x++)
|
|
199
|
-
if (r.binIndex[x])
|
|
200
|
-
for (const p of r.binIndex[x])
|
|
201
|
-
u.push(new D(p.minv, p.maxv, x));
|
|
202
|
-
const h = r.linearIndex.length;
|
|
203
|
-
let c = null;
|
|
204
|
-
const b = Math.min(t >> 14, h - 1), I = Math.min(n >> 14, h - 1);
|
|
205
|
-
for (let m = b; m <= I; ++m) {
|
|
206
|
-
const w = r.linearIndex[m];
|
|
207
|
-
w && (!c || w.compareTo(c) < 0) && (c = w);
|
|
208
|
-
}
|
|
209
|
-
return X(u, c);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
const re = 21582659, se = 38359875;
|
|
213
|
-
function ae(o, e) {
|
|
214
|
-
return o * 2 ** e;
|
|
215
|
-
}
|
|
216
|
-
function G(o, e) {
|
|
217
|
-
return Math.floor(o / 2 ** e);
|
|
218
|
-
}
|
|
219
|
-
class z extends W {
|
|
220
|
-
constructor(e) {
|
|
221
|
-
super(e), this.maxBinNumber = 0, this.depth = 0, this.minShift = 0;
|
|
222
|
-
}
|
|
223
|
-
async lineCount(e, t = {}) {
|
|
224
|
-
const n = await this.parse(t), i = n.refNameToId[e];
|
|
225
|
-
if (i === void 0 || !n.indices[i])
|
|
226
|
-
return -1;
|
|
227
|
-
const { stats: a } = n.indices[i];
|
|
228
|
-
return a ? a.lineCount : -1;
|
|
229
|
-
}
|
|
230
|
-
indexCov() {
|
|
231
|
-
throw new Error("CSI indexes do not support indexcov");
|
|
232
|
-
}
|
|
233
|
-
parseAuxData(e, t) {
|
|
234
|
-
const n = e.readInt32LE(t), i = n & 65536 ? "zero-based-half-open" : "1-based-closed", s = { 0: "generic", 1: "SAM", 2: "VCF" }[n & 15];
|
|
235
|
-
if (!s)
|
|
236
|
-
throw new Error(`invalid Tabix preset format flags ${n}`);
|
|
237
|
-
const a = {
|
|
238
|
-
ref: e.readInt32LE(t + 4),
|
|
239
|
-
start: e.readInt32LE(t + 8),
|
|
240
|
-
end: e.readInt32LE(t + 12)
|
|
241
|
-
}, r = e.readInt32LE(t + 16), f = r ? String.fromCharCode(r) : null, d = e.readInt32LE(t + 20), u = e.readInt32LE(t + 24), { refIdToName: h, refNameToId: c } = this._parseNameBytes(e.slice(t + 28, t + 28 + u));
|
|
242
|
-
return {
|
|
243
|
-
refIdToName: h,
|
|
244
|
-
refNameToId: c,
|
|
245
|
-
skipLines: d,
|
|
246
|
-
metaChar: f,
|
|
247
|
-
columnNumbers: a,
|
|
248
|
-
format: s,
|
|
249
|
-
coordinateType: i
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
_parseNameBytes(e) {
|
|
253
|
-
let t = 0, n = 0;
|
|
254
|
-
const i = [], s = {};
|
|
255
|
-
for (let a = 0; a < e.length; a += 1)
|
|
256
|
-
if (!e[a]) {
|
|
257
|
-
if (n < a) {
|
|
258
|
-
let r = e.toString("utf8", n, a);
|
|
259
|
-
r = this.renameRefSeq(r), i[t] = r, s[r] = t;
|
|
260
|
-
}
|
|
261
|
-
n = a + 1, t += 1;
|
|
262
|
-
}
|
|
263
|
-
return { refNameToId: s, refIdToName: i };
|
|
264
|
-
}
|
|
265
|
-
// fetch and parse the index
|
|
266
|
-
async _parse(e = {}) {
|
|
267
|
-
const t = await $(await this.filehandle.readFile(e));
|
|
268
|
-
let n;
|
|
269
|
-
if (t.readUInt32LE(0) === re)
|
|
270
|
-
n = 1;
|
|
271
|
-
else if (t.readUInt32LE(0) === se)
|
|
272
|
-
n = 2;
|
|
273
|
-
else
|
|
274
|
-
throw new Error("Not a CSI file");
|
|
275
|
-
this.minShift = t.readInt32LE(4), this.depth = t.readInt32LE(8), this.maxBinNumber = ((1 << (this.depth + 1) * 3) - 1) / 7;
|
|
276
|
-
const i = 2 ** (this.minShift + this.depth * 3), s = t.readInt32LE(12), a = s && s >= 30 ? this.parseAuxData(t, 16) : {
|
|
277
|
-
refIdToName: [],
|
|
278
|
-
refNameToId: {},
|
|
279
|
-
metaChar: null,
|
|
280
|
-
columnNumbers: { ref: 0, start: 1, end: 2 },
|
|
281
|
-
coordinateType: "zero-based-half-open",
|
|
282
|
-
format: "generic"
|
|
283
|
-
}, r = t.readInt32LE(16 + s);
|
|
284
|
-
let f, d = 16 + s + 4;
|
|
285
|
-
const u = new Array(r).fill(0).map(() => {
|
|
286
|
-
const h = t.readInt32LE(d);
|
|
287
|
-
d += 4;
|
|
288
|
-
const c = {};
|
|
289
|
-
let b;
|
|
290
|
-
for (let I = 0; I < h; I += 1) {
|
|
291
|
-
const m = t.readUInt32LE(d);
|
|
292
|
-
if (m > this.maxBinNumber)
|
|
293
|
-
b = this.parsePseudoBin(t, d + 4), d += 48;
|
|
294
|
-
else {
|
|
295
|
-
const w = T(t, d + 4);
|
|
296
|
-
f = this._findFirstData(f, w);
|
|
297
|
-
const x = t.readInt32LE(d + 12);
|
|
298
|
-
d += 16;
|
|
299
|
-
const p = new Array(x);
|
|
300
|
-
for (let l = 0; l < x; l += 1) {
|
|
301
|
-
const g = T(t, d), P = T(t, d + 8);
|
|
302
|
-
d += 16, p[l] = new D(g, P, m);
|
|
303
|
-
}
|
|
304
|
-
c[m] = p;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
return { binIndex: c, stats: b };
|
|
308
|
-
});
|
|
309
|
-
return {
|
|
310
|
-
...a,
|
|
311
|
-
csi: !0,
|
|
312
|
-
refCount: r,
|
|
313
|
-
maxBlockSize: 65536,
|
|
314
|
-
firstDataLine: f,
|
|
315
|
-
csiVersion: n,
|
|
316
|
-
indices: u,
|
|
317
|
-
depth: this.depth,
|
|
318
|
-
maxBinNumber: this.maxBinNumber,
|
|
319
|
-
maxRefLength: i
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
parsePseudoBin(e, t) {
|
|
323
|
-
return { lineCount: j(H.fromBytesLE(e.slice(t + 28, t + 36), !0)) };
|
|
324
|
-
}
|
|
325
|
-
async blocksForRange(e, t, n, i = {}) {
|
|
326
|
-
t < 0 && (t = 0);
|
|
327
|
-
const s = await this.parse(i), a = s.refNameToId[e];
|
|
328
|
-
if (a === void 0)
|
|
329
|
-
return [];
|
|
330
|
-
const r = s.indices[a];
|
|
331
|
-
if (!r)
|
|
332
|
-
return [];
|
|
333
|
-
const f = this.reg2bins(t, n), d = [];
|
|
334
|
-
for (const [u, h] of f)
|
|
335
|
-
for (let c = u; c <= h; c++)
|
|
336
|
-
if (r.binIndex[c])
|
|
337
|
-
for (const b of r.binIndex[c])
|
|
338
|
-
d.push(new D(b.minv, b.maxv, c));
|
|
339
|
-
return X(d, new V(0, 0));
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* calculate the list of bins that may overlap with region [beg,end) (zero-based half-open)
|
|
343
|
-
*/
|
|
344
|
-
reg2bins(e, t) {
|
|
345
|
-
e -= 1, e < 1 && (e = 1), t > 2 ** 50 && (t = 2 ** 34), t -= 1;
|
|
346
|
-
let n = 0, i = 0, s = this.minShift + this.depth * 3;
|
|
347
|
-
const a = [];
|
|
348
|
-
for (; n <= this.depth; s -= 3, i += ae(1, n * 3), n += 1) {
|
|
349
|
-
const r = i + G(e, s), f = i + G(t, s);
|
|
350
|
-
if (f - r + a.length > this.maxBinNumber)
|
|
351
|
-
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`);
|
|
352
|
-
a.push([r, f]);
|
|
353
|
-
}
|
|
354
|
-
return a;
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
function oe(o) {
|
|
358
|
-
return /^[\u0000-\u007F]*$/.test(o);
|
|
359
|
-
}
|
|
360
|
-
const S = typeof TextDecoder < "u" ? new TextDecoder("utf8") : void 0;
|
|
361
|
-
class ue {
|
|
362
|
-
/**
|
|
363
|
-
* @param {object} args
|
|
364
|
-
*
|
|
365
|
-
* @param {string} [args.path]
|
|
366
|
-
*
|
|
367
|
-
* @param {filehandle} [args.filehandle]
|
|
368
|
-
*
|
|
369
|
-
* @param {string} [args.tbiPath]
|
|
370
|
-
*
|
|
371
|
-
* @param {filehandle} [args.tbiFilehandle]
|
|
372
|
-
*
|
|
373
|
-
* @param {string} [args.csiPath]
|
|
374
|
-
*
|
|
375
|
-
* @param {filehandle} [args.csiFilehandle]
|
|
376
|
-
*
|
|
377
|
-
* @param {url} [args.url]
|
|
378
|
-
*
|
|
379
|
-
* @param {csiUrl} [args.csiUrl]
|
|
380
|
-
*
|
|
381
|
-
* @param {tbiUrl} [args.tbiUrl]
|
|
382
|
-
*
|
|
383
|
-
* @param {function} [args.renameRefSeqs] optional function with sig `string
|
|
384
|
-
* => string` to transform reference sequence names for the purpose of
|
|
385
|
-
* indexing and querying. note that the data that is returned is not altered,
|
|
386
|
-
* just the names of the reference sequences that are used for querying.
|
|
387
|
-
*/
|
|
388
|
-
constructor({ path: e, filehandle: t, url: n, tbiPath: i, tbiUrl: s, tbiFilehandle: a, csiPath: r, csiUrl: f, csiFilehandle: d, renameRefSeqs: u = (c) => c, chunkCacheSize: h = 5 * 2 ** 20 }) {
|
|
389
|
-
if (t)
|
|
390
|
-
this.filehandle = t;
|
|
391
|
-
else if (e)
|
|
392
|
-
this.filehandle = new R(e);
|
|
393
|
-
else if (n)
|
|
394
|
-
this.filehandle = new F(n);
|
|
395
|
-
else
|
|
396
|
-
throw new TypeError("must provide either filehandle or path");
|
|
397
|
-
if (a)
|
|
398
|
-
this.index = new y({
|
|
399
|
-
filehandle: a,
|
|
400
|
-
renameRefSeqs: u
|
|
401
|
-
});
|
|
402
|
-
else if (d)
|
|
403
|
-
this.index = new z({
|
|
404
|
-
filehandle: d,
|
|
405
|
-
renameRefSeqs: u
|
|
406
|
-
});
|
|
407
|
-
else if (i)
|
|
408
|
-
this.index = new y({
|
|
409
|
-
filehandle: new R(i),
|
|
410
|
-
renameRefSeqs: u
|
|
411
|
-
});
|
|
412
|
-
else if (r)
|
|
413
|
-
this.index = new z({
|
|
414
|
-
filehandle: new R(r),
|
|
415
|
-
renameRefSeqs: u
|
|
416
|
-
});
|
|
417
|
-
else if (e)
|
|
418
|
-
this.index = new y({
|
|
419
|
-
filehandle: new R(`${e}.tbi`),
|
|
420
|
-
renameRefSeqs: u
|
|
421
|
-
});
|
|
422
|
-
else if (f)
|
|
423
|
-
this.index = new z({
|
|
424
|
-
filehandle: new F(f)
|
|
425
|
-
});
|
|
426
|
-
else if (s)
|
|
427
|
-
this.index = new y({
|
|
428
|
-
filehandle: new F(s)
|
|
429
|
-
});
|
|
430
|
-
else if (n)
|
|
431
|
-
this.index = new y({
|
|
432
|
-
filehandle: new F(`${n}.tbi`)
|
|
433
|
-
});
|
|
434
|
-
else
|
|
435
|
-
throw new TypeError("must provide one of tbiFilehandle, tbiPath, csiFilehandle, csiPath, tbiUrl, csiUrl");
|
|
436
|
-
this.renameRefSeq = u, this.chunkCache = new J({
|
|
437
|
-
cache: new K({ maxSize: Math.floor(h / 65536) }),
|
|
438
|
-
fill: (c, b) => this.readChunk(c, { signal: b })
|
|
439
|
-
});
|
|
440
|
-
}
|
|
441
|
-
/**
|
|
442
|
-
* @param refName name of the reference sequence
|
|
443
|
-
*
|
|
444
|
-
* @param start start of the region (in 0-based half-open coordinates)
|
|
445
|
-
*
|
|
446
|
-
* @param end end of the region (in 0-based half-open coordinates)
|
|
447
|
-
*
|
|
448
|
-
* @param opts callback called for each line in the region. can also pass a
|
|
449
|
-
* object param containing obj.lineCallback, obj.signal, etc
|
|
450
|
-
*
|
|
451
|
-
* @returns promise that is resolved when the whole read is finished,
|
|
452
|
-
* rejected on error
|
|
453
|
-
*/
|
|
454
|
-
async getLines(e, t, n, i) {
|
|
455
|
-
var s, a;
|
|
456
|
-
let r, f = {}, d;
|
|
457
|
-
typeof i == "function" ? d = i : (f = i, d = i.lineCallback, r = i.signal);
|
|
458
|
-
const u = await this.index.getMetadata(f);
|
|
459
|
-
_(r);
|
|
460
|
-
const h = t ?? 0, c = n ?? u.maxRefLength;
|
|
461
|
-
if (!(h <= c))
|
|
462
|
-
throw new TypeError("invalid start and end coordinates. start must be less than or equal to end");
|
|
463
|
-
if (h === c)
|
|
464
|
-
return;
|
|
465
|
-
const b = await this.index.blocksForRange(e, h, c, f);
|
|
466
|
-
_(r);
|
|
467
|
-
for (const I of b) {
|
|
468
|
-
const { buffer: m, cpositions: w, dpositions: x } = await this.chunkCache.get(I.toString(), I, r);
|
|
469
|
-
_(r);
|
|
470
|
-
let p = 0, l = 0;
|
|
471
|
-
const g = (s = S == null ? void 0 : S.decode(m)) !== null && s !== void 0 ? s : m.toString(), P = m.length < 5e8 && oe(g);
|
|
472
|
-
for (; p < g.length; ) {
|
|
473
|
-
let E, v;
|
|
474
|
-
if (P) {
|
|
475
|
-
if (v = g.indexOf(`
|
|
476
|
-
`, p), v === -1)
|
|
477
|
-
break;
|
|
478
|
-
E = g.slice(p, v);
|
|
479
|
-
} else {
|
|
480
|
-
if (v = m.indexOf(`
|
|
481
|
-
`, p), v === -1)
|
|
482
|
-
break;
|
|
483
|
-
const L = m.slice(p, v);
|
|
484
|
-
E = (a = S == null ? void 0 : S.decode(L)) !== null && a !== void 0 ? a : L.toString();
|
|
485
|
-
}
|
|
486
|
-
if (x) {
|
|
487
|
-
for (; p + I.minv.dataPosition >= x[l++]; )
|
|
488
|
-
;
|
|
489
|
-
l--;
|
|
490
|
-
}
|
|
491
|
-
const { startCoordinate: N, overlaps: B } = this.checkLine(u, e, h, c, E);
|
|
492
|
-
if (B)
|
|
493
|
-
d(
|
|
494
|
-
E,
|
|
495
|
-
// cpositions[pos] refers to actual file offset of a bgzip block
|
|
496
|
-
// boundaries
|
|
497
|
-
//
|
|
498
|
-
// we multiply by (1 <<8) in order to make sure each block has a
|
|
499
|
-
// "unique" address space so that data in that block could never
|
|
500
|
-
// overlap
|
|
501
|
-
//
|
|
502
|
-
// then the blockStart-dpositions is an uncompressed file offset
|
|
503
|
-
// from that bgzip block boundary, and since the cpositions are
|
|
504
|
-
// multiplied by (1 << 8) these uncompressed offsets get a unique
|
|
505
|
-
// space
|
|
506
|
-
w[l] * 256 + (p - x[l]) + I.minv.dataPosition + 1
|
|
507
|
-
);
|
|
508
|
-
else if (N !== void 0 && N >= c)
|
|
509
|
-
return;
|
|
510
|
-
p = v + 1;
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
async getMetadata(e = {}) {
|
|
515
|
-
return this.index.getMetadata(e);
|
|
516
|
-
}
|
|
517
|
-
/**
|
|
518
|
-
* get a buffer containing the "header" region of the file, which are the
|
|
519
|
-
* bytes up to the first non-meta line
|
|
520
|
-
*/
|
|
521
|
-
async getHeaderBuffer(e = {}) {
|
|
522
|
-
const { firstDataLine: t, metaChar: n, maxBlockSize: i } = await this.getMetadata(e);
|
|
523
|
-
_(e.signal);
|
|
524
|
-
const s = ((t == null ? void 0 : t.blockPosition) || 0) + i, a = await this._readRegion(0, s, e), r = await $(a);
|
|
525
|
-
if (n) {
|
|
526
|
-
let f = -1;
|
|
527
|
-
const d = 10, u = n.charCodeAt(0);
|
|
528
|
-
for (let h = 0; h < r.length && !(h === f + 1 && r[h] !== u); h += 1)
|
|
529
|
-
r[h] === d && (f = h);
|
|
530
|
-
return r.subarray(0, f + 1);
|
|
531
|
-
}
|
|
532
|
-
return r;
|
|
533
|
-
}
|
|
534
|
-
/**
|
|
535
|
-
* get a string containing the "header" region of the file, is the portion up
|
|
536
|
-
* to the first non-meta line
|
|
537
|
-
*
|
|
538
|
-
* @returns {Promise} for a string
|
|
539
|
-
*/
|
|
540
|
-
async getHeader(e = {}) {
|
|
541
|
-
return (await this.getHeaderBuffer(e)).toString("utf8");
|
|
542
|
-
}
|
|
543
|
-
/**
|
|
544
|
-
* get an array of reference sequence names, in the order in which they occur
|
|
545
|
-
* in the file. reference sequence renaming is not applied to these names.
|
|
546
|
-
*/
|
|
547
|
-
async getReferenceSequenceNames(e = {}) {
|
|
548
|
-
return (await this.getMetadata(e)).refIdToName;
|
|
549
|
-
}
|
|
550
|
-
/**
|
|
551
|
-
* @param {object} metadata metadata object from the parsed index, containing
|
|
552
|
-
* columnNumbers, metaChar, and format
|
|
553
|
-
*
|
|
554
|
-
* @param {string} regionRefName
|
|
555
|
-
*
|
|
556
|
-
* @param {number} regionStart region start coordinate (0-based-half-open)
|
|
557
|
-
*
|
|
558
|
-
* @param {number} regionEnd region end coordinate (0-based-half-open)
|
|
559
|
-
*
|
|
560
|
-
* @param {array[string]} line
|
|
561
|
-
*
|
|
562
|
-
* @returns {object} like `{startCoordinate, overlaps}`. overlaps is boolean,
|
|
563
|
-
* true if line is a data line that overlaps the given region
|
|
564
|
-
*/
|
|
565
|
-
checkLine(e, t, n, i, s) {
|
|
566
|
-
const { columnNumbers: a, metaChar: r, coordinateType: f, format: d } = e;
|
|
567
|
-
if (r && s.startsWith(r))
|
|
568
|
-
return { overlaps: !1 };
|
|
569
|
-
let { ref: u, start: h, end: c } = a;
|
|
570
|
-
u || (u = 0), h || (h = 0), c || (c = 0), d === "VCF" && (c = 8);
|
|
571
|
-
const b = Math.max(u, h, c);
|
|
572
|
-
let I = 1, m = 0, w = "", x = -1 / 0;
|
|
573
|
-
const p = s.length;
|
|
574
|
-
for (let l = 0; l < p + 1; l++)
|
|
575
|
-
if (s[l] === " " || l === p) {
|
|
576
|
-
if (I === u) {
|
|
577
|
-
if (this.renameRefSeq(s.slice(m, l)) !== t)
|
|
578
|
-
return {
|
|
579
|
-
overlaps: !1
|
|
580
|
-
};
|
|
581
|
-
} else if (I === h) {
|
|
582
|
-
if (x = parseInt(s.slice(m, l), 10), f === "1-based-closed" && (x -= 1), x >= i)
|
|
583
|
-
return {
|
|
584
|
-
startCoordinate: x,
|
|
585
|
-
overlaps: !1
|
|
586
|
-
};
|
|
587
|
-
if ((c === 0 || c === h) && x + 1 <= n)
|
|
588
|
-
return {
|
|
589
|
-
startCoordinate: x,
|
|
590
|
-
overlaps: !1
|
|
591
|
-
};
|
|
592
|
-
} else if (d === "VCF" && I === 4)
|
|
593
|
-
w = s.slice(m, l);
|
|
594
|
-
else if (I === c && (d === "VCF" ? this._getVcfEnd(x, w, s.slice(m, l)) : Number.parseInt(s.slice(m, l), 10)) <= n)
|
|
595
|
-
return {
|
|
596
|
-
overlaps: !1
|
|
597
|
-
};
|
|
598
|
-
if (m = l + 1, I += 1, I > b)
|
|
599
|
-
break;
|
|
600
|
-
}
|
|
601
|
-
return {
|
|
602
|
-
startCoordinate: x,
|
|
603
|
-
overlaps: !0
|
|
604
|
-
};
|
|
605
|
-
}
|
|
606
|
-
_getVcfEnd(e, t, n) {
|
|
607
|
-
let i = e + t.length;
|
|
608
|
-
const s = n.includes("SVTYPE=TRA");
|
|
609
|
-
if (n[0] !== "." && !s) {
|
|
610
|
-
let a = ";";
|
|
611
|
-
for (let r = 0; r < n.length; r += 1) {
|
|
612
|
-
if (a === ";" && n.slice(r, r + 4) === "END=") {
|
|
613
|
-
let f = n.indexOf(";", r);
|
|
614
|
-
f === -1 && (f = n.length), i = parseInt(n.slice(r + 4, f), 10);
|
|
615
|
-
break;
|
|
616
|
-
}
|
|
617
|
-
a = n[r];
|
|
618
|
-
}
|
|
619
|
-
} else if (s)
|
|
620
|
-
return e + 1;
|
|
621
|
-
return i;
|
|
622
|
-
}
|
|
623
|
-
/**
|
|
624
|
-
* return the approximate number of data lines in the given reference
|
|
625
|
-
* sequence
|
|
626
|
-
*
|
|
627
|
-
* @param refSeq reference sequence name
|
|
628
|
-
*
|
|
629
|
-
* @returns number of data lines present on that reference sequence
|
|
630
|
-
*/
|
|
631
|
-
async lineCount(e, t = {}) {
|
|
632
|
-
return this.index.lineCount(e, t);
|
|
633
|
-
}
|
|
634
|
-
async _readRegion(e, t, n = {}) {
|
|
635
|
-
const i = Q.Buffer.alloc(t), { bytesRead: s, buffer: a } = await this.filehandle.read(i, 0, t, e, n);
|
|
636
|
-
return a.subarray(0, s);
|
|
637
|
-
}
|
|
638
|
-
/**
|
|
639
|
-
* read and uncompress the data in a chunk (composed of one or more
|
|
640
|
-
* contiguous bgzip blocks) of the file
|
|
641
|
-
*/
|
|
642
|
-
async readChunk(e, t = {}) {
|
|
643
|
-
const n = await this._readRegion(e.minv.blockPosition, e.fetchedSize(), t);
|
|
644
|
-
return Z(n, e);
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
export {
|
|
648
|
-
z as CSI,
|
|
649
|
-
y as TBI,
|
|
650
|
-
ue as TabixIndexedFile
|
|
651
|
-
};
|