@jbrowse/bandage-core 12.7.1 → 13.1.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 (71) hide show
  1. package/README.md +42 -10
  2. package/dist/chunks/{chunk-F5CP5KSV.js → chunk-2HR33HEK.js} +43 -19
  3. package/dist/chunks/{chunk-XNLXC6GB.js → chunk-2TNFP3GC.js} +1 -1
  4. package/dist/chunks/{chunk-RQHIDUZR.js → chunk-4SM3YYY4.js} +6 -2
  5. package/dist/chunks/{chunk-3BLYOLTX.js → chunk-5PQQ4IXZ.js} +1 -1
  6. package/dist/chunks/{chunk-Q4B4O2M4.js → chunk-7ZS7UNYY.js} +1 -5
  7. package/dist/chunks/{chunk-H5NMBQZG.js → chunk-APOFTO4L.js} +1 -1
  8. package/dist/chunks/{chunk-6YVWF5TR.js → chunk-CDLHGGJH.js} +2 -2
  9. package/dist/chunks/{chunk-IDPBN2BP.js → chunk-DBLRFSET.js} +12 -13
  10. package/dist/chunks/{chunk-4J4IKYSL.js → chunk-FSOP446U.js} +6 -51
  11. package/dist/chunks/{chunk-QPKSULKV.js → chunk-IDYGRSNF.js} +1 -1
  12. package/dist/chunks/{chunk-WXUEAMJJ.js → chunk-IGQVO5L3.js} +1 -1
  13. package/dist/chunks/{chunk-KA6B7WCZ.js → chunk-JT2FJHD6.js} +1 -1
  14. package/dist/chunks/{chunk-EHEKIJ56.js → chunk-LJSZRCTZ.js} +2 -2
  15. package/dist/chunks/{chunk-7O7427XK.js → chunk-M2URPEV3.js} +1 -1
  16. package/dist/chunks/chunk-NPDW3JAD.js +118 -0
  17. package/dist/chunks/{chunk-FAWHP2CG.js → chunk-OB6OUWHG.js} +8 -8
  18. package/dist/chunks/{chunk-BPIELHWX.js → chunk-OROLXHDA.js} +2 -2
  19. package/dist/chunks/{chunk-ETYIYH7I.js → chunk-Q25JVERA.js} +5 -5
  20. package/dist/chunks/{chunk-LT66KA3W.js → chunk-QDP2NTAV.js} +3 -3
  21. package/dist/chunks/{chunk-TTFQTTBZ.js → chunk-RNROMUAS.js} +3 -3
  22. package/dist/chunks/{chunk-Q4X6O7BL.js → chunk-STHPR76Q.js} +22 -7
  23. package/dist/chunks/{chunk-QHCAFMHM.js → chunk-U7V64JZY.js} +1 -1
  24. package/dist/chunks/{chunk-O6SLIY74.js → chunk-WWQI7LPU.js} +195 -98
  25. package/dist/chunks/{chunk-3HNQW3HM.js → chunk-YI5HHKTR.js} +1 -1
  26. package/dist/chunks/{chunk-YAJT4IDN.js → chunk-Z2OUCH2J.js} +1 -1
  27. package/dist/chunks/{chunk-KCVW4VPK.js → chunk-Z2RG6IYI.js} +10 -10
  28. package/dist/cli/figure.js +22 -22
  29. package/dist/cli/fold.js +5 -5
  30. package/dist/figure.js +17 -17
  31. package/dist/figureData.js +20 -20
  32. package/dist/figureScene.js +13 -13
  33. package/dist/figureSettings.js +6 -6
  34. package/dist/gbzCut.js +4 -4
  35. package/dist/gbzWindow.js +3 -3
  36. package/dist/gfa/departures.js +26 -0
  37. package/dist/gfa/gfaConverter.js +1 -2
  38. package/dist/gfa/gfaTables.js +2 -2
  39. package/dist/gfa/graphTables.js +1 -2
  40. package/dist/index.js +39 -33
  41. package/dist/layout/forceCache.js +6 -6
  42. package/dist/layout/tubeMapLayout.js +5 -5
  43. package/dist/layout/walkRowDraw.js +4 -4
  44. package/dist/layout/walkRowLayout.js +6 -6
  45. package/dist/layout/walkRowRuns.js +3 -3
  46. package/dist/layout/walkRows.js +4 -4
  47. package/dist/layout/walkStrip.js +7 -7
  48. package/dist/layoutModes.js +8 -8
  49. package/dist/pipeline.js +5 -5
  50. package/dist/tubeMap/bundle.js +6 -6
  51. package/dist/tubeMap/coarsen.js +6 -6
  52. package/dist/tubeMap/deviations.js +6 -6
  53. package/dist/tubeMap/draw.js +5 -5
  54. package/dist/types/gfa/departures.d.ts +72 -0
  55. package/dist/types/gfa/graphTables.d.ts +35 -12
  56. package/dist/types/index.d.ts +4 -4
  57. package/dist/types/layout/deletionRoutes.d.ts +1 -1
  58. package/dist/types/layout/walkRowDraw.d.ts +4 -4
  59. package/dist/types/layout/walkRowRuns.d.ts +26 -6
  60. package/dist/types/layout/walkRows.d.ts +10 -4
  61. package/dist/types/types.d.ts +4 -25
  62. package/dist/types/version.d.ts +1 -1
  63. package/dist/types/walkHighlight.d.ts +1 -1
  64. package/dist/version.js +1 -1
  65. package/dist/viewport.js +6 -6
  66. package/dist/walkHighlight.js +2 -2
  67. package/dist/walkKey.js +2 -2
  68. package/package.json +3 -1
  69. package/dist/chunks/chunk-D7ZTAGDM.js +0 -168
  70. package/dist/gfa/walkStops.js +0 -28
  71. package/dist/types/gfa/walkStops.d.ts +0 -59
