@jbrowse/bandage-core 10.1.0 → 10.2.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.
@@ -10,7 +10,7 @@ function foldVariants(graph, belowBp) {
10
10
  if (!(belowBp > 0) || graph.paths?.length || !graph.nodes.some((node) => isBackbone(node))) {
11
11
  return graph;
12
12
  }
13
- const { nodes, edges } = graph;
13
+ const { nodes, edges } = readForward(graph);
14
14
  const index = new Map(nodes.map((node, i) => [node.id, i]));
15
15
  const sides = edges.map(forwardSides);
16
16
  const links = linksAt(nodes.length, edges, sides, index);
@@ -47,7 +47,34 @@ function foldVariants(graph, belowBp) {
47
47
  const skip = skipped(nodes[a], sides[k].from, nodes[b], sides[k].to);
48
48
  return kept[a] && kept[b] && !(skip > 0 && skip < belowBp);
49
49
  });
50
- return mergeAlleleRuns({ ...graph, edges: keptEdges }, kept, allele);
50
+ return mergeAlleleRuns({ ...graph, nodes, edges: keptEdges }, kept, allele);
51
+ }
52
+ function readForward({ nodes, edges }) {
53
+ const reversed = new Set(
54
+ nodes.filter((node) => node.stable?.strand === "-").map((node) => node.id)
55
+ );
56
+ if (reversed.size === 0) {
57
+ return { nodes, edges };
58
+ }
59
+ const read = (id, strand) => {
60
+ const own = strand ?? ownStrand(id);
61
+ return reversed.has(id) ? complement(own) : own;
62
+ };
63
+ return {
64
+ nodes: nodes.map(
65
+ (node) => reversed.has(node.id) ? { ...node, stable: { ...node.stable, strand: "+" } } : node
66
+ ),
67
+ edges: edges.map(
68
+ (edge) => reversed.has(edge.from) || reversed.has(edge.to) ? {
69
+ ...edge,
70
+ fromStrand: read(edge.from, edge.fromStrand),
71
+ toStrand: read(edge.to, edge.toStrand)
72
+ } : edge
73
+ )
74
+ };
75
+ }
76
+ function complement(strand) {
77
+ return strand === "+" ? "-" : "+";
51
78
  }
