@jbrowse/bandage-core 4.0.29 → 4.0.30

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.
@@ -1946,16 +1946,32 @@ function sampleOf(path) {
1946
1946
  function labelOf(path) {
1947
1947
  return path.haplotype !== void 0 && path.sample !== void 0 ? `${path.sample}#${path.haplotype}` : sampleOf(path);
1948
1948
  }
1949
- function sliceBetween(nodeIds, span, region, flanked = true) {
1949
+ function stepsOf(pieces, lengthOf) {
1950
+ const steps = [];
1951
+ let end;
1952
+ for (const piece of pieces) {
1953
+ if (end !== void 0 && piece.start !== void 0 && piece.start > end) {
1954
+ steps.push(piece.start - end);
1955
+ }
1956
+ steps.push(...piece.nodeIds);
1957
+ const bp = piece.nodeIds.reduce(
1958
+ (sum, id) => sum + (lengthOf.get(id) ?? 0),
1959
+ 0
1960
+ );
1961
+ end = piece.start === void 0 ? void 0 : piece.start + bp;
1962
+ }
1963
+ return steps;
1964
+ }
1965
+ function sliceBetween(steps, span, region, flanked = true) {
1950
1966
  if (!region || !flanked) {
1951
- return { ids: nodeIds, complete: true };
1967
+ return { ids: steps, complete: true };
1952
1968
  }
1953
1969
  let i0 = -1;
1954
1970
  let i1 = -1;
1955
1971
  let bestEnd = -Infinity;
1956
1972
  let bestStart = Infinity;
1957
- nodeIds.forEach((id, i) => {
1958
- const s = span.get(id);
1973
+ steps.forEach((id, i) => {
1974
+ const s = typeof id === "string" ? span.get(id) : void 0;
1959
1975
  if (s) {
1960
1976
  if (s.end <= region.start && s.end > bestEnd) {
1961
1977
  bestEnd = s.end;
@@ -1968,9 +1984,9 @@ function sliceBetween(nodeIds, span, region, flanked = true) {
1968
1984
  }
1969
1985
  });
1970
1986
  if (i0 < 0 || i1 < 0) {
1971
- return { ids: nodeIds, complete: false };
1987
+ return { ids: steps, complete: false };
1972
1988
  }
1973
- const ids = nodeIds.slice(Math.min(i0, i1) + 1, Math.max(i0, i1));
1989
+ const ids = steps.slice(Math.min(i0, i1) + 1, Math.max(i0, i1));
1974
1990
  return { ids: i0 < i1 ? ids : ids.reverse(), complete: true };
1975
1991
  }
1976
1992
  function walkRows(graph, region, unit) {
@@ -1982,6 +1998,10 @@ function walkRows(graph, region, unit) {
1982
1998
  if (!first || others.length === 0) {
1983
1999
  return void 0;
1984
2000
  }
2001
+ const walks = /* @__PURE__ */ new Map();
2002
+ for (const path of others) {
2003
+ walks.set(path.name, [...walks.get(path.name) ?? [], path]);
2004
+ }
1985
2005
  const lengthOf = new Map(graph.nodes.map((n2) => [n2.id, n2.length]));
1986
2006
  const referenceStart = first.start ?? 0;
1987
2007
  const cut = region && region.end > region.start ? region : void 0;
@@ -1997,20 +2017,35 @@ function walkRows(graph, region, unit) {
1997
2017
  }
1998
2018
  }
1999
2019
  const flanked = cut === void 0 || [...span.values()].some((s) => s.end <= cut.start) && [...span.values()].some((s) => s.start >= cut.end);
2000
- const rowOf = (path) => {
2001
- const { ids, complete } = sliceBetween(path.nodeIds, span, cut, flanked);
2020
+ const rowOf = (pieces) => {
2021
+ const path = pieces[0];
2022
+ const ordered = [...pieces].sort((a, b) => (a.start ?? 0) - (b.start ?? 0));
2023
+ const { ids, complete } = sliceBetween(
2024
+ stepsOf(ordered, lengthOf),
2025
+ span,
2026
+ cut,
2027
+ flanked
2028
+ );
2002
2029
  const runs = [];
2003
2030
  let bp = 0;
2004
2031
  let offReferenceBp = 0;
2032
+ let gapBp = 0;
2005
2033
  let step = 0;
2006
2034
  for (const id of ids) {
2035
+ if (typeof id === "number") {
2036
+ runs.push({ start: bp, bp: id, onReference: false, gap: true });
2037
+ bp += id;
2038
+ gapBp += id;
2039
+ step = 0;
2040
+ continue;
2041
+ }
2007
2042
  const len = lengthOf.get(id) ?? 0;
2008
2043
  const s = span.get(id);
2009
2044
  const last = runs.at(-1);
2010
2045
  const at = last?.referenceStart;
2011
2046
  const forward = s && at !== void 0 && step >= 0 && at + last.bp === s.start;
2012
2047
  const backward = s && at !== void 0 && step <= 0 && s.end === at;
2013
- if (!s && last && !last.onReference) {
2048
+ if (!s && last && !last.onReference && !last.gap) {
2014
2049
  last.bp += len;
2015
2050
  } else if (forward || backward) {
2016
2051
  last.bp += len;
@@ -2040,6 +2075,7 @@ function walkRows(graph, region, unit) {
2040
2075
  haplotype: path.haplotype,
2041
2076
  bp,
2042
2077
  offReferenceBp,
2078
+ gapBp,
2043
2079
  complete,
2044
2080
  runs
2045
2081
  };
@@ -2048,11 +2084,8 @@ function walkRows(graph, region, unit) {
2048
2084
  return {
2049
2085
  origin,
2050
2086
  unit,
2051
- reference: rowOf({
2052
- ...first,
2053
- nodeIds: referencePieces2.flatMap((piece) => piece.nodeIds)
2054
- }),
2055
- rows: others.map(rowOf).sort(
2087
+ reference: rowOf(referencePieces2),
2088
+ rows: [...walks.values()].map(rowOf).sort(
2056
2089
  (a, b) => Number(b.complete) - Number(a.complete) || b.bp - a.bp || a.label.localeCompare(b.label)
2057
2090
  )
2058
2091
  };
@@ -4349,8 +4382,11 @@ function walkKey(walk, reference) {
4349
4382
  const { field } = walk.encoding;
4350
4383
  const own = walk.range ? rangeText(walk.range.contig, walk.range.start, walk.range.end) : void 0;
4351
4384
  const scale = field === "progress" ? own : field === "reference" && reference ? rangeText(reference.name, reference.start, reference.end) : void 0;
4385
+ const spanned = walk.range ? walk.range.end - walk.range.start : walk.bp;
4386
+ const outside = spanned - walk.bp;
4352
4387
  return {
4353
- delta: walk.referenceBp === void 0 || walk.bp === walk.referenceBp ? "" : ` ${walk.bp > walk.referenceBp ? "+" : "\u2212"}${formatBp(Math.abs(walk.bp - walk.referenceBp))}`,
4388
+ delta: walk.referenceBp === void 0 || spanned === walk.referenceBp ? "" : ` ${spanned > walk.referenceBp ? "+" : "\u2212"}${formatBp(Math.abs(spanned - walk.referenceBp))}`,
4389
+ outside: outside > 0 ? `, ${formatBp(outside)} outside the cut` : "",
4354
4390
  reversed: walk.reversedBp > 0 ? `, ${formatBp(walk.reversedBp)} reversed` : "",
4355
4391
  shades: field !== "walk",
4356
4392
  scale,
@@ -4788,7 +4824,7 @@ function svgCanvas(width, height) {
4788
4824
  }
4789
4825
 
4790
4826
  // src/version.ts
4791
- var version = "4.0.29";
4827
+ var version = "4.0.30";
4792
4828
 
4793
4829
  // src/viewport.ts
4794
4830
  function axisScaleOf(scale, pixelRows) {
@@ -4866,7 +4902,7 @@ function walkKeySvg(id, x, y, walk, label, reference) {
4866
4902
  y,
4867
4903
  encodingStops(walk.encoding),
4868
4904
  label,
4869
- key.delta + key.reversed,
4905
+ key.delta + key.outside + key.reversed,
4870
4906
  key.scale
4871
4907
  );
4872
4908
  }
@@ -5402,7 +5438,7 @@ function parseWalk(line) {
5402
5438
  end: +fields[5]
5403
5439
  };
5404
5440
  }
5405
- var stepsOf = (walk) => walk.fields[6].match(/[<>][^<>]+/g) ?? [];
5441
+ var stepsOf2 = (walk) => walk.fields[6].match(/[<>][^<>]+/g) ?? [];
5406
5442
  function segmentLengths(lines) {
5407
5443
  const lengths = /* @__PURE__ */ new Map();
5408
5444
  for (const line of lines) {
@@ -5421,7 +5457,7 @@ function extend(a, b, lengths) {
5421
5457
  if (b.end <= a.end) {
5422
5458
  return a;
5423
5459
  }
5424
- const steps = stepsOf(b);
5460
+ const steps = stepsOf2(b);
5425
5461
  let pos = b.start;
5426
5462
  for (const [i, step] of steps.entries()) {
5427
5463
  if (pos === a.end) {
@@ -5455,7 +5491,7 @@ function joinPieces(pieces, lengths, startsPath) {
5455
5491
  }
5456
5492
  var flip2 = (sign) => sign === "+" ? "-" : "+";
5457
5493
  function* stepLinks(walk) {
5458
- const steps = stepsOf(walk).map((step) => ({
5494
+ const steps = stepsOf2(walk).map((step) => ({
5459
5495
  id: step.slice(1),
5460
5496
  sign: step.startsWith(">") ? "+" : "-"
5461
5497
  }));
@@ -17,7 +17,7 @@ import {
17
17
  openGbz,
18
18
  parseRegion,
19
19
  refNameBinding
20
- } from "../chunks/chunk-QN464POI.js";
20
+ } from "../chunks/chunk-P7UDDVHK.js";
21
21
 
22
22
  // src/cli/figure.ts
23
23
  import { access, open, readFile, writeFile } from "node:fs/promises";
package/dist/index.js CHANGED
@@ -101,7 +101,7 @@ import {
101
101
  wellKnownSample,
102
102
  yToXOf,
103
103
  zoomAbout
104
- } from "./chunks/chunk-QN464POI.js";
104
+ } from "./chunks/chunk-P7UDDVHK.js";
105
105
 
106
106
  // src/index.ts
107
107
  import { getDpr } from "@jbrowse/render-core/canvas2dUtils";
@@ -5,6 +5,7 @@ export interface WalkRun {
5
5
  onReference: boolean;
6
6
  referenceStart?: number;
7
7
  reversed?: true;
8
+ gap?: true;
8
9
  }
9
10
  export interface WalkRow {
10
11
  name: string;
@@ -13,6 +14,7 @@ export interface WalkRow {
13
14
  haplotype?: number;
14
15
  bp: number;
15
16
  offReferenceBp: number;
17
+ gapBp: number;
16
18
  complete: boolean;
17
19
  runs: WalkRun[];
18
20
  }
@@ -1 +1 @@
1
- export declare const version = "4.0.29";
1
+ export declare const version = "4.0.30";
@@ -6,6 +6,7 @@ export declare function walkKey(walk: LiftedWalk, reference?: {
6
6
  end: number;
7
7
  }): {
8
8
  delta: string;
9
+ outside: string;
9
10
  reversed: string;
10
11
  shades: boolean;
11
12
  scale: string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/bandage-core",
3
- "version": "4.0.29",
3
+ "version": "4.0.30",
4
4
  "description": "Pangenome graph layout and drawing with no host: GFA in, the Bandage force-directed engine and reference-anchored layouts, a Canvas2D renderer, hit testing and labels out",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "repository": {
@@ -31,7 +31,7 @@
31
31
  "dist"
32
32
  ],
33
33
  "dependencies": {
34
- "@gmod/gbz-base": "^4.1.0",
34
+ "@gmod/gbz-base": "^5.0.0",
35
35
  "@gmod/tabix": "^3.9.0",
36
36
  "@gmod/tubemap-core": "^0.1.0",
37
37
  "@jbrowse/core": "5.0.0-beta.9",