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,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Augmented red-black interval tree for efficient overlap queries.
|
|
3
|
+
*
|
|
4
|
+
* Port of igv.js `js/intervalTree.ts` (CLR-based implementation).
|
|
5
|
+
* Typed generically — values stored in intervals are `T` instead of `unknown`.
|
|
6
|
+
*
|
|
7
|
+
* Each node stores augmented min/max for its subtree, enabling O(log n + k)
|
|
8
|
+
* overlap queries via subtree pruning.
|
|
9
|
+
*
|
|
10
|
+
* Layer 1 (Data + Layout) — pure data structure, no DOM, no canvas.
|
|
11
|
+
*/
|
|
12
|
+
/** An interval with an associated value. */
|
|
13
|
+
export interface Interval<T = unknown> {
|
|
14
|
+
low: number;
|
|
15
|
+
high: number;
|
|
16
|
+
value: T;
|
|
17
|
+
}
|
|
18
|
+
interface TreeNode<T> {
|
|
19
|
+
color: number;
|
|
20
|
+
parent: TreeNode<T>;
|
|
21
|
+
left: TreeNode<T>;
|
|
22
|
+
right: TreeNode<T>;
|
|
23
|
+
interval: Interval<T>;
|
|
24
|
+
/** Augmented: maximum high value in this subtree. */
|
|
25
|
+
max: number;
|
|
26
|
+
/** Augmented: minimum low value in this subtree. */
|
|
27
|
+
min: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Augmented red-black interval tree.
|
|
31
|
+
*
|
|
32
|
+
* Public API:
|
|
33
|
+
* - `insert(start, end, value)` — O(log n) insertion
|
|
34
|
+
* - `findOverlapping(start, end)` — O(log n + k) query, returns sorted intervals
|
|
35
|
+
* - `mapIntervals(fn)` — apply function to every interval (in-order)
|
|
36
|
+
*/
|
|
37
|
+
export declare class IntervalTree<T = unknown> {
|
|
38
|
+
#private;
|
|
39
|
+
root: TreeNode<T>;
|
|
40
|
+
constructor();
|
|
41
|
+
/**
|
|
42
|
+
* Insert an interval [start, end] with associated value.
|
|
43
|
+
* Maintains red-black balance and augmented min/max.
|
|
44
|
+
*/
|
|
45
|
+
insert(start: number, end: number, value: T): void;
|
|
46
|
+
/**
|
|
47
|
+
* Find all intervals overlapping [start, end].
|
|
48
|
+
* Returns intervals sorted by `low` value.
|
|
49
|
+
*/
|
|
50
|
+
findOverlapping(start: number, end: number): Interval<T>[];
|
|
51
|
+
/**
|
|
52
|
+
* Apply a function to every interval in the tree.
|
|
53
|
+
*/
|
|
54
|
+
mapIntervals(fn: (interval: Interval<T>) => void): void;
|
|
55
|
+
}
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Binary data parser for reading structured binary data from a DataView.
|
|
3
|
+
* Port of js/binary.ts, simplified for BigWig reading (no VPointer).
|
|
4
|
+
*/
|
|
5
|
+
export declare class BinaryParser {
|
|
6
|
+
littleEndian: boolean;
|
|
7
|
+
position: number;
|
|
8
|
+
readonly view: DataView;
|
|
9
|
+
readonly length: number;
|
|
10
|
+
constructor(dataView: DataView, littleEndian?: boolean);
|
|
11
|
+
setPosition(position: number): void;
|
|
12
|
+
available(): number;
|
|
13
|
+
remLength(): number;
|
|
14
|
+
getByte(): number;
|
|
15
|
+
getShort(): number;
|
|
16
|
+
getUShort(): number;
|
|
17
|
+
getInt(): number;
|
|
18
|
+
getUInt(): number;
|
|
19
|
+
getLong(): number;
|
|
20
|
+
getString(len?: number): string;
|
|
21
|
+
getFixedLengthString(len: number): string;
|
|
22
|
+
getFloat(): number;
|
|
23
|
+
getDouble(): number;
|
|
24
|
+
skip(n: number): number;
|
|
25
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared I/O utilities — binary parsing and HTTP range requests.
|
|
3
|
+
* Used by GTX reader and other format-specific code.
|
|
4
|
+
*/
|
|
5
|
+
export { BinaryParser } from './binaryParser';
|
|
6
|
+
export { fetchRange, getContentLength, BufferedRangeReader } from './rangeReader';
|
|
7
|
+
export type { ByteRange } from './rangeReader';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP range request reader using native fetch.
|
|
3
|
+
* Replaces igvxhr + BufferedReader for BigWig file reading.
|
|
4
|
+
*
|
|
5
|
+
* Handles cross-origin 307/302 redirects that strip the Range header.
|
|
6
|
+
* When a redirect causes the server to return 200 (full content) instead of
|
|
7
|
+
* 206 (partial), we either retry against the final URL or slice the correct
|
|
8
|
+
* bytes from the full response — matching igvxhr behavior.
|
|
9
|
+
*/
|
|
10
|
+
export interface ByteRange {
|
|
11
|
+
start: number;
|
|
12
|
+
size: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Fetch a byte range from a URL as an ArrayBuffer.
|
|
16
|
+
*
|
|
17
|
+
* Handles two redirect failure modes:
|
|
18
|
+
* 1. Cross-origin redirect strips Range header → server returns 200 (full file).
|
|
19
|
+
* We retry directly against response.url (the final URL post-redirect).
|
|
20
|
+
* 2. If retry still returns 200, we slice the requested bytes from the full
|
|
21
|
+
* response (matching igvxhr's fallback behavior).
|
|
22
|
+
*
|
|
23
|
+
* On HTTP 416 (Range Not Satisfiable), fetches the actual file size via HEAD
|
|
24
|
+
* and retries once with a clamped range.
|
|
25
|
+
*/
|
|
26
|
+
export declare function fetchRange(url: string, range: ByteRange, signal?: AbortSignal): Promise<ArrayBuffer>;
|
|
27
|
+
/**
|
|
28
|
+
* Fetch the Content-Length of a URL via a HEAD request.
|
|
29
|
+
* If redirected and Content-Length is missing, retries against the final URL.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getContentLength(url: string, signal?: AbortSignal): Promise<number>;
|
|
32
|
+
/**
|
|
33
|
+
* Buffered reader that caches fetched data to minimize HTTP requests.
|
|
34
|
+
* When a requested range is within the cached buffer, no fetch is needed.
|
|
35
|
+
*
|
|
36
|
+
* On HTTP 416, recovers by fetching the file's Content-Length and retrying,
|
|
37
|
+
* matching js/bigwig/bufferedReader.ts behavior.
|
|
38
|
+
*/
|
|
39
|
+
export declare class BufferedRangeReader {
|
|
40
|
+
private readonly url;
|
|
41
|
+
private readonly bufferSize;
|
|
42
|
+
private cachedRange;
|
|
43
|
+
private cachedData;
|
|
44
|
+
private contentLength;
|
|
45
|
+
constructor(url: string, bufferSize?: number);
|
|
46
|
+
dataViewForRange(requestedRange: ByteRange, signal?: AbortSignal, retries?: number): Promise<DataView>;
|
|
47
|
+
loadArrayBuffer(range: ByteRange, signal?: AbortSignal): Promise<ArrayBuffer>;
|
|
48
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Locus parsing, formatting, and clamping utilities.
|
|
3
|
+
*/
|
|
4
|
+
import type { Locus } from './types';
|
|
5
|
+
import type { ChromSizes } from './genome/chromSizes';
|
|
6
|
+
import type { CumulativeOffsets } from './genome/chromSizes';
|
|
7
|
+
/** Check if a locus represents whole genome view. */
|
|
8
|
+
export declare function isWholeGenomeView(locus: Locus): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Parse a locus string like "chr17:7,668,000-7,688,000" into a Locus object.
|
|
11
|
+
* Accepts with or without commas. Also recognizes "all" / "*" for whole genome view
|
|
12
|
+
* (requires cumulative offsets to compute end position).
|
|
13
|
+
* Returns null if parsing fails.
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseLocus(str: string, cumOffsets?: CumulativeOffsets): Locus | null;
|
|
16
|
+
/**
|
|
17
|
+
* Format a Locus object as a human-readable string with thousands separators.
|
|
18
|
+
* e.g., { chr: 'chr17', start: 7668000, end: 7688000 } → "chr17:7,668,000-7,688,000"
|
|
19
|
+
*/
|
|
20
|
+
export declare function formatLocus(locus: Locus): string;
|
|
21
|
+
/**
|
|
22
|
+
* Format a base pair length as a human-readable string.
|
|
23
|
+
* e.g., 20000 → "20 kb", 2500000 → "2.5 Mb", 500 → "500 bp"
|
|
24
|
+
*/
|
|
25
|
+
export declare function formatBpLength(bp: number): string;
|
|
26
|
+
/**
|
|
27
|
+
* Clamp a locus to valid chromosome bounds.
|
|
28
|
+
*
|
|
29
|
+
* Enforces:
|
|
30
|
+
* - start >= 0
|
|
31
|
+
* - end <= chromLength (if known)
|
|
32
|
+
* - span <= chromLength (if known)
|
|
33
|
+
*
|
|
34
|
+
* Maintains viewport span when possible by shifting rather than shrinking.
|
|
35
|
+
* Matches the behavior of js/referenceFrame.ts clampStart().
|
|
36
|
+
*/
|
|
37
|
+
export declare function clampLocus(locus: Locus, chromSizes?: ChromSizes, cumOffsets?: CumulativeOffsets): Locus;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic feature packing — greedy interval scheduling for row assignment.
|
|
3
|
+
*
|
|
4
|
+
* Assigns a `row` number to each feature so that no two features in the same
|
|
5
|
+
* row overlap. Features are sorted by start position, then placed in the first
|
|
6
|
+
* available row. This is used by every annotation-style track (genes, BED, GFF,
|
|
7
|
+
* VCF, interactions, etc.).
|
|
8
|
+
*
|
|
9
|
+
* Mirrors igv.js featurePacker.ts (js/feature/featurePacker.ts) which uses the
|
|
10
|
+
* same greedy algorithm with a generic {start, end, row} interface.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const features = [{start: 100, end: 200}, {start: 150, end: 300}, {start: 250, end: 400}]
|
|
15
|
+
* packFeatures(features)
|
|
16
|
+
* // features[0].row === 0, features[1].row === 1, features[2].row === 0
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Minimal interface for packable features.
|
|
21
|
+
* Any object with start/end coordinates and a mutable row field.
|
|
22
|
+
* Mirrors igv.js PackableFeature (js/feature/featurePacker.ts).
|
|
23
|
+
*/
|
|
24
|
+
export interface Packable {
|
|
25
|
+
start: number;
|
|
26
|
+
end: number;
|
|
27
|
+
row?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Assign row numbers to features using greedy interval scheduling.
|
|
31
|
+
* Features are sorted by start position, then placed in the first row
|
|
32
|
+
* where they don't overlap a previously placed feature.
|
|
33
|
+
*
|
|
34
|
+
* Mutates features in place by setting `.row`.
|
|
35
|
+
*
|
|
36
|
+
* @param features - Array of features to pack. Must have `start` and `end`.
|
|
37
|
+
* @param maxRows - Maximum number of rows. Features beyond this limit are
|
|
38
|
+
* still assigned rows but pile up. Default: unlimited.
|
|
39
|
+
* Matches igv.js behavior in featurePacker.ts and featureTrack.ts (default maxRows: 1000).
|
|
40
|
+
*/
|
|
41
|
+
export declare function packFeatures<T extends Packable>(features: T[], maxRows?: number): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PopupProvider — abstraction for popup/tooltip rendering.
|
|
3
|
+
*
|
|
4
|
+
* Follows the CanvasProvider / WorkerProvider pattern.
|
|
5
|
+
* Provide a custom implementation to replace the default `<loom-popup>` Web Component
|
|
6
|
+
* with your own React, Vue, or vanilla JS popup.
|
|
7
|
+
*
|
|
8
|
+
* When no popup provider is supplied, the browser still emits `trackclick` and
|
|
9
|
+
* `trackhover` events — consumers can handle interaction entirely via events.
|
|
10
|
+
*/
|
|
11
|
+
import type { PopupDataItem } from './types';
|
|
12
|
+
export interface PopupProvider {
|
|
13
|
+
/** Show a popup with the given data, positioned relative to the container. */
|
|
14
|
+
show(data: PopupDataItem[], position: {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
}, container: HTMLElement): void;
|
|
18
|
+
/** Hide the popup. */
|
|
19
|
+
hide(): void;
|
|
20
|
+
/** Clean up resources (remove DOM elements, etc). */
|
|
21
|
+
dispose(): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RemoteProtocol — WebSocket message framing and event forwarding.
|
|
3
|
+
*
|
|
4
|
+
* Provides `RemoteConnection` which bridges a `HeadlessGenomeBrowser` to a
|
|
5
|
+
* WebSocket-like transport. Incoming command messages are dispatched via
|
|
6
|
+
* `CommandDispatcher`; browser events are forwarded as unsolicited messages.
|
|
7
|
+
*
|
|
8
|
+
* The `RemoteSocket` interface is minimal and testable — works with browser
|
|
9
|
+
* WebSocket, the `ws` npm package, or mock implementations.
|
|
10
|
+
*/
|
|
11
|
+
import type { HeadlessGenomeBrowser } from './headlessGenomeBrowser';
|
|
12
|
+
import type { CommandDispatcherOptions } from './commandDispatcher';
|
|
13
|
+
/** Inbound: agent/server sends a command request. */
|
|
14
|
+
export interface RequestMessage {
|
|
15
|
+
id: string;
|
|
16
|
+
command: string;
|
|
17
|
+
args?: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
/** Outbound: successful command result. */
|
|
20
|
+
export interface ResponseMessage {
|
|
21
|
+
id: string;
|
|
22
|
+
result: unknown;
|
|
23
|
+
}
|
|
24
|
+
/** Outbound: command failed. */
|
|
25
|
+
export interface ErrorMessage {
|
|
26
|
+
id: string;
|
|
27
|
+
error: {
|
|
28
|
+
code: string;
|
|
29
|
+
message: string;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** Outbound: unsolicited browser event. */
|
|
33
|
+
export interface EventMessage {
|
|
34
|
+
event: string;
|
|
35
|
+
data: unknown;
|
|
36
|
+
}
|
|
37
|
+
export type OutboundMessage = ResponseMessage | ErrorMessage | EventMessage;
|
|
38
|
+
/**
|
|
39
|
+
* Minimal WebSocket-like interface.
|
|
40
|
+
* Works with browser WebSocket, Node `ws`, or test mocks.
|
|
41
|
+
*/
|
|
42
|
+
export interface RemoteSocket {
|
|
43
|
+
send(data: string): void;
|
|
44
|
+
addEventListener(type: 'message', handler: (event: {
|
|
45
|
+
data: string;
|
|
46
|
+
}) => void): void;
|
|
47
|
+
addEventListener(type: 'close', handler: () => void): void;
|
|
48
|
+
addEventListener(type: 'error', handler: (event: unknown) => void): void;
|
|
49
|
+
removeEventListener(type: string, handler: (...args: unknown[]) => void): void;
|
|
50
|
+
readonly readyState: number;
|
|
51
|
+
}
|
|
52
|
+
export declare const READY_STATE_OPEN = 1;
|
|
53
|
+
export declare class RemoteConnection {
|
|
54
|
+
private dispatcher;
|
|
55
|
+
private socket;
|
|
56
|
+
private browser;
|
|
57
|
+
private unsubscribers;
|
|
58
|
+
private messageHandler;
|
|
59
|
+
private closeHandler;
|
|
60
|
+
private detached;
|
|
61
|
+
constructor(browser: HeadlessGenomeBrowser, socket: RemoteSocket, options?: CommandDispatcherOptions);
|
|
62
|
+
/** Disconnect: unsubscribe all event listeners and stop forwarding. */
|
|
63
|
+
detach(): void;
|
|
64
|
+
/** Whether this connection has been detached. */
|
|
65
|
+
get isDetached(): boolean;
|
|
66
|
+
private handleMessage;
|
|
67
|
+
private send;
|
|
68
|
+
private subscribeToEvents;
|
|
69
|
+
/**
|
|
70
|
+
* Convert non-serializable event payloads to plain JSON.
|
|
71
|
+
*
|
|
72
|
+
* Track references → { trackId, trackType, trackName }
|
|
73
|
+
* Error objects → string message
|
|
74
|
+
* ROISet objects → set name string
|
|
75
|
+
*/
|
|
76
|
+
private sanitizeEventData;
|
|
77
|
+
private findManagedTrack;
|
|
78
|
+
private findTrackId;
|
|
79
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified RenderTheme system — shadcn-style palette-driven theming.
|
|
3
|
+
*
|
|
4
|
+
* Users define a global palette (primary, secondary, background, foreground, etc.)
|
|
5
|
+
* and each track type knows how to derive its specific config defaults from that
|
|
6
|
+
* palette. Everything is overridable at three levels:
|
|
7
|
+
*
|
|
8
|
+
* 1. Palette-derived defaults (gene.color = palette.primary)
|
|
9
|
+
* 2. Per-track-type overrides (theme.gene.borderRadius = 3)
|
|
10
|
+
* 3. Per-track instance overrides (options.config.color = 'red')
|
|
11
|
+
*
|
|
12
|
+
* Renderers never see RenderTheme directly — they still consume GeneRenderConfig,
|
|
13
|
+
* WigRenderConfig, etc. The theme system produces those configs.
|
|
14
|
+
*/
|
|
15
|
+
import type { GeneRenderConfig, WigRenderConfig, RulerRenderConfig } from './types';
|
|
16
|
+
/** Global color palette — the primary customization surface. */
|
|
17
|
+
export interface ThemePalette {
|
|
18
|
+
/** Main track color (CDS exons, wig bars, signal fill). */
|
|
19
|
+
primary: string;
|
|
20
|
+
/** Alternate strand, negative values. */
|
|
21
|
+
secondary: string;
|
|
22
|
+
/** Highlights, selections, active states. */
|
|
23
|
+
accent: string;
|
|
24
|
+
/** Track canvas background. */
|
|
25
|
+
background: string;
|
|
26
|
+
/** Text, labels, tick marks. */
|
|
27
|
+
foreground: string;
|
|
28
|
+
/** Subtle elements: baselines, introns, borders. */
|
|
29
|
+
muted: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Unified render theme. Defines a global palette, typography, and nucleotide
|
|
33
|
+
* colors. Each track type derives its config defaults from the palette, with
|
|
34
|
+
* optional per-track-type overrides.
|
|
35
|
+
*/
|
|
36
|
+
export interface RenderTheme {
|
|
37
|
+
palette: ThemePalette;
|
|
38
|
+
/** CSS font-family string. Default: 'sans-serif'. */
|
|
39
|
+
fontFamily: string;
|
|
40
|
+
/** Base font size in pixels. Default: 10. */
|
|
41
|
+
fontSize: number;
|
|
42
|
+
/** Nucleotide color mapping (A, C, G, T, N). */
|
|
43
|
+
nucleotideColors: Record<string, string>;
|
|
44
|
+
gene?: Partial<GeneRenderConfig>;
|
|
45
|
+
wig?: Partial<WigRenderConfig>;
|
|
46
|
+
ruler?: Partial<RulerRenderConfig>;
|
|
47
|
+
}
|
|
48
|
+
/** Returns the default render theme matching classic igv.js appearance. */
|
|
49
|
+
export declare function defaultRenderTheme(): RenderTheme;
|
|
50
|
+
/**
|
|
51
|
+
* Deep-merge a partial theme into the defaults.
|
|
52
|
+
* If no overrides provided, returns the default theme.
|
|
53
|
+
*/
|
|
54
|
+
export declare function resolveTheme(overrides?: Partial<RenderTheme>): RenderTheme;
|
|
55
|
+
/**
|
|
56
|
+
* Resolve a full GeneRenderConfig from a theme + optional per-track overrides.
|
|
57
|
+
*
|
|
58
|
+
* Resolution: palette-derived defaults → theme.gene overrides → per-track overrides.
|
|
59
|
+
*/
|
|
60
|
+
export declare function resolveGeneConfig(theme: RenderTheme, overrides?: Partial<GeneRenderConfig>): GeneRenderConfig;
|
|
61
|
+
/**
|
|
62
|
+
* Resolve a full WigRenderConfig from a theme + optional per-track overrides.
|
|
63
|
+
*
|
|
64
|
+
* Resolution: palette-derived defaults → theme.wig overrides → per-track overrides.
|
|
65
|
+
*/
|
|
66
|
+
export declare function resolveWigConfig(theme: RenderTheme, overrides?: Partial<WigRenderConfig>): WigRenderConfig;
|
|
67
|
+
/**
|
|
68
|
+
* Resolve a full RulerRenderConfig from a theme + optional per-track overrides.
|
|
69
|
+
*
|
|
70
|
+
* Resolution: palette-derived defaults → theme.ruler overrides → per-track overrides.
|
|
71
|
+
*/
|
|
72
|
+
export declare function resolveRulerConfig(theme: RenderTheme, overrides?: Partial<RulerRenderConfig>): RulerRenderConfig;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in RenderTheme presets.
|
|
3
|
+
*
|
|
4
|
+
* These are Partial<RenderTheme> objects — pass them to resolveTheme() to get
|
|
5
|
+
* a fully resolved theme with defaults filled in.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* import {resolveTheme} from './renderTheme'
|
|
9
|
+
* import {modernRenderTheme} from './renderThemePresets'
|
|
10
|
+
* const theme = resolveTheme(modernRenderTheme)
|
|
11
|
+
*/
|
|
12
|
+
import type { RenderTheme } from './renderTheme';
|
|
13
|
+
/** Modern theme — blue/pink palette, rounded exons, system font. */
|
|
14
|
+
export declare const modernRenderTheme: Partial<RenderTheme>;
|
|
15
|
+
/** Dark theme — adapted for dark backgrounds, high contrast. */
|
|
16
|
+
export declare const darkRenderTheme: Partial<RenderTheme>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure stateless ROI overlay renderer — for SVG/PNG export.
|
|
3
|
+
*
|
|
4
|
+
* Layer 2: takes a CanvasRenderingContext2D, draws ROI overlays.
|
|
5
|
+
* No DOM, no state. Used by HeadlessGenomeBrowser.toSVG().
|
|
6
|
+
*/
|
|
7
|
+
import type { ROI, RenderContext } from '../types';
|
|
8
|
+
export interface ROIRenderOptions {
|
|
9
|
+
/** Total height to render overlays across (sum of all track heights). */
|
|
10
|
+
totalHeight: number;
|
|
11
|
+
/** Height of the label chip at the top of each ROI. */
|
|
12
|
+
headerHeight?: number;
|
|
13
|
+
/** Font for ROI labels. */
|
|
14
|
+
font?: string;
|
|
15
|
+
/** Label text color. */
|
|
16
|
+
labelColor?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Render ROI overlays onto a canvas context.
|
|
20
|
+
*
|
|
21
|
+
* Draws semi-transparent filled rectangles spanning the full track height,
|
|
22
|
+
* with a small label chip at the top showing the ROI name.
|
|
23
|
+
*/
|
|
24
|
+
export declare function renderROIOverlays(ctx: CanvasRenderingContext2D, rois: ROI[], rc: RenderContext, options: ROIRenderOptions): void;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ROISet — a named collection of Regions of Interest.
|
|
3
|
+
*
|
|
4
|
+
* Layer 1 (Data): pure data model, no DOM, no canvas.
|
|
5
|
+
* Mirrors igv.js ROISet (js/roi/ROISet.ts) but with typed interfaces
|
|
6
|
+
* and no feature source abstraction (features stored in-memory).
|
|
7
|
+
*/
|
|
8
|
+
import type { ROI, ROISetConfig } from '../types';
|
|
9
|
+
/** Default fill color for loaded ROI sets — blue with low alpha. */
|
|
10
|
+
export declare const ROI_DEFAULT_COLOR = "rgba(68, 134, 247, 0.15)";
|
|
11
|
+
/** Default fill color for user-defined ROIs — green with low alpha. */
|
|
12
|
+
export declare const ROI_USER_DEFINED_COLOR = "rgba(155, 185, 129, 0.2)";
|
|
13
|
+
/** Generate a short unique ROI ID. */
|
|
14
|
+
export declare function generateROIId(): string;
|
|
15
|
+
/**
|
|
16
|
+
* A named collection of ROI features with a default color.
|
|
17
|
+
*
|
|
18
|
+
* Supports add/remove/update operations and spatial filtering.
|
|
19
|
+
* Serializable to ROISetConfig for session persistence.
|
|
20
|
+
*/
|
|
21
|
+
export declare class ROISet {
|
|
22
|
+
readonly name: string;
|
|
23
|
+
readonly isUserDefined: boolean;
|
|
24
|
+
color: string;
|
|
25
|
+
private _features;
|
|
26
|
+
constructor(config: ROISetConfig);
|
|
27
|
+
/** All features in this set. */
|
|
28
|
+
get features(): readonly ROI[];
|
|
29
|
+
/** Add a feature to this set. Assigns an ID if missing. */
|
|
30
|
+
addFeature(roi: ROI): ROI;
|
|
31
|
+
/** Remove a feature by ID. Returns the removed feature, or undefined. */
|
|
32
|
+
removeFeature(id: string): ROI | undefined;
|
|
33
|
+
/** Update a feature by ID. Returns the updated feature, or undefined. */
|
|
34
|
+
updateFeature(id: string, changes: Partial<Omit<ROI, 'id'>>): ROI | undefined;
|
|
35
|
+
/** Find a feature by ID. */
|
|
36
|
+
findById(id: string): ROI | undefined;
|
|
37
|
+
/** Get features overlapping a genomic region. */
|
|
38
|
+
getFeatures(chr: string, start: number, end: number): ROI[];
|
|
39
|
+
/** Serialize to a JSON-safe config. */
|
|
40
|
+
toJSON(): ROISetConfig;
|
|
41
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stateless ruler track renderer.
|
|
3
|
+
*
|
|
4
|
+
* Draws genomic coordinate tick marks and labels onto a canvas context.
|
|
5
|
+
* Ported from js/rulerTrack.ts but with no igv.js dependencies.
|
|
6
|
+
*/
|
|
7
|
+
import type { RulerRenderConfig, RenderContext } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* Render a genomic coordinate ruler onto a canvas context.
|
|
10
|
+
*
|
|
11
|
+
* Stateless — all state is passed as parameters.
|
|
12
|
+
* Draws tick marks, labels with SI-prefix units, and a baseline.
|
|
13
|
+
*/
|
|
14
|
+
export declare function renderRulerTrack(ctx: CanvasRenderingContext2D, config: RulerRenderConfig, rc: RenderContext): void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canvas manager for rendering a genomic coordinate ruler.
|
|
3
|
+
*
|
|
4
|
+
* Extends BaseTrackCanvas — canvas lifecycle is handled by the base class.
|
|
5
|
+
* This class only implements ruler-specific rendering.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* const canvas = document.createElement('canvas')
|
|
9
|
+
* const ruler = new RulerTrackCanvas(canvas, { locus })
|
|
10
|
+
* ruler.attachTo(containerDiv)
|
|
11
|
+
*/
|
|
12
|
+
import type { Locus, RulerRenderConfig, RenderContext, RulerTrackSessionConfig } from './types';
|
|
13
|
+
import type { CanvasProvider } from './canvasProvider';
|
|
14
|
+
import type { RenderTheme } from './renderTheme';
|
|
15
|
+
import { BaseTrackCanvas } from './baseTrackCanvas';
|
|
16
|
+
export interface RulerTrackCanvasOptions {
|
|
17
|
+
locus: Locus;
|
|
18
|
+
/** Per-track config overrides. Applied after theme-derived defaults. */
|
|
19
|
+
config?: Partial<RulerRenderConfig>;
|
|
20
|
+
/** Unified render theme. Palette drives default colors/fonts. */
|
|
21
|
+
theme?: Partial<RenderTheme>;
|
|
22
|
+
/** Canvas provider for environment abstraction. Default: DOMCanvasProvider. */
|
|
23
|
+
canvasProvider?: CanvasProvider;
|
|
24
|
+
}
|
|
25
|
+
export declare class RulerTrackCanvas extends BaseTrackCanvas<RulerRenderConfig> {
|
|
26
|
+
readonly type = "ruler";
|
|
27
|
+
constructor(canvas: HTMLCanvasElement, options: RulerTrackCanvasOptions);
|
|
28
|
+
protected computeHeight(_width: number): number;
|
|
29
|
+
protected getBackground(): string;
|
|
30
|
+
protected doRender(ctx: CanvasRenderingContext2D, _width: number, _height: number, rc: RenderContext): void;
|
|
31
|
+
serializeConfig(theme: RenderTheme): RulerTrackSessionConfig;
|
|
32
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DNA/RNA sequence utilities — complement, reverse-complement, and codon translation.
|
|
3
|
+
*
|
|
4
|
+
* Layer 1 (Data + Layout): Pure functions, no DOM, no canvas. Can run in Node.js,
|
|
5
|
+
* workers, or any environment.
|
|
6
|
+
*
|
|
7
|
+
* Ported from:
|
|
8
|
+
* - js/util/sequenceUtils.ts (complement/reverseComplement)
|
|
9
|
+
* - js/util/translationDict.ts (codon table)
|
|
10
|
+
* - js/sequenceTrack.ts (complement table with IUPAC codes, translateSequence)
|
|
11
|
+
*/
|
|
12
|
+
/** Return the complement of a single base (identity if unknown). */
|
|
13
|
+
export declare function complementBase(base: string): string;
|
|
14
|
+
/** Return the complement of a DNA sequence (no reversal). */
|
|
15
|
+
export declare function complementSequence(sequence: string): string;
|
|
16
|
+
/** Return the reverse complement of a DNA sequence. */
|
|
17
|
+
export declare function reverseComplementSequence(sequence: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Standard genetic code: 64 codons → single-letter amino acid or 'STOP'.
|
|
20
|
+
*
|
|
21
|
+
* Direct port of js/util/translationDict.ts.
|
|
22
|
+
*/
|
|
23
|
+
export declare const translationDict: Readonly<Record<string, string>>;
|
|
24
|
+
/** A single codon translation result. */
|
|
25
|
+
export interface CodonTranslation {
|
|
26
|
+
/** The 3-base codon string. */
|
|
27
|
+
codons: string;
|
|
28
|
+
/** Single-letter amino acid code, 'STOP', or '' for unknown codons. */
|
|
29
|
+
aminoA: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Translate a DNA sequence into three reading frames.
|
|
33
|
+
*
|
|
34
|
+
* Returns an array of 3 frames (offset 0, 1, 2). Each frame is an array
|
|
35
|
+
* of codon translations.
|
|
36
|
+
*
|
|
37
|
+
* When `reversed` is true, each individual codon is reversed before lookup
|
|
38
|
+
* (matching igv.js SequenceTrack.translateSequence behavior — this is NOT
|
|
39
|
+
* the same as reverse-complement; the complement is applied separately
|
|
40
|
+
* to the display sequence).
|
|
41
|
+
*
|
|
42
|
+
* Port of js/sequenceTrack.ts translateSequence().
|
|
43
|
+
*/
|
|
44
|
+
export declare function translateSequence(seq: string, reversed?: boolean): CodonTranslation[][];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session serialization and igv.js compatibility.
|
|
3
|
+
*
|
|
4
|
+
* Provides:
|
|
5
|
+
* - igv.js session import/export (fromIgvSession / toIgvSession)
|
|
6
|
+
* - Track creation via the track registry (createTrackFromSession)
|
|
7
|
+
*
|
|
8
|
+
* Track creation is delegated to the track registry (src/trackRegistry.ts),
|
|
9
|
+
* which provides an extensible Map-based factory. This module re-exports
|
|
10
|
+
* the registry's `createTrackFromConfig` under the legacy name for backward
|
|
11
|
+
* compatibility with existing session-loading code.
|
|
12
|
+
*
|
|
13
|
+
* Per-track config serialization is distributed to each track canvas class
|
|
14
|
+
* (WigTrackCanvas.serializeConfig, AnnotationTrackCanvas.serializeConfig, etc.)
|
|
15
|
+
*/
|
|
16
|
+
import type { SessionConfig, TrackSessionConfig, IgvSessionObject, Locus, SequenceProvider } from './types';
|
|
17
|
+
import type { CanvasProvider } from './canvasProvider';
|
|
18
|
+
import type { WorkerProvider } from './workerProvider';
|
|
19
|
+
import type { RenderTheme } from './themes/renderTheme';
|
|
20
|
+
export type { CreatedTrack } from './trackRegistry';
|
|
21
|
+
export declare const SESSION_VERSION = "1.0";
|
|
22
|
+
export interface CreateDataSourceOptions {
|
|
23
|
+
/** Worker provider for offloading CPU-intensive tasks in data sources. */
|
|
24
|
+
workerProvider?: WorkerProvider;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Use the track registry (`createTrackFromConfig`) instead, which
|
|
28
|
+
* handles data source creation internally. Kept for direct data source creation
|
|
29
|
+
* in non-session contexts.
|
|
30
|
+
*/
|
|
31
|
+
export { createDataSource } from './trackRegistry';
|
|
32
|
+
export interface CreateTrackFromSessionOptions extends CreateDataSourceOptions {
|
|
33
|
+
/** Canvas provider for creating track canvases. */
|
|
34
|
+
canvasProvider?: CanvasProvider;
|
|
35
|
+
/** Render theme for config resolution. */
|
|
36
|
+
theme?: Partial<RenderTheme>;
|
|
37
|
+
/** Sequence provider from the genome, used by sequence tracks. */
|
|
38
|
+
sequenceProvider?: SequenceProvider;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Create a track canvas + data source from a serialized TrackSessionConfig.
|
|
42
|
+
*
|
|
43
|
+
* Delegates to the track registry's `createTrackFromConfig()`, which uses
|
|
44
|
+
* the extensible Map-based factory instead of a switch/case.
|
|
45
|
+
*/
|
|
46
|
+
export declare function createTrackFromSession(trackConfig: TrackSessionConfig, locus: Locus, options?: CreateTrackFromSessionOptions): import("./trackRegistry").CreatedTrack;
|
|
47
|
+
/**
|
|
48
|
+
* Convert an igv.js session object to our SessionConfig format.
|
|
49
|
+
* Unknown track types are skipped with a console warning.
|
|
50
|
+
*/
|
|
51
|
+
export declare function fromIgvSession(igvSession: IgvSessionObject): SessionConfig;
|
|
52
|
+
/**
|
|
53
|
+
* Convert our SessionConfig to an igv.js-compatible session object.
|
|
54
|
+
*/
|
|
55
|
+
export declare function toIgvSession(session: SessionConfig): IgvSessionObject;
|