@jbrowse/bandage-core 0.1.17 → 0.1.18
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 +4 -2
- package/dist/index.js +102 -15
- package/dist/types/facetGrid.d.ts +21 -0
- package/dist/types/index.d.ts +5 -2
- package/dist/types/walkEncoding.d.ts +0 -5
- package/dist/types/walkHighlight.d.ts +1 -0
- package/dist/types/walkKey.d.ts +12 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,11 +9,13 @@ npm install @jbrowse/bandage-core
|
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
- GFA and rGFA text in (`loadGraph`)
|
|
12
|
-
- Layouts: Bandage's FMMM engine as WASM (`loadBandage`, `forceLayout`),
|
|
13
|
-
|
|
12
|
+
- Layouts: Bandage's FMMM engine as WASM (`loadBandage`, `forceLayout`),
|
|
13
|
+
ordered, anchored, sample rows, walk rows, tube map
|
|
14
14
|
- A Canvas2D renderer (`buildGeometry`, `Canvas2DRenderer`), hit testing and
|
|
15
15
|
label placement
|
|
16
16
|
- Bubbles, deletion edges, path colors, gbz-base windows cut to GFA
|
|
17
|
+
- Walks lifted out of the drawing (`walkLift`), one facet panel per walk
|
|
18
|
+
(`facetLifts`, `facetGrid`) and each walk's key in words (`walkKey`)
|
|
17
19
|
- Which assembly a backbone lies on (`graphBackbone`, `backboneAssembly`,
|
|
18
20
|
`assemblyWalk`), and the genes on it: `featuresOnBackbone` renames an
|
|
19
21
|
assembly's genes onto the backbone's refNames, and `genePins` pins only those
|
package/dist/index.js
CHANGED
|
@@ -5251,17 +5251,9 @@ function drawTubeMapConnectors(ctx, connectors, bottom, {
|
|
|
5251
5251
|
// src/walkEncoding.ts
|
|
5252
5252
|
import { packAbgr as packAbgr3 } from "@jbrowse/core/util/colorBits";
|
|
5253
5253
|
var WALK_FIELDS = [
|
|
5254
|
-
{
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
legend: "light where each walk starts, dark where it ends"
|
|
5258
|
-
},
|
|
5259
|
-
{ value: "walk", label: "One colour for the walk", legend: "" },
|
|
5260
|
-
{
|
|
5261
|
-
value: "reference",
|
|
5262
|
-
label: "Reference position",
|
|
5263
|
-
legend: "along the reference left to right, charcoal off it"
|
|
5264
|
-
}
|
|
5254
|
+
{ value: "progress", label: "Progress along the walk" },
|
|
5255
|
+
{ value: "walk", label: "One colour for the walk" },
|
|
5256
|
+
{ value: "reference", label: "Reference position" }
|
|
5265
5257
|
];
|
|
5266
5258
|
var WALK_SCHEMES = [
|
|
5267
5259
|
{ value: "grey", label: "Grey to black", ends: ["#a3a3a3", "#151515"] },
|
|
@@ -5339,9 +5331,6 @@ function encodingSwatchCss({ field, scheme }) {
|
|
|
5339
5331
|
});
|
|
5340
5332
|
return `linear-gradient(to right, ${stops.join(", ")})`;
|
|
5341
5333
|
}
|
|
5342
|
-
function fieldLegend(field) {
|
|
5343
|
-
return WALK_FIELDS.find((f) => f.value === field).legend;
|
|
5344
|
-
}
|
|
5345
5334
|
|
|
5346
5335
|
// src/walkHighlight.ts
|
|
5347
5336
|
function referenceOf(graph) {
|
|
@@ -5455,6 +5444,30 @@ function walkLift(graph, layers, ramp) {
|
|
|
5455
5444
|
reversedBp: bp
|
|
5456
5445
|
};
|
|
5457
5446
|
});
|
|
5447
|
+
return liftOf(walks, ramp);
|
|
5448
|
+
}
|
|
5449
|
+
var FACET_COLOR = { field: "progress", scheme: "red" };
|
|
5450
|
+
function facetLifts(graph, lift, layers, ramp) {
|
|
5451
|
+
return lift.walks.map((walk) => {
|
|
5452
|
+
const stated = layers.find((l) => l.walk === walk.name)?.color;
|
|
5453
|
+
const encoding = resolveEncoding(
|
|
5454
|
+
{ walk: walk.name, color: { ...FACET_COLOR, ...stated } },
|
|
5455
|
+
walk.reference,
|
|
5456
|
+
0
|
|
5457
|
+
);
|
|
5458
|
+
return liftOf(
|
|
5459
|
+
[
|
|
5460
|
+
{
|
|
5461
|
+
...walk,
|
|
5462
|
+
encoding,
|
|
5463
|
+
colors: laneColors(graph, walk, encoding, ramp)
|
|
5464
|
+
}
|
|
5465
|
+
],
|
|
5466
|
+
ramp
|
|
5467
|
+
);
|
|
5468
|
+
});
|
|
5469
|
+
}
|
|
5470
|
+
function liftOf(walks, ramp) {
|
|
5458
5471
|
return {
|
|
5459
5472
|
walks,
|
|
5460
5473
|
referenceDomain: ramp ? { start: ramp.start, end: ramp.start + ramp.span } : void 0,
|
|
@@ -5464,6 +5477,75 @@ function walkLift(graph, layers, ramp) {
|
|
|
5464
5477
|
};
|
|
5465
5478
|
}
|
|
5466
5479
|
|
|
5480
|
+
// src/walkKey.ts
|
|
5481
|
+
function rangeText(contig, start, end) {
|
|
5482
|
+
const s = Math.round(start);
|
|
5483
|
+
const e = Math.round(end);
|
|
5484
|
+
return `${contig ? `${contig}:` : ""}${s.toLocaleString()}-${e.toLocaleString()} (${formatBp(e - s)})`;
|
|
5485
|
+
}
|
|
5486
|
+
function walkKey(walk, reference) {
|
|
5487
|
+
const { field } = walk.encoding;
|
|
5488
|
+
const own = walk.range ? rangeText(walk.range.contig, walk.range.start, walk.range.end) : void 0;
|
|
5489
|
+
const scale = field === "progress" ? own : field === "reference" && reference ? rangeText(reference.name, reference.start, reference.end) : void 0;
|
|
5490
|
+
return {
|
|
5491
|
+
delta: walk.referenceBp === void 0 || walk.bp === walk.referenceBp ? "" : ` ${walk.bp > walk.referenceBp ? "+" : "\u2212"}${formatBp(Math.abs(walk.bp - walk.referenceBp))}`,
|
|
5492
|
+
reversed: walk.reversedBp > 0 ? `, ${formatBp(walk.reversedBp)} reversed` : "",
|
|
5493
|
+
shades: field !== "walk",
|
|
5494
|
+
scale,
|
|
5495
|
+
hover: scale === own ? void 0 : own
|
|
5496
|
+
};
|
|
5497
|
+
}
|
|
5498
|
+
|
|
5499
|
+
// src/facetGrid.ts
|
|
5500
|
+
var FACET_GAP_PX = 8;
|
|
5501
|
+
var FACET_TITLE_PX = 34;
|
|
5502
|
+
var FACET_PAD_PX = 12;
|
|
5503
|
+
var MIN_FACET_PANEL_PX = 60;
|
|
5504
|
+
function facetGrid({
|
|
5505
|
+
count,
|
|
5506
|
+
bounds,
|
|
5507
|
+
pixelRows,
|
|
5508
|
+
width,
|
|
5509
|
+
room,
|
|
5510
|
+
columns
|
|
5511
|
+
}) {
|
|
5512
|
+
function tile(across) {
|
|
5513
|
+
const rows = Math.ceil(count / across);
|
|
5514
|
+
const panelWidth = Math.floor(
|
|
5515
|
+
(width - (across - 1) * FACET_GAP_PX) / across
|
|
5516
|
+
);
|
|
5517
|
+
const panelRoom = (room - rows * FACET_TITLE_PX - (rows - 1) * FACET_GAP_PX) / rows;
|
|
5518
|
+
const fitX = (panelWidth - 2 * FACET_PAD_PX) / bounds.w;
|
|
5519
|
+
const fitY = bounds.h > 0 ? (panelRoom - 2 * FACET_PAD_PX) / bounds.h : Infinity;
|
|
5520
|
+
const scale = pixelRows ? fitX : Math.min(fitX, fitY);
|
|
5521
|
+
const drawn = pixelRows ? bounds.h : bounds.h * scale;
|
|
5522
|
+
const height = Math.floor(
|
|
5523
|
+
Math.max(
|
|
5524
|
+
MIN_FACET_PANEL_PX,
|
|
5525
|
+
Math.min(drawn + 2 * FACET_PAD_PX, panelRoom)
|
|
5526
|
+
)
|
|
5527
|
+
);
|
|
5528
|
+
return {
|
|
5529
|
+
columns: across,
|
|
5530
|
+
width: panelWidth,
|
|
5531
|
+
height,
|
|
5532
|
+
scale,
|
|
5533
|
+
total: rows * (height + FACET_TITLE_PX) + (rows - 1) * FACET_GAP_PX
|
|
5534
|
+
};
|
|
5535
|
+
}
|
|
5536
|
+
if (columns !== void 0) {
|
|
5537
|
+
return tile(Math.max(1, Math.min(count, Math.round(columns))));
|
|
5538
|
+
}
|
|
5539
|
+
let best = tile(1);
|
|
5540
|
+
for (let across = 2; across <= count; across++) {
|
|
5541
|
+
const grid = tile(across);
|
|
5542
|
+
if (grid.scale > best.scale) {
|
|
5543
|
+
best = grid;
|
|
5544
|
+
}
|
|
5545
|
+
}
|
|
5546
|
+
return best;
|
|
5547
|
+
}
|
|
5548
|
+
|
|
5467
5549
|
// src/bubbles/bubbleLine.ts
|
|
5468
5550
|
var SATURATED_PATH_COUNT = 2147483647;
|
|
5469
5551
|
|
|
@@ -6281,6 +6363,9 @@ export {
|
|
|
6281
6363
|
BUBBLE_SPREADS,
|
|
6282
6364
|
COLOR_SCHEMES,
|
|
6283
6365
|
Canvas2DRenderer,
|
|
6366
|
+
FACET_GAP_PX,
|
|
6367
|
+
FACET_PAD_PX,
|
|
6368
|
+
FACET_TITLE_PX,
|
|
6284
6369
|
FIT_PADDING,
|
|
6285
6370
|
FORCE_LAYOUT_LABEL,
|
|
6286
6371
|
HALO_FACTOR,
|
|
@@ -6320,8 +6405,9 @@ export {
|
|
|
6320
6405
|
encodingSwatchCss,
|
|
6321
6406
|
engineKey,
|
|
6322
6407
|
engineRequest,
|
|
6408
|
+
facetGrid,
|
|
6409
|
+
facetLifts,
|
|
6323
6410
|
featuresOnBackbone,
|
|
6324
|
-
fieldLegend,
|
|
6325
6411
|
findHoveredEdge,
|
|
6326
6412
|
findHoveredNode,
|
|
6327
6413
|
fitTransform,
|
|
@@ -6369,6 +6455,7 @@ export {
|
|
|
6369
6455
|
tubeX,
|
|
6370
6456
|
viewportOf,
|
|
6371
6457
|
walkHighlight,
|
|
6458
|
+
walkKey,
|
|
6372
6459
|
walkLift,
|
|
6373
6460
|
walkRows,
|
|
6374
6461
|
walkRowsExtent,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const FACET_GAP_PX = 8;
|
|
2
|
+
export declare const FACET_TITLE_PX = 34;
|
|
3
|
+
export declare const FACET_PAD_PX = 12;
|
|
4
|
+
export interface FacetGrid {
|
|
5
|
+
columns: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
scale: number;
|
|
9
|
+
total: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function facetGrid({ count, bounds, pixelRows, width, room, columns, }: {
|
|
12
|
+
count: number;
|
|
13
|
+
bounds: {
|
|
14
|
+
w: number;
|
|
15
|
+
h: number;
|
|
16
|
+
};
|
|
17
|
+
pixelRows: boolean;
|
|
18
|
+
width: number;
|
|
19
|
+
room: number;
|
|
20
|
+
columns?: number;
|
|
21
|
+
}): FacetGrid;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -32,9 +32,12 @@ export type { Connector, ReferenceNode } from './tubeMap/connectors.js';
|
|
|
32
32
|
export type { TubeMapColumn, TubeMapDrawing } from './layout/tubeMapLayout.js';
|
|
33
33
|
export { deletionEdges } from './deletionEdges.js';
|
|
34
34
|
export type { DeletionEdge } from './deletionEdges.js';
|
|
35
|
-
export { walkHighlight, walkLift } from './walkHighlight.js';
|
|
35
|
+
export { facetLifts, walkHighlight, walkLift } from './walkHighlight.js';
|
|
36
|
+
export { walkKey } from './walkKey.js';
|
|
37
|
+
export { FACET_GAP_PX, FACET_PAD_PX, FACET_TITLE_PX, facetGrid, } from './facetGrid.js';
|
|
38
|
+
export type { FacetGrid } from './facetGrid.js';
|
|
36
39
|
export type { LiftedWalk, WalkLift } from './walkHighlight.js';
|
|
37
|
-
export { WALK_FIELDS, WALK_SCHEMES, encodingSwatchCss,
|
|
40
|
+
export { WALK_FIELDS, WALK_SCHEMES, encodingSwatchCss, resolveEncoding, schemeCss, } from './walkEncoding.js';
|
|
38
41
|
export type { WalkEncoding, WalkField, WalkLayer, WalkScheme, } from './walkEncoding.js';
|
|
39
42
|
export { pathColorsLegible, pathLegend } from './pathColors.js';
|
|
40
43
|
export { bubblesFromGraph } from './bubbles/bubblesFromGraph.js';
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
export declare const WALK_FIELDS: readonly [{
|
|
2
2
|
readonly value: "progress";
|
|
3
3
|
readonly label: "Progress along the walk";
|
|
4
|
-
readonly legend: "light where each walk starts, dark where it ends";
|
|
5
4
|
}, {
|
|
6
5
|
readonly value: "walk";
|
|
7
6
|
readonly label: "One colour for the walk";
|
|
8
|
-
readonly legend: "";
|
|
9
7
|
}, {
|
|
10
8
|
readonly value: "reference";
|
|
11
9
|
readonly label: "Reference position";
|
|
12
|
-
readonly legend: "along the reference left to right, charcoal off it";
|
|
13
10
|
}];
|
|
14
11
|
export type WalkField = (typeof WALK_FIELDS)[number]['value'];
|
|
15
12
|
export declare const WALK_SCHEMES: readonly [{
|
|
@@ -51,6 +48,4 @@ export declare function schemeCss(scheme: WalkScheme, t: number): string;
|
|
|
51
48
|
export declare function schemeColor(scheme: WalkScheme, t: number): number;
|
|
52
49
|
export declare function encodedColor({ field, scheme }: WalkEncoding, t?: number): number;
|
|
53
50
|
export declare const NO_VALUE_COLOR: number;
|
|
54
|
-
export declare const NO_VALUE_CSS: string;
|
|
55
51
|
export declare function encodingSwatchCss({ field, scheme }: WalkEncoding): string;
|
|
56
|
-
export declare function fieldLegend(field: WalkField): "" | "light where each walk starts, dark where it ends" | "along the reference left to right, charcoal off it";
|
|
@@ -34,3 +34,4 @@ export interface WalkLift {
|
|
|
34
34
|
}
|
|
35
35
|
export declare function walkHighlight(graph: Graph, name: string): WalkHighlight | undefined;
|
|
36
36
|
export declare function walkLift(graph: Graph, layers: readonly WalkLayer[], ramp?: ReferenceRamp): WalkLift | undefined;
|
|
37
|
+
export declare function facetLifts(graph: Graph, lift: WalkLift, layers: readonly WalkLayer[], ramp?: ReferenceRamp): WalkLift[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LiftedWalk } from './walkHighlight.js';
|
|
2
|
+
export declare function walkKey(walk: LiftedWalk, reference?: {
|
|
3
|
+
name?: string;
|
|
4
|
+
start: number;
|
|
5
|
+
end: number;
|
|
6
|
+
}): {
|
|
7
|
+
delta: string;
|
|
8
|
+
reversed: string;
|
|
9
|
+
shades: boolean;
|
|
10
|
+
scale: string | undefined;
|
|
11
|
+
hover: string | undefined;
|
|
12
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/bandage-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
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": {
|