@jbrowse/bandage-core 10.2.7 → 10.3.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 (190) hide show
  1. package/dist/alleleProjection/projectAlleles.js +8 -4
  2. package/dist/anchoredNodes.js +2 -1
  3. package/dist/bubbleSpreads.js +2 -2
  4. package/dist/bubbles/bubbleHalos.js +10 -11
  5. package/dist/bubbles/bubblesFromGraph.js +8 -3
  6. package/dist/bubbles/classifyBubble.js +9 -6
  7. package/dist/bubbles/popBubble.js +7 -5
  8. package/dist/bubbles/superbubbles.js +18 -14
  9. package/dist/chunks/{chunk-RAKOB6IV.js → chunk-234NFZS4.js} +8 -6
  10. package/dist/chunks/{chunk-A4PFFC4Q.js → chunk-2XEQR54X.js} +60 -102
  11. package/dist/chunks/{chunk-6JEWNXCQ.js → chunk-34BOZKIE.js} +0 -2
  12. package/dist/chunks/{chunk-RVS2QCOX.js → chunk-3GLG3ZLE.js} +2 -11
  13. package/dist/chunks/{chunk-PUG7LXDF.js → chunk-3PZSBNLI.js} +4 -1
  14. package/dist/chunks/{chunk-KBEP7VYK.js → chunk-3VCKBSML.js} +4 -4
  15. package/dist/chunks/{chunk-BPLIXMH7.js → chunk-4XWZNPQ2.js} +14 -0
  16. package/dist/chunks/{chunk-LKW2TP4N.js → chunk-5YILQTHE.js} +18 -16
  17. package/dist/chunks/{chunk-B6IW3IRE.js → chunk-65ILXEIN.js} +14 -15
  18. package/dist/chunks/{chunk-4DRQTBBE.js → chunk-6EOB6ANX.js} +1 -1
  19. package/dist/chunks/{chunk-QBHPHLAQ.js → chunk-7JGLJK44.js} +41 -36
  20. package/dist/chunks/{chunk-T2PCSAFY.js → chunk-7XR26JST.js} +2 -2
  21. package/dist/chunks/{chunk-URZ3CH2R.js → chunk-A4JDEUAI.js} +1 -1
  22. package/dist/chunks/{chunk-JLSJMCDJ.js → chunk-A54O52XZ.js} +3 -3
  23. package/dist/chunks/chunk-A55OZVYX.js +327 -0
  24. package/dist/chunks/{chunk-CWFNEKST.js → chunk-A7H753BA.js} +3 -3
  25. package/dist/chunks/{chunk-VV6KGJ7M.js → chunk-AMX4OQAW.js} +18 -27
  26. package/dist/chunks/{chunk-RPRHR56C.js → chunk-BS6HPYCZ.js} +3 -3
  27. package/dist/chunks/chunk-BSOZW3FC.js +30 -0
  28. package/dist/chunks/{chunk-CU6P5RUG.js → chunk-BVYR7IFN.js} +22 -16
  29. package/dist/chunks/{chunk-XXT2JCAC.js → chunk-BX4AUMZE.js} +11 -13
  30. package/dist/chunks/{chunk-N73TI3VG.js → chunk-BZFOFC4D.js} +6 -9
  31. package/dist/chunks/{chunk-4ETPXDO6.js → chunk-CGFPFBT2.js} +1 -1
  32. package/dist/chunks/{chunk-24WITXQY.js → chunk-CGMSKIEO.js} +9 -25
  33. package/dist/chunks/{chunk-IGVV37VI.js → chunk-CKUVEHSS.js} +3 -3
  34. package/dist/chunks/{chunk-JBCZIBFC.js → chunk-CRCD3ODN.js} +0 -1
  35. package/dist/chunks/{chunk-OIV2GBAJ.js → chunk-DBLV7PGG.js} +27 -17
  36. package/dist/chunks/{chunk-JA2HJIYS.js → chunk-E4ZM4OOJ.js} +3 -5
  37. package/dist/chunks/{chunk-ABUIN5AK.js → chunk-EHXBZ5JZ.js} +29 -24
  38. package/dist/chunks/{chunk-QLWI2PZ3.js → chunk-EJRJAAN7.js} +24 -21
  39. package/dist/chunks/{chunk-Q7LYHGGQ.js → chunk-GIHTHYXY.js} +5 -4
  40. package/dist/chunks/{chunk-L3O7AWLI.js → chunk-GJLZ2MKE.js} +2 -2
  41. package/dist/chunks/{chunk-LOEA5IHZ.js → chunk-GJU6BJJA.js} +8 -8
  42. package/dist/chunks/{chunk-XL472HHD.js → chunk-GQZVR5DW.js} +12 -7
  43. package/dist/chunks/{chunk-UVBGRJQX.js → chunk-HKYXWZQS.js} +1 -1
  44. package/dist/chunks/chunk-HMXCN6PG.js +17 -0
  45. package/dist/chunks/{chunk-WSIFAZU7.js → chunk-HNWJ4B7S.js} +12 -13
  46. package/dist/chunks/chunk-HOAIOEI7.js +18 -0
  47. package/dist/chunks/{chunk-XMW266WS.js → chunk-HSVFCA2J.js} +18 -20
  48. package/dist/chunks/{chunk-3XSM4OZU.js → chunk-IYALCKNB.js} +5 -5
  49. package/dist/chunks/{chunk-QXUEF3AJ.js → chunk-KWHWNOTY.js} +22 -17
  50. package/dist/chunks/{chunk-M6LK4GII.js → chunk-LGJBB5BP.js} +8 -9
  51. package/dist/chunks/{chunk-VQWHMWLF.js → chunk-M5NPD55W.js} +18 -14
  52. package/dist/chunks/{chunk-TKIJ5535.js → chunk-MD5VPXXT.js} +6 -6
  53. package/dist/chunks/{chunk-HK5Y2YWV.js → chunk-MYDHU2UV.js} +6 -11
  54. package/dist/chunks/{chunk-TZFWUT2C.js → chunk-MYLAJDKB.js} +2 -2
  55. package/dist/chunks/{chunk-4HWM3FNK.js → chunk-OMUPUB4J.js} +39 -56
  56. package/dist/chunks/{chunk-PTABFYQ7.js → chunk-PFRQBCGC.js} +49 -60
  57. package/dist/chunks/{chunk-T6V4KI2L.js → chunk-PPDE4IVT.js} +1 -1
  58. package/dist/chunks/{chunk-KC7T5RWG.js → chunk-PSCSZSVK.js} +9 -16
  59. package/dist/chunks/{chunk-CG35S2S2.js → chunk-PTQPTDZH.js} +1 -1
  60. package/dist/chunks/{chunk-L2HDM2R3.js → chunk-QQCOVMMT.js} +7 -7
  61. package/dist/chunks/{chunk-CQHUZHET.js → chunk-RFG42VIO.js} +46 -30
  62. package/dist/chunks/{chunk-FYQWPEEY.js → chunk-RJWPJCIB.js} +5 -11
  63. package/dist/chunks/{chunk-AR4BUBMU.js → chunk-RWKP7UO4.js} +34 -35
  64. package/dist/chunks/{chunk-WBSWROE6.js → chunk-SHKGYGM4.js} +14 -18
  65. package/dist/chunks/{chunk-2CMYNW3E.js → chunk-SI3BB4DO.js} +1 -1
  66. package/dist/chunks/{chunk-DY3JCAMX.js → chunk-SOMZGDVS.js} +7 -16
  67. package/dist/chunks/{chunk-EFQLEGWM.js → chunk-SZHQK6GL.js} +7 -8
  68. package/dist/chunks/{chunk-5GMFEPWR.js → chunk-TCOLHD7N.js} +16 -28
  69. package/dist/chunks/{chunk-XV4P5KEQ.js → chunk-TGUFT6KK.js} +6 -3
  70. package/dist/chunks/{chunk-CM6LO6OC.js → chunk-UAFATXYA.js} +10 -14
  71. package/dist/chunks/{chunk-7SRWJLSC.js → chunk-UBQSRCWR.js} +11 -8
  72. package/dist/chunks/{chunk-RUCH6ZFL.js → chunk-V4YML3GR.js} +2 -1
  73. package/dist/chunks/{chunk-VQC7KELB.js → chunk-V7J6U4XC.js} +11 -3
  74. package/dist/chunks/{chunk-ES2N6V56.js → chunk-VX656OAZ.js} +6 -11
  75. package/dist/chunks/chunk-WA5WNP6V.js +37 -0
  76. package/dist/chunks/{chunk-EQ2NIFRH.js → chunk-WJ4TIAVA.js} +1 -1
  77. package/dist/chunks/{chunk-A7CFWFQS.js → chunk-WONB6LMC.js} +1 -1
  78. package/dist/chunks/{chunk-23YFB5BB.js → chunk-XUT4HXVE.js} +29 -13
  79. package/dist/chunks/{chunk-G45YY72K.js → chunk-Z6XZWPXK.js} +17 -25
  80. package/dist/chunks/{chunk-XI3ZUTWF.js → chunk-ZNJ4JAPT.js} +14 -20
  81. package/dist/chunks/{chunk-AUFAPUO4.js → chunk-ZPBEUOBM.js} +3 -1
  82. package/dist/chunks/{chunk-RAEABQNW.js → chunk-ZPZ7GNBT.js} +1 -0
  83. package/dist/cli/figure.js +59 -56
  84. package/dist/cli/fold.js +19 -17
  85. package/dist/deletionEdges.js +5 -7
  86. package/dist/facetGrid.js +2 -1
  87. package/dist/figure.js +45 -42
  88. package/dist/figureData.js +48 -44
  89. package/dist/figureScene.js +34 -29
  90. package/dist/figureSettings.js +19 -17
  91. package/dist/foldVariants.js +5 -3
  92. package/dist/gbzCut.js +12 -7
  93. package/dist/gbzJoin.js +2 -1
  94. package/dist/gbzWindow.js +11 -6
  95. package/dist/genes/genePins.js +6 -4
  96. package/dist/gfa/gfaConverter.js +7 -5
  97. package/dist/gfa/gfaTables.js +2 -1
  98. package/dist/gfa/graphTables.js +3 -3
  99. package/dist/graphLabels.js +8 -5
  100. package/dist/index.js +88 -85
  101. package/dist/labelLayout.js +12 -9
  102. package/dist/layout/anchoredLayout.js +8 -5
  103. package/dist/layout/drawnScale.js +1 -5
  104. package/dist/layout/forceCache.js +19 -17
  105. package/dist/layout/mergeRuns.js +5 -3
  106. package/dist/layout/orderedLayout.js +5 -2
  107. package/dist/layout/orientToReference.js +3 -2
  108. package/dist/layout/placeOffReference.js +7 -4
  109. package/dist/layout/referenceSeeds.js +6 -4
  110. package/dist/layout/sampleRowLayout.js +8 -5
  111. package/dist/layout/trimToWindow.js +6 -4
  112. package/dist/layout/tubeMapLayout.js +17 -19
  113. package/dist/layout/walkRowDraw.js +18 -17
  114. package/dist/layout/walkRowLayout.js +10 -6
  115. package/dist/layout/walkRows.js +9 -5
  116. package/dist/layout/walkStrip.js +21 -18
  117. package/dist/layoutModes.js +23 -20
  118. package/dist/nodeWidths.js +1 -3
  119. package/dist/pansn.js +5 -1
  120. package/dist/pathAnchoring.js +6 -4
  121. package/dist/pathColors.js +12 -9
  122. package/dist/pathVisits.js +3 -1
  123. package/dist/pipeline.js +18 -16
  124. package/dist/reference.js +5 -3
  125. package/dist/referenceRampCss.js +9 -17
  126. package/dist/referenceSpan.js +4 -2
  127. package/dist/referenceStrip.js +18 -14
  128. package/dist/renderer/Canvas2DRenderer.js +1 -1
  129. package/dist/renderer/GeometryBuilder.js +19 -14
  130. package/dist/renderer/svgCanvas.js +1 -1
  131. package/dist/tubeMap/axis.js +11 -6
  132. package/dist/tubeMap/bundle.js +16 -12
  133. package/dist/tubeMap/coarsen.js +20 -345
  134. package/dist/tubeMap/deviations.js +53 -23
  135. package/dist/tubeMap/draw.js +11 -8
  136. package/dist/tubeMap/frame.js +3 -2
  137. package/dist/tubeMap/genes.js +10 -7
  138. package/dist/tubeMap/mismatches.js +1 -1
  139. package/dist/tubeMap/nodeColors.js +18 -14
  140. package/dist/tubeMap/reads.js +1 -1
  141. package/dist/tubeMap/warp.js +2 -1
  142. package/dist/types/alleleProjection/projectAlleles.d.ts +1 -4
  143. package/dist/types/bubbles/bubbleHalos.d.ts +0 -2
  144. package/dist/types/bubbles/bubblesFromGraph.d.ts +6 -4
  145. package/dist/types/bubbles/classifyBubble.d.ts +2 -1
  146. package/dist/types/deletionEdges.d.ts +0 -8
  147. package/dist/types/figureScene.d.ts +17 -7
  148. package/dist/types/figureSettings.d.ts +2 -0
  149. package/dist/types/gbzCut.d.ts +4 -0
  150. package/dist/types/gbzWindow.d.ts +1 -0
  151. package/dist/types/gfa-core/gfaParser.d.ts +1 -1
  152. package/dist/types/graphLabels.d.ts +2 -1
  153. package/dist/types/layout/drawnScale.d.ts +0 -2
  154. package/dist/types/layout/referenceSeeds.d.ts +2 -1
  155. package/dist/types/layout/tubeMapLayout.d.ts +0 -7
  156. package/dist/types/layout/walkRowDraw.d.ts +0 -1
  157. package/dist/types/layout/walkRowLayout.d.ts +1 -0
  158. package/dist/types/layout/walkRows.d.ts +1 -0
  159. package/dist/types/nodeWidths.d.ts +0 -1
  160. package/dist/types/pansn.d.ts +9 -0
  161. package/dist/types/pathVisits.d.ts +6 -0
  162. package/dist/types/referenceRampCss.d.ts +4 -0
  163. package/dist/types/renderer/Canvas2DRenderer.d.ts +1 -0
  164. package/dist/types/renderer/GeometryBuilder.d.ts +3 -2
  165. package/dist/types/tubeMap/axis.d.ts +3 -1
  166. package/dist/types/tubeMap/coarsen.d.ts +3 -1
  167. package/dist/types/tubeMap/deviations.d.ts +2 -1
  168. package/dist/types/tubeMap/mismatches.d.ts +0 -1
  169. package/dist/types/tubeMap/warp.d.ts +2 -1
  170. package/dist/types/util/SpatialIndex.d.ts +1 -1
  171. package/dist/types/util/geometry.d.ts +4 -0
  172. package/dist/types/util/groups.d.ts +3 -0
  173. package/dist/types/util/hitDetection.d.ts +2 -2
  174. package/dist/types/util/partitionPoint.d.ts +1 -0
  175. package/dist/types/util/weakMemo.d.ts +1 -0
  176. package/dist/types/version.d.ts +1 -1
  177. package/dist/util/SpatialIndex.js +8 -5
  178. package/dist/util/edgeCurves.js +7 -4
  179. package/dist/util/geometry.js +3 -1
  180. package/dist/util/groups.js +10 -0
  181. package/dist/util/hitDetection.js +9 -6
  182. package/dist/util/partitionPoint.js +6 -0
  183. package/dist/util/weakMemo.js +6 -0
  184. package/dist/version.js +1 -1
  185. package/dist/viewport.js +19 -17
  186. package/dist/walkEncoding.js +18 -14
  187. package/dist/walkHighlight.js +19 -15
  188. package/dist/walkKey.js +9 -6
  189. package/package.json +2 -2
  190. package/dist/chunks/chunk-ZY2AFL4Y.js +0 -43
