@jbrowse/bandage-core 9.10.0 → 10.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.
Files changed (86) hide show
  1. package/README.md +20 -0
  2. package/dist/bubbles/popBubble.js +3 -2
  3. package/dist/bubbles/superbubbles.js +4 -3
  4. package/dist/chunks/{chunk-TOVOJNT7.js → chunk-3XE3OUEN.js} +1 -1
  5. package/dist/chunks/{chunk-A6PSWTLX.js → chunk-4QTNXTGW.js} +1 -1
  6. package/dist/chunks/chunk-A647OH7N.js +284 -0
  7. package/dist/chunks/{chunk-NGODVSCA.js → chunk-AZJF2PZE.js} +9 -9
  8. package/dist/chunks/{chunk-5GZEPPEW.js → chunk-BEWLQADP.js} +1 -1
  9. package/dist/chunks/{chunk-Q6UIUY6X.js → chunk-CFNFT4RA.js} +1 -1
  10. package/dist/chunks/{chunk-K5NYTPLC.js → chunk-DCJC32QW.js} +1 -1
  11. package/dist/chunks/{chunk-IGJCTPFB.js → chunk-EMUUNWRU.js} +52 -43
  12. package/dist/chunks/{chunk-2FLBFVMO.js → chunk-FFFYXMOP.js} +16 -16
  13. package/dist/chunks/{chunk-LZWSZRUY.js → chunk-FG762CCP.js} +3 -8
  14. package/dist/chunks/{chunk-73RSLGZT.js → chunk-FLFBYSJO.js} +1 -1
  15. package/dist/chunks/{chunk-VK6XMP6B.js → chunk-FLUQODT2.js} +1 -3
  16. package/dist/chunks/{chunk-PIN7ZMTZ.js → chunk-HQ2AHRMH.js} +1 -1
  17. package/dist/chunks/{chunk-FUUJ76KD.js → chunk-IFOZFVZK.js} +2 -2
  18. package/dist/chunks/{chunk-CXKZYLYS.js → chunk-IM4SJUPO.js} +12 -22
  19. package/dist/chunks/{chunk-BDWQQK33.js → chunk-KJYSOHVN.js} +1 -1
  20. package/dist/chunks/{chunk-2VTM3DHG.js → chunk-KY4LV2Z6.js} +1 -1
  21. package/dist/chunks/{chunk-HRAU4VTB.js → chunk-MSX3BDO4.js} +11 -11
  22. package/dist/chunks/{chunk-4IYP43W6.js → chunk-NP356MC2.js} +1 -1
  23. package/dist/chunks/{chunk-TFAFIRZB.js → chunk-OEPCRURR.js} +1 -1
  24. package/dist/chunks/{chunk-OA7RIMZ2.js → chunk-PSMKPSO4.js} +89 -22
  25. package/dist/chunks/{chunk-LTUWJKHD.js → chunk-Q7LYHGGQ.js} +114 -6
  26. package/dist/chunks/{chunk-MVMP6AGI.js → chunk-QIVPRZ4H.js} +12 -7
  27. package/dist/chunks/{chunk-PT37VS5B.js → chunk-QORSYW7J.js} +1 -1
  28. package/dist/chunks/{chunk-J7YKQ5YW.js → chunk-QXAB2FLJ.js} +1 -1
  29. package/dist/chunks/chunk-RAEABQNW.js +227 -0
  30. package/dist/chunks/{chunk-XZ2BLAA6.js → chunk-REE4GUDM.js} +1 -1
  31. package/dist/chunks/{chunk-KYY5363X.js → chunk-VOWI544A.js} +1 -1
  32. package/dist/chunks/{chunk-JVLURPFW.js → chunk-VPE4AYP7.js} +1 -2
  33. package/dist/chunks/{chunk-FJZ2TB46.js → chunk-VZNKA3K2.js} +2 -2
  34. package/dist/chunks/{chunk-DMH4NL2M.js → chunk-WI7ZHJ27.js} +2 -2
  35. package/dist/chunks/{chunk-IZI7KIVX.js → chunk-ZR7A7DKQ.js} +1 -1
  36. package/dist/cli/figure.js +27 -28
  37. package/dist/cli/fold.js +7 -6
  38. package/dist/figure.js +20 -19
  39. package/dist/figureData.js +21 -22
  40. package/dist/figureSettings.js +8 -7
  41. package/dist/gbzCut.js +3 -2
  42. package/dist/gbzWindow.js +6 -1
  43. package/dist/gfa/gfaConverter.js +3 -2
  44. package/dist/gfa/graphTables.js +2 -1
  45. package/dist/index.js +63 -54
  46. package/dist/layout/deletionRoutes.js +1 -3
  47. package/dist/layout/forceCache.js +8 -7
  48. package/dist/layout/trimToWindow.js +17 -23
  49. package/dist/layout/tubeMapLayout.js +4 -3
  50. package/dist/layout/walkRowDraw.js +6 -5
  51. package/dist/layout/walkRowLayout.js +4 -3
  52. package/dist/layout/walkRows.js +3 -2
  53. package/dist/layout/walkStrip.js +7 -6
  54. package/dist/layoutEngines.js +1 -5
  55. package/dist/layoutModes.js +7 -6
  56. package/dist/pathAnchoring.js +2 -1
  57. package/dist/pathColors.js +3 -2
  58. package/dist/pathVisits.js +8 -0
  59. package/dist/pipeline.js +7 -6
  60. package/dist/referenceRampCss.js +5 -4
  61. package/dist/referenceStrip.js +5 -4
  62. package/dist/renderer/GeometryBuilder.js +4 -3
  63. package/dist/tubeMap/bundle.js +5 -4
  64. package/dist/tubeMap/coarsen.js +15 -13
  65. package/dist/tubeMap/draw.js +3 -2
  66. package/dist/tubeMap/nodeColors.js +5 -4
  67. package/dist/types/gbzWindow.d.ts +15 -1
  68. package/dist/types/gfa/gfaConverter.d.ts +1 -1
  69. package/dist/types/index.d.ts +3 -2
  70. package/dist/types/layout/deletionRoutes.d.ts +1 -2
  71. package/dist/types/pathAnchoring.d.ts +3 -2
  72. package/dist/types/pathVisits.d.ts +64 -0
  73. package/dist/types/types.d.ts +2 -1
  74. package/dist/types/version.d.ts +1 -1
  75. package/dist/version.js +1 -1
  76. package/dist/viewport.js +8 -7
  77. package/dist/walkEncoding.js +5 -4
  78. package/dist/walkHighlight.js +6 -5
  79. package/package.json +2 -1
  80. package/dist/chunks/chunk-6PYZYBBF.js +0 -226
  81. package/dist/chunks/chunk-LYJ4US66.js +0 -664
  82. package/dist/chunks/chunk-Q6FRNVDU.js +0 -531
  83. package/dist/layout/stressEngine.js +0 -11
  84. package/dist/layout/stressPlacement.js +0 -7
  85. package/dist/types/layout/stressEngine.d.ts +0 -27
  86. package/dist/types/layout/stressPlacement.d.ts +0 -5