package/README.md CHANGED
@@ -15,18 +15,50 @@ npm install @jbrowse/bandage-core
15
15
 
16
16
  - `loadGraph` reads GFA or rGFA text. The caller decompresses a `.gfa.gz` first
17
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
18
+ [@jbrowse/graph-walks](https://github.com/GMOD/graph-walks) 6 cuts from a
19
+ [gfa-to-tabix](https://github.com/GMOD/gfa-to-tabix) 4 walk file, format 7
20
+ (`.walks.gz` beside its `.idx` directory), for a region on the reference. A
21
+ worker can transfer them without copying, and `graphTablesGFA` writes their
22
+ nodes, links and walks as GFA
22
23
  - `openGbz` and `cutGbzRegion` cut a window from a
23
24
  [gbz-base](https://github.com/jltsiren/gbz-base) database (`.gbz.db`) to GFA
24
25
  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
27
- `elsewhere,trimmed=400,chunk=GRCh38#0#chr22:20316160`
28
- (`src/gfa/walkStops.ts`). Walk rows split each gap at those stops and label
29
- each part with its cause
26
+
27
+ ### Departures
28
+
29
+ A walk-file cut's tables carry `departures`: every place over the window where a
30
+ haplotype's consecutive steps on the reference are not adjacent there, with the
31
+ breakpoint and strand of each end, the haplotype's own bp between them (`ownBp`,
32
+ from `hapStart` on its contig), the part of that the graph lacks (`missingBp`)
33
+ and how many times the reference passes each end's node. `src/gfa/departures.ts`
34
+ reads them.
35
+
36
+ - Walk rows draw the facts and make no call on what a departure is. A haplotype
37
+ with no step in the window is a `stepless` row, a hairline under the reference
38
+ between its departure's ends:
39
+ `no step on GRCh38 across 54 kb · 120 kb of its own`
40
+ - A gap between two pieces of a walk splits into the bp the cut trimmed
41
+ (`outside the extracted subgraph`), the bp the departures inside it say the
42
+ graph lacks (`not in the graph`), and the rest: the walk's own sequence the
43
+ cut did not read (`of its own, not read`), or, where the walk goes back to the
44
+ reference, `on nodes filed near chr22:20.3 Mb`, where it rejoins
45
+ - A walk reaching one flank reads as a lower bound. Its contig ends inside the
46
+ window only where its last step there is on the reference, with no departure
47
+ at that step and nothing the cut trimmed past it. A departure there says where
48
+ the walk goes on: `≥ 0.5 kb · goes on near chr1:4 kb · 4 kb of its own`. A
49
+ walk whose only step is a flank has no bp in the window and says just how it
50
+ goes on or that its contig ends at the window. A cut with no context stands
51
+ the reference's outermost nodes in for the flanks, so a walk that stops inside
52
+ reads the same way there rather than as a whole walk shorter than the
53
+ reference
54
+ - A row whose departure has an end on a node the reference passes more than once
55
+ says `placement choice`: the file's writer chose that pass
56
+ - Each row's `departures` lists those its runs do not draw as steps, for a
57
+ host's hover
58
+ - `GraphTables` mirrors graph-walks 6's, and `typecheck/graphWalks.ts` holds the
59
+ two equal. `departures` is required, so tables from a reader that states none
60
+ fail to compile; a source with none, such as GFA text or a gbz-base cut,
61
+ passes `departureTable()`
30
62
 
31
63
  ## Laying out and drawing
32
64
 
@@ -127,7 +159,7 @@ pnpm build # dist/ with declarations
127
159
  - [BandageJS](https://github.com/cmdcolin/BandageJS) - browser viewer for GFA
128
160
  files, walk files and gbz-base databases
129
161
  - [gfa-to-tabix](https://github.com/GMOD/gfa-to-tabix) - indexes a GFA by
130
- reference position, writing the `.walks.bed.gz` walk files
162
+ reference position, writing the `.walks.gz` walk files
131
163
  - [@jbrowse/graph-walks](https://github.com/GMOD/graph-walks) - range-request
132
164
  reader for walk files
133
165
  - [@jbrowse/graph-fmmm-layout](https://github.com/GMOD/graph-fmmm-layout) -
@@ -9,8 +9,13 @@ import {
9
9
  } from "./chunk-GQZVR5DW.js";
10
10
  import {
11
11
  GAP_CAUSE_TEXT,
12
- OUTSIDE_TEXT
13
- } from "./chunk-D7ZTAGDM.js";
12
+ OUTSIDE_TEXT,
13
+ PLACEMENT_CHOICE_TEXT,
14
+ departureSpan,
15
+ departureText,
16
+ placementChoice,
17
+ roughBp
18
+ } from "./chunk-NPDW3JAD.js";
14
19
  import {
15
20
  LABEL_CHAR_PX
16
21
  } from "./chunk-S43IBA5Y.js";
@@ -29,7 +34,7 @@ var ON_REFERENCE = "#2f8fd6";
29
34
  var OFF_REFERENCE = "#8e3fbf";
30
35
  var OUTSIDE_CUT = "#bdbdbd";
31
36
  var MISSING_INK = "#8a8a8a";
32
- var UNKNOWN_GAP = "#e2e2e2";
37
+ var OWN_GAP = "#e2e2e2";
33
38
  var ABRIDGED_GAP = "#d9a441";
34
39
  var GENE_INK = "#1c1c22";
35
40
  var BAR_PX = 12;
@@ -48,11 +53,11 @@ function signedLength(delta) {
48
53
  function units(bp, unit) {
49
54
  return unit ? ` \u2248 ${Math.round(bp / unit)} units` : "";
50
55
  }
51
- var near = ({ refName, start }) => `${panSNContig(refName)}:${start < 1e6 ? `${Math.round(start / 1e3)} kb` : `${(start / 1e6).toFixed(1)} Mb`}`;
56
+ var near = (refName, pos) => `${refName === void 0 ? "" : `${panSNContig(refName)}:`}${pos < 1e6 ? `${Math.round(pos / 1e3)} kb` : `${(pos / 1e6).toFixed(1)} Mb`}`;
52
57
  function stepsText(steps) {
53
58
  return steps < 1e3 ? `${steps}` : `${Math.round(steps / 1e3)} k`;
54
59
  }
55
- function gapsText(gapBp, runs, abridgedSteps = 0) {
60
+ function gapsText(gapBp, runs, abridgedSteps, refName) {
56
61
  if (gapBp <= 0) {
57
62
  return "";
58
63
  }
@@ -62,7 +67,9 @@ function gapsText(gapBp, runs, abridgedSteps = 0) {
62
67
  }
63
68
  const bpOf = (cause) => gaps.filter((g) => g.cause === cause).reduce((sum, g) => sum + g.bp, 0);
64
69
  const places = [
65
- ...new Set(gaps.flatMap((g) => g.chunk ? [near(g.chunk)] : []))
70
+ ...new Set(
71
+ gaps.flatMap((g) => g.near === void 0 ? [] : [near(refName, g.near)])
72
+ )
66
73
  ];
67
74
  const parts = [
68
75
  [bpOf("missing"), GAP_CAUSE_TEXT.missing],
@@ -70,25 +77,34 @@ function gapsText(gapBp, runs, abridgedSteps = 0) {
70
77
  bpOf("elsewhere"),
71
78
  `on nodes filed near ${places[0]}${places.length > 1 ? ` and ${places.length - 1} more place${places.length > 2 ? "s" : ""}` : ""}`
72
79
  ],
73
- [bpOf("unknown"), GAP_CAUSE_TEXT.unknown],
74
- [bpOf("deleted"), GAP_CAUSE_TEXT.deleted],
80
+ [bpOf("own"), GAP_CAUSE_TEXT.own],
75
81
  [bpOf(void 0), OUTSIDE_TEXT]
76
82
  ];
77
83
  const abridged = bpOf("abridged");
78
84
  return (abridged > 0 ? ` \xB7 ${stepsText(abridgedSteps)} steps, ${kb(abridged)} not loaded` : "") + parts.filter(([bp]) => bp > 0).map(([bp, text]) => ` \xB7 ${kb(bp)} ${text}`).join("");
79
85
  }
80
- function roughBp(bp) {
81
- return bp >= 1e6 ? `${Number((bp / 1e6).toPrecision(2))} Mb` : bp >= 1e3 ? `${Number((bp / 1e3).toPrecision(2))} kb` : `${bp} bp`;
86
+ function steplessText(departures, reference) {
87
+ const widest = [...departures].sort((a, b) => {
88
+ const x = departureSpan(a);
89
+ const y = departureSpan(b);
90
+ return y.end - y.start - (x.end - x.start);
91
+ })[0];
92
+ const more = departures.length - 1;
93
+ return widest ? [
94
+ departureText(widest, reference),
95
+ ...more > 0 ? [`${more} more departure${more > 1 ? "s" : ""}`] : [],
96
+ ...!placementChoice(widest) && departures.some(placementChoice) ? [PLACEMENT_CHOICE_TEXT] : []
97
+ ].join(" \xB7 ") : "";
82
98
  }
83
99
  function walkRowReadout(row, reference, unit, call) {
84
100
  const { bp, gapBp, complete, stop } = row;
85
101
  if (!reference) {
86
102
  return `${kb(bp)}${units(bp, unit)}`;
87
103
  }
88
- if (row.deletionBp !== void 0) {
89
- return `no step on the reference across ${roughBp(row.deletionBp)}`;
104
+ if (row.stepless) {
105
+ return steplessText(row.departures ?? [], reference.sample);
90
106
  }
91
- const outside = gapsText(gapBp, row.runs, row.abridgedSteps);
107
+ const outside = `${gapsText(gapBp, row.runs, row.abridgedSteps ?? 0, reference.name)}${row.placementChoice ? ` \xB7 ${PLACEMENT_CHOICE_TEXT}` : ""}`;
92
108
  const called = call ? ` \xB7 called ${kb(call.bp)}${call.spanningReads === 0 ? " \xB7 no spanning read" : ""}` : "";
93
109
  if (complete) {
94
110
  const delta = bp - reference.bp;
@@ -101,8 +117,9 @@ function walkRowReadout(row, reference, unit, call) {
101
117
  const where = stop.shortBp > 0 ? `${kb(stop.shortBp)} before` : "at";
102
118
  return `contig ends ${where} the ${region}${called}`;
103
119
  }
104
- const why = !stop ? "partial walk" : stop.contigEnds ? `contig ends inside the ${region}` : "does not rejoin the reference within the extracted subgraph";
105
- return `\u2265 ${kb(bp)}${units(bp, unit)} \xB7 ${why}${outside}${called}`;
120
+ const why = !stop ? "partial walk" : stop.contigEnds ? `contig ends inside the ${region}` : stop.goesOn ? `goes on near ${near(reference.name, stop.goesOn.near)} \xB7 ${roughBp(stop.goesOn.departure.ownBp)} of its own` : "does not rejoin the reference within the extracted subgraph";
121
+ const bound = bp === 0 ? "" : `\u2265 ${kb(bp)}${units(bp, unit)} \xB7 `;
122
+ return `${bound}${why}${outside}${called}`;
106
123
  }
107
124
  function readoutPlacement(text, endX, width) {
108
125
  const x = endX + 6;
@@ -126,7 +143,7 @@ function unitTicks(bp, unit, pxPerBp) {
126
143
  return ticks;
127
144
  }
128
145
  function gapStyle(cause) {
129
- return cause === "missing" ? { fill: MISSING_INK, px: MISSING_PX, label: GAP_CAUSE_TEXT.missing } : cause === "deleted" ? { fill: MISSING_INK, px: MISSING_PX, label: GAP_CAUSE_TEXT.deleted } : cause === "unknown" ? { fill: UNKNOWN_GAP, px: GAP_PX, label: GAP_CAUSE_TEXT.unknown } : cause === "abridged" ? { fill: ABRIDGED_GAP, px: GAP_PX, label: GAP_CAUSE_TEXT.abridged } : { fill: OUTSIDE_CUT, px: GAP_PX, label: OUTSIDE_TEXT };
146
+ return cause === "missing" ? { fill: MISSING_INK, px: MISSING_PX, label: GAP_CAUSE_TEXT.missing } : cause === "departure" ? { fill: MISSING_INK, px: MISSING_PX, label: GAP_CAUSE_TEXT.departure } : cause === "own" ? { fill: OWN_GAP, px: GAP_PX, label: GAP_CAUSE_TEXT.own } : cause === "abridged" ? { fill: ABRIDGED_GAP, px: GAP_PX, label: GAP_CAUSE_TEXT.abridged } : { fill: OUTSIDE_CUT, px: GAP_PX, label: OUTSIDE_TEXT };
130
147
  }
131
148
  function runPaint(run, ramp) {
132
149
  if (run.gap) {
@@ -245,8 +262,8 @@ function walkRowsKey(bars, o = {}) {
245
262
  for (const cause of [
246
263
  void 0,
247
264
  "missing",
248
- "deleted",
249
- "unknown",
265
+ "departure",
266
+ "own",
250
267
  "abridged"
251
268
  ]) {
252
269
  const { fill, px, label } = gapStyle(cause);
@@ -257,6 +274,13 @@ function walkRowsKey(bars, o = {}) {
257
274
  });
258
275
  }
259
276
  }
277
+ if ([bars.reference, ...bars.rows].some((row) => row.placementChoice)) {
278
+ entries.push({
279
+ swatch: { kind: "gene" },
280
+ label: `${PLACEMENT_CHOICE_TEXT}: the writer chose which pass of a node the reference passes more than once a step takes`,
281
+ note: true
282
+ });
283
+ }
260
284
  if (o.genes?.crowded) {
261
285
  entries.push({
262
286
  swatch: { kind: "gene" },
@@ -560,7 +584,7 @@ export {
560
584
  OFF_REFERENCE,
561
585
  OUTSIDE_CUT,
562
586
  MISSING_INK,
563
- UNKNOWN_GAP,
587
+ OWN_GAP,
564
588
  ABRIDGED_GAP,
565
589
  GENE_INK,
566
590
  BAR_PX,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  clampZoom
3
- } from "./chunk-TTFQTTBZ.js";
3
+ } from "./chunk-RNROMUAS.js";
4
4
 
5
5
  // src/viewport.ts
6
6
  function axisScaleOf(scale, pixelRows) {
@@ -6,7 +6,10 @@ import {
6
6
  } from "./chunk-5ORP7EFJ.js";
7
7
  import {
8
8
  gfaTables
9
- } from "./chunk-4J4IKYSL.js";
9
+ } from "./chunk-FSOP446U.js";
10
+ import {
11
+ departureTable
12
+ } from "./chunk-NPDW3JAD.js";
10
13
  import {
11
14
  panSNMatchesPrefix,
12
15
  panSNSample
@@ -200,7 +203,8 @@ function compactTables(cut) {
200
203
  offsets,
201
204
  steps,
202
205
  reversed
203
- }
206
+ },
207
+ departures: departureTable()
204
208
  };
205
209
  }
206
210
 
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ENGINE_DEFAULTS
3
- } from "./chunk-TTFQTTBZ.js";
3
+ } from "./chunk-RNROMUAS.js";
4
4
 
5
5
  // src/figureSettings.ts
6
6
  var FIGURE_DEFAULTS = {
@@ -1,9 +1,6 @@
1
1
  import {
2
2
  stableCoordinate
3
3
  } from "./chunk-CFXXFHRK.js";
4
- import {
5
- walkStopFields
6
- } from "./chunk-D7ZTAGDM.js";
7
4
  import {
8
5
  pathOrigin,
9
6
  surveyPaths
@@ -158,8 +155,7 @@ function convertGFAToGraph(gfaGraph, name = "Imported GFA") {
158
155
  start: walkStart(walk),
159
156
  sample: walk.sample,
160
157
  haplotype: walk.haplotype,
161
- contig: walk.contig,
162
- ...walkStopFields(walk.tags)
158
+ contig: walk.contig
163
159
  });
164
160
  recordPathEdges(nodeIds2, name2);
165
161
  }
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  walkRowRuns,
3
3
  walkRowsOf
4
- } from "./chunk-O6SLIY74.js";
4
+ } from "./chunk-WWQI7LPU.js";
5
5
 
6
6
  // src/layout/walkRows.ts
7
7
  function filterSamples(rows, samples) {
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  READOUT_ROOM,
3
3
  longestBar
4
- } from "./chunk-EHEKIJ56.js";
4
+ } from "./chunk-LJSZRCTZ.js";
5
5
  import {
6
6
  alongRow,
7
7
  barEnd,
8
8
  boxesGenes,
9
9
  rowPitch,
10
10
  rowSpan
11
- } from "./chunk-F5CP5KSV.js";
11
+ } from "./chunk-2HR33HEK.js";
12
12
  import {
13
13
  LABEL_CHAR_PX
14
14
  } from "./chunk-S43IBA5Y.js";
@@ -1,8 +1,3 @@
1
- import {
2
- stopAt,
3
- stopFields,
4
- walkStopTags
5
- } from "./chunk-D7ZTAGDM.js";
6
1
  import {
7
2
  PathVisits
8
3
  } from "./chunk-BEUTROKU.js";
@@ -21,14 +16,14 @@ function tablePath(w, p) {
21
16
  const start = w.starts[p];
22
17
  const steps = w.abridgedSteps?.[p] ?? Number.NaN;
23
18
  const abridged = Number.isNaN(steps) ? {} : { abridged: { steps, bp: w.abridgedBp?.[p] ?? 0 } };
19
+ const trimmedBefore = w.trimmedBefore?.[p];
20
+ const trimmedAfter = w.trimmedAfter?.[p];
24
21
  return fields ? {
25
22
  name: `${fields.sample}#${fields.haplotype}#${fields.contig}`,
26
23
  start,
27
24
  ...fields,
28
- ...stopFields(
29
- w.before && stopAt(w.before, p),
30
- w.after && stopAt(w.after, p)
31
- ),
25
+ ...trimmedBefore === void 0 ? {} : { trimmedBefore },
26
+ ...trimmedAfter === void 0 ? {} : { trimmedAfter },
32
27
  ...abridged
33
28
  } : { name: pLineName(walkName, start, w.ends[p]), start };
34
29
  }
@@ -81,7 +76,7 @@ function tableNodeIds({ nodes: n, links: l, walks: w }, traversals) {
81
76
  (segment, i) => `${segment}${canonical[i] === 2 ? "-" : "+"}`
82
77
  );
83
78
  }
84
- function graphFromTables({ nodes: n, links: l, walks: w, skips }, name = "Imported GFA") {
79
+ function graphFromTables({ nodes: n, links: l, walks: w, departures }, name = "Imported GFA") {
85
80
  const count = n.names.length;
86
81
  const declared = n.lengths.length;
87
82
  const drawnWalks = [];
@@ -268,10 +263,14 @@ function graphFromTables({ nodes: n, links: l, walks: w, skips }, name = "Import
268
263
  samples: pathSamples
269
264
  }) : void 0,
270
265
  anchoredBy: nodes.some((node) => node.stable) ? "tags" : void 0,
271
- ...skips?.names.length ? { skips } : {}
266
+ ...departures.names.length > 0 ? { departures } : {}
272
267
  };
273
268
  }
274
- function graphTablesGFA({ nodes, links, walks }) {
269
+ function graphTablesGFA({
270
+ nodes,
271
+ links,
272
+ walks
273
+ }) {
275
274
  const { names } = nodes;
276
275
  const lines = ["H VN:Z:1.1"];
277
276
  for (let i = 0; i < nodes.lengths.length; i++) {
@@ -295,7 +294,7 @@ function graphTablesGFA({ nodes, links, walks }) {
295
294
  steps.push([names[walks.steps[s]], walks.reversed[s]]);
296
295
  }
297
296
  lines.push(
298
- fields ? `W ${fields.sample} ${fields.haplotype} ${fields.contig} ${start} ${end} ${steps.map(([id, rev]) => (rev ? "<" : ">") + id).join("")}${walkStopTags(walks, p)}` : `P ${pLineName(name, start, end)} ${steps.map(([id, rev]) => id + (rev ? "-" : "+")).join(",")} *`
297
+ fields ? `W ${fields.sample} ${fields.haplotype} ${fields.contig} ${start} ${end} ${steps.map(([id, rev]) => (rev ? "<" : ">") + id).join("")}` : `P ${pLineName(name, start, end)} ${steps.map(([id, rev]) => id + (rev ? "-" : "+")).join(",")} *`
299
298
  );
300
299
  }
301
300
  return lines.join("\n");
@@ -1,9 +1,6 @@
1
1
  import {
2
- END_STOP_TAG,
3
- START_STOP_TAG,
4
- StopColumns,
5
- parseStopTag
6
- } from "./chunk-D7ZTAGDM.js";
2
+ departureTable
3
+ } from "./chunk-NPDW3JAD.js";
7
4
  import {
8
5
  Column
9
6
  } from "./chunk-BEUTROKU.js";
@@ -109,7 +106,6 @@ function readWalkBody(line, from, segments, steps) {
109
106
  }
110
107
  }
111
108
  finish(i);
112
- return i;
113
109
  }
114
110
  function walkFields(line) {
115
111
  const fields = [];
@@ -166,8 +162,6 @@ function gfaTables(text) {
166
162
  const walkEnds = [];
167
163
  const offsets = [0];
168
164
  const steps = stepColumns();
169
- const before = new StopColumns();
170
- const after = new StopColumns();
171
165
  for (const raw of lines) {
172
166
  if (raw.startsWith("L ")) {
173
167
  const [, source, strand1, target, strand2] = trimCR(raw).split(" ");
@@ -183,17 +177,7 @@ function gfaTables(text) {
183
177
  names.push(`${w.sample}#${w.haplotype}#${w.contig}`);
184
178
  walkStarts.push(w.start === "*" ? 0 : +w.start);
185
179
  walkEnds.push(w.end === "*" ? -1 : +w.end);
186
- const end = readWalkBody(line, w.body, segments, steps);
187
- const tags = walkTags(line, end);
188
- if (tags === void 0) {
189
- return void 0;
190
- }
191
- if (tags.before) {
192
- before.push(tags.before);
193
- }
194
- if (tags.after) {
195
- after.push(tags.after);
196
- }
180
+ readWalkBody(line, w.body, segments, steps);
197
181
  if (steps.nodes.length === offsets.at(-1)) {
198
182
  return void 0;
199
183
  }
@@ -201,11 +185,6 @@ function gfaTables(text) {
201
185
  }
202
186
  }
203
187
  }
204
- if ([before.kinds.length, after.kinds.length].some(
205
- (n) => n > 0 && n < names.length
206
- )) {
207
- return void 0;
208
- }
209
188
  return {
210
189
  nodes: {
211
190
  names: segments.names,
@@ -226,33 +205,9 @@ function gfaTables(text) {
226
205
  ends: Float64Array.from(walkEnds),
227
206
  offsets: Int32Array.from(offsets),
228
207
  steps: steps.nodes.data.slice(0, steps.nodes.length),
229
- reversed: steps.reversed.data.slice(0, steps.reversed.length),
230
- ...stopColumns(names.length, before, after)
231
- }
232
- };
233
- }
234
- function walkTags(line, from) {
235
- const out = {};
236
- for (const tag of from < line.length ? line.slice(from + 1).split(" ") : []) {
237
- const value = tag.slice(5);
238
- if (tag.startsWith(`${START_STOP_TAG}:Z:`)) {
239
- out.before = parseStopTag(value);
240
- if (!out.before) {
241
- return void 0;
242
- }
243
- } else if (tag.startsWith(`${END_STOP_TAG}:Z:`)) {
244
- out.after = parseStopTag(value);
245
- if (!out.after) {
246
- return void 0;
247
- }
248
- }
249
- }
250
- return out;
251
- }
252
- function stopColumns(walks, before, after) {
253
- return {
254
- ...before.kinds.length === walks && walks > 0 ? { before: before.table() } : {},
255
- ...after.kinds.length === walks && walks > 0 ? { after: after.table() } : {}
208
+ reversed: steps.reversed.data.slice(0, steps.reversed.length)
209
+ },
210
+ departures: departureTable()
256
211
  };
257
212
  }
258
213
 
@@ -6,7 +6,7 @@ import {
6
6
  haplotypeWanted,
7
7
  referencePathQuery,
8
8
  referenceSamplesOf
9
- } from "./chunk-RQHIDUZR.js";
9
+ } from "./chunk-4SM3YYY4.js";
10
10
  import {
11
11
  panSNSample
12
12
  } from "./chunk-2JL2JVZ2.js";
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var version = "12.7.1";
2
+ var version = "13.1.0";
3
3
 
4
4
  export {
5
5
  version
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pathSteps
3
- } from "./chunk-3HNQW3HM.js";
3
+ } from "./chunk-YI5HHKTR.js";
4
4
  import {
5
5
  pathOrigin
6
6
  } from "./chunk-QBI6SC74.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  walkRows
3
- } from "./chunk-H5NMBQZG.js";
3
+ } from "./chunk-APOFTO4L.js";
4
4
  import {
5
5
  barEnd
6
- } from "./chunk-F5CP5KSV.js";
6
+ } from "./chunk-2HR33HEK.js";
7
7
  import {
8
8
  ROW_HEIGHT_PX
9
9
  } from "./chunk-CPMHA4W5.js";
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-KKHXMJEE.js";
10
10
  import {
11
11
  referenceWalkName
12
- } from "./chunk-O6SLIY74.js";
12
+ } from "./chunk-WWQI7LPU.js";
13
13
  import {
14
14
  pathOrigin
15
15
  } from "./chunk-QBI6SC74.js";
