@jbrowse/bandage-core 9.10.0 → 10.0.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.
Files changed (74) hide show
  1. package/dist/bubbles/popBubble.js +3 -2
  2. package/dist/bubbles/superbubbles.js +4 -3
  3. package/dist/chunks/{chunk-Q6UIUY6X.js → chunk-33T67FPZ.js} +1 -1
  4. package/dist/chunks/{chunk-TOVOJNT7.js → chunk-3APK25GI.js} +1 -1
  5. package/dist/chunks/{chunk-A6PSWTLX.js → chunk-4QTNXTGW.js} +1 -1
  6. package/dist/chunks/{chunk-5GZEPPEW.js → chunk-BEWLQADP.js} +1 -1
  7. package/dist/chunks/{chunk-2VTM3DHG.js → chunk-CDPYXHVR.js} +1 -1
  8. package/dist/chunks/{chunk-K5NYTPLC.js → chunk-DCJC32QW.js} +1 -1
  9. package/dist/chunks/{chunk-IZI7KIVX.js → chunk-E5UEYZWK.js} +1 -1
  10. package/dist/chunks/{chunk-IGJCTPFB.js → chunk-EMUUNWRU.js} +52 -43
  11. package/dist/chunks/{chunk-PIN7ZMTZ.js → chunk-EU6FBTQF.js} +4 -4
  12. package/dist/chunks/{chunk-LZWSZRUY.js → chunk-FG762CCP.js} +3 -8
  13. package/dist/chunks/{chunk-73RSLGZT.js → chunk-FLFBYSJO.js} +1 -1
  14. package/dist/chunks/{chunk-FUUJ76KD.js → chunk-ICXMWYOA.js} +5 -5
  15. package/dist/chunks/{chunk-CXKZYLYS.js → chunk-IM4SJUPO.js} +12 -22
  16. package/dist/chunks/{chunk-6PYZYBBF.js → chunk-KAN2WTG5.js} +1 -1
  17. package/dist/chunks/{chunk-BDWQQK33.js → chunk-KJYSOHVN.js} +1 -1
  18. package/dist/chunks/{chunk-4IYP43W6.js → chunk-NP356MC2.js} +1 -1
  19. package/dist/chunks/{chunk-TFAFIRZB.js → chunk-OEPCRURR.js} +1 -1
  20. package/dist/chunks/{chunk-PT37VS5B.js → chunk-OOLNLCIO.js} +1 -1
  21. package/dist/chunks/{chunk-OA7RIMZ2.js → chunk-PSMKPSO4.js} +89 -22
  22. package/dist/chunks/{chunk-NGODVSCA.js → chunk-Q6IOQP4J.js} +8 -8
  23. package/dist/chunks/{chunk-LTUWJKHD.js → chunk-Q7LYHGGQ.js} +114 -6
  24. package/dist/chunks/{chunk-MVMP6AGI.js → chunk-QIVPRZ4H.js} +12 -7
  25. package/dist/chunks/{chunk-J7YKQ5YW.js → chunk-QXAB2FLJ.js} +1 -1
  26. package/dist/chunks/chunk-RAEABQNW.js +227 -0
  27. package/dist/chunks/{chunk-XZ2BLAA6.js → chunk-REE4GUDM.js} +1 -1
  28. package/dist/chunks/{chunk-2FLBFVMO.js → chunk-RJXPPYA7.js} +13 -13
  29. package/dist/chunks/{chunk-KYY5363X.js → chunk-VOWI544A.js} +1 -1
  30. package/dist/chunks/{chunk-FJZ2TB46.js → chunk-VZNKA3K2.js} +2 -2
  31. package/dist/chunks/{chunk-HRAU4VTB.js → chunk-W4GZCVUK.js} +6 -6
  32. package/dist/chunks/{chunk-DMH4NL2M.js → chunk-WI7ZHJ27.js} +2 -2
  33. package/dist/cli/figure.js +24 -23
  34. package/dist/cli/fold.js +6 -5
  35. package/dist/figure.js +19 -18
  36. package/dist/figureData.js +20 -19
  37. package/dist/figureSettings.js +7 -6
  38. package/dist/gbzCut.js +3 -2
  39. package/dist/gbzWindow.js +6 -1
  40. package/dist/gfa/gfaConverter.js +3 -2
  41. package/dist/gfa/graphTables.js +2 -1
  42. package/dist/index.js +57 -47
  43. package/dist/layout/forceCache.js +7 -6
  44. package/dist/layout/trimToWindow.js +17 -23
  45. package/dist/layout/tubeMapLayout.js +4 -3
  46. package/dist/layout/walkRowDraw.js +6 -5
  47. package/dist/layout/walkRowLayout.js +4 -3
  48. package/dist/layout/walkRows.js +3 -2
  49. package/dist/layout/walkStrip.js +7 -6
  50. package/dist/layoutModes.js +8 -7
  51. package/dist/pathAnchoring.js +2 -1
  52. package/dist/pathColors.js +3 -2
  53. package/dist/pathVisits.js +8 -0
  54. package/dist/pipeline.js +6 -5
  55. package/dist/referenceRampCss.js +5 -4
  56. package/dist/referenceStrip.js +5 -4
  57. package/dist/renderer/GeometryBuilder.js +4 -3
  58. package/dist/tubeMap/bundle.js +5 -4
  59. package/dist/tubeMap/coarsen.js +15 -13
  60. package/dist/tubeMap/draw.js +4 -3
  61. package/dist/tubeMap/nodeColors.js +5 -4
  62. package/dist/types/gbzWindow.d.ts +15 -1
  63. package/dist/types/gfa/gfaConverter.d.ts +1 -1
  64. package/dist/types/index.d.ts +2 -1
  65. package/dist/types/layout/deletionRoutes.d.ts +1 -1
  66. package/dist/types/pathAnchoring.d.ts +3 -2
  67. package/dist/types/pathVisits.d.ts +64 -0
  68. package/dist/types/types.d.ts +2 -1
  69. package/dist/types/version.d.ts +1 -1
  70. package/dist/version.js +1 -1
  71. package/dist/viewport.js +7 -6
  72. package/dist/walkEncoding.js +5 -4
  73. package/dist/walkHighlight.js +6 -5
  74. package/package.json +1 -1
