@jbrowse/bandage-core 10.0.0 → 10.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 (41) hide show
  1. package/README.md +20 -0
  2. package/dist/chunks/{chunk-3APK25GI.js → chunk-3XE3OUEN.js} +1 -1
  3. package/dist/chunks/chunk-A647OH7N.js +284 -0
  4. package/dist/chunks/{chunk-Q6IOQP4J.js → chunk-AZJF2PZE.js} +5 -5
  5. package/dist/chunks/{chunk-33T67FPZ.js → chunk-CFNFT4RA.js} +1 -1
  6. package/dist/chunks/{chunk-RJXPPYA7.js → chunk-FFFYXMOP.js} +7 -7
  7. package/dist/chunks/{chunk-VK6XMP6B.js → chunk-FLUQODT2.js} +1 -3
  8. package/dist/chunks/{chunk-ICXMWYOA.js → chunk-IFOZFVZK.js} +4 -4
  9. package/dist/chunks/{chunk-CDPYXHVR.js → chunk-KY4LV2Z6.js} +1 -1
  10. package/dist/chunks/{chunk-W4GZCVUK.js → chunk-MSX3BDO4.js} +5 -5
  11. package/dist/chunks/{chunk-OOLNLCIO.js → chunk-QORSYW7J.js} +1 -1
  12. package/dist/chunks/{chunk-JVLURPFW.js → chunk-VPE4AYP7.js} +1 -2
  13. package/dist/chunks/{chunk-E5UEYZWK.js → chunk-ZR7A7DKQ.js} +1 -1
  14. package/dist/cli/figure.js +12 -14
  15. package/dist/cli/fold.js +2 -2
  16. package/dist/figure.js +8 -8
  17. package/dist/figureData.js +10 -12
  18. package/dist/figureSettings.js +3 -3
  19. package/dist/index.js +36 -37
  20. package/dist/layout/deletionRoutes.js +1 -3
  21. package/dist/layout/forceCache.js +3 -3
  22. package/dist/layout/walkRowLayout.js +2 -2
  23. package/dist/layout/walkRows.js +1 -1
  24. package/dist/layoutEngines.js +1 -5
  25. package/dist/layoutModes.js +4 -4
  26. package/dist/pipeline.js +2 -2
  27. package/dist/tubeMap/draw.js +2 -2
  28. package/dist/types/index.d.ts +1 -1
  29. package/dist/types/layout/deletionRoutes.d.ts +0 -1
  30. package/dist/types/version.d.ts +1 -1
  31. package/dist/version.js +1 -1
  32. package/dist/viewport.js +3 -3
  33. package/package.json +2 -1
  34. package/dist/chunks/chunk-KAN2WTG5.js +0 -226
  35. package/dist/chunks/chunk-LYJ4US66.js +0 -664
  36. package/dist/chunks/chunk-Q6FRNVDU.js +0 -531
  37. package/dist/layout/stressEngine.js +0 -11
  38. package/dist/layout/stressPlacement.js +0 -7
  39. package/dist/types/layout/stressEngine.d.ts +0 -27
  40. package/dist/types/layout/stressPlacement.d.ts +0 -5
  41. package/dist/chunks/{chunk-EU6FBTQF.js → chunk-HQ2AHRMH.js} +3 -3