@@ -0,0 +1,118 @@
1
+ // src/gfa/departures.ts
2
+ function departureAt(t, k) {
3
+ return {
4
+ name: t.names[k],
5
+ hapStart: t.hapStarts[k],
6
+ ownBp: t.ownBp[k],
7
+ missingBp: t.missingBp[k],
8
+ leavePos: t.leavePos[k],
9
+ leaveReversed: t.leaveReversed[k] === 1,
10
+ leavePasses: t.leavePasses[k],
11
+ rejoinPos: t.rejoinPos[k],
12
+ rejoinReversed: t.rejoinReversed[k] === 1,
13
+ rejoinPasses: t.rejoinPasses[k],
14
+ fromSteps: t.fromSteps[k] === 1
15
+ };
16
+ }
17
+ function departureTable(departures = []) {
18
+ return {
19
+ names: departures.map((d) => d.name),
20
+ hapStarts: Float64Array.from(departures, (d) => d.hapStart),
21
+ ownBp: Float64Array.from(departures, (d) => d.ownBp),
22
+ missingBp: Float64Array.from(departures, (d) => d.missingBp),
23
+ leavePos: Float64Array.from(departures, (d) => d.leavePos),
24
+ leaveReversed: Uint8Array.from(departures, (d) => d.leaveReversed ? 1 : 0),
25
+ leavePasses: Int32Array.from(departures, (d) => d.leavePasses),
26
+ rejoinPos: Float64Array.from(departures, (d) => d.rejoinPos),
27
+ rejoinReversed: Uint8Array.from(
28
+ departures,
29
+ (d) => d.rejoinReversed ? 1 : 0
30
+ ),
31
+ rejoinPasses: Int32Array.from(departures, (d) => d.rejoinPasses),
32
+ fromSteps: Uint8Array.from(departures, (d) => d.fromSteps ? 1 : 0),
33
+ offsets: new Int32Array(departures.length + 1),
34
+ steps: new Int32Array(0),
35
+ reversed: new Uint8Array(0)
36
+ };
37
+ }
38
+ function departureKind(d) {
39
+ return d.leaveReversed !== d.rejoinReversed ? "switch" : d.leavePos === d.rejoinPos ? "adjacent" : (d.leaveReversed ? d.rejoinPos > d.leavePos : d.rejoinPos < d.leavePos) ? "back" : "forward";
40
+ }
41
+ function placementChoice(d) {
42
+ return d.leavePasses > 1 || d.rejoinPasses > 1;
43
+ }
44
+ function departureSpan(d) {
45
+ return {
46
+ start: Math.min(d.leavePos, d.rejoinPos),
47
+ end: Math.max(d.leavePos, d.rejoinPos)
48
+ };
49
+ }
50
+ function roughBp(bp) {
51
+ return bp >= 1e6 ? `${Number((bp / 1e6).toPrecision(2))} Mb` : bp >= 1e3 ? `${Number((bp / 1e3).toPrecision(2))} kb` : `${bp} bp`;
52
+ }
53
+ function departureText(d, reference = "the reference") {
54
+ const { start, end } = departureSpan(d);
55
+ const apart = roughBp(end - start);
56
+ const kind = departureKind(d);
57
+ const ends = kind === "forward" ? `no step on ${reference} across ${apart}` : kind === "back" ? `rejoins ${reference} ${apart} back` : kind === "switch" ? `rejoins ${reference} on the other strand, ${apart} away` : `between adjacent steps on ${reference}`;
58
+ return [
59
+ ends,
60
+ `${roughBp(d.ownBp)} of its own`,
61
+ ...d.missingBp > 0 ? [`${roughBp(d.missingBp)} not in the graph`] : [],
62
+ ...placementChoice(d) ? [PLACEMENT_CHOICE_TEXT] : []
63
+ ].join(" \xB7 ");
64
+ }
65
+ var PLACEMENT_CHOICE_TEXT = "placement choice";
66
+ var GAP_CAUSE_TEXT = {
67
+ missing: "not in the graph",
68
+ elsewhere: "on nodes filed elsewhere",
69
+ own: "of its own, not read",
70
+ abridged: "abridged: steps not loaded",
71
+ // a row of departures alone: the haplotype has no step on the reference
72
+ // across the window, which says nothing of what it carries instead
73
+ departure: "no step on the reference"
74
+ };
75
+ var OUTSIDE_TEXT = "outside the extracted subgraph";
76
+ function gapParts(from, to, trimmed, departures) {
77
+ const bp = to - from;
78
+ const inside = departures.filter((d) => d.hapStart >= from && d.hapStart + d.ownBp <= to).sort((a, b) => a.hapStart - b.hapStart);
79
+ const first = inside[0];
80
+ return first ? splitGap(from, to, trimmed, inside, first) : [{ bp }];
81
+ }
82
+ function splitGap(from, to, trimmed, inside, first) {
83
+ const bp = to - from;
84
+ const left = Math.min(trimmed.after ?? 0, bp);
85
+ const right = Math.min(trimmed.before ?? 0, bp - left);
86
+ const between = bp - left - right;
87
+ const missing = Math.min(
88
+ inside.reduce((sum, d) => sum + d.missingBp, 0),
89
+ between
90
+ );
91
+ const spans = inside.length === 1 && first.hapStart === from && first.hapStart + first.ownBp === to;
92
+ const rest = spans ? { bp: between - missing, cause: "own" } : {
93
+ bp: between - missing,
94
+ cause: "elsewhere",
95
+ near: first.hapStart === from ? first.rejoinPos : first.leavePos
96
+ };
97
+ const parts = [
98
+ { bp: left },
99
+ { bp: missing, cause: "missing" },
100
+ rest,
101
+ { bp: right }
102
+ ];
103
+ return parts.filter((part) => part.bp > 0);
104
+ }
105
+
106
+ export {
107
+ departureAt,
108
+ departureTable,
109
+ departureKind,
110
+ placementChoice,
111
+ departureSpan,
112
+ roughBp,
113
+ departureText,
114
+ PLACEMENT_CHOICE_TEXT,
115
+ GAP_CAUSE_TEXT,
116
+ OUTSIDE_TEXT,
117
+ gapParts
118
+ };