package/README.md CHANGED
@@ -57,6 +57,26 @@ Release with `pnpm version patch`: it lints, tests, stamps `src/version.ts`,
57
57
  writes the changelog with git-cliff and pushes the `v*` tag, and `publish.yml`
58
58
  publishes to npm with trusted publishing.
59
59
 
60
+ ## See also
61
+
62
+ - [jbrowse-plugin-graphgenomeviewer](https://github.com/GMOD/jbrowse-plugin-graphgenomeviewer) -
63
+ JBrowse 2 plugin that browses these graphs by locus
64
+ - [BandageJS](https://github.com/cmdcolin/BandageJS) - standalone page for GFA
65
+ and gbz-base graphs
66
+ - [@jbrowse/graph-stress-layout](https://github.com/GMOD/graph-stress-layout) -
67
+ stress layout that keeps the reference straight
68
+ - [@gmod/gbz-base](https://github.com/GMOD/gbz-base-js) - range-request reader
69
+ for `.gbz.db` databases
70
+ - [ggbandage](https://github.com/GMOD/ggbandage) - Bandage-style graph figures
71
+ as ggplot2 layers
72
+ - [@jbrowse/tubemap-core](https://github.com/GMOD/tubemap-core) -
73
+ sequenceTubeMap's layout, without the DOM
74
+
75
+ Tutorials on [jbrowse.org](https://jbrowse.org/jb2/docs/tutorials/)
76
+
77
+ - [HPRC part 1: graph alleles and haplotypes](https://jbrowse.org/jb2/docs/tutorials/pangenome_hprc/)
78
+ - [HPRC part 3: repeat lengths](https://jbrowse.org/jb2/docs/tutorials/pangenome_hprc_repeats/)
79
+
60
80
  ## License
61
81
 
62
82
  Both Bandage and OGDF are GPL, which is why this package is GPL-3.0-or-later.
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  bubbleSubgraph
3
- } from "../chunks/chunk-A6PSWTLX.js";
4
- import "../chunks/chunk-IGJCTPFB.js";
3
+ } from "../chunks/chunk-4QTNXTGW.js";
4
+ import "../chunks/chunk-EMUUNWRU.js";
5
+ import "../chunks/chunk-RAEABQNW.js";
5
6
  import "../chunks/chunk-BPLIXMH7.js";
6
7
  import "../chunks/chunk-FYQWPEEY.js";
7
8
  export {
@@ -1,14 +1,15 @@
1
1
  import {
2
2
  graphBubbles,
3
3
  superbubblesFromGraph
4
- } from "../chunks/chunk-5GZEPPEW.js";
4
+ } from "../chunks/chunk-BEWLQADP.js";
5
5
  import "../chunks/chunk-CLOP7UVD.js";
6
- import "../chunks/chunk-A6PSWTLX.js";
6
+ import "../chunks/chunk-4QTNXTGW.js";
7
7
  import "../chunks/chunk-EHUBJDDB.js";
8
8
  import "../chunks/chunk-XKWD2RY3.js";
9
9
  import "../chunks/chunk-FX4RDMDN.js";
10
10
  import "../chunks/chunk-HNQPEMYE.js";
11
- import "../chunks/chunk-IGJCTPFB.js";
11
+ import "../chunks/chunk-EMUUNWRU.js";
12
+ import "../chunks/chunk-RAEABQNW.js";
12
13
  import "../chunks/chunk-BPLIXMH7.js";
13
14
  import "../chunks/chunk-2CVHXFK7.js";
14
15
  import "../chunks/chunk-CPMHA4W5.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  walkRows
3
- } from "./chunk-6PYZYBBF.js";
3
+ } from "./chunk-A647OH7N.js";
4
4
  import {
5
5
  ROW_HEIGHT_PX
6
6
  } from "./chunk-CPMHA4W5.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  trimOrigins
3
- } from "./chunk-IGJCTPFB.js";
3
+ } from "./chunk-EMUUNWRU.js";
4
4
 
5
5
  // src/bubbles/popBubble.ts
6
6
  function bubbleSubgraph(graph, segmentIds) {
@@ -0,0 +1,284 @@
1
+ import {
2
+ pathOrigin
3
+ } from "./chunk-EMUUNWRU.js";
4
+ import {
5
+ panSNContig,
6
+ panSNSample
7
+ } from "./chunk-BPLIXMH7.js";
8
+
9
+ // src/layout/walkRows.ts
10
+ function sampleOf(path) {
11
+ return path.sample ?? panSNSample(path.name);
12
+ }
13
+ function labelOf(path) {
14
+ return path.haplotype !== void 0 && path.sample !== void 0 ? `${path.sample}#${path.haplotype}` : sampleOf(path);
15
+ }
16
+ var NodeTable = class {
17
+ constructor(graph) {
18
+ this.index = /* @__PURE__ */ new Map();
19
+ this.lengths = [];
20
+ this.onReference = new Uint8Array(0);
21
+ this.referenceStart = new Float64Array(0);
22
+ this.referenceEnd = new Float64Array(0);
23
+ for (const node of graph.nodes) {
24
+ this.lengths[this.indexOf(node.id)] = node.length;
25
+ }
26
+ }
27
+ indexOf(id) {
28
+ let i = this.index.get(id);
29
+ if (i === void 0) {
30
+ i = this.lengths.length;
31
+ this.index.set(id, i);
32
+ this.lengths.push(0);
33
+ }
34
+ return i;
35
+ }
36
+ nodesOf(path) {
37
+ const nodes = new Int32Array(path.nodeIds.length);
38
+ path.nodeIds.forEach((id, k) => {
39
+ nodes[k] = this.indexOf(id);
40
+ });
41
+ return nodes;
42
+ }
43
+ spanAt(steps, k) {
44
+ const node = k >= 0 && k < steps.length ? steps[k] : -1;
45
+ return node >= 0 && this.onReference[node] ? { start: this.referenceStart[node], end: this.referenceEnd[node] } : void 0;
46
+ }
47
+ };
48
+ function stepsOf(pieces, table) {
49
+ const out = [];
50
+ let end;
51
+ for (const piece of pieces) {
52
+ if (end !== void 0 && piece.start !== void 0 && piece.start > end) {
53
+ out.push(end - piece.start);
54
+ }
55
+ let bp = 0;
56
+ for (const node of piece.nodes) {
57
+ out.push(node);
58
+ bp += table.lengths[node];
59
+ }
60
+ end = piece.start === void 0 ? void 0 : piece.start + bp;
61
+ }
62
+ return Float64Array.from(out);
63
+ }
64
+ function stepSpan(pieces, table, k) {
65
+ let end;
66
+ let at = 0;
67
+ let found;
68
+ for (const piece of pieces) {
69
+ if (piece.start === void 0 || end !== void 0 && piece.start < end) {
70
+ return void 0;
71
+ }
72
+ if (end !== void 0 && piece.start > end) {
73
+ if (at++ === k) {
74
+ found = { start: end, end: piece.start };
75
+ }
76
+ }
77
+ let pos = piece.start;
78
+ for (const node of piece.nodes) {
79
+ const len = table.lengths[node];
80
+ if (at++ === k) {
81
+ found = { start: pos, end: pos + len };
82
+ }
83
+ pos += len;
84
+ }
85
+ end = pos;
86
+ }
87
+ return found;
88
+ }
89
+ function sliceBetween(steps, table, region, flanked = true) {
90
+ if (!region || !flanked) {
91
+ return { ids: steps, complete: true, from: -1, to: -1 };
92
+ }
93
+ const { onReference, referenceStart, referenceEnd } = table;
94
+ let i0 = -1;
95
+ let i1 = -1;
96
+ let bestEnd = -Infinity;
97
+ let bestStart = Infinity;
98
+ for (let i = 0; i < steps.length; i++) {
99
+ const node = steps[i];
100
+ if (node >= 0 && onReference[node]) {
101
+ const end2 = referenceEnd[node];
102
+ const start = referenceStart[node];
103
+ if (end2 <= region.start && end2 > bestEnd) {
104
+ bestEnd = end2;
105
+ i0 = i;
106
+ }
107
+ if (start >= region.end && start < bestStart) {
108
+ bestStart = start;
109
+ i1 = i;
110
+ }
111
+ }
112
+ }
113
+ if (i0 >= 0 && i1 >= 0) {
114
+ const ids2 = steps.slice(Math.min(i0, i1) + 1, Math.max(i0, i1));
115
+ return {
116
+ ids: i0 < i1 ? ids2 : ids2.reverse(),
117
+ complete: true,
118
+ from: i0,
119
+ to: i1
120
+ };
121
+ }
122
+ const spanAt = (k) => table.spanAt(steps, k);
123
+ const flank = i0 >= 0 ? i0 : i1;
124
+ let near = -1;
125
+ for (let d = 1; flank >= 0 && near < 0 && d < steps.length; d++) {
126
+ near = [flank - d, flank + d].find((j) => spanAt(j) !== void 0) ?? -1;
127
+ }
128
+ if (near < 0) {
129
+ return { ids: steps, complete: false, from: -1, to: -1 };
130
+ }
131
+ const forward = near > flank === spanAt(near).start > spanAt(flank).start;
132
+ const after = forward === (flank === i0);
133
+ const ids = after ? steps.slice(flank + 1) : steps.slice(0, flank).reverse();
134
+ const last = ids.length > 0 ? ids.length - 1 : -1;
135
+ const end = last < 0 ? spanAt(flank) : spanAt(after ? flank + 1 + last : 0);
136
+ const stop = {
137
+ contigEnds: end !== void 0,
138
+ shortBp: !end ? 0 : Math.max(0, region.start - end.end, end.start - region.end)
139
+ };
140
+ return {
141
+ ids,
142
+ complete: false,
143
+ from: flank,
144
+ to: after ? steps.length : -1,
145
+ stop
146
+ };
147
+ }
148
+ function filterSamples(rows, samples) {
149
+ return samples ? rows.filter((r) => samples.includes(r.sample)).sort(
150
+ (a, b) => samples.indexOf(a.sample) - samples.indexOf(b.sample) || a.label.localeCompare(b.label)
151
+ ) : rows;
152
+ }
153
+ function walkRows(graph, region, unit) {
154
+ const paths = graph.paths ?? [];
155
+ const isReference = (p) => pathOrigin(p.name).name === graph.referencePath;
156
+ const referencePieces = paths.some(isReference) ? paths.filter(isReference).sort((a, b) => (a.start ?? 0) - (b.start ?? 0)) : paths.slice(0, 1);
157
+ const first = referencePieces[0];
158
+ const others = paths.filter((p) => !referencePieces.includes(p));
159
+ if (!first || others.length === 0) {
160
+ return void 0;
161
+ }
162
+ const walks = /* @__PURE__ */ new Map();
163
+ for (const path of others) {
164
+ const pieces = walks.get(path.name);
165
+ if (pieces) {
166
+ pieces.push(path);
167
+ } else {
168
+ walks.set(path.name, [path]);
169
+ }
170
+ }
171
+ const table = new NodeTable(graph);
172
+ const referenceStart = first.start ?? 0;
173
+ const cut = region && region.end > region.start ? region : void 0;
174
+ const referenceNodes = referencePieces.map((piece) => table.nodesOf(piece));
175
+ const nodeCount = table.lengths.length;
176
+ table.onReference = new Uint8Array(nodeCount);
177
+ table.referenceStart = new Float64Array(nodeCount);
178
+ table.referenceEnd = new Float64Array(nodeCount);
179
+ let reachesBefore = false;
180
+ let reachesAfter = false;
181
+ for (const [p, piece] of referencePieces.entries()) {
182
+ let pos = piece.start ?? 0;
183
+ for (const node of referenceNodes[p]) {
184
+ const len = table.lengths[node];
185
+ if (!table.onReference[node]) {
186
+ table.onReference[node] = 1;
187
+ table.referenceStart[node] = pos;
188
+ table.referenceEnd[node] = pos + len;
189
+ reachesBefore ||= cut !== void 0 && pos + len <= cut.start;
190
+ reachesAfter ||= cut !== void 0 && pos >= cut.end;
191
+ }
192
+ pos += len;
193
+ }
194
+ }
195
+ const flanked = cut === void 0 || reachesBefore && reachesAfter;
196
+ const rowOf = (paths2, nodes) => {
197
+ const path = paths2[0];
198
+ const pieces = paths2.map((piece, p) => ({
199
+ start: piece.start,
200
+ nodes: nodes?.[p] ?? table.nodesOf(piece)
201
+ })).sort((a, b) => (a.start ?? 0) - (b.start ?? 0));
202
+ const { ids, complete, from, to, stop } = sliceBetween(
203
+ stepsOf(pieces, table),
204
+ table,
205
+ cut,
206
+ flanked
207
+ );
208
+ const contig = path.contig ?? panSNContig(pathOrigin(path.name).name);
209
+ const axisSpan = stepSpan(pieces, table, from < 0 ? 0 : from);
210
+ const axis = !axisSpan ? void 0 : from < 0 ? { contig, start: axisSpan.start, reversed: false } : from < to ? { contig, start: axisSpan.end, reversed: false } : { contig, start: axisSpan.start, reversed: true };
211
+ const { lengths, onReference, referenceStart: referenceStart2, referenceEnd } = table;
212
+ const runs = [];
213
+ let last;
214
+ let bp = 0;
215
+ let offReferenceBp = 0;
216
+ let gapBp = 0;
217
+ let step = 0;
218
+ for (const node of ids) {
219
+ if (node < 0) {
220
+ last = { start: bp, bp: -node, onReference: false, gap: true };
221
+ runs.push(last);
222
+ bp -= node;
223
+ gapBp -= node;
224
+ step = 0;
225
+ continue;
226
+ }
227
+ const len = lengths[node];
228
+ const on = onReference[node] === 1;
229
+ const at = last?.referenceStart;
230
+ const forward = on && at !== void 0 && step >= 0 && at + last.bp === referenceStart2[node];
231
+ const backward = on && at !== void 0 && step <= 0 && referenceEnd[node] === at;
232
+ if (!on && last && !last.onReference && !last.gap) {
233
+ last.bp += len;
234
+ } else if (forward || backward) {
235
+ last.bp += len;
236
+ if (!forward) {
237
+ last.referenceStart = referenceStart2[node];
238
+ last.reversed = true;
239
+ }
240
+ step = forward ? 1 : -1;
241
+ } else {
242
+ last = {
243
+ start: bp,
244
+ bp: len,
245
+ onReference: on,
246
+ referenceStart: on ? referenceStart2[node] : void 0
247
+ };
248
+ runs.push(last);
249
+ step = 0;
250
+ }
251
+ bp += len;
252
+ if (!on) {
253
+ offReferenceBp += len;
254
+ }
255
+ }
256
+ return {
257
+ name: path.name,
258
+ label: labelOf(path),
259
+ sample: sampleOf(path),
260
+ haplotype: path.haplotype,
261
+ bp,
262
+ offReferenceBp,
263
+ gapBp,
264
+ complete,
265
+ stop,
266
+ runs,
267
+ axis
268
+ };
269
+ };
270
+ const origin = cut ? cut.start : referenceStart;
271
+ return {
272
+ origin,
273
+ unit,
274
+ reference: rowOf(referencePieces, referenceNodes),
275
+ rows: [...walks.values()].map((paths2) => rowOf(paths2)).sort(
276
+ (a, b) => Number(b.complete) - Number(a.complete) || b.bp - a.bp || a.label.localeCompare(b.label)
277
+ )
278
+ };
279
+ }
280
+
281
+ export {
282
+ filterSamples,
283
+ walkRows
284
+ };
@@ -1,32 +1,32 @@
1
1
  import {
2
2
  layoutEngine
3
- } from "./chunk-VK6XMP6B.js";
3
+ } from "./chunk-FLUQODT2.js";
4
4
  import {
5
5
  layoutModeByValue
6
- } from "./chunk-FUUJ76KD.js";
6
+ } from "./chunk-IFOZFVZK.js";
7
7
  import {
8
8
  parseRegion
9
- } from "./chunk-73RSLGZT.js";
9
+ } from "./chunk-FLFBYSJO.js";
10
10
  import {
11
11
  layoutGeometryInputs
12
12
  } from "./chunk-LOCJN3BZ.js";
13
13
  import {
14
14
  version
15
- } from "./chunk-2VTM3DHG.js";
15
+ } from "./chunk-KY4LV2Z6.js";
16
16
  import {
17
17
  axisScaleOf
18
- } from "./chunk-PT37VS5B.js";
18
+ } from "./chunk-QORSYW7J.js";
19
19
  import {
20
20
  facetLifts,
21
21
  walkLift
22
- } from "./chunk-MVMP6AGI.js";
22
+ } from "./chunk-QIVPRZ4H.js";
23
23
  import {
24
24
  walkKey
25
25
  } from "./chunk-2LQ5BWT7.js";
