@jbrowse/bandage-core 4.0.27 → 4.0.28

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.
@@ -3153,7 +3153,7 @@ function nodeInk(graph, nodeById, contigThickness, nodeWidth2) {
3153
3153
  }
3154
3154
 
3155
3155
  // src/renderer/GeometryBuilder.ts
3156
- import { packAbgr as packAbgr2 } from "@jbrowse/core/util/colorBits";
3156
+ import { abgrToCssRgba, packAbgr as packAbgr2 } from "@jbrowse/core/util/colorBits";
3157
3157
 
3158
3158
  // src/renderer/colorBits.ts
3159
3159
  import {
@@ -3227,6 +3227,9 @@ var EDGE_DELETION_COLOR = packAbgr2(24, 24, 28, 240);
3227
3227
  var DELETION_THICKNESS_FACTOR = 2.2;
3228
3228
  var LIFT_BACKDROP_COLOR = packAbgr2(160, 160, 160, 255);
3229
3229
  var FADED_ALPHA = 0.18;
3230
+ var LIFT_BACKDROP_CSS = abgrToCssRgba(
3231
+ fadeAbgr(LIFT_BACKDROP_COLOR, FADED_ALPHA)
3232
+ );
3230
3233
  var DELETION_DASH_PX = 11;
3231
3234
  var MIN_PATH_STRIPE_PX = 1.2;
3232
3235
  var MIN_WALK_LANE_PX = 4;
@@ -3880,7 +3883,7 @@ function buildGeometry(options) {
3880
3883
 
3881
3884
  // src/renderer/Canvas2DRenderer.ts
3882
3885
  import {
3883
- abgrToCssRgba,
3886
+ abgrToCssRgba as abgrToCssRgba2,
3884
3887
  normalizedRgbToCssRgba
3885
3888
  } from "@jbrowse/core/util/colorBits";
3886
3889
  import { syncCanvasSize } from "@jbrowse/render-core/canvas2dUtils";
@@ -3949,7 +3952,7 @@ var Canvas2DRenderer = class extends Canvas2DRenderingBackendBase {
3949
3952
  weight: e.thickness,
3950
3953
  last: inRun(hl, i)
3951
3954
  }))) {
3952
- ctx.strokeStyle = abgrToCssRgba(color);
3955
+ ctx.strokeStyle = abgrToCssRgba2(color);
3953
3956
  ctx.lineWidth = items[0].thickness * 2 * t.dpr;
3954
3957
  ctx.beginPath();
3955
3958
  for (const e of items) {
@@ -3992,7 +3995,7 @@ var Canvas2DRenderer = class extends Canvas2DRenderingBackendBase {
3992
3995
  last: factor !== void 0
3993
3996
  };
3994
3997
  })) {
3995
- ctx.strokeStyle = abgrToCssRgba(color);
3998
+ ctx.strokeStyle = abgrToCssRgba2(color);
3996
3999
  ctx.lineWidth = items[0].thickness * 2 * t.dpr;
3997
4000
  ctx.beginPath();
3998
4001
  for (const s of items) {
@@ -4021,7 +4024,7 @@ var Canvas2DRenderer = class extends Canvas2DRenderingBackendBase {
4021
4024
  weight: 0,
4022
4025
  last: inRun(hl, i)
4023
4026
  }))) {
4024
- ctx.fillStyle = abgrToCssRgba(color);
4027
+ ctx.fillStyle = abgrToCssRgba2(color);
4025
4028
  ctx.beginPath();
4026
4029
  for (const a of items) {
4027
4030
  const [tip, left, notch, right] = arrowheadOutline(a, t);
@@ -4738,7 +4741,7 @@ function svgCanvas(width, height) {
4738
4741
  }
4739
4742
 
4740
4743
  // src/version.ts
4741
- var version = "4.0.27";
4744
+ var version = "4.0.28";
4742
4745
 
4743
4746
  // src/viewport.ts
4744
4747
  function axisScaleOf(scale, pixelRows) {
@@ -5406,15 +5409,57 @@ function nodeLimitError(error, limit, windowBp) {
5406
5409
  return new NodeLimitError(limit, windowBp, Math.max(fits, 1));
5407
5410
  }
5408
5411
  }
5412
+ var GBZ_CUT_DEFAULTS = {
5413
+ context: 1e3,
5414
+ snarls: "contained",
5415
+ limit: 1e5
5416
+ };
5417
+ async function referencePieces(db, query, start, end) {
5418
+ const inside = (await db.paths()).filter(
5419
+ ({ isIndexed, name }) => isIndexed && name.sample === query.sample && name.haplotype === query.haplotype && name.contig === query.contig && name.fragment > start && name.fragment < end
5420
+ ).map((path) => path.name.fragment);
5421
+ const bounds = [start, ...[...new Set(inside)].sort((a, b) => a - b), end];
5422
+ return bounds.slice(1).map((pieceEnd, i) => ({
5423
+ start: bounds[i],
5424
+ end: pieceEnd
5425
+ }));
5426
+ }
5427
+ function joinCuts(gfas) {
5428
+ const cuts = gfas.map((gfa) => gfa.split("\n").filter((line) => line !== ""));
5429
+ const ofType = (cut, type) => cut.filter((line) => line.startsWith(type));
5430
+ const lines = /* @__PURE__ */ new Set([
5431
+ ...ofType(cuts[0] ?? [], "H"),
5432
+ ...cuts.flatMap((cut) => ofType(cut, "S")),
5433
+ ...cuts.flatMap((cut) => ofType(cut, "L")),
5434
+ ...cuts.flatMap((cut) => ofType(cut, "W").slice(0, 1)),
5435
+ ...cuts.flatMap((cut) => ofType(cut, "W").slice(1))
5436
+ ]);
5437
+ return lines.size === 0 ? "" : `${[...lines].join("\n")}
5438
+ `;
5439
+ }
5409
5440
  async function cutWindowGFA(db, query, start, end, { keep, ...opts }) {
5410
- const subgraph = query ? await db.getSubgraphForRange(query, start, end, {
5411
- ...opts,
5412
- haplotypes: "all",
5413
- ...keep === void 0 ? {} : { keep }
5414
- }).catch((error) => {
5415
- throw nodeLimitError(error, opts.limit, end - start) ?? error;
5416
- }) : void 0;
5417
- return subgraph ? subgraph.toGFA({ names: "resolved" }) : "";
5441
+ if (!query) {
5442
+ return "";
5443
+ }
5444
+ const pieces = await referencePieces(db, query, start, end);
5445
+ const subgraphs = await Promise.all(
5446
+ pieces.map(
5447
+ (piece) => db.getSubgraphForRange(query, piece.start, piece.end, {
5448
+ ...opts,
5449
+ haplotypes: "all",
5450
+ ...keep === void 0 ? {} : { keep }
5451
+ }).catch((error) => {
5452
+ throw nodeLimitError(error, opts.limit, end - start) ?? error;
5453
+ })
5454
+ )
5455
+ );
5456
+ return joinCuts(
5457
+ await Promise.all(
5458
+ subgraphs.flatMap(
5459
+ (subgraph) => subgraph ? [subgraph.toGFA({ names: "resolved" })] : []
5460
+ )
5461
+ )
5462
+ );
5418
5463
  }
5419
5464
 
5420
5465
  // src/gbzCut.ts
@@ -5427,7 +5472,6 @@ function haplotypeIndexBeside(db) {
5427
5472
  const GBZ_DB = /\.gbz\.db$/i;
5428
5473
  return GBZ_DB.test(db) ? db.replace(GBZ_DB, ".haplotype-index.db") : void 0;
5429
5474
  }
5430
- var WALK_LIMIT = 1e5;
5431
5475
  function parseRegion(text) {
5432
5476
  const m = /^\s*([^:\s]+):([\d,]+)-([\d,]+)\s*$/.exec(text);
5433
5477
  if (!m) {
@@ -5466,9 +5510,9 @@ async function cutGbzRegion({ base, referenceSamples }, src, signal) {
5466
5510
  signal?.throwIfAborted();
5467
5511
  const wanted = src.haplotypes?.length ? src.haplotypes : void 0;
5468
5512
  const text = await cutWindowGFA(base, query, region.start, region.end, {
5469
- context: src.context ?? 1e3,
5470
- snarls: src.snarls ?? "contained",
5471
- limit: WALK_LIMIT,
5513
+ context: src.context ?? GBZ_CUT_DEFAULTS.context,
5514
+ snarls: src.snarls ?? GBZ_CUT_DEFAULTS.snarls,
5515
+ limit: GBZ_CUT_DEFAULTS.limit,
5472
5516
  signal,
5473
5517
  ...wanted ? { keep: (name) => haplotypeWanted(name, wanted) } : {}
5474
5518
  });
@@ -5528,10 +5572,8 @@ export {
5528
5572
  nodeWidthPx,
5529
5573
  maxNodeWidthPx,
5530
5574
  nodeInk,
5531
- fadeAbgr,
5532
5575
  baseEdgeCurves,
5533
- LIFT_BACKDROP_COLOR,
5534
- FADED_ALPHA,
5576
+ LIFT_BACKDROP_CSS,
5535
5577
  REFERENCE_RAMP_MAX_HUE,
5536
5578
  computeReferenceRamp,
5537
5579
  computeColorSchemeRange,
@@ -17,7 +17,7 @@ import {
17
17
  openGbz,
18
18
  parseRegion,
19
19
  refNameBinding
20
- } from "../chunks/chunk-VNCGWA2N.js";
20
+ } from "../chunks/chunk-G3HO75W7.js";
21
21
 
22
22
  // src/cli/figure.ts
23
23
  import { access, open, readFile, writeFile } from "node:fs/promises";
package/dist/index.js CHANGED
@@ -5,7 +5,6 @@ import {
5
5
  FACET_GAP_PX,
6
6
  FACET_PAD_PX,
7
7
  FACET_TITLE_PX,
8
- FADED_ALPHA,
9
8
  FIT_PADDING,
10
9
  FORCE_LAYOUT_LABEL,
11
10
  HALO_FACTOR,
@@ -15,7 +14,7 @@ import {
15
14
  LABEL_PX,
16
15
  LAYOUT_MODES,
17
16
  LEGEND_INSET_PX,
18
- LIFT_BACKDROP_COLOR,
17
+ LIFT_BACKDROP_CSS,
19
18
  NODE_WIDTHS,
20
19
  REFERENCE_RAMP_MAX_HUE,
21
20
  ROW_HEIGHT_PX,
@@ -43,7 +42,6 @@ import {
43
42
  facetCells,
44
43
  facetGrid,
45
44
  facetLifts,
46
- fadeAbgr,
47
45
  featuresOnBackbone,
48
46
  figureSvg,
49
47
  fitTransform,
@@ -102,7 +100,7 @@ import {
102
100
  wellKnownSample,
103
101
  yToXOf,
104
102
  zoomAbout
105
- } from "./chunks/chunk-VNCGWA2N.js";
103
+ } from "./chunks/chunk-G3HO75W7.js";
106
104
 
107
105
  // src/index.ts
108
106
  import { getDpr } from "@jbrowse/render-core/canvas2dUtils";
@@ -478,7 +476,6 @@ var REFERENCE_STRIP_ZONE_PX = REFERENCE_STRIP_PX + 8;
478
476
  var OVERHANG_PX = 8;
479
477
  var OVERHANG_CAP_PX = OVERHANG_PX + 3;
480
478
  var MIN_STAGGER_PX = 12;
481
- var PALE = abgrToCssRgba(fadeAbgr(LIFT_BACKDROP_COLOR, FADED_ALPHA));
482
479
  function referenceStripBlocks(graph, {
483
480
  colorScheme,
484
481
  referenceRamp,
@@ -490,14 +487,14 @@ function referenceStripBlocks(graph, {
490
487
  if (isBackbone(node)) {
491
488
  const colors = walks ? walks.map((w) => {
492
489
  const lane = w.colors.get(node.id);
493
- return lane === void 0 ? PALE : abgrToCssRgba(lane);
490
+ return lane === void 0 ? LIFT_BACKDROP_CSS : abgrToCssRgba(lane);
494
491
  }) : [abgrToCssRgba(getNodeColor(node, index, colorScheme, range))];
495
492
  out.push({
496
493
  node: node.id,
497
494
  bp0: node.stable.start,
498
495
  bp1: node.stable.start + node.length,
499
496
  colors,
500
- faded: colors.includes(PALE)
497
+ faded: colors.includes(LIFT_BACKDROP_CSS)
501
498
  });
502
499
  }
503
500
  });
@@ -24,4 +24,13 @@ export interface GbzWindowOptions {
24
24
  keep?: (name: PathName) => boolean;
25
25
  signal?: AbortSignal;
26
26
  }
27
+ export declare const GBZ_CUT_DEFAULTS: {
28
+ readonly context: 1000;
29
+ readonly snarls: "contained";
30
+ readonly limit: 100000;
31
+ };
32
+ export declare function referencePieces(db: GBZBase, query: PathQuery, start: number, end: number): Promise<{
33
+ start: number;
34
+ end: number;
35
+ }[]>;
27
36
  export declare function cutWindowGFA(db: GBZBase, query: PathQuery | undefined, start: number, end: number, { keep, ...opts }: GbzWindowOptions): Promise<string>;
@@ -6,6 +6,7 @@ import type { RenderBatch } from './types.js';
6
6
  import type { AxisScale, BezierCurve } from '../util/geometry.js';
7
7
  export declare const LIFT_BACKDROP_COLOR: number;
8
8
  export declare const FADED_ALPHA = 0.18;
9
+ export declare const LIFT_BACKDROP_CSS: string;
9
10
  export interface BuildOptions {
10
11
  nodePositions: Record<string, NodeSegment[]>;
11
12
  graph: Graph;
@@ -1 +1 @@
1
- export declare const version = "4.0.27";
1
+ export declare const version = "4.0.28";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/bandage-core",
3
- "version": "4.0.27",
3
+ "version": "4.0.28",
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": {