@@ -1,10 +1,13 @@
1
1
  import {
2
2
  pathOrigin
3
- } from "./chunk-M6LK4GII.js";
3
+ } from "./chunk-LGJBB5BP.js";
4
+ import {
5
+ groupBy
6
+ } from "./chunk-BSOZW3FC.js";
4
7
  import {
5
8
  panSNContig,
6
9
  panSNSample
7
- } from "./chunk-BPLIXMH7.js";
10
+ } from "./chunk-4XWZNPQ2.js";
8
11
 
9
12
  // src/layout/walkRows.ts
10
13
  function sampleOf(path) {
@@ -150,29 +153,27 @@ function filterSamples(rows, samples) {
150
153
  (a, b) => samples.indexOf(a.sample) - samples.indexOf(b.sample) || a.label.localeCompare(b.label)
151
154
  ) : rows;
152
155
  }
153
- function walkRows(graph, region, unit) {
154
- const paths = graph.paths ?? [];
155
- const nameOf = (p) => pathOrigin(p.name).name;
156
+ function referenceWalkName(graph) {
157
+ const names = (graph.paths ?? []).map((p) => pathOrigin(p.name).name);
158
+ if (graph.referencePath !== void 0 && names.includes(graph.referencePath)) {
159
+ return graph.referencePath;
160
+ }
156
161
  const rankZero = new Set(
157
162
  graph.nodes.flatMap((n) => n.stable?.rank === 0 ? [n.stable.refName] : [])
158
163
  );
159
- const names = paths.map(nameOf);
160
- const referenceName = graph.referencePath !== void 0 && names.includes(graph.referencePath) ? graph.referencePath : names.find((n) => rankZero.has(n)) ?? names[0];
164
+ return names.find((n) => rankZero.has(n)) ?? names[0];
165
+ }
166
+ function walkRows(graph, region, unit) {
167
+ const paths = graph.paths ?? [];
168
+ const nameOf = (p) => pathOrigin(p.name).name;
169
+ const referenceName = referenceWalkName(graph);
161
170
  const referencePieces = paths.filter((p) => nameOf(p) === referenceName).sort((a, b) => (a.start ?? 0) - (b.start ?? 0));
162
171
  const first = referencePieces[0];
163
172
  const others = paths.filter((p) => !referencePieces.includes(p));
164
173
  if (!first || others.length === 0) {
165
174
  return void 0;
166
175
  }
167
- const walks = /* @__PURE__ */ new Map();
168
- for (const path of others) {
169
- const pieces = walks.get(path.name);
170
- if (pieces) {
171
- pieces.push(path);
172
- } else {
173
- walks.set(path.name, [path]);
174
- }
175
- }
176
+ const walks = groupBy(others, nameOf);
176
177
  const table = new NodeTable(graph);
177
178
  const referenceStart = first.start ?? 0;
178
179
  const cut = region && region.end > region.start ? region : void 0;
@@ -285,5 +286,6 @@ function walkRows(graph, region, unit) {
285
286
 
286
287
  export {
287
288
  filterSamples,
289
+ referenceWalkName,
288
290
  walkRows
289
291
  };
@@ -1,15 +1,21 @@
1
1
  import {
2
2
  tubeMapMismatches
3
- } from "./chunk-XXT2JCAC.js";
3
+ } from "./chunk-BX4AUMZE.js";
4
4
  import {
5
5
  MAX_GAP_PX
6
- } from "./chunk-HK5Y2YWV.js";
6
+ } from "./chunk-MYDHU2UV.js";
7
7
  import {
8
8
  readColor
9
- } from "./chunk-CWFNEKST.js";
9
+ } from "./chunk-A7H753BA.js";
10
+ import {
11
+ referenceWalkName
12
+ } from "./chunk-5YILQTHE.js";
10
13
  import {
11
14
  pathOrigin
12
- } from "./chunk-M6LK4GII.js";
15
+ } from "./chunk-LGJBB5BP.js";
16
+ import {
17
+ pushTo
18
+ } from "./chunk-BSOZW3FC.js";
13
19
 
