@jbrowse/bandage-core 4.5.0 → 4.7.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.
- package/dist/chunks/{chunk-7KQ2IWLP.js → chunk-NUCLM4VR.js} +37 -14
- package/dist/cli/figure.js +24 -4
- package/dist/index.js +5 -1
- package/dist/types/cli/figure.d.ts +1 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/layout/walkRowDraw.d.ts +3 -1
- package/dist/types/layout/walkRows.d.ts +4 -0
- package/dist/types/referenceRampCss.d.ts +4 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -2212,6 +2212,11 @@ function sliceBetween(steps, span, region, flanked = true) {
|
|
|
2212
2212
|
to: i1
|
|
2213
2213
|
};
|
|
2214
2214
|
}
|
|
2215
|
+
function filterSamples(rows, samples) {
|
|
2216
|
+
return samples ? rows.filter((r) => samples.includes(r.sample)).sort(
|
|
2217
|
+
(a, b) => samples.indexOf(a.sample) - samples.indexOf(b.sample) || a.label.localeCompare(b.label)
|
|
2218
|
+
) : rows;
|
|
2219
|
+
}
|
|
2215
2220
|
function walkRows(graph, region, unit) {
|
|
2216
2221
|
const paths = graph.paths ?? [];
|
|
2217
2222
|
const isReference2 = (p) => pathOrigin(p.name).name === graph.referencePath;
|
|
@@ -4986,9 +4991,12 @@ function rampStops({ start, bp, reversed }, domain) {
|
|
|
4986
4991
|
(_, i) => rampHue(start + bp * (reversed ? n2 - i : i) / n2, domain)
|
|
4987
4992
|
);
|
|
4988
4993
|
}
|
|
4989
|
-
var
|
|
4990
|
-
|
|
4991
|
-
|
|
4994
|
+
var RAMP_GRADIENT_STOPS = Array.from({ length: 7 }, (_, i) => ({
|
|
4995
|
+
offset: i / 6,
|
|
4996
|
+
color: rampHueCss(i / 6 * REFERENCE_RAMP_MAX_HUE)
|
|
4997
|
+
}));
|
|
4998
|
+
var RAMP_GRADIENT_CSS = `linear-gradient(to right, ${RAMP_GRADIENT_STOPS.map(
|
|
4999
|
+
(s) => `${s.color} ${s.offset * 100}%`
|
|
4992
5000
|
).join(", ")})`;
|
|
4993
5001
|
|
|
4994
5002
|
// src/layout/walkRowDraw.ts
|
|
@@ -5050,6 +5058,12 @@ function alongRow(axis, start, end) {
|
|
|
5050
5058
|
function rowSpan(axis, bp) {
|
|
5051
5059
|
return axis.reversed ? { start: axis.start - bp, end: axis.start } : { start: axis.start, end: axis.start + bp };
|
|
5052
5060
|
}
|
|
5061
|
+
function genesOnRow(row, genes) {
|
|
5062
|
+
const contig = row.axis?.contig;
|
|
5063
|
+
return genes.filter(
|
|
5064
|
+
(g) => g.refName === contig || g.refName.endsWith(`#${contig}`)
|
|
5065
|
+
);
|
|
5066
|
+
}
|
|
5053
5067
|
function placeRowGenes(rows, byRow) {
|
|
5054
5068
|
const placed = /* @__PURE__ */ new Map();
|
|
5055
5069
|
for (const row of rows) {
|
|
@@ -5122,10 +5136,7 @@ var rowsText = (n2) => `${n2} row${n2 === 1 ? "" : "s"}`;
|
|
|
5122
5136
|
function walkRowsKey(bars, o = {}) {
|
|
5123
5137
|
const entries = [
|
|
5124
5138
|
{
|
|
5125
|
-
swatch: {
|
|
5126
|
-
kind: "bar",
|
|
5127
|
-
fill: o.ramp ? o.rampCss ?? ON_REFERENCE : ON_REFERENCE
|
|
5128
|
-
},
|
|
5139
|
+
swatch: o.ramp ? { kind: "bar", fill: o.rampCss ?? RAMP_GRADIENT_CSS, ramp: true } : { kind: "bar", fill: ON_REFERENCE },
|
|
5129
5140
|
label: `on ${bars.reference.label}'s path`
|
|
5130
5141
|
},
|
|
5131
5142
|
{
|
|
@@ -5180,9 +5191,17 @@ function walkRowsKey(bars, o = {}) {
|
|
|
5180
5191
|
var CALL_TICK = "#111";
|
|
5181
5192
|
var UNBACKED_TICK = "#9e9e9e";
|
|
5182
5193
|
var DISAGREES = "#c62828";
|
|
5183
|
-
function walkRowsKeyTree(entries, x, y) {
|
|
5194
|
+
function walkRowsKeyTree(entries, x, y, idPrefix = "walk-key") {
|
|
5184
5195
|
let at = 0;
|
|
5185
|
-
const parts = entries.flatMap((e) => {
|
|
5196
|
+
const parts = entries.flatMap((e, i) => {
|
|
5197
|
+
const rampId = `${idPrefix}-ramp-${i}`;
|
|
5198
|
+
const ramp = !e.note && e.swatch.kind === "bar" && e.swatch.ramp ? el(
|
|
5199
|
+
"linearGradient",
|
|
5200
|
+
{ id: rampId },
|
|
5201
|
+
...RAMP_GRADIENT_STOPS.map(
|
|
5202
|
+
(s) => el("stop", { offset: s.offset, "stop-color": s.color })
|
|
5203
|
+
)
|
|
5204
|
+
) : void 0;
|
|
5186
5205
|
const swatch = e.note ? void 0 : e.swatch.kind === "gene" ? el("rect", {
|
|
5187
5206
|
x: at,
|
|
5188
5207
|
y: 5,
|
|
@@ -5197,7 +5216,7 @@ function walkRowsKeyTree(entries, x, y) {
|
|
|
5197
5216
|
width: 18,
|
|
5198
5217
|
height: e.swatch.kind === "gap" ? GAP_PX : 8,
|
|
5199
5218
|
rx: 2,
|
|
5200
|
-
fill: e.swatch.fill
|
|
5219
|
+
fill: ramp ? `url(#${rampId})` : e.swatch.fill
|
|
5201
5220
|
});
|
|
5202
5221
|
const text = el(
|
|
5203
5222
|
"text",
|
|
@@ -5210,7 +5229,7 @@ function walkRowsKeyTree(entries, x, y) {
|
|
|
5210
5229
|
e.label
|
|
5211
5230
|
);
|
|
5212
5231
|
at += (e.note ? 0 : 23) + e.label.length * LABEL_CHAR_PX + 16;
|
|
5213
|
-
return
|
|
5232
|
+
return [ramp, swatch, text].filter((p) => p !== void 0);
|
|
5214
5233
|
});
|
|
5215
5234
|
return {
|
|
5216
5235
|
width: at,
|
|
@@ -5703,7 +5722,7 @@ function svgCanvas(width, height) {
|
|
|
5703
5722
|
}
|
|
5704
5723
|
|
|
5705
5724
|
// src/version.ts
|
|
5706
|
-
var version = "4.
|
|
5725
|
+
var version = "4.7.0";
|
|
5707
5726
|
|
|
5708
5727
|
// src/viewport.ts
|
|
5709
5728
|
function axisScaleOf(scale, pixelRows) {
|
|
@@ -6006,7 +6025,8 @@ function figureSvg(graph, layout, o = {}) {
|
|
|
6006
6025
|
genes: o.rowGenes?.size ? o.rowGeneGaps : void 0
|
|
6007
6026
|
}),
|
|
6008
6027
|
x,
|
|
6009
|
-
2
|
|
6028
|
+
2,
|
|
6029
|
+
"rows-key"
|
|
6010
6030
|
);
|
|
6011
6031
|
push({ width: key.width, markup: serializeEl(key.tree) });
|
|
6012
6032
|
} else if (!lift && referenceRamp) {
|
|
@@ -6047,7 +6067,8 @@ function figureSvg(graph, layout, o = {}) {
|
|
|
6047
6067
|
genes: stripGeneGaps(frame, strip.rowGenes, strip.rowGeneGaps)
|
|
6048
6068
|
}),
|
|
6049
6069
|
6,
|
|
6050
|
-
height + frame.height
|
|
6070
|
+
height + frame.height,
|
|
6071
|
+
"strip-key"
|
|
6051
6072
|
);
|
|
6052
6073
|
parts.push(
|
|
6053
6074
|
`<line x1="0" x2="${width}" y1="${height + 0.5}" y2="${height + 0.5}" stroke="#ddd"/>`,
|
|
@@ -6695,6 +6716,7 @@ export {
|
|
|
6695
6716
|
formatBp,
|
|
6696
6717
|
pathColorsLegible,
|
|
6697
6718
|
pathLegend,
|
|
6719
|
+
filterSamples,
|
|
6698
6720
|
walkRows,
|
|
6699
6721
|
walkRowsExtent,
|
|
6700
6722
|
FORCE_LAYOUT_LABEL,
|
|
@@ -6757,6 +6779,7 @@ export {
|
|
|
6757
6779
|
runPaint,
|
|
6758
6780
|
alongRow,
|
|
6759
6781
|
rowSpan,
|
|
6782
|
+
genesOnRow,
|
|
6760
6783
|
placeRowGenes,
|
|
6761
6784
|
rowGeneBoxes,
|
|
6762
6785
|
walkRowsKey,
|
package/dist/cli/figure.js
CHANGED
|
@@ -5,10 +5,12 @@ import {
|
|
|
5
5
|
cutGbzRegion,
|
|
6
6
|
featuresOnBackbone,
|
|
7
7
|
figureSvg,
|
|
8
|
+
filterSamples,
|
|
8
9
|
forceLayout,
|
|
9
10
|
genesFromBed,
|
|
10
11
|
genesFromGff3Lines,
|
|
11
12
|
genesFromText,
|
|
13
|
+
genesOnRow,
|
|
12
14
|
graphBackbone,
|
|
13
15
|
haplotypeIndexBeside,
|
|
14
16
|
layoutModeByValue,
|
|
@@ -16,9 +18,10 @@ import {
|
|
|
16
18
|
loadGraph,
|
|
17
19
|
openGbz,
|
|
18
20
|
parseRegion,
|
|
21
|
+
placeRowGenes,
|
|
19
22
|
refNameBinding,
|
|
20
23
|
walkRows
|
|
21
|
-
} from "../chunks/chunk-
|
|
24
|
+
} from "../chunks/chunk-NUCLM4VR.js";
|
|
22
25
|
|
|
23
26
|
// src/cli/figure.ts
|
|
24
27
|
import { access, open, readFile, writeFile } from "node:fs/promises";
|
|
@@ -172,13 +175,30 @@ async function renderSpec(spec, base) {
|
|
|
172
175
|
},
|
|
173
176
|
engine
|
|
174
177
|
)).result;
|
|
175
|
-
const
|
|
178
|
+
const bars = spec.walkStrip ? walkRows(graph, source.region) : void 0;
|
|
179
|
+
const stripRows = bars && {
|
|
180
|
+
...bars,
|
|
181
|
+
rows: filterSamples(bars.rows, spec.walkRowSamples)
|
|
182
|
+
};
|
|
183
|
+
const genes = spec.genes ? await readGenes(spec.genes, graph, resolve) : void 0;
|
|
184
|
+
const reference = stripRows?.reference;
|
|
185
|
+
const rowGenes = reference && genes?.length ? placeRowGenes(
|
|
186
|
+
[reference],
|
|
187
|
+
/* @__PURE__ */ new Map([[reference.name, genesOnRow(reference, genes)]])
|
|
188
|
+
) : void 0;
|
|
176
189
|
return figureSvg(graph, layout, {
|
|
177
190
|
...spec,
|
|
178
|
-
walkStrip: stripRows && {
|
|
191
|
+
walkStrip: stripRows && {
|
|
192
|
+
rows: stripRows,
|
|
193
|
+
rowGenes,
|
|
194
|
+
rowGeneGaps: rowGenes && {
|
|
195
|
+
untracked: stripRows.rows.length,
|
|
196
|
+
unread: 0
|
|
197
|
+
}
|
|
198
|
+
},
|
|
179
199
|
walks: spec.walks?.map((w) => typeof w === "string" ? { walk: w } : w),
|
|
180
200
|
region: source.region,
|
|
181
|
-
genes
|
|
201
|
+
genes,
|
|
182
202
|
spec
|
|
183
203
|
});
|
|
184
204
|
}
|
package/dist/index.js
CHANGED
|
@@ -58,6 +58,7 @@ import {
|
|
|
58
58
|
facetSettingOf,
|
|
59
59
|
featuresOnBackbone,
|
|
60
60
|
figureSvg,
|
|
61
|
+
filterSamples,
|
|
61
62
|
fitTransform,
|
|
62
63
|
forceLayout,
|
|
63
64
|
formatBp,
|
|
@@ -66,6 +67,7 @@ import {
|
|
|
66
67
|
genesFromBed,
|
|
67
68
|
genesFromGff3Lines,
|
|
68
69
|
genesFromText,
|
|
70
|
+
genesOnRow,
|
|
69
71
|
getNodeColor,
|
|
70
72
|
graphBackbone,
|
|
71
73
|
haplotypeWanted,
|
|
@@ -136,7 +138,7 @@ import {
|
|
|
136
138
|
wellKnownSample,
|
|
137
139
|
yToXOf,
|
|
138
140
|
zoomAbout
|
|
139
|
-
} from "./chunks/chunk-
|
|
141
|
+
} from "./chunks/chunk-NUCLM4VR.js";
|
|
140
142
|
|
|
141
143
|
// src/index.ts
|
|
142
144
|
import { getDpr } from "@jbrowse/render-core/canvas2dUtils";
|
|
@@ -1854,6 +1856,7 @@ export {
|
|
|
1854
1856
|
facetSettingOf,
|
|
1855
1857
|
featuresOnBackbone,
|
|
1856
1858
|
figureSvg,
|
|
1859
|
+
filterSamples,
|
|
1857
1860
|
findHoveredEdge,
|
|
1858
1861
|
findHoveredNode,
|
|
1859
1862
|
fitTransform,
|
|
@@ -1864,6 +1867,7 @@ export {
|
|
|
1864
1867
|
genesFromBed,
|
|
1865
1868
|
genesFromGff3Lines,
|
|
1866
1869
|
genesFromText,
|
|
1870
|
+
genesOnRow,
|
|
1867
1871
|
getDpr,
|
|
1868
1872
|
graphBackbone,
|
|
1869
1873
|
haplotypeWanted,
|
package/dist/types/index.d.ts
CHANGED
|
@@ -54,9 +54,9 @@ export type { BubbleHalo } from './bubbles/bubbleHalos.js';
|
|
|
54
54
|
export { BUBBLE_KIND_COLORS, BUBBLE_KIND_NAMES, bubbleSegmentIds, classifyBubble, } from './bubbles/classifyBubble.js';
|
|
55
55
|
export { bubbleSubgraph } from './bubbles/popBubble.js';
|
|
56
56
|
export type { MinigraphBubble } from './bubbles/bubbleLine.js';
|
|
57
|
-
export { walkRows } from './layout/walkRows.js';
|
|
57
|
+
export { filterSamples, walkRows } from './layout/walkRows.js';
|
|
58
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, coalesceRuns, placeRowGenes, readoutPlacement, rowGeneBoxes, rowSpan, runPaint, unitTicks, walkRowReadout, walkRowsKey, walkRowsKeyTree, walkRowsTree, } from './layout/walkRowDraw.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, coalesceRuns, genesOnRow, placeRowGenes, readoutPlacement, rowGeneBoxes, rowSpan, runPaint, unitTicks, walkRowReadout, walkRowsKey, walkRowsKeyTree, walkRowsTree, } from './layout/walkRowDraw.js';
|
|
60
60
|
export type { GeneBox, GeneGaps, KeyEntry, KeySwatch, ReadoutCall, RowGene, WalkRowsFrame, WalkRowsWithCalls, } from './layout/walkRowDraw.js';
|
|
61
61
|
export { LABELLED_ROW_PX, WALK_STRIP_CEILING_PX, segmentAt, stripGeneGaps, stripMarks, stripRowAt, walkMarksTree, walkStripFrame, walkStripLabelsTree, } from './layout/walkStrip.js';
|
|
62
62
|
export type { StripFrame, StripMark } from './layout/walkStrip.js';
|
|
@@ -49,6 +49,7 @@ export interface RowGene {
|
|
|
49
49
|
end: number;
|
|
50
50
|
}[];
|
|
51
51
|
}
|
|
52
|
+
export declare function genesOnRow(row: WalkRow, genes: GeneModel[]): GeneModel[];
|
|
52
53
|
export declare function placeRowGenes(rows: WalkRow[], byRow: Map<string, GeneModel[]>): Map<string, RowGene[]>;
|
|
53
54
|
export declare function boxesGenes(rowPx: number, barPx: number): boolean;
|
|
54
55
|
export interface GeneBox {
|
|
@@ -74,6 +75,7 @@ export declare function rowGeneBoxes(genes: RowGene[], X: (offset: number) => nu
|
|
|
74
75
|
export type KeySwatch = {
|
|
75
76
|
kind: 'bar';
|
|
76
77
|
fill: string;
|
|
78
|
+
ramp?: true;
|
|
77
79
|
} | {
|
|
78
80
|
kind: 'gap';
|
|
79
81
|
fill: string;
|
|
@@ -108,7 +110,7 @@ export type WalkRowsWithCalls = Omit<WalkRows, 'reference' | 'rows'> & {
|
|
|
108
110
|
})[];
|
|
109
111
|
};
|
|
110
112
|
export declare const DISAGREES = "#c62828";
|
|
111
|
-
export declare function walkRowsKeyTree(entries: KeyEntry[], x: number, y: number): {
|
|
113
|
+
export declare function walkRowsKeyTree(entries: KeyEntry[], x: number, y: number, idPrefix?: string): {
|
|
112
114
|
width: number;
|
|
113
115
|
tree: El;
|
|
114
116
|
};
|
|
@@ -30,6 +30,10 @@ export interface WalkRows {
|
|
|
30
30
|
reference: WalkRow;
|
|
31
31
|
rows: WalkRow[];
|
|
32
32
|
}
|
|
33
|
+
export declare function filterSamples<R extends {
|
|
34
|
+
sample: string;
|
|
35
|
+
label: string;
|
|
36
|
+
}>(rows: R[], samples: string[] | undefined): R[];
|
|
33
37
|
export declare function walkRows(graph: Graph, region?: {
|
|
34
38
|
start: number;
|
|
35
39
|
end: number;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "4.
|
|
1
|
+
export declare const version = "4.7.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/bandage-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.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": {
|