@jbrowse/bandage-core 12.7.1 → 13.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 (71) hide show
  1. package/README.md +41 -9
  2. package/dist/chunks/{chunk-3HNQW3HM.js → chunk-252FIXUH.js} +1 -1
  3. package/dist/chunks/{chunk-F5CP5KSV.js → chunk-2HR33HEK.js} +43 -19
  4. package/dist/chunks/{chunk-QHCAFMHM.js → chunk-2T462OOE.js} +1 -1
  5. package/dist/chunks/{chunk-XNLXC6GB.js → chunk-2TNFP3GC.js} +1 -1
  6. package/dist/chunks/{chunk-FAWHP2CG.js → chunk-4D2OQVTR.js} +8 -8
  7. package/dist/chunks/{chunk-RQHIDUZR.js → chunk-4SM3YYY4.js} +6 -2
  8. package/dist/chunks/{chunk-3BLYOLTX.js → chunk-5PQQ4IXZ.js} +1 -1
  9. package/dist/chunks/{chunk-Q4B4O2M4.js → chunk-7ZS7UNYY.js} +1 -5
  10. package/dist/chunks/{chunk-O6SLIY74.js → chunk-BQ2GXFH6.js} +168 -80
  11. package/dist/chunks/{chunk-IDPBN2BP.js → chunk-DBLRFSET.js} +12 -13
  12. package/dist/chunks/{chunk-KA6B7WCZ.js → chunk-DZWYTA5R.js} +1 -1
  13. package/dist/chunks/{chunk-KCVW4VPK.js → chunk-EPCC5T5Y.js} +10 -10
  14. package/dist/chunks/{chunk-BPIELHWX.js → chunk-FLCRH3JY.js} +2 -2
  15. package/dist/chunks/{chunk-4J4IKYSL.js → chunk-FSOP446U.js} +6 -51
  16. package/dist/chunks/{chunk-EHEKIJ56.js → chunk-IDDGO6EW.js} +2 -2
  17. package/dist/chunks/{chunk-QPKSULKV.js → chunk-IDYGRSNF.js} +1 -1
  18. package/dist/chunks/{chunk-ETYIYH7I.js → chunk-K5QGQNPO.js} +5 -5
  19. package/dist/chunks/{chunk-H5NMBQZG.js → chunk-LHPUMKX4.js} +1 -1
  20. package/dist/chunks/chunk-NPDW3JAD.js +118 -0
  21. package/dist/chunks/{chunk-LT66KA3W.js → chunk-QDP2NTAV.js} +3 -3
  22. package/dist/chunks/{chunk-TTFQTTBZ.js → chunk-RNROMUAS.js} +3 -3
  23. package/dist/chunks/{chunk-WXUEAMJJ.js → chunk-RWCZLHXX.js} +1 -1
  24. package/dist/chunks/{chunk-7O7427XK.js → chunk-S3A345Q4.js} +1 -1
  25. package/dist/chunks/{chunk-Q4X6O7BL.js → chunk-STHPR76Q.js} +22 -7
  26. package/dist/chunks/{chunk-6YVWF5TR.js → chunk-VX57QTQD.js} +2 -2
  27. package/dist/chunks/{chunk-YAJT4IDN.js → chunk-Z2OUCH2J.js} +1 -1
  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 +2 -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
@@ -1,10 +1,13 @@
1
1
  import {
2
2
  tableNodeIds,
3
3
  tablePath
4
- } from "./chunk-IDPBN2BP.js";
4
+ } from "./chunk-DBLRFSET.js";
5
5
  import {
6
- gapParts
7
- } from "./chunk-D7ZTAGDM.js";
6
+ departureAt,
7
+ departureSpan,
8
+ gapParts,
9
+ placementChoice
10
+ } from "./chunk-NPDW3JAD.js";
8
11
  import {
9
12
  pathOrigin
10
13
  } from "./chunk-QBI6SC74.js";
