loom-browser 0.0.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/LICENSE +21 -0
- package/README.md +287 -0
- package/dist/igv.d.ts +667 -0
- package/dist/igv.esm.js +76708 -0
- package/dist/igv.esm.min.js +26 -0
- package/dist/igv.esm.min.js.map +1 -0
- package/dist/igv.js +76716 -0
- package/dist/igv.min.js +26 -0
- package/dist/igv.min.js.map +1 -0
- package/dist/loom.d.ts +667 -0
- package/dist/loom.esm.js +14927 -0
- package/dist/loom.esm.min.js +2 -0
- package/dist/loom.esm.min.js.map +1 -0
- package/dist/loom.js +15114 -0
- package/dist/loom.min.js +2 -0
- package/dist/loom.min.js.map +1 -0
- package/dist/types/agent/index.d.ts +4 -0
- package/dist/types/agent/stateProjection.d.ts +115 -0
- package/dist/types/agent/trackSelector.d.ts +31 -0
- package/dist/types/baseTrackCanvas.d.ts +62 -0
- package/dist/types/bigwig/binaryParser.d.ts +25 -0
- package/dist/types/bigwig/bpTree.d.ts +40 -0
- package/dist/types/bigwig/bwReader.d.ts +69 -0
- package/dist/types/bigwig/chromTree.d.ts +28 -0
- package/dist/types/bigwig/index.d.ts +66 -0
- package/dist/types/bigwig/inflate.d.ts +9 -0
- package/dist/types/bigwig/rangeReader.d.ts +48 -0
- package/dist/types/bigwig/rpTree.d.ts +27 -0
- package/dist/types/canvasProvider.d.ts +36 -0
- package/dist/types/commandDispatcher.d.ts +199 -0
- package/dist/types/contextMenu.d.ts +64 -0
- package/dist/types/contextMenuProvider.d.ts +25 -0
- package/dist/types/data/cachedSequence.d.ts +19 -0
- package/dist/types/data/ucscApi.d.ts +21 -0
- package/dist/types/data/ucscSequence.d.ts +19 -0
- package/dist/types/dataLifecycle.d.ts +16 -0
- package/dist/types/dataSources/bigWigDataSource.d.ts +24 -0
- package/dist/types/dataSources/dataSourceCacheKey.d.ts +9 -0
- package/dist/types/dataSources/dynseqDataSource.d.ts +20 -0
- package/dist/types/dataSources/featureSourceFactory.d.ts +46 -0
- package/dist/types/dataSources/geneDataSource.d.ts +16 -0
- package/dist/types/dataSources/gtxDataSource.d.ts +42 -0
- package/dist/types/dataSources/sequenceDataSource.d.ts +15 -0
- package/dist/types/dataSources/textFeatureSource.d.ts +63 -0
- package/dist/types/decode/bed.d.ts +64 -0
- package/dist/types/decode/bedpe.d.ts +36 -0
- package/dist/types/decode/exonUtils.d.ts +29 -0
- package/dist/types/decode/gff.d.ts +58 -0
- package/dist/types/decode/interact.d.ts +19 -0
- package/dist/types/decode/ucsc.d.ts +56 -0
- package/dist/types/dynseqRenderer.d.ts +37 -0
- package/dist/types/events.d.ts +23 -0
- package/dist/types/export/canvas2svg.d.ts +166 -0
- package/dist/types/export/index.d.ts +2 -0
- package/dist/types/featureCache.d.ts +69 -0
- package/dist/types/formats/featureParser.d.ts +72 -0
- package/dist/types/formats/formatDetection.d.ts +46 -0
- package/dist/types/geneRenderer.d.ts +17 -0
- package/dist/types/geneThemes.d.ts +11 -0
- package/dist/types/geneTrackCanvas.d.ts +46 -0
- package/dist/types/genome/chromAlias.d.ts +46 -0
- package/dist/types/genome/chromSizes.d.ts +53 -0
- package/dist/types/genome/genome.d.ts +51 -0
- package/dist/types/genomeBrowser.d.ts +189 -0
- package/dist/types/gtx/fetchCoordinator.d.ts +34 -0
- package/dist/types/gtx/gtxReader.d.ts +144 -0
- package/dist/types/gtx/index.d.ts +40 -0
- package/dist/types/gtx/zstdWasm.d.ts +22 -0
- package/dist/types/headlessGenomeBrowser.d.ts +450 -0
- package/dist/types/index.d.ts +123 -0
- package/dist/types/intervalTree.d.ts +56 -0
- package/dist/types/io/binaryParser.d.ts +25 -0
- package/dist/types/io/index.d.ts +7 -0
- package/dist/types/io/rangeReader.d.ts +48 -0
- package/dist/types/locusUtils.d.ts +37 -0
- package/dist/types/pack.d.ts +41 -0
- package/dist/types/popupProvider.d.ts +22 -0
- package/dist/types/remoteProtocol.d.ts +79 -0
- package/dist/types/renderTheme.d.ts +72 -0
- package/dist/types/renderThemePresets.d.ts +16 -0
- package/dist/types/roi/index.d.ts +3 -0
- package/dist/types/roi/roiRenderer.d.ts +24 -0
- package/dist/types/roi/roiSet.d.ts +41 -0
- package/dist/types/rulerRenderer.d.ts +14 -0
- package/dist/types/rulerTrackCanvas.d.ts +32 -0
- package/dist/types/sequence/sequenceUtils.d.ts +44 -0
- package/dist/types/session.d.ts +55 -0
- package/dist/types/src/bigwig/index.d.ts +66 -0
- package/dist/types/src/canvasProvider.d.ts +36 -0
- package/dist/types/src/commandDispatcher.d.ts +220 -0
- package/dist/types/src/contextMenu.d.ts +64 -0
- package/dist/types/src/contextMenuProvider.d.ts +25 -0
- package/dist/types/src/data/cachedSequence.d.ts +19 -0
- package/dist/types/src/data/ucscApi.d.ts +21 -0
- package/dist/types/src/data/ucscSequence.d.ts +19 -0
- package/dist/types/src/dataLifecycle.d.ts +16 -0
- package/dist/types/src/dataSources/bigWigDataSource.d.ts +24 -0
- package/dist/types/src/dataSources/dataSourceCacheKey.d.ts +9 -0
- package/dist/types/src/dataSources/featureSourceFactory.d.ts +46 -0
- package/dist/types/src/dataSources/geneDataSource.d.ts +16 -0
- package/dist/types/src/dataSources/gtxDataSource.d.ts +42 -0
- package/dist/types/src/dataSources/sequenceDataSource.d.ts +15 -0
- package/dist/types/src/dataSources/textFeatureSource.d.ts +63 -0
- package/dist/types/src/decode/bed.d.ts +64 -0
- package/dist/types/src/decode/bedpe.d.ts +36 -0
- package/dist/types/src/decode/exonUtils.d.ts +29 -0
- package/dist/types/src/decode/gff.d.ts +58 -0
- package/dist/types/src/decode/interact.d.ts +19 -0
- package/dist/types/src/decode/ucsc.d.ts +56 -0
- package/dist/types/src/events.d.ts +23 -0
- package/dist/types/src/export/canvas2svg.d.ts +166 -0
- package/dist/types/src/export/index.d.ts +2 -0
- package/dist/types/src/featureCache.d.ts +69 -0
- package/dist/types/src/formats/featureParser.d.ts +72 -0
- package/dist/types/src/formats/formatDetection.d.ts +46 -0
- package/dist/types/src/genome/chromAlias.d.ts +46 -0
- package/dist/types/src/genome/chromSizes.d.ts +53 -0
- package/dist/types/src/genome/genome.d.ts +51 -0
- package/dist/types/src/genomeBrowser.d.ts +189 -0
- package/dist/types/src/gtx/fetchCoordinator.d.ts +34 -0
- package/dist/types/src/gtx/gtxReader.d.ts +144 -0
- package/dist/types/src/gtx/index.d.ts +40 -0
- package/dist/types/src/gtx/zstdWasm.d.ts +22 -0
- package/dist/types/src/headlessGenomeBrowser.d.ts +450 -0
- package/dist/types/src/index.d.ts +123 -0
- package/dist/types/src/intervalTree.d.ts +56 -0
- package/dist/types/src/io/binaryParser.d.ts +25 -0
- package/dist/types/src/io/index.d.ts +7 -0
- package/dist/types/src/io/rangeReader.d.ts +48 -0
- package/dist/types/src/locusUtils.d.ts +37 -0
- package/dist/types/src/pack.d.ts +41 -0
- package/dist/types/src/popupProvider.d.ts +22 -0
- package/dist/types/src/remoteProtocol.d.ts +81 -0
- package/dist/types/src/roi/index.d.ts +3 -0
- package/dist/types/src/roi/roiRenderer.d.ts +24 -0
- package/dist/types/src/roi/roiSet.d.ts +41 -0
- package/dist/types/src/sequence/sequenceUtils.d.ts +44 -0
- package/dist/types/src/session.d.ts +55 -0
- package/dist/types/src/stateProjection.d.ts +115 -0
- package/dist/types/src/tabix/index.d.ts +48 -0
- package/dist/types/src/themes/index.d.ts +3 -0
- package/dist/types/src/themes/renderTheme.d.ts +86 -0
- package/dist/types/src/themes/renderThemePresets.d.ts +16 -0
- package/dist/types/src/trackRegistry.d.ts +81 -0
- package/dist/types/src/trackSelector.d.ts +31 -0
- package/dist/types/src/tracks/annotation/annotationRenderer.d.ts +17 -0
- package/dist/types/src/tracks/annotation/annotationThemes.d.ts +11 -0
- package/dist/types/src/tracks/annotation/annotationTrackCanvas.d.ts +58 -0
- package/dist/types/src/tracks/annotation/index.d.ts +4 -0
- package/dist/types/src/tracks/axis/axisRenderer.d.ts +19 -0
- package/dist/types/src/tracks/axis/index.d.ts +1 -0
- package/dist/types/src/tracks/baseTrackCanvas.d.ts +113 -0
- package/dist/types/src/tracks/dynseq/dynseqRenderer.d.ts +38 -0
- package/dist/types/src/tracks/dynseq/index.d.ts +1 -0
- package/dist/types/src/tracks/index.d.ts +7 -0
- package/dist/types/src/tracks/interaction/index.d.ts +4 -0
- package/dist/types/src/tracks/interaction/interactionRenderer.d.ts +52 -0
- package/dist/types/src/tracks/interaction/interactionTrackCanvas.d.ts +54 -0
- package/dist/types/src/tracks/ruler/index.d.ts +3 -0
- package/dist/types/src/tracks/ruler/rulerRenderer.d.ts +25 -0
- package/dist/types/src/tracks/ruler/rulerTrackCanvas.d.ts +43 -0
- package/dist/types/src/tracks/sequence/index.d.ts +5 -0
- package/dist/types/src/tracks/sequence/sequenceRenderer.d.ts +34 -0
- package/dist/types/src/tracks/sequence/sequenceThemes.d.ts +11 -0
- package/dist/types/src/tracks/sequence/sequenceTrackCanvas.d.ts +67 -0
- package/dist/types/src/tracks/wig/index.d.ts +5 -0
- package/dist/types/src/tracks/wig/wigRenderer.d.ts +15 -0
- package/dist/types/src/tracks/wig/wigSummary.d.ts +31 -0
- package/dist/types/src/tracks/wig/wigThemes.d.ts +15 -0
- package/dist/types/src/tracks/wig/wigTrackCanvas.d.ts +82 -0
- package/dist/types/src/types.d.ts +885 -0
- package/dist/types/src/ui/components/LoomBrowserShell.d.ts +52 -0
- package/dist/types/src/ui/components/LoomChromosomeSelect.d.ts +18 -0
- package/dist/types/src/ui/components/LoomContextMenu.d.ts +39 -0
- package/dist/types/src/ui/components/LoomExportControls.d.ts +13 -0
- package/dist/types/src/ui/components/LoomInputDialog.d.ts +27 -0
- package/dist/types/src/ui/components/LoomLocusInput.d.ts +18 -0
- package/dist/types/src/ui/components/LoomNavbar.d.ts +15 -0
- package/dist/types/src/ui/components/LoomPopup.d.ts +32 -0
- package/dist/types/src/ui/components/LoomWindowSize.d.ts +14 -0
- package/dist/types/src/ui/components/LoomZoomControls.d.ts +10 -0
- package/dist/types/src/ui/index.d.ts +21 -0
- package/dist/types/src/ui/themes.d.ts +14 -0
- package/dist/types/src/worker/nodeWorkerProvider.d.ts +28 -0
- package/dist/types/src/worker/taskHandler.d.ts +15 -0
- package/dist/types/src/worker/webWorkerProvider.d.ts +51 -0
- package/dist/types/src/worker/workerScript.d.ts +11 -0
- package/dist/types/src/workerProvider.d.ts +76 -0
- package/dist/types/stateProjection.d.ts +115 -0
- package/dist/types/tabix/bgzBlockLoader.d.ts +60 -0
- package/dist/types/tabix/bgzf.d.ts +43 -0
- package/dist/types/tabix/index.d.ts +48 -0
- package/dist/types/tabix/tabixIndex.d.ts +85 -0
- package/dist/types/tabix/tabixReader.d.ts +60 -0
- package/dist/types/tabix/virtualOffset.d.ts +41 -0
- package/dist/types/test/src/mockCanvasProvider.d.ts +67 -0
- package/dist/types/test/src/testBedDecode.d.ts +1 -0
- package/dist/types/test/src/testCanvas2SVG.d.ts +7 -0
- package/dist/types/test/src/testChromAlias.d.ts +1 -0
- package/dist/types/test/src/testCommandDispatcher.d.ts +1 -0
- package/dist/types/test/src/testData.d.ts +7 -0
- package/dist/types/test/src/testDataLifecycle.d.ts +1 -0
- package/dist/types/test/src/testDataSourceCacheKey.d.ts +1 -0
- package/dist/types/test/src/testDataSources.d.ts +5 -0
- package/dist/types/test/src/testDecodeUcsc.d.ts +1 -0
- package/dist/types/test/src/testEvents.d.ts +1 -0
- package/dist/types/test/src/testFeatureCache.d.ts +1 -0
- package/dist/types/test/src/testFeatureParser.d.ts +1 -0
- package/dist/types/test/src/testFormatDetection.d.ts +1 -0
- package/dist/types/test/src/testGffDecode.d.ts +1 -0
- package/dist/types/test/src/testHeadlessBrowser.d.ts +1 -0
- package/dist/types/test/src/testInteractionDecoder.d.ts +1 -0
- package/dist/types/test/src/testIntervalTree.d.ts +1 -0
- package/dist/types/test/src/testLocusUtils.d.ts +1 -0
- package/dist/types/test/src/testPack.d.ts +1 -0
- package/dist/types/test/src/testROI.d.ts +1 -0
- package/dist/types/test/src/testRemoteProtocol.d.ts +1 -0
- package/dist/types/test/src/testRenderTheme.d.ts +1 -0
- package/dist/types/test/src/testSVGExport.d.ts +5 -0
- package/dist/types/test/src/testSequence.d.ts +1 -0
- package/dist/types/test/src/testSession.d.ts +1 -0
- package/dist/types/test/src/testTrackSelector.d.ts +1 -0
- package/dist/types/test/src/testTrackSerialize.d.ts +1 -0
- package/dist/types/test/src/testWigSummary.d.ts +1 -0
- package/dist/types/test/src/testWorkerDispatch.d.ts +9 -0
- package/dist/types/themes/index.d.ts +3 -0
- package/dist/types/themes/renderTheme.d.ts +86 -0
- package/dist/types/themes/renderThemePresets.d.ts +16 -0
- package/dist/types/trackRegistry.d.ts +81 -0
- package/dist/types/trackSelector.d.ts +31 -0
- package/dist/types/tracks/annotation/annotationRenderer.d.ts +17 -0
- package/dist/types/tracks/annotation/annotationThemes.d.ts +11 -0
- package/dist/types/tracks/annotation/annotationTrackCanvas.d.ts +58 -0
- package/dist/types/tracks/annotation/index.d.ts +4 -0
- package/dist/types/tracks/axis/axisRenderer.d.ts +19 -0
- package/dist/types/tracks/axis/index.d.ts +1 -0
- package/dist/types/tracks/baseTrackCanvas.d.ts +113 -0
- package/dist/types/tracks/dynseq/dynseqRenderer.d.ts +38 -0
- package/dist/types/tracks/dynseq/index.d.ts +1 -0
- package/dist/types/tracks/gene/geneRenderer.d.ts +17 -0
- package/dist/types/tracks/gene/geneThemes.d.ts +11 -0
- package/dist/types/tracks/gene/geneTrackCanvas.d.ts +58 -0
- package/dist/types/tracks/gene/index.d.ts +4 -0
- package/dist/types/tracks/index.d.ts +7 -0
- package/dist/types/tracks/interaction/index.d.ts +4 -0
- package/dist/types/tracks/interaction/interactionRenderer.d.ts +52 -0
- package/dist/types/tracks/interaction/interactionTrackCanvas.d.ts +54 -0
- package/dist/types/tracks/ruler/index.d.ts +3 -0
- package/dist/types/tracks/ruler/rulerRenderer.d.ts +25 -0
- package/dist/types/tracks/ruler/rulerTrackCanvas.d.ts +43 -0
- package/dist/types/tracks/sequence/index.d.ts +5 -0
- package/dist/types/tracks/sequence/sequenceRenderer.d.ts +34 -0
- package/dist/types/tracks/sequence/sequenceThemes.d.ts +11 -0
- package/dist/types/tracks/sequence/sequenceTrackCanvas.d.ts +67 -0
- package/dist/types/tracks/wig/index.d.ts +5 -0
- package/dist/types/tracks/wig/wigRenderer.d.ts +15 -0
- package/dist/types/tracks/wig/wigSummary.d.ts +31 -0
- package/dist/types/tracks/wig/wigThemes.d.ts +15 -0
- package/dist/types/tracks/wig/wigTrackCanvas.d.ts +82 -0
- package/dist/types/types.d.ts +885 -0
- package/dist/types/ui/components/IgvBrowserShell.d.ts +52 -0
- package/dist/types/ui/components/IgvChromosomeSelect.d.ts +18 -0
- package/dist/types/ui/components/IgvExportControls.d.ts +13 -0
- package/dist/types/ui/components/IgvLocusInput.d.ts +18 -0
- package/dist/types/ui/components/IgvNavbar.d.ts +15 -0
- package/dist/types/ui/components/IgvWindowSize.d.ts +14 -0
- package/dist/types/ui/components/IgvZoomControls.d.ts +10 -0
- package/dist/types/ui/components/LoomBrowserShell.d.ts +52 -0
- package/dist/types/ui/components/LoomChromosomeSelect.d.ts +18 -0
- package/dist/types/ui/components/LoomContextMenu.d.ts +39 -0
- package/dist/types/ui/components/LoomExportControls.d.ts +13 -0
- package/dist/types/ui/components/LoomInputDialog.d.ts +27 -0
- package/dist/types/ui/components/LoomLocusInput.d.ts +18 -0
- package/dist/types/ui/components/LoomNavbar.d.ts +15 -0
- package/dist/types/ui/components/LoomPopup.d.ts +32 -0
- package/dist/types/ui/components/LoomWindowSize.d.ts +14 -0
- package/dist/types/ui/components/LoomZoomControls.d.ts +10 -0
- package/dist/types/ui/index.d.ts +21 -0
- package/dist/types/ui/themes.d.ts +14 -0
- package/dist/types/wigRenderer.d.ts +15 -0
- package/dist/types/wigSummary.d.ts +31 -0
- package/dist/types/wigThemes.d.ts +15 -0
- package/dist/types/wigTrackCanvas.d.ts +46 -0
- package/dist/types/worker/decodeWig.d.ts +20 -0
- package/dist/types/worker/nodeWorkerProvider.d.ts +28 -0
- package/dist/types/worker/taskHandler.d.ts +15 -0
- package/dist/types/worker/webWorkerProvider.d.ts +51 -0
- package/dist/types/worker/workerScript.d.ts +11 -0
- package/dist/types/workerProvider.d.ts +76 -0
- package/package.json +102 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format detection from URL/filename and track type inference.
|
|
3
|
+
*
|
|
4
|
+
* Port of js/util/fileFormatUtils.ts (inferFileFormatFromName, knownFileExtensions)
|
|
5
|
+
* and js/util/trackUtils.ts (inferTrackType).
|
|
6
|
+
*
|
|
7
|
+
* Layer 1 (Data + Layout): pure functions, no I/O, no DOM.
|
|
8
|
+
*/
|
|
9
|
+
/** Comprehensive set of known file extensions. Port of js/util/fileFormatUtils.ts. */
|
|
10
|
+
export declare const knownFileExtensions: ReadonlySet<string>;
|
|
11
|
+
/**
|
|
12
|
+
* Infer file format from a URL or filename.
|
|
13
|
+
*
|
|
14
|
+
* Strips compression extensions (.gz, .bgz), auxiliary extensions (.txt, .tab, .tsv),
|
|
15
|
+
* then checks the remaining extension against known formats.
|
|
16
|
+
*
|
|
17
|
+
* Port of js/util/fileFormatUtils.ts::inferFileFormatFromName().
|
|
18
|
+
*/
|
|
19
|
+
export declare function inferFormatFromPath(path: string): string | undefined;
|
|
20
|
+
/** Check if a format string represents a binary (non-text) format. */
|
|
21
|
+
export declare function isBinaryFormat(format: string): boolean;
|
|
22
|
+
/** BigWig/BigBed format set — these use BWSource in igv.js. */
|
|
23
|
+
export declare const bbFormats: Set<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Check if a URL is likely tabix-indexed.
|
|
26
|
+
*
|
|
27
|
+
* Only `.bgz` (bgzip-specific extension) is auto-detected as indexed.
|
|
28
|
+
* Plain `.gz` files may be either bgzipped+tabix-indexed or plain gzipped,
|
|
29
|
+
* so callers should explicitly set `indexed: true` or provide an `indexURL`
|
|
30
|
+
* for those. This matches igv.js behavior where indexURL must be configured
|
|
31
|
+
* for BED/GFF files to use tabix.
|
|
32
|
+
*/
|
|
33
|
+
export declare function isLikelyIndexed(url: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Infer the tabix index URL from a data file URL.
|
|
36
|
+
* Appends '.tbi' to the URL (respecting query parameters).
|
|
37
|
+
*
|
|
38
|
+
* Port of js/util/fileFormatUtils.ts::inferIndexPath().
|
|
39
|
+
*/
|
|
40
|
+
export declare function inferIndexURL(url: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Infer the track type from a file format.
|
|
43
|
+
*
|
|
44
|
+
* Port of js/util/trackUtils.ts::inferTrackType().
|
|
45
|
+
*/
|
|
46
|
+
export declare function inferTrackType(format: string | undefined): string | undefined;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default chromosome alias resolution.
|
|
3
|
+
*
|
|
4
|
+
* Computes NCBI↔UCSC mappings (chr1↔1, chrM↔MT) and case aliases from
|
|
5
|
+
* chromosome names. This covers the ~90% case where BigWig/BAM files use
|
|
6
|
+
* a different naming convention than the genome.
|
|
7
|
+
*
|
|
8
|
+
* Port of js/genome/chromAliasDefaults.ts. In our architecture this is
|
|
9
|
+
* Layer 1 (Data + Layout): pure data, no DOM.
|
|
10
|
+
*
|
|
11
|
+
* Extension points for file-based (ChromAliasFile) and BigBed-based
|
|
12
|
+
* (ChromAliasBB) alias sources can be added later by implementing the
|
|
13
|
+
* same interface and wiring into GenomeImpl.
|
|
14
|
+
*/
|
|
15
|
+
import type { ChromAliasRecord } from '../types';
|
|
16
|
+
/**
|
|
17
|
+
* Add case-insensitivity and chr-prefix aliases to an alias record.
|
|
18
|
+
* Reusable by future ChromAliasFile/ChromAliasBB implementations.
|
|
19
|
+
*
|
|
20
|
+
* Mirrors igv.js ChromAliasDefaults.addCaseAliases (js/genome/chromAliasDefaults.ts).
|
|
21
|
+
*/
|
|
22
|
+
export declare function addCaseAliases(record: ChromAliasRecord): void;
|
|
23
|
+
/**
|
|
24
|
+
* Default chromosome alias resolver.
|
|
25
|
+
*
|
|
26
|
+
* Builds a bidirectional alias cache from chromosome names at construction time.
|
|
27
|
+
* All lookups are synchronous (no network). Covers:
|
|
28
|
+
* - NCBI↔UCSC numeric mapping (chr1↔1, chrM↔MT)
|
|
29
|
+
* - Human sex chromosomes (23↔chrX, 24↔chrY) for hg, GRCh, b37 genomes
|
|
30
|
+
* - Mouse sex chromosomes (21↔chrX, 22↔chrY) for mm, GRCm, rheMac genomes
|
|
31
|
+
* - Case aliases (uppercase, lowercase, capitalized, chr-prefix-flipped)
|
|
32
|
+
* - NCBI gi| accession parsing
|
|
33
|
+
*
|
|
34
|
+
* Mirrors igv.js ChromAliasDefaults (js/genome/chromAliasDefaults.ts).
|
|
35
|
+
*/
|
|
36
|
+
export declare class ChromAliasDefaults {
|
|
37
|
+
private cache;
|
|
38
|
+
constructor(chromosomeNames: string[], genomeId?: string);
|
|
39
|
+
/** Resolve alias to canonical name. Returns undefined if not found. */
|
|
40
|
+
getChromosomeName(alias: string): string | undefined;
|
|
41
|
+
/** Get full alias record for a chromosome or alias. */
|
|
42
|
+
getAliasRecord(alias: string): ChromAliasRecord | undefined;
|
|
43
|
+
private buildAliases;
|
|
44
|
+
private addHumanSexAliases;
|
|
45
|
+
private addMouseSexAliases;
|
|
46
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chromosome size data and utilities.
|
|
3
|
+
*
|
|
4
|
+
* Provides a lightweight ChromSizes type (chr → bp length), a default
|
|
5
|
+
* hg38 dataset, and genome coordinate system utilities for whole genome view.
|
|
6
|
+
*/
|
|
7
|
+
/** Mapping of chromosome names to their lengths in base pairs. */
|
|
8
|
+
export type ChromSizes = Record<string, number>;
|
|
9
|
+
/**
|
|
10
|
+
* Look up the length of a chromosome. Returns undefined if not found.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getChromLength(chr: string, chromSizes?: ChromSizes): number | undefined;
|
|
13
|
+
/** Precomputed genome-wide coordinate system for whole genome view. */
|
|
14
|
+
export interface CumulativeOffsets {
|
|
15
|
+
/** Chromosome name → genome-wide start position. */
|
|
16
|
+
offsets: Record<string, number>;
|
|
17
|
+
/** Total length of all main chromosomes. */
|
|
18
|
+
totalLength: number;
|
|
19
|
+
/** Ordered chromosome names used in the WG view. */
|
|
20
|
+
chromosomeNames: string[];
|
|
21
|
+
}
|
|
22
|
+
/** Check if a chromosome name is a "main" chromosome (chr1-22, X, Y, M). */
|
|
23
|
+
export declare function isMainChromosome(name: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Return ordered list of main chromosome names from chromSizes.
|
|
26
|
+
* Order: chr1-22 (numeric), chrX, chrY, chrM.
|
|
27
|
+
*/
|
|
28
|
+
export declare function mainChromosomeNames(chromSizes: ChromSizes): string[];
|
|
29
|
+
/**
|
|
30
|
+
* Compute cumulative genome-wide offsets for main chromosomes.
|
|
31
|
+
* Used to map per-chromosome coordinates to a linear genome-wide space.
|
|
32
|
+
*/
|
|
33
|
+
export declare function computeCumulativeOffsets(chromSizes: ChromSizes): CumulativeOffsets;
|
|
34
|
+
/**
|
|
35
|
+
* Convert a genome-wide coordinate back to chromosome-relative coordinates.
|
|
36
|
+
* Returns the chromosome and position within it.
|
|
37
|
+
*/
|
|
38
|
+
export declare function genomeToChromCoord(genomePos: number, cumOffsets: CumulativeOffsets): {
|
|
39
|
+
chr: string;
|
|
40
|
+
position: number;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Parse a tab-separated chrom.sizes file into a ChromSizes record.
|
|
44
|
+
* Format: one line per chromosome, `name\tlength`, with optional comments (#).
|
|
45
|
+
* Mirrors the UCSC chrom.sizes file format.
|
|
46
|
+
*/
|
|
47
|
+
export declare function parseChromSizes(text: string): ChromSizes;
|
|
48
|
+
/**
|
|
49
|
+
* GRCh38/hg38 chromosome sizes.
|
|
50
|
+
* Includes main chromosomes (chr1-22, X, Y, M) plus all contigs and alts.
|
|
51
|
+
* Source: UCSC hg38.chrom.sizes
|
|
52
|
+
*/
|
|
53
|
+
export declare const hg38ChromSizes: ChromSizes;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Genome assembly abstraction.
|
|
3
|
+
*
|
|
4
|
+
* Provides a unified `Genome` object that encapsulates chromosome metadata,
|
|
5
|
+
* cumulative offsets for whole genome view, and optional sequence access.
|
|
6
|
+
*
|
|
7
|
+
* Mirrors igv.js `Genome` class (js/genome/genome.ts) which provides:
|
|
8
|
+
* - Chromosome sizes and metadata
|
|
9
|
+
* - Sequence access via CachedSequence wrapping FASTA/2bit/UCSC API
|
|
10
|
+
* - Cumulative offsets for genome-wide coordinate conversion
|
|
11
|
+
* - Chromosome alias resolution via ChromAliasDefaults (Gap #6)
|
|
12
|
+
*
|
|
13
|
+
* In our architecture this is Layer 1 (Data + Layout): pure data, no DOM.
|
|
14
|
+
* The HeadlessGenomeBrowser (Layer 3) takes a Genome and derives chromSizes,
|
|
15
|
+
* cumulativeOffsets, and sequenceProvider from it.
|
|
16
|
+
*
|
|
17
|
+
* Factory functions:
|
|
18
|
+
* - `createGenomeSync()` — synchronous, requires inline chromSizes
|
|
19
|
+
* - `createGenome()` — async, can fetch chromSizes from URL
|
|
20
|
+
* - `hg38Genome` — pre-built singleton for the default human genome
|
|
21
|
+
*/
|
|
22
|
+
import type { Genome, GenomeConfig } from '../types';
|
|
23
|
+
import type { ChromSizes } from './chromSizes';
|
|
24
|
+
/**
|
|
25
|
+
* Create a Genome synchronously from inline chromosome sizes.
|
|
26
|
+
*
|
|
27
|
+
* Use when chromSizes are already available (e.g., built-in genomes,
|
|
28
|
+
* or after fetching from a URL yourself).
|
|
29
|
+
*/
|
|
30
|
+
export declare function createGenomeSync(config: GenomeConfig & {
|
|
31
|
+
chromSizes: ChromSizes;
|
|
32
|
+
}): Genome;
|
|
33
|
+
/**
|
|
34
|
+
* Create a Genome asynchronously.
|
|
35
|
+
*
|
|
36
|
+
* Supports:
|
|
37
|
+
* - Built-in genome IDs (e.g., "hg38") — uses hardcoded chromSizes
|
|
38
|
+
* - Inline chromSizes — same as createGenomeSync
|
|
39
|
+
* - chromSizesURL — fetches and parses tab-separated chrom.sizes file
|
|
40
|
+
*
|
|
41
|
+
* Mirrors igv.js `Genome.createGenome(config, browser)` (js/genome/genome.ts)
|
|
42
|
+
* which loads sequence, cytobands, and chromosomes asynchronously.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createGenome(config: GenomeConfig): Promise<Genome>;
|
|
45
|
+
/**
|
|
46
|
+
* Pre-built hg38 genome with UCSC sequence API.
|
|
47
|
+
*
|
|
48
|
+
* This is the default genome used by HeadlessGenomeBrowser when no genome
|
|
49
|
+
* is specified. Equivalent to igv.js's default behavior of loading hg38.
|
|
50
|
+
*/
|
|
51
|
+
export declare const hg38Genome: Genome;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOM-attached GenomeBrowser — extends HeadlessGenomeBrowser with pointer events,
|
|
3
|
+
* ResizeObserver, canvas stacking, and sweep-to-zoom.
|
|
4
|
+
*
|
|
5
|
+
* Coordinates multiple Track instances, stacking them vertically in a container.
|
|
6
|
+
* Static rendering is the base — interactivity (drag-to-pan) is enabled by default
|
|
7
|
+
* but can be disabled via `interactive: false`.
|
|
8
|
+
*
|
|
9
|
+
* Ruler tracks get special treatment: dragging on a ruler creates a selection
|
|
10
|
+
* overlay (sweep-to-zoom) instead of panning.
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* const browser = new GenomeBrowser(container, {
|
|
14
|
+
* locus: { chr: 'chr17', start: 7668000, end: 7688000 },
|
|
15
|
+
* })
|
|
16
|
+
* browser.addTrack(rulerTrack)
|
|
17
|
+
* browser.addTrack(geneTrack)
|
|
18
|
+
* // Drag to pan — works out of the box.
|
|
19
|
+
* // Drag on ruler — sweep to zoom.
|
|
20
|
+
* // Cleanup:
|
|
21
|
+
* browser.dispose()
|
|
22
|
+
*/
|
|
23
|
+
import type { Track, DataSource, SessionConfig, DataSourceConfig } from "./types";
|
|
24
|
+
import { HeadlessGenomeBrowser } from "./headlessGenomeBrowser";
|
|
25
|
+
import type { HeadlessGenomeBrowserOptions } from "./headlessGenomeBrowser";
|
|
26
|
+
import type { RemoteSocket } from "./remoteProtocol";
|
|
27
|
+
import type { CreateTrackFromSessionOptions } from "./session";
|
|
28
|
+
export { BrowserEvent } from "./headlessGenomeBrowser";
|
|
29
|
+
export type { BrowserEvents } from "./headlessGenomeBrowser";
|
|
30
|
+
export interface GenomeBrowserOptions extends HeadlessGenomeBrowserOptions {
|
|
31
|
+
/** Enable mouse/touch drag to pan. Default: true. */
|
|
32
|
+
interactive?: boolean;
|
|
33
|
+
/** Enable trackpad pinch and scroll-wheel zoom. Default: true when interactive. */
|
|
34
|
+
wheelZoom?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export declare class GenomeBrowser extends HeadlessGenomeBrowser {
|
|
37
|
+
private container;
|
|
38
|
+
private interactive;
|
|
39
|
+
private isDragging;
|
|
40
|
+
private lastPointerX;
|
|
41
|
+
private isSweeping;
|
|
42
|
+
private sweepStartX;
|
|
43
|
+
private sweepOverlay;
|
|
44
|
+
private sweepRulerCanvas;
|
|
45
|
+
private pointerDownX;
|
|
46
|
+
private pointerDownY;
|
|
47
|
+
private pointerDownTarget;
|
|
48
|
+
private lastClickTime;
|
|
49
|
+
private lastClickX;
|
|
50
|
+
private lastClickY;
|
|
51
|
+
private singleClickTimer;
|
|
52
|
+
private hoverThrottleId;
|
|
53
|
+
private _rafId;
|
|
54
|
+
private resizeObserver;
|
|
55
|
+
private trackRows;
|
|
56
|
+
private handleContextMenu;
|
|
57
|
+
private inputDialog;
|
|
58
|
+
private remoteConnection;
|
|
59
|
+
private reorderDragTrack;
|
|
60
|
+
private reorderDragRow;
|
|
61
|
+
private reorderHandlers;
|
|
62
|
+
private handlePointerDown;
|
|
63
|
+
private handlePointerMove;
|
|
64
|
+
private handlePointerUp;
|
|
65
|
+
private handleMouseMove;
|
|
66
|
+
private handleMouseLeave;
|
|
67
|
+
private handleDocMouseDown;
|
|
68
|
+
private handleWheel;
|
|
69
|
+
private wheelRafId;
|
|
70
|
+
private roiOverlayContainer;
|
|
71
|
+
private roiElements;
|
|
72
|
+
constructor(container: HTMLElement, options: GenomeBrowserOptions);
|
|
73
|
+
/** Add a track and attach its canvas to the container. */
|
|
74
|
+
addTrack<F>(track: Track, dataSource?: DataSource<F>, dataSourceConfig?: DataSourceConfig, maxTrackHeight?: number): string;
|
|
75
|
+
/** Remove a track and its row from the container. */
|
|
76
|
+
removeTrack(trackOrId: Track | string): void;
|
|
77
|
+
/** Move a track and reorder the DOM rows to match. */
|
|
78
|
+
moveTrack(track: Track, toIndex: number): void;
|
|
79
|
+
/**
|
|
80
|
+
* Load a session, replacing all current tracks.
|
|
81
|
+
* Removes existing canvases from the DOM, then delegates to the headless
|
|
82
|
+
* implementation which recreates tracks. New canvases are attached via addTrack().
|
|
83
|
+
*/
|
|
84
|
+
loadSession(session: SessionConfig, options?: CreateTrackFromSessionOptions): void;
|
|
85
|
+
/** Re-render all tracks, reading width from the DOM container. */
|
|
86
|
+
render(): void;
|
|
87
|
+
/** Clean up event listeners, remove canvases, and dispose headless core. */
|
|
88
|
+
/**
|
|
89
|
+
* Attach a remote WebSocket connection.
|
|
90
|
+
* Incoming command messages are automatically dispatched.
|
|
91
|
+
* Browser events are automatically forwarded.
|
|
92
|
+
*/
|
|
93
|
+
attachRemote(socket: RemoteSocket): void;
|
|
94
|
+
/** Detach the remote connection and stop forwarding events. */
|
|
95
|
+
detachRemote(): void;
|
|
96
|
+
dispose(): void;
|
|
97
|
+
/**
|
|
98
|
+
* Update the axis content for a track based on its getAxisInfo().
|
|
99
|
+
* Uses a canvas for quantitative axes (tick marks + labels) matching igv.js paintAxis,
|
|
100
|
+
* and a DOM label for annotation tracks (e.g., gene track name).
|
|
101
|
+
*/
|
|
102
|
+
private updateAxisContent;
|
|
103
|
+
/**
|
|
104
|
+
* Prepare an axis canvas at the correct size with DPR scaling,
|
|
105
|
+
* then delegate to the given stateless render function.
|
|
106
|
+
*/
|
|
107
|
+
private paintAxisCanvas;
|
|
108
|
+
/** Check if a pointer event target is a ruler track canvas. */
|
|
109
|
+
private isRulerCanvas;
|
|
110
|
+
private createSweepOverlay;
|
|
111
|
+
private removeSweepOverlay;
|
|
112
|
+
private setupDragHandlers;
|
|
113
|
+
/** Check if an event originated inside an overlay UI component (Shadow DOM) or ROI element. */
|
|
114
|
+
private isOverlayTarget;
|
|
115
|
+
/** Find the track whose canvas contains the given event target. */
|
|
116
|
+
private findTrackForTarget;
|
|
117
|
+
/** Canvas-relative coordinates from a mouse/pointer event. */
|
|
118
|
+
private canvasCoords;
|
|
119
|
+
private handleClick;
|
|
120
|
+
private setupHoverHandlers;
|
|
121
|
+
private teardownHoverHandlers;
|
|
122
|
+
private setupContextMenuHandler;
|
|
123
|
+
private teardownContextMenuHandler;
|
|
124
|
+
/** Reorder DOM rows to match managedTracks order. */
|
|
125
|
+
private syncDOMOrder;
|
|
126
|
+
/** Set up drag-to-reorder pointer handlers on an axis div. */
|
|
127
|
+
private setupReorderHandlers;
|
|
128
|
+
/** Remove reorder handlers for a track. */
|
|
129
|
+
private teardownReorderHandlers;
|
|
130
|
+
private teardownDragHandlers;
|
|
131
|
+
/**
|
|
132
|
+
* Set up wheel event handling for trackpad pinch-to-zoom and scroll-wheel zoom.
|
|
133
|
+
*
|
|
134
|
+
* Trackpad pinch gestures on macOS/Chrome are reported as `wheel` events with
|
|
135
|
+
* `ctrlKey: true` and `deltaY` indicating zoom direction. Regular scroll-wheel
|
|
136
|
+
* events (ctrl+scroll) use the same mechanism. Both zoom around the pointer
|
|
137
|
+
* position for natural, cursor-anchored zoom behavior.
|
|
138
|
+
*/
|
|
139
|
+
private setupWheelHandler;
|
|
140
|
+
private teardownWheelHandler;
|
|
141
|
+
/** Ensure the ROI overlay container exists and is sized correctly. */
|
|
142
|
+
private ensureROIOverlayContainer;
|
|
143
|
+
/**
|
|
144
|
+
* Render ROI overlays as DOM elements positioned over the track viewport.
|
|
145
|
+
*
|
|
146
|
+
* Creates/updates/removes DOM elements for each visible ROI.
|
|
147
|
+
* DOM-based (not canvas) for easy hover/click interaction without
|
|
148
|
+
* re-rendering track canvases.
|
|
149
|
+
*/
|
|
150
|
+
private renderROIOverlays;
|
|
151
|
+
/** Create a styled DOM element for an ROI region. */
|
|
152
|
+
private createROIElement;
|
|
153
|
+
/** Show context menu for an ROI. */
|
|
154
|
+
private showROIContextMenu;
|
|
155
|
+
/** Clean up ROI overlay elements. */
|
|
156
|
+
private clearROIOverlay;
|
|
157
|
+
/**
|
|
158
|
+
* Export the current view as an SVG string, including axis columns.
|
|
159
|
+
*
|
|
160
|
+
* Overrides HeadlessGenomeBrowser.toSVG() to add axis rendering on the
|
|
161
|
+
* left side of each track, matching igv.js Browser.toSVG() which calls
|
|
162
|
+
* renderSVGAxis() for each TrackView (js/browser.ts lines 352-388).
|
|
163
|
+
*/
|
|
164
|
+
toSVG(options?: {
|
|
165
|
+
width?: number;
|
|
166
|
+
backdropColor?: string;
|
|
167
|
+
}): string;
|
|
168
|
+
/**
|
|
169
|
+
* Export the current view as a PNG data URL.
|
|
170
|
+
*
|
|
171
|
+
* Pipeline: toSVG() → Blob → Image → Canvas (DPR-scaled) → toDataURL.
|
|
172
|
+
* Matches igv.js Browser.savePNGtoFile() (js/browser.ts lines 407-440).
|
|
173
|
+
*
|
|
174
|
+
* Returns a promise that resolves to a `data:image/png;base64,...` string.
|
|
175
|
+
*/
|
|
176
|
+
toPNG(): Promise<string>;
|
|
177
|
+
/**
|
|
178
|
+
* Download the current view as an SVG file.
|
|
179
|
+
* Matches igv.js Browser.saveSVGtoFile() (js/browser.ts lines 390-405).
|
|
180
|
+
*/
|
|
181
|
+
saveSVGtoFile(filename?: string): void;
|
|
182
|
+
/**
|
|
183
|
+
* Download the current view as a PNG file.
|
|
184
|
+
* Matches igv.js Browser.savePNGtoFile() (js/browser.ts lines 407-440).
|
|
185
|
+
*/
|
|
186
|
+
savePNGtoFile(filename?: string): Promise<void>;
|
|
187
|
+
/** Trigger a file download via a temporary anchor element. */
|
|
188
|
+
private downloadURL;
|
|
189
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GTX fetch coordinator — batches requests from multiple GtxDataSource
|
|
3
|
+
* instances into a single readFeatures() call.
|
|
4
|
+
*
|
|
5
|
+
* When loadAllTracksIfNeeded fires for 5 GTX tracks, all 5
|
|
6
|
+
* GtxDataSource.fetch() calls run synchronously in the same tick.
|
|
7
|
+
* Each calls coordinator.request() which is synchronous — no awaits
|
|
8
|
+
* before the batching logic. Requests are collected, then flushed
|
|
9
|
+
* on the next microtask as a single readFeatures() call with all
|
|
10
|
+
* experiment indexes, merging byte ranges across experiments.
|
|
11
|
+
*
|
|
12
|
+
* Layer 1 (Data + Layout): no DOM, no canvas.
|
|
13
|
+
*/
|
|
14
|
+
import { GtxReader } from './gtxReader';
|
|
15
|
+
import type { WigFeature, Locus } from '../types';
|
|
16
|
+
export declare function getCoordinator(url: string, reader: GtxReader): GtxFetchCoordinator;
|
|
17
|
+
export declare function clearCoordinators(): void;
|
|
18
|
+
export declare class GtxFetchCoordinator {
|
|
19
|
+
private url;
|
|
20
|
+
private reader;
|
|
21
|
+
private pending;
|
|
22
|
+
constructor(url: string, reader: GtxReader);
|
|
23
|
+
/**
|
|
24
|
+
* Request features for one experiment. Fully synchronous — collects the
|
|
25
|
+
* request and returns a promise that resolves when the batch flushes.
|
|
26
|
+
*
|
|
27
|
+
* The flush handles reader.init() internally, so callers do NOT need
|
|
28
|
+
* to await init() before calling this. This is critical: if callers
|
|
29
|
+
* awaited init(), the await would yield and each continuation would
|
|
30
|
+
* resume in a separate microtask, defeating batching.
|
|
31
|
+
*/
|
|
32
|
+
request(experimentId: string, locus: Locus, bpPerPixel: number, signal?: AbortSignal): Promise<WigFeature[]>;
|
|
33
|
+
private flush;
|
|
34
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GTX file reader — binary format for bundled genomic signal data.
|
|
3
|
+
*
|
|
4
|
+
* A GTX file packs multiple experiments (BigWig-equivalent signal tracks) into
|
|
5
|
+
* a single file with:
|
|
6
|
+
* - Tile-based indexing (flat arrays, not R-trees)
|
|
7
|
+
* - zstd dictionary compression for small chunk sizes
|
|
8
|
+
* - Per-experiment metadata
|
|
9
|
+
* - Multi-resolution zoom levels
|
|
10
|
+
*
|
|
11
|
+
* Uses HTTP Range Requests for selective remote access — never downloads
|
|
12
|
+
* the full file.
|
|
13
|
+
*
|
|
14
|
+
* Layer 1 (Data + Layout): no DOM, no canvas.
|
|
15
|
+
*/
|
|
16
|
+
import type { WigFeature } from '../types';
|
|
17
|
+
export interface GtxHeader {
|
|
18
|
+
version: number;
|
|
19
|
+
genome: string;
|
|
20
|
+
nExperiments: number;
|
|
21
|
+
resolution: number;
|
|
22
|
+
payloadEncoding: number;
|
|
23
|
+
nZoomLevels: number;
|
|
24
|
+
chromDirectoryOffset: number;
|
|
25
|
+
experimentMetadataOffset: number;
|
|
26
|
+
dictionaryOffset: number;
|
|
27
|
+
dictionarySize: number;
|
|
28
|
+
zoomDirectoryOffset: number;
|
|
29
|
+
groupStatsDirectoryOffset: number;
|
|
30
|
+
}
|
|
31
|
+
export interface ChromEntry {
|
|
32
|
+
name: string;
|
|
33
|
+
length: number;
|
|
34
|
+
tileIndexOffset: number;
|
|
35
|
+
tileIndexLength: number;
|
|
36
|
+
nTiles: number;
|
|
37
|
+
}
|
|
38
|
+
export interface ExperimentEntry {
|
|
39
|
+
id: string;
|
|
40
|
+
experimentIndex: number;
|
|
41
|
+
metadata: Map<string, string>;
|
|
42
|
+
}
|
|
43
|
+
export interface ExperimentPointer {
|
|
44
|
+
offset: number;
|
|
45
|
+
size: number;
|
|
46
|
+
}
|
|
47
|
+
export interface TileEntry {
|
|
48
|
+
positionsOffset: number;
|
|
49
|
+
positionsSize: number;
|
|
50
|
+
experimentPointers: ExperimentPointer[];
|
|
51
|
+
}
|
|
52
|
+
export interface ZoomLevel {
|
|
53
|
+
reductionLevel: number;
|
|
54
|
+
chromTileIndexes: Map<string, ZoomChromEntry>;
|
|
55
|
+
}
|
|
56
|
+
export interface ZoomChromEntry {
|
|
57
|
+
tileIndexOffset: number;
|
|
58
|
+
tileIndexLength: number;
|
|
59
|
+
nTiles: number;
|
|
60
|
+
}
|
|
61
|
+
export declare class GtxReader {
|
|
62
|
+
private readonly url;
|
|
63
|
+
private header?;
|
|
64
|
+
private dictionary?;
|
|
65
|
+
private dctx?;
|
|
66
|
+
private experiments;
|
|
67
|
+
private experimentIdToIndex;
|
|
68
|
+
private chromosomes;
|
|
69
|
+
private chromOrder;
|
|
70
|
+
private tileIndexCache;
|
|
71
|
+
private zoomLevels;
|
|
72
|
+
private zoomTileIndexCache;
|
|
73
|
+
private initialized;
|
|
74
|
+
private initPromise?;
|
|
75
|
+
constructor(url: string);
|
|
76
|
+
/**
|
|
77
|
+
* Initialize the reader: fetch header, dictionary, experiment metadata,
|
|
78
|
+
* and chromosome directory. Idempotent — safe to call multiple times.
|
|
79
|
+
*
|
|
80
|
+
* Note: init does NOT forward the caller's AbortSignal to avoid a race
|
|
81
|
+
* condition where aborting one track's fetch would leave the shared reader
|
|
82
|
+
* half-initialized (header set but metadata empty), permanently broken
|
|
83
|
+
* for all subsequent callers.
|
|
84
|
+
*/
|
|
85
|
+
init(_signal?: AbortSignal): Promise<void>;
|
|
86
|
+
private _doInit;
|
|
87
|
+
private parseHeader;
|
|
88
|
+
private parseExperimentMetadata;
|
|
89
|
+
private parseChromDirectory;
|
|
90
|
+
private parseZoomDirectory;
|
|
91
|
+
/**
|
|
92
|
+
* Lazily fetch and parse the tile index for a chromosome.
|
|
93
|
+
* Cached after first load.
|
|
94
|
+
*/
|
|
95
|
+
loadTileIndex(chrom: string, signal?: AbortSignal): Promise<TileEntry[]>;
|
|
96
|
+
private loadZoomTileIndex;
|
|
97
|
+
private parseTileIndex;
|
|
98
|
+
/**
|
|
99
|
+
* Read signal data for one or more experiments in a genomic region.
|
|
100
|
+
* Multiple experiments from the same tile are fetched with merged byte ranges.
|
|
101
|
+
*
|
|
102
|
+
* @returns Map from experiment index to WigFeature array
|
|
103
|
+
*/
|
|
104
|
+
readFeatures(chrom: string, start: number, end: number, experimentIndexes: number[], bpPerPixel?: number, signal?: AbortSignal): Promise<Map<number, WigFeature[]>>;
|
|
105
|
+
/**
|
|
106
|
+
* Read zoom-level data for one or more experiments.
|
|
107
|
+
*/
|
|
108
|
+
private readZoomFeatures;
|
|
109
|
+
/** Returns all experiment IDs in this GTX file. */
|
|
110
|
+
getExperimentIds(): string[];
|
|
111
|
+
/** Returns metadata key-value pairs for an experiment, or undefined if not found. */
|
|
112
|
+
getExperimentMetadata(id: string): Map<string, string> | undefined;
|
|
113
|
+
/** Resolve an experiment ID to its numeric index. */
|
|
114
|
+
resolveExperimentIndex(id: string): number | undefined;
|
|
115
|
+
/** Get the parsed header (must call init() first). */
|
|
116
|
+
getHeader(): GtxHeader | undefined;
|
|
117
|
+
/** Get all chromosome entries. */
|
|
118
|
+
getChromosomes(): Map<string, ChromEntry>;
|
|
119
|
+
/**
|
|
120
|
+
* Compute the fetch size for the chrom + zoom directory region.
|
|
121
|
+
*
|
|
122
|
+
* The directories sit at the end of the file, followed only by an 8-byte
|
|
123
|
+
* xxHash64 checksum. We compute the span from known offsets, and the
|
|
124
|
+
* trailing checksum bytes won't affect parsing since directory parsers
|
|
125
|
+
* read a known structure and stop.
|
|
126
|
+
*/
|
|
127
|
+
private computeDirFetchSize;
|
|
128
|
+
/**
|
|
129
|
+
* Select the best zoom level for a given bp/pixel resolution.
|
|
130
|
+
* Returns undefined if full resolution should be used.
|
|
131
|
+
*/
|
|
132
|
+
private selectZoomLevel;
|
|
133
|
+
/**
|
|
134
|
+
* Merge adjacent/nearby byte ranges and fetch, then split back to
|
|
135
|
+
* per-experiment chunks.
|
|
136
|
+
*/
|
|
137
|
+
private fetchMergedRanges;
|
|
138
|
+
/** Decompress a zstd-compressed chunk using the cached dictionary. */
|
|
139
|
+
private decompress;
|
|
140
|
+
/** Read a u64 from BinaryParser (as JavaScript number). */
|
|
141
|
+
private readU64;
|
|
142
|
+
/** Clean up the decompression context. */
|
|
143
|
+
dispose(): void;
|
|
144
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GTX reader — public API.
|
|
3
|
+
*
|
|
4
|
+
* Reads GTX binary files via HTTP range requests and returns
|
|
5
|
+
* WigFeature[] arrays ready for rendering. A single GTX file
|
|
6
|
+
* bundles multiple experiments; the reader is cached per URL
|
|
7
|
+
* and shared across all experiments from the same file.
|
|
8
|
+
*
|
|
9
|
+
* Layer 1 (Data + Layout): no DOM, no canvas.
|
|
10
|
+
*/
|
|
11
|
+
export { GtxReader } from './gtxReader';
|
|
12
|
+
export type { GtxHeader, ChromEntry, ExperimentEntry } from './gtxReader';
|
|
13
|
+
import type { WigFeature, WindowFunction, Locus } from '../types';
|
|
14
|
+
import type { WorkerProvider } from '../workerProvider';
|
|
15
|
+
export interface FetchGtxOptions {
|
|
16
|
+
/** Resolution in base pairs per pixel. Used to select an appropriate zoom level. */
|
|
17
|
+
bpPerPixel?: number;
|
|
18
|
+
/** Aggregation function for zoom-level data. Default: 'mean'. */
|
|
19
|
+
windowFunction?: WindowFunction;
|
|
20
|
+
/** Worker provider for offloading decode work (reserved for future use). */
|
|
21
|
+
workerProvider?: WorkerProvider;
|
|
22
|
+
/** AbortSignal for cancelling in-flight HTTP requests. */
|
|
23
|
+
signal?: AbortSignal;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Fetch GTX features for a single experiment at a genomic locus.
|
|
27
|
+
*/
|
|
28
|
+
export declare function fetchGtxFeatures(url: string, experimentId: string, locus: Locus, options?: FetchGtxOptions): Promise<WigFeature[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Fetch GTX features across all specified chromosomes for whole genome view.
|
|
31
|
+
* Returns features with per-chromosome coordinates (caller transforms to genome-wide).
|
|
32
|
+
*/
|
|
33
|
+
export declare function fetchGtxWGFeatures(url: string, experimentId: string, chromNames: string[], bpPerPixel: number, options?: Pick<FetchGtxOptions, 'windowFunction' | 'workerProvider' | 'signal'>): Promise<WigFeature[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Fetch GTX features for multiple experiments simultaneously.
|
|
36
|
+
* Optimizes network by merging byte ranges for experiments in the same tiles.
|
|
37
|
+
*/
|
|
38
|
+
export declare function fetchGtxMultiFeatures(url: string, experimentIds: string[], locus: Locus, options?: FetchGtxOptions): Promise<Map<string, WigFeature[]>>;
|
|
39
|
+
/** Clear the GTX reader cache (useful for testing or memory management). */
|
|
40
|
+
export declare function clearGtxCache(): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* First-party zstd WASM decompression module.
|
|
3
|
+
*
|
|
4
|
+
* Directly instantiates the zstd WASM binary (from @bokuweb/zstd-wasm, MIT license)
|
|
5
|
+
* without the Emscripten glue code that breaks webpack bundling.
|
|
6
|
+
*
|
|
7
|
+
* Only exposes decompression with dictionary — the minimum needed for GTX.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Initialize the zstd WASM module. Idempotent — safe to call multiple times.
|
|
11
|
+
* Loads the WASM binary from the same directory as this module.
|
|
12
|
+
*/
|
|
13
|
+
export declare function initZstd(): Promise<void>;
|
|
14
|
+
/** Create a decompression context. Returns an opaque handle. */
|
|
15
|
+
export declare function createDCtx(): number;
|
|
16
|
+
/** Free a decompression context. */
|
|
17
|
+
export declare function freeDCtx(dctx: number): void;
|
|
18
|
+
/**
|
|
19
|
+
* Decompress a zstd-compressed buffer using a dictionary.
|
|
20
|
+
* Returns a newly allocated Uint8Array with the decompressed data.
|
|
21
|
+
*/
|
|
22
|
+
export declare function decompressUsingDict(dctx: number, compressed: Uint8Array, dictionary: Uint8Array): Uint8Array;
|