jbrowse-plugin-graphgenomeviewer 8.0.0 → 8.0.2
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/{AddTrackWorkflow-KT6Z6PSW.js → AddTrackWorkflow-RJSOQZYQ.js} +2 -2
- package/dist/chunks/{ChooseSamplesDialog-YUH6SVEZ.js → ChooseSamplesDialog-LO7FKFSS.js} +2 -2
- package/dist/chunks/{ChooseWalksDialog-2QJKRASB.js → ChooseWalksDialog-JJSOVCEU.js} +2 -2
- package/dist/chunks/{GbzBaseSyntenyAdapter-NPEXW3Z3.js → GbzBaseSyntenyAdapter-EGNUOKB2.js} +2 -2
- package/dist/chunks/{GbzBaseSyntenyAdapter-NPEXW3Z3.js.map → GbzBaseSyntenyAdapter-EGNUOKB2.js.map} +1 -1
- package/dist/chunks/{GraphGenomeView-5LYF6LMA.js → GraphGenomeView-667ZUNDI.js} +2 -2
- package/dist/chunks/{GraphTrackSettingsDialog-T5YKMIPH.js → GraphTrackSettingsDialog-7M3Q635V.js} +2 -2
- package/dist/chunks/{GraphTrackSettingsDialog-T5YKMIPH.js.map → GraphTrackSettingsDialog-7M3Q635V.js.map} +1 -1
- package/dist/chunks/{HighlightColorDialog-UGAQFACU.js → HighlightColorDialog-4F34Q4PY.js} +2 -2
- package/dist/chunks/LinearGraphDisplay-BAEMS5WG.js +2 -0
- package/dist/chunks/LinearGraphDisplay-BAEMS5WG.js.map +7 -0
- package/dist/chunks/{MinigraphBubbleAdapter-D57ZFMKV.js → MinigraphBubbleAdapter-G25V6MZL.js} +2 -2
- package/dist/chunks/{RgfaTabixAdapter-HN2NLJJW.js → RgfaTabixAdapter-JPTUWO2Z.js} +2 -2
- package/dist/chunks/{WalkFormsAdapter-ESCQSNEJ.js → WalkFormsAdapter-PBN7BJZW.js} +2 -2
- package/dist/chunks/{WalkTabixSyntenyAdapter-62PJZBRP.js → WalkTabixSyntenyAdapter-27WDE5JF.js} +2 -2
- package/dist/chunks/{chunk-SVLBMU6I.js → chunk-2PNGGCQJ.js} +2 -2
- package/dist/chunks/{chunk-SVLBMU6I.js.map → chunk-2PNGGCQJ.js.map} +1 -1
- package/dist/chunks/{chunk-2VKDQF54.js → chunk-2V75YPTT.js} +2 -2
- package/dist/chunks/{chunk-2VKDQF54.js.map → chunk-2V75YPTT.js.map} +3 -3
- package/dist/chunks/chunk-3EQNVA3F.js +4 -0
- package/dist/chunks/{chunk-H53NTUCD.js.map → chunk-3EQNVA3F.js.map} +4 -4
- package/dist/chunks/{chunk-ON465L7Z.js → chunk-5RHNR3TH.js} +1 -1
- package/dist/chunks/{chunk-ON465L7Z.js.map → chunk-5RHNR3TH.js.map} +1 -1
- package/dist/chunks/{chunk-LR45N54F.js → chunk-CBKSPAUI.js} +2 -2
- package/dist/chunks/{chunk-VCYF5E2N.js → chunk-CJAV55QB.js} +1 -1
- package/dist/chunks/{chunk-VCYF5E2N.js.map → chunk-CJAV55QB.js.map} +1 -1
- package/dist/chunks/{chunk-DKUKQR3S.js → chunk-DG3E6BSX.js} +2 -2
- package/dist/chunks/{chunk-ZKCMVSD4.js → chunk-FY7X6253.js} +2 -2
- package/dist/chunks/{chunk-ZKCMVSD4.js.map → chunk-FY7X6253.js.map} +1 -1
- package/dist/chunks/chunk-HLAQQI6G.js +2 -0
- package/dist/chunks/chunk-HLAQQI6G.js.map +7 -0
- package/dist/chunks/{chunk-NE3OW4WX.js → chunk-I6F25EXY.js} +2 -2
- package/dist/chunks/{chunk-QGLMVXGX.js → chunk-IAXUZMOX.js} +2 -2
- package/dist/chunks/{chunk-QGLMVXGX.js.map → chunk-IAXUZMOX.js.map} +1 -1
- package/dist/chunks/{chunk-56YYNIV3.js → chunk-JMRW3IGK.js} +2 -2
- package/dist/chunks/{chunk-56YYNIV3.js.map → chunk-JMRW3IGK.js.map} +1 -1
- package/dist/chunks/chunk-JOYKGTDE.js +4 -0
- package/dist/chunks/chunk-JOYKGTDE.js.map +7 -0
- package/dist/chunks/chunk-NIEZKWQV.js +2 -0
- package/dist/chunks/{chunk-YU7T5WOQ.js.map → chunk-NIEZKWQV.js.map} +2 -2
- package/dist/chunks/chunk-NLS74JSZ.js +2 -0
- package/dist/chunks/{chunk-26SCNTI3.js.map → chunk-NLS74JSZ.js.map} +1 -1
- package/dist/chunks/{chunk-A4YQH3PN.js → chunk-O5FDMVL3.js} +2 -2
- package/dist/chunks/chunk-Q7QC2EQU.js +2 -0
- package/dist/chunks/chunk-RHYBJCA4.js +2 -0
- package/dist/chunks/chunk-RHYBJCA4.js.map +7 -0
- package/dist/chunks/chunk-X7YIGIYW.js +2 -0
- package/dist/chunks/{chunk-YXN7J6LG.js.map → chunk-X7YIGIYW.js.map} +4 -4
- package/dist/chunks/chunk-XB5KC2EZ.js +2 -0
- package/dist/chunks/{chunk-JSWEU5QG.js.map → chunk-XB5KC2EZ.js.map} +2 -2
- package/dist/chunks/chunk-XWCLYB5C.js +2 -0
- package/dist/chunks/{chunk-KQ6JJDJC.js.map → chunk-XWCLYB5C.js.map} +4 -4
- package/dist/chunks/{chunk-SD7WGQ6Y.js → chunk-ZGTG74GE.js} +3 -3
- package/dist/chunks/{chunk-SD7WGQ6Y.js.map → chunk-ZGTG74GE.js.map} +2 -2
- package/dist/chunks/renderSvg-YNA5VK6A.js +2 -0
- package/dist/chunks/renderSvg-YNA5VK6A.js.map +7 -0
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +4 -4
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +4 -4
- package/package.json +2 -2
- package/src/GraphGenomeView/components/GraphCanvas.test.tsx +1 -1
- package/src/GraphGenomeView/components/GraphCanvas.tsx +66 -18
- package/src/GraphGenomeView/components/Legend.tsx +81 -34
- package/src/GraphGenomeView/components/LegendSwatch.tsx +13 -30
- package/src/GraphGenomeView/components/PaneSvg.tsx +79 -22
- package/src/GraphGenomeView/components/SettingsMenu.tsx +1 -1
- package/src/GraphGenomeView/components/legendStyles.ts +13 -1
- package/src/GraphGenomeView/legendSections.test.ts +131 -2
- package/src/GraphGenomeView/legendSections.ts +220 -42
- package/src/GraphGenomeView/model.test.ts +7 -8
- package/src/GraphGenomeView/pane/fitViews.ts +6 -57
- package/src/GraphGenomeView/pane/graphViews.ts +23 -1
- package/src/GraphGenomeView/pane/launchActions.ts +1 -1
- package/src/LinearGraphDisplay/LinearGraphDisplay.test.ts +19 -1
- package/src/LinearGraphDisplay/components/LinearGraphDisplay.tsx +6 -6
- package/src/LinearGraphDisplay/model.ts +9 -10
- package/src/RgfaTabixAdapter/walkFiles.test.ts +36 -0
- package/src/RgfaTabixAdapter/walkReader.ts +22 -7
- package/src/version.ts +1 -1
- package/dist/chunks/LinearGraphDisplay-YTSXFZED.js +0 -2
- package/dist/chunks/LinearGraphDisplay-YTSXFZED.js.map +0 -7
- package/dist/chunks/chunk-26SCNTI3.js +0 -2
- package/dist/chunks/chunk-AZ3YVI3P.js +0 -2
- package/dist/chunks/chunk-H53NTUCD.js +0 -4
- package/dist/chunks/chunk-JSWEU5QG.js +0 -2
- package/dist/chunks/chunk-JYTZO52E.js +0 -2
- package/dist/chunks/chunk-JYTZO52E.js.map +0 -7
- package/dist/chunks/chunk-KQ6JJDJC.js +0 -2
- package/dist/chunks/chunk-KUT6FNKO.js +0 -4
- package/dist/chunks/chunk-KUT6FNKO.js.map +0 -7
- package/dist/chunks/chunk-LJAPKX5Y.js +0 -2
- package/dist/chunks/chunk-LJAPKX5Y.js.map +0 -7
- package/dist/chunks/chunk-YU7T5WOQ.js +0 -2
- package/dist/chunks/chunk-YXN7J6LG.js +0 -2
- package/dist/chunks/renderSvg-3KAQCRFY.js +0 -2
- package/dist/chunks/renderSvg-3KAQCRFY.js.map +0 -7
- package/src/LinearGraphDisplay/components/GraphStatusChrome.test.tsx +0 -182
- package/src/LinearGraphDisplay/components/GraphStatusChrome.tsx +0 -158
- /package/dist/chunks/{AddTrackWorkflow-KT6Z6PSW.js.map → AddTrackWorkflow-RJSOQZYQ.js.map} +0 -0
- /package/dist/chunks/{ChooseSamplesDialog-YUH6SVEZ.js.map → ChooseSamplesDialog-LO7FKFSS.js.map} +0 -0
- /package/dist/chunks/{ChooseWalksDialog-2QJKRASB.js.map → ChooseWalksDialog-JJSOVCEU.js.map} +0 -0
- /package/dist/chunks/{GraphGenomeView-5LYF6LMA.js.map → GraphGenomeView-667ZUNDI.js.map} +0 -0
- /package/dist/chunks/{HighlightColorDialog-UGAQFACU.js.map → HighlightColorDialog-4F34Q4PY.js.map} +0 -0
- /package/dist/chunks/{MinigraphBubbleAdapter-D57ZFMKV.js.map → MinigraphBubbleAdapter-G25V6MZL.js.map} +0 -0
- /package/dist/chunks/{RgfaTabixAdapter-HN2NLJJW.js.map → RgfaTabixAdapter-JPTUWO2Z.js.map} +0 -0
- /package/dist/chunks/{WalkFormsAdapter-ESCQSNEJ.js.map → WalkFormsAdapter-PBN7BJZW.js.map} +0 -0
- /package/dist/chunks/{WalkTabixSyntenyAdapter-62PJZBRP.js.map → WalkTabixSyntenyAdapter-27WDE5JF.js.map} +0 -0
- /package/dist/chunks/{chunk-LR45N54F.js.map → chunk-CBKSPAUI.js.map} +0 -0
- /package/dist/chunks/{chunk-DKUKQR3S.js.map → chunk-DG3E6BSX.js.map} +0 -0
- /package/dist/chunks/{chunk-NE3OW4WX.js.map → chunk-I6F25EXY.js.map} +0 -0
- /package/dist/chunks/{chunk-A4YQH3PN.js.map → chunk-O5FDMVL3.js.map} +0 -0
- /package/dist/chunks/{chunk-AZ3YVI3P.js.map → chunk-Q7QC2EQU.js.map} +0 -0
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
legendSections,
|
|
3
|
+
rowPitch,
|
|
4
|
+
swatchHeight,
|
|
5
|
+
swatchWidth,
|
|
6
|
+
tubeMapRows,
|
|
7
|
+
} from './legendSections'
|
|
2
8
|
|
|
3
9
|
import type { GraphPaneModel } from './model'
|
|
4
10
|
|
|
@@ -47,5 +53,128 @@ test("the ramp key's bp read the same in every locale", () => {
|
|
|
47
53
|
}
|
|
48
54
|
const [ramp] = legendSections(model as unknown as GraphPaneModel)
|
|
49
55
|
german.mockRestore()
|
|
50
|
-
expect(ramp!.rows[0]!.
|
|
56
|
+
expect(ramp!.rows[0]!.under).toBe('1,000-123,457 (122 kb)')
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
function widthModel(over: Record<string, unknown>) {
|
|
60
|
+
return {
|
|
61
|
+
walkLift: undefined,
|
|
62
|
+
referenceRampDomain: undefined,
|
|
63
|
+
bubbleHalos: [],
|
|
64
|
+
genePins: [],
|
|
65
|
+
pathLegend: [],
|
|
66
|
+
tubeMapKeys: {},
|
|
67
|
+
deletions: [],
|
|
68
|
+
graph: {
|
|
69
|
+
nodes: [{ depth: 1 }, { depth: 26 }],
|
|
70
|
+
edges: [],
|
|
71
|
+
paths: Array.from({ length: 26 }, () => ({})),
|
|
72
|
+
},
|
|
73
|
+
drawsNodes: true,
|
|
74
|
+
walkRowBars: undefined,
|
|
75
|
+
nodeWidth: 'depth',
|
|
76
|
+
contigThickness: 6,
|
|
77
|
+
depthRange: { min: 1, max: 26, mean: 8 },
|
|
78
|
+
linkWidth: 'uniform',
|
|
79
|
+
connectorThickness: 2,
|
|
80
|
+
busiestLink: 26,
|
|
81
|
+
...over,
|
|
82
|
+
} as unknown as GraphPaneModel
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function widthLegend(
|
|
86
|
+
over: Record<string, unknown>,
|
|
87
|
+
testid = 'graph-width-legend',
|
|
88
|
+
) {
|
|
89
|
+
return legendSections(widthModel(over)).find(s => s.testid === testid)?.rows
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
test('the width key names what node thickness counts, thickest first', () => {
|
|
93
|
+
const rows = widthLegend({})!
|
|
94
|
+
expect(rows.map(r => r.label)).toEqual(['26 walks', '8 walks', '1 walk'])
|
|
95
|
+
const [thick, mean, thin] = rows.map(r => swatchHeight(r.swatch!))
|
|
96
|
+
expect(mean).toBe(6)
|
|
97
|
+
expect(thick).toBeGreaterThan(mean!)
|
|
98
|
+
expect(thin).toBeLessThan(mean!)
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
test('a walk count reads whole, and a mean that rounds onto an end is dropped', () => {
|
|
102
|
+
expect(
|
|
103
|
+
widthLegend({ depthRange: { min: 1, max: 3, mean: 1.9 } })!.map(
|
|
104
|
+
r => r.label,
|
|
105
|
+
),
|
|
106
|
+
).toEqual(['3 walks', '2 walks', '1 walk'])
|
|
107
|
+
expect(
|
|
108
|
+
widthLegend({ depthRange: { min: 1, max: 3, mean: 1.2 } })!.map(
|
|
109
|
+
r => r.label,
|
|
110
|
+
),
|
|
111
|
+
).toEqual(['3 walks', '1 walk'])
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
test('a node a walk loops through keys passes, not walks', () => {
|
|
115
|
+
const looped = { nodes: [], edges: [], paths: [{}, {}, {}] }
|
|
116
|
+
expect(
|
|
117
|
+
widthLegend({
|
|
118
|
+
graph: looped,
|
|
119
|
+
depthRange: { min: 1, max: 9, mean: 3 },
|
|
120
|
+
})!.map(r => r.label),
|
|
121
|
+
).toEqual(['9 walk passes', '3 walk passes', '1 walk pass'])
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
test('colour keys are square chips, unlike the thickness bars', () => {
|
|
125
|
+
const model = {
|
|
126
|
+
walkLift: undefined,
|
|
127
|
+
graph: undefined,
|
|
128
|
+
referenceRampDomain: { start: 0, end: 1000 },
|
|
129
|
+
referenceRampDrawsOffReference: true,
|
|
130
|
+
bubbleHalos: [],
|
|
131
|
+
genePins: [],
|
|
132
|
+
pathLegend: [],
|
|
133
|
+
tubeMapKeys: {},
|
|
134
|
+
}
|
|
135
|
+
const [ramp] = legendSections(model as unknown as GraphPaneModel)
|
|
136
|
+
const off = ramp!.rows.find(r => r.key === 'off')!.swatch!
|
|
137
|
+
expect(swatchWidth(off)).toBe(swatchHeight(off))
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
test('a frequency width keys shares of haplotypes, or AF where tagged', () => {
|
|
141
|
+
expect(widthLegend({ nodeWidth: 'frequency' })!.map(r => r.label)).toEqual([
|
|
142
|
+
'100% of haplotypes',
|
|
143
|
+
'50% of haplotypes',
|
|
144
|
+
'10% of haplotypes',
|
|
145
|
+
])
|
|
146
|
+
const tagged = { nodes: [{ depth: 1, frequency: 0.4 }], edges: [] }
|
|
147
|
+
expect(
|
|
148
|
+
widthLegend({ nodeWidth: 'frequency', graph: tagged })![0]!.label,
|
|
149
|
+
).toBe('AF 100%')
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
test('uniform widths, or one depth everywhere, draw no width key', () => {
|
|
153
|
+
expect(widthLegend({ nodeWidth: 'uniform' })).toBeUndefined()
|
|
154
|
+
expect(
|
|
155
|
+
widthLegend({ depthRange: { min: 3, max: 3, mean: 3 } }),
|
|
156
|
+
).toBeUndefined()
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
test('links by walks key the busiest link and a single walk', () => {
|
|
160
|
+
const rows = widthLegend(
|
|
161
|
+
{ nodeWidth: 'uniform', linkWidth: 'walks' },
|
|
162
|
+
'graph-link-width-legend',
|
|
163
|
+
)!
|
|
164
|
+
expect(rows.map(r => r.label)).toEqual(['26 walks', '1 walk'])
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
test('a key of several groups heads each once, a key of one stays bare', () => {
|
|
168
|
+
const both = legendSections(widthModel({ linkWidth: 'walks' }))
|
|
169
|
+
expect(both.map(s => s.heading)).toEqual(['Node thickness', 'Link thickness'])
|
|
170
|
+
const one = legendSections(widthModel({}))
|
|
171
|
+
expect(one.map(s => s.heading)).toEqual([undefined])
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
test('every row of a key shares one pitch, roomy enough for its tallest', () => {
|
|
175
|
+
const rows = widthLegend({})!
|
|
176
|
+
for (const row of rows) {
|
|
177
|
+
expect(rowPitch(rows)).toBeGreaterThanOrEqual(swatchHeight(row.swatch!) + 2)
|
|
178
|
+
}
|
|
179
|
+
expect(rowPitch([{ key: 'a', label: 'a' }])).toBe(15)
|
|
51
180
|
})
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
BUBBLE_KIND_NAMES,
|
|
5
5
|
} from '@jbrowse/bandage-core/bubbles/classifyBubble'
|
|
6
6
|
import { deletionKey } from '@jbrowse/bandage-core/deletionEdges'
|
|
7
|
+
import { edgeWidthFactor } from '@jbrowse/bandage-core/edgeWidths'
|
|
7
8
|
import { EXON_COLOR } from '@jbrowse/bandage-core/genes/exonOutline'
|
|
8
9
|
import { formatBp } from '@jbrowse/bandage-core/graphLabels'
|
|
9
10
|
import {
|
|
@@ -14,6 +15,7 @@ import {
|
|
|
14
15
|
UNBACKED_TICK,
|
|
15
16
|
walkRowsKey,
|
|
16
17
|
} from '@jbrowse/bandage-core/layout/walkRowDraw'
|
|
18
|
+
import { frequencyKey, nodeWidthPx } from '@jbrowse/bandage-core/nodeWidths'
|
|
17
19
|
import { referenceLabel } from '@jbrowse/bandage-core/reference'
|
|
18
20
|
import { RAMP_GRADIENT_STOPS } from '@jbrowse/bandage-core/referenceRampCss'
|
|
19
21
|
import {
|
|
@@ -35,13 +37,14 @@ import { COLORED_BLOCKS, blockFill, blockLetter } from './walkRowBlocks'
|
|
|
35
37
|
|
|
36
38
|
import type { GraphPaneModel } from './model'
|
|
37
39
|
import type { KeySwatch } from '@jbrowse/bandage-core/layout/walkRowDraw'
|
|
40
|
+
import type { GraphNode } from '@jbrowse/bandage-core/types'
|
|
38
41
|
import type { LiftedWalk } from '@jbrowse/bandage-core/walkHighlight'
|
|
39
42
|
|
|
40
43
|
// The legend as data, so the screen's panel and the exported figure's key
|
|
41
44
|
// draw the same rows from one place
|
|
42
45
|
|
|
43
46
|
export const SWATCH_PX = 18
|
|
44
|
-
const BAR_PX =
|
|
47
|
+
const BAR_PX = 32
|
|
45
48
|
|
|
46
49
|
// LIFT_BACKDROP_CSS reads paler alone than faded strokes do where they
|
|
47
50
|
// overlap, so the key samples it darker
|
|
@@ -52,6 +55,9 @@ const STRIP_SAMPLES = 6
|
|
|
52
55
|
const TUBE_SWATCH_PX = 7
|
|
53
56
|
const FOLD_TICK_BACKING = '#b8b8c0'
|
|
54
57
|
const WALK_ROW_SWATCH_PX = WALK_ROW_BAR_PX - 4
|
|
58
|
+
const LINK_INK = 'rgba(119, 119, 119, 0.85)'
|
|
59
|
+
const LINE_PX = 15
|
|
60
|
+
const CHIP_PX = 10
|
|
55
61
|
|
|
56
62
|
export interface Stop {
|
|
57
63
|
offset: number
|
|
@@ -65,6 +71,8 @@ export type LegendSwatch =
|
|
|
65
71
|
width?: number
|
|
66
72
|
height?: number
|
|
67
73
|
square?: boolean
|
|
74
|
+
// a hairline edge, so a pale colour still shows on the white key
|
|
75
|
+
edged?: true
|
|
68
76
|
}
|
|
69
77
|
// the reference strip, a band per lifted walk
|
|
70
78
|
| { kind: 'bands'; bands: Stop[][] }
|
|
@@ -98,21 +106,75 @@ export interface LegendRow {
|
|
|
98
106
|
interface LegendSection {
|
|
99
107
|
testid: string
|
|
100
108
|
rows: LegendRow[]
|
|
109
|
+
group?: string
|
|
110
|
+
// the group's name, over the first of its sections
|
|
111
|
+
heading?: string
|
|
112
|
+
// set apart from the group above by a heading's gap, though it has none
|
|
113
|
+
spaced?: true
|
|
101
114
|
}
|
|
102
115
|
|
|
103
116
|
export function swatchWidth(swatch: LegendSwatch) {
|
|
104
117
|
return swatch.kind === 'fill' ? (swatch.width ?? SWATCH_PX) : SWATCH_PX
|
|
105
118
|
}
|
|
106
119
|
|
|
120
|
+
export const bandPx = (bands: readonly unknown[]) => (bands.length > 1 ? 3 : 4)
|
|
121
|
+
|
|
122
|
+
export function swatchHeight(swatch: LegendSwatch) {
|
|
123
|
+
switch (swatch.kind) {
|
|
124
|
+
case 'fill':
|
|
125
|
+
return swatch.height ?? 8
|
|
126
|
+
case 'bands':
|
|
127
|
+
return bandPx(swatch.bands) * swatch.bands.length
|
|
128
|
+
case 'line':
|
|
129
|
+
return 3
|
|
130
|
+
case 'halo':
|
|
131
|
+
case 'overhang':
|
|
132
|
+
return 10
|
|
133
|
+
case 'outline':
|
|
134
|
+
case 'tick':
|
|
135
|
+
return swatch.height
|
|
136
|
+
case 'glyph':
|
|
137
|
+
return 15
|
|
138
|
+
case 'bracket':
|
|
139
|
+
return 7
|
|
140
|
+
case 'blank':
|
|
141
|
+
return 0
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// One column every swatch of a key sits in, so the words after them line up
|
|
146
|
+
export function swatchColumn(rows: readonly LegendRow[]) {
|
|
147
|
+
return rows.reduce(
|
|
148
|
+
(px, row) => (row.swatch ? Math.max(px, swatchWidth(row.swatch)) : px),
|
|
149
|
+
0,
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// One pitch for every line of a key, roomy enough for its tallest swatch, so
|
|
154
|
+
// rows sit evenly however their swatches differ
|
|
155
|
+
export function rowPitch(rows: readonly LegendRow[]) {
|
|
156
|
+
return rows.reduce(
|
|
157
|
+
(px, row) =>
|
|
158
|
+
row.swatch ? Math.max(px, Math.ceil(swatchHeight(row.swatch)) + 3) : px,
|
|
159
|
+
LINE_PX,
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
|
|
107
163
|
const flat = (color: string): Stop[] => [{ offset: 0, color }]
|
|
108
164
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
165
|
+
// A colour's key is a square chip, so it never reads as a thickness bar
|
|
166
|
+
function fillRow(key: string, color: string, label: string): LegendRow {
|
|
167
|
+
return {
|
|
168
|
+
key,
|
|
169
|
+
label,
|
|
170
|
+
swatch: {
|
|
171
|
+
kind: 'fill',
|
|
172
|
+
stops: flat(color),
|
|
173
|
+
width: CHIP_PX,
|
|
174
|
+
height: CHIP_PX,
|
|
175
|
+
edged: true,
|
|
176
|
+
},
|
|
177
|
+
}
|
|
116
178
|
}
|
|
117
179
|
|
|
118
180
|
// hard-edged bands, a read taking one shade of its strand's palette
|
|
@@ -150,14 +212,16 @@ function rampRows(model: GraphPaneModel): LegendRow[] {
|
|
|
150
212
|
// a measured domain runs between node midpoints, which can fall on a half bp
|
|
151
213
|
const start = Math.round(domain.start)
|
|
152
214
|
const end = Math.round(domain.end)
|
|
215
|
+
const reference = model.graph ? referenceLabel(model.graph) : 'reference'
|
|
153
216
|
return [
|
|
154
217
|
{
|
|
155
218
|
key: 'ramp',
|
|
156
|
-
label:
|
|
219
|
+
label: `position on ${reference}`,
|
|
157
220
|
swatch: { kind: 'fill', stops: RAMP_GRADIENT_STOPS, width: BAR_PX },
|
|
221
|
+
under: `${start.toLocaleString('en-US')}-${end.toLocaleString('en-US')} (${formatBp(end - start)})`,
|
|
158
222
|
},
|
|
159
223
|
...(model.referenceRampDrawsOffReference
|
|
160
|
-
? [fillRow('off', REFERENCE_RAMP_ALT_CSS, 'off the reference'
|
|
224
|
+
? [fillRow('off', REFERENCE_RAMP_ALT_CSS, 'off the reference')]
|
|
161
225
|
: []),
|
|
162
226
|
]
|
|
163
227
|
}
|
|
@@ -198,7 +262,7 @@ function stripRows(model: GraphPaneModel): LegendRow[] {
|
|
|
198
262
|
return [
|
|
199
263
|
{
|
|
200
264
|
key: 'strip',
|
|
201
|
-
label: `
|
|
265
|
+
label: `reference${rowPerWalk ? ', a row per walk' : ''}`,
|
|
202
266
|
swatch: { kind: 'bands', bands: stripBands(model) },
|
|
203
267
|
},
|
|
204
268
|
...(model.referenceStripFaded
|
|
@@ -263,6 +327,88 @@ function deletionRows(model: GraphPaneModel): LegendRow[] {
|
|
|
263
327
|
: []
|
|
264
328
|
}
|
|
265
329
|
|
|
330
|
+
function thicknessRow(
|
|
331
|
+
key: string,
|
|
332
|
+
label: string,
|
|
333
|
+
px: number,
|
|
334
|
+
color: string,
|
|
335
|
+
): LegendRow {
|
|
336
|
+
return {
|
|
337
|
+
key,
|
|
338
|
+
label,
|
|
339
|
+
swatch: { kind: 'fill', stops: flat(color), width: BAR_PX, height: px },
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
const roundDepth = (depth: number) =>
|
|
344
|
+
depth >= 10 ? Math.round(depth) : Math.round(depth * 10) / 10
|
|
345
|
+
|
|
346
|
+
// What a node's thickness counts, with bars as thick as the drawing makes
|
|
347
|
+
// the thinnest, the mean and the thickest node
|
|
348
|
+
function nodeWidthRows(model: GraphPaneModel): LegendRow[] {
|
|
349
|
+
const { graph, contigThickness: px, depthRange: range } = model
|
|
350
|
+
if (!graph || !model.drawsNodes || model.walkRowBars) {
|
|
351
|
+
return []
|
|
352
|
+
}
|
|
353
|
+
if (model.nodeWidth === 'frequency') {
|
|
354
|
+
const tagged = graph.nodes.some(n => n.frequency !== undefined)
|
|
355
|
+
return frequencyKey(px).map(({ label, widthPx }) =>
|
|
356
|
+
thicknessRow(
|
|
357
|
+
`width-${label}`,
|
|
358
|
+
tagged ? `AF ${label}` : `${label} of haplotypes`,
|
|
359
|
+
widthPx,
|
|
360
|
+
REFERENCE_RAMP_ALT_CSS,
|
|
361
|
+
),
|
|
362
|
+
)
|
|
363
|
+
}
|
|
364
|
+
if (model.nodeWidth !== 'depth' || !range || range.min === range.max) {
|
|
365
|
+
return []
|
|
366
|
+
}
|
|
367
|
+
const walkCount = graph.paths?.length ?? 0
|
|
368
|
+
const walks = walkCount > 0
|
|
369
|
+
const depths = [
|
|
370
|
+
...new Set(
|
|
371
|
+
[range.max, range.mean, range.min].map(walks ? Math.round : roundDepth),
|
|
372
|
+
),
|
|
373
|
+
]
|
|
374
|
+
// a walk looping through a repeat passes its nodes more than once, and
|
|
375
|
+
// each pass counts
|
|
376
|
+
const passes = depths[0]! > walkCount
|
|
377
|
+
const counted = (n: number) =>
|
|
378
|
+
passes
|
|
379
|
+
? `${n.toLocaleString('en-US')} walk pass${n === 1 ? '' : 'es'}`
|
|
380
|
+
: `${n.toLocaleString('en-US')} walk${n === 1 ? '' : 's'}`
|
|
381
|
+
return depths.map(depth =>
|
|
382
|
+
thicknessRow(
|
|
383
|
+
`width-${depth}`,
|
|
384
|
+
walks ? counted(depth) : `depth ${depth.toLocaleString('en-US')}`,
|
|
385
|
+
nodeWidthPx({ depth } as GraphNode, px, 'depth', range.mean),
|
|
386
|
+
REFERENCE_RAMP_ALT_CSS,
|
|
387
|
+
),
|
|
388
|
+
)
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function linkWidthRows(model: GraphPaneModel): LegendRow[] {
|
|
392
|
+
const busiest = model.busiestLink
|
|
393
|
+
if (
|
|
394
|
+
!model.drawsNodes ||
|
|
395
|
+
model.walkRowBars ||
|
|
396
|
+
model.linkWidth !== 'walks' ||
|
|
397
|
+
busiest === 0
|
|
398
|
+
) {
|
|
399
|
+
return []
|
|
400
|
+
}
|
|
401
|
+
const counts = busiest > 1 ? [busiest, 1] : [1]
|
|
402
|
+
return counts.map(n =>
|
|
403
|
+
thicknessRow(
|
|
404
|
+
`link-width-${n}`,
|
|
405
|
+
`${n.toLocaleString('en-US')} walk${n === 1 ? '' : 's'}`,
|
|
406
|
+
model.connectorThickness * edgeWidthFactor(n, busiest, 'walks'),
|
|
407
|
+
LINK_INK,
|
|
408
|
+
),
|
|
409
|
+
)
|
|
410
|
+
}
|
|
411
|
+
|
|
266
412
|
function geneRows(model: GraphPaneModel): LegendRow[] {
|
|
267
413
|
return model.genePins.some(pin => pin.exonsByNode.length > 0)
|
|
268
414
|
? [
|
|
@@ -514,41 +660,26 @@ export function walkKeyRow(model: GraphPaneModel, walk: LiftedWalk): LegendRow {
|
|
|
514
660
|
|
|
515
661
|
// The off-reference colour, where the lift paints it, and the faded rest.
|
|
516
662
|
// rampRows draws no key while walks are lifted, so these rows name both.
|
|
517
|
-
function fadedRows(
|
|
518
|
-
model: GraphPaneModel,
|
|
519
|
-
faded: string,
|
|
520
|
-
width = SWATCH_PX,
|
|
521
|
-
): LegendRow[] {
|
|
663
|
+
function fadedRows(model: GraphPaneModel, faded: string): LegendRow[] {
|
|
522
664
|
return [
|
|
523
665
|
...(model.liftPaintsOffReference
|
|
524
|
-
? [
|
|
525
|
-
fillRow(
|
|
526
|
-
'lift-off',
|
|
527
|
-
REFERENCE_RAMP_ALT_CSS,
|
|
528
|
-
'off the reference',
|
|
529
|
-
width,
|
|
530
|
-
),
|
|
531
|
-
]
|
|
666
|
+
? [fillRow('lift-off', REFERENCE_RAMP_ALT_CSS, 'off the reference')]
|
|
532
667
|
: []),
|
|
533
|
-
fillRow('faded', FADED_SWATCH, faded
|
|
668
|
+
fillRow('faded', FADED_SWATCH, faded),
|
|
534
669
|
]
|
|
535
670
|
}
|
|
536
671
|
|
|
537
|
-
// Each lifted walk's key, then what the faded rest is
|
|
538
|
-
// shaded walk's bar are bars of its width
|
|
672
|
+
// Each lifted walk's key, then what the faded rest is
|
|
539
673
|
function walkReadoutRows(model: GraphPaneModel): LegendRow[] {
|
|
540
674
|
const lift = model.walkLift
|
|
541
675
|
if (!lift || model.facetPanels) {
|
|
542
676
|
return []
|
|
543
677
|
}
|
|
544
678
|
const rows = lift.walks.map(w => walkKeyRow(model, w))
|
|
545
|
-
const width = rows.some(r => swatchWidth(r.swatch!) === BAR_PX)
|
|
546
|
-
? BAR_PX
|
|
547
|
-
: SWATCH_PX
|
|
548
679
|
const faded = model.graph
|
|
549
680
|
? fadedKey(model.graph, lift, model.liftedWalksLabel)
|
|
550
681
|
: `not on ${model.liftedWalksLabel}`
|
|
551
|
-
return [...rows, ...fadedRows(model, faded
|
|
682
|
+
return [...rows, ...fadedRows(model, faded)]
|
|
552
683
|
}
|
|
553
684
|
|
|
554
685
|
// The faceted pane's one key line under its panels: each panel's title keys
|
|
@@ -570,19 +701,66 @@ export function facetKeyRows(model: GraphPaneModel): LegendRow[] {
|
|
|
570
701
|
]
|
|
571
702
|
}
|
|
572
703
|
|
|
573
|
-
// The keys in the order the panel stacks them, top first
|
|
704
|
+
// The keys in the order the panel stacks them, top first, each under its
|
|
705
|
+
// group's heading once the key holds more than one group
|
|
574
706
|
export function legendSections(model: GraphPaneModel): LegendSection[] {
|
|
575
|
-
|
|
707
|
+
const sections: LegendSection[] = [
|
|
576
708
|
{ testid: 'graph-open-bubble-legend', rows: openBubbleRows(model) },
|
|
577
|
-
{ testid: 'graph-ramp-legend', rows: rampRows(model) },
|
|
578
|
-
{
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
709
|
+
{ testid: 'graph-ramp-legend', rows: rampRows(model), group: 'Color' },
|
|
710
|
+
{
|
|
711
|
+
testid: 'graph-walk-readout',
|
|
712
|
+
rows: walkReadoutRows(model),
|
|
713
|
+
group: 'Walks',
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
testid: 'graph-width-legend',
|
|
717
|
+
rows: nodeWidthRows(model),
|
|
718
|
+
group: 'Node thickness',
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
testid: 'graph-link-width-legend',
|
|
722
|
+
rows: linkWidthRows(model),
|
|
723
|
+
group: 'Link thickness',
|
|
724
|
+
},
|
|
725
|
+
{ testid: 'graph-halo-legend', rows: haloRows(model), group: 'Marks' },
|
|
726
|
+
{
|
|
727
|
+
testid: 'graph-deletion-legend',
|
|
728
|
+
rows: deletionRows(model),
|
|
729
|
+
group: 'Marks',
|
|
730
|
+
},
|
|
731
|
+
{ testid: 'graph-gene-legend', rows: geneRows(model), group: 'Marks' },
|
|
732
|
+
{ testid: 'graph-path-legend', rows: pathRows(model), group: 'Paths' },
|
|
733
|
+
{
|
|
734
|
+
testid: 'graph-tube-map-legend',
|
|
735
|
+
rows: tubeMapRows(model),
|
|
736
|
+
group: 'Tube map',
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
testid: 'graph-walk-rows-legend',
|
|
740
|
+
rows: walkRowsRows(model),
|
|
741
|
+
group: 'Walk rows',
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
testid: 'graph-reference-strip-legend',
|
|
745
|
+
rows: stripRows(model),
|
|
746
|
+
group: 'Top strip',
|
|
747
|
+
},
|
|
582
748
|
{ testid: 'graph-fold-legend', rows: foldRows(model) },
|
|
583
|
-
{ testid: 'graph-path-legend', rows: pathRows(model) },
|
|
584
|
-
{ testid: 'graph-tube-map-legend', rows: tubeMapRows(model) },
|
|
585
|
-
{ testid: 'graph-walk-rows-legend', rows: walkRowsRows(model) },
|
|
586
|
-
{ testid: 'graph-walk-readout', rows: walkReadoutRows(model) },
|
|
587
749
|
].filter(section => section.rows.length > 0)
|
|
750
|
+
const groups = new Set(sections.flatMap(section => section.group ?? []))
|
|
751
|
+
if (groups.size < 2) {
|
|
752
|
+
return sections
|
|
753
|
+
}
|
|
754
|
+
const headed = new Set<string>()
|
|
755
|
+
return sections.map((section, i) => {
|
|
756
|
+
const { group } = section
|
|
757
|
+
if (!group) {
|
|
758
|
+
return i === 0 ? section : { ...section, spaced: true as const }
|
|
759
|
+
}
|
|
760
|
+
if (headed.has(group)) {
|
|
761
|
+
return section
|
|
762
|
+
}
|
|
763
|
+
headed.add(group)
|
|
764
|
+
return { ...section, heading: group }
|
|
765
|
+
})
|
|
588
766
|
}
|
|
@@ -1674,25 +1674,24 @@ describe('canvas height follows the drawing', () => {
|
|
|
1674
1674
|
|
|
1675
1675
|
expect(model.canvasHeight).toBe(600)
|
|
1676
1676
|
model.setLegendSize({ width: 150, height: 60 })
|
|
1677
|
-
expect(model.legendRoom).toBe('right')
|
|
1678
1677
|
expect(model.canvasHeight).toBe(600)
|
|
1679
1678
|
})
|
|
1680
1679
|
|
|
1681
|
-
//
|
|
1682
|
-
//
|
|
1683
|
-
test('
|
|
1680
|
+
// As a JBrowse track's legend does, the key floats over the drawing, which
|
|
1681
|
+
// fits as though it were not there
|
|
1682
|
+
test('the fit leaves the floating legend no room', async () => {
|
|
1684
1683
|
rpcRespond()
|
|
1685
1684
|
const model = createModel()
|
|
1686
1685
|
await model.loadGFA(RGFA_FOUR_RANKS, 'four ranks')
|
|
1687
1686
|
model.zoomToFit()
|
|
1688
|
-
const { scale, translateY, canvasHeight } = model
|
|
1687
|
+
const { scale, translateX, translateY, canvasHeight } = model
|
|
1689
1688
|
|
|
1690
1689
|
model.setLegendSize({ width: 150, height: 60 })
|
|
1691
1690
|
model.zoomToFit()
|
|
1692
|
-
expect(model.legendRoom).toBe('top')
|
|
1693
1691
|
expect(model.scale).toBeCloseTo(scale, 10)
|
|
1694
|
-
expect(model.
|
|
1695
|
-
expect(model.
|
|
1692
|
+
expect(model.translateX).toBeCloseTo(translateX, 5)
|
|
1693
|
+
expect(model.translateY).toBeCloseTo(translateY, 5)
|
|
1694
|
+
expect(model.canvasHeight).toBe(canvasHeight)
|
|
1696
1695
|
})
|
|
1697
1696
|
|
|
1698
1697
|
test('the hover tooltip moves beside a legend that reaches its corner', async () => {
|
|
@@ -104,7 +104,7 @@ export const withFitViews = withHostViews
|
|
|
104
104
|
(self.walkRowGroups?.sections.length ?? 0) * SECTION_HEADER_PX
|
|
105
105
|
return rowPitch(
|
|
106
106
|
bars.rows.length + 1,
|
|
107
|
-
room - this.
|
|
107
|
+
room - this.fitPadTop - FIT_PADDING - headersPx,
|
|
108
108
|
)
|
|
109
109
|
},
|
|
110
110
|
// Where each walk row and section header sits at the rows' pitch
|
|
@@ -226,8 +226,9 @@ export const withFitViews = withHostViews
|
|
|
226
226
|
},
|
|
227
227
|
// Room over a tube map for the rows its genes need, one inside the
|
|
228
228
|
// padding and one more for each further gene that overlaps it, and
|
|
229
|
-
// room for the reference strip
|
|
230
|
-
|
|
229
|
+
// room for the reference strip. The legend floats over the drawing, as
|
|
230
|
+
// a JBrowse track's legend does, so the fit leaves it no room.
|
|
231
|
+
get fitPadTop() {
|
|
231
232
|
const rows = tubeMapGeneRows(self.tubeMapGenes)
|
|
232
233
|
return (
|
|
233
234
|
FIT_PADDING +
|
|
@@ -235,57 +236,6 @@ export const withFitViews = withHostViews
|
|
|
235
236
|
self.referenceStripZonePx
|
|
236
237
|
)
|
|
237
238
|
},
|
|
238
|
-
// The fit draws nothing under the legend. It leaves the legend room on
|
|
239
|
-
// the side that costs the drawing less scale: beside a tall drawing,
|
|
240
|
-
// which has width to spare, or above a wide flat one, which takes the
|
|
241
|
-
// height instead. A drawing whose x the host places can only move down.
|
|
242
|
-
// Reads get no room: their letters, and the legend row naming them, come
|
|
243
|
-
// and go with the fit's scale.
|
|
244
|
-
get legendRoom(): 'right' | 'top' | undefined {
|
|
245
|
-
const bounds = this.layoutBounds
|
|
246
|
-
const { width, height } = self.legendSize
|
|
247
|
-
if (
|
|
248
|
-
!bounds ||
|
|
249
|
-
bounds.w <= 0 ||
|
|
250
|
-
width === 0 ||
|
|
251
|
-
self.facetPanels ||
|
|
252
|
-
self.tubeMapReads
|
|
253
|
-
) {
|
|
254
|
-
return undefined
|
|
255
|
-
}
|
|
256
|
-
if (self.hostPlacesX) {
|
|
257
|
-
return 'top'
|
|
258
|
-
}
|
|
259
|
-
const base = this.fitPadTopBase
|
|
260
|
-
const room = this.fitRoom
|
|
261
|
-
const across = (padRight: number) =>
|
|
262
|
-
(self.paneWidth - this.fitPadLeft - padRight) / bounds.w
|
|
263
|
-
const down = (padTop: number) =>
|
|
264
|
-
self.pixelRows
|
|
265
|
-
? bounds.h + padTop + FIT_PADDING <= room
|
|
266
|
-
? Infinity
|
|
267
|
-
: 0
|
|
268
|
-
: (room - padTop - FIT_PADDING) / bounds.h
|
|
269
|
-
const beside = Math.min(across(width + 2 * LEGEND_INSET_PX), down(base))
|
|
270
|
-
const above = Math.min(
|
|
271
|
-
across(FIT_PADDING),
|
|
272
|
-
down(base + height + LEGEND_INSET_PX),
|
|
273
|
-
)
|
|
274
|
-
return above >= beside ? 'top' : 'right'
|
|
275
|
-
},
|
|
276
|
-
get fitPadTop() {
|
|
277
|
-
return (
|
|
278
|
-
this.fitPadTopBase +
|
|
279
|
-
(this.legendRoom === 'top'
|
|
280
|
-
? self.legendSize.height + LEGEND_INSET_PX
|
|
281
|
-
: 0)
|
|
282
|
-
)
|
|
283
|
-
},
|
|
284
|
-
get fitPadRight() {
|
|
285
|
-
return this.legendRoom === 'right'
|
|
286
|
-
? Math.max(FIT_PADDING, self.legendSize.width + 2 * LEGEND_INSET_PX)
|
|
287
|
-
: FIT_PADDING
|
|
288
|
-
},
|
|
289
239
|
// A tube map on its own axis reads by panning along it, as in
|
|
290
240
|
// sequenceTubeMap. Rather than shrink a long cut to a strip, the fit
|
|
291
241
|
// stops where its tubes are MIN_FIT_TUBE_PX wide, or at whatever fits
|
|
@@ -409,8 +359,7 @@ export const withFitViews = withHostViews
|
|
|
409
359
|
: { width: self.paneWidth, height: this.canvasHeight }
|
|
410
360
|
},
|
|
411
361
|
// The fit's margins: a facet panel's all round, else room for the row
|
|
412
|
-
// labels
|
|
413
|
-
// puts it
|
|
362
|
+
// labels and the genes and strip above
|
|
414
363
|
get fitPads() {
|
|
415
364
|
return this.facetGrid
|
|
416
365
|
? {
|
|
@@ -422,7 +371,7 @@ export const withFitViews = withHostViews
|
|
|
422
371
|
: {
|
|
423
372
|
left: this.fitPadLeft,
|
|
424
373
|
top: this.fitPadTop,
|
|
425
|
-
right:
|
|
374
|
+
right: FIT_PADDING,
|
|
426
375
|
bottom: FIT_PADDING,
|
|
427
376
|
}
|
|
428
377
|
},
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
deletionDrawing,
|
|
10
10
|
deletionEdges,
|
|
11
11
|
} from '@jbrowse/bandage-core/deletionEdges'
|
|
12
|
+
import { busiestEdge } from '@jbrowse/bandage-core/edgeWidths'
|
|
12
13
|
import { facetSettingOf } from '@jbrowse/bandage-core/facetGrid'
|
|
13
14
|
import { genePins } from '@jbrowse/bandage-core/genes/genePins'
|
|
14
15
|
import { formatBp } from '@jbrowse/bandage-core/graphLabels'
|
|
@@ -27,7 +28,7 @@ import {
|
|
|
27
28
|
layoutModeByValue,
|
|
28
29
|
modeUsesLayoutEngine,
|
|
29
30
|
} from '@jbrowse/bandage-core/layoutModes'
|
|
30
|
-
import { nodeInk } from '@jbrowse/bandage-core/nodeWidths'
|
|
31
|
+
import { meanDepth, nodeInk } from '@jbrowse/bandage-core/nodeWidths'
|
|
31
32
|
import { pathOrigin } from '@jbrowse/bandage-core/pathAnchoring'
|
|
32
33
|
import {
|
|
33
34
|
pathColorsLegible,
|
|
@@ -352,6 +353,9 @@ export const withGraphViews = paneBase
|
|
|
352
353
|
get geometryPainted() {
|
|
353
354
|
return geometryPainted(self)
|
|
354
355
|
},
|
|
356
|
+
get paintSuperseded() {
|
|
357
|
+
return !this.geometryPainted
|
|
358
|
+
},
|
|
355
359
|
// The app-wide readiness contract (AppReadyMarker, @jbrowse/capture)
|
|
356
360
|
// reads this: a declared source still fetching, or a graph whose
|
|
357
361
|
// settled geometry is not on the canvas yet.
|
|
@@ -879,6 +883,24 @@ export const withGraphViews = paneBase
|
|
|
879
883
|
self.nodeWidth,
|
|
880
884
|
)
|
|
881
885
|
},
|
|
886
|
+
// the depths the width key samples, swept once per graph rather than on
|
|
887
|
+
// each legend render
|
|
888
|
+
get depthRange() {
|
|
889
|
+
const nodes = self.graph?.nodes
|
|
890
|
+
if (!nodes?.length) {
|
|
891
|
+
return undefined
|
|
892
|
+
}
|
|
893
|
+
let min = Infinity
|
|
894
|
+
let max = -Infinity
|
|
895
|
+
for (const { depth } of nodes) {
|
|
896
|
+
min = Math.min(min, depth)
|
|
897
|
+
max = Math.max(max, depth)
|
|
898
|
+
}
|
|
899
|
+
return { min, max, mean: meanDepth(self.graph!) }
|
|
900
|
+
},
|
|
901
|
+
get busiestLink() {
|
|
902
|
+
return self.graph ? busiestEdge(self.graph) : 0
|
|
903
|
+
},
|
|
882
904
|
// Links that skip reference sequence, i.e. the deletions this graph
|
|
883
905
|
// holds. Computed once per graph rather than per geometry rebuild: it is
|
|
884
906
|
// a pass over the edges and the drawing rebuilds on every pan.
|