@@ -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,7 +1,7 @@
1
1
  import {
2
2
  engineKey,
3
3
  forceLayout
4
- } from "./chunk-HRAU4VTB.js";
4
+ } from "./chunk-W4GZCVUK.js";
5
5
 
6
6
  // src/layout/forceCache.ts
7
7
  var DEFAULT_SIZE = 4;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  walkRows
3
- } from "./chunk-6PYZYBBF.js";
3
+ } from "./chunk-KAN2WTG5.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) {
@@ -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,5 +1,5 @@
1
1
  // src/version.ts
2
- var version = "9.10.0";
2
+ var version = "10.0.0";
3
3
 
4
4
  export {
5
5
  version
@@ -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,6 +1,6 @@
1
1
  import {
2
2
  ENGINE_DEFAULTS
3
- } from "./chunk-HRAU4VTB.js";
3
+ } from "./chunk-W4GZCVUK.js";
4
4
 
5
5
  // src/figureSettings.ts
6
6
  var FIGURE_DEFAULTS = {
@@ -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
@@ -1,15 +1,15 @@
1
- import {
2
- tubeMapMismatches
3
- } from "./chunk-XXT2JCAC.js";
4
1
  import {
5
2
  MAX_GAP_PX
6
3
  } from "./chunk-HK5Y2YWV.js";
4
+ import {
5
+ tubeMapMismatches
6
+ } from "./chunk-XXT2JCAC.js";
7
7
  import {
8
8
  readColor
9
9
  } from "./chunk-CWFNEKST.js";
10
10
  import {
11
11
  pathOrigin
12
- } from "./chunk-IGJCTPFB.js";
12
+ } from "./chunk-EMUUNWRU.js";
13
13
 