52
79
  function forwardSides(edge) {
53
80
  return {
@@ -61,8 +88,9 @@ function linksAt(count, edges, sides, index) {
61
88
  const a = index.get(edge.from);
62
89
  const b = index.get(edge.to);
63
90
  if (a !== void 0 && b !== void 0) {
64
- links[a].push({ other: b, side: sides[k].from });
65
- links[b].push({ other: a, side: sides[k].to });
91
+ const { from, to } = sides[k];
92
+ links[a].push({ other: b, side: from, otherSide: to });
93
+ links[b].push({ other: a, side: to, otherSide: from });
66
94
  }
67
95
  });
68
96
  return links;
@@ -74,11 +102,11 @@ function onOneSequence(a, b) {
74
102
  }
75
103
  function continues(a, aSide, b, bSide) {
76
104
  const pair = onOneSequence(a, b);
77
- if (!pair || aSide === bSide) {
105
+ if (!pair) {
78
106
  return false;
79
107
  }
80
108
  const [sa, sb] = pair;
81
- return sa.start + a.length === sb.start || sb.start + b.length === sa.start;
109
+ return aSide === "e" && bSide === "s" && sa.start + a.length === sb.start || bSide === "e" && aSide === "s" && sb.start + b.length === sa.start;
82
110
  }
83
111
  function skipped(a, aSide, b, bSide) {
84
112
  const pair = onOneSequence(a, b);
@@ -86,10 +114,10 @@ function skipped(a, aSide, b, bSide) {
86
114
  return 0;
87
115
  }
88
116
  const [sa, sb] = pair;
89
- return Math.max(
90
- sb.start - (sa.start + a.length),
91
- sa.start - (sb.start + b.length)
92
- );
117
+ return Math.abs(position(sb, b, bSide) - position(sa, a, aSide));
118
+ }
119
+ function position({ start }, node, side) {
120
+ return side === "s" ? start : start + node.length;
93
121
  }
94
122
  function alleleOf(nodes, edges, sides, index) {
95
123
  const parent = nodes.map((_, i) => i);
@@ -132,13 +160,14 @@ function alleleContent(group, nodes, links, allele) {
132
160
  let oneSequence = true;
133
161
  for (const i of group) {
134
162
  length += nodes[i].length;
135
- for (const { other } of links[i]) {
163
+ for (const { other, otherSide } of links[i]) {
136
164
  const node = nodes[other];
137
165
  if (allele[other] !== allele[i] && isBackbone(node)) {
138
166
  refName ??= node.stable.refName;
139
167
  oneSequence &&= node.stable.refName === refName;
140
- lo = Math.min(lo, node.stable.start + node.length);
141
- hi = Math.max(hi, node.stable.start);
168
+ const at = position(node.stable, node, otherSide);
169
+ lo = Math.min(lo, at);
170
+ hi = Math.max(hi, at);
142
171
  }
143
172
  }
144
173
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  layoutEngine
3
- } from "./chunk-FLUQODT2.js";
3
+ } from "./chunk-DT2GGH4D.js";
4
4
  import {
5
5
  layoutModeByValue
6
6
  } from "./chunk-4R6QNG23.js";
@@ -12,7 +12,7 @@ import {
12
12
  } from "./chunk-LOCJN3BZ.js";
13
13
  import {
14
14
  version
15
- } from "./chunk-MZIOBJZB.js";
15
+ } from "./chunk-M3NPTHSE.js";
16
16
  import {
17
17
  axisScaleOf
18
18
  } from "./chunk-L5WF4ZPS.js";
@@ -13,7 +13,7 @@ var LAYOUT_ENGINES = [
13
13
  {
14
14
  value: "stress",
15
15
  label: "Stress",
16
- description: "Stress layout by stochastic gradient descent in plain JS: distances along the graph become distances on the page, so the reference reads straight and a repeat loop reads as a ring."
16
+ description: "Plain JS: the reference drawn straight and each variant placed against it, an allele as a lens, a repeat loop as a ring, a deletion as an arch; stress by stochastic gradient descent for components with no reference."
17
17
  }
18
18
  ];
19
19
  var LAYOUT_ENGINE_VALUES = LAYOUT_ENGINES.map((e) => e.value);
@@ -36,7 +36,7 @@ import {
36
36
  } from "./chunk-LOCJN3BZ.js";
37
37
  import {
38
38
  version
39
- } from "./chunk-MZIOBJZB.js";
39
+ } from "./chunk-M3NPTHSE.js";
40
40
  import {
41
41
  axisScaleOf
42
42
  } from "./chunk-L5WF4ZPS.js";
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var version = "10.1.0";
2
+ var version = "10.2.0";
3
3
 
4
4
  export {
5
5
  version
@@ -6,7 +6,7 @@ import {
6
6
  } from "../chunks/chunk-BXEPA4KS.js";
7
7
  import {
8
8
  figureSvg
9
- } from "../chunks/chunk-CFPER2S2.js";
9
+ } from "../chunks/chunk-EDR4CGCQ.js";
10
10
  import "../chunks/chunk-47DYCZOK.js";
11
11
  import "../chunks/chunk-RPDXZLCG.js";
12
12
  import "../chunks/chunk-WBCOREDZ.js";
@@ -26,7 +26,7 @@ import {
26
26
  LAYOUT_ENGINE_VALUES,
27
27
  isLayoutEngineKind,
28
28
  layoutEngine
29
- } from "../chunks/chunk-FLUQODT2.js";
29
+ } from "../chunks/chunk-DT2GGH4D.js";
30
30
  import {
31
31
  LAYOUT_MODES,
32
32
  layoutModeByValue
@@ -50,7 +50,7 @@ import {
50
50
  import "../chunks/chunk-Q7LYHGGQ.js";
51
51
  import "../chunks/chunk-WSIFAZU7.js";
52
52
  import "../chunks/chunk-LOCJN3BZ.js";
53
- import "../chunks/chunk-MZIOBJZB.js";
53
+ import "../chunks/chunk-M3NPTHSE.js";
54
54
  import "../chunks/chunk-L5WF4ZPS.js";
55
55
  import "../chunks/chunk-R456ME6J.js";
56
56
  import "../chunks/chunk-ALDGONEI.js";
package/dist/cli/fold.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  } from "../chunks/chunk-B4YH42OP.js";
5
5
  import {
6
6
  foldVariants
7
- } from "../chunks/chunk-YPYWYPHX.js";
7
+ } from "../chunks/chunk-AFP3NWSL.js";
8
8
  import {
9
9
  loadGraph
10
10
  } from "../chunks/chunk-XTCNEKO5.js";
package/dist/figure.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  figureSvg
3
- } from "./chunks/chunk-CFPER2S2.js";
3
+ } from "./chunks/chunk-EDR4CGCQ.js";
4
4
  import "./chunks/chunk-47DYCZOK.js";
5
5
  import "./chunks/chunk-RPDXZLCG.js";
6
6
  import "./chunks/chunk-WBCOREDZ.js";
@@ -14,7 +14,7 @@ import "./chunks/chunk-FP4H7SFT.js";
14
14
  import "./chunks/chunk-MLSWIMZO.js";
15
15
  import "./chunks/chunk-NNODIW4U.js";
16
16
  import "./chunks/chunk-LOCJN3BZ.js";
17
- import "./chunks/chunk-MZIOBJZB.js";
17
+ import "./chunks/chunk-M3NPTHSE.js";
18
18
  import "./chunks/chunk-L5WF4ZPS.js";
