@jbrowse/bandage-core 4.0.30 → 4.1.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.
@@ -17,7 +17,7 @@ import {
17
17
  openGbz,
18
18
  parseRegion,
19
19
  refNameBinding
20
- } from "../chunks/chunk-P7UDDVHK.js";
20
+ } from "../chunks/chunk-WAW4SYMY.js";
21
21
 
22
22
  // src/cli/figure.ts
23
23
  import { access, open, readFile, writeFile } from "node:fs/promises";
@@ -34,10 +34,6 @@ function byteSource(location) {
34
34
  headers: { range: `bytes=${position}-${position + length - 1}` }
35
35
  });
36
36
  return new Uint8Array(await res.arrayBuffer());
37
- },
38
- async stat() {
39
- const res = await fetchOk(location, { method: "HEAD" });
40
- return { size: Number(res.headers.get("content-length")) };
41
37
  }
42
38
  };
43
39
  }
@@ -47,9 +43,6 @@ function byteSource(location) {
47
43
  const buffer = new Uint8Array(length);
48
44
  const { bytesRead } = await (await handle).read(buffer, 0, length, position);
49
45
  return buffer.subarray(0, bytesRead);
50
- },
51
- async stat() {
52
- return { size: (await (await handle).stat()).size };
53
46
  }
54
47
  };
55
48
  }