14
14
  // src/tubeMap/draw.ts
15
15
  import { curvePaths, nodeOutlinePath } from "@jbrowse/tubemap-core";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  pathSteps
3
- } from "./chunk-CXKZYLYS.js";
3
+ } from "./chunk-IM4SJUPO.js";
4
4
  import {
5
5
  pathOrigin
6
- } from "./chunk-IGJCTPFB.js";
6
+ } from "./chunk-EMUUNWRU.js";
7
7
 
8
8
  // src/tubeMap/bundle.ts
9
9
  function bundleRoutes(graph, groupOf = () => "", merge = true) {
@@ -67,12 +67,7 @@ function bundleRoutes(graph, groupOf = () => "", merge = true) {
67
67
  ...graph,
68
68
  paths: kept,
69
69
  anchorPaths: graph.anchorPaths?.filter((p) => keptWalks.has(p.name)),
70
- pathVisits: graph.pathVisits ? new Map(
71
- [...graph.pathVisits].map(([segment, visits]) => [
72
- segment,
73
- visits.filter((v) => keptWalks.has(v.path))
74
- ])
75
- ) : void 0
70
+ pathVisits: graph.pathVisits?.filter((path) => keptWalks.has(path))
76
71
  };
77
72
  }
78
73
 
@@ -5,7 +5,7 @@ import {
5
5
  referencePathQuery,
6
6
  referenceSamplesOf,
7
7
  resolveReferenceSample
8
- } from "./chunk-LTUWJKHD.js";
8
+ } from "./chunk-Q7LYHGGQ.js";
9
9
 
10
10
  // src/gbzCut.ts
11
11
  import { GBZBase } from "@gmod/gbz-base";
@@ -1,12 +1,12 @@
1
- import {
2
- sampleRowLayout
3
- } from "./chunk-LOEA5IHZ.js";
4
1
  import {
5
2
  hasTubeMapBackbone,
6
3
  hasTubeMapPaths,
7
4
  tubeMapLayout,
8
5
  tubeMapReferenceLayout
9
- } from "./chunk-CXKZYLYS.js";
6
+ } from "./chunk-IM4SJUPO.js";
7
+ import {
8
+ sampleRowLayout
9
+ } from "./chunk-LOEA5IHZ.js";
10
10
  import {
11
11
  anchoredLayout
12
12
  } from "./chunk-L3O7AWLI.js";
@@ -15,7 +15,7 @@ import {
15
15
  } from "./chunk-HNQPEMYE.js";
16
16
  import {
17
17
  walkRowLayout
18
- } from "./chunk-TOVOJNT7.js";
18
+ } from "./chunk-3APK25GI.js";
19
19
  import {
20
20
  isBackbone,
21
21
  isOffReference
@@ -6,10 +6,10 @@ import {
6
6
  import {
7
7
  pathCssColor,
8
8
  pathGreyCssColor
9
- } from "./chunk-XZ2BLAA6.js";
9
+ } from "./chunk-REE4GUDM.js";
10
10
  import {
11
11
  pathOrigin
12
- } from "./chunk-IGJCTPFB.js";
12
+ } from "./chunk-EMUUNWRU.js";
13
13
  import {
14
14
  ownStrand,
15
15
  strandSides
@@ -22,30 +22,19 @@ import {
22
22
  import { forward, isReverse, layoutTubeMap } from "@jbrowse/tubemap-core";
23
23
  function pathSteps(graph) {
24
24
  const nodeById = new Map(graph.nodes.map((n) => [n.id, n]));
25
- const strands = /* @__PURE__ */ new Map();
26
- for (const [segment, visits] of graph.pathVisits ?? []) {
27
- for (const visit of visits) {
28
- const key = `${visit.path} ${segment}`;
29
- const list = strands.get(key);
30
- if (list) {
31
- list.push(visit.strand);
32
- } else {
33
- strands.set(key, [visit.strand]);
34
- }
35
- }
36
- }
37
- const seen = /* @__PURE__ */ new Map();
25
+ const visits = graph.pathVisits;
26
+ const next = visits?.replay();
38
27
  return (graph.paths ?? []).map((path) => {
39
- const walk = pathOrigin(path.name).name;
28
+ const walk = visits?.pathIndex(pathOrigin(path.name).name) ?? -1;
40
29
  return path.nodeIds.flatMap((id) => {
41
30
  const node = nodeById.get(id);
42
31
  if (!node) {
43
32
  return [];
44
33
  }
45
- const key = `${walk} ${node.name}`;
46
- const k = seen.get(key) ?? 0;
47
- seen.set(key, k + 1);
48
- return [{ node, strand: strands.get(key)?.[k] ?? canonicalStrand(node) }];
34
+ const at = visits && next ? next(visits.slot(node.name), walk) : -1;
35
+ return [
36
+ { node, strand: at >= 0 ? visits.strand(at) : canonicalStrand(node) }
37
+ ];
49
38
  });
50
39
  });
51
40
  }
@@ -208,8 +197,9 @@ function boxGraph(graph, { members, flipped }) {
208
197
  ...path,
209
198
  nodeIds: path.nodeIds.filter((id) => !absorbed.has(id))
210
199
  })),