14
20
  // src/tubeMap/draw.ts
15
21
  import { curvePaths, flattenPath, nodeOutlinePath } from "@jbrowse/tubemap-core";
@@ -102,8 +108,9 @@ function layerOf(layout, type, colors, referenceIds, gapWidth) {
102
108
  }
103
109
  function referenceTrackIds(graph) {
104
110
  const ids = /* @__PURE__ */ new Set();
111
+ const name = graph && referenceWalkName(graph);
105
112
  graph?.paths?.forEach((path, i) => {
106
- if (pathOrigin(path.name).name === graph.referencePath) {
113
+ if (pathOrigin(path.name).name === name) {
107
114
  ids.add(i);
108
115
  }
109
116
  });
@@ -132,9 +139,7 @@ function tubeMapPicture({
132
139
  layerOf(layout, "read", colors, referenceIds, gapWidth)
133
140
  ],
134
141
  nodes,
135
- mismatches: tubeMapMismatches(layout).filter(
136
- (m) => m.kind !== "insertion" || !m.softClip
137
- )
142
+ mismatches: tubeMapMismatches(layout)
138
143
  };
139
144
  }
140
145
  function trace(ctx, commands, x, y) {
@@ -180,13 +185,7 @@ function fillByColor(ctx, items, visible, colorOf, addTo) {
180
185
  const byColor = /* @__PURE__ */ new Map();
181
186
  for (const item of items) {
182
187
  if (visible(item)) {
183
- const color = colorOf(item);
184
- const list = byColor.get(color);
185
- if (list) {
186
- list.push(item);
187
- } else {
188
- byColor.set(color, [item]);
189
- }
188
+ pushTo(byColor, colorOf(item), item);
190
189
  }
191
190
  }
192
191
  for (const list of byColor.values()) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  tubeSpan
3
- } from "./chunk-XMW266WS.js";
3
+ } from "./chunk-HSVFCA2J.js";
4
4
 
5
5
  // src/tubeMap/genes.ts
6
6
  function tubeMapGenes(byRefName, genes) {
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  svgCanvas
3
- } from "./chunk-RUCH6ZFL.js";
3
+ } from "./chunk-V4YML3GR.js";
4
4
  import {
5
5
  stripGeneGaps,
6
6
  walkStripFrame,
7
7
  walkStripLabelsTree
8
- } from "./chunk-WBSWROE6.js";
8
+ } from "./chunk-SHKGYGM4.js";
9
9
  import {
10
10
  walkRowsKey,
11
11
  walkRowsKeyTree,
12
12
  walkRowsTree
13
- } from "./chunk-EFQLEGWM.js";
13
+ } from "./chunk-SZHQK6GL.js";
14
14
  import {
15
15
  Canvas2DRenderer
16
- } from "./chunk-QLWI2PZ3.js";
16
+ } from "./chunk-EJRJAAN7.js";
17
17
  import {
18
18
  EXON_COLOR,
19
19
  exonOutlineTree,
@@ -21,43 +21,45 @@ import {
21
21
  } from "./chunk-JSUCGZ6K.js";
22
22
  import {
23
23
  genePins
24
- } from "./chunk-RPRHR56C.js";
24
+ } from "./chunk-BS6HPYCZ.js";
25
25
  import {
26
26
  geneLabelCandidates
27
- } from "./chunk-KC7T5RWG.js";
27
+ } from "./chunk-PSCSZSVK.js";
28
28
  import {
29
29
  nodesUnderBox
30
- } from "./chunk-4HWM3FNK.js";
30
+ } from "./chunk-OMUPUB4J.js";
31
31
  import {
32
32
  escapeAttr,
33
33
  serializeEl
34
34
  } from "./chunk-H2H4Y3TV.js";
