@jbrowse/bandage-core 11.7.1 → 11.8.0
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/README.md +106 -48
- package/dist/bubbles/bubbleHalos.js +6 -6
- package/dist/bubbles/classifyBubble.js +5 -5
- package/dist/bubbles/superbubbles.js +7 -7
- package/dist/chunks/{chunk-3PZSBNLI.js → chunk-22ZMVREZ.js} +19 -14
- package/dist/chunks/{chunk-VB4IXIPM.js → chunk-2H3ALI6L.js} +223 -45
- package/dist/chunks/{chunk-FBPAX5K6.js → chunk-2RCKHCF7.js} +1 -1
- package/dist/chunks/{chunk-5NZRT7GL.js → chunk-3CXZUC2Y.js} +2 -2
- package/dist/chunks/{chunk-WUZH2OJ6.js → chunk-3XYLEK4H.js} +2 -2
- package/dist/chunks/{chunk-F7O56DVR.js → chunk-4OVIUCSB.js} +2 -2
- package/dist/chunks/{chunk-JGH2V54E.js → chunk-4YPCUVMC.js} +2 -2
- package/dist/chunks/{chunk-FU57ZNRQ.js → chunk-6CXLLJ2C.js} +3 -3
- package/dist/chunks/{chunk-SACSQ45G.js → chunk-6MD4VS2F.js} +1 -1
- package/dist/chunks/{chunk-VACK24HF.js → chunk-735MPLUL.js} +35 -9
- package/dist/chunks/chunk-7GDNDQD7.js +504 -0
- package/dist/chunks/{chunk-IN4IYSA2.js → chunk-7PEYA3NA.js} +2 -2
- package/dist/chunks/{chunk-CWCVQJYY.js → chunk-AXE3RR7J.js} +1 -1
- package/dist/chunks/{chunk-BXE3SBBN.js → chunk-C3KAPREU.js} +1 -1
- package/dist/chunks/{chunk-ATDVS2CW.js → chunk-G3GLGDKV.js} +2 -2
- package/dist/chunks/{chunk-RB2MDFQU.js → chunk-G4WQBRDS.js} +4 -4
- package/dist/chunks/{chunk-SDI6BVG7.js → chunk-J4PDHWP2.js} +1 -1
- package/dist/chunks/{chunk-3UGWYQNY.js → chunk-JKIAHYAW.js} +14 -8
- package/dist/chunks/{chunk-TCSV3II7.js → chunk-L2RQV23D.js} +1 -1
- package/dist/chunks/{chunk-6XDTAKO7.js → chunk-LA6JHEVV.js} +1 -1
- package/dist/chunks/{chunk-G7SG4XMK.js → chunk-LODKC7PJ.js} +7 -0
- package/dist/chunks/{chunk-RK7ZOFPR.js → chunk-MO4DIRHD.js} +80 -38
- package/dist/chunks/{chunk-PCHEUVHB.js → chunk-N2GAA7RB.js} +1 -1
- package/dist/chunks/{chunk-I5SGYTRM.js → chunk-N4AJV4GH.js} +25 -14
- package/dist/chunks/{chunk-Q7I563MH.js → chunk-NHOXLUIL.js} +2 -2
- package/dist/chunks/{chunk-RT4K2JMZ.js → chunk-NQWEYJDD.js} +1 -1
- package/dist/chunks/{chunk-3Y2EFDID.js → chunk-OIOAK7BS.js} +1 -1
- package/dist/chunks/{chunk-EZGNBDHD.js → chunk-R3NPBUKT.js} +8 -8
- package/dist/chunks/{chunk-KJDERUQF.js → chunk-R4XCTRIU.js} +45 -10
- package/dist/chunks/{chunk-HTF32WSW.js → chunk-S3ICPPXC.js} +3 -3
- package/dist/chunks/{chunk-OXW5OHYQ.js → chunk-S4CH434Z.js} +1 -1
- package/dist/chunks/{chunk-HMEAGAGC.js → chunk-S7BCZVRK.js} +2 -2
- package/dist/chunks/{chunk-UV2IJMIG.js → chunk-SDDMV2MM.js} +1 -1
- package/dist/chunks/{chunk-J6XHW4KI.js → chunk-SIXFXXRI.js} +3 -3
- package/dist/chunks/{chunk-LKQOIPGE.js → chunk-U6JPSXJ3.js} +90 -21
- package/dist/chunks/{chunk-SENPGW4O.js → chunk-VCUOYVLC.js} +1 -1
- package/dist/chunks/{chunk-XTF2VWJN.js → chunk-VSRRIFRF.js} +1 -1
- package/dist/chunks/{chunk-BFUS3ENH.js → chunk-X5ULFAMM.js} +2 -2
- package/dist/chunks/{chunk-PJWLYGRL.js → chunk-XOIYBEU7.js} +1 -1
- package/dist/chunks/{chunk-JLIVX2SF.js → chunk-YEDZ37PH.js} +1 -1
- package/dist/chunks/{chunk-APLWFV4I.js → chunk-YF6T33PU.js} +10 -2
- package/dist/chunks/{chunk-2VMKQKVO.js → chunk-YIWN32ZX.js} +1 -1
- package/dist/chunks/{chunk-3WSA4NNP.js → chunk-ZKIH2USC.js} +1 -1
- package/dist/cli/figure.js +31 -30
- package/dist/cli/fold.js +6 -6
- package/dist/deletionEdges.js +2 -2
- package/dist/figure.js +27 -26
- package/dist/figureData.js +25 -24
- package/dist/figureScene.js +18 -17
- package/dist/figureSettings.js +6 -6
- package/dist/foldVariants.js +2 -2
- package/dist/genes/genePins.js +3 -3
- package/dist/graphLabels.js +4 -4
- package/dist/index.js +45 -44
- package/dist/labelLayout.js +8 -8
- package/dist/layout/forceCache.js +6 -6
- package/dist/layout/mergeRuns.js +2 -2
- package/dist/layout/orientToReference.js +3 -1
- package/dist/layout/tubeMapLayout.js +9 -9
- package/dist/layout/walkRowDraw.js +9 -8
- package/dist/layout/walkRowLayout.js +3 -3
- package/dist/layout/walkRowRuns.js +1 -1
- package/dist/layout/walkRows.js +2 -2
- package/dist/layout/walkStrip.js +13 -12
- package/dist/layoutModes.js +11 -11
- package/dist/pathColors.js +5 -5
- package/dist/pipeline.js +5 -5
- package/dist/referenceStrip.js +9 -8
- package/dist/renderer/GeometryBuilder.js +8 -7
- package/dist/renderer/walkLanes.js +44 -0
- package/dist/tubeMap/axis.js +5 -5
- package/dist/tubeMap/bundle.js +10 -10
- package/dist/tubeMap/coarsen.js +10 -10
- package/dist/tubeMap/deviations.js +11 -11
- package/dist/tubeMap/draw.js +5 -5
- package/dist/tubeMap/genes.js +6 -6
- package/dist/tubeMap/nodeColors.js +9 -8
- package/dist/tubeMap/reads.js +2 -2
- package/dist/types/figureData.d.ts +22 -0
- package/dist/types/foldVariants.d.ts +3 -1
- package/dist/types/renderer/types.d.ts +20 -0
- package/dist/types/renderer/walkLanes.d.ts +60 -0
- package/dist/types/types.d.ts +1 -0
- package/dist/types/util/geometry.d.ts +13 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/walkEncoding.d.ts +7 -5
- package/dist/types/walkHighlight.d.ts +3 -0
- package/dist/util/SpatialIndex.js +4 -4
- package/dist/util/edgeCurves.js +3 -3
- package/dist/util/geometry.js +7 -1
- package/dist/util/hitDetection.js +5 -5
- package/dist/version.js +1 -1
- package/dist/viewport.js +6 -6
- package/dist/walkEncoding.js +9 -8
- package/dist/walkHighlight.js +10 -9
- package/dist/walkKey.js +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,47 +1,94 @@
|
|
|
1
1
|
# @jbrowse/bandage-core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
TypeScript library that lays out and draws pangenome graphs, used by
|
|
4
4
|
[jbrowse-plugin-graphgenomeviewer](https://github.com/GMOD/jbrowse-plugin-graphgenomeviewer)
|
|
5
|
-
and [BandageJS](https://github.com/cmdcolin/BandageJS).
|
|
5
|
+
and [BandageJS](https://github.com/cmdcolin/BandageJS). It imports no React,
|
|
6
|
+
MobX or JBrowse code. BandageJS's
|
|
7
|
+
[`src/main.ts`](https://github.com/cmdcolin/BandageJS/blob/main/src/main.ts) is
|
|
8
|
+
the worked example.
|
|
6
9
|
|
|
7
10
|
```
|
|
8
11
|
npm install @jbrowse/bandage-core
|
|
9
12
|
```
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
|
|
14
|
+
## Reading a graph
|
|
15
|
+
|
|
16
|
+
- `loadGraph` reads GFA or rGFA text. The caller decompresses a `.gfa.gz` first
|
|
17
|
+
- `loadGraph` also takes `GraphTables`, the typed arrays that
|
|
18
|
+
[@jbrowse/graph-walks](https://github.com/GMOD/graph-walks) cuts from a
|
|
19
|
+
[gfa-to-tabix](https://github.com/GMOD/gfa-to-tabix) walk file
|
|
20
|
+
(`.walks.bed.gz` beside its `.tbi`) for a region on the reference. A worker
|
|
21
|
+
can transfer them without copying, and `graphTablesGFA` writes them as GFA
|
|
22
|
+
- `openGbz` and `cutGbzRegion` cut a window from a
|
|
23
|
+
[gbz-base](https://github.com/jltsiren/gbz-base) database (`.gbz.db`) to GFA
|
|
24
|
+
text
|
|
25
|
+
- In a walk-file cut, the `ws:Z:` and `we:Z:` tags on each W line record what
|
|
26
|
+
lies past the fragment's start and end, such as `break,bp=19021` or
|
|
15
27
|
`elsewhere,trimmed=400,chunk=GRCh38#0#chr22:20316160`
|
|
16
|
-
(`src/gfa/walkStops.ts`). Walk rows split each gap
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
and
|
|
28
|
+
(`src/gfa/walkStops.ts`). Walk rows split each gap at those stops and label
|
|
29
|
+
each part with its cause
|
|
30
|
+
|
|
31
|
+
## Laying out and drawing
|
|
32
|
+
|
|
33
|
+
- `loadBandage` loads Bandage's FMMM engine, compiled to WASM in
|
|
34
|
+
[@jbrowse/graph-fmmm-layout](https://github.com/GMOD/graph-fmmm-layout), and
|
|
35
|
+
`forceLayout` runs it. The other layouts are ordered, anchored, sample rows,
|
|
36
|
+
walk rows and tube map
|
|
37
|
+
- `buildGeometry` and `Canvas2DRenderer` draw to a canvas, with hit testing and
|
|
38
|
+
label placement. The library also finds bubbles and deletion edges and colors
|
|
39
|
+
paths
|
|
40
|
+
- `walkLift` lifts a walk out of the drawing, `facetLifts` and `facetGrid` draw
|
|
41
|
+
one panel per walk, and `walkKey` describes each walk in words
|
|
42
|
+
- `graphBackbone`, `backboneAssembly` and `assemblyWalk` find which assembly a
|
|
43
|
+
backbone lies on. `featuresOnBackbone` renames that assembly's genes onto the
|
|
44
|
+
backbone's refNames, and `genePins` pins only those
|
|
45
|
+
|
|
46
|
+
## Figures
|
|
47
|
+
|
|
48
|
+
- `figureSvg` draws a graph and its lifted walks to a standalone SVG. The
|
|
49
|
+
`bandage-figure` CLI makes one from a JSON spec with no browser:
|
|
33
50
|
`npx -p @jbrowse/bandage-core bandage-figure spec.json -o figure.svg`. See
|
|
34
51
|
[docs/figures.md](docs/figures.md)
|
|
35
|
-
-
|
|
36
|
-
|
|
37
|
-
[docs/coarse-tier.md](docs/coarse-tier.md)
|
|
38
|
-
- Figure data: `figureData` returns what `figureSvg` would paint as columnar
|
|
39
|
-
tables, for another graphics system to draw;
|
|
52
|
+
- `figureData` returns what `figureSvg` would draw as columnar tables, for
|
|
53
|
+
another graphics system to draw;
|
|
40
54
|
[ggbandage](https://github.com/GMOD/ggbandage) draws them in ggplot2
|
|
41
55
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
56
|
+
## Coarse tier: `bandage-fold`
|
|
57
|
+
|
|
58
|
+
`bandage-fold` writes an rGFA with every variant under `--below` bp folded into
|
|
59
|
+
the reference. Indexed by gfa-to-tabix, the output is the coarse tier a graph
|
|
60
|
+
track draws once zoomed out past the fine index, so a whole chromosome fits.
|
|
61
|
+
[`gfa-to-tabix fold`](https://github.com/GMOD/gfa-to-tabix/blob/main/docs/subcommands.md#fold)
|
|
62
|
+
documents the fold and the handover from the fine index.
|
|
63
|
+
|
|
64
|
+
```console
|
|
65
|
+
npx -p @jbrowse/bandage-core bandage-fold graph.rgfa.gz --below 10000 \
|
|
66
|
+
| gfa-to-tabix - -o graph.fold10000
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- The input is a GFA or rGFA, plain or gzipped, or `-` for stdin. `-o out.gfa`
|
|
70
|
+
writes a file in place of stdout
|
|
71
|
+
- `--reference PATH` names a plain GFA's backbone path. In an rGFA, the segments
|
|
72
|
+
tagged `SR:i:0` form the backbone
|
|
73
|
+
- The fold keeps the backbone, every allele whose own length or the reference it
|
|
74
|
+
replaces reaches `--below`, and the shortest way from each one's ends back to
|
|
75
|
+
the backbone. It joins the reference between kept alleles into one segment
|
|
76
|
+
- `bandage-fold` drops paths and walks from the output. It writes forward a
|
|
77
|
+
segment that a plain GFA's path reads reversed, and flips its links to match,
|
|
78
|
+
so the output re-reads as the graph that was folded
|
|
79
|
+
- gfa-to-tabix's `--layout anchored|contig` should match the fine index's. An
|
|
80
|
+
anchored window inside a large bubble then returns the whole bubble in both
|
|
81
|
+
tiers, and a contig one only what links reach from it
|
|
82
|
+
- The graph track folds each cut it draws at ten pixels (`FOLD_PX` in
|
|
83
|
+
jbrowse-plugin-graphgenomeviewer), and folding a fold again at a larger size
|
|
84
|
+
closely matches folding the original at that size. A tier folded at N and
|
|
85
|
+
handed over at N / 10 bp per pixel, such as
|
|
86
|
+
`coarse: { uri: "graph.fold10000", aboveBpPerPx: 1000 }`, therefore draws
|
|
87
|
+
nearly what the fine cut drew
|
|
88
|
+
- Node caps a string at 512 MB, and `bandage-fold` reads the whole graph into
|
|
89
|
+
one, so it cannot fold a whole human pangenome. `gfa-to-tabix fold`, a port of
|
|
90
|
+
the same fold, writes the index in one pass:
|
|
91
|
+
`gfa-to-tabix fold graph.rgfa.gz --below 10000 -o graph.fold10000`
|
|
45
92
|
|
|
46
93
|
## Developing
|
|
47
94
|
|
|
@@ -51,27 +98,38 @@ pnpm test # unit tests
|
|
|
51
98
|
pnpm build # dist/ with declarations
|
|
52
99
|
```
|
|
53
100
|
|
|
54
|
-
The FMMM engine and its wasm build
|
|
55
|
-
[graph-fmmm-layout](https://github.com/GMOD/graph-fmmm-layout)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
[
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
101
|
+
- The FMMM engine and its wasm build are in
|
|
102
|
+
[graph-fmmm-layout](https://github.com/GMOD/graph-fmmm-layout)
|
|
103
|
+
- CI also packs the core and runs the typecheck and tests of
|
|
104
|
+
[BandageJS](https://github.com/cmdcolin/BandageJS) and
|
|
105
|
+
[jbrowse-plugin-graphgenomeviewer](https://github.com/GMOD/jbrowse-plugin-graphgenomeviewer)
|
|
106
|
+
against it. For an API change, push the consumer's matching change to a
|
|
107
|
+
`core-next` branch in that consumer's repo, which CI tests in place of `main`
|
|
108
|
+
until the release
|
|
109
|
+
- `src/foldParity.test.ts` folds a few hundred random rGFA graphs with
|
|
110
|
+
`foldVariants` and with the gfa-to-tabix release that
|
|
111
|
+
`.github/actions/gfa-to-tabix` pins, and fails when they fold differently.
|
|
112
|
+
Locally the test runs the `gfa-to-tabix` on PATH or named by `GFA_TO_TABIX`,
|
|
113
|
+
and skips without one. In the other direction, gfa-to-tabix's
|
|
114
|
+
`scripts/parity-fold.sh` checks that `gfa-to-tabix fold` writes the same bytes
|
|
115
|
+
as `bandage-fold | gfa-to-tabix -`, and its CI tests the port against a pinned
|
|
116
|
+
bandage-core
|
|
117
|
+
- Release with `pnpm version patch`: it lints, tests, stamps `src/version.ts`,
|
|
118
|
+
writes the changelog with git-cliff and pushes the `v*` tag. `publish.yml`
|
|
119
|
+
then runs CI, consumers included, and publishes to npm with trusted publishing
|
|
120
|
+
only if it passes. When a consumer fails, push its side to `core-next` and
|
|
121
|
+
rerun the failed jobs
|
|
68
122
|
|
|
69
123
|
## See also
|
|
70
124
|
|
|
71
125
|
- [jbrowse-plugin-graphgenomeviewer](https://github.com/GMOD/jbrowse-plugin-graphgenomeviewer) -
|
|
72
126
|
JBrowse 2 plugin that browses these graphs by locus
|
|
73
|
-
- [BandageJS](https://github.com/cmdcolin/BandageJS) -
|
|
74
|
-
and gbz-base
|
|
127
|
+
- [BandageJS](https://github.com/cmdcolin/BandageJS) - browser viewer for GFA
|
|
128
|
+
files, walk files and gbz-base databases
|
|
129
|
+
- [gfa-to-tabix](https://github.com/GMOD/gfa-to-tabix) - indexes a GFA by
|
|
130
|
+
reference position, writing the `.walks.bed.gz` walk files
|
|
131
|
+
- [@jbrowse/graph-walks](https://github.com/GMOD/graph-walks) - range-request
|
|
132
|
+
reader for walk files
|
|
75
133
|
- [@jbrowse/graph-fmmm-layout](https://github.com/GMOD/graph-fmmm-layout) -
|
|
76
134
|
Bandage's FMMM layout as wasm
|
|
77
135
|
- [@jbrowse/graph-stress-layout](https://github.com/GMOD/graph-stress-layout) -
|
|
@@ -83,7 +141,7 @@ failed jobs.
|
|
|
83
141
|
- [@jbrowse/tubemap-core](https://github.com/GMOD/tubemap-core) -
|
|
84
142
|
sequenceTubeMap's layout, without the DOM
|
|
85
143
|
|
|
86
|
-
Tutorials on [jbrowse.org](https://jbrowse.org/jb2/docs/tutorials/)
|
|
144
|
+
Tutorials on [jbrowse.org](https://jbrowse.org/jb2/docs/tutorials/):
|
|
87
145
|
|
|
88
146
|
- [HPRC part 1: graph alleles and haplotypes](https://jbrowse.org/jb2/docs/tutorials/pangenome_hprc/)
|
|
89
147
|
- [HPRC part 3: repeat lengths](https://jbrowse.org/jb2/docs/tutorials/pangenome_hprc_repeats/)
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
bubbleHalos,
|
|
3
3
|
coversGraph
|
|
4
|
-
} from "../chunks/chunk-
|
|
5
|
-
import "../chunks/chunk-
|
|
4
|
+
} from "../chunks/chunk-4YPCUVMC.js";
|
|
5
|
+
import "../chunks/chunk-OIOAK7BS.js";
|
|
6
6
|
import "../chunks/chunk-FX4RDMDN.js";
|
|
7
|
-
import "../chunks/chunk-
|
|
7
|
+
import "../chunks/chunk-6CXLLJ2C.js";
|
|
8
8
|
import "../chunks/chunk-HMXCN6PG.js";
|
|
9
9
|
import "../chunks/chunk-AB35TJST.js";
|
|
10
|
-
import "../chunks/chunk-
|
|
11
|
-
import "../chunks/chunk-
|
|
10
|
+
import "../chunks/chunk-YIWN32ZX.js";
|
|
11
|
+
import "../chunks/chunk-3CXZUC2Y.js";
|
|
12
12
|
import "../chunks/chunk-TLWXLNLY.js";
|
|
13
13
|
import "../chunks/chunk-3YBP46PB.js";
|
|
14
|
-
import "../chunks/chunk-
|
|
14
|
+
import "../chunks/chunk-735MPLUL.js";
|
|
15
15
|
import "../chunks/chunk-CPMHA4W5.js";
|
|
16
16
|
import "../chunks/chunk-ZPZ7GNBT.js";
|
|
17
17
|
import "../chunks/chunk-BSOZW3FC.js";
|
|
@@ -3,16 +3,16 @@ import {
|
|
|
3
3
|
BUBBLE_KIND_NAMES,
|
|
4
4
|
bubbleSegmentIds,
|
|
5
5
|
classifyBubble
|
|
6
|
-
} from "../chunks/chunk-
|
|
6
|
+
} from "../chunks/chunk-OIOAK7BS.js";
|
|
7
7
|
import "../chunks/chunk-FX4RDMDN.js";
|
|
8
|
-
import "../chunks/chunk-
|
|
8
|
+
import "../chunks/chunk-6CXLLJ2C.js";
|
|
9
9
|
import "../chunks/chunk-HMXCN6PG.js";
|
|
10
10
|
import "../chunks/chunk-AB35TJST.js";
|
|
11
|
-
import "../chunks/chunk-
|
|
12
|
-
import "../chunks/chunk-
|
|
11
|
+
import "../chunks/chunk-YIWN32ZX.js";
|
|
12
|
+
import "../chunks/chunk-3CXZUC2Y.js";
|
|
13
13
|
import "../chunks/chunk-TLWXLNLY.js";
|
|
14
14
|
import "../chunks/chunk-3YBP46PB.js";
|
|
15
|
-
import "../chunks/chunk-
|
|
15
|
+
import "../chunks/chunk-735MPLUL.js";
|
|
16
16
|
import "../chunks/chunk-CPMHA4W5.js";
|
|
17
17
|
import "../chunks/chunk-ZPZ7GNBT.js";
|
|
18
18
|
import "../chunks/chunk-BSOZW3FC.js";
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
graphBubbles,
|
|
3
3
|
superbubblesFromGraph
|
|
4
|
-
} from "../chunks/chunk-
|
|
5
|
-
import "../chunks/chunk-
|
|
4
|
+
} from "../chunks/chunk-SIXFXXRI.js";
|
|
5
|
+
import "../chunks/chunk-4YPCUVMC.js";
|
|
6
6
|
import "../chunks/chunk-RFG42VIO.js";
|
|
7
|
-
import "../chunks/chunk-
|
|
7
|
+
import "../chunks/chunk-OIOAK7BS.js";
|
|
8
8
|
import "../chunks/chunk-FX4RDMDN.js";
|
|
9
9
|
import "../chunks/chunk-MHZTTLBU.js";
|
|
10
10
|
import "../chunks/chunk-UAFATXYA.js";
|
|
11
11
|
import "../chunks/chunk-VX656OAZ.js";
|
|
12
|
-
import "../chunks/chunk-
|
|
12
|
+
import "../chunks/chunk-6CXLLJ2C.js";
|
|
13
13
|
import "../chunks/chunk-HMXCN6PG.js";
|
|
14
14
|
import "../chunks/chunk-AB35TJST.js";
|
|
15
|
-
import "../chunks/chunk-
|
|
16
|
-
import "../chunks/chunk-
|
|
15
|
+
import "../chunks/chunk-YIWN32ZX.js";
|
|
16
|
+
import "../chunks/chunk-3CXZUC2Y.js";
|
|
17
17
|
import "../chunks/chunk-TLWXLNLY.js";
|
|
18
18
|
import "../chunks/chunk-3YBP46PB.js";
|
|
19
|
-
import "../chunks/chunk-
|
|
19
|
+
import "../chunks/chunk-735MPLUL.js";
|
|
20
20
|
import "../chunks/chunk-CPMHA4W5.js";
|
|
21
21
|
import "../chunks/chunk-ZPZ7GNBT.js";
|
|
22
22
|
import "../chunks/chunk-BSOZW3FC.js";
|
|
@@ -1,24 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ownStrand
|
|
3
|
+
} from "./chunk-735MPLUL.js";
|
|
1
4
|
import {
|
|
2
5
|
isBackbone
|
|
3
6
|
} from "./chunk-RJWPJCIB.js";
|
|
4
7
|
|
|
5
8
|
// src/layout/orientToReference.ts
|
|
6
9
|
function orientToReference(graph, positions) {
|
|
7
|
-
const backbone = graph.nodes.filter(
|
|
8
|
-
|
|
9
|
-
);
|
|
10
|
-
if (backbone.length < 2) {
|
|
11
|
-
return positions;
|
|
12
|
-
}
|
|
13
|
-
const points = backbone.map((node) => {
|
|
10
|
+
const backbone = graph.nodes.filter(isBackbone).filter((node) => (positions[node.id]?.length ?? 0) > 0);
|
|
11
|
+
const points = backbone.flatMap((node) => {
|
|
14
12
|
const segments = positions[node.id];
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
const last = segments.length - 1;
|
|
14
|
+
const forwards = ownStrand(node.id) === (node.stable.strand ?? "+");
|
|
15
|
+
return segments.map((p, i) => {
|
|
16
|
+
const along = last === 0 ? 0.5 : i / last;
|
|
17
|
+
return {
|
|
18
|
+
x: p.x,
|
|
19
|
+
y: p.y,
|
|
20
|
+
r: node.stable.start + node.length * (forwards ? along : 1 - along),
|
|
21
|
+
w: node.length / segments.length
|
|
22
|
+
};
|
|
23
|
+
});
|
|
22
24
|
});
|
|
23
25
|
const weight = points.reduce((sum, p) => sum + p.w, 0);
|
|
24
26
|
if (weight === 0) {
|
|
@@ -33,6 +35,9 @@ function orientToReference(graph, positions) {
|
|
|
33
35
|
sxr += p.w * (p.x - cx) * (p.r - cr);
|
|
34
36
|
syr += p.w * (p.y - cy) * (p.r - cr);
|
|
35
37
|
}
|
|
38
|
+
if (sxr === 0 && syr === 0) {
|
|
39
|
+
return positions;
|
|
40
|
+
}
|
|
36
41
|
const angle = -Math.atan2(syr, sxr);
|
|
37
42
|
const c = Math.cos(angle);
|
|
38
43
|
const s = Math.sin(angle);
|