211
- pathVisits: graph.pathVisits && new Map(
212
- [...graph.pathVisits].filter(([name]) => !absorbedNames.has(name))
200
+ pathVisits: graph.pathVisits?.filter(
201
+ () => true,
202
+ (segment) => !absorbedNames.has(segment)
213
203
  )
214
204
  };
215
205
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pathOrigin
3
- } from "./chunk-IGJCTPFB.js";
3
+ } from "./chunk-EMUUNWRU.js";
4
4
  import {
5
5
  panSNContig,
6
6
  panSNSample
@@ -2,7 +2,7 @@ import {
2
2
  LIFT_BACKDROP_CSS,
3
3
  computeColorSchemeRange,
4
4
  getNodeColor
5
- } from "./chunk-4IYP43W6.js";
5
+ } from "./chunk-NP356MC2.js";
6
6
  import {
7
7
  abgrToCssRgba
8
8
  } from "./chunk-G2FD7S3C.js";
@@ -11,7 +11,7 @@ import {
11
11
  PATH_SATURATION,
12
12
  nameHue,
13
13
  pathHueAt
14
- } from "./chunk-XZ2BLAA6.js";
14
+ } from "./chunk-REE4GUDM.js";
15
15
  import {
16
16
  meanDepth,
17
17
  nodeWidthPx
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  computeColorSchemeRange,
3
3
  getNodeColor
4
- } from "./chunk-4IYP43W6.js";
4
+ } from "./chunk-NP356MC2.js";
5
5
  import {
6
6
  abgrToCssRgba
7
7
  } from "./chunk-G2FD7S3C.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  clampZoom
3
- } from "./chunk-HRAU4VTB.js";
3
+ } from "./chunk-W4GZCVUK.js";
4
4
 
5
5
  // src/viewport.ts