35
35
  import {
36
36
  version
37
- } from "./chunk-CG35S2S2.js";
37
+ } from "./chunk-PTQPTDZH.js";
38
38
  import {
39
39
  axisScaleOf
40
- } from "./chunk-A7CFWFQS.js";
41
- import {
42
- rangeText,
43
- walkKey
44
- } from "./chunk-4ETPXDO6.js";
40
+ } from "./chunk-WONB6LMC.js";
45
41
  import {
46
42
  figureScene
47
- } from "./chunk-23YFB5BB.js";
43
+ } from "./chunk-XUT4HXVE.js";
48
44
  import {
49
45
  encodingStops
50
- } from "./chunk-VQC7KELB.js";
46
+ } from "./chunk-V7J6U4XC.js";
47
+ import {
48
+ rangeText
49
+ } from "./chunk-CGFPFBT2.js";
51
50
  import {
52
51
  walkRowLabels
53
- } from "./chunk-L2HDM2R3.js";
52
+ } from "./chunk-QQCOVMMT.js";
54
53
  import {
55
54
  nodeInk
56
- } from "./chunk-JBCZIBFC.js";
55
+ } from "./chunk-CRCD3ODN.js";
56
+ import {
57
+ FIGURE_DEFAULTS
58
+ } from "./chunk-ZPBEUOBM.js";
57
59
  import {
58
60
  FIT_PADDING,
59
61
  fitTransform
60
- } from "./chunk-QXUEF3AJ.js";
62
+ } from "./chunk-KWHWNOTY.js";
61
63
  import {
62
64
  LABEL_CHAR_PX,
63
65
  LABEL_PAD,
@@ -69,9 +71,8 @@ import {
69
71
  FACET_GAP_PX,
70
72
  FACET_PAD_PX,
71
73
  FACET_TITLE_PX,
72
- facetCells,
73
74
  facetGrid
74
- } from "./chunk-XV4P5KEQ.js";
75
+ } from "./chunk-TGUFT6KK.js";
75
76
 
