@jbrowse/bandage-core 8.2.0 → 9.0.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.
Files changed (35) hide show
  1. package/dist/chunks/{chunk-3FXPFVKJ.js → chunk-AMS3MAFP.js} +1 -1
  2. package/dist/chunks/{chunk-DRA7733Q.js → chunk-BPRXQ2SS.js} +8 -3
  3. package/dist/chunks/{chunk-TEDQJPMI.js → chunk-CWFNEKST.js} +22 -7
  4. package/dist/chunks/chunk-INJ2UVOT.js +370 -0
  5. package/dist/chunks/{chunk-KCRL5JB2.js → chunk-LLP3FXPM.js} +31 -10
  6. package/dist/chunks/{chunk-DE4UFDUZ.js → chunk-TLQ7F2ZT.js} +1 -1
  7. package/dist/chunks/{chunk-OWFPAIJI.js → chunk-WEDZ76AK.js} +1 -1
  8. package/dist/chunks/{chunk-CF62U3QS.js → chunk-WNUZP3WQ.js} +2 -2
  9. package/dist/chunks/{chunk-733L2TS6.js → chunk-XXT2JCAC.js} +10 -7
  10. package/dist/chunks/{chunk-GQ2AOHU4.js → chunk-YOYLCLIG.js} +7 -29
  11. package/dist/cli/figure.js +5 -5
  12. package/dist/figure.js +2 -2
  13. package/dist/index.js +15 -13
  14. package/dist/layout/tubeMapLayout.js +12 -6
  15. package/dist/layoutModes.js +3 -3
  16. package/dist/tubeMap/axis.js +1 -1
  17. package/dist/tubeMap/coarsen.js +11 -23
  18. package/dist/tubeMap/connectors.js +1 -4
  19. package/dist/tubeMap/deviations.js +15 -19
  20. package/dist/tubeMap/draw.js +9 -5
  21. package/dist/tubeMap/genes.js +2 -2
  22. package/dist/tubeMap/mismatches.js +1 -1
  23. package/dist/tubeMap/reads.js +1 -1
  24. package/dist/types/index.d.ts +4 -4
  25. package/dist/types/layout/tubeMapLayout.d.ts +15 -2
  26. package/dist/types/layoutModes.d.ts +5 -5
  27. package/dist/types/tubeMap/axis.d.ts +6 -3
  28. package/dist/types/tubeMap/connectors.d.ts +2 -11
  29. package/dist/types/tubeMap/deviations.d.ts +2 -3
  30. package/dist/types/tubeMap/draw.d.ts +4 -1
  31. package/dist/types/tubeMap/mismatches.d.ts +1 -1
  32. package/dist/types/version.d.ts +1 -1
  33. package/dist/version.js +1 -1
  34. package/package.json +1 -1
  35. package/dist/chunks/chunk-W2I4DOL4.js +0 -230