@@ -26,9 +29,9 @@ var GAP_CAUSES = [
26
29
  void 0,
27
30
  "missing",
28
31
  "elsewhere",
29
- "unknown",
32
+ "own",
30
33
  "abridged",
31
- "deleted"
34
+ "departure"
32
35
  ];
33
36
  var CAUSE_SHIFT = 3;
34
37
  var causeFlags = (cause) => GAP_CAUSES.indexOf(cause) << CAUSE_SHIFT;
@@ -93,7 +96,8 @@ function graphPieces(graph) {
93
96
  lengths: Int32Array.from(lengths),
94
97
  names,
95
98
  reference,
96
- stableStart: (node) => stable.get(node) ?? Number.NaN
99
+ stableStart: (node) => stable.get(node) ?? Number.NaN,
100
+ departures: graph.departures
97
101
  };
98
102
  }
99
103
  function tablePieces(tables, referencePath, visits) {
@@ -127,7 +131,8 @@ function tablePieces(tables, referencePath, visits) {
127
131
  // steps
128
132
  names: visits ? tableNodeIds(tables) : n.names,
129
133
  reference,
130
- stableStart: (node) => node < n.lengths.length && n.ranks[node] === 0 && onReferenceContig(n.refNames[n.refs[node]]) ? n.starts[node] : Number.NaN
134
+ stableStart: (node) => node < n.lengths.length && n.ranks[node] === 0 && onReferenceContig(n.refNames[n.refs[node]]) ? n.starts[node] : Number.NaN,
135
+ departures: tables.departures
131
136
  };
132
137
  }