76
77
  // src/figure.ts
77
78
  var FONT = 'font-family="Helvetica, Arial, sans-serif" font-size="11"';
@@ -100,15 +101,14 @@ function exonKeySvg(x, y) {
100
101
  markup: `<g transform="translate(${x} ${y})" ${FONT}><rect x="1" y="4" width="${SWATCH_PX - 2}" height="10" rx="4" fill="none" stroke="${EXON_COLOR}" stroke-width="2"/><text x="${SWATCH_PX + 5}" y="13">exon</text></g>`
101
102
  };
102
103
  }
103
- function walkKeySvg(id, x, y, walk, label, reference) {
104
- const key = walkKey(walk, reference);
104
+ function walkKeySvg(id, x, y, walk, label, key) {
105
105
  return keySvg(
106
106
  id,
107
107
  x,
108
108
  y,
109
109
  encodingStops(walk.encoding),
110
110
  label,
111
- key.delta + key.outside + key.reversed,
111
+ key.note,
112
112
  key.scale
113
113
  );
114
114
  }
@@ -122,8 +122,8 @@ function chip(x, y, w, name, note) {
122
122
  return `<rect x="${x - w / 2}" y="${y - LABEL_PX - LABEL_PAD + 2}" width="${w}" height="${LABEL_PX + LABEL_PAD * 2 - 2}" rx="3" fill="#fff" fill-opacity="0.85" stroke="${EXON_COLOR}"/><text x="${x}" y="${y}" font-family="Helvetica, Arial, sans-serif" font-size="${LABEL_PX}" fill="${GENE_INK}" text-anchor="middle"><tspan font-style="italic" font-weight="600">${escapeAttr(name)}</tspan>${note ? escapeAttr(note) : ""}</text>`;
123
123
  }
124
124
  function figureSvg(graph, layout, o = {}) {
125
- const width = o.width ?? 1200;
126
- const room = o.height ?? 800;
125
+ const width = o.width ?? FIGURE_DEFAULTS.width;
126
+ const room = o.height ?? FIGURE_DEFAULTS.height;
127
127
  const rows = o.walkRows;
128
128
  const {
129
129
  bounds,
@@ -132,10 +132,10 @@ function figureSvg(graph, layout, o = {}) {
132
132
  layers,
133
133
  lift,
134
134
  facet,
135
- panels,
135
+ facets,
136
136
  labelOf,
137
137
  referenceName,
138
- reference,
138
+ keyText,
139
139
  contigThickness,
140
140
  nodeWidth,
141
141
  geometry
@@ -209,7 +209,7 @@ function figureSvg(graph, layout, o = {}) {
209
209
  w,
210
210
  h,
211
211
  pixelRows,
212
- panels ? {
212
+ facets ? {
213
213
  padLeft: FACET_PAD_PX,
214
214
  padTop: FACET_PAD_PX,
215
215
  padRight: FACET_PAD_PX,
@@ -235,12 +235,8 @@ function figureSvg(graph, layout, o = {}) {
235
235
  }
236
236
  const parts = [];
237
237
  let height;
238
- if (panels) {
239
- const place = facetCells(
240
- panels.map((p) => p.walks[0].name),
241
- facet.field || "walk",
242
- facet.domain
243
- );
238
+ if (facets) {
239
+ const { panels, place } = facets;
244
240
  const grid = facetGrid({
245
241
  count: place.count,
246
242
  bounds,
@@ -255,7 +251,14 @@ function figureSvg(graph, layout, o = {}) {
255
251
  const y = Math.floor(cell / grid.columns) * (grid.height + FACET_TITLE_PX + FACET_GAP_PX);
256
252
  const walk = panel.walks[0];
257
253
  parts.push(
258
- walkKeySvg(`key${i}`, x + 6, y + 2, walk, labelOf(walk.name), reference).markup,
254
+ walkKeySvg(
255
+ `key${i}`,
256
+ x + 6,
257
+ y + 2,
258
+ walk,
259
+ labelOf(walk.name),
260
+ keyText(walk)
261
+ ).markup,
259
262
  `<svg x="${x}" y="${y + FACET_TITLE_PX}" width="${grid.width}" height="${grid.height}">${drawing(panel, grid.width, grid.height)}</svg>`
260
263
  );
261
264
  });
@@ -268,7 +271,9 @@ function figureSvg(graph, layout, o = {}) {
268
271
  };
269
272
  if (lift) {
270
273
  lift.walks.forEach((walk, i) => {
271
- push(walkKeySvg(`key${i}`, x, 2, walk, labelOf(walk.name), reference));
274
+ push(
275
+ walkKeySvg(`key${i}`, x, 2, walk, labelOf(walk.name), keyText(walk))
276
+ );
272
277
  });
273
278
  push(
274
279
  keySvg(
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  computeColorSchemeRange,
3
3
  getNodeColor
4
- } from "./chunk-A4PFFC4Q.js";
4
+ } from "./chunk-2XEQR54X.js";
5
5
  import {
6
6
  abgrToCssRgba
7
7
  } from "./chunk-G2FD7S3C.js";
@@ -11,7 +11,7 @@ function tubeMapNodeColors(graph, colorScheme, referenceRamp) {
11
11
  if (colorScheme === "uniform" || colorScheme === "grey") {
12
12
  return void 0;
13
13
  }
14
- const range = { ...computeColorSchemeRange(graph), referenceRamp };
14
+ const range = computeColorSchemeRange(graph, referenceRamp);
15
15
  return new Map(
16
16
  graph.nodes.map((node, index) => [
17
17
  node.id,
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-FX4RDMDN.js";
4
4
  import {
5
5
  formatBp
6
- } from "./chunk-PTABFYQ7.js";
6
+ } from "./chunk-PFRQBCGC.js";
7
7
 
8
8
  // src/bubbles/classifyBubble.ts
9
9
  var REPEAT_GROWTH = 10;
@@ -2,13 +2,13 @@ import {
2
2
  LIFT_BACKDROP_CSS,
3
3
  computeColorSchemeRange,
4
4
  getNodeColor
5
- } from "./chunk-A4PFFC4Q.js";
5
+ } from "./chunk-2XEQR54X.js";
6
6
  import {
7
7
  abgrToCssRgba
8
8
  } from "./chunk-G2FD7S3C.js";
9
9
  import {
10
10
  isBackbone
11
- } from "./chunk-FYQWPEEY.js";
11
+ } from "./chunk-RJWPJCIB.js";
12
12
 
13
13
  // src/referenceStrip.ts
14
14
  var REFERENCE_STRIP_PX = 12;
@@ -21,7 +21,7 @@ function referenceStripBlocks(graph, {
21
21
  referenceRamp,
22
22
  walks
23
23
  }) {
24
- const range = { ...computeColorSchemeRange(graph), referenceRamp };
24
+ const range = computeColorSchemeRange(graph, referenceRamp);
25
25
  const out = [];
26
26
  graph.nodes.forEach((node, index) => {
27
27
  if (isBackbone(node)) {
@@ -0,0 +1,327 @@
1
+ import {
2
+ pathSteps
3
+ } from "./chunk-ZNJ4JAPT.js";
4
+ import {
5
+ pathOrigin
6
+ } from "./chunk-LGJBB5BP.js";
7
+ import {
8
+ PathVisitsBuilder
9
+ } from "./chunk-ZPZ7GNBT.js";
10
+ import {
11
+ isBackbone
12
+ } from "./chunk-RJWPJCIB.js";
13
+ import {
14
+ partitionPoint
15
+ } from "./chunk-HOAIOEI7.js";
16
+
17
+ // src/tubeMap/coarsen.ts
18
+ function readWalk(path, steps) {
19
+ const runs = [];
20
+ const open = () => ({ a: -Infinity, b: Infinity, detour: [], bp: 0 });
21
+ const gaps = [open()];
22
+ for (const { node, strand } of steps) {
23
+ const gap = gaps.at(-1);
24
+ const last = runs.at(-1);
25
+ if (isBackbone(node)) {
26
+ const start = node.stable.start;
27
+ const end = start + node.length;
28
+ const inverted = strand !== (node.stable.strand ?? "+");
29
+ const joins = last !== void 0 && gap.detour.length === 0;
30
+ if (joins && !last.inverted && !inverted && last.end === start) {
31
+ last.end = end;
32
+ } else if (joins && last.inverted && inverted && last.start === end) {
33
+ last.start = start;
34
+ } else {
35
+ runs.push({ start, end, inverted });
36
+ gaps.push(open());
37
+ }
38
+ } else {
39
+ gap.detour.push({ node, strand });
40
+ gap.bp += node.length;
41
+ }
42
+ }
43
+ runs.forEach((run, i) => {
44
+ gaps[i].b = run.start;
45
+ gaps[i + 1].a = run.end;
46
+ });
47
+ return { path, runs, gaps };
48
+ }
49
+ function isSmall(gap, sigma) {
50
+ return Number.isFinite(gap.a) && Number.isFinite(gap.b) && gap.b >= gap.a && Math.max(gap.b - gap.a, gap.bp) < sigma;
51
+ }
52
+ function strictlyInside(cuts, a, b) {
53
+ const i = partitionPoint(cuts.length, (j) => cuts[j] <= a);
54
+ return i < cuts.length && cuts[i] < b;
55
+ }
56
+ function referenceGaps(backbone) {
57
+ const cuts = /* @__PURE__ */ new Map();
58
+ for (let i = 1; i < backbone.length; i++) {
59
+ const prev = backbone[i - 1];
60
+ const node = backbone[i];
61
+ const end = prev.stable.start + prev.length;
62
+ if (end !== node.stable.start) {
63
+ cuts.set(end, "reference-gap");
64
+ cuts.set(node.stable.start, "reference-gap");
65
+ }
66
+ }
67
+ return cuts;
68
+ }
69
+ function findCuts(walks, sigma, cuts) {
70
+ const cut = (bp, cause) => {
71
+ if (Number.isFinite(bp) && !cuts.has(bp)) {
72
+ cuts.set(bp, cause);
73
+ }
74
+ };
75
+ for (const { runs, gaps } of walks) {
76
+ const first = runs[0];
77
+ const last = runs.at(-1);
78
+ if (first && last) {
79
+ cut(first.start, "walk-end");
80
+ cut(last.end, "walk-end");
81
+ }
82
+ for (const run of runs) {
83
+ if (run.inverted && run.end - run.start >= sigma) {
84
+ cut(run.start, "inversion");
85
+ cut(run.end, "inversion");
86
+ }
87
+ }
88
+ for (const gap of gaps) {
89
+ if (gap.b < gap.a) {
90
+ cut(gap.a, "backward");
91
+ cut(gap.b, "backward");
92
+ } else if (!isSmall(gap, sigma)) {
93
+ cut(gap.a, "variant");
94
+ cut(gap.b, "variant");
95
+ }
96
+ }
97
+ }
98
+ const spans = walks.flatMap(({ runs, gaps }) => [
99
+ ...gaps.filter((g) => isSmall(g, sigma)).map((g) => [g.a, g.b]),
100
+ ...runs.filter((r) => r.inverted && r.end - r.start < sigma).map((r) => [r.start, r.end])
101
+ ]);
102
+ for (let changed = true; changed; ) {
103
+ changed = false;
104
+ const sorted = [...cuts.keys()].sort((x, y) => x - y);
105
+ for (const [a, b] of spans) {
106
+ if (strictlyInside(sorted, a, b)) {
107
+ changed ||= !cuts.has(a) || !cuts.has(b);
108
+ cut(a, "overlap");
109
+ cut(b, "overlap");
110
+ }
111
+ }
112
+ }
113
+ return cuts;
114
+ }
115
+ function mergeReference(backbone, cuts) {
116
+ const merged = [];
117
+ let group = [];
118
+ const close = () => {
119
+ const first = group[0];
120
+ const last = group.at(-1);
121
+ if (first && last) {
122
+ const bp0 = first.stable.start;
123
+ const bp1 = last.stable.start + last.length;
124
+ const name = `${bp0}-${bp1}`;
125
+ merged.push({
126
+ node: {
127
+ id: `${name}+`,
128
+ name,
129
+ length: bp1 - bp0,
130
+ depth: 0,
131
+ stable: {
132
+ refName: first.stable.refName,
133
+ start: bp0,
134
+ rank: 0,
135
+ strand: "+"
136
+ }
137
+ },
138
+ members: group
139
+ });
140
+ }
141
+ group = [];
142
+ };
143
+ for (const node of backbone) {
144
+ if (cuts.has(node.stable.start)) {
145
+ close();
146
+ }
147
+ group.push(node);
148
+ }
149
+ close();
150
+ return merged;
151
+ }
152
+ function lastAtMost(items, key, x) {
153
+ return Math.max(0, partitionPoint(items.length, (i) => key(items[i]) <= x) - 1);
154
+ }
155
+ function coarsenTubeMap(graph, sigma) {
156
+ const backbone = graph.nodes.filter(isBackbone).sort((a, b) => a.stable.start - b.stable.start);
157
+ const paths = graph.paths ?? [];
158
+ if (backbone.length === 0 || paths.length === 0) {
159
+ return void 0;
160
+ }
161
+ const stepsOf = pathSteps(graph);
162
+ const walks = paths.map((p, i) => readWalk(p, stepsOf[i]));
163
+ const cuts = findCuts(walks, sigma, referenceGaps(backbone));
164
+ const sortedCuts = [...cuts.keys()].sort((x, y) => x - y);
165
+ const merged = mergeReference(backbone, cuts);
166
+ const mergedAt = (bp) => lastAtMost(merged, (m) => m.node.stable.start, bp);
167
+ const members = /* @__PURE__ */ new Map();
168
+ const coarseOf = /* @__PURE__ */ new Map();
169
+ for (const m of merged) {
170
+ members.set(
171
+ m.node.id,
172
+ m.members.map((n) => n.id)
173
+ );
174
+ for (const n of m.members) {
175
+ coarseOf.set(n.id, m.node.id);
176
+ }
177
+ }
178
+ const routes = /* @__PURE__ */ new Map();
179
+ const routeFor = (gap) => {
180
+ const key = `${gap.a} ${gap.b} ${gap.detour.map((s) => s.node.id + s.strand).join(",")}`;
181
+ let node = routes.get(key);
182
+ if (!node) {
183
+ const name = `r${routes.size}`;
184
+ node = {
185
+ id: `${name}+`,
186
+ name,
187
+ length: gap.bp,
188
+ depth: 0,
189
+ stable: {
190
+ refName: backbone[0].stable.refName,
191
+ start: Number.isFinite(gap.a) ? gap.a : gap.b,
192
+ rank: 1,
193
+ strand: "+"
194
+ }
195
+ };
196
+ routes.set(key, node);
197
+ members.set(
198
+ node.id,
199
+ gap.detour.map((s) => s.node.id)
200
+ );
201
+ for (const s of gap.detour) {
202
+ if (!coarseOf.has(s.node.id)) {
203
+ coarseOf.set(s.node.id, node.id);
204
+ }
205
+ }
206
+ }
207
+ return node;
208
+ };
209
+ const deviations = /* @__PURE__ */ new Map();
210
+ const coarsePaths = [];
211
+ const pathVisits = new PathVisitsBuilder();
212
+ const edges = /* @__PURE__ */ new Map();
213
+ const depth = /* @__PURE__ */ new Map();
214
+ for (const { path, runs, gaps } of walks) {
215
+ const steps = [];
216
+ const devs = [];
217
+ let continuing = false;
218
+ const append = (node, strand) => {
219
+ const last = steps.at(-1);
220
+ if (!(continuing && last?.node === node && last.strand === strand)) {
221
+ steps.push({ node, strand });
222
+ }
223
+ continuing = true;
224
+ };
225
+ const structural = (gap) => {
226
+ continuing = false;
227
+ if (gap.detour.length > 0) {
228
+ append(routeFor(gap), "+");
229
+ continuing = false;
230
+ }
231
+ };
232
+ const fold = (gap) => {
233
+ if (gap.bp > 0 || gap.b > gap.a) {
234
+ devs.push({ start: gap.a, end: gap.b, bp: gap.bp });
235
+ }
236
+ const home = merged[mergedAt(gap.b > gap.a ? gap.a : gap.a - 1)];
237
+ for (const s of gap.detour) {
238
+ if (!coarseOf.has(s.node.id)) {
239
+ coarseOf.set(s.node.id, home.node.id);
240
+ members.get(home.node.id).push(s.node.id);
241
+ }
242
+ }
243
+ };
244
+ runs.forEach((run, i) => {
245
+ const gap = gaps[i];
246
+ if (isSmall(gap, sigma) && !strictlyInside(sortedCuts, gap.a, gap.b)) {
247
+ fold(gap);
248
+ } else {
249
+ structural(gap);
250
+ }
251
+ const i0 = mergedAt(run.start);
252
+ const i1 = mergedAt(run.end - 1);
253
+ const small = run.end - run.start < sigma;
254
+ if (run.inverted && !small) {
255
+ continuing = false;
256
+ for (let j = i1; j >= i0; j--) {
257
+ append(merged[j].node, "-");
258
+ }
259
+ continuing = false;
260
+ } else {
261
+ if (run.inverted) {
262
+ devs.push({
263
+ start: run.start,
264
+ end: run.end,
265
+ bp: run.end - run.start,
266
+ inverted: true
267
+ });
268
+ }
269
+ for (let j = i0; j <= i1; j++) {
270
+ append(merged[j].node, "+");
271
+ }
272
+ }
273
+ });
274
+ structural(gaps.at(-1));
275
+ const visitName = pathOrigin(path.name).name;
276
+ let pos = 0;
277
+ steps.forEach(({ node, strand }, i) => {
278
+ depth.set(node.id, (depth.get(node.id) ?? 0) + 1);
279
+ pathVisits.add(
280
+ node.name,
281
+ visitName,
282
+ path.sample ?? visitName,
283
+ pos,
284
+ strand === "-"
285
+ );
286
+ pos += node.length;
287
+ const next = steps[i + 1];
288
+ if (next) {
289
+ const key = `${node.id}${strand} ${next.node.id}${next.strand}`;
290
+ const edge = edges.get(key);
291
+ if (edge) {
292
+ edge.pathIds.push(path.name);
293
+ } else {
294
+ edges.set(key, {
295
+ from: node.id,
296
+ to: next.node.id,
297
+ fromStrand: strand,
298
+ toStrand: next.strand,
299
+ pathIds: [path.name]
300
+ });
301
+ }
302
+ }
303
+ });
304
+ coarsePaths.push({ ...path, nodeIds: steps.map((s) => s.node.id) });
305
+ deviations.set(path.name, devs);
306
+ }
307
+ const nodes = [...merged.map((m) => m.node), ...routes.values()].filter((n) => depth.has(n.id)).map((n) => ({ ...n, depth: depth.get(n.id) }));
308
+ return {
309
+ graph: {
310
+ ...graph,
311
+ nodes,
312
+ edges: [...edges.values()],
313
+ paths: coarsePaths,
314
+ pathVisits: pathVisits.build(),
315
+ reads: void 0
316
+ },
317
+ members,
318
+ coarseOf,
319
+ deviations,
320
+ cuts
321
+ };
322
+ }
323
+
324
+ export {
325
+ lastAtMost,
326
+ coarsenTubeMap
327
+ };