26
26
  import {
27
27
  buildGeometry,
28
28
  computeReferenceRamp
29
- } from "./chunk-4IYP43W6.js";
29
+ } from "./chunk-NP356MC2.js";
30
30
  import {
31
31
  abgrAlpha,
32
32
  abgrBlue,
@@ -36,14 +36,14 @@ import {
36
36
  import {
37
37
  pathLegend,
38
38
  walkLabelsOf
39
- } from "./chunk-XZ2BLAA6.js";
39
+ } from "./chunk-REE4GUDM.js";
40
40
  import {
41
41
  drawingBounds,
42
42
  engineSettingsOf,
43
43
  fitTransform,
44
44
  forceLayout,
45
45
  loadGraph
46
- } from "./chunk-HRAU4VTB.js";
46
+ } from "./chunk-MSX3BDO4.js";
47
47
  import {
48
48
  referenceLabel
49
49
  } from "./chunk-RAKOB6IV.js";
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-CLOP7UVD.js";
6
6
  import {
7
7
  bubbleSubgraph
8
- } from "./chunk-A6PSWTLX.js";
8
+ } from "./chunk-4QTNXTGW.js";
9
9
  import {
10
10
  coversGraph
11
11
  } from "./chunk-EHUBJDDB.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  engineKey,
3
3
  forceLayout