133
138
  function sampleOf(path) {
@@ -187,7 +192,8 @@ function walkRowRuns(source, region, o = {}) {
187
192
  lengths,
188
193
  names,
189
194
  reference,
190
- stableStart
195
+ stableStart,
196
+ departures
191
197
  } = "walks" in source ? tablePieces(source, o.referencePath, o.visits) : graphPieces(source);
192
198
  const declared = lengths.length;
193
199
  const lengthOf = (node) => node < declared ? lengths[node] : 0;
@@ -198,8 +204,8 @@ function walkRowRuns(source, region, o = {}) {
198
204
  const referencePieces = pieceIds.filter((p) => nameOf(p) === reference).sort(byStart);
199
205
  const first = referencePieces[0];
200
206
  const others = pieceIds.filter((p) => nameOf(p) !== reference);
201
- const { skips } = source;
202
- if (first === void 0 || others.length === 0 && !skips?.names.length) {
207
+ const departuresOf = departuresByWalk(departures, reference);
208
+ if (first === void 0 || others.length === 0 && departuresOf.size === 0) {
203
209
  return void 0;
204
210
  }
205
211
  const walks = groupBy(others, nameOf);
@@ -208,6 +214,8 @@ function walkRowRuns(source, region, o = {}) {
208
214
  const revisits = /* @__PURE__ */ new Map();
209
215
  let flankEnd = -Infinity;
210
216
  let flankStart = Infinity;
217
+ let referenceLo = Infinity;
218
+ let referenceHi = -Infinity;
211
219
  const cut = region && region.end > region.start ? region : void 0;
212
220
  for (const piece of referencePieces) {
213
221
  let pos = startOf(piece) ?? 0;
@@ -224,6 +232,8 @@ function walkRowRuns(source, region, o = {}) {
224
232
  } else {
225
233
  spanStart[node] = pos;
226
234
  spanEnd[node] = pos + len;
235
+ referenceLo = Math.min(referenceLo, pos);
236
+ referenceHi = Math.max(referenceHi, pos + len);
227
237
  if (cut) {
228
238
  if (pos + len <= cut.start) {
229
239
  flankEnd = Math.max(flankEnd, pos + len);
@@ -238,26 +248,13 @@ function walkRowRuns(source, region, o = {}) {
238
248
  }
239
249
  const flanked = cut === void 0 || flankEnd > -Infinity && flankStart < Infinity;
240
250
  const runs = new Columns(5);
241
- const chunks = [];
242
- const chunkIndex = /* @__PURE__ */ new Map();
243
- const chunkOf = (chunk2) => {
244
- if (!chunk2) {
245
- return -1;
246
- }
247
- const key = `${chunk2.refName}:${chunk2.start}`;
248
- let i = chunkIndex.get(key);
249
- if (i === void 0) {
250
- i = chunks.length;
251
- chunkIndex.set(key, i);
252
- chunks.push(chunk2);
253
- }
254
- return i;
255
- };
256
251
  const visits = o.visits ? new Columns(4) : void 0;
257
252
  let steps = new Int32Array(0);
258
253
  let stepStart = new Float64Array(0);
259
254
  const rowOf = (pieces) => {
260
255
  const head = heads[pieces[0]];
256
+ const own = departuresOf.get(nameOf(pieces[0])) ?? [];
257
+ const extents = [];
261
258
  const ordered = [...pieces].sort(byStart);
262
259
  let count = ordered.length - 1;
263
260
  let abridgedSteps = 0;
@@ -291,9 +288,13 @@ function walkRowRuns(source, region, o = {}) {
291
288
  partsAt.set(
292
289
  length,
293
290
  gapParts(
294
- gap,
295
- previous === void 0 ? void 0 : heads[previous].after,
296
- heads[piece].before
291
+ start2 - gap,
292
+ start2,
293
+ {
294
+ after: heads[previous].trimmedAfter,
295
+ before: heads[piece].trimmedBefore
296
+ },
297
+ own
297
298
  )
298
299
  );
299
300
  steps[length] = -gap;
@@ -315,6 +316,9 @@ function walkRowRuns(source, region, o = {}) {
315
316
  pos += lengthOf(node);
316
317
  }
317
318
  end = start2 === void 0 ? void 0 : pos;
319
+ if (start2 !== void 0) {
320
+ extents.push([start2, pos]);
321
+ }
318
322
  previous = piece;
319
323
  }
320
324
  const onReference = (i) => i >= 0 && i < length && steps[i] >= 0 && !Number.isNaN(spanStart[steps[i]]);
@@ -322,33 +326,55 @@ function walkRowRuns(source, region, o = {}) {
322
326
  const id = steps[i];
323
327
  return stepStart[i] + (id < 0 ? -id : lengthOf(id));
324
328
  };
325
- const partialSide = (i0, i1) => {
326
- const flank = i0 >= 0 ? i0 : i1;
327
- let near = -1;
328
- for (let d = 1; near < 0 && d < length; d++) {
329
- near = [flank - d, flank + d].find(onReference) ?? -1;
330
- }
331
- if (near < 0) {
332
- return void 0;
333
- }
334
- const forward = near > flank === spanStart[steps[near]] > spanStart[steps[flank]];
335
- const after = forward === (flank === i0);
329
+ const endOf = (after) => {
336
330
  const last2 = after ? length - 1 : 0;
337
- const contigEnds = onReference(last2);
331
+ const edge = after ? stepEnd(last2) : stepStart[last2];
332
+ return {
333
+ last: last2,
334
+ departure: own.find(
335
+ (d) => after ? d.hapStart === edge : d.hapStart + d.ownBp === edge
336
+ ),
337
+ trimmed: after ? heads[ordered.at(-1)].trimmedAfter : heads[ordered[0]].trimmedBefore
338
+ };
339
+ };
340
+ const flankForward = (flank, rightward) => {
341
+ let near2 = -1;
342
+ for (let d = 1; near2 < 0 && d < length; d++) {
343
+ near2 = [flank - d, flank + d].find(onReference) ?? -1;
344
+ }
345
+ const tail = endOf(true);
346
+ const lead = endOf(false);
347
+ return near2 >= 0 ? near2 > flank === spanStart[steps[near2]] > spanStart[steps[flank]] : length > 1 ? void 0 : tail.departure ? !tail.departure.leaveReversed : lead.departure ? !lead.departure.rejoinReversed : (!tail.trimmed || !!lead.trimmed) === rightward;
348
+ };
349
+ const partialSide = (i0, i1, inside) => {
350
+ const flank = i0 >= 0 ? i0 : i1;
351
+ const rightward = flank === i0;
352
+ const forward = flankForward(flank, rightward);
353
+ const after = forward === rightward;
354
+ const { last: last2, departure, trimmed } = endOf(after);
355
+ const contigEnds = onReference(last2) && !departure && !trimmed;
338
356
  const stop2 = {
339
357
  contigEnds,
340
358
  shortBp: contigEnds ? Math.max(
341
359
  0,
342
360
  cut.start - spanEnd[steps[last2]],
343
361
  spanStart[steps[last2]] - cut.end
344
- ) : 0
362
+ ) : 0,
363
+ ...departure ? {
364
+ goesOn: {
365
+ departure,
366
+ near: after ? departure.rejoinPos : departure.leavePos
367
+ }
368
+ } : {}
345
369
  };
346
- return {
370
+ const skip = inside ? 0 : 1;
371
+ const from2 = after === inside ? stepStart[flank] : stepEnd(flank);
372
+ return forward === void 0 ? void 0 : {
347
373
  stop: stop2,
348
- lo: after ? flank + 1 : 0,
349
- hi: after ? length : flank,
374
+ lo: after ? flank + skip : 0,
375
+ hi: after ? length : flank + 1 - skip,
350
376
  backward: !forward,
351
- axisStart: forward ? after ? stepEnd(flank) : stepStart[0] : after ? stepEnd(length - 1) : stepStart[flank]
377
+ axisStart: forward ? after ? from2 : stepStart[0] : after ? stepEnd(length - 1) : from2
352
378
  };
353
379
  };
354
380
  let lo = 0;
@@ -381,6 +407,14 @@ function walkRowRuns(source, region, o = {}) {
381
407
  }
382
408
  return Number.isNaN(spanStart[id]) && (abridgedAt(i - 1) || abridgedAt(i + 1)) ? stableStart(id) : spanStart[id];
383
409
  };
410
+ const stopsInside = (i0, i1, inside) => {
411
+ complete = false;
412
+ const side = i0 >= 0 || i1 >= 0 ? partialSide(i0, i1, inside) : void 0;
413
+ if (side) {
414
+ ;
415
+ ({ lo, hi, backward, axisStart, stop } = side);
416
+ }
417
+ };
384
418
  let leftTrim = 0;
385
419
  let rightTrim = 0;
386
420
  if (cut && flanked) {
@@ -403,12 +437,7 @@ function walkRowRuns(source, region, o = {}) {
403
437
  }
404
438
  }
405
439
  if (i0 < 0 || i1 < 0) {
406
- complete = false;
407
- const inside = i0 >= 0 || i1 >= 0 ? partialSide(i0, i1) : void 0;
408
- if (inside) {
409
- ;
410
- ({ lo, hi, backward, axisStart, stop } = inside);
411
- }
440
+ stopsInside(i0, i1, false);
412
441
  } else {
413
442
  lo = Math.min(i0, i1) + 1;
414
443
  hi = Math.max(i0, i1);
@@ -419,6 +448,23 @@ function walkRowRuns(source, region, o = {}) {
419
448
  leftTrim = trimAbridged(i0 + inward, flankEnd - bestEnd);
420
449
  rightTrim = trimAbridged(i1 - inward, bestStart - flankStart);
421
450
  }
451
+ } else if (cut && ordered.some(
452
+ (p) => heads[p].trimmedBefore !== void 0 || heads[p].trimmedAfter !== void 0
453
+ )) {
454
+ let i0 = -1;
455
+ let i1 = -1;
456
+ for (let i = 0; i < length; i++) {
457
+ const start2 = placeStart(i);
458
+ if (i0 < 0 && start2 === referenceLo) {
459
+ i0 = i;
460
+ }
461
+ if (i1 < 0 && start2 + lengthOf(steps[i]) === referenceHi) {
462
+ i1 = i;
463
+ }
464
+ }
465
+ if (i0 < 0 || i1 < 0) {
466
+ stopsInside(i0, i1, true);
467
+ }
422
468
  }
423
469
  const contig = head.contig ?? panSNContig(pathOrigin(head.name).name);
424
470
  const axis2 = unplaced || length === 0 ? void 0 : axisStart !== void 0 ? { contig, start: axisStart, reversed: backward } : flankFrom < 0 ? { contig, start: stepStart[0], reversed: false } : flankFrom < flankTo ? {
@@ -470,7 +516,7 @@ function walkRowRuns(source, region, o = {}) {
470
516
  part.bp,
471
517
  Number.NaN,
472
518
  RUN_GAP | causeFlags(part.cause),
473
- chunkOf(part.chunk)
519
+ part.near ?? Number.NaN
474
520
  );
475
521
  bp2 += part.bp;
476
522
  }
@@ -502,7 +548,7 @@ function walkRowRuns(source, region, o = {}) {
502
548
  } else {
503
549
  lastFlags = on ? RUN_ON_REFERENCE : 0;
504
550
  lastRef = on ? at : Number.NaN;
505
- runs.push(bp2, len, lastRef, lastFlags, -1);
551
+ runs.push(bp2, len, lastRef, lastFlags, Number.NaN);
506
552
  last = runs.length - 1;
507
553
  step = 0;
508
554
  }
@@ -515,6 +561,9 @@ function walkRowRuns(source, region, o = {}) {
515
561
  }
516
562
  runs.endRow();
517
563
  visits?.endRow();
564
+ const undrawn = own.filter(
565
+ (d) => !extents.some(([a, b]) => d.hapStart > a && d.hapStart + d.ownBp < b)
566
+ );
518
567
  return {
519
568
  name: head.name,
520
569
  label: labelOf(head),
@@ -527,19 +576,38 @@ function walkRowRuns(source, region, o = {}) {
527
576
  stop,
528
577
  axis: axis2,
529
578
  ...abridgedSteps > 0 ? { abridgedSteps } : {},
530
- ...leftTrim + rightTrim > 0 ? { estimated: true } : {}
579
+ ...leftTrim + rightTrim > 0 ? { estimated: true } : {},
580
+ ...undrawn.length > 0 ? { departures: undrawn } : {},
581
+ ...own.some(placementChoice) ? { placementChoice: true } : {}
531
582
  };
532
583
  };
533
- const skipRowOf = (name, start2, end, bar2) => {
534
- const from2 = bar2 ? Math.max(start2, bar2.start) : start2;
535
- const bp2 = Math.max((bar2 ? Math.min(end, bar2.end) : end) - from2, 0);
536
- runs.push(
537
- from2 - (bar2 ? bar2.start : start2),
538
- bp2,
539
- Number.NaN,
540
- RUN_GAP | causeFlags("deleted"),
541
- -1
542
- );
584
+ const steplessRowOf = (name, own, bar2) => {
585
+ const spans = own.map(departureSpan).sort((a, b) => a.start - b.start);
586
+ const base = bar2?.start ?? spans[0]?.start ?? 0;
587
+ const merged = [];
588
+ for (const span of spans) {
589
+ const start2 = bar2 ? Math.max(span.start, bar2.start) : span.start;
590
+ const end = bar2 ? Math.min(span.end, bar2.end) : span.end;
591
+ const last = merged.at(-1);
592
+ if (end > start2) {
593
+ if (last && start2 <= last.end) {
594
+ last.end = Math.max(last.end, end);
595
+ } else {
596
+ merged.push({ start: start2, end });
597
+ }
598
+ }
599
+ }
600
+ let gapBp = 0;
601
+ for (const { start: start2, end } of merged) {
602
+ runs.push(
603
+ start2 - base,
604
+ end - start2,
605
+ Number.NaN,
606
+ RUN_GAP | causeFlags("departure"),
607
+ Number.NaN
608
+ );
609
+ gapBp += end - start2;
610
+ }
543
611
  runs.endRow();
544
612
  visits?.endRow();
545
613
  const head = { name, ...panSNFields(name) };
@@ -549,12 +617,14 @@ function walkRowRuns(source, region, o = {}) {
549
617
  sample: sampleOf(head),
550
618
  haplotype: head.haplotype,
551
619
  bp: 0,
552
- offReferenceBp: 0,
553
- gapBp: bp2,
620
+ offReferenceBp: own.reduce((sum, d) => sum + d.ownBp, 0),
621
+ gapBp,
554
622
  complete: true,
555
623
  stop: void 0,
556
624
  axis: void 0,
557
- deletionBp: end - start2
625
+ departures: own,
626
+ stepless: true,
627
+ ...own.some(placementChoice) ? { placementChoice: true } : {}
558
628
  };
559
629
  };
560
630
  const referenceRow = rowOf(referencePieces);
@@ -568,16 +638,14 @@ function walkRowRuns(source, region, o = {}) {
568
638
  start: axis.start,
569
639
  end: axis.start + referenceRow.bp + referenceRow.gapBp
570
640
  } : cut;
571
- skips?.names.forEach((name, k) => {
572
- const contig = pathOrigin(name).name;
573
- if (!drawn.has(contig)) {
574
- drawn.add(contig);
641
+ for (const [name, own] of departuresOf) {
642
+ if (!drawn.has(name)) {
575
643
  rows.push({
576
- meta: skipRowOf(contig, skips.starts[k], skips.ends[k], bar),
644
+ meta: steplessRowOf(name, own, bar),
577
645
  row: rows.length + 1
578
646
  });
579
647
  }
580
- });
648
+ }
581
649
  const metas = [referenceRow, ...rows.map((r) => r.meta)];
582
650
  if (new Set(metas.map((m) => m.label)).size < metas.length) {
583
651
  for (const meta of metas) {
@@ -593,9 +661,9 @@ function walkRowRuns(source, region, o = {}) {
593
661
  float64,
594
662
  float64,
595
663
  (n) => new Uint8Array(n),
596
- (n) => new Int32Array(n)
664
+ float64
597
665
  ]);
598
- const [start, bp, referenceStart, flags, chunk] = columns;
666
+ const [start, bp, referenceStart, flags, near] = columns;
599
667
  return {
600
668
  origin: cut ? cut.start : startOf(first) ?? 0,
601
669
  rows: [referenceRow, ...rows.map((r) => r.meta)],
@@ -604,11 +672,31 @@ function walkRowRuns(source, region, o = {}) {
604
672
  bp,
605
673
  referenceStart,
606
674
  flags,
607
- chunk,
608
- chunks,
675
+ near,
609
676
  visits: visits && visitColumns(visits, order, names)
610
677
  };
611
678
  }
679
+ function departuresByWalk(table, reference) {
680
+ const byWalk = /* @__PURE__ */ new Map();
681
+ if (table) {
682
+ for (let k = 0; k < table.names.length; k++) {
683
+ const d = departureAt(table, k);
684
+ const name = pathOrigin(d.name).name;
685
+ if (name !== reference) {
686
+ const list = byWalk.get(name);
687
+ if (list) {
688
+ list.push(d);
689
+ } else {
690
+ byWalk.set(name, [d]);
691
+ }
692
+ }
693
+ }
694
+ }
695
+ for (const list of byWalk.values()) {
696
+ list.sort((a, b) => a.hapStart - b.hapStart);
697
+ }
698
+ return byWalk;
699
+ }
612
700
  function visitColumns(visits, order, names) {
613
701
  const { offsets, columns } = visits.reorder(order, [
614
702
  (n) => new Int32Array(n),
@@ -632,9 +720,9 @@ function runAt(t, k) {
632
720
  if (cause) {
633
721
  run.cause = cause;
634
722
  }
635
- const chunk = t.chunks[t.chunk[k]];
636
- if (chunk) {
637
- run.chunk = chunk;
723
+ const near = t.near[k];
724
+ if (!Number.isNaN(near)) {
725
+ run.near = near;
638
726
  }
639
727
  } else {
640
728
  run.referenceStart = Number.isNaN(t.referenceStart[k]) ? void 0 : t.referenceStart[k];
@@ -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,6 +1,6 @@
1
1
  import {
2
2
  pathSteps
3
- } from "./chunk-3HNQW3HM.js";
3
+ } from "./chunk-252FIXUH.js";
4
4
  import {
5
5
  pathOrigin
6
6
  } from "./chunk-QBI6SC74.js";
@@ -5,7 +5,7 @@ import {
5
5
  stripGeneGaps,
6
6
  walkStripFrame,
7
7
  walkStripLabelsTree
8
- } from "./chunk-6YVWF5TR.js";
8
+ } from "./chunk-VX57QTQD.js";
9
9
  import {
10
10
  Canvas2DRenderer
11
11
  } from "./chunk-4DMSPNYV.js";
@@ -26,30 +26,30 @@ import {
26
26
  } from "./chunk-HEYIAMTC.js";
27
27
  import {
28
28
  version
29
- } from "./chunk-WXUEAMJJ.js";
29
+ } from "./chunk-RWCZLHXX.js";
30
30
  import {
31
31
  axisScaleOf
32
- } from "./chunk-XNLXC6GB.js";
32
+ } from "./chunk-2TNFP3GC.js";
33
33
  import {
34
34
  figureScene
35
- } from "./chunk-ETYIYH7I.js";
35
+ } from "./chunk-K5QGQNPO.js";
36
36
  import {
37
37
  fadedKey
38
- } from "./chunk-Q4X6O7BL.js";
38
+ } from "./chunk-STHPR76Q.js";
39
39
  import {
40
40
  rangeText
41
- } from "./chunk-LT66KA3W.js";
41
+ } from "./chunk-QDP2NTAV.js";
42
42
  import {
43
43
  encodingStops
44
44
  } from "./chunk-OC5HU7M3.js";
45
45
  import {
46
46
  walkRowLabels
47
- } from "./chunk-EHEKIJ56.js";
47
+ } from "./chunk-IDDGO6EW.js";
48
48
  import {
49
49
  walkRowsKey,
50
50
  walkRowsKeyTree,
51
51
  walkRowsTree
52
- } from "./chunk-F5CP5KSV.js";
52
+ } from "./chunk-2HR33HEK.js";
53
53
  import {
54
54
  THREAD_PX,
55
55
  passesKey,
@@ -60,11 +60,11 @@ import {
60
60
  } from "./chunk-XWH4LB56.js";
61
61
  import {
62
62
  FIGURE_DEFAULTS
63
- } from "./chunk-3BLYOLTX.js";
63
+ } from "./chunk-5PQQ4IXZ.js";
64
64
  import {
65
65
  FIT_PADDING,
66
66
  fitTransform
67
- } from "./chunk-TTFQTTBZ.js";
67
+ } from "./chunk-RNROMUAS.js";
68
68
  import {
69
69
  LABEL_CHAR_PX,
70
70
  LABEL_PAD,
@@ -6,7 +6,7 @@ import {
6
6
  hasTubeMapPaths,
7
7
  tubeMapLayout,
8
8
  tubeMapReferenceLayout
9
- } from "./chunk-3HNQW3HM.js";
9
+ } from "./chunk-252FIXUH.js";
10
10
  import {
11
11
  anchoredLayout
12
12
  } from "./chunk-CNWAVRLF.js";
@@ -15,7 +15,7 @@ import {
15
15
  } from "./chunk-Q7OFBTBW.js";
16
16
  import {
17
17
  walkRowLayout
18
- } from "./chunk-EHEKIJ56.js";
18
+ } from "./chunk-IDDGO6EW.js";
19
19
  import {
20
20
  withoutStrayHandles
21
21
  } from "./chunk-FGH4D6WT.js";
@@ -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