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,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BED format decoders — BED (3-12 columns), narrowPeak, broadPeak, bedGraph, gappedPeak.
|
|
3
|
+
*
|
|
4
|
+
* Port of js/feature/decode/ucsc.ts (decodeBed, decodePeak, decodeNarrowPeak,
|
|
5
|
+
* decodeBedGraph, decodeGappedPeak).
|
|
6
|
+
*
|
|
7
|
+
* Layer 1 (Data + Layout): pure functions, no I/O, no DOM.
|
|
8
|
+
*/
|
|
9
|
+
import type { BedFeature, PeakFeature, BedGraphFeature } from '../types';
|
|
10
|
+
/** Header metadata extracted from track lines and column directives. */
|
|
11
|
+
export interface BedHeader {
|
|
12
|
+
nameField?: string;
|
|
13
|
+
/** When true, column 4 may contain GFF-style key=value attributes. */
|
|
14
|
+
gffTags?: boolean;
|
|
15
|
+
/** Column index for color (from #columns directive). */
|
|
16
|
+
colorColumn?: number;
|
|
17
|
+
/** Column index for thickness (from #columns directive). */
|
|
18
|
+
thicknessColumn?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Decode a BED format line (3-12 columns) into a BedFeature.
|
|
22
|
+
*
|
|
23
|
+
* Port of js/feature/decode/ucsc.ts::decodeBed().
|
|
24
|
+
* Preserves igv.js patterns:
|
|
25
|
+
* - Column count gating with maxColumnCount
|
|
26
|
+
* - GFF-style attribute parsing in col4 when contains `=` and `;`
|
|
27
|
+
* - Exon block validation (count < 1000, sizes.length === starts.length === count)
|
|
28
|
+
* - Early return on parse errors (partial feature returned, not rejected)
|
|
29
|
+
* - Color parsing for col8 (skip "." and "0")
|
|
30
|
+
*/
|
|
31
|
+
export declare function decodeBed(tokens: string[], header?: BedHeader, maxColumnCount?: number): BedFeature | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Decode a broadPeak/regionPeak format line (BED6+3: signal, pValue, qValue).
|
|
34
|
+
*
|
|
35
|
+
* Port of js/feature/decode/ucsc.ts::decodePeak().
|
|
36
|
+
*/
|
|
37
|
+
export declare function decodeBroadPeak(tokens: string[], header?: BedHeader): PeakFeature | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Decode a narrowPeak format line (BED6+4: signal, pValue, qValue, peak).
|
|
40
|
+
*
|
|
41
|
+
* Port of js/feature/decode/ucsc.ts::decodeNarrowPeak().
|
|
42
|
+
*/
|
|
43
|
+
export declare function decodeNarrowPeak(tokens: string[], header?: BedHeader): PeakFeature | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Decode a gappedPeak format line (BED12+3: signal, pValue, qValue).
|
|
46
|
+
*
|
|
47
|
+
* Port of js/feature/decode/ucsc.ts::decodeGappedPeak().
|
|
48
|
+
*/
|
|
49
|
+
export declare function decodeGappedPeak(tokens: string[], header?: BedHeader): PeakFeature | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Decode a BedGraph line (chr, start, end, value).
|
|
52
|
+
*
|
|
53
|
+
* Port of js/feature/decode/ucsc.ts::decodeBedGraph().
|
|
54
|
+
*/
|
|
55
|
+
export declare function decodeBedGraph(tokens: string[]): BedGraphFeature | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Decode a refFlat format line.
|
|
58
|
+
*
|
|
59
|
+
* Format: geneName, name, chrom, strand, txStart, txEnd, cdsStart, cdsEnd,
|
|
60
|
+
* exonCount, exonStarts, exonEnds
|
|
61
|
+
*
|
|
62
|
+
* Port of js/feature/decode/ucsc.ts::decodeReflat().
|
|
63
|
+
*/
|
|
64
|
+
export declare function decodeRefflat(tokens: string[]): BedFeature | undefined;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BEDPE format decoder — pairwise genomic interactions (Hi-C, ChIA-PET, SVs).
|
|
3
|
+
*
|
|
4
|
+
* Standard BEDPE: 10+ columns (chr1/start1/end1/chr2/start2/end2/name/score/strand1/strand2).
|
|
5
|
+
* Variants: 7-column (score in name column), hiccups (6 standard + extra columns).
|
|
6
|
+
*
|
|
7
|
+
* Port of js/feature/decode/bedpe.ts.
|
|
8
|
+
* Layer 1 (Data + Layout): pure functions, no I/O, no DOM.
|
|
9
|
+
*/
|
|
10
|
+
import type { InteractionFeature } from '../types';
|
|
11
|
+
/** Header metadata for BEDPE files. */
|
|
12
|
+
export interface BedpeHeader {
|
|
13
|
+
/** Whether this is a hiccups-format file (auto-detected on first feature). */
|
|
14
|
+
hiccups?: boolean;
|
|
15
|
+
/** Column names from header line. */
|
|
16
|
+
columnNames?: string[];
|
|
17
|
+
/** Column index for per-feature color. */
|
|
18
|
+
colorColumn?: number;
|
|
19
|
+
/** Column index for per-feature line thickness. */
|
|
20
|
+
thicknessColumn?: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Decode a single BEDPE line into an InteractionFeature.
|
|
24
|
+
*
|
|
25
|
+
* Handles standard 10-column BEDPE and hiccups variants.
|
|
26
|
+
* Returns undefined for unparseable lines.
|
|
27
|
+
*/
|
|
28
|
+
export declare function decodeBedpe(tokens: string[], header?: BedpeHeader): InteractionFeature | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Post-process BEDPE features:
|
|
31
|
+
* 1. Auto-detect score in name column (non-standard 7-col variant).
|
|
32
|
+
* 2. Duplicate inter-chromosome features so each chromosome has a copy.
|
|
33
|
+
*/
|
|
34
|
+
export declare function fixBedPE(features: InteractionFeature[]): void;
|
|
35
|
+
/** Detect hiccups format from column headers. */
|
|
36
|
+
export declare function isHiccups(columns: string[]): boolean;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared exon and feature utilities used by multiple decoders (BED, genePred, GFF).
|
|
3
|
+
*
|
|
4
|
+
* Layer 1 (Data + Layout): pure functions, no I/O, no DOM.
|
|
5
|
+
*/
|
|
6
|
+
import type { Exon } from '../types';
|
|
7
|
+
/**
|
|
8
|
+
* Mark UTR exons and partial UTR boundaries.
|
|
9
|
+
*
|
|
10
|
+
* For non-coding transcripts (cdStart === cdEnd), all exons are marked as UTR.
|
|
11
|
+
* For coding transcripts, exons entirely outside the CDS are marked as UTR,
|
|
12
|
+
* and exons overlapping CDS boundaries get cdStart/cdEnd set.
|
|
13
|
+
*
|
|
14
|
+
* Port of js/feature/decode/ucsc.ts::findUTRs.
|
|
15
|
+
*/
|
|
16
|
+
export declare function findUTRs(exons: Exon[], cdStart: number, cdEnd: number): void;
|
|
17
|
+
/**
|
|
18
|
+
* Parse a color value from a BED column (comma-separated RGB or hex) into a CSS color string.
|
|
19
|
+
*
|
|
20
|
+
* Accepts:
|
|
21
|
+
* - "r,g,b" (e.g. "255,0,0" → "rgb(255,0,0)")
|
|
22
|
+
* - "#RRGGBB" or "#RGB" (returned as-is)
|
|
23
|
+
* - "." or "0" → returns undefined (no color)
|
|
24
|
+
*
|
|
25
|
+
* Port of igv.js IGVColor.createColorString() for the subset used by BED format.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseColorString(value: string): string | undefined;
|
|
28
|
+
/** Parse a strand character to a typed strand value. */
|
|
29
|
+
export declare function parseStrand(s: string): '+' | '-' | undefined;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GFF3/GTF format decoders and transcript assembly.
|
|
3
|
+
*
|
|
4
|
+
* Ports:
|
|
5
|
+
* - js/feature/gff/gff.ts (decodeGFF3, decodeGTF)
|
|
6
|
+
* - js/feature/gff/parseAttributeString.ts (parseAttributeString, decodeGFFAttribute)
|
|
7
|
+
* - js/feature/gff/gffHelper.ts (combineFeatures — transcript assembly)
|
|
8
|
+
* - js/feature/gff/so.ts (sequence ontology type checks)
|
|
9
|
+
*
|
|
10
|
+
* Layer 1 (Data + Layout): pure functions, no I/O, no DOM.
|
|
11
|
+
*/
|
|
12
|
+
import type { GFFRecord, GFFFeature } from '../types';
|
|
13
|
+
export declare function isTranscript(type: string): boolean;
|
|
14
|
+
export declare function isTranscriptPart(type: string): boolean;
|
|
15
|
+
export declare function isExon(type: string): boolean;
|
|
16
|
+
export declare function isIntron(type: string): boolean;
|
|
17
|
+
export declare function isCoding(type: string): boolean;
|
|
18
|
+
export declare function isUTR(type: string): boolean;
|
|
19
|
+
/** Decode GFF3 percent-encoded characters. */
|
|
20
|
+
export declare function decodeGFFAttribute(str: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Parse GFF/GTF attribute string (column 9) into key-value pairs.
|
|
23
|
+
*
|
|
24
|
+
* Returns an array (not a map) because attribute keys are not required to be unique.
|
|
25
|
+
* GFF3 uses `=` as key-value delimiter, GTF uses space.
|
|
26
|
+
*
|
|
27
|
+
* Port of js/feature/gff/parseAttributeString.ts::parseAttributeString().
|
|
28
|
+
*/
|
|
29
|
+
export declare function parseGFFAttributes(attributeString: string, keyValueDelim?: string): Array<[string, string]>;
|
|
30
|
+
/**
|
|
31
|
+
* Decode a single GFF3 record line.
|
|
32
|
+
*
|
|
33
|
+
* Parses column 9 attributes with `=` delimiter, extracts ID, Parent, color.
|
|
34
|
+
*/
|
|
35
|
+
export declare function decodeGFF3(tokens: string[]): GFFRecord | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Decode a single GTF record line.
|
|
38
|
+
*
|
|
39
|
+
* Parses column 9 attributes with space delimiter, infers ID/Parent from
|
|
40
|
+
* feature type (gene→gene_id, transcript→transcript_id, exon→transcript_id parent).
|
|
41
|
+
*/
|
|
42
|
+
export declare function decodeGTF(tokens: string[]): GFFRecord | undefined;
|
|
43
|
+
interface AssemblyOptions {
|
|
44
|
+
/** Custom name field to use for feature names. */
|
|
45
|
+
nameField?: string;
|
|
46
|
+
/** Feature types to filter out (default: ['chromosome']). */
|
|
47
|
+
filterTypes?: string[];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Assemble flat GFFRecords into hierarchical GFFFeatures (transcripts with exon structure).
|
|
51
|
+
*
|
|
52
|
+
* Combines gene→transcript→exon/CDS records by parent/ID relationships.
|
|
53
|
+
* Handles both GFF3 (explicit ID/Parent) and GTF (inferred from feature type).
|
|
54
|
+
*
|
|
55
|
+
* Port of js/feature/gff/gffHelper.ts::combineFeatures().
|
|
56
|
+
*/
|
|
57
|
+
export declare function assembleGFFTranscripts(records: GFFRecord[], format: 'gff3' | 'gtf' | 'gff', options?: AssemblyOptions): GFFFeature[];
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UCSC interact format decoder — 18-column pairwise genomic interactions.
|
|
3
|
+
*
|
|
4
|
+
* See https://genome.ucsc.edu/goldenpath/help/interact.html
|
|
5
|
+
*
|
|
6
|
+
* Columns: chrom, chromStart, chromEnd, name, score, value, exp, color,
|
|
7
|
+
* sourceChrom, sourceStart, sourceEnd, sourceName, sourceStrand,
|
|
8
|
+
* targetChrom, targetStart, targetEnd, targetName, targetStrand
|
|
9
|
+
*
|
|
10
|
+
* Port of js/feature/decode/interact.ts.
|
|
11
|
+
* Layer 1 (Data + Layout): pure functions, no I/O, no DOM.
|
|
12
|
+
*/
|
|
13
|
+
import type { InteractionFeature } from '../types';
|
|
14
|
+
/**
|
|
15
|
+
* Decode a single UCSC interact format line into an InteractionFeature.
|
|
16
|
+
*
|
|
17
|
+
* Returns undefined for lines with fewer than 6 columns.
|
|
18
|
+
*/
|
|
19
|
+
export declare function decodeInteract(tokens: string[]): InteractionFeature | undefined;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UCSC gene prediction format decoders.
|
|
3
|
+
*
|
|
4
|
+
* Ported from js/feature/decode/ucsc.ts — handles genePred, genePredExt,
|
|
5
|
+
* and refGene formats. These are the formats used by UCSC genome browser
|
|
6
|
+
* for gene annotations (ncbiRefSeq, knownGene, etc.).
|
|
7
|
+
*/
|
|
8
|
+
import type { AnnotationFeature } from '../types';
|
|
9
|
+
/**
|
|
10
|
+
* Decode a UCSC "genePred" record (basic gene prediction format).
|
|
11
|
+
*
|
|
12
|
+
* Column layout (no bin): name, chrom, strand, txStart, txEnd, cdsStart, cdsEnd,
|
|
13
|
+
* exonCount, exonStarts, exonEnds
|
|
14
|
+
* Column layout (with bin): bin, name, chrom, strand, txStart, txEnd, cdsStart, cdsEnd,
|
|
15
|
+
* exonCount, exonStarts, exonEnds, score, name2
|
|
16
|
+
*
|
|
17
|
+
* @param tokens - Tab-split fields from a single line
|
|
18
|
+
* @param shift - 1 if the record has a leading `bin` column (refGene), 0 otherwise
|
|
19
|
+
*/
|
|
20
|
+
export declare function decodeGenePred(tokens: string[], shift?: 0 | 1): AnnotationFeature | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Decode a UCSC "genePredExt" record. refGene files are in this format.
|
|
23
|
+
*
|
|
24
|
+
* Same as genePred but with additional columns:
|
|
25
|
+
* ..., score, name2, cdsStartStat, cdsEndStat, exonFrames
|
|
26
|
+
*
|
|
27
|
+
* @param tokens - Tab-split fields from a single line
|
|
28
|
+
* @param shift - 1 if the record has a leading `bin` column (refGene), 0 otherwise
|
|
29
|
+
*/
|
|
30
|
+
export declare function decodeGenePredExt(tokens: string[], shift?: 0 | 1): AnnotationFeature | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Decode a UCSC REST API JSON record into a AnnotationFeature.
|
|
33
|
+
*
|
|
34
|
+
* The UCSC API returns JSON objects with the same fields as the text format
|
|
35
|
+
* but as named properties instead of positional columns.
|
|
36
|
+
*/
|
|
37
|
+
export declare function decodeRefGeneJson(rec: RefGeneRecord): AnnotationFeature;
|
|
38
|
+
/** Shape of a record returned by the UCSC REST API for ncbiRefSeq/refGene tracks. */
|
|
39
|
+
export interface RefGeneRecord {
|
|
40
|
+
bin?: number;
|
|
41
|
+
name: string;
|
|
42
|
+
name2: string;
|
|
43
|
+
chrom: string;
|
|
44
|
+
strand: string;
|
|
45
|
+
txStart: number;
|
|
46
|
+
txEnd: number;
|
|
47
|
+
cdsStart: number;
|
|
48
|
+
cdsEnd: number;
|
|
49
|
+
exonCount: number;
|
|
50
|
+
exonStarts: string;
|
|
51
|
+
exonEnds: string;
|
|
52
|
+
score?: number;
|
|
53
|
+
cdsStartStat?: string;
|
|
54
|
+
cdsEndStat?: string;
|
|
55
|
+
exonFrames?: string;
|
|
56
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dynamic sequence (dynseq) renderer for wig tracks.
|
|
3
|
+
*
|
|
4
|
+
* Renders DNA base letters (A, C, G, T, N) as filled glyphs whose height
|
|
5
|
+
* is proportional to the wig signal value. Only activates at high zoom
|
|
6
|
+
* (bpPerPixel < 2) where individual bases are resolvable.
|
|
7
|
+
*
|
|
8
|
+
* Ported from js/feature/wigTrack.ts renderDynSeq/drawLetterGlyph/drawSVGPath.
|
|
9
|
+
*/
|
|
10
|
+
/** Default nucleotide color scheme matching igv.js. */
|
|
11
|
+
export declare const defaultNucleotideColors: Readonly<Record<string, string>>;
|
|
12
|
+
/**
|
|
13
|
+
* Draw a single DNA base letter as a filled glyph.
|
|
14
|
+
*
|
|
15
|
+
* @param ctx - Canvas context
|
|
16
|
+
* @param base - The base character (A, C, G, T, N)
|
|
17
|
+
* @param x - Left edge pixel position
|
|
18
|
+
* @param y - Top edge pixel position
|
|
19
|
+
* @param width - Glyph width in pixels
|
|
20
|
+
* @param height - Glyph height in pixels
|
|
21
|
+
* @param color - Fill color
|
|
22
|
+
* @param flipVertical - Flip the glyph vertically (for negative values)
|
|
23
|
+
*/
|
|
24
|
+
export declare function drawLetterGlyph(ctx: CanvasRenderingContext2D, base: string, x: number, y: number, width: number, height: number, color: string, flipVertical?: boolean): void;
|
|
25
|
+
/**
|
|
26
|
+
* Render a single wig feature as dynseq (DNA base glyphs scaled by value).
|
|
27
|
+
*
|
|
28
|
+
* @param ctx - Canvas context
|
|
29
|
+
* @param sequence - DNA sequence string for this feature's region
|
|
30
|
+
* @param x - Left edge pixel position of the feature
|
|
31
|
+
* @param width - Pixel width of the feature
|
|
32
|
+
* @param y - Y pixel of the data value
|
|
33
|
+
* @param y0 - Y pixel of the zero line
|
|
34
|
+
* @param value - The wig data value (for determining negative/flip)
|
|
35
|
+
* @param colors - Nucleotide color map
|
|
36
|
+
*/
|
|
37
|
+
export declare function renderDynSeqFeature(ctx: CanvasRenderingContext2D, sequence: string, x: number, width: number, y: number, y0: number, value: number, colors?: Readonly<Record<string, string>>): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight typed event emitter.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* type Events = { locuschange: { locus: Locus }; zoom: { factor: number } }
|
|
6
|
+
* const emitter = new EventEmitter<Events>()
|
|
7
|
+
* const unsub = emitter.on('locuschange', data => console.log(data.locus))
|
|
8
|
+
* emitter.emit('locuschange', { locus: { chr: 'chr1', start: 0, end: 1000 } })
|
|
9
|
+
* unsub()
|
|
10
|
+
*/
|
|
11
|
+
type Handler<T> = (data: T) => void;
|
|
12
|
+
export declare class EventEmitter<EventMap extends object> {
|
|
13
|
+
private listeners;
|
|
14
|
+
/** Subscribe to an event. Returns an unsubscribe function. */
|
|
15
|
+
on<K extends keyof EventMap>(event: K, handler: Handler<EventMap[K]>): () => void;
|
|
16
|
+
/** Unsubscribe a specific handler, or all handlers for an event. */
|
|
17
|
+
off<K extends keyof EventMap>(event: K, handler?: Handler<EventMap[K]>): void;
|
|
18
|
+
/** Emit an event to all subscribers. */
|
|
19
|
+
emit<K extends keyof EventMap>(event: K, data: EventMap[K]): void;
|
|
20
|
+
/** Remove all listeners for all events. */
|
|
21
|
+
removeAllListeners(): void;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canvas2SVG — A Canvas-to-SVG rendering context.
|
|
3
|
+
*
|
|
4
|
+
* Implements the CanvasRenderingContext2D interface but builds an SVG document
|
|
5
|
+
* instead of rasterizing to pixels. Drop-in replacement for Canvas2D context
|
|
6
|
+
* in our stateless renderers.
|
|
7
|
+
*
|
|
8
|
+
* Port of Canvas 2 SVG v1.0.19 (MIT license, Kerry Liu / Gliffy Inc. 2014)
|
|
9
|
+
* from js/canvas2svg.ts with full TypeScript typing.
|
|
10
|
+
*
|
|
11
|
+
* Layer 1 utility — no DOM attachment, no track logic.
|
|
12
|
+
*/
|
|
13
|
+
/** Configuration for creating a Canvas2SVG context. */
|
|
14
|
+
export interface C2SConfig {
|
|
15
|
+
width?: number;
|
|
16
|
+
height?: number;
|
|
17
|
+
enableMirroring?: boolean;
|
|
18
|
+
ctx?: CanvasRenderingContext2D;
|
|
19
|
+
viewbox?: ViewBox;
|
|
20
|
+
backdropColor?: string;
|
|
21
|
+
}
|
|
22
|
+
interface ViewBox {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
}
|
|
28
|
+
/** Extra methods provided by Canvas2SVG beyond the standard CanvasRenderingContext2D API. */
|
|
29
|
+
export interface C2SVGExtensions {
|
|
30
|
+
/** Flag indicating this is an SVG rendering context. */
|
|
31
|
+
isSVG: boolean;
|
|
32
|
+
/** Create a clipped, translated group (used for per-track viewport rendering). */
|
|
33
|
+
saveWithTranslationAndClipRect(id: string, tx: number, ty: number, width: number, height: number, clipYOffset: number): void;
|
|
34
|
+
/** Update the SVG document height and viewBox. */
|
|
35
|
+
setHeight(height: number): void;
|
|
36
|
+
/** Serialize the SVG DOM tree to an XML string. */
|
|
37
|
+
getSerializedSvg(fixNamedEntities: boolean): string;
|
|
38
|
+
/** Stroke an ellipse element (SVG native, not path-based). */
|
|
39
|
+
strokeEllipse(cx: number, cy: number, rx: number, ry: number, rotation: number, startAngle: number, endAngle: number, isCCW?: boolean): void;
|
|
40
|
+
/** Fill an ellipse element (SVG native, not path-based). */
|
|
41
|
+
fillEllipse(cx: number, cy: number, rx: number, ry: number, rotation: number, startAngle: number, endAngle: number, isCCW?: boolean): void;
|
|
42
|
+
}
|
|
43
|
+
/** A Canvas2SVG context: implements CanvasRenderingContext2D plus SVG-specific extensions. */
|
|
44
|
+
export type C2SContext = CanvasRenderingContext2D & C2SVGExtensions;
|
|
45
|
+
declare class SVGCanvasGradient {
|
|
46
|
+
__root: SVGElement;
|
|
47
|
+
__ctx: C2S;
|
|
48
|
+
constructor(gradientNode: SVGElement, ctx: C2S);
|
|
49
|
+
addColorStop(offset: number, color: string): void;
|
|
50
|
+
}
|
|
51
|
+
declare class SVGCanvasPattern {
|
|
52
|
+
__root: SVGElement;
|
|
53
|
+
__ctx: C2S;
|
|
54
|
+
constructor(pattern: SVGElement, ctx: C2S);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Canvas2SVG rendering context.
|
|
58
|
+
*
|
|
59
|
+
* Implements the subset of CanvasRenderingContext2D that our renderers use,
|
|
60
|
+
* plus SVG-specific extensions (saveWithTranslationAndClipRect, setHeight,
|
|
61
|
+
* getSerializedSvg, stroke/fillEllipse).
|
|
62
|
+
*
|
|
63
|
+
* Usage:
|
|
64
|
+
* const ctx = new C2S({ width: 800, height: 600 })
|
|
65
|
+
* // ... draw using standard Canvas2D API ...
|
|
66
|
+
* const svgString = ctx.getSerializedSvg(true)
|
|
67
|
+
*/
|
|
68
|
+
export declare class C2S {
|
|
69
|
+
readonly isSVG = true;
|
|
70
|
+
width: number;
|
|
71
|
+
height: number;
|
|
72
|
+
canvas: C2S;
|
|
73
|
+
private config;
|
|
74
|
+
private enableMirroring;
|
|
75
|
+
private viewbox;
|
|
76
|
+
private __canvas;
|
|
77
|
+
private __ctx;
|
|
78
|
+
private __document;
|
|
79
|
+
__root: SVGElement;
|
|
80
|
+
private __defs;
|
|
81
|
+
private __rootGroup;
|
|
82
|
+
private __currentElement;
|
|
83
|
+
private __currentElementsToStyle;
|
|
84
|
+
private __ids;
|
|
85
|
+
private __stack;
|
|
86
|
+
private __groupStack;
|
|
87
|
+
private __currentDefaultPath;
|
|
88
|
+
private __currentPosition;
|
|
89
|
+
strokeStyle: string | CanvasGradient | CanvasPattern;
|
|
90
|
+
fillStyle: string | CanvasGradient | CanvasPattern;
|
|
91
|
+
lineCap: CanvasLineCap;
|
|
92
|
+
lineJoin: CanvasLineJoin;
|
|
93
|
+
miterLimit: number;
|
|
94
|
+
lineWidth: number;
|
|
95
|
+
globalAlpha: number;
|
|
96
|
+
font: string;
|
|
97
|
+
shadowColor: string;
|
|
98
|
+
shadowOffsetX: number;
|
|
99
|
+
shadowOffsetY: number;
|
|
100
|
+
shadowBlur: number;
|
|
101
|
+
textAlign: CanvasTextAlign;
|
|
102
|
+
textBaseline: CanvasTextBaseline;
|
|
103
|
+
lineDash: string | null;
|
|
104
|
+
private __fontUnderline;
|
|
105
|
+
private __fontHref;
|
|
106
|
+
constructor(config?: C2SConfig);
|
|
107
|
+
setWidth(width: number): void;
|
|
108
|
+
setHeight(height: number): void;
|
|
109
|
+
__createElement(elementName: string, properties?: Record<string, string | number>, resetFill?: boolean): SVGElement;
|
|
110
|
+
private __setDefaultStyles;
|
|
111
|
+
private __applyStyleState;
|
|
112
|
+
private __getStyleState;
|
|
113
|
+
private __applyStyleToCurrentElement;
|
|
114
|
+
private __closestGroupOrSvg;
|
|
115
|
+
getSerializedSvg(fixNamedEntities: boolean): string;
|
|
116
|
+
getSvg(): SVGElement;
|
|
117
|
+
saveWithTranslationAndClipRect(id: string, tx: number, ty: number, width: number, height: number, clipYOffset: number): void;
|
|
118
|
+
save(): void;
|
|
119
|
+
restore(): void;
|
|
120
|
+
private __addTransform;
|
|
121
|
+
scale(x: number, y?: number): void;
|
|
122
|
+
rotate(angle: number): void;
|
|
123
|
+
translate(x: number, y: number): void;
|
|
124
|
+
transform(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
|
125
|
+
beginPath(): void;
|
|
126
|
+
private __applyCurrentDefaultPath;
|
|
127
|
+
private __addPathCommand;
|
|
128
|
+
moveTo(x: number, y: number): void;
|
|
129
|
+
closePath(): void;
|
|
130
|
+
lineTo(x: number, y: number): void;
|
|
131
|
+
bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void;
|
|
132
|
+
quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
|
|
133
|
+
roundRect(x: number, y: number, w: number, h: number, radii?: number | number[]): void;
|
|
134
|
+
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void;
|
|
135
|
+
stroke(): void;
|
|
136
|
+
fill(): void;
|
|
137
|
+
rect(x: number, y: number, width: number, height: number): void;
|
|
138
|
+
fillRect(x: number, y: number, width: number, height: number): void;
|
|
139
|
+
strokeRect(x: number, y: number, width: number, height: number): void;
|
|
140
|
+
strokeEllipse(cx: number, cy: number, rx: number, ry: number, _rotation: number, _startAngle: number, _endAngle: number, _isCCW?: boolean): void;
|
|
141
|
+
fillEllipse(cx: number, cy: number, rx: number, ry: number, _rotation: number, _startAngle: number, _endAngle: number, _isCCW?: boolean): void;
|
|
142
|
+
private __ellipse;
|
|
143
|
+
private __clearCanvas;
|
|
144
|
+
clearRect(x: number, y: number, width: number, height: number): void;
|
|
145
|
+
createLinearGradient(x1: number, y1: number, x2: number, y2: number): SVGCanvasGradient;
|
|
146
|
+
createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): SVGCanvasGradient;
|
|
147
|
+
private __parseFont;
|
|
148
|
+
private __wrapTextLink;
|
|
149
|
+
private __applyText;
|
|
150
|
+
fillText(text: string, x: number, y: number): void;
|
|
151
|
+
strokeText(text: string, x: number, y: number): void;
|
|
152
|
+
measureText(text: string): TextMetrics;
|
|
153
|
+
arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, counterClockwise?: boolean): void;
|
|
154
|
+
clip(): void;
|
|
155
|
+
drawImage(image: CanvasImageSource | C2S, ...args: number[]): void;
|
|
156
|
+
createPattern(image: HTMLCanvasElement | HTMLImageElement | C2S, _repetition: string | null): SVGCanvasPattern;
|
|
157
|
+
setLineDash(dashArray: number[]): void;
|
|
158
|
+
getLineDash(): number[];
|
|
159
|
+
drawFocusIfNeeded(): void;
|
|
160
|
+
createImageData(): ImageData;
|
|
161
|
+
getImageData(): ImageData;
|
|
162
|
+
putImageData(): void;
|
|
163
|
+
setTransform(): void;
|
|
164
|
+
globalCompositeOperation: GlobalCompositeOperation;
|
|
165
|
+
}
|
|
166
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feature cache with interval-tree-backed spatial queries.
|
|
3
|
+
*
|
|
4
|
+
* Port of igv.js `js/feature/featureCache.ts`. Features are grouped by
|
|
5
|
+
* chromosome, sorted, chunked, and indexed via IntervalTree for O(log n + k)
|
|
6
|
+
* range queries.
|
|
7
|
+
*
|
|
8
|
+
* Layer 1 (Data + Layout) — pure data structure, no DOM, no canvas.
|
|
9
|
+
*/
|
|
10
|
+
import { IntervalTree } from './intervalTree';
|
|
11
|
+
/** Minimal interface for features stored in the cache. */
|
|
12
|
+
export interface CacheableFeature {
|
|
13
|
+
chr: string;
|
|
14
|
+
start: number;
|
|
15
|
+
end: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Range metadata describing what genomic region is fully cached.
|
|
19
|
+
* When present, `containsRange()` delegates to this; when absent,
|
|
20
|
+
* the cache is assumed to contain all features (e.g., whole-file load).
|
|
21
|
+
*/
|
|
22
|
+
export interface CacheRange {
|
|
23
|
+
contains(chr: string, start: number, end: number): boolean;
|
|
24
|
+
}
|
|
25
|
+
/** Index range pointing into the sorted allFeatures[chr] array. */
|
|
26
|
+
interface IndexRange {
|
|
27
|
+
start: number;
|
|
28
|
+
end: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Spatial feature cache backed by per-chromosome interval trees.
|
|
32
|
+
*
|
|
33
|
+
* Features are chunked (max(10, len/10) per chunk) to reduce tree size
|
|
34
|
+
* while maintaining fast overlap queries. Matches igv.js FeatureCache.
|
|
35
|
+
*
|
|
36
|
+
* @typeParam F - Feature type, must have chr/start/end at minimum.
|
|
37
|
+
*/
|
|
38
|
+
export declare class FeatureCache<F extends CacheableFeature> {
|
|
39
|
+
/** Per-chromosome interval trees indexing feature chunks. */
|
|
40
|
+
readonly treeMap: Record<string, IntervalTree<IndexRange>>;
|
|
41
|
+
/** Optional range metadata for partial-cache validation. */
|
|
42
|
+
readonly range: CacheRange | undefined;
|
|
43
|
+
/** Total number of cached features across all chromosomes. */
|
|
44
|
+
readonly count: number;
|
|
45
|
+
/** All features grouped by chromosome, sorted by start. */
|
|
46
|
+
readonly allFeatures: Record<string, F[]>;
|
|
47
|
+
constructor(featureList?: F[], range?: CacheRange);
|
|
48
|
+
/**
|
|
49
|
+
* Check if the cache covers a genomic range.
|
|
50
|
+
* Returns true when no range metadata is set (cache assumed complete)
|
|
51
|
+
* or when the range metadata confirms coverage.
|
|
52
|
+
*/
|
|
53
|
+
containsRange(chr: string, start: number, end: number): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Query features overlapping [start, end] on the given chromosome.
|
|
56
|
+
* Returns features sorted by start position. O(log n + k) via interval tree.
|
|
57
|
+
*/
|
|
58
|
+
queryFeatures(chr: string, start: number, end: number): F[];
|
|
59
|
+
/**
|
|
60
|
+
* Search all cached features matching a predicate.
|
|
61
|
+
* Scans every feature across all chromosomes — O(n).
|
|
62
|
+
*/
|
|
63
|
+
findFeatures(fn: (f: F) => boolean): F[];
|
|
64
|
+
/**
|
|
65
|
+
* Returns all features grouped by chromosome.
|
|
66
|
+
*/
|
|
67
|
+
getAllFeatures(): Record<string, F[]>;
|
|
68
|
+
}
|
|
69
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feature parser — lines → typed features.
|
|
3
|
+
*
|
|
4
|
+
* Dispatches to format-specific decoders based on format string. Handles
|
|
5
|
+
* header parsing, comment skipping, delimiter selection, and GFF assembly.
|
|
6
|
+
*
|
|
7
|
+
* Port of js/feature/featureParser.ts.
|
|
8
|
+
*
|
|
9
|
+
* Layer 1 (Data + Layout): pure functions, no I/O, no DOM.
|
|
10
|
+
*/
|
|
11
|
+
import type { BedFeature, PeakFeature, BedGraphFeature, GFFRecord, GFFFeature, InteractionFeature, TextFileFormat } from '../types';
|
|
12
|
+
/** Decoder function type — takes tokens from a split line, returns a feature or undefined. */
|
|
13
|
+
export type DecoderFunction = (tokens: string[], header?: Record<string, unknown>) => unknown | undefined;
|
|
14
|
+
/** Header metadata extracted from track lines, column directives, and format directives. */
|
|
15
|
+
export interface FeatureHeader {
|
|
16
|
+
format?: string;
|
|
17
|
+
nameField?: string;
|
|
18
|
+
gffTags?: boolean;
|
|
19
|
+
columnNames?: string[];
|
|
20
|
+
colorColumn?: number;
|
|
21
|
+
thicknessColumn?: number;
|
|
22
|
+
/** Properties parsed from track lines. */
|
|
23
|
+
properties?: Record<string, string>;
|
|
24
|
+
/** Wig step/span directive state (for fixedStep/variableStep). */
|
|
25
|
+
wig?: WigDirective;
|
|
26
|
+
/** Column shift (1 for refgene/ensgene formats). */
|
|
27
|
+
shift?: number;
|
|
28
|
+
}
|
|
29
|
+
interface WigDirective {
|
|
30
|
+
format: string;
|
|
31
|
+
chrom: string;
|
|
32
|
+
start?: number;
|
|
33
|
+
step?: number;
|
|
34
|
+
span: number;
|
|
35
|
+
index?: number;
|
|
36
|
+
}
|
|
37
|
+
interface DecoderInfo {
|
|
38
|
+
decode: (tokens: string[], header: FeatureHeader) => unknown | undefined;
|
|
39
|
+
delimiter: string | RegExp;
|
|
40
|
+
/** Whether parsed features need GFF transcript assembly. */
|
|
41
|
+
requiresAssembly: boolean;
|
|
42
|
+
/** Optional post-processing of all decoded features (e.g., BEDPE fixup). */
|
|
43
|
+
postProcess?: (features: any[]) => void;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get the appropriate decoder function and delimiter for a format string.
|
|
47
|
+
*
|
|
48
|
+
* Port of js/feature/featureParser.ts::setDecoder().
|
|
49
|
+
*/
|
|
50
|
+
export declare function getDecoder(format: TextFileFormat, _header?: FeatureHeader): DecoderInfo;
|
|
51
|
+
/**
|
|
52
|
+
* Parse header information from text lines.
|
|
53
|
+
*
|
|
54
|
+
* Extracts track line properties, column names, format directives
|
|
55
|
+
* (#gffTags, ##gff-version 3, etc.).
|
|
56
|
+
*
|
|
57
|
+
* Port of js/feature/featureParser.ts::parseHeader().
|
|
58
|
+
*/
|
|
59
|
+
export declare function parseHeader(lines: string[], format: TextFileFormat): FeatureHeader;
|
|
60
|
+
/**
|
|
61
|
+
* Parse text lines into features for a given format.
|
|
62
|
+
*
|
|
63
|
+
* Handles: comment/header skipping, delimiter-based tokenization,
|
|
64
|
+
* WIG directive parsing, GFF transcript assembly.
|
|
65
|
+
*
|
|
66
|
+
* Port of js/feature/featureParser.ts::parseFeatures().
|
|
67
|
+
*/
|
|
68
|
+
export declare function parseFeatures(lines: string[], format: TextFileFormat, options?: {
|
|
69
|
+
header?: FeatureHeader;
|
|
70
|
+
assembleGFF?: boolean;
|
|
71
|
+
}): Array<BedFeature | PeakFeature | BedGraphFeature | GFFFeature | GFFRecord | InteractionFeature>;
|
|
72
|
+
export {};
|