@@ -1,230 +0,0 @@
1
- import {
2
- canonicalStrand,
3
- stepName,
4
- tubeMapReads
5
- } from "./chunk-TEDQJPMI.js";
6
- import {
7
- pathCssColor,
8
- pathGreyCssColor
9
- } from "./chunk-7GBL7SJY.js";
10
- import {
11
- pathOrigin
12
- } from "./chunk-ST2IBUAN.js";
13
- import {
14
- isBackbone
15
- } from "./chunk-FYQWPEEY.js";
16
-
17
- // src/layout/tubeMapLayout.ts
18
- import { layoutTubeMap } from "@jbrowse/tubemap-core";
19
- function visitStrands(graph) {
20
- const strands = /* @__PURE__ */ new Map();
21
- for (const [segment, visits] of graph.pathVisits ?? []) {
22
- for (const visit of visits) {
23
- const key = `${visit.path} ${segment}`;
24
- const list = strands.get(key);
25
- if (list) {
26
- list.push(visit.strand);
27
- } else {
28
- strands.set(key, [visit.strand]);
29
- }
30
- }
31
- }
32
- return strands;
33
- }
34
- function tubeMapTracks(graph) {
35
- const nodeById = new Map(graph.nodes.map((n) => [n.id, n]));
36
- const strands = visitStrands(graph);
37
- const paths = (graph.paths ?? []).map((path, index) => ({ path, index }));
38
- const reference = paths.findIndex(
39
- (p) => pathOrigin(p.path.name).name === graph.referencePath
40
- );
41
- if (reference > 0) {
42
- paths.unshift(...paths.splice(reference, 1));
43
- }
44
- return paths.flatMap(({ path, index }) => {
45
- const visitName = pathOrigin(path.name).name;
46
- const seen = /* @__PURE__ */ new Map();
47
- const sequence = path.nodeIds.flatMap((id) => {
48
- const node = nodeById.get(id);
49
- if (!node) {
50
- return [];
51
- }
52
- const k = seen.get(node.name) ?? 0;
53
- seen.set(node.name, k + 1);
54
- const strand = strands.get(`${visitName} ${node.name}`)?.[k] ?? canonicalStrand(node);
55
- return [stepName(node, strand)];
56
- });
57
- return sequence.length > 0 ? [
58
- {
59
- id: index,
60
- name: path.name,
61
- sequence,
62
- sourceTrackID: 0,
63
- type: "haplotype"
64
- }
65
- ] : [];
66
- });
67
- }
68
- function tubeMapNodes(graph) {
69
- return graph.nodes.map((n) => ({
70
- name: n.id,
71
- seq: "",
72
- sequenceLength: Math.max(1, n.length)
73
- }));
74
- }
75
- function hasTubeMapPaths(graph) {
76
- return (graph.paths?.length ?? 0) > 0;
77
- }
78
- var STACK_PX = 600;
79
- var MIN_TUBE_PX = 3;
80
- var MAX_TUBE_PX = 15;
81
- function tubeWidth(trackCount) {
82
- return Math.max(
83
- MIN_TUBE_PX,
84
- Math.min(MAX_TUBE_PX, Math.floor(STACK_PX / Math.max(1, trackCount)))
85
- );
86
- }
87
- function runTubeMap(graph) {
88
- const paths = graph.paths ?? [];
89
- const tracks = tubeMapTracks(graph);
90
- const reads = graph.reads ? tubeMapReads(graph, graph.reads, paths.length) : [];
91
- const tubeColor = reads.length > 0 ? pathGreyCssColor : pathCssColor;
92
- const pathColors = paths.map((_, i) => tubeColor(i, paths.length));
93
- const layout = layoutTubeMap(tubeMapNodes(graph), tracks, reads, {
94
- nodeWidthOption: "compressed",
95
- trackWidth: tubeWidth(tracks.length)
96
- });
97
- return layout ? { layout, pathColors } : void 0;
98
- }
99
- function drawnNodes(layout) {
100
- const nodes = [];
101
- layout.nodes.forEach((node) => {
102
- if (node.order >= 0) {
103
- nodes.push(node);
104
- }
105
- });
106
- return nodes;
107
- }
108
- function centreline(node, yOffset, x0, x1) {
109
- const y = node.y + node.contentHeight / 2 - yOffset;
110
- return [
111
- { x: x0, y },
112
- { x: x1, y }
113
- ];
114
- }
115
- function extentOf(layout, yOffset) {
116
- return {
117
- minY: layout.bounds.minY - yOffset,
118
- maxY: layout.bounds.maxY - yOffset
119
- };
120
- }
121
- function tubeMapLayout(graph) {
122
- const run = hasTubeMapPaths(graph) ? runTubeMap(graph) : void 0;
123
- if (!run) {
124
- return void 0;
125
- }
126
- const { layout, pathColors } = run;
127
- const yOffset = layout.bounds.minY;
128
- const nodePositions = {};
129
- for (const node of drawnNodes(layout)) {
130
- nodePositions[node.name] = centreline(
131
- node,
132
- yOffset,
133
- node.x,
134
- node.x + node.pixelWidth
135
- );
136
- }
137
- const { minY, maxY } = extentOf(layout, yOffset);
138
- return {
139
- nodePositions,
140
- tubeMap: { layout, yOffset, pathColors },
141
- extent: {
142
- minX: layout.bounds.minX,
143
- maxX: layout.bounds.maxX,
144
- minY,
145
- maxY
146
- }
147
- };
148
- }
149
- function tubeMapColumns(graph, layout) {
150
- const nodeById = new Map(graph.nodes.map((n) => [n.id, n]));
151
- const byOrder = /* @__PURE__ */ new Map();
152
- for (const node of drawnNodes(layout)) {
153
- const list = byOrder.get(node.order);
154
- if (list) {
155
- list.push(node);
156
- } else {
157
- byOrder.set(node.order, [node]);
158
- }
159
- }
160
- const columns = [];
161
- let end = -Infinity;
162
- for (const order of [...byOrder.keys()].sort((a, b) => a - b)) {
163
- const nodes = byOrder.get(order);
164
- let bp0 = Infinity;
165
- let bp1 = -Infinity;
166
- for (const node of nodes) {
167
- const graphNode = nodeById.get(node.name);
168
- if (graphNode && isBackbone(graphNode)) {
169
- bp0 = Math.min(bp0, graphNode.stable.start);
170
- bp1 = Math.max(bp1, graphNode.stable.start + node.sequenceLength);
171
- }
172
- }
173
- if (bp0 === Infinity) {
174
- bp0 = bp1 = end;
175
- }
176
- if (bp0 < end) {
177
- bp0 = end;
178
- bp1 = Math.max(end, bp1);
179
- }
180
- end = Math.max(end, bp1);
181
- columns.push({
182
- order,
183
- x0: Math.min(...nodes.map((n) => n.x)),
184
- x1: Math.max(...nodes.map((n) => n.x + n.pixelWidth)),
185
- bp0,
186
- bp1
187
- });
188
- }
189
- const first = columns.find((c) => c.bp0 !== -Infinity);
190
- for (const column of columns) {
191
- if (column.bp0 === -Infinity) {
192
- column.bp0 = column.bp1 = first?.bp0 ?? 0;
193
- }
194
- }
195
- return columns;
196
- }
197
- function pathsReachBackbone(graph) {
198
- return graph.nodes.some(isBackbone) && hasTubeMapPaths(graph);
199
- }
200
- function tubeMapReferenceLayout(graph) {
201
- const run = pathsReachBackbone(graph) ? runTubeMap(graph) : void 0;
202
- if (!run) {
203
- return void 0;
204
- }
205
- const { layout, pathColors } = run;
206
- const columns = tubeMapColumns(graph, layout);
207
- const byOrder = new Map(columns.map((c) => [c.order, c]));
208
- const yOffset = layout.bounds.minY;
209
- const nodePositions = {};
210
- for (const node of drawnNodes(layout)) {
211
- const column = byOrder.get(node.order);
212
- nodePositions[node.name] = centreline(node, yOffset, column.bp0, column.bp1);
213
- }
214
- return {
215
- nodePositions,
216
- tubeMap: { layout, yOffset, columns, pathColors },
217
- referenceAxis: true,
218
- pixelRows: true,
219
- extent: extentOf(layout, yOffset)
220
- };
221
- }
222
-
223
- export {
224
- visitStrands,
225
- tubeMapTracks,
226
- hasTubeMapPaths,
227
- tubeWidth,
228
- tubeMapLayout,
229
- tubeMapReferenceLayout
230
- };