@@ -1,226 +0,0 @@
1
- import {
2
- pathOrigin
3
- } from "./chunk-EMUUNWRU.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
- function stepsOf(pieces, lengthOf) {
17
- const steps = [];
18
- let end;
19
- for (const piece of pieces) {
20
- if (end !== void 0 && piece.start !== void 0 && piece.start > end) {
21
- steps.push(piece.start - end);
22
- }
23
- steps.push(...piece.nodeIds);
24
- const bp = piece.nodeIds.reduce(
25
- (sum, id) => sum + (lengthOf.get(id) ?? 0),
26
- 0
27
- );
28
- end = piece.start === void 0 ? void 0 : piece.start + bp;
29
- }
30
- return steps;
31
- }
32
- function stepSpans(pieces, lengthOf) {
33
- const spans = [];
34
- let end;
35
- for (const piece of pieces) {
36
- if (piece.start === void 0 || end !== void 0 && piece.start < end) {
37
- return void 0;
38
- }
39
- if (end !== void 0 && piece.start > end) {
40
- spans.push({ start: end, end: piece.start });
41
- }
42
- let pos = piece.start;
43
- for (const id of piece.nodeIds) {
44
- const len = lengthOf.get(id) ?? 0;
45
- spans.push({ start: pos, end: pos + len });
46
- pos += len;
47
- }
48
- end = pos;
49
- }
50
- return spans;
51
- }
52
- function sliceBetween(steps, span, region, flanked = true) {
53
- if (!region || !flanked) {
54
- return { ids: steps, complete: true, from: -1, to: -1 };
55
- }
56
- const spanAt = (i) => {
57
- const id = steps[i];
58
- return typeof id === "string" ? span.get(id) : void 0;
59
- };
60
- let i0 = -1;
61
- let i1 = -1;
62
- let bestEnd = -Infinity;
63
- let bestStart = Infinity;
64
- steps.forEach((_, i) => {
65
- const s = spanAt(i);
66
- if (s) {
67
- if (s.end <= region.start && s.end > bestEnd) {
68
- bestEnd = s.end;
69
- i0 = i;
70
- }
71
- if (s.start >= region.end && s.start < bestStart) {
72
- bestStart = s.start;
73
- i1 = i;
74
- }
75
- }
76
- });
77
- if (i0 >= 0 && i1 >= 0) {
78
- const ids2 = steps.slice(Math.min(i0, i1) + 1, Math.max(i0, i1));
79
- return {
80
- ids: i0 < i1 ? ids2 : ids2.reverse(),
81
- complete: true,
82
- from: i0,
83
- to: i1
84
- };
85
- }
86
- const flank = i0 >= 0 ? i0 : i1;
87
- let near = -1;
88
- for (let d = 1; flank >= 0 && near < 0 && d < steps.length; d++) {
89
- near = [flank - d, flank + d].find((j) => spanAt(j) !== void 0) ?? -1;
90
- }
91
- if (near < 0) {
92
- return { ids: steps, complete: false, from: -1, to: -1 };
93
- }
94
- const forward = near > flank === spanAt(near).start > spanAt(flank).start;
95
- const after = forward === (flank === i0);
96
- const ids = after ? steps.slice(flank + 1) : steps.slice(0, flank).reverse();
97
- const last = ids.length > 0 ? ids.length - 1 : -1;
98
- const end = last < 0 ? spanAt(flank) : spanAt(after ? flank + 1 + last : 0);
99
- const stop = {
100
- contigEnds: end !== void 0,
101
- shortBp: !end ? 0 : Math.max(0, region.start - end.end, end.start - region.end)
102
- };
103
- return {
104
- ids,
105
- complete: false,
106
- from: flank,
107
- to: after ? steps.length : -1,
108
- stop
109
- };
110
- }
111
- function filterSamples(rows, samples) {
112
- return samples ? rows.filter((r) => samples.includes(r.sample)).sort(
113
- (a, b) => samples.indexOf(a.sample) - samples.indexOf(b.sample) || a.label.localeCompare(b.label)
114
- ) : rows;
115
- }
116
- function walkRows(graph, region, unit) {
117
- const paths = graph.paths ?? [];
118
- const isReference = (p) => pathOrigin(p.name).name === graph.referencePath;
119
- const referencePieces = paths.some(isReference) ? paths.filter(isReference).sort((a, b) => (a.start ?? 0) - (b.start ?? 0)) : paths.slice(0, 1);
120
- const first = referencePieces[0];
121
- const others = paths.filter((p) => !referencePieces.includes(p));
122
- if (!first || others.length === 0) {
123
- return void 0;
124
- }
125
- const walks = /* @__PURE__ */ new Map();
126
- for (const path of others) {
127
- walks.set(path.name, [...walks.get(path.name) ?? [], path]);
128
- }
129
- const lengthOf = new Map(graph.nodes.map((n) => [n.id, n.length]));
130
- const referenceStart = first.start ?? 0;
131
- const cut = region && region.end > region.start ? region : void 0;
132
- const span = /* @__PURE__ */ new Map();
133
- for (const piece of referencePieces) {
134
- let pos = piece.start ?? 0;
135
- for (const id of piece.nodeIds) {
136
- const len = lengthOf.get(id) ?? 0;
137
- if (!span.has(id)) {
138
- span.set(id, { start: pos, end: pos + len });
139
- }
140
- pos += len;
141
- }
142
- }
143
- const flanked = cut === void 0 || [...span.values()].some((s) => s.end <= cut.start) && [...span.values()].some((s) => s.start >= cut.end);
144
- const rowOf = (pieces) => {
145
- const path = pieces[0];
146
- const ordered = [...pieces].sort((a, b) => (a.start ?? 0) - (b.start ?? 0));
147
- const { ids, complete, from, to, stop } = sliceBetween(
148
- stepsOf(ordered, lengthOf),
149
- span,
150
- cut,
151
- flanked
152
- );
153
- const spans = stepSpans(ordered, lengthOf);
154
- const contig = path.contig ?? panSNContig(pathOrigin(path.name).name);
155
- const axis = !spans?.length ? void 0 : from < 0 ? { contig, start: spans[0].start, reversed: false } : from < to ? { contig, start: spans[from].end, reversed: false } : { contig, start: spans[from].start, reversed: true };
156
- const runs = [];
157
- let bp = 0;
158
- let offReferenceBp = 0;
159
- let gapBp = 0;
160
- let step = 0;
161
- for (const id of ids) {
162
- if (typeof id === "number") {
163
- runs.push({ start: bp, bp: id, onReference: false, gap: true });
164
- bp += id;
165
- gapBp += id;
166
- step = 0;
167
- continue;
168
- }
169
- const len = lengthOf.get(id) ?? 0;
170
- const s = span.get(id);
171
- const last = runs.at(-1);
172
- const at = last?.referenceStart;
173
- const forward = s && at !== void 0 && step >= 0 && at + last.bp === s.start;
174
- const backward = s && at !== void 0 && step <= 0 && s.end === at;
175
- if (!s && last && !last.onReference && !last.gap) {
176
- last.bp += len;
177
- } else if (forward || backward) {
178
- last.bp += len;
179
- if (!forward) {
180
- last.referenceStart = s.start;
181
- last.reversed = true;
182
- }
183
- step = forward ? 1 : -1;
184
- } else {
185
- runs.push({
186
- start: bp,
187
- bp: len,
188
- onReference: s !== void 0,
189
- referenceStart: s?.start
190
- });
191
- step = 0;
192
- }
193
- bp += len;
194
- if (!s) {
195
- offReferenceBp += len;
196
- }
197
- }
198
- return {
199
- name: path.name,
200
- label: labelOf(path),
201
- sample: sampleOf(path),
202
- haplotype: path.haplotype,
203
- bp,
204
- offReferenceBp,
205
- gapBp,
206
- complete,
207
- stop,
208
- runs,
209
- axis
210
- };
211
- };
212
- const origin = cut ? cut.start : referenceStart;
213
- return {
214
- origin,
215
- unit,
216
- reference: rowOf(referencePieces),
217
- rows: [...walks.values()].map(rowOf).sort(
218
- (a, b) => Number(b.complete) - Number(a.complete) || b.bp - a.bp || a.label.localeCompare(b.label)
219
- )
220
- };
221
- }
222
-
223
- export {
224
- filterSamples,
225
- walkRows
226
- };