@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.
- package/README.md +42 -10
- package/dist/chunks/{chunk-F5CP5KSV.js → chunk-2HR33HEK.js} +43 -19
- package/dist/chunks/{chunk-XNLXC6GB.js → chunk-2TNFP3GC.js} +1 -1
- package/dist/chunks/{chunk-RQHIDUZR.js → chunk-4SM3YYY4.js} +6 -2
- package/dist/chunks/{chunk-3BLYOLTX.js → chunk-5PQQ4IXZ.js} +1 -1
- package/dist/chunks/{chunk-Q4B4O2M4.js → chunk-7ZS7UNYY.js} +1 -5
- package/dist/chunks/{chunk-H5NMBQZG.js → chunk-APOFTO4L.js} +1 -1
- package/dist/chunks/{chunk-6YVWF5TR.js → chunk-CDLHGGJH.js} +2 -2
- package/dist/chunks/{chunk-IDPBN2BP.js → chunk-DBLRFSET.js} +12 -13
- package/dist/chunks/{chunk-4J4IKYSL.js → chunk-FSOP446U.js} +6 -51
- package/dist/chunks/{chunk-QPKSULKV.js → chunk-IDYGRSNF.js} +1 -1
- package/dist/chunks/{chunk-WXUEAMJJ.js → chunk-IGQVO5L3.js} +1 -1
- package/dist/chunks/{chunk-KA6B7WCZ.js → chunk-JT2FJHD6.js} +1 -1
- package/dist/chunks/{chunk-EHEKIJ56.js → chunk-LJSZRCTZ.js} +2 -2
- package/dist/chunks/{chunk-7O7427XK.js → chunk-M2URPEV3.js} +1 -1
- package/dist/chunks/chunk-NPDW3JAD.js +118 -0
- package/dist/chunks/{chunk-FAWHP2CG.js → chunk-OB6OUWHG.js} +8 -8
- package/dist/chunks/{chunk-BPIELHWX.js → chunk-OROLXHDA.js} +2 -2
- package/dist/chunks/{chunk-ETYIYH7I.js → chunk-Q25JVERA.js} +5 -5
- package/dist/chunks/{chunk-LT66KA3W.js → chunk-QDP2NTAV.js} +3 -3
- package/dist/chunks/{chunk-TTFQTTBZ.js → chunk-RNROMUAS.js} +3 -3
- package/dist/chunks/{chunk-Q4X6O7BL.js → chunk-STHPR76Q.js} +22 -7
- package/dist/chunks/{chunk-QHCAFMHM.js → chunk-U7V64JZY.js} +1 -1
- package/dist/chunks/{chunk-O6SLIY74.js → chunk-WWQI7LPU.js} +195 -98
- package/dist/chunks/{chunk-3HNQW3HM.js → chunk-YI5HHKTR.js} +1 -1
- package/dist/chunks/{chunk-YAJT4IDN.js → chunk-Z2OUCH2J.js} +1 -1
- package/dist/chunks/{chunk-KCVW4VPK.js → chunk-Z2RG6IYI.js} +10 -10
- package/dist/cli/figure.js +22 -22
- package/dist/cli/fold.js +5 -5
- package/dist/figure.js +17 -17
- package/dist/figureData.js +20 -20
- package/dist/figureScene.js +13 -13
- package/dist/figureSettings.js +6 -6
- package/dist/gbzCut.js +4 -4
- package/dist/gbzWindow.js +3 -3
- package/dist/gfa/departures.js +26 -0
- package/dist/gfa/gfaConverter.js +1 -2
- package/dist/gfa/gfaTables.js +2 -2
- package/dist/gfa/graphTables.js +1 -2
- package/dist/index.js +39 -33
- package/dist/layout/forceCache.js +6 -6
- package/dist/layout/tubeMapLayout.js +5 -5
- package/dist/layout/walkRowDraw.js +4 -4
- package/dist/layout/walkRowLayout.js +6 -6
- package/dist/layout/walkRowRuns.js +3 -3
- package/dist/layout/walkRows.js +4 -4
- package/dist/layout/walkStrip.js +7 -7
- package/dist/layoutModes.js +8 -8
- package/dist/pipeline.js +5 -5
- package/dist/tubeMap/bundle.js +6 -6
- package/dist/tubeMap/coarsen.js +6 -6
- package/dist/tubeMap/deviations.js +6 -6
- package/dist/tubeMap/draw.js +5 -5
- package/dist/types/gfa/departures.d.ts +72 -0
- package/dist/types/gfa/graphTables.d.ts +35 -12
- package/dist/types/index.d.ts +4 -4
- package/dist/types/layout/deletionRoutes.d.ts +1 -1
- package/dist/types/layout/walkRowDraw.d.ts +4 -4
- package/dist/types/layout/walkRowRuns.d.ts +26 -6
- package/dist/types/layout/walkRows.d.ts +10 -4
- package/dist/types/types.d.ts +4 -25
- package/dist/types/version.d.ts +1 -1
- package/dist/types/walkHighlight.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/viewport.js +6 -6
- package/dist/walkHighlight.js +2 -2
- package/dist/walkKey.js +2 -2
- package/package.json +3 -1
- package/dist/chunks/chunk-D7ZTAGDM.js +0 -168
- package/dist/gfa/walkStops.js +0 -28
- package/dist/types/gfa/walkStops.d.ts +0 -59
|
@@ -3,25 +3,25 @@ import {
|
|
|
3
3
|
} from "./chunk-CO6RGQAD.js";
|
|
4
4
|
import {
|
|
5
5
|
layoutModeByValue
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-OROLXHDA.js";
|
|
7
7
|
import {
|
|
8
8
|
parseRegion
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-IDYGRSNF.js";
|
|
10
10
|
import {
|
|
11
11
|
genePins
|
|
12
12
|
} from "./chunk-HEYIAMTC.js";
|
|
13
13
|
import {
|
|
14
14
|
version
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-IGQVO5L3.js";
|
|
16
16
|
import {
|
|
17
17
|
axisScaleOf
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-2TNFP3GC.js";
|
|
19
19
|
import {
|
|
20
20
|
figureScene
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-Q25JVERA.js";
|
|
22
22
|
import {
|
|
23
23
|
fadedKey
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-STHPR76Q.js";
|
|
25
25
|
import {
|
|
26
26
|
encodingStops
|
|
27
27
|
} from "./chunk-OC5HU7M3.js";
|
|
@@ -44,13 +44,13 @@ import {
|
|
|
44
44
|
} from "./chunk-XWH4LB56.js";
|
|
45
45
|
import {
|
|
46
46
|
FIGURE_DEFAULTS
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-5PQQ4IXZ.js";
|
|
48
48
|
import {
|
|
49
49
|
engineSettingsOf,
|
|
50
50
|
fitTransform,
|
|
51
51
|
forceLayout,
|
|
52
52
|
loadGraph
|
|
53
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-RNROMUAS.js";
|
|
54
54
|
import {
|
|
55
55
|
referencePositions
|
|
56
56
|
} from "./chunk-L4DBSRA2.js";
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
hasTubeMapPaths,
|
|
7
7
|
tubeMapLayout,
|
|
8
8
|
tubeMapReferenceLayout
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-YI5HHKTR.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-
|
|
18
|
+
} from "./chunk-LJSZRCTZ.js";
|
|
19
19
|
import {
|
|
20
20
|
withoutStrayHandles
|
|
21
21
|
} from "./chunk-FGH4D6WT.js";
|
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
facetLifts,
|
|
6
6
|
walkLift
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-STHPR76Q.js";
|
|
8
8
|
import {
|
|
9
9
|
walkKey
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-QDP2NTAV.js";
|
|
11
11
|
import {
|
|
12
12
|
walkRowsExtent
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-LJSZRCTZ.js";
|
|
14
14
|
import {
|
|
15
15
|
buildGeometry,
|
|
16
16
|
computeReferenceRamp
|
|
@@ -21,10 +21,10 @@ import {
|
|
|
21
21
|
} from "./chunk-KKYPJITI.js";
|
|
22
22
|
import {
|
|
23
23
|
FIGURE_DEFAULTS
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-5PQQ4IXZ.js";
|
|
25
25
|
import {
|
|
26
26
|
drawingBounds
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-RNROMUAS.js";
|
|
28
28
|
import {
|
|
29
29
|
referenceLabel
|
|
30
30
|
} from "./chunk-5ORP7EFJ.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
GAP_CAUSE_TEXT,
|
|
3
3
|
OUTSIDE_TEXT
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-NPDW3JAD.js";
|
|
5
5
|
import {
|
|
6
6
|
formatBp,
|
|
7
7
|
groupDigits
|
|
@@ -18,10 +18,10 @@ function walkKey(walk, reference) {
|
|
|
18
18
|
const own = walk.range ? rangeText(walk.range.contig, walk.range.start, walk.range.end) : void 0;
|
|
19
19
|
const scale = field === "progress" ? own : field === "reference" && reference ? rangeText(reference.name, reference.start, reference.end) : void 0;
|
|
20
20
|
const spanned = walk.range ? walk.range.end - walk.range.start : walk.bp;
|
|
21
|
-
const outside = spanned - walk.bp - walk.missingBp - walk.
|
|
21
|
+
const outside = spanned - walk.bp - walk.missingBp - walk.ownBp;
|
|
22
22
|
const gaps = [
|
|
23
23
|
[walk.missingBp, GAP_CAUSE_TEXT.missing],
|
|
24
|
-
[walk.
|
|
24
|
+
[walk.ownBp, GAP_CAUSE_TEXT.own],
|
|
25
25
|
[outside, OUTSIDE_TEXT]
|
|
26
26
|
];
|
|
27
27
|
return {
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from "./chunk-NAYS472K.js";
|
|
15
15
|
import {
|
|
16
16
|
convertGFAToGraph
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-7ZS7UNYY.js";
|
|
18
18
|
import {
|
|
19
19
|
parseGFA
|
|
20
20
|
} from "./chunk-CFXXFHRK.js";
|
|
@@ -23,10 +23,10 @@ import {
|
|
|
23
23
|
} from "./chunk-FGH4D6WT.js";
|
|
24
24
|
import {
|
|
25
25
|
graphFromTables
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-DBLRFSET.js";
|
|
27
27
|
import {
|
|
28
28
|
gfaTables
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-FSOP446U.js";
|
|
30
30
|
import {
|
|
31
31
|
mergeRuns,
|
|
32
32
|
splitRuns
|
|
@@ -7,8 +7,9 @@ import {
|
|
|
7
7
|
rampFraction
|
|
8
8
|
} from "./chunk-UY7CLJNZ.js";
|
|
9
9
|
import {
|
|
10
|
+
departureAt,
|
|
10
11
|
gapParts
|
|
11
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-NPDW3JAD.js";
|
|
12
13
|
import {
|
|
13
14
|
pathOrigin,
|
|
14
15
|
referenceVisitStarts
|
|
@@ -102,18 +103,20 @@ function highlightOf(graph, name, { byId, edgeAt }) {
|
|
|
102
103
|
before += length;
|
|
103
104
|
});
|
|
104
105
|
}
|
|
106
|
+
const departures = departuresOf(graph, name);
|
|
105
107
|
let missingBp = 0;
|
|
106
|
-
let
|
|
108
|
+
let ownBp = 0;
|
|
107
109
|
let end;
|
|
108
110
|
pieces.forEach((piece, p) => {
|
|
109
111
|
if (end !== void 0 && piece.start !== void 0 && piece.start > end) {
|
|
110
112
|
for (const part of gapParts(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
piece.
|
|
113
|
+
end,
|
|
114
|
+
piece.start,
|
|
115
|
+
{ after: pieces[p - 1].trimmedAfter, before: piece.trimmedBefore },
|
|
116
|
+
departures
|
|
114
117
|
)) {
|
|
115
118
|
missingBp += part.cause === "missing" ? part.bp : 0;
|
|
116
|
-
|
|
119
|
+
ownBp += part.cause === "own" ? part.bp : 0;
|
|
117
120
|
}
|
|
118
121
|
}
|
|
119
122
|
end = piece.start === void 0 ? void 0 : piece.start + bpOf(piece);
|
|
@@ -142,9 +145,21 @@ function highlightOf(graph, name, { byId, edgeAt }) {
|
|
|
142
145
|
bp,
|
|
143
146
|
referenceBp: referenceSpan(),
|
|
144
147
|
missingBp,
|
|
145
|
-
|
|
148
|
+
ownBp
|
|
146
149
|
};
|
|
147
150
|
}
|
|
151
|
+
function departuresOf(graph, name) {
|
|
152
|
+
const table = graph.departures;
|
|
153
|
+
const out = [];
|
|
154
|
+
if (table) {
|
|
155
|
+
for (let k = 0; k < table.names.length; k++) {
|
|
156
|
+
if (pathOrigin(table.names[k]).name === name) {
|
|
157
|
+
out.push(departureAt(table, k));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return out;
|
|
162
|
+
}
|
|
148
163
|
function laneColors(graph, byId, walk, encoding, ramp) {
|
|
149
164
|
const places = encoding.field === "progress" || !ramp ? void 0 : referencePlaces(graph, byId, walk, ramp);
|
|
150
165
|
const colors = /* @__PURE__ */ new Map();
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
tableNodeIds,
|
|
3
3
|
tablePath
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-DBLRFSET.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
"
|
|
32
|
+
"own",
|
|
30
33
|
"abridged",
|
|
31
|
-
"
|
|
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
|
|
202
|
-
if (first === void 0 || others.length === 0 &&
|
|
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,57 @@ 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
|
-
const
|
|
254
|
+
const departureRuns = (own, bar2) => {
|
|
255
|
+
const spans = own.map(departureSpan).sort((a, b) => a.start - b.start);
|
|
256
|
+
const base = bar2?.start ?? spans[0]?.start ?? 0;
|
|
257
|
+
const merged = [];
|
|
258
|
+
for (const span of spans) {
|
|
259
|
+
const start2 = bar2 ? Math.max(span.start, bar2.start) : span.start;
|
|
260
|
+
const end = bar2 ? Math.min(span.end, bar2.end) : span.end;
|
|
261
|
+
const last = merged.at(-1);
|
|
262
|
+
if (end > start2) {
|
|
263
|
+
if (last && start2 <= last.end) {
|
|
264
|
+
last.end = Math.max(last.end, end);
|
|
265
|
+
} else {
|
|
266
|
+
merged.push({ start: start2, end });
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
let gapBp = 0;
|
|
271
|
+
for (const { start: start2, end } of merged) {
|
|
272
|
+
runs.push(
|
|
273
|
+
start2 - base,
|
|
274
|
+
end - start2,
|
|
275
|
+
Number.NaN,
|
|
276
|
+
RUN_GAP | causeFlags("departure"),
|
|
277
|
+
Number.NaN
|
|
278
|
+
);
|
|
279
|
+
gapBp += end - start2;
|
|
280
|
+
}
|
|
281
|
+
return gapBp;
|
|
282
|
+
};
|
|
283
|
+
const steplessMeta = (head, own, gapBp) => ({
|
|
284
|
+
name: head.name,
|
|
285
|
+
label: labelOf(head),
|
|
286
|
+
sample: sampleOf(head),
|
|
287
|
+
haplotype: head.haplotype,
|
|
288
|
+
bp: 0,
|
|
289
|
+
offReferenceBp: own.reduce((sum, d) => sum + d.ownBp, 0),
|
|
290
|
+
gapBp,
|
|
291
|
+
complete: true,
|
|
292
|
+
stop: void 0,
|
|
293
|
+
axis: void 0,
|
|
294
|
+
departures: own,
|
|
295
|
+
stepless: true,
|
|
296
|
+
...own.some(placementChoice) ? { placementChoice: true } : {}
|
|
297
|
+
});
|
|
298
|
+
const rowOf = (pieces, bar2) => {
|
|
260
299
|
const head = heads[pieces[0]];
|
|
300
|
+
const own = departuresOf.get(nameOf(pieces[0])) ?? [];
|
|
301
|
+
const extents = [];
|
|
261
302
|
const ordered = [...pieces].sort(byStart);
|
|
262
303
|
let count = ordered.length - 1;
|
|
263
304
|
let abridgedSteps = 0;
|
|
@@ -291,9 +332,13 @@ function walkRowRuns(source, region, o = {}) {
|
|
|
291
332
|
partsAt.set(
|
|
292
333
|
length,
|
|
293
334
|
gapParts(
|
|
294
|
-
gap,
|
|
295
|
-
|
|
296
|
-
|
|
335
|
+
start2 - gap,
|
|
336
|
+
start2,
|
|
337
|
+
{
|
|
338
|
+
after: heads[previous].trimmedAfter,
|
|
339
|
+
before: heads[piece].trimmedBefore
|
|
340
|
+
},
|
|
341
|
+
own
|
|
297
342
|
)
|
|
298
343
|
);
|
|
299
344
|
steps[length] = -gap;
|
|
@@ -315,6 +360,9 @@ function walkRowRuns(source, region, o = {}) {
|
|
|
315
360
|
pos += lengthOf(node);
|
|
316
361
|
}
|
|
317
362
|
end = start2 === void 0 ? void 0 : pos;
|
|
363
|
+
if (start2 !== void 0) {
|
|
364
|
+
extents.push([start2, pos]);
|
|
365
|
+
}
|
|
318
366
|
previous = piece;
|
|
319
367
|
}
|
|
320
368
|
const onReference = (i) => i >= 0 && i < length && steps[i] >= 0 && !Number.isNaN(spanStart[steps[i]]);
|
|
@@ -322,33 +370,55 @@ function walkRowRuns(source, region, o = {}) {
|
|
|
322
370
|
const id = steps[i];
|
|
323
371
|
return stepStart[i] + (id < 0 ? -id : lengthOf(id));
|
|
324
372
|
};
|
|
325
|
-
const
|
|
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);
|
|
373
|
+
const endOf = (after) => {
|
|
336
374
|
const last2 = after ? length - 1 : 0;
|
|
337
|
-
const
|
|
375
|
+
const edge = after ? stepEnd(last2) : stepStart[last2];
|
|
376
|
+
return {
|
|
377
|
+
last: last2,
|
|
378
|
+
departure: own.find(
|
|
379
|
+
(d) => after ? d.hapStart === edge : d.hapStart + d.ownBp === edge
|
|
380
|
+
),
|
|
381
|
+
trimmed: after ? heads[ordered.at(-1)].trimmedAfter : heads[ordered[0]].trimmedBefore
|
|
382
|
+
};
|
|
383
|
+
};
|
|
384
|
+
const flankForward = (flank, rightward) => {
|
|
385
|
+
let near2 = -1;
|
|
386
|
+
for (let d = 1; near2 < 0 && d < length; d++) {
|
|
387
|
+
near2 = [flank - d, flank + d].find(onReference) ?? -1;
|
|
388
|
+
}
|
|
389
|
+
const tail = endOf(true);
|
|
390
|
+
const lead = endOf(false);
|
|
391
|
+
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;
|
|
392
|
+
};
|
|
393
|
+
const partialSide = (i0, i1, inside) => {
|
|
394
|
+
const flank = i0 >= 0 ? i0 : i1;
|
|
395
|
+
const rightward = flank === i0;
|
|
396
|
+
const forward = flankForward(flank, rightward);
|
|
397
|
+
const after = forward === rightward;
|
|
398
|
+
const { last: last2, departure, trimmed } = endOf(after);
|
|
399
|
+
const contigEnds = onReference(last2) && !departure && !trimmed;
|
|
338
400
|
const stop2 = {
|
|
339
401
|
contigEnds,
|
|
340
402
|
shortBp: contigEnds ? Math.max(
|
|
341
403
|
0,
|
|
342
404
|
cut.start - spanEnd[steps[last2]],
|
|
343
405
|
spanStart[steps[last2]] - cut.end
|
|
344
|
-
) : 0
|
|
406
|
+
) : 0,
|
|
407
|
+
...departure ? {
|
|
408
|
+
goesOn: {
|
|
409
|
+
departure,
|
|
410
|
+
near: after ? departure.rejoinPos : departure.leavePos
|
|
411
|
+
}
|
|
412
|
+
} : {}
|
|
345
413
|
};
|
|
346
|
-
|
|
414
|
+
const skip = inside ? 0 : 1;
|
|
415
|
+
const from2 = after === inside ? stepStart[flank] : stepEnd(flank);
|
|
416
|
+
return forward === void 0 ? void 0 : {
|
|
347
417
|
stop: stop2,
|
|
348
|
-
lo: after ? flank +
|
|
349
|
-
hi: after ? length : flank,
|
|
418
|
+
lo: after ? flank + skip : 0,
|
|
419
|
+
hi: after ? length : flank + 1 - skip,
|
|
350
420
|
backward: !forward,
|
|
351
|
-
axisStart: forward ? after ?
|
|
421
|
+
axisStart: forward ? after ? from2 : stepStart[0] : after ? stepEnd(length - 1) : from2
|
|
352
422
|
};
|
|
353
423
|
};
|
|
354
424
|
let lo = 0;
|
|
@@ -381,6 +451,14 @@ function walkRowRuns(source, region, o = {}) {
|
|
|
381
451
|
}
|
|
382
452
|
return Number.isNaN(spanStart[id]) && (abridgedAt(i - 1) || abridgedAt(i + 1)) ? stableStart(id) : spanStart[id];
|
|
383
453
|
};
|
|
454
|
+
const stopsInside = (i0, i1, inside) => {
|
|
455
|
+
complete = false;
|
|
456
|
+
const side = i0 >= 0 || i1 >= 0 ? partialSide(i0, i1, inside) : void 0;
|
|
457
|
+
if (side) {
|
|
458
|
+
;
|
|
459
|
+
({ lo, hi, backward, axisStart, stop } = side);
|
|
460
|
+
}
|
|
461
|
+
};
|
|
384
462
|
let leftTrim = 0;
|
|
385
463
|
let rightTrim = 0;
|
|
386
464
|
if (cut && flanked) {
|
|
@@ -403,12 +481,7 @@ function walkRowRuns(source, region, o = {}) {
|
|
|
403
481
|
}
|
|
404
482
|
}
|
|
405
483
|
if (i0 < 0 || i1 < 0) {
|
|
406
|
-
|
|
407
|
-
const inside = i0 >= 0 || i1 >= 0 ? partialSide(i0, i1) : void 0;
|
|
408
|
-
if (inside) {
|
|
409
|
-
;
|
|
410
|
-
({ lo, hi, backward, axisStart, stop } = inside);
|
|
411
|
-
}
|
|
484
|
+
stopsInside(i0, i1, false);
|
|
412
485
|
} else {
|
|
413
486
|
lo = Math.min(i0, i1) + 1;
|
|
414
487
|
hi = Math.max(i0, i1);
|
|
@@ -419,7 +492,28 @@ function walkRowRuns(source, region, o = {}) {
|
|
|
419
492
|
leftTrim = trimAbridged(i0 + inward, flankEnd - bestEnd);
|
|
420
493
|
rightTrim = trimAbridged(i1 - inward, bestStart - flankStart);
|
|
421
494
|
}
|
|
495
|
+
} else if (cut && ordered.some(
|
|
496
|
+
(p) => heads[p].trimmedBefore !== void 0 || heads[p].trimmedAfter !== void 0
|
|
497
|
+
)) {
|
|
498
|
+
let i0 = -1;
|
|
499
|
+
let i1 = -1;
|
|
500
|
+
for (let i = 0; i < length; i++) {
|
|
501
|
+
const start2 = placeStart(i);
|
|
502
|
+
if (i0 < 0 && start2 === referenceLo) {
|
|
503
|
+
i0 = i;
|
|
504
|
+
}
|
|
505
|
+
if (i1 < 0 && start2 + lengthOf(steps[i]) === referenceHi) {
|
|
506
|
+
i1 = i;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
if (i0 < 0 || i1 < 0) {
|
|
510
|
+
stopsInside(i0, i1, true);
|
|
511
|
+
}
|
|
422
512
|
}
|
|
513
|
+
const stepless = bar2 !== void 0 && lo >= hi && own.some((d) => {
|
|
514
|
+
const span = departureSpan(d);
|
|
515
|
+
return span.start < bar2.end && span.end > bar2.start;
|
|
516
|
+
});
|
|
423
517
|
const contig = head.contig ?? panSNContig(pathOrigin(head.name).name);
|
|
424
518
|
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 ? {
|
|
425
519
|
contig,
|
|
@@ -470,7 +564,7 @@ function walkRowRuns(source, region, o = {}) {
|
|
|
470
564
|
part.bp,
|
|
471
565
|
Number.NaN,
|
|
472
566
|
RUN_GAP | causeFlags(part.cause),
|
|
473
|
-
|
|
567
|
+
part.near ?? Number.NaN
|
|
474
568
|
);
|
|
475
569
|
bp2 += part.bp;
|
|
476
570
|
}
|
|
@@ -502,7 +596,7 @@ function walkRowRuns(source, region, o = {}) {
|
|
|
502
596
|
} else {
|
|
503
597
|
lastFlags = on ? RUN_ON_REFERENCE : 0;
|
|
504
598
|
lastRef = on ? at : Number.NaN;
|
|
505
|
-
runs.push(bp2, len, lastRef, lastFlags,
|
|
599
|
+
runs.push(bp2, len, lastRef, lastFlags, Number.NaN);
|
|
506
600
|
last = runs.length - 1;
|
|
507
601
|
step = 0;
|
|
508
602
|
}
|
|
@@ -513,9 +607,13 @@ function walkRowRuns(source, region, o = {}) {
|
|
|
513
607
|
offReferenceBp += len;
|
|
514
608
|
}
|
|
515
609
|
}
|
|
610
|
+
const departureGapBp = stepless ? departureRuns(own, bar2) : 0;
|
|
516
611
|
runs.endRow();
|
|
517
612
|
visits?.endRow();
|
|
518
|
-
|
|
613
|
+
const undrawn = own.filter(
|
|
614
|
+
(d) => !extents.some(([a, b]) => d.hapStart > a && d.hapStart + d.ownBp < b)
|
|
615
|
+
);
|
|
616
|
+
return stepless ? steplessMeta(head, own, departureGapBp) : {
|
|
519
617
|
name: head.name,
|
|
520
618
|
label: labelOf(head),
|
|
521
619
|
sample: sampleOf(head),
|
|
@@ -527,57 +625,36 @@ function walkRowRuns(source, region, o = {}) {
|
|
|
527
625
|
stop,
|
|
528
626
|
axis: axis2,
|
|
529
627
|
...abridgedSteps > 0 ? { abridgedSteps } : {},
|
|
530
|
-
...leftTrim + rightTrim > 0 ? { estimated: true } : {}
|
|
628
|
+
...leftTrim + rightTrim > 0 ? { estimated: true } : {},
|
|
629
|
+
...undrawn.length > 0 ? { departures: undrawn } : {},
|
|
630
|
+
...own.some(placementChoice) ? { placementChoice: true } : {}
|
|
531
631
|
};
|
|
532
632
|
};
|
|
533
|
-
const
|
|
534
|
-
const
|
|
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
|
-
);
|
|
633
|
+
const steplessRowOf = (name, own, bar2) => {
|
|
634
|
+
const gapBp = departureRuns(own, bar2);
|
|
543
635
|
runs.endRow();
|
|
544
636
|
visits?.endRow();
|
|
545
|
-
|
|
546
|
-
return {
|
|
547
|
-
name,
|
|
548
|
-
label: labelOf(head),
|
|
549
|
-
sample: sampleOf(head),
|
|
550
|
-
haplotype: head.haplotype,
|
|
551
|
-
bp: 0,
|
|
552
|
-
offReferenceBp: 0,
|
|
553
|
-
gapBp: bp2,
|
|
554
|
-
complete: true,
|
|
555
|
-
stop: void 0,
|
|
556
|
-
axis: void 0,
|
|
557
|
-
deletionBp: end - start2
|
|
558
|
-
};
|
|
637
|
+
return steplessMeta({ name, ...panSNFields(name) }, own, gapBp);
|
|
559
638
|
};
|
|
560
639
|
const referenceRow = rowOf(referencePieces);
|
|
561
|
-
const rows = [...walks.values()].map((pieces, i) => ({
|
|
562
|
-
meta: rowOf(pieces),
|
|
563
|
-
row: i + 1
|
|
564
|
-
}));
|
|
565
|
-
const drawn = new Set(walks.keys());
|
|
566
640
|
const { axis } = referenceRow;
|
|
567
641
|
const bar = axis ? {
|
|
568
642
|
start: axis.start,
|
|
569
643
|
end: axis.start + referenceRow.bp + referenceRow.gapBp
|
|
570
644
|
} : cut;
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
645
|
+
const rows = [...walks.values()].map((pieces, i) => ({
|
|
646
|
+
meta: rowOf(pieces, bar),
|
|
647
|
+
row: i + 1
|
|
648
|
+
}));
|
|
649
|
+
const drawn = new Set(walks.keys());
|
|
650
|
+
for (const [name, own] of departuresOf) {
|
|
651
|
+
if (!drawn.has(name)) {
|
|
575
652
|
rows.push({
|
|
576
|
-
meta:
|
|
653
|
+
meta: steplessRowOf(name, own, bar),
|
|
577
654
|
row: rows.length + 1
|
|
578
655
|
});
|
|
579
656
|
}
|
|
580
|
-
}
|
|
657
|
+
}
|
|
581
658
|
const metas = [referenceRow, ...rows.map((r) => r.meta)];
|
|
582
659
|
if (new Set(metas.map((m) => m.label)).size < metas.length) {
|
|
583
660
|
for (const meta of metas) {
|
|
@@ -593,9 +670,9 @@ function walkRowRuns(source, region, o = {}) {
|
|
|
593
670
|
float64,
|
|
594
671
|
float64,
|
|
595
672
|
(n) => new Uint8Array(n),
|
|
596
|
-
|
|
673
|
+
float64
|
|
597
674
|
]);
|
|
598
|
-
const [start, bp, referenceStart, flags,
|
|
675
|
+
const [start, bp, referenceStart, flags, near] = columns;
|
|
599
676
|
return {
|
|
600
677
|
origin: cut ? cut.start : startOf(first) ?? 0,
|
|
601
678
|
rows: [referenceRow, ...rows.map((r) => r.meta)],
|
|
@@ -604,11 +681,31 @@ function walkRowRuns(source, region, o = {}) {
|
|
|
604
681
|
bp,
|
|
605
682
|
referenceStart,
|
|
606
683
|
flags,
|
|
607
|
-
|
|
608
|
-
chunks,
|
|
684
|
+
near,
|
|
609
685
|
visits: visits && visitColumns(visits, order, names)
|
|
610
686
|
};
|
|
611
687
|
}
|
|
688
|
+
function departuresByWalk(table, reference) {
|
|
689
|
+
const byWalk = /* @__PURE__ */ new Map();
|
|
690
|
+
if (table) {
|
|
691
|
+
for (let k = 0; k < table.names.length; k++) {
|
|
692
|
+
const d = departureAt(table, k);
|
|
693
|
+
const name = pathOrigin(d.name).name;
|
|
694
|
+
if (name !== reference) {
|
|
695
|
+
const list = byWalk.get(name);
|
|
696
|
+
if (list) {
|
|
697
|
+
list.push(d);
|
|
698
|
+
} else {
|
|
699
|
+
byWalk.set(name, [d]);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
for (const list of byWalk.values()) {
|
|
705
|
+
list.sort((a, b) => a.hapStart - b.hapStart);
|
|
706
|
+
}
|
|
707
|
+
return byWalk;
|
|
708
|
+
}
|
|
612
709
|
function visitColumns(visits, order, names) {
|
|
613
710
|
const { offsets, columns } = visits.reorder(order, [
|
|
614
711
|
(n) => new Int32Array(n),
|
|
@@ -632,9 +729,9 @@ function runAt(t, k) {
|
|
|
632
729
|
if (cause) {
|
|
633
730
|
run.cause = cause;
|
|
634
731
|
}
|
|
635
|
-
const
|
|
636
|
-
if (
|
|
637
|
-
run.
|
|
732
|
+
const near = t.near[k];
|
|
733
|
+
if (!Number.isNaN(near)) {
|
|
734
|
+
run.near = near;
|
|
638
735
|
}
|
|
639
736
|
} else {
|
|
640
737
|
run.referenceStart = Number.isNaN(t.referenceStart[k]) ? void 0 : t.referenceStart[k];
|