package/dist/index.js CHANGED
@@ -1,12 +1,16 @@
1
1
  import {
2
+ BAR_PX,
2
3
  BUBBLE_SPREADS,
3
4
  COLOR_SCHEMES,
4
5
  Canvas2DRenderer,
6
+ DISAGREES,
5
7
  FACET_GAP_PX,
6
8
  FACET_PAD_PX,
7
9
  FACET_TITLE_PX,
8
10
  FIT_PADDING,
9
11
  FORCE_LAYOUT_LABEL,
12
+ GAP_PX,
13
+ GENE_INK,
10
14
  HALO_FACTOR,
11
15
  HPRC_GBZ,
12
16
  LABEL_CHAR_PX,
@@ -16,11 +20,16 @@ import {
16
20
  LEGEND_INSET_PX,
17
21
  LIFT_BACKDROP_CSS,
18
22
  NODE_WIDTHS,
23
+ OFF_REFERENCE,
24
+ ON_REFERENCE,
25
+ OUTSIDE_CUT,
26
+ RAMP_GRADIENT_CSS,
19
27
  REFERENCE_RAMP_MAX_HUE,
20
28
  ROW_HEIGHT_PX,
21
29
  WALK_FIELDS,
22
30
  WALK_SCHEMES,
23
31
  WELL_KNOWN_SAMPLES,
32
+ alongRow,
24
33
  assemblyWalk,
25
34
  axisScaleOf,
26
35
  backboneAssembly,
@@ -35,6 +44,7 @@ import {
35
44
  cutWindowGFA,
36
45
  deletionEdges,
37
46
  drawingBounds,
47
+ el,
38
48
  encodingStops,
39
49
  encodingSwatchCss,
40
50
  engineKey,
@@ -64,6 +74,7 @@ import {
64
74
  loadGraph,
65
75
  maxNodeWidthPx,
66
76
  meanDepth,
77
+ mergeOverlappingByName,
67
78
  modeUsesLayoutEngine,
68
79
  nodeInk,
69
80
  nodeWidthPx,
@@ -76,7 +87,12 @@ import {
76
87
  pathColorsLegible,
77
88
  pathLegend,
78
89
  pathRibbonOffsets,
90
+ placeRowGenes,
91
+ rampHue,
92
+ rampHueCss,
93
+ rampStops,
79
94
  rangeText,
95
+ readoutPlacement,
80
96
  refNameBinding,
81
97
  referenceOrder,
82
98
  referencePathQuery,
@@ -84,24 +100,33 @@ import {
84
100
  resolveColorScheme,
85
101
  resolveEncoding,
86
102
  resolveReferenceSample,
103
+ rowGeneBoxes,
104
+ rowSpan,
105
+ runPaint,
87
106
  schemeCss,
88
107
  screenToLayout,
108
+ serializeEl,
89
109
  svgCanvas,
90
110
  svgPath,
91
111
  translateCurves,
92
112
  trimOrigins,
113
+ unitTicks,
93
114
  version,
94
115
  viewportOf,
95
116
  walkHighlight,
96
117
  walkKey,
97
118
  walkLift,
98
119
  walkPosition,
120
+ walkRowReadout,
99
121
  walkRows,
100
122
  walkRowsExtent,
123
+ walkRowsKey,
124
+ walkRowsKeyTree,
125
+ walkRowsTree,
101
126
  wellKnownSample,
102
127
  yToXOf,
103
128
  zoomAbout
104
- } from "./chunks/chunk-P7UDDVHK.js";
129
+ } from "./chunks/chunk-WAW4SYMY.js";
105
130
 
106
131
  // src/index.ts
107
132
  import { getDpr } from "@jbrowse/render-core/canvas2dUtils";
@@ -1764,12 +1789,21 @@ export {
1764
1789
  LAYOUT_MODES,
1765
1790
  LEGEND_INSET_PX,
1766
1791
  NODE_WIDTHS,
1792
+ RAMP_GRADIENT_CSS,
1767
1793
  REFERENCE_RAMP_MAX_HUE,
1768
1794
  REFERENCE_STRIP_ZONE_PX,
1769
1795
  ROW_HEIGHT_PX,
1796
+ BAR_PX as WALK_BAR_PX,
1797
+ DISAGREES as WALK_DISAGREES,
1770
1798
  WALK_FIELDS,
1799
+ GAP_PX as WALK_GAP_PX,
1800
+ GENE_INK as WALK_GENE_INK,
1801
+ OFF_REFERENCE as WALK_OFF_REFERENCE,
1802
+ ON_REFERENCE as WALK_ON_REFERENCE,
1803
+ OUTSIDE_CUT as WALK_OUTSIDE_CUT,
1771
1804
  WALK_SCHEMES,
1772
1805
  WELL_KNOWN_SAMPLES,
1806
+ alongRow,
1773
1807
  assemblyWalk,
1774
1808
  axisScaleOf,
1775
1809
  backboneAssembly,
@@ -1792,6 +1826,7 @@ export {
1792
1826
  drawTubeMapGenes,
1793
1827
  drawTubeMapRuler,
1794
1828
  drawingBounds,
1829
+ el,
1795
1830
  encodingStops,
1796
1831
  encodingSwatchCss,
1797
1832
  engineKey,
@@ -1822,6 +1857,7 @@ export {
1822
1857
  loadGraph,
1823
1858
  maxNodeWidthPx,
1824
1859
  meanDepth,
1860
+ mergeOverlappingByName,
1825
1861
  modeUsesLayoutEngine,
1826
1862
  nodeInk,
1827
1863
  nodeWidthPx,
@@ -1833,7 +1869,12 @@ export {
1833
1869
  parseRegion,
1834
1870
  pathColorsLegible,
1835
1871
  pathLegend,
1872
+ placeRowGenes,
1873
+ rampHue,
1874
+ rampHueCss,
1875
+ rampStops,
1836
1876
  rangeText,
1877
+ readoutPlacement,
1837
1878
  refNameBinding,
1838
1879
  referenceBoxes,
1839
1880
  referenceKnots,
@@ -1844,9 +1885,13 @@ export {
1844
1885
  resolveColorScheme,
1845
1886
  resolveEncoding,
1846
1887
  resolveReferenceSample,
1888
+ rowGeneBoxes,
1889
+ rowSpan,
1847
1890
  rulerBoxes,
1891
+ runPaint,
1848
1892
  schemeCss,
1849
1893
  screenToLayout,
1894
+ serializeEl,
1850
1895
  stripBlockAt,
1851
1896
  svgCanvas,
1852
1897
  tubeMapConnectors,
@@ -1856,14 +1901,19 @@ export {
1856
1901
  tubeMapNodeColors,
1857
1902
  tubeMapPicture,
1858
1903
  tubeX,
1904
+ unitTicks,
1859
1905
  version,
1860
1906
  viewportOf,
1861
1907
  walkHighlight,
1862
1908
  walkKey,
1863
1909
  walkLift,
1864
1910
  walkPosition,
1911
+ walkRowReadout,
1865
1912
  walkRows,
1866
1913
  walkRowsExtent,
1914
+ walkRowsKey,
1915
+ walkRowsKeyTree,
1916
+ walkRowsTree,
1867
1917
  warpX,
1868
1918
  wellKnownSample,
1869
1919
  wheelZoomFactor,
@@ -0,0 +1,8 @@
1
+ export type ElAttrs = Record<string, string | number | undefined>;
2
+ export interface El {
3
+ tag: string;
4
+ attrs: ElAttrs;
5
+ children: (El | string)[];
6
+ }
7
+ export declare function el(tag: string, attrs?: ElAttrs, ...children: (El | string | undefined | false)[]): El;
8
+ export declare function serializeEl(node: El | string): string;
@@ -1,6 +1,7 @@
1
1
  import type { ColorScheme } from './colorSchemes.js';
2
2
  import type { FacetInput } from './facetGrid.js';
3
3
  import type { GeneModel } from './genes/genePins.js';
4
+ import type { GeneGaps, RowGene, WalkRowsWithCalls } from './layout/walkRowDraw.js';
4
5
  import type { NodeWidth } from './nodeWidths.js';
5
6
  import type { Graph, LayoutResult } from './types.js';
6
7
  import type { WalkLayer } from './walkEncoding.js';
@@ -26,5 +27,8 @@ export interface FigureOptions {
26
27
  fitToDrawing?: boolean;
27
28
  genes?: GeneModel[];
28
29
  spec?: unknown;
30
+ walkRows?: WalkRowsWithCalls;
31
+ rowGenes?: Map<string, RowGene[]>;
32
+ rowGeneGaps?: GeneGaps;
29
33
  }
30
34
  export declare function figureSvg(graph: Graph, layout: LayoutResult, o?: FigureOptions): string;
@@ -1,5 +1,5 @@
1
1
  import { GBZBase } from '@gmod/gbz-base';
2
- import type { ByteSource, RangeOptions } from '@gmod/gbz-base';
2
+ import type { ByteSource, SnarlOutput } from '@gmod/gbz-base';
3
3
  export interface GbzSource {
4
4
  db: string;
5
5
  index?: string;
@@ -7,7 +7,7 @@ export interface GbzSource {
7
7
  haplotypes?: string[];
8
8
  referenceSample?: string;
9
9
  context?: number;
10
- snarls?: RangeOptions['snarls'];
10
+ snarls?: SnarlOutput;
11
11
  }
12
12
  export declare const HPRC_GBZ: {
13
13
  db: string;
@@ -1,4 +1,4 @@
1
- import type { GBZBase, PathName, PathQuery, RangeOptions } from '@gmod/gbz-base';
1
+ import type { GBZBase, PathName, PathQuery, SnarlOutput } from '@gmod/gbz-base';
2
2
  export declare class NoReferenceSampleError extends Error {
3
3
  name: string;
4
4
  constructor(anchor: string, referenceSamples: string[]);
@@ -16,21 +16,17 @@ export declare function resolveReferenceSample({ configured, anchorPrefix, refer
16
16
  referenceSamples: string[];
17
17
  }): string;
18
18
  export declare function referencePathQuery(db: GBZBase, referenceSample: string, refName: string): Promise<PathQuery | undefined>;
19
- export declare function nodeLimitError(error: unknown, limit: number, windowBp: number, walkedFrom?: number): NodeLimitError | undefined;
19
+ export declare function nodeLimitError(error: unknown, limit: number, windowBp: number): NodeLimitError | undefined;
20
20
  export interface GbzWindowOptions {
21
21
  context: number;
22
- snarls: RangeOptions['snarls'];
22
+ snarls: SnarlOutput;
23
23
  limit: number;
24
- keep?: (name: PathName) => boolean;
25
- signal?: AbortSignal;
24
+ keep?: ((name: PathName) => boolean) | undefined;
25
+ signal?: AbortSignal | undefined;
26
26
  }
27
27
  export declare const GBZ_CUT_DEFAULTS: {
28
28
  readonly context: 1000;
29
29
  readonly snarls: "contained";
30
30
  readonly limit: 100000;
31
31
  };
32
- export declare function referencePieces(db: GBZBase, query: PathQuery, start: number, end: number): Promise<{
33
- start: number;
34
- end: number;
35
- }[]>;
36
- export declare function cutWindowGFA(db: GBZBase, query: PathQuery | undefined, start: number, end: number, { keep, ...opts }: GbzWindowOptions): Promise<string>;
32
+ export declare function cutWindowGFA(db: GBZBase, query: PathQuery | undefined, start: number, end: number, opts: GbzWindowOptions): Promise<string>;
@@ -5,6 +5,7 @@ export declare function mergedIntervals(intervals: Interval[]): {
5
5
  end: number;
6
6
  }[];
7
7
  export declare function genesFromGff3Lines(lines: Iterable<string>): GeneModel[];
8
+ export declare function mergeOverlappingByName(genes: GeneModel[]): GeneModel[];
8
9
  export declare function genesFromBed(text: string): GeneModel[];
9
10
  export declare function genesFromText(text: string): GeneModel[];
10
11
  export {};
@@ -36,7 +36,7 @@ export type { DeletionEdge } from './deletionEdges.js';
36
36
  export { facetLifts, walkHighlight, walkLift } from './walkHighlight.js';
37
37
  export { rangeText, walkKey, walkPosition } from './walkKey.js';
38
38
  export { figureSvg } from './figure.js';
39
- export { genesFromBed, genesFromGff3Lines, genesFromText, } from './genes/geneFiles.js';
39
+ export { genesFromBed, genesFromGff3Lines, genesFromText, mergeOverlappingByName, } from './genes/geneFiles.js';
40
40
  export { HPRC_GBZ, cutGbzRegion, openGbz, parseRegion } from './gbzCut.js';
41
41
  export type { GbzSource } from './gbzCut.js';
42
42
  export { version } from './version.js';
@@ -55,7 +55,12 @@ export { BUBBLE_KIND_COLORS, BUBBLE_KIND_NAMES, bubbleSegmentIds, classifyBubble
55
55
  export { bubbleSubgraph } from './bubbles/popBubble.js';
56
56
  export type { MinigraphBubble } from './bubbles/bubbleLine.js';
57
57
  export { walkRows } from './layout/walkRows.js';
58
- export type { WalkRows } from './layout/walkRows.js';
58
+ export type { WalkAxis, WalkRow, WalkRows, WalkRun } from './layout/walkRows.js';
59
+ export { BAR_PX as WALK_BAR_PX, DISAGREES as WALK_DISAGREES, GAP_PX as WALK_GAP_PX, GENE_INK as WALK_GENE_INK, OFF_REFERENCE as WALK_OFF_REFERENCE, ON_REFERENCE as WALK_ON_REFERENCE, OUTSIDE_CUT as WALK_OUTSIDE_CUT, alongRow, placeRowGenes, readoutPlacement, rowGeneBoxes, rowSpan, runPaint, unitTicks, walkRowReadout, walkRowsKey, walkRowsKeyTree, walkRowsTree, } from './layout/walkRowDraw.js';
60
+ export type { GeneBox, GeneGaps, KeyEntry, KeySwatch, ReadoutCall, RowGene, WalkRowsFrame, WalkRowsWithCalls, } from './layout/walkRowDraw.js';
61
+ export { el, serializeEl } from './el.js';
62
+ export type { El, ElAttrs } from './el.js';
63
+ export { RAMP_GRADIENT_CSS, rampHue, rampHueCss, rampStops, } from './referenceRampCss.js';
59
64
  export { walkRowsExtent } from './layout/walkRowLayout.js';
60
65
  export { ROW_HEIGHT_PX } from './layout/rowSpacing.js';
61
66
  export { HALO_FACTOR, LEGEND_INSET_PX, geneCoverageNote, layoutLabels, } from './labelLayout.js';
@@ -0,0 +1,125 @@
1
+ import type { WalkAxis, WalkRow, WalkRows, WalkRun } from './walkRows.js';
2
+ import type { El } from '../el.js';
3
+ import type { GeneModel } from '../genes/genePins.js';
4
+ export declare const ON_REFERENCE = "#2f8fd6";
5
+ export declare const OFF_REFERENCE = "#8e3fbf";
6
+ export declare const OUTSIDE_CUT = "#bdbdbd";
7
+ export declare const GENE_INK = "#1c1c22";
8
+ export declare const BAR_PX = 12;
9
+ export declare const GAP_PX = 4;
10
+ export declare function kb(bp: number): string;
11
+ export interface ReadoutCall {
12
+ bp: number;
13
+ spanningReads?: number;
14
+ agrees?: boolean;
15
+ }
16
+ export declare function walkRowReadout(row: Pick<WalkRow, 'bp' | 'gapBp' | 'complete'>, reference: Pick<WalkRow, 'bp'> | undefined, unit?: number, call?: ReadoutCall): string;
17
+ export declare function readoutPlacement(text: string, endX: number, width: number): {
18
+ x: number;
19
+ anchor: "start";
20
+ halo: boolean;
21
+ } | {
22
+ x: number;
23
+ anchor: "end";
24
+ halo: boolean;
25
+ };
26
+ export declare function unitTicks(bp: number, unit: number, pxPerBp: number): number[];
27
+ export declare function runPaint(run: WalkRun, ramp: {
28
+ start: number;
29
+ end: number;
30
+ } | undefined): {
31
+ fill: string;
32
+ } | {
33
+ stops: string[];
34
+ };
35
+ export declare function alongRow(axis: WalkAxis, start: number, end: number): {
36
+ start: number;
37
+ end: number;
38
+ };
39
+ export declare function rowSpan(axis: WalkAxis, bp: number): {
40
+ start: number;
41
+ end: number;
42
+ };
43
+ export interface RowGene {
44
+ name: string;
45
+ start: number;
46
+ end: number;
47
+ exons: {
48
+ start: number;
49
+ end: number;
50
+ }[];
51
+ }
52
+ export declare function placeRowGenes(rows: WalkRow[], byRow: Map<string, GeneModel[]>): Map<string, RowGene[]>;
53
+ export interface GeneBox {
54
+ name: string;
55
+ x: number;
56
+ y: number;
57
+ w: number;
58
+ h: number;
59
+ exons: {
60
+ x: number;
61
+ w: number;
62
+ }[];
63
+ label?: {
64
+ x: number;
65
+ y: number;
66
+ size: number;
67
+ };
68
+ }
69
+ export declare function rowGeneBoxes(genes: RowGene[], X: (offset: number) => number, y: number): GeneBox[];
70
+ export type KeySwatch = {
71
+ kind: 'bar';
72
+ fill: string;
73
+ } | {
74
+ kind: 'gap';
75
+ fill: string;
76
+ } | {
77
+ kind: 'gene';
78
+ };
79
+ export interface KeyEntry {
80
+ swatch: KeySwatch;
81
+ label: string;
82
+ note?: true;
83
+ }
84
+ export interface GeneGaps {
85
+ untracked: number;
86
+ unplaced?: number;
87
+ unread: number;
88
+ }
89
+ export declare function walkRowsKey(bars: WalkRows, o?: {
90
+ ramp?: {
91
+ start: number;
92
+ end: number;
93
+ };
94
+ rampCss?: string;
95
+ genes?: GeneGaps;
96
+ }): KeyEntry[];
97
+ export type WalkRowsWithCalls = Omit<WalkRows, 'reference' | 'rows'> & {
98
+ reference: WalkRow & {
99
+ call?: ReadoutCall;
100
+ };
101
+ rows: (WalkRow & {
102
+ call?: ReadoutCall;
103
+ })[];
104
+ };
105
+ export declare const DISAGREES = "#c62828";
106
+ export declare function walkRowsKeyTree(entries: KeyEntry[], x: number, y: number): {
107
+ width: number;
108
+ tree: El;
109
+ };
110
+ export interface WalkRowsFrame {
111
+ scaleX: number;
112
+ scaleY: number;
113
+ translateX: number;
114
+ translateY: number;
115
+ width: number;
116
+ height: number;
117
+ }
118
+ export declare function walkRowsTree(bars: WalkRowsWithCalls, frame: WalkRowsFrame, o?: {
119
+ ramp?: {
120
+ start: number;
121
+ end: number;
122
+ };
123
+ rowGenes?: Map<string, RowGene[]>;
124
+ idPrefix?: string;
125
+ }): El;
@@ -7,6 +7,11 @@ export interface WalkRun {
7
7
  reversed?: true;
8
8
  gap?: true;
9
9
  }
10
+ export interface WalkAxis {
11
+ contig: string;
12
+ start: number;
13
+ reversed: boolean;
14
+ }
10
15
  export interface WalkRow {
11
16
  name: string;
12
17
  label: string;
@@ -17,6 +22,7 @@ export interface WalkRow {
17
22
  gapBp: number;
18
23
  complete: boolean;
19
24
  runs: WalkRun[];
25
+ axis?: WalkAxis;
20
26
  }
21
27
  export interface WalkRows {
22
28
  origin: number;
@@ -42,7 +42,7 @@ export declare const LAYOUT_MODES: readonly [{
42
42
  }, {
43
43
  readonly value: "walkrows";
44
44
  readonly label: "Walk rows";
45
- readonly description: "x is each walk's own bp: one bar per haplotype, sequence the reference also carries in blue and sequence it does not in purple, so a repeat expansion reads as bar length. Needs W or P lines.";
45
+ readonly description: "x is each walk's own bp: one bar per haplotype, blue where the graph aligns it to the reference and purple where it does not, so a repeat expansion reads as bar length, and each bar boxes its haplotype's own genes where the session has them. Needs W or P lines.";
46
46
  readonly run: typeof walkRowLayout;
47
47
  readonly cutMargins: false;
48
48
  readonly wholeWalks: true;
@@ -116,7 +116,7 @@ export declare function layoutModeByValue(value: string): {
116
116
  } | {
117
117
  readonly value: "walkrows";
118
118
  readonly label: "Walk rows";
119
- readonly description: "x is each walk's own bp: one bar per haplotype, sequence the reference also carries in blue and sequence it does not in purple, so a repeat expansion reads as bar length. Needs W or P lines.";
119
+ readonly description: "x is each walk's own bp: one bar per haplotype, blue where the graph aligns it to the reference and purple where it does not, so a repeat expansion reads as bar length, and each bar boxes its haplotype's own genes where the session has them. Needs W or P lines.";
120
120
  readonly run: typeof walkRowLayout;
121
121
  readonly cutMargins: false;
122
122
  readonly wholeWalks: true;
@@ -0,0 +1,14 @@
1
+ export declare function rampHueCss(hue: number): string;
2
+ export declare function rampHue(bp: number, domain: {
3
+ start: number;
4
+ end: number;
5
+ }): number;
6
+ export declare function rampStops({ start, bp, reversed }: {
7
+ start: number;
8
+ bp: number;
9
+ reversed?: boolean;
10
+ }, domain: {
11
+ start: number;
12
+ end: number;
13
+ }): number[];
14
+ export declare const RAMP_GRADIENT_CSS: string;
@@ -1 +1 @@
1
- export declare const version = "4.0.30";
1
+ export declare const version = "4.1.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/bandage-core",
3
- "version": "4.0.30",
3
+ "version": "4.1.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": {
@@ -31,7 +31,7 @@
31
31
  "dist"
32
32
  ],
33
33
  "dependencies": {
34
- "@gmod/gbz-base": "^5.0.0",
34
+ "@gmod/gbz-base": "^6.0.1",
35
35
  "@gmod/tabix": "^3.9.0",
36
36
  "@gmod/tubemap-core": "^0.1.0",
37
37
  "@jbrowse/core": "5.0.0-beta.9",