6
6
  function axisScaleOf(scale, pixelRows) {
@@ -1,3 +1,6 @@
1
+ import {
2
+ PathVisits
3
+ } from "./chunk-RAEABQNW.js";
1
4
  import {
2
5
  panSNSample
3
6
  } from "./chunk-BPLIXMH7.js";
@@ -7,6 +10,32 @@ function walkFields(panSN) {
7
10
  const [sample = "", haplotype = "", ...contig] = panSN.split("#");
8
11
  return { sample, haplotype, contig: contig.join("#") };
9
12
  }
13
+ function namesByList(lists, names, listCount, pathNames) {
14
+ const starts = new Int32Array(listCount + 1);
15
+ for (const list of lists) {
16
+ starts[list + 1]++;
17
+ }
18
+ for (let i = 0; i < listCount; i++) {
19
+ starts[i + 1] += starts[i];
20
+ }
21
+ const fill = starts.slice(0, listCount);
22
+ const grouped = new Int32Array(lists.length);
23
+ lists.forEach((list, i) => {
24
+ grouped[fill[list]++] = names[i];
25
+ });
26
+ const listed = new Int32Array(pathNames.length).fill(-1);
27
+ return Array.from({ length: listCount }, (_, list) => {
28
+ const out = [];
29
+ for (let i = starts[list]; i < starts[list + 1]; i++) {
30
+ const k = grouped[i];
31
+ if (listed[k] !== list) {
32
+ listed[k] = list;
33
+ out.push(pathNames[k]);
34
+ }
35
+ }
36
+ return out;
37
+ });
38
+ }
10
39
  function graphFromTables({ nodes: n, links: l, walks: w }, name = "Imported GFA") {
11
40
  const count = n.names.length;
12
41
  const declared = n.lengths.length;
@@ -95,27 +124,54 @@ function graphFromTables({ nodes: n, links: l, walks: w }, name = "Imported GFA"
95
124
  }
96
125
  edgeLists.push(list);
97
126
  }
127
+ const adjacency = new Int32Array(count + 1);
128
+ for (let a = 0; a < count; a++) {
129
+ adjacency[a + 1] = adjacency[a] + (neighbours[a]?.length ?? 0) / 2;
130
+ }
131
+ const adjacentNode = new Int32Array(adjacency[count]);
132
+ const adjacentList = new Int32Array(adjacency[count]);
133
+ neighbours.forEach((near, a) => {
134
+ for (let j = 0; j < near.length; j += 2) {
135
+ adjacentNode[adjacency[a] + j / 2] = near[j];
136
+ adjacentList[adjacency[a] + j / 2] = near[j + 1];
137
+ }
138
+ });
139
+ const listOf = (a, b) => {
140
+ for (let j = adjacency[a]; j < adjacency[a + 1]; j++) {
141
+ if (adjacentNode[j] === b) {
142
+ return adjacentList[j];
143
+ }
144
+ }
145
+ return -1;
146
+ };
98
147
  const nameIndex = /* @__PURE__ */ new Map();
99
148
  const pathNames = [];
100
- const crossing = Array.from({ length: lists }, () => []);
149
+ const crossedList = new Int32Array(w.offsets[w.names.length] ?? 0);
150
+ const crossedName = new Int32Array(crossedList.length);
151
+ let crossings = 0;
101
152
  const lastWalk = new Int32Array(lists).fill(-1);
102
153
  const paths = [];
103
154
  const anchorPaths = [];
104
- const visits = new Array(count);
105
- const filled = new Int32Array(count);
155
+ const totalSteps = w.offsets[w.names.length] ?? 0;
156
+ const visitPath = new Int32Array(totalSteps);
157
+ const visitStart = new Float64Array(totalSteps);
158
+ const visitReversed = new Uint8Array(totalSteps);
159
+ const fill = new Int32Array(count).fill(-1);
106
160
  const visitOrder = [];
161
+ const blocks = [0];
162
+ const pathSamples = [];
107
163
  for (const p of drawnWalks) {
108
164
  const { sample, haplotype, contig } = walkFields(w.names[p]);
109
165
  const pathName = `${sample}#${+haplotype}#${contig}`;
110
166
  let named = nameIndex.get(pathName);
111
- const repeat = named !== void 0;
112
167
  if (named === void 0) {
113
168
  named = pathNames.length;
114
169
  nameIndex.set(pathName, named);
115
170
  pathNames.push(pathName);
171
+ pathSamples.push(panSNSample(pathName));
116
172
  }
117
173
  const start = w.starts[p];
118
- const visitSample = panSNSample(pathName);
174
+ const visitSample = pathSamples[named];
119
175
  const first = w.offsets[p];
120
176
  const nodeIds = new Array(w.offsets[p + 1] - first);
121
177
  let pos = start;
@@ -123,25 +179,22 @@ function graphFromTables({ nodes: n, links: l, walks: w }, name = "Imported GFA"
123
179
  for (let s = first; s < w.offsets[p + 1]; s++) {
124
180
  const node = w.steps[s];
125
181
  nodeIds[s - first] = ids[node];
126
- if (filled[node] === 0) {
127
- visits[node] = new Array(traversals[node]);
182
+ if (fill[node] === -1) {
183
+ fill[node] = blocks.at(-1);
184
+ blocks.push(fill[node] + traversals[node]);
128
185
  visitOrder.push(node);
129
186
  }
130
- visits[node][filled[node]++] = {
131
- path: pathName,
132
- sample: visitSample,
133
- start: pos,
134
- strand: w.reversed[s] ? "-" : "+"
135
- };
187
+ const at = fill[node]++;
188
+ visitPath[at] = named;
189
+ visitStart[at] = pos;
190
+ visitReversed[at] = w.reversed[s];
136
191
  pos += node < declared ? n.lengths[node] : 0;
137
192
  if (prev >= 0) {
138
- const list = pairList(prev, node);
139
- if (list !== void 0 && lastWalk[list] !== p) {
193
+ const list = listOf(prev, node);
194
+ if (list >= 0 && lastWalk[list] !== p) {
140
195
  lastWalk[list] = p;
141
- const names = crossing[list];
142
- if (!repeat || !names.includes(named)) {
143
- names.push(named);
144
- }
196
+ crossedList[crossings] = list;
197
+ crossedName[crossings++] = named;
145
198
  }
146
199
  }
147
200
  prev = node;
@@ -161,10 +214,16 @@ function graphFromTables({ nodes: n, links: l, walks: w }, name = "Imported GFA"
161
214
  length: pos - start
162
215
  });
163
216
  }
217
+ const listNames = namesByList(
218
+ crossedList.subarray(0, crossings),
219
+ crossedName,
220
+ lists,
221
+ pathNames
222
+ );
164
223
  edges.forEach((edge, i) => {
165
- const names = crossing[edgeLists[i]];
224
+ const names = listNames[edgeLists[i]];
166
225
  if (names.length > 0) {
167
- edge.pathIds = names.map((k) => pathNames[k]);
226
+ edge.pathIds = names;
168
227
  }
169
228
  });
170
229
  const walked = drawnWalks.length > 0;
@@ -174,7 +233,15 @@ function graphFromTables({ nodes: n, links: l, walks: w }, name = "Imported GFA"
174
233
  edges,
175
234
  paths: walked ? paths : void 0,
176
235
  anchorPaths: walked ? anchorPaths : void 0,
177
- pathVisits: walked ? new Map(visitOrder.map((node) => [n.names[node], visits[node]])) : void 0,
236
+ pathVisits: walked ? new PathVisits({
237
+ segments: visitOrder.map((node) => n.names[node]),
238
+ offsets: Int32Array.from(blocks),
239
+ path: visitPath.subarray(0, blocks.at(-1)),
240
+ start: visitStart.subarray(0, blocks.at(-1)),
241
+ reversed: visitReversed.subarray(0, blocks.at(-1)),
242
+ paths: pathNames,
243
+ samples: pathSamples
244
+ }) : void 0,
178
245
  anchoredBy: nodes.some((node) => node.stable) ? "tags" : void 0
179
246
  };
180
247
  }
@@ -3,30 +3,30 @@ import {
3
3
  } from "./chunk-VK6XMP6B.js";
4
4
  import {
5
5
  layoutModeByValue
6
- } from "./chunk-FUUJ76KD.js";
6
+ } from "./chunk-ICXMWYOA.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-CDPYXHVR.js";
16
16
  import {
17
17
  axisScaleOf
18
- } from "./chunk-PT37VS5B.js";
18
+ } from "./chunk-OOLNLCIO.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-W4GZCVUK.js";
47
47
  import {
48
48
  referenceLabel
49
49
  } from "./chunk-RAKOB6IV.js";