@jbrowse/bandage-core 10.0.0 → 10.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.
- package/README.md +23 -0
- package/dist/bubbles/popBubble.js +2 -2
- package/dist/bubbles/superbubbles.js +3 -3
- package/dist/chunks/{chunk-ICXMWYOA.js → chunk-4R6QNG23.js} +5 -5
- package/dist/chunks/{chunk-KJYSOHVN.js → chunk-5BGP5Z64.js} +1 -1
- package/dist/chunks/{chunk-VOWI544A.js → chunk-ALDGONEI.js} +1 -1
- package/dist/chunks/{chunk-3APK25GI.js → chunk-C7MZJSPT.js} +1 -1
- package/dist/chunks/{chunk-RJXPPYA7.js → chunk-CFPER2S2.js} +13 -13
- package/dist/chunks/{chunk-33T67FPZ.js → chunk-CRTD2SBP.js} +1 -1
- package/dist/chunks/{chunk-IM4SJUPO.js → chunk-DK5P2YOL.js} +2 -2
- package/dist/chunks/{chunk-VK6XMP6B.js → chunk-FLUQODT2.js} +1 -3
- package/dist/chunks/{chunk-BEWLQADP.js → chunk-FNGIQF43.js} +1 -1
- package/dist/chunks/{chunk-OEPCRURR.js → chunk-GNTTI6LA.js} +1 -1
- package/dist/chunks/{chunk-EU6FBTQF.js → chunk-IUDJKOLB.js} +4 -4
- package/dist/chunks/{chunk-QXAB2FLJ.js → chunk-IW6CYVX2.js} +1 -1
- package/dist/chunks/{chunk-OOLNLCIO.js → chunk-L5WF4ZPS.js} +1 -1
- package/dist/chunks/{chunk-EMUUNWRU.js → chunk-M6LK4GII.js} +7 -1
- package/dist/chunks/{chunk-E5UEYZWK.js → chunk-MVFDSFV2.js} +1 -1
- package/dist/chunks/{chunk-CDPYXHVR.js → chunk-MZIOBJZB.js} +1 -1
- package/dist/chunks/{chunk-FG762CCP.js → chunk-PKFMP65V.js} +2 -2
- package/dist/chunks/{chunk-QIVPRZ4H.js → chunk-R456ME6J.js} +2 -2
- package/dist/chunks/chunk-RIPAA7OK.js +284 -0
- package/dist/chunks/{chunk-WI7ZHJ27.js → chunk-RPDXZLCG.js} +2 -2
- package/dist/chunks/{chunk-NP356MC2.js → chunk-SBMJNRTV.js} +1 -1
- package/dist/chunks/{chunk-4QTNXTGW.js → chunk-T6V4KI2L.js} +1 -1
- package/dist/chunks/{chunk-REE4GUDM.js → chunk-TWRLC3KK.js} +1 -1
- package/dist/chunks/{chunk-Q6IOQP4J.js → chunk-VIERZJO2.js} +8 -8
- package/dist/chunks/{chunk-JVLURPFW.js → chunk-VPE4AYP7.js} +1 -2
- package/dist/chunks/{chunk-W4GZCVUK.js → chunk-XTCNEKO5.js} +7 -7
- package/dist/chunks/{chunk-VZNKA3K2.js → chunk-XYP6WL2N.js} +7 -3
- package/dist/chunks/{chunk-B4645SM2.js → chunk-YPYWYPHX.js} +3 -3
- package/dist/chunks/{chunk-DCJC32QW.js → chunk-ZIUKZUPJ.js} +1 -1
- package/dist/cli/figure.js +22 -24
- package/dist/cli/fold.js +5 -5
- package/dist/figure.js +16 -16
- package/dist/figureData.js +17 -19
- package/dist/figureSettings.js +5 -5
- package/dist/foldVariants.js +1 -1
- package/dist/gfa/gfaConverter.js +2 -2
- package/dist/index.js +50 -51
- package/dist/layout/deletionRoutes.js +1 -3
- package/dist/layout/forceCache.js +5 -5
- package/dist/layout/trimToWindow.js +1 -1
- package/dist/layout/tubeMapLayout.js +3 -3
- package/dist/layout/walkRowDraw.js +5 -5
- package/dist/layout/walkRowLayout.js +3 -3
- package/dist/layout/walkRows.js +2 -2
- package/dist/layout/walkStrip.js +6 -6
- package/dist/layoutEngines.js +1 -5
- package/dist/layoutModes.js +7 -7
- package/dist/pathAnchoring.js +1 -1
- package/dist/pathColors.js +2 -2
- package/dist/pipeline.js +4 -4
- package/dist/referenceRampCss.js +4 -4
- package/dist/referenceStrip.js +4 -4
- package/dist/renderer/GeometryBuilder.js +3 -3
- package/dist/tubeMap/bundle.js +4 -4
- package/dist/tubeMap/coarsen.js +3 -3
- package/dist/tubeMap/draw.js +3 -3
- package/dist/tubeMap/nodeColors.js +4 -4
- package/dist/types/index.d.ts +1 -1
- package/dist/types/layout/deletionRoutes.d.ts +0 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/viewport.js +5 -5
- package/dist/walkEncoding.js +4 -4
- package/dist/walkHighlight.js +5 -5
- package/package.json +2 -1
- package/dist/chunks/chunk-KAN2WTG5.js +0 -226
- package/dist/chunks/chunk-LYJ4US66.js +0 -664
- package/dist/chunks/chunk-Q6FRNVDU.js +0 -531
- package/dist/layout/stressEngine.js +0 -11
- package/dist/layout/stressPlacement.js +0 -7
- package/dist/types/layout/stressEngine.d.ts +0 -27
- package/dist/types/layout/stressPlacement.d.ts +0 -5
package/README.md
CHANGED
|
@@ -25,6 +25,9 @@ npm install @jbrowse/bandage-core
|
|
|
25
25
|
and the `bandage-figure` CLI makes one from a JSON spec with no browser:
|
|
26
26
|
`npx -p @jbrowse/bandage-core bandage-figure spec.json -o figure.svg`. See
|
|
27
27
|
[docs/figures.md](docs/figures.md)
|
|
28
|
+
- Coarse tier: the `bandage-fold` CLI folds every variant under a size into the
|
|
29
|
+
reference, so a graph track draws a whole chromosome. See
|
|
30
|
+
[docs/coarse-tier.md](docs/coarse-tier.md)
|
|
28
31
|
- Figure data: `figureData` returns what `figureSvg` would paint as columnar
|
|
29
32
|
tables, for another graphics system to draw;
|
|
30
33
|
[ggbandage](https://github.com/GMOD/ggbandage) draws them in ggplot2
|
|
@@ -57,6 +60,26 @@ Release with `pnpm version patch`: it lints, tests, stamps `src/version.ts`,
|
|
|
57
60
|
writes the changelog with git-cliff and pushes the `v*` tag, and `publish.yml`
|
|
58
61
|
publishes to npm with trusted publishing.
|
|
59
62
|
|
|
63
|
+
## See also
|
|
64
|
+
|
|
65
|
+
- [jbrowse-plugin-graphgenomeviewer](https://github.com/GMOD/jbrowse-plugin-graphgenomeviewer) -
|
|
66
|
+
JBrowse 2 plugin that browses these graphs by locus
|
|
67
|
+
- [BandageJS](https://github.com/cmdcolin/BandageJS) - standalone page for GFA
|
|
68
|
+
and gbz-base graphs
|
|
69
|
+
- [@jbrowse/graph-stress-layout](https://github.com/GMOD/graph-stress-layout) -
|
|
70
|
+
stress layout that keeps the reference straight
|
|
71
|
+
- [@gmod/gbz-base](https://github.com/GMOD/gbz-base-js) - range-request reader
|
|
72
|
+
for `.gbz.db` databases
|
|
73
|
+
- [ggbandage](https://github.com/GMOD/ggbandage) - Bandage-style graph figures
|
|
74
|
+
as ggplot2 layers
|
|
75
|
+
- [@jbrowse/tubemap-core](https://github.com/GMOD/tubemap-core) -
|
|
76
|
+
sequenceTubeMap's layout, without the DOM
|
|
77
|
+
|
|
78
|
+
Tutorials on [jbrowse.org](https://jbrowse.org/jb2/docs/tutorials/)
|
|
79
|
+
|
|
80
|
+
- [HPRC part 1: graph alleles and haplotypes](https://jbrowse.org/jb2/docs/tutorials/pangenome_hprc/)
|
|
81
|
+
- [HPRC part 3: repeat lengths](https://jbrowse.org/jb2/docs/tutorials/pangenome_hprc_repeats/)
|
|
82
|
+
|
|
60
83
|
## License
|
|
61
84
|
|
|
62
85
|
Both Bandage and OGDF are GPL, which is why this package is GPL-3.0-or-later.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
bubbleSubgraph
|
|
3
|
-
} from "../chunks/chunk-
|
|
4
|
-
import "../chunks/chunk-
|
|
3
|
+
} from "../chunks/chunk-T6V4KI2L.js";
|
|
4
|
+
import "../chunks/chunk-M6LK4GII.js";
|
|
5
5
|
import "../chunks/chunk-RAEABQNW.js";
|
|
6
6
|
import "../chunks/chunk-BPLIXMH7.js";
|
|
7
7
|
import "../chunks/chunk-FYQWPEEY.js";
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
graphBubbles,
|
|
3
3
|
superbubblesFromGraph
|
|
4
|
-
} from "../chunks/chunk-
|
|
4
|
+
} from "../chunks/chunk-FNGIQF43.js";
|
|
5
5
|
import "../chunks/chunk-CLOP7UVD.js";
|
|
6
|
-
import "../chunks/chunk-
|
|
6
|
+
import "../chunks/chunk-T6V4KI2L.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-
|
|
11
|
+
import "../chunks/chunk-M6LK4GII.js";
|
|
12
12
|
import "../chunks/chunk-RAEABQNW.js";
|
|
13
13
|
import "../chunks/chunk-BPLIXMH7.js";
|
|
14
14
|
import "../chunks/chunk-2CVHXFK7.js";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sampleRowLayout
|
|
3
|
+
} from "./chunk-LOEA5IHZ.js";
|
|
1
4
|
import {
|
|
2
5
|
hasTubeMapBackbone,
|
|
3
6
|
hasTubeMapPaths,
|
|
4
7
|
tubeMapLayout,
|
|
5
8
|
tubeMapReferenceLayout
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import {
|
|
8
|
-
sampleRowLayout
|
|
9
|
-
} from "./chunk-LOEA5IHZ.js";
|
|
9
|
+
} from "./chunk-DK5P2YOL.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-
|
|
18
|
+
} from "./chunk-C7MZJSPT.js";
|
|
19
19
|
import {
|
|
20
20
|
isBackbone,
|
|
21
21
|
isOffReference
|
|
@@ -5,15 +5,15 @@ import {
|
|
|
5
5
|
stripGeneGaps,
|
|
6
6
|
walkStripFrame,
|
|
7
7
|
walkStripLabelsTree
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-RPDXZLCG.js";
|
|
9
|
+
import {
|
|
10
|
+
Canvas2DRenderer
|
|
11
|
+
} from "./chunk-WBCOREDZ.js";
|
|
9
12
|
import {
|
|
10
13
|
walkRowsKey,
|
|
11
14
|
walkRowsKeyTree,
|
|
12
15
|
walkRowsTree
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import {
|
|
15
|
-
Canvas2DRenderer
|
|
16
|
-
} from "./chunk-WBCOREDZ.js";
|
|
16
|
+
} from "./chunk-XYP6WL2N.js";
|
|
17
17
|
import {
|
|
18
18
|
EXON_COLOR,
|
|
19
19
|
exonOutlineTree,
|
|
@@ -36,17 +36,17 @@ import {
|
|
|
36
36
|
} from "./chunk-LOCJN3BZ.js";
|
|
37
37
|
import {
|
|
38
38
|
version
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-MZIOBJZB.js";
|
|
40
40
|
import {
|
|
41
41
|
axisScaleOf
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-L5WF4ZPS.js";
|
|
43
43
|
import {
|
|
44
44
|
facetLifts,
|
|
45
45
|
walkLift
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-R456ME6J.js";
|
|
47
47
|
import {
|
|
48
48
|
encodingStops
|
|
49
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-ALDGONEI.js";
|
|
50
50
|
import {
|
|
51
51
|
rangeText,
|
|
52
52
|
walkKey
|
|
@@ -54,15 +54,15 @@ import {
|
|
|
54
54
|
import {
|
|
55
55
|
buildGeometry,
|
|
56
56
|
computeReferenceRamp
|
|
57
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-SBMJNRTV.js";
|
|
58
58
|
import {
|
|
59
59
|
walkRowLabels,
|
|
60
60
|
walkRowsExtent
|
|
61
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-C7MZJSPT.js";
|
|
62
62
|
import {
|
|
63
63
|
pathLegend,
|
|
64
64
|
walkLabelsOf
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-TWRLC3KK.js";
|
|
66
66
|
import {
|
|
67
67
|
nodeInk
|
|
68
68
|
} from "./chunk-PBENCR5L.js";
|
|
@@ -70,7 +70,7 @@ import {
|
|
|
70
70
|
FIT_PADDING,
|
|
71
71
|
drawingBounds,
|
|
72
72
|
fitTransform
|
|
73
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-XTCNEKO5.js";
|
|
74
74
|
import {
|
|
75
75
|
referenceLabel
|
|
76
76
|
} from "./chunk-RAKOB6IV.js";
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
MAX_GAP_PX
|
|
3
|
-
} from "./chunk-HK5Y2YWV.js";
|
|
4
1
|
import {
|
|
5
2
|
tubeMapMismatches
|
|
6
3
|
} from "./chunk-XXT2JCAC.js";
|
|
4
|
+
import {
|
|
5
|
+
MAX_GAP_PX
|
|
6
|
+
} from "./chunk-HK5Y2YWV.js";
|
|
7
7
|
import {
|
|
8
8
|
readColor
|
|
9
9
|
} from "./chunk-CWFNEKST.js";
|
|
10
10
|
import {
|
|
11
11
|
pathOrigin
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-M6LK4GII.js";
|
|
13
13
|
|
|
14
14
|
// src/tubeMap/draw.ts
|
|
15
15
|
import { curvePaths, nodeOutlinePath } from "@jbrowse/tubemap-core";
|
|
@@ -10,8 +10,14 @@ import {
|
|
|
10
10
|
|
|
11
11
|
// src/pathAnchoring.ts
|
|
12
12
|
var RANGE_SUFFIX = /:(\d+)-\d+$/;
|
|
13
|
+
var VG_FRAGMENT = /^([^#]*#[^#]*#[^#[]*)#(\d+)(?:\[(\d+)-\d+\])?$/;
|
|
14
|
+
var VG_SUBRANGE = /\[(\d+)-\d+\]$/;
|
|
13
15
|
function pathOrigin(pathName) {
|
|
14
|
-
const
|
|
16
|
+
const fragment = VG_FRAGMENT.exec(pathName);
|
|
17
|
+
if (fragment) {
|
|
18
|
+
return { name: fragment[1], start: +fragment[2] + +(fragment[3] ?? 0) };
|
|
19
|
+
}
|
|
20
|
+
const match = RANGE_SUFFIX.exec(pathName) ?? VG_SUBRANGE.exec(pathName);
|
|
15
21
|
return match ? { name: pathName.slice(0, match.index), start: +match[1] } : { name: pathName, start: 0 };
|
|
16
22
|
}
|
|
17
23
|
function surveyPaths(paths, lengthOf) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
pathSteps
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DK5P2YOL.js";
|
|
4
4
|
import {
|
|
5
5
|
pathOrigin
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-M6LK4GII.js";
|
|
7
7
|
|
|
8
8
|
// src/tubeMap/bundle.ts
|
|
9
9
|
function bundleRoutes(graph, groupOf = () => "", merge = true) {
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import {
|
|
2
|
+
pathOrigin
|
|
3
|
+
} from "./chunk-M6LK4GII.js";
|
|
4
|
+
import {
|
|
5
|
+
panSNContig,
|
|
6
|
+
panSNSample
|
|
7
|
+
} from "./chunk-BPLIXMH7.js";
|
|
8
|
+
|
|
9
|
+
// src/layout/walkRows.ts
|
|
10
|
+
function sampleOf(path) {
|
|
11
|
+
return path.sample ?? panSNSample(path.name);
|
|
12
|
+
}
|
|
13
|
+
function labelOf(path) {
|
|
14
|
+
return path.haplotype !== void 0 && path.sample !== void 0 ? `${path.sample}#${path.haplotype}` : sampleOf(path);
|
|
15
|
+
}
|
|
16
|
+
var NodeTable = class {
|
|
17
|
+
constructor(graph) {
|
|
18
|
+
this.index = /* @__PURE__ */ new Map();
|
|
19
|
+
this.lengths = [];
|
|
20
|
+
this.onReference = new Uint8Array(0);
|
|
21
|
+
this.referenceStart = new Float64Array(0);
|
|
22
|
+
this.referenceEnd = new Float64Array(0);
|
|
23
|
+
for (const node of graph.nodes) {
|
|
24
|
+
this.lengths[this.indexOf(node.id)] = node.length;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
indexOf(id) {
|
|
28
|
+
let i = this.index.get(id);
|
|
29
|
+
if (i === void 0) {
|
|
30
|
+
i = this.lengths.length;
|
|
31
|
+
this.index.set(id, i);
|
|
32
|
+
this.lengths.push(0);
|
|
33
|
+
}
|
|
34
|
+
return i;
|
|
35
|
+
}
|
|
36
|
+
nodesOf(path) {
|
|
37
|
+
const nodes = new Int32Array(path.nodeIds.length);
|
|
38
|
+
path.nodeIds.forEach((id, k) => {
|
|
39
|
+
nodes[k] = this.indexOf(id);
|
|
40
|
+
});
|
|
41
|
+
return nodes;
|
|
42
|
+
}
|
|
43
|
+
spanAt(steps, k) {
|
|
44
|
+
const node = k >= 0 && k < steps.length ? steps[k] : -1;
|
|
45
|
+
return node >= 0 && this.onReference[node] ? { start: this.referenceStart[node], end: this.referenceEnd[node] } : void 0;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
function stepsOf(pieces, table) {
|
|
49
|
+
const out = [];
|
|
50
|
+
let end;
|
|
51
|
+
for (const piece of pieces) {
|
|
52
|
+
if (end !== void 0 && piece.start !== void 0 && piece.start > end) {
|
|
53
|
+
out.push(end - piece.start);
|
|
54
|
+
}
|
|
55
|
+
let bp = 0;
|
|
56
|
+
for (const node of piece.nodes) {
|
|
57
|
+
out.push(node);
|
|
58
|
+
bp += table.lengths[node];
|
|
59
|
+
}
|
|
60
|
+
end = piece.start === void 0 ? void 0 : piece.start + bp;
|
|
61
|
+
}
|
|
62
|
+
return Float64Array.from(out);
|
|
63
|
+
}
|
|
64
|
+
function stepSpan(pieces, table, k) {
|
|
65
|
+
let end;
|
|
66
|
+
let at = 0;
|
|
67
|
+
let found;
|
|
68
|
+
for (const piece of pieces) {
|
|
69
|
+
if (piece.start === void 0 || end !== void 0 && piece.start < end) {
|
|
70
|
+
return void 0;
|
|
71
|
+
}
|
|
72
|
+
if (end !== void 0 && piece.start > end) {
|
|
73
|
+
if (at++ === k) {
|
|
74
|
+
found = { start: end, end: piece.start };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
let pos = piece.start;
|
|
78
|
+
for (const node of piece.nodes) {
|
|
79
|
+
const len = table.lengths[node];
|
|
80
|
+
if (at++ === k) {
|
|
81
|
+
found = { start: pos, end: pos + len };
|
|
82
|
+
}
|
|
83
|
+
pos += len;
|
|
84
|
+
}
|
|
85
|
+
end = pos;
|
|
86
|
+
}
|
|
87
|
+
return found;
|
|
88
|
+
}
|
|
89
|
+
function sliceBetween(steps, table, region, flanked = true) {
|
|
90
|
+
if (!region || !flanked) {
|
|
91
|
+
return { ids: steps, complete: true, from: -1, to: -1 };
|
|
92
|
+
}
|
|
93
|
+
const { onReference, referenceStart, referenceEnd } = table;
|
|
94
|
+
let i0 = -1;
|
|
95
|
+
let i1 = -1;
|
|
96
|
+
let bestEnd = -Infinity;
|
|
97
|
+
let bestStart = Infinity;
|
|
98
|
+
for (let i = 0; i < steps.length; i++) {
|
|
99
|
+
const node = steps[i];
|
|
100
|
+
if (node >= 0 && onReference[node]) {
|
|
101
|
+
const end2 = referenceEnd[node];
|
|
102
|
+
const start = referenceStart[node];
|
|
103
|
+
if (end2 <= region.start && end2 > bestEnd) {
|
|
104
|
+
bestEnd = end2;
|
|
105
|
+
i0 = i;
|
|
106
|
+
}
|
|
107
|
+
if (start >= region.end && start < bestStart) {
|
|
108
|
+
bestStart = start;
|
|
109
|
+
i1 = i;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (i0 >= 0 && i1 >= 0) {
|
|
114
|
+
const ids2 = steps.slice(Math.min(i0, i1) + 1, Math.max(i0, i1));
|
|
115
|
+
return {
|
|
116
|
+
ids: i0 < i1 ? ids2 : ids2.reverse(),
|
|
117
|
+
complete: true,
|
|
118
|
+
from: i0,
|
|
119
|
+
to: i1
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
const spanAt = (k) => table.spanAt(steps, k);
|
|
123
|
+
const flank = i0 >= 0 ? i0 : i1;
|
|
124
|
+
let near = -1;
|
|
125
|
+
for (let d = 1; flank >= 0 && near < 0 && d < steps.length; d++) {
|
|
126
|
+
near = [flank - d, flank + d].find((j) => spanAt(j) !== void 0) ?? -1;
|
|
127
|
+
}
|
|
128
|
+
if (near < 0) {
|
|
129
|
+
return { ids: steps, complete: false, from: -1, to: -1 };
|
|
130
|
+
}
|
|
131
|
+
const forward = near > flank === spanAt(near).start > spanAt(flank).start;
|
|
132
|
+
const after = forward === (flank === i0);
|
|
133
|
+
const ids = after ? steps.slice(flank + 1) : steps.slice(0, flank).reverse();
|
|
134
|
+
const last = ids.length > 0 ? ids.length - 1 : -1;
|
|
135
|
+
const end = last < 0 ? spanAt(flank) : spanAt(after ? flank + 1 + last : 0);
|
|
136
|
+
const stop = {
|
|
137
|
+
contigEnds: end !== void 0,
|
|
138
|
+
shortBp: !end ? 0 : Math.max(0, region.start - end.end, end.start - region.end)
|
|
139
|
+
};
|
|
140
|
+
return {
|
|
141
|
+
ids,
|
|
142
|
+
complete: false,
|
|
143
|
+
from: flank,
|
|
144
|
+
to: after ? steps.length : -1,
|
|
145
|
+
stop
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function filterSamples(rows, samples) {
|
|
149
|
+
return samples ? rows.filter((r) => samples.includes(r.sample)).sort(
|
|
150
|
+
(a, b) => samples.indexOf(a.sample) - samples.indexOf(b.sample) || a.label.localeCompare(b.label)
|
|
151
|
+
) : rows;
|
|
152
|
+
}
|
|
153
|
+
function walkRows(graph, region, unit) {
|
|
154
|
+
const paths = graph.paths ?? [];
|
|
155
|
+
const isReference = (p) => pathOrigin(p.name).name === graph.referencePath;
|
|
156
|
+
const referencePieces = paths.some(isReference) ? paths.filter(isReference).sort((a, b) => (a.start ?? 0) - (b.start ?? 0)) : paths.slice(0, 1);
|
|
157
|
+
const first = referencePieces[0];
|
|
158
|
+
const others = paths.filter((p) => !referencePieces.includes(p));
|
|
159
|
+
if (!first || others.length === 0) {
|
|
160
|
+
return void 0;
|
|
161
|
+
}
|
|
162
|
+
const walks = /* @__PURE__ */ new Map();
|
|
163
|
+
for (const path of others) {
|
|
164
|
+
const pieces = walks.get(path.name);
|
|
165
|
+
if (pieces) {
|
|
166
|
+
pieces.push(path);
|
|
167
|
+
} else {
|
|
168
|
+
walks.set(path.name, [path]);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const table = new NodeTable(graph);
|
|
172
|
+
const referenceStart = first.start ?? 0;
|
|
173
|
+
const cut = region && region.end > region.start ? region : void 0;
|
|
174
|
+
const referenceNodes = referencePieces.map((piece) => table.nodesOf(piece));
|
|
175
|
+
const nodeCount = table.lengths.length;
|
|
176
|
+
table.onReference = new Uint8Array(nodeCount);
|
|
177
|
+
table.referenceStart = new Float64Array(nodeCount);
|
|
178
|
+
table.referenceEnd = new Float64Array(nodeCount);
|
|
179
|
+
let reachesBefore = false;
|
|
180
|
+
let reachesAfter = false;
|
|
181
|
+
for (const [p, piece] of referencePieces.entries()) {
|
|
182
|
+
let pos = piece.start ?? 0;
|
|
183
|
+
for (const node of referenceNodes[p]) {
|
|
184
|
+
const len = table.lengths[node];
|
|
185
|
+
if (!table.onReference[node]) {
|
|
186
|
+
table.onReference[node] = 1;
|
|
187
|
+
table.referenceStart[node] = pos;
|
|
188
|
+
table.referenceEnd[node] = pos + len;
|
|
189
|
+
reachesBefore ||= cut !== void 0 && pos + len <= cut.start;
|
|
190
|
+
reachesAfter ||= cut !== void 0 && pos >= cut.end;
|
|
191
|
+
}
|
|
192
|
+
pos += len;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
const flanked = cut === void 0 || reachesBefore && reachesAfter;
|
|
196
|
+
const rowOf = (paths2, nodes) => {
|
|
197
|
+
const path = paths2[0];
|
|
198
|
+
const pieces = paths2.map((piece, p) => ({
|
|
199
|
+
start: piece.start,
|
|
200
|
+
nodes: nodes?.[p] ?? table.nodesOf(piece)
|
|
201
|
+
})).sort((a, b) => (a.start ?? 0) - (b.start ?? 0));
|
|
202
|
+
const { ids, complete, from, to, stop } = sliceBetween(
|
|
203
|
+
stepsOf(pieces, table),
|
|
204
|
+
table,
|
|
205
|
+
cut,
|
|
206
|
+
flanked
|
|
207
|
+
);
|
|
208
|
+
const contig = path.contig ?? panSNContig(pathOrigin(path.name).name);
|
|
209
|
+
const axisSpan = stepSpan(pieces, table, from < 0 ? 0 : from);
|
|
210
|
+
const axis = !axisSpan ? void 0 : from < 0 ? { contig, start: axisSpan.start, reversed: false } : from < to ? { contig, start: axisSpan.end, reversed: false } : { contig, start: axisSpan.start, reversed: true };
|
|
211
|
+
const { lengths, onReference, referenceStart: referenceStart2, referenceEnd } = table;
|
|
212
|
+
const runs = [];
|
|
213
|
+
let last;
|
|
214
|
+
let bp = 0;
|
|
215
|
+
let offReferenceBp = 0;
|
|
216
|
+
let gapBp = 0;
|
|
217
|
+
let step = 0;
|
|
218
|
+
for (const node of ids) {
|
|
219
|
+
if (node < 0) {
|
|
220
|
+
last = { start: bp, bp: -node, onReference: false, gap: true };
|
|
221
|
+
runs.push(last);
|
|
222
|
+
bp -= node;
|
|
223
|
+
gapBp -= node;
|
|
224
|
+
step = 0;
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
const len = lengths[node];
|
|
228
|
+
const on = onReference[node] === 1;
|
|
229
|
+
const at = last?.referenceStart;
|
|
230
|
+
const forward = on && at !== void 0 && step >= 0 && at + last.bp === referenceStart2[node];
|
|
231
|
+
const backward = on && at !== void 0 && step <= 0 && referenceEnd[node] === at;
|
|
232
|
+
if (!on && last && !last.onReference && !last.gap) {
|
|
233
|
+
last.bp += len;
|
|
234
|
+
} else if (forward || backward) {
|
|
235
|
+
last.bp += len;
|
|
236
|
+
if (!forward) {
|
|
237
|
+
last.referenceStart = referenceStart2[node];
|
|
238
|
+
last.reversed = true;
|
|
239
|
+
}
|
|
240
|
+
step = forward ? 1 : -1;
|
|
241
|
+
} else {
|
|
242
|
+
last = {
|
|
243
|
+
start: bp,
|
|
244
|
+
bp: len,
|
|
245
|
+
onReference: on,
|
|
246
|
+
referenceStart: on ? referenceStart2[node] : void 0
|
|
247
|
+
};
|
|
248
|
+
runs.push(last);
|
|
249
|
+
step = 0;
|
|
250
|
+
}
|
|
251
|
+
bp += len;
|
|
252
|
+
if (!on) {
|
|
253
|
+
offReferenceBp += len;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return {
|
|
257
|
+
name: path.name,
|
|
258
|
+
label: labelOf(path),
|
|
259
|
+
sample: sampleOf(path),
|
|
260
|
+
haplotype: path.haplotype,
|
|
261
|
+
bp,
|
|
262
|
+
offReferenceBp,
|
|
263
|
+
gapBp,
|
|
264
|
+
complete,
|
|
265
|
+
stop,
|
|
266
|
+
runs,
|
|
267
|
+
axis
|
|
268
|
+
};
|
|
269
|
+
};
|
|
270
|
+
const origin = cut ? cut.start : referenceStart;
|
|
271
|
+
return {
|
|
272
|
+
origin,
|
|
273
|
+
unit,
|
|
274
|
+
reference: rowOf(referencePieces, referenceNodes),
|
|
275
|
+
rows: [...walks.values()].map((paths2) => rowOf(paths2)).sort(
|
|
276
|
+
(a, b) => Number(b.complete) - Number(a.complete) || b.bp - a.bp || a.label.localeCompare(b.label)
|
|
277
|
+
)
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export {
|
|
282
|
+
filterSamples,
|
|
283
|
+
walkRows
|
|
284
|
+
};
|
|
@@ -2,13 +2,13 @@ import {
|
|
|
2
2
|
alongRow,
|
|
3
3
|
boxesGenes,
|
|
4
4
|
rowPitch
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-XYP6WL2N.js";
|
|
6
6
|
import {
|
|
7
7
|
el
|
|
8
8
|
} from "./chunk-NNODIW4U.js";
|
|
9
9
|
import {
|
|
10
10
|
pathOrigin
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-M6LK4GII.js";
|
|
12
12
|
import {
|
|
13
13
|
LABEL_CHAR_PX
|
|
14
14
|
} from "./chunk-AB35TJST.js";
|