4
- } from "./chunk-HRAU4VTB.js";
4
+ } from "./chunk-MSX3BDO4.js";
5
5
 
6
6
  // src/layout/forceCache.ts
7
7
  var DEFAULT_SIZE = 4;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  REFERENCE_RAMP_MAX_HUE
3
- } from "./chunk-4IYP43W6.js";
3
+ } from "./chunk-NP356MC2.js";
4
4
 
5
5
  // src/referenceRampCss.ts
6
6
  function rampHueCss(hue) {
@@ -1,3 +1,6 @@
1
+ import {
2
+ PathVisitsBuilder
3
+ } from "./chunk-RAEABQNW.js";
1
4
  import {
2
5
  panSNSample
3
6
  } from "./chunk-BPLIXMH7.js";
@@ -13,23 +16,13 @@ function pathOrigin(pathName) {
13
16
  }
14
17
  function surveyPaths(paths, lengthOf) {
15
18
  const anchorPaths = [];
16
- const pathVisits = /* @__PURE__ */ new Map();
19
+ const visits = new PathVisitsBuilder();
17
20
  for (const path of paths) {
18
21
  const sample = panSNSample(path.name);
22
+ const p = visits.pathOf(path.name, sample);
19
23
  let pos = path.start;
20
24
  for (const step of path.steps) {
21
- const visit = {
22
- path: path.name,
23
- sample,
24
- start: pos,
25
- strand: step.strand
26
- };
27
- const existing = pathVisits.get(step.id);
28
- if (existing) {
29
- existing.push(visit);
30
- } else {
31
- pathVisits.set(step.id, [visit]);
32
- }
25
+ visits.addAt(visits.declare(step.id), p, pos, step.strand === "-");
33
26
  pos += lengthOf(step.id);
34
27
  }
35
28
  anchorPaths.push({
@@ -39,7 +32,7 @@ function surveyPaths(paths, lengthOf) {
39
32
  length: pos - path.start
40
33
  });
41
34
  }
42
- return { anchorPaths, pathVisits };
35
+ return { anchorPaths, pathVisits: visits.build() };
43
36
  }
44
37
  function chooseReferencePath(anchorPaths, preferred) {
45
38
  const named = anchorPaths.find(
@@ -49,41 +42,56 @@ function chooseReferencePath(anchorPaths, preferred) {
49
42
  }
50
43
  var OFF_REFERENCE_RANK = 1;
51
44
  function anchorNode(node, visits, reference, samplesOf) {
52
- let anchored = node;
53
- if (visits && visits.length > 0) {
54
- const anchor = visits.find((v) => v.path === reference) ?? visits[0];
55
- anchored = {
56
- ...node,
57
- stable: {
58
- refName: anchor.path,
59
- start: anchor.start,
60
- rank: anchor.path === reference ? REFERENCE_RANK : OFF_REFERENCE_RANK,
61
- strand: anchor.strand
62
- },
63
- samples: samplesOf(visits)
64
- };
45
+ const slot = visits.slot(node.name);
46
+ if (slot < 0 || visits.offsets[slot] === visits.offsets[slot + 1]) {
47
+ return node;
65
48
  }
66
- return anchored;
49
+ const own = visits.firstBy(slot, reference);
50
+ const anchor = own >= 0 ? own : visits.offsets[slot];
51
+ return {
52
+ ...node,
53
+ stable: {
54
+ refName: visits.paths[visits.path[anchor]],
55
+ start: visits.start[anchor],
56
+ rank: own >= 0 ? REFERENCE_RANK : OFF_REFERENCE_RANK,
57
+ strand: visits.strand(anchor)
58
+ },
59
+ samples: samplesOf(slot)
60
+ };
67
61
  }
68
- function sampleSorter(paths) {
69
- const sorted = [...new Set(paths.map((p) => p.sample))].sort();
62
+ function sampleSorter(visits) {
63
+ const sorted = [...new Set(visits.samples)].sort();
70
64
  const rank = new Map(sorted.map((sample, i) => [sample, i]));
65
+ const pathRank = Int32Array.from(visits.samples, (s) => rank.get(s));
71
66
  const seen = new Uint8Array(sorted.length);
72
- return (visits) => {
73
- const ranks = [];
74
- for (const { sample } of visits) {
75
- const r = rank.get(sample);
76
- if (r === void 0) {
77
- ranks.forEach((r2) => seen[r2] = 0);
78
- return [...new Set(visits.map((v) => v.sample))].sort();
79
- }
67
+ const ranks = new Int32Array(sorted.length);
68
+ return (slot) => {
69
+ let n = 0;
70
+ for (let i = visits.offsets[slot]; i < visits.offsets[slot + 1]; i++) {
71
+ const r = pathRank[visits.path[i]];
80
72
  if (seen[r] === 0) {
81
73
  seen[r] = 1;
82
- ranks.push(r);
74
+ ranks[n++] = r;
75
+ }
76
+ }
77
+ let out;
78
+ if (n === sorted.length) {
79
+ out = sorted;
80
+ seen.fill(0);
81
+ } else if (n * 8 < sorted.length) {
82
+ const found = ranks.subarray(0, n);
83
+ found.forEach((r) => seen[r] = 0);
84
+ out = Array.from(found.sort(), (r) => sorted[r]);
85
+ } else {
86
+ out = [];
87
+ for (let r = 0; r < sorted.length; r++) {
88
+ if (seen[r] === 1) {
89
+ seen[r] = 0;
90
+ out.push(sorted[r]);
91
+ }
83
92
  }
84
93
  }
85
- ranks.forEach((r) => seen[r] = 0);
86
- return Array.from(Int32Array.from(ranks).sort(), (r) => sorted[r]);
94
+ return out;
87
95
  };
88
96
  }
89
97
  function anchorFromPaths(graph, preferred) {
@@ -92,11 +100,12 @@ function anchorFromPaths(graph, preferred) {
92
100
  if (!reference || !anchorPaths || !pathVisits) {
93
101
  return graph;
94
102
  }
95
- const samplesOf = sampleSorter(anchorPaths);
103
+ const samplesOf = sampleSorter(pathVisits);
104
+ const referenceIndex = pathVisits.pathIndex(reference.name);
96
105
  return {
97
106
  ...graph,
98
107
  nodes: graph.nodes.map(
99
- (node) => anchorNode(node, pathVisits.get(node.name), reference.name, samplesOf)
108
+ (node) => anchorNode(node, pathVisits, referenceIndex, samplesOf)
100
109
  ),
101
110
  anchoredBy: "paths",
102
111
  referencePath: reference.name
@@ -5,23 +5,23 @@ import {
5
5
  stripGeneGaps,
6
6
  walkStripFrame,
7
7
  walkStripLabelsTree
8
- } from "./chunk-DMH4NL2M.js";
9
- import {
10
- walkRowsKey,
11
- walkRowsKeyTree,
12
- walkRowsTree
13
- } from "./chunk-FJZ2TB46.js";
8
+ } from "./chunk-WI7ZHJ27.js";
14
9
  import {
15
10
  Canvas2DRenderer
16
11
  } from "./chunk-WBCOREDZ.js";
17
12
  import {
18
- genePins
19
- } from "./chunk-BUBZ32IC.js";
13
+ walkRowsKey,
14
+ walkRowsKeyTree,
15
+ walkRowsTree
16
+ } from "./chunk-VZNKA3K2.js";
20
17
  import {
21
18
  EXON_COLOR,
22
19
  exonOutlineTree,
23
20
  exonStretches
24
21
  } from "./chunk-3S3YVOJ7.js";
22
+ import {
23
+ genePins
24
+ } from "./chunk-BUBZ32IC.js";
25
25
  import {
26
26
  geneLabelCandidates
27
27
  } from "./chunk-DRG4236Y.js";
@@ -36,17 +36,17 @@ import {
36
36
  } from "./chunk-LOCJN3BZ.js";
37
37
  import {
38
38
  version
39
- } from "./chunk-2VTM3DHG.js";
39
+ } from "./chunk-KY4LV2Z6.js";
40
40
  import {
41
41
  axisScaleOf
42
- } from "./chunk-PT37VS5B.js";
42
+ } from "./chunk-QORSYW7J.js";
43
43
  import {
44
44
  facetLifts,
45
45
  walkLift
46
- } from "./chunk-MVMP6AGI.js";
46
+ } from "./chunk-QIVPRZ4H.js";
47
47
  import {
48
48
  encodingStops
49
- } from "./chunk-KYY5363X.js";
49
+ } from "./chunk-VOWI544A.js";
50
50
  import {
51
51
  rangeText,
52
52
  walkKey
@@ -54,15 +54,15 @@ import {
54
54
  import {
55
55
  buildGeometry,
56
56
  computeReferenceRamp
57
- } from "./chunk-4IYP43W6.js";
57
+ } from "./chunk-NP356MC2.js";
58
58
  import {
59
59
  walkRowLabels,
60
60
  walkRowsExtent
61
- } from "./chunk-TOVOJNT7.js";
61
+ } from "./chunk-3XE3OUEN.js";
62
62
  import {
63
63
  pathLegend,
64
64
  walkLabelsOf
65
- } from "./chunk-XZ2BLAA6.js";
65
+ } from "./chunk-REE4GUDM.js";
66
66
  import {
67
67
  nodeInk
68
68
  } from "./chunk-PBENCR5L.js";
@@ -70,7 +70,7 @@ import {
70
70
  FIT_PADDING,
71
71
  drawingBounds,
72
72
  fitTransform
73
- } from "./chunk-HRAU4VTB.js";
73
+ } from "./chunk-MSX3BDO4.js";
74
74
  import {
75
75
  referenceLabel
76
76
  } from "./chunk-RAKOB6IV.js";