@jbrowse/bandage-core 0.1.20 → 4.0.24

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 CHANGED
@@ -34,6 +34,7 @@ the worked example.
34
34
  Lives in the plugin repo as a pnpm workspace package. The plugin imports its
35
35
  source directly, so a change here needs no publish to reach the plugin.
36
36
 
37
- The core releases with the plugin: `pnpm version patch` at the repo root bumps
38
- both, and `publish.yml` and `publish-core.yml` each publish one from the `v*`
39
- tag.
37
+ The core releases with the plugin, at the plugin's version: `pnpm version patch`
38
+ at the repo root sets both, and `publish.yml` and `publish-core.yml` each
39
+ publish one from the `v*` tag. `publish-core.yml` also runs by hand to publish a
40
+ version a failed run left behind.
@@ -3558,6 +3558,9 @@ var Canvas2DRenderer = class extends Canvas2DRenderingBackendBase {
3558
3558
  }
3559
3559
  const ctx = this.ctx;
3560
3560
  const { width, height } = ctx.canvas;
3561
+ if (clearColor[3] < 1) {
3562
+ ctx.clearRect(0, 0, width, height);
3563
+ }
3561
3564
  ctx.fillStyle = normalizedRgbToCssRgba(
3562
3565
  [clearColor[0], clearColor[1], clearColor[2]],
3563
3566
  clearColor[3]
@@ -3742,8 +3745,8 @@ function occupancy(frame, reserved = []) {
3742
3745
  function placeLabels(candidates, frame, take) {
3743
3746
  const out = [];
3744
3747
  const row = LABEL_PX + LABEL_PAD * 2;
3745
- for (const c of candidates) {
3746
- const w = labelWidth(c.text);
3748
+ const place = (c, text) => {
3749
+ const w = labelWidth(text);
3747
3750
  const direction = c.y > frame.height / 2 ? -1 : 1;
3748
3751
  for (let tries = 0; tries <= (c.stack ?? 0); tries++) {
3749
3752
  const y = c.y + direction * tries * row;
@@ -3754,13 +3757,19 @@ function placeLabels(candidates, frame, take) {
3754
3757
  y1: y + LABEL_PAD
3755
3758
  };
3756
3759
  if (offFrame(box, frame)) {
3757
- break;
3760
+ return void 0;
3758
3761
  }
3759
3762
  if (insideFrame(box, frame) && take(box)) {
3760
- out.push({ ...c, y, w });
3761
- break;
3763
+ return { ...c, text, y, w };
3762
3764
  }
3763
3765
  }
3766
+ return void 0;
3767
+ };
3768
+ for (const c of candidates) {
3769
+ const placed = place(c, c.text) ?? (c.fallback === void 0 ? void 0 : place(c, c.fallback));
3770
+ if (placed) {
3771
+ out.push(placed);
3772
+ }
3764
3773
  }
3765
3774
  return out;
3766
3775
  }
@@ -10,7 +10,7 @@ import {
10
10
  referencePathQuery,
11
11
  referenceSamplesOf,
12
12
  resolveReferenceSample
13
- } from "../chunks/chunk-3XDR3ZBS.js";
13
+ } from "../chunks/chunk-4AOHEU76.js";
14
14
 
15
15
  // src/cli/figure.ts
16
16
  import { open, readFile, writeFile } from "node:fs/promises";
package/dist/index.js CHANGED
@@ -95,7 +95,7 @@ import {
95
95
  wellKnownSample,
96
96
  yToXOf,
97
97
  zoomAbout
98
- } from "./chunks/chunk-3XDR3ZBS.js";
98
+ } from "./chunks/chunk-4AOHEU76.js";
99
99
 
100
100
  // src/index.ts
101
101
  import { getDpr } from "@jbrowse/render-core/canvas2dUtils";
@@ -466,27 +466,30 @@ function wheelZoomFactor(e) {
466
466
 
467
467
  // src/referenceStrip.ts
468
468
  import { abgrToCssRgba } from "@jbrowse/core/util/colorBits";
469
- var REFERENCE_STRIP_PX = 10;
469
+ var REFERENCE_STRIP_PX = 12;
470
470
  var REFERENCE_STRIP_ZONE_PX = REFERENCE_STRIP_PX + 8;
471
- var OVERHANG_PX = 5;
471
+ var OVERHANG_PX = 8;
472
+ var OVERHANG_CAP_PX = OVERHANG_PX + 3;
473
+ var PALE = abgrToCssRgba(fadeAbgr(LIFT_BACKDROP_COLOR, FADED_ALPHA));
472
474
  function referenceStripBlocks(graph, {
473
475
  colorScheme,
474
476
  referenceRamp,
475
- walkNodes,
476
- walkColors
477
+ walks
477
478
  }) {
478
479
  const range = { ...computeColorSchemeRange(graph), referenceRamp };
479
480
  const out = [];
480
481
  graph.nodes.forEach((node, index) => {
481
482
  if (isBackbone(node)) {
482
- const own = walkNodes ? walkColors?.get(node.id) ?? LIFT_BACKDROP_COLOR : getNodeColor(node, index, colorScheme, range);
483
- const faded = !!walkNodes && !walkNodes.has(node.id);
483
+ const colors = walks ? walks.map((w) => {
484
+ const lane = w.colors.get(node.id);
485
+ return lane === void 0 ? PALE : abgrToCssRgba(lane);
486
+ }) : [abgrToCssRgba(getNodeColor(node, index, colorScheme, range))];
484
487
  out.push({
485
488
  node: node.id,
486
489
  bp0: node.stable.start,
487
490
  bp1: node.stable.start + node.length,
488
- color: abgrToCssRgba(faded ? fadeAbgr(own, FADED_ALPHA) : own),
489
- faded
491
+ colors,
492
+ faded: colors.includes(PALE)
490
493
  });
491
494
  }
492
495
  });
@@ -532,7 +535,7 @@ function stripPixels(blocks, frame, width, dpr) {
532
535
  const [x0, x1] = span(frame, b.bp0, b.bp1);
533
536
  const px0 = Math.round(x0 * dpr);
534
537
  return {
535
- color: b.color,
538
+ colors: b.colors,
536
539
  x0,
537
540
  px0,
538
541
  px1: Math.max(Math.round(x1 * dpr), px0 + 1)
@@ -540,22 +543,33 @@ function stripPixels(blocks, frame, width, dpr) {
540
543
  }).filter((b) => b.px1 > 0 && b.px0 < width * dpr).sort((a, b) => a.x0 - b.x0);
541
544
  const out = [];
542
545
  let claimed = -Infinity;
543
- for (const { color, px0, px1 } of placed) {
546
+ const tierEnds = [-Infinity, -Infinity];
547
+ for (const { colors, px0, px1 } of placed) {
544
548
  const start = Math.max(px0, claimed);
545
549
  if (px1 > start) {
546
- out.push({ color, x0: start / dpr, x1: px1 / dpr });
550
+ const tier = tierEnds[0] < start ? 0 : 1;
551
+ tierEnds[tier] = px1;
552
+ out.push({ colors, x0: start / dpr, x1: px1 / dpr, tier });
547
553
  claimed = px1;
548
554
  }
549
555
  }
550
556
  return out;
551
557
  }
552
- function drawOverhang(ctx, tipX, inward) {
553
- const mid = REFERENCE_STRIP_PX / 2;
554
- const baseX = tipX + inward * (OVERHANG_PX + 1);
555
- ctx.moveTo(tipX + inward, mid);
556
- ctx.lineTo(baseX, mid - OVERHANG_PX / 1.4);
557
- ctx.lineTo(baseX, mid + OVERHANG_PX / 1.4);
558
+ function drawOverhang(ctx, edgeX, inward, ink) {
559
+ const capX = inward > 0 ? edgeX : edgeX - OVERHANG_CAP_PX;
560
+ ctx.clearRect(capX, 0, OVERHANG_CAP_PX, REFERENCE_STRIP_PX);
561
+ const tipX = edgeX + inward;
562
+ const baseX = tipX + inward * OVERHANG_PX;
563
+ ctx.beginPath();
564
+ ctx.moveTo(tipX, REFERENCE_STRIP_PX / 2);
565
+ ctx.lineTo(baseX, 0);
566
+ ctx.lineTo(baseX, REFERENCE_STRIP_PX);
558
567
  ctx.closePath();
568
+ ctx.fillStyle = ink;
569
+ ctx.fill();
570
+ }
571
+ function rowEdge(row, rows, dpr) {
572
+ return Math.round(row * REFERENCE_STRIP_PX * dpr / rows) / dpr;
559
573
  }
560
574
  function drawReferenceStrip(ctx, blocks, frame, {
561
575
  width,
@@ -564,26 +578,22 @@ function drawReferenceStrip(ctx, blocks, frame, {
564
578
  dpr = 1
565
579
  }) {
566
580
  const ink = darkMode ? "#ffffff" : "#18181c";
567
- ctx.fillStyle = darkMode ? "#1f1f1f" : "#ffffff";
568
- ctx.fillRect(0, 0, width, REFERENCE_STRIP_ZONE_PX);
581
+ ctx.clearRect(0, 0, width, REFERENCE_STRIP_ZONE_PX);
569
582
  for (const b of stripPixels(blocks, frame, width, dpr)) {
570
- ctx.fillStyle = b.color;
571
- ctx.fillRect(b.x0, 0, b.x1 - b.x0, REFERENCE_STRIP_PX);
583
+ const rows = b.colors.length > 1 ? b.colors.length : 2;
584
+ b.colors.forEach((color, i) => {
585
+ const row = b.colors.length > 1 ? i : b.tier;
586
+ const y0 = rowEdge(row, rows, dpr);
587
+ ctx.fillStyle = color;
588
+ ctx.fillRect(b.x0, y0, b.x1 - b.x0, rowEdge(row + 1, rows, dpr) - y0);
589
+ });
572
590
  }
573
591
  const overhang = stripOverhang(blocks, frame, width);
574
- if (overhang.left > 0 || overhang.right > 0) {
575
- ctx.beginPath();
576
- if (overhang.left > 0) {
577
- drawOverhang(ctx, 0, 1);
578
- }
579
- if (overhang.right > 0) {
580
- drawOverhang(ctx, width, -1);
581
- }
582
- ctx.fillStyle = ink;
583
- ctx.fill();
584
- ctx.strokeStyle = darkMode ? "#1f1f1f" : "#ffffff";
585
- ctx.lineWidth = 1;
586
- ctx.stroke();
592
+ if (overhang.left > 0) {
593
+ drawOverhang(ctx, 0, 1, ink);
594
+ }
595
+ if (overhang.right > 0) {
596
+ drawOverhang(ctx, width, -1, ink);
587
597
  }
588
598
  if (lit) {
589
599
  const [x0, x1] = span(frame, lit.start, lit.end);
@@ -1770,6 +1780,7 @@ function layoutLabels(m) {
1770
1780
  x,
1771
1781
  y: y + m.contigThickness + GENE_PIN_DROP_PX,
1772
1782
  text: note ? `${pin.gene.name} \xB7 ${note}` : pin.gene.name,
1783
+ fallback: note ? `${pin.gene.name} \u2026` : void 0,
1773
1784
  stack: GENE_STACK
1774
1785
  };
1775
1786
  }),
@@ -13,6 +13,7 @@ export interface LabelCandidate<T> {
13
13
  y: number;
14
14
  text: string;
15
15
  stack?: number;
16
+ fallback?: string;
16
17
  }
17
18
  export interface PlacedLabel<T> extends LabelCandidate<T> {
18
19
  w: number;
@@ -1,20 +1,21 @@
1
1
  import type { ResolvedColorScheme } from './colorSchemes.js';
2
2
  import type { ReferenceRamp } from './renderer/GeometryBuilder.js';
3
3
  import type { Graph, NodeSegment } from './types.js';
4
- export declare const REFERENCE_STRIP_PX = 10;
4
+ export declare const REFERENCE_STRIP_PX = 12;
5
5
  export declare const REFERENCE_STRIP_ZONE_PX: number;
6
6
  export interface StripBlock {
7
7
  node: string;
8
8
  bp0: number;
9
9
  bp1: number;
10
- color: string;
10
+ colors: string[];
11
11
  faded: boolean;
12
12
  }
13
- export declare function referenceStripBlocks(graph: Graph, { colorScheme, referenceRamp, walkNodes, walkColors, }: {
13
+ export declare function referenceStripBlocks(graph: Graph, { colorScheme, referenceRamp, walks, }: {
14
14
  colorScheme: ResolvedColorScheme;
15
15
  referenceRamp?: ReferenceRamp;
16
- walkNodes?: ReadonlySet<string>;
17
- walkColors?: ReadonlyMap<string, number>;
16
+ walks?: readonly {
17
+ colors: ReadonlyMap<string, number>;
18
+ }[];
18
19
  }): StripBlock[];
19
20
  export interface BpFrame {
20
21
  scale: number;
@@ -41,9 +42,10 @@ export interface StripLit {
41
42
  };
42
43
  }
43
44
  export declare function stripPixels(blocks: readonly StripBlock[], frame: BpFrame, width: number, dpr: number): {
44
- color: string;
45
+ colors: string[];
45
46
  x0: number;
46
47
  x1: number;
48
+ tier: number;
47
49
  }[];
48
50
  export declare function drawReferenceStrip(ctx: CanvasRenderingContext2D, blocks: readonly StripBlock[], frame: BpFrame, { width, lit, darkMode, dpr, }: {
49
51
  width: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/bandage-core",
3
- "version": "0.1.20",
3
+ "version": "4.0.24",
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": {