@jbrowse/bandage-core 7.5.1 → 8.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.
@@ -42,7 +42,7 @@ import {
42
42
  } from "./chunk-RCWYY6XA.js";
43
43
  import {
44
44
  version
45
- } from "./chunk-CNGKWYUC.js";
45
+ } from "./chunk-XMNHWMGM.js";
46
46
  import {
47
47
  axisScaleOf
48
48
  } from "./chunk-4UBWXZVX.js";
@@ -1,5 +1,5 @@
1
1
  // src/tubeMap/mismatches.ts
2
- import { forward, getXCoordinateOfBaseWithinNode } from "@gmod/tubemap-core";
2
+ import { forward, getXCoordinateOfBaseWithinNode } from "@jbrowse/tubemap-core";
3
3
  function readMismatches(read, layout) {
4
4
  const marks = [];
5
5
  const entries = read.sequenceNew ?? [];
@@ -1,9 +1,12 @@
1
1
  import {
2
2
  tubeMapMismatches
3
- } from "./chunk-EJ5OZTCK.js";
3
+ } from "./chunk-733L2TS6.js";
4
+ import {
5
+ readColor
6
+ } from "./chunk-TEDQJPMI.js";
4
7
 
5
8
  // src/tubeMap/draw.ts
6
- import { curvePaths, nodeOutlinePath } from "@gmod/tubemap-core";
9
+ import { curvePaths, nodeOutlinePath } from "@jbrowse/tubemap-core";
7
10
  function parsePath(d) {
8
11
  const tokens = d.trim().split(/[\s,]+/);
9
12
  const commands = [];
@@ -50,29 +53,41 @@ function extentOf(commands) {
50
53
  }
51
54
  return { x0, x1 };
52
55
  }