19
19
  import "./chunks/chunk-R456ME6J.js";
20
20
  import "./chunks/chunk-ALDGONEI.js";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  figureData,
3
3
  gfaFigureData
4
- } from "./chunks/chunk-VIERZJO2.js";
5
- import "./chunks/chunk-FLUQODT2.js";
4
+ } from "./chunks/chunk-CPVZGVDL.js";
5
+ import "./chunks/chunk-DT2GGH4D.js";
6
6
  import "./chunks/chunk-4R6QNG23.js";
7
7
  import "./chunks/chunk-LOEA5IHZ.js";
8
8
  import "./chunks/chunk-DK5P2YOL.js";
@@ -17,7 +17,7 @@ import "./chunks/chunk-FLFBYSJO.js";
17
17
  import "./chunks/chunk-Q7LYHGGQ.js";
18
18
  import "./chunks/chunk-WSIFAZU7.js";
19
19
  import "./chunks/chunk-LOCJN3BZ.js";
20
- import "./chunks/chunk-MZIOBJZB.js";
20
+ import "./chunks/chunk-M3NPTHSE.js";
21
21
  import "./chunks/chunk-L5WF4ZPS.js";
22
22
  import "./chunks/chunk-R456ME6J.js";
23
23
  import "./chunks/chunk-ALDGONEI.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  foldVariants
3
- } from "./chunks/chunk-YPYWYPHX.js";
3
+ } from "./chunks/chunk-AFP3NWSL.js";
4
4
  import "./chunks/chunk-2CVHXFK7.js";
5
5
  import "./chunks/chunk-CPMHA4W5.js";
6
6
  import "./chunks/chunk-FYQWPEEY.js";
package/dist/index.js CHANGED
@@ -87,7 +87,7 @@ import {
87
87
  } from "./chunks/chunk-AZFVORTC.js";
88
88
  import {
89
89
  figureSvg
90
- } from "./chunks/chunk-CFPER2S2.js";
90
+ } from "./chunks/chunk-EDR4CGCQ.js";
91
91
  import {
92
92
  svgCanvas
93
93
  } from "./chunks/chunk-47DYCZOK.js";
@@ -168,11 +168,11 @@ import {
168
168
  import {
169
169
  figureData,
170
170
  gfaFigureData
171
- } from "./chunks/chunk-VIERZJO2.js";
171
+ } from "./chunks/chunk-CPVZGVDL.js";
172
172
  import {
173
173
  LAYOUT_ENGINES,
174
174
  layoutEngine
175
- } from "./chunks/chunk-FLUQODT2.js";
175
+ } from "./chunks/chunk-DT2GGH4D.js";
176
176
  import {
177
177
  FORCE_LAYOUT_LABEL,
178
178
  LAYOUT_MODES,
@@ -211,7 +211,7 @@ import {
211
211
  } from "./chunks/chunk-LOCJN3BZ.js";
212
212
  import {
213
213
  version
214
- } from "./chunks/chunk-MZIOBJZB.js";
214
+ } from "./chunks/chunk-M3NPTHSE.js";
215
215
  import {
216
216
  axisScaleOf,
217
217
  contains,
@@ -3,7 +3,7 @@ import {
3
3
  LAYOUT_ENGINE_VALUES,
4
4
  isLayoutEngineKind,
5
5
  layoutEngine
6
- } from "./chunks/chunk-FLUQODT2.js";
6
+ } from "./chunks/chunk-DT2GGH4D.js";
7
7
  import "./chunks/chunk-7XHHVYG7.js";
8
8
  export {
9
9
  LAYOUT_ENGINES,
@@ -6,7 +6,7 @@ export declare const LAYOUT_ENGINES: readonly [{
6
6
  }, {
7
7
  readonly value: "stress";
8
8
  readonly label: "Stress";
9
- readonly description: "Stress layout by stochastic gradient descent in plain JS: distances along the graph become distances on the page, so the reference reads straight and a repeat loop reads as a ring.";
9
+ readonly description: "Plain JS: the reference drawn straight and each variant placed against it, an allele as a lens, a repeat loop as a ring, a deletion as an arch; stress by stochastic gradient descent for components with no reference.";
10
10
  }];
11
11
  export type LayoutEngineKind = (typeof LAYOUT_ENGINES)[number]['value'];
12
12
  export declare const LAYOUT_ENGINE_VALUES: ("fmmm" | "stress")[];
@@ -1 +1 @@
1
- export declare const version = "10.1.0";
1
+ export declare const version = "10.2.0";
package/dist/version.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  version
3
- } from "./chunks/chunk-MZIOBJZB.js";
3
+ } from "./chunks/chunk-M3NPTHSE.js";
4
4
  export {
5
5
  version
6
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/bandage-core",
3
- "version": "10.1.0",
3
+ "version": "10.2.0",
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": {