53
- function shapeOf(d, color, alpha, track) {
56
+ function shapeOf(d, color, track) {
54
57
  const commands = parsePath(d);
55
- return { commands, color, track, alpha, ...extentOf(commands) };
58
+ return { commands, color, track, ...extentOf(commands) };
59
+ }
60
+ function trackColors(layout, pathColors) {
61
+ return new Map(
62
+ layout.tracks.map((track) => [
63
+ track.id,
64
+ track.type === "read" ? readColor(track) : pathColors[track.id]
65
+ ])
66
+ );
56
67
  }
57
- function layerOf(layout, type) {
68
+ function layerOf(layout, type, colors) {
58
69
  const { shapes } = layout;
70
+ const colorOf = (s) => colors.get(s.id);
59
71
  const trackOf = (s) => type === "haplotype" ? s.id : void 0;
60
72
  const rects = [...shapes.rectangles, ...shapes.verticalRectangles].filter((r) => r.type === type).map((r) => ({
61
- color: r.color,
73
+ color: colorOf(r),
62
74
  track: trackOf(r),
63
- alpha: r.alpha ?? 1,
64
75
  x0: r.xStart,
65
76
  x1: r.xEnd + 1,
66
77
  y0: r.yStart,
67
78
  y1: r.yEnd + 1
68
79
  }));
69
80
  const curves = curvePaths(shapes.curves, type).map(
70
- (c) => shapeOf(c.path, c.color, c.alpha ?? 1, trackOf(c))
81
+ (c) => shapeOf(c.path, colorOf(c), trackOf(c))
71
82
  );
72
- const corners = shapes.corners.filter((c) => c.type === type).map((c) => shapeOf(c.path, c.color, 1, trackOf(c)));
83
+ const corners = shapes.corners.filter((c) => c.type === type).map((c) => shapeOf(c.path, colorOf(c), trackOf(c)));
73
84
  return { rects, shapes: [...curves, ...corners] };
74
85
  }
75
- function tubeMapPicture(layout) {
86
+ function tubeMapPicture({
87
+ layout,
88
+ pathColors
89
+ }) {
90
+ const colors = trackColors(layout, pathColors);
76
91
  const nodes = [];
77
92
  layout.nodes.forEach((node) => {
78
93
  if (node.order >= 0) {
@@ -82,7 +97,10 @@ function tubeMapPicture(layout) {
82
97
  });
83
98
  return {
84
99
  bounds: layout.bounds,
85
- layers: [layerOf(layout, "haplotype"), layerOf(layout, "read")],
100
+ layers: [
101
+ layerOf(layout, "haplotype", colors),
102
+ layerOf(layout, "read", colors)
103
+ ],
86
104
  nodes,
87
105
  mismatches: tubeMapMismatches(layout).filter(
88
106
  (m) => m.kind !== "insertion" || !m.softClip
@@ -132,25 +150,23 @@ function fillByColor(ctx, items, visible, colorOf, addTo) {
132
150
  const byColor = /* @__PURE__ */ new Map();
133
151
  for (const item of items) {
134
152
  if (visible(item)) {
135
- const key = `${colorOf(item)}|${item.alpha}`;
136
- const list = byColor.get(key);
153
+ const color = colorOf(item);
154
+ const list = byColor.get(color);
137
155
  if (list) {
138
156
  list.push(item);
139
157
  } else {
140
- byColor.set(key, [item]);
158
+ byColor.set(color, [item]);
141
159
  }
142
160
  }
143
161
  }
144
162
  for (const list of byColor.values()) {
145
163
  ctx.fillStyle = colorOf(list[0]);
146
- ctx.globalAlpha = list[0].alpha;
147
164
  ctx.beginPath();
148
165
  for (const item of list) {
149
166
  addTo(item);
150
167
  }
151
168
  ctx.fill();
152
169
  }
153
- ctx.globalAlpha = 1;
154
170
  }
155
171
  var FULL_OUTLINE_PX = 12;
156
172
  var MIN_OUTLINE_ALPHA = 0.15;
@@ -162,6 +178,7 @@ function drawTubeMap(ctx, picture, frame) {
162
178
  const { x, y, width } = frame;
163
179
  const visible = (item) => x(item.x1) >= 0 && x(item.x0) <= width;
164
180
  const colorOf = (item) => item.track !== void 0 && frame.tubeColors?.[item.track] || item.color;
181
+ ctx.globalAlpha = 1;
165
182
  for (const layer of picture.layers) {
166
183
  fillByColor(ctx, layer.rects, visible, colorOf, (r) => {
167
184
  const left = x(r.x0);
@@ -234,6 +251,7 @@ function drawMismatches(ctx, marks, frame) {
234
251
 
235
252
  export {
236
253
  parsePath,
254
+ trackColors,
237
255
  tubeMapPicture,
238
256
  drawTubeMap,
239
257
  mismatchesLegible,
@@ -1,6 +1,5 @@
1
1
  import {
2
2
  canonicalStrand,
3
- readColor,
4
3
  stepName,
5
4
  tubeMapReads
6
5
  } from "./chunk-TEDQJPMI.js";
@@ -16,7 +15,7 @@ import {
16
15
  } from "./chunk-FYQWPEEY.js";
17
16
 
18
17
  // src/layout/tubeMapLayout.ts
19
- import { layoutTubeMap } from "@gmod/tubemap-core";
18
+ import { layoutTubeMap } from "@jbrowse/tubemap-core";
20
19
  function visitStrands(graph) {
21
20
  const strands = /* @__PURE__ */ new Map();
22
21
  for (const [segment, visits] of graph.pathVisits ?? []) {
@@ -93,8 +92,7 @@ function runTubeMap(graph) {
93
92
  const pathColors = paths.map((_, i) => tubeColor(i, paths.length));
94
93
  const layout = layoutTubeMap(tubeMapNodes(graph), tracks, reads, {
95
94
  nodeWidthOption: "compressed",
96
- trackWidth: tubeWidth(tracks.length),
97
- trackColor: (track) => track.type === "read" ? readColor(track) : pathColors[track.id]
95
+ trackWidth: tubeWidth(tracks.length)
98
96
  });
99
97
  return layout ? { layout, pathColors } : void 0;
100
98
  }
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var version = "7.5.1";
2
+ var version = "8.0.0";
3
3
 
4
4
  export {
5
5
  version
@@ -5,7 +5,7 @@ import {
5
5
  hasTubeMapPaths,
6
6
  tubeMapLayout,
7
7
  tubeMapReferenceLayout
8
- } from "./chunk-AYOSNXLQ.js";
8
+ } from "./chunk-W2I4DOL4.js";
9
9
  import {
10
10
  anchoredLayout
11
11
  } from "./chunk-L3O7AWLI.js";
@@ -7,9 +7,9 @@ import {
7
7
  import {
8
8
  LAYOUT_MODES,
9
9
  layoutModeByValue
10
- } from "../chunks/chunk-FRR2RGBT.js";
10
+ } from "../chunks/chunk-ZJQ6H3AR.js";
11
11
  import "../chunks/chunk-LOEA5IHZ.js";
12
- import "../chunks/chunk-AYOSNXLQ.js";
12
+ import "../chunks/chunk-W2I4DOL4.js";
13
13
  import "../chunks/chunk-TEDQJPMI.js";
14
14
  import "../chunks/chunk-L3O7AWLI.js";
15
15
  import "../chunks/chunk-TZFWUT2C.js";
@@ -35,7 +35,7 @@ import "../chunks/chunk-LYJ4US66.js";
35
35
  import "../chunks/chunk-7XHHVYG7.js";
36
36
  import {
37
37
  figureSvg
38
- } from "../chunks/chunk-7ESIZZO7.js";
38
+ } from "../chunks/chunk-5ARDFGLJ.js";
39
39
  import "../chunks/chunk-LOCJN3BZ.js";
40
40
  import "../chunks/chunk-47DYCZOK.js";
41
41
  import "../chunks/chunk-ZYHSUNQO.js";
@@ -53,7 +53,7 @@ import "../chunks/chunk-2LQ5BWT7.js";
53
53
  import "../chunks/chunk-AVJK272H.js";
54
54
  import "../chunks/chunk-RCWYY6XA.js";
55
55
  import "../chunks/chunk-UMNCCYBN.js";
56
- import "../chunks/chunk-CNGKWYUC.js";
56
+ import "../chunks/chunk-XMNHWMGM.js";
57
57
  import "../chunks/chunk-4UBWXZVX.js";
58
58
  import "../chunks/chunk-MP7LXLWV.js";
59
59
  import {
package/dist/figure.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  figureSvg
3
- } from "./chunks/chunk-7ESIZZO7.js";
3
+ } from "./chunks/chunk-5ARDFGLJ.js";
4
4
  import "./chunks/chunk-LOCJN3BZ.js";
5
5
  import "./chunks/chunk-47DYCZOK.js";
6
6
  import "./chunks/chunk-ZYHSUNQO.js";
@@ -15,7 +15,7 @@ import "./chunks/chunk-2LQ5BWT7.js";
15
15
  import "./chunks/chunk-AVJK272H.js";
16
16
  import "./chunks/chunk-RCWYY6XA.js";
17
17
  import "./chunks/chunk-UMNCCYBN.js";
18
- import "./chunks/chunk-CNGKWYUC.js";
18
+ import "./chunks/chunk-XMNHWMGM.js";
19
19
  import "./chunks/chunk-4UBWXZVX.js";
20
20
  import "./chunks/chunk-MP7LXLWV.js";
21
21
  import "./chunks/chunk-SZNZ2T6D.js";
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  drawTubeMap,
6
6
  tubeMapPicture
7
- } from "./chunks/chunk-CR7EGAFE.js";
7
+ } from "./chunks/chunk-KCRL5JB2.js";
8
8
  import {
9
9
  tubeMapFrame,
10
10
  tubeMapNodeAt
@@ -13,7 +13,7 @@ import {
13
13
  drawTubeMapGenes,
14
14
  tubeMapGenes
15
15
  } from "./chunks/chunk-OWFPAIJI.js";
16
- import "./chunks/chunk-EJ5OZTCK.js";
16
+ import "./chunks/chunk-733L2TS6.js";
17
17
  import {
18
18
  tubeMapNodeColors
19
19
  } from "./chunks/chunk-KEVQ46GG.js";
@@ -69,9 +69,9 @@ import {
69
69
  LAYOUT_MODES,
70
70
  layoutModeByValue,
71
71
  modeUsesLayoutEngine
72
- } from "./chunks/chunk-FRR2RGBT.js";
72
+ } from "./chunks/chunk-ZJQ6H3AR.js";
73
73
  import "./chunks/chunk-LOEA5IHZ.js";
74
- import "./chunks/chunk-AYOSNXLQ.js";
74
+ import "./chunks/chunk-W2I4DOL4.js";
75
75
  import "./chunks/chunk-TEDQJPMI.js";
76
76
  import "./chunks/chunk-L3O7AWLI.js";
77
77
  import "./chunks/chunk-TZFWUT2C.js";
@@ -112,7 +112,7 @@ import {
112
112
  } from "./chunks/chunk-7XHHVYG7.js";
113
113
  import {
114
114
  figureSvg
115
- } from "./chunks/chunk-7ESIZZO7.js";
115
+ } from "./chunks/chunk-5ARDFGLJ.js";
116
116
  import {
117
117
  layoutGeometryInputs
118
118
  } from "./chunks/chunk-LOCJN3BZ.js";
@@ -204,7 +204,7 @@ import {
204
204
  import "./chunks/chunk-UMNCCYBN.js";
205
205
  import {
206
206
  version
207
- } from "./chunks/chunk-CNGKWYUC.js";
207
+ } from "./chunks/chunk-XMNHWMGM.js";
208
208
  import {
209
209
  axisScaleOf,
210
210
  contains,
@@ -5,7 +5,7 @@ import {
5
5
  tubeMapTracks,
6
6
  tubeWidth,
7
7
  visitStrands
8
- } from "../chunks/chunk-AYOSNXLQ.js";
8
+ } from "../chunks/chunk-W2I4DOL4.js";
9
9
  import "../chunks/chunk-TEDQJPMI.js";
10
10
  import "../chunks/chunk-C44YRP5F.js";
11
11
  import "../chunks/chunk-7GBL7SJY.js";
@@ -4,9 +4,9 @@ import {
4
4
  LAYOUT_MODE_VALUES,
5
5
  layoutModeByValue,
6
6
  modeUsesLayoutEngine
7
- } from "./chunks/chunk-FRR2RGBT.js";
7
+ } from "./chunks/chunk-ZJQ6H3AR.js";
8
8
  import "./chunks/chunk-LOEA5IHZ.js";
9
- import "./chunks/chunk-AYOSNXLQ.js";
9
+ import "./chunks/chunk-W2I4DOL4.js";
10
10
  import "./chunks/chunk-TEDQJPMI.js";
11
11
  import "./chunks/chunk-L3O7AWLI.js";
12
12
  import "./chunks/chunk-TZFWUT2C.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  visitStrands
3
- } from "../chunks/chunk-AYOSNXLQ.js";
3
+ } from "../chunks/chunk-W2I4DOL4.js";
4
4
  import {
5
5
  canonicalStrand
6
6
  } from "../chunks/chunk-TEDQJPMI.js";
@@ -3,13 +3,17 @@ import {
3
3
  mismatchOnScreen,
4
4
  mismatchesLegible,
5
5
  parsePath,
6
+ trackColors,
6
7
  tubeMapPicture
7
- } from "../chunks/chunk-CR7EGAFE.js";
8
- import "../chunks/chunk-EJ5OZTCK.js";
8
+ } from "../chunks/chunk-KCRL5JB2.js";
9
+ import "../chunks/chunk-733L2TS6.js";
10
+ import "../chunks/chunk-TEDQJPMI.js";
11
+ import "../chunks/chunk-C44YRP5F.js";
9
12
  export {
10
13
  drawTubeMap,
11
14
  mismatchOnScreen,
12
15
  mismatchesLegible,
13
16
  parsePath,
17
+ trackColors,
14
18
  tubeMapPicture
15
19
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  tubeMapMismatches
3
- } from "../chunks/chunk-EJ5OZTCK.js";
3
+ } from "../chunks/chunk-733L2TS6.js";
4
4
  export {
5
5
  tubeMapMismatches
6
6
  };
@@ -1,6 +1,6 @@
1
1
  import type { Coarsened } from '../tubeMap/coarsen.js';
2
2
  import type { Graph, LayoutResult } from '../types.js';
3
- import type { InputTrack, TubeMapLayout } from '@gmod/tubemap-core';
3
+ import type { InputTrack, TubeMapLayout } from '@jbrowse/tubemap-core';
4
4
  export interface TubeMapColumn {
5
5
  order: number;
6
6
  x0: number;
@@ -1,6 +1,6 @@
1
1
  import type { TubeMapFrame } from './draw.js';
2
2
  import type { Graph } from '../types.js';
3
- import type { TubeMapLayout } from '@gmod/tubemap-core';
3
+ import type { TubeMapLayout } from '@jbrowse/tubemap-core';
4
4
  export interface Box {
5
5
  bp0: number;
6
6
  bp1: number;
@@ -1,5 +1,5 @@
1
1
  import type { Graph } from '../types.js';
2
- import type { TubeMapLayout } from '@gmod/tubemap-core';
2
+ import type { TubeMapLayout } from '@jbrowse/tubemap-core';
3
3
  export interface ReferenceNode {
4
4
  node: string;
5
5
  bp0: number;
@@ -1,7 +1,7 @@
1
1
  import type { Deviation } from './coarsen.js';
2
2
  import type { TubeMapFrame } from './draw.js';
3
3
  import type { Graph } from '../types.js';
4
- import type { TubeMapLayout } from '@gmod/tubemap-core';
4
+ import type { TubeMapLayout } from '@jbrowse/tubemap-core';
5
5
  export interface DeviationMark {
6
6
  x0: number;
7
7
  x1: number;
@@ -1,6 +1,7 @@
1
1
  import type { TubeMapTransform } from './frame.js';
2
2
  import type { TubeMapMismatch } from './mismatches.js';
3
- import type { TubeMapLayout } from '@gmod/tubemap-core';
3
+ import type { TubeMapDrawing } from '../layout/tubeMapLayout.js';
4
+ import type { TubeMapLayout } from '@jbrowse/tubemap-core';
4
5
  type Command = {
5
6
  op: 'M' | 'L';
6
7
  x: number;
@@ -32,7 +33,6 @@ export declare function parsePath(d: string): Command[];
32
33
  interface Filled {
33
34
  color: string;
34
35
  track?: number;
35
- alpha: number;
36
36
  x0: number;
37
37
  x1: number;
38
38
  }
@@ -58,7 +58,8 @@ export interface TubeMapPicture {
58
58
  }[];
59
59
  mismatches: TubeMapMismatch[];
60
60
  }
61
- export declare function tubeMapPicture(layout: TubeMapLayout): TubeMapPicture;
61
+ export declare function trackColors(layout: TubeMapLayout, pathColors: readonly string[]): ReadonlyMap<number, string>;
62
+ export declare function tubeMapPicture({ layout, pathColors, }: Pick<TubeMapDrawing, 'layout' | 'pathColors'>): TubeMapPicture;
62
63
  export interface TubeMapFrame extends TubeMapTransform {
63
64
  width: number;
64
65
  highlightNode?: string | null;
@@ -1,4 +1,4 @@
1
- import type { TubeMapLayout } from '@gmod/tubemap-core';
1
+ import type { TubeMapLayout } from '@jbrowse/tubemap-core';
2
2
  interface MarkBase {
3
3
  readId: number;
4
4
  y: number;
@@ -1,6 +1,6 @@
1
1
  import type { GafRecord } from '../gaf/parseGaf.js';
2
2
  import type { Graph, GraphNode } from '../types.js';
3
- import type { InputTrack } from '@gmod/tubemap-core';
3
+ import type { InputTrack } from '@jbrowse/tubemap-core';
4
4
  export declare function canonicalStrand(node: GraphNode): "+" | "-";
5
5
  export declare function stepName(node: GraphNode, strand: '+' | '-'): string;
6
6
  export declare function tubeMapReads(graph: Graph, records: readonly GafRecord[], firstId: number): InputTrack[];
@@ -1 +1 @@
1
- export declare const version = "7.5.1";
1
+ export declare const version = "8.0.0";
package/dist/version.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  version
3
- } from "./chunks/chunk-CNGKWYUC.js";
3
+ } from "./chunks/chunk-XMNHWMGM.js";
4
4
  export {
5
5
  version
6
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/bandage-core",
3
- "version": "7.5.1",
3
+ "version": "8.0.0",
4
4
  "description": "Pangenome graph layout and drawing with no host: GFA in, the Bandage force-directed engine and reference-anchored layouts, a Canvas2D renderer, hit testing and labels out",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "repository": {
@@ -36,7 +36,7 @@
36
36
  "dependencies": {
37
37
  "@gmod/gbz-base": "^7.0.0",
38
38
  "@gmod/tabix": "^3.9.1",
39
- "@gmod/tubemap-core": "^0.1.0"
39
+ "@jbrowse/tubemap-core": "^0.2.1"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@eslint/js": "^10.0.1",