jbrowse-plugin-graphgenomeviewer 4.7.0 → 5.0.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/README.md +7 -1
- package/dist/chunks/ChooseWalksDialog-GVQLSGHX.js +2 -0
- package/dist/chunks/ChooseWalksDialog-GVQLSGHX.js.map +7 -0
- package/dist/chunks/GbzBaseSyntenyAdapter-CKKVHC2R.js +4 -0
- package/dist/chunks/GbzBaseSyntenyAdapter-CKKVHC2R.js.map +7 -0
- package/dist/chunks/{GraphGenomeView-HZ2EQUOC.js → GraphGenomeView-YYP4IFSI.js} +2 -2
- package/dist/chunks/{GraphTrackSettingsDialog-JVPM25GV.js → GraphTrackSettingsDialog-2WPJRAJC.js} +2 -2
- package/dist/chunks/LinearGraphDisplay-7YE624D5.js +2 -0
- package/dist/chunks/LinearGraphDisplay-7YE624D5.js.map +7 -0
- package/dist/chunks/chunk-2H7GDQ3R.js +6 -0
- package/dist/chunks/chunk-2H7GDQ3R.js.map +7 -0
- package/dist/chunks/chunk-BZOIENU5.js +2 -0
- package/dist/chunks/chunk-BZOIENU5.js.map +7 -0
- package/dist/chunks/{chunk-UTWFU4X6.js → chunk-H54W6OQQ.js} +2 -2
- package/dist/chunks/{chunk-UTWFU4X6.js.map → chunk-H54W6OQQ.js.map} +4 -4
- package/dist/chunks/{chunk-F2EPKNTV.js → chunk-O4XV3K35.js} +2 -2
- package/dist/chunks/{chunk-F2EPKNTV.js.map → chunk-O4XV3K35.js.map} +4 -4
- package/dist/chunks/chunk-SJNG2XK7.js +2 -0
- package/dist/chunks/chunk-SJNG2XK7.js.map +7 -0
- package/dist/chunks/chunk-WKVVIDCS.js +3 -0
- package/dist/chunks/{chunk-KCL5TF5X.js.map → chunk-WKVVIDCS.js.map} +3 -3
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +5 -5
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +4 -4
- package/package.json +3 -3
- package/src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.test.ts +36 -2
- package/src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.ts +67 -1
- package/src/GbzBaseSyntenyAdapter/test_data/fragmented.haplotype-index.db +0 -0
- package/src/GbzBaseSyntenyAdapter/test_data/micb-kir3dl1.haplotype-index.db +0 -0
- package/src/GbzBaseSyntenyAdapter/test_data/micb-kir3dl1.sampled.haplotype-index.db +0 -0
- package/src/GetHaplotypeOverview.ts +77 -0
- package/src/GraphGenomeView/components/ChooseWalksDialog.tsx +86 -0
- package/src/GraphGenomeView/components/GraphSettingsDialog.tsx +205 -187
- package/src/GraphGenomeView/components/TubeMapLegend.test.tsx +29 -0
- package/src/GraphGenomeView/components/TubeMapOverlay.tsx +8 -0
- package/src/GraphGenomeView/host.ts +6 -0
- package/src/GraphGenomeView/model.ts +10 -4224
- package/src/GraphGenomeView/pane/fitViews.ts +589 -0
- package/src/GraphGenomeView/pane/graphViews.ts +829 -0
- package/src/GraphGenomeView/pane/hostViews.ts +193 -0
- package/src/GraphGenomeView/pane/launchActions.ts +407 -0
- package/src/GraphGenomeView/pane/launchViews.ts +191 -0
- package/src/GraphGenomeView/pane/loadActions.ts +701 -0
- package/src/GraphGenomeView/pane/paneBase.ts +479 -0
- package/src/GraphGenomeView/pane/renderingActions.ts +281 -0
- package/src/GraphGenomeView/pane/settingActions.ts +467 -0
- package/src/GraphGenomeView/pane/walkRowViews.ts +205 -0
- package/src/HaplotypeOverview/HaplotypeOverviewCanvas.tsx +203 -0
- package/src/HaplotypeOverview/draw.test.ts +136 -0
- package/src/HaplotypeOverview/draw.ts +433 -0
- package/src/HaplotypeOverview/model.ts +163 -0
- package/src/LinearGraphDisplay/LinearGraphDisplay.test.ts +184 -0
- package/src/LinearGraphDisplay/components/LinearGraphDisplay.tsx +12 -2
- package/src/LinearGraphDisplay/model.ts +107 -3
- package/src/gaf/gafFile.ts +2 -0
- package/src/index.ts +2 -0
- package/src/version.ts +1 -1
- package/dist/chunks/GbzBaseSyntenyAdapter-AZBYMDIW.js +0 -8
- package/dist/chunks/GbzBaseSyntenyAdapter-AZBYMDIW.js.map +0 -7
- package/dist/chunks/LinearGraphDisplay-MJ4ZBJRX.js +0 -2
- package/dist/chunks/LinearGraphDisplay-MJ4ZBJRX.js.map +0 -7
- package/dist/chunks/chunk-BUXVOMDL.js +0 -2
- package/dist/chunks/chunk-BUXVOMDL.js.map +0 -7
- package/dist/chunks/chunk-KCL5TF5X.js +0 -3
- /package/dist/chunks/{GraphGenomeView-HZ2EQUOC.js.map → GraphGenomeView-YYP4IFSI.js.map} +0 -0
- /package/dist/chunks/{GraphTrackSettingsDialog-JVPM25GV.js.map → GraphTrackSettingsDialog-2WPJRAJC.js.map} +0 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { sameBubble } from '@jbrowse/bandage-core/bubbles/bubbleLine'
|
|
2
|
+
import { layoutModeByValue } from '@jbrowse/bandage-core/layoutModes'
|
|
3
|
+
import {
|
|
4
|
+
REFERENCE_STRIP_ZONE_PX,
|
|
5
|
+
nodeAnchor,
|
|
6
|
+
referenceStripBlocks,
|
|
7
|
+
stripBlockAt,
|
|
8
|
+
stripOverhang,
|
|
9
|
+
} from '@jbrowse/bandage-core/referenceStrip'
|
|
10
|
+
import { referenceBoxes } from '@jbrowse/bandage-core/tubeMap/axis'
|
|
11
|
+
import { referenceNodes } from '@jbrowse/bandage-core/tubeMap/connectors'
|
|
12
|
+
import { deviationMarks } from '@jbrowse/bandage-core/tubeMap/deviations'
|
|
13
|
+
import { tubeMapPicture } from '@jbrowse/bandage-core/tubeMap/draw'
|
|
14
|
+
import { tubeMapGenes } from '@jbrowse/bandage-core/tubeMap/genes'
|
|
15
|
+
|
|
16
|
+
import { hostFrame } from '../host'
|
|
17
|
+
import { PAPER_DARK, PAPER_LIGHT, paperCss } from './paneBase'
|
|
18
|
+
import { withWalkRowViews } from './walkRowViews'
|
|
19
|
+
|
|
20
|
+
export const withHostViews = withWalkRowViews
|
|
21
|
+
.views(self => ({
|
|
22
|
+
// Whether the drawing's x is reference bp a host can place. Walk rows
|
|
23
|
+
// put the backbone at its bp too, but their bars are lengths, so the
|
|
24
|
+
// mode's `cutMargins` is what says the drawing is a picture.
|
|
25
|
+
get xIsReferenceBp() {
|
|
26
|
+
return (
|
|
27
|
+
self.layoutResult?.referenceAxis === true &&
|
|
28
|
+
layoutModeByValue(self.chosenLayoutMode).cutMargins
|
|
29
|
+
)
|
|
30
|
+
},
|
|
31
|
+
}))
|
|
32
|
+
.views(self => ({
|
|
33
|
+
// Whether the host places x. Only a layout whose x is reference bp can
|
|
34
|
+
// take the window's transform; force, ordered and walk rows draw in
|
|
35
|
+
// their own coordinates inside the track, and a popped bubble is a
|
|
36
|
+
// picture of its own.
|
|
37
|
+
get hostPlacesX() {
|
|
38
|
+
const { host, graphRegion: region } = self
|
|
39
|
+
return (
|
|
40
|
+
host !== undefined &&
|
|
41
|
+
host.initialized &&
|
|
42
|
+
region !== undefined &&
|
|
43
|
+
self.xIsReferenceBp &&
|
|
44
|
+
self.popStack.length === 0 &&
|
|
45
|
+
!host.dynamicBlocks.contentBlocks.some(
|
|
46
|
+
b => b.refName === region.refName && b.reversed,
|
|
47
|
+
)
|
|
48
|
+
)
|
|
49
|
+
},
|
|
50
|
+
}))
|
|
51
|
+
.views(self => ({
|
|
52
|
+
get hostFrame() {
|
|
53
|
+
const { host, graphRegion } = self
|
|
54
|
+
return self.hostPlacesX && host && graphRegion
|
|
55
|
+
? hostFrame(host, graphRegion)
|
|
56
|
+
: undefined
|
|
57
|
+
},
|
|
58
|
+
get tubeMapPicture() {
|
|
59
|
+
const drawing = self.layoutResult?.tubeMap
|
|
60
|
+
return drawing ? tubeMapPicture(drawing.layout) : undefined
|
|
61
|
+
},
|
|
62
|
+
get tubeMapReference() {
|
|
63
|
+
const drawing = self.layoutResult?.tubeMap
|
|
64
|
+
return drawing && self.drawnGraph
|
|
65
|
+
? referenceBoxes(self.drawnGraph, drawing.layout)
|
|
66
|
+
: undefined
|
|
67
|
+
},
|
|
68
|
+
// the folded variants, as ticks on the tubes of the walks carrying them
|
|
69
|
+
get tubeMapDeviations() {
|
|
70
|
+
const coarse = self.layoutResult?.tubeMap?.coarse
|
|
71
|
+
const layout = self.layoutResult?.tubeMap?.layout
|
|
72
|
+
return coarse && layout
|
|
73
|
+
? deviationMarks(coarse.graph, layout, coarse.deviations)
|
|
74
|
+
: []
|
|
75
|
+
},
|
|
76
|
+
// the reference boxes a linear view's connectors tie to its bp, which
|
|
77
|
+
// the reference axis already puts under that bp
|
|
78
|
+
get tubeMapReferenceNodes() {
|
|
79
|
+
const layout = self.layoutResult
|
|
80
|
+
return layout?.tubeMap && !layout.referenceAxis && self.drawnGraph
|
|
81
|
+
? referenceNodes(self.drawnGraph, layout.tubeMap.layout)
|
|
82
|
+
: undefined
|
|
83
|
+
},
|
|
84
|
+
}))
|
|
85
|
+
.views(self => ({
|
|
86
|
+
// A linear view has the genes in a track of their own, at their bp
|
|
87
|
+
get tubeMapGenes() {
|
|
88
|
+
const reference = self.tubeMapReference
|
|
89
|
+
return self.showGenes && !self.host && reference && self.backboneGenes
|
|
90
|
+
? tubeMapGenes(reference, self.backboneGenes)
|
|
91
|
+
: []
|
|
92
|
+
},
|
|
93
|
+
// A drawing of nodes in its own coordinates inside a linear view, whose
|
|
94
|
+
// reference segments the strip can put back at their bp
|
|
95
|
+
get referenceStripApplies() {
|
|
96
|
+
return (
|
|
97
|
+
!!self.host?.initialized &&
|
|
98
|
+
!!self.layoutResult &&
|
|
99
|
+
self.drawsNodes &&
|
|
100
|
+
!self.hostPlacesX &&
|
|
101
|
+
!self.facetPanels
|
|
102
|
+
)
|
|
103
|
+
},
|
|
104
|
+
}))
|
|
105
|
+
.views(self => ({
|
|
106
|
+
get referenceStripBlocks() {
|
|
107
|
+
const { graph } = self
|
|
108
|
+
return self.showReferenceStrip && self.referenceStripApplies && graph
|
|
109
|
+
? referenceStripBlocks(graph, {
|
|
110
|
+
colorScheme: self.effectiveColorScheme,
|
|
111
|
+
referenceRamp: self.referenceRamp,
|
|
112
|
+
walks: self.walkLift?.walks,
|
|
113
|
+
})
|
|
114
|
+
: []
|
|
115
|
+
},
|
|
116
|
+
// Read off the live blocks, so the strip follows every frame of a pan
|
|
117
|
+
// in the linear view
|
|
118
|
+
get referenceStripFrame() {
|
|
119
|
+
const { host, graphRegion } = self
|
|
120
|
+
return host?.initialized && graphRegion
|
|
121
|
+
? hostFrame(host, graphRegion)
|
|
122
|
+
: undefined
|
|
123
|
+
},
|
|
124
|
+
}))
|
|
125
|
+
.views(self => ({
|
|
126
|
+
get referenceStripShown() {
|
|
127
|
+
return (
|
|
128
|
+
self.referenceStripBlocks.length > 0 &&
|
|
129
|
+
self.referenceStripFrame !== undefined
|
|
130
|
+
)
|
|
131
|
+
},
|
|
132
|
+
// Whether the graph draws reference past the window's edges. A boolean
|
|
133
|
+
// rather than the bp, which moves on every frame of a pan and would
|
|
134
|
+
// resize the legend with it.
|
|
135
|
+
get referenceStripOverhangs() {
|
|
136
|
+
const frame = self.referenceStripFrame
|
|
137
|
+
if (!frame || self.referenceStripBlocks.length === 0) {
|
|
138
|
+
return false
|
|
139
|
+
}
|
|
140
|
+
const { left, right } = stripOverhang(
|
|
141
|
+
self.referenceStripBlocks,
|
|
142
|
+
frame,
|
|
143
|
+
self.paneWidth,
|
|
144
|
+
)
|
|
145
|
+
return left > 0 || right > 0
|
|
146
|
+
},
|
|
147
|
+
get referenceStripFaded() {
|
|
148
|
+
return self.referenceStripBlocks.some(b => b.faded)
|
|
149
|
+
},
|
|
150
|
+
}))
|
|
151
|
+
.views(self => ({
|
|
152
|
+
// The lit span on the strip, and where the graph drew what it is of:
|
|
153
|
+
// the hovered node, the hovered bubble's name, or the selected node
|
|
154
|
+
get referenceStripLit() {
|
|
155
|
+
if (!self.referenceStripShown) {
|
|
156
|
+
return undefined
|
|
157
|
+
}
|
|
158
|
+
const toScreen = (p: { x: number; y: number }) => ({
|
|
159
|
+
x: p.x * self.scaleX + self.translateX,
|
|
160
|
+
y: p.y * self.scaleY + self.translateY,
|
|
161
|
+
})
|
|
162
|
+
const bubble = self.hoveredNode === null ? self.hoveredBubble : null
|
|
163
|
+
if (bubble) {
|
|
164
|
+
const halo = self.bubbleHalos.find(h => sameBubble(h.bubble, bubble))
|
|
165
|
+
return {
|
|
166
|
+
start: bubble.start,
|
|
167
|
+
end: bubble.end,
|
|
168
|
+
anchor: halo ? toScreen(halo.labelAt) : undefined,
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const nodeId = self.hoveredNode ?? self.selectedNode
|
|
172
|
+
const span = nodeId === null ? undefined : self.nodeSpan(nodeId)
|
|
173
|
+
return span && nodeId !== null
|
|
174
|
+
? {
|
|
175
|
+
...span,
|
|
176
|
+
anchor: nodeAnchor(self.nodePositions?.[nodeId], toScreen),
|
|
177
|
+
}
|
|
178
|
+
: undefined
|
|
179
|
+
},
|
|
180
|
+
referenceStripNodeAt(sx: number, sy: number) {
|
|
181
|
+
const frame = self.referenceStripFrame
|
|
182
|
+
return self.referenceStripShown && frame
|
|
183
|
+
? stripBlockAt(self.referenceStripBlocks, frame, sx, sy)
|
|
184
|
+
: undefined
|
|
185
|
+
},
|
|
186
|
+
get paperCss() {
|
|
187
|
+
return paperCss(self.darkMode ? PAPER_DARK : PAPER_LIGHT)
|
|
188
|
+
},
|
|
189
|
+
// the strip, and the gap the fit leaves under it
|
|
190
|
+
get referenceStripZonePx() {
|
|
191
|
+
return self.referenceStripShown ? REFERENCE_STRIP_ZONE_PX : 0
|
|
192
|
+
},
|
|
193
|
+
}))
|
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
import { COLOR_SCHEMES } from '@jbrowse/bandage-core/colorSchemes'
|
|
2
|
+
import { LAYOUT_MODES } from '@jbrowse/bandage-core/layoutModes'
|
|
3
|
+
import { WALK_FIELDS, WALK_SCHEMES } from '@jbrowse/bandage-core/walkEncoding'
|
|
4
|
+
import { pushLaunchViewMenuItem } from '@jbrowse/core/ui'
|
|
5
|
+
import { getSession } from '@jbrowse/core/util'
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
ChooseWalksDialog,
|
|
9
|
+
FACETS,
|
|
10
|
+
TUBE_MAP_FOLDS,
|
|
11
|
+
TUBE_MAP_MODES,
|
|
12
|
+
WALK_MENU_ITEMS,
|
|
13
|
+
} from './paneBase'
|
|
14
|
+
import { withRenderingActions } from './renderingActions'
|
|
15
|
+
import { graphLaunchMenuItems } from '../../launchFromGraph/graphMenuItems'
|
|
16
|
+
import {
|
|
17
|
+
highlightInLinearView,
|
|
18
|
+
launchSyntenyView,
|
|
19
|
+
showInLinearView,
|
|
20
|
+
} from '../../launchFromGraph/launchFromGraph'
|
|
21
|
+
import { launchTracks } from '../../launchFromGraph/launchTracks'
|
|
22
|
+
import { launchableSyntenyTracks } from '../../launchFromGraph/syntenyTracks'
|
|
23
|
+
import { downloadText } from '../download'
|
|
24
|
+
|
|
25
|
+
import type { GraphLocation } from '../../launchFromGraph/contributors'
|
|
26
|
+
import type { MenuItem } from '@jbrowse/core/ui'
|
|
27
|
+
|
|
28
|
+
export const withLaunchActions = withRenderingActions
|
|
29
|
+
.actions(self => ({
|
|
30
|
+
// Move the linear view already on screen, or open one if there is none,
|
|
31
|
+
// and pair with whichever it was. A view being created gets the session's
|
|
32
|
+
// annotation for the assembly it opens on (see launchTracks), led by the
|
|
33
|
+
// graph's own segments track when the launch is on the reference — the one
|
|
34
|
+
// assembly that track is configured for.
|
|
35
|
+
//
|
|
36
|
+
// Only a view on the reference is paired with. A node's hover band is on
|
|
37
|
+
// that assembly, so paired with a view on another the band fails that
|
|
38
|
+
// view's assembly check and the reference view's id check, and is drawn
|
|
39
|
+
// nowhere.
|
|
40
|
+
showInLinearView(target: { location: GraphLocation; assembly: string }) {
|
|
41
|
+
const session = getSession(self)
|
|
42
|
+
const onReference = target.assembly === self.graphRegion?.assemblyName
|
|
43
|
+
const viewId = showInLinearView({
|
|
44
|
+
session,
|
|
45
|
+
location: target.location,
|
|
46
|
+
assembly: target.assembly,
|
|
47
|
+
connectedViewId: self.connectedViewId,
|
|
48
|
+
tracks: launchTracks({
|
|
49
|
+
session,
|
|
50
|
+
assemblyName: target.assembly,
|
|
51
|
+
first: onReference ? self.sourceTrackId : undefined,
|
|
52
|
+
}),
|
|
53
|
+
})
|
|
54
|
+
if (onReference) {
|
|
55
|
+
self.pairWithLinearView(viewId)
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
// Mark the node's reference interval in the linear view beside the graph.
|
|
59
|
+
// Not an action that opens anything: with no view to mark, the menu does
|
|
60
|
+
// not offer it (see nodeLaunchMenuItems).
|
|
61
|
+
highlightInLinearView(target: {
|
|
62
|
+
location: GraphLocation
|
|
63
|
+
assembly: string
|
|
64
|
+
}) {
|
|
65
|
+
highlightInLinearView({
|
|
66
|
+
session: getSession(self),
|
|
67
|
+
location: target.location,
|
|
68
|
+
assembly: target.assembly,
|
|
69
|
+
connectedViewId: self.connectedViewId,
|
|
70
|
+
})
|
|
71
|
+
},
|
|
72
|
+
showSyntenyView(trackId: string) {
|
|
73
|
+
launchSyntenyView({
|
|
74
|
+
session: getSession(self),
|
|
75
|
+
contributors: self.launchableAssemblies,
|
|
76
|
+
trackId,
|
|
77
|
+
graphTrackId: self.sourceTrackId,
|
|
78
|
+
})
|
|
79
|
+
},
|
|
80
|
+
}))
|
|
81
|
+
.views(self => ({
|
|
82
|
+
// Synteny datasets that could fill the panels of a multi-genome launch.
|
|
83
|
+
// Below two openable contributors there is nothing to compare, so the scan
|
|
84
|
+
// is skipped rather than run and discarded.
|
|
85
|
+
get syntenyLaunchTracks() {
|
|
86
|
+
const samples = self.launchableAssemblies.map(c => c.sample)
|
|
87
|
+
return samples.length >= 2
|
|
88
|
+
? launchableSyntenyTracks(getSession(self), samples)
|
|
89
|
+
: []
|
|
90
|
+
},
|
|
91
|
+
}))
|
|
92
|
+
.views(self => ({
|
|
93
|
+
// The graph's way out, in the same shared "Launch view" submenu every
|
|
94
|
+
// other view contributes to. Until this existed the triangle had two edges:
|
|
95
|
+
// a linear view could open a graph or a synteny view of a locus, and the
|
|
96
|
+
// graph could open nothing at all.
|
|
97
|
+
graphMenuItems(): MenuItem[] {
|
|
98
|
+
const walks = self.walkChoices
|
|
99
|
+
return [
|
|
100
|
+
{
|
|
101
|
+
label: 'Layout',
|
|
102
|
+
subMenu: LAYOUT_MODES.map(mode => ({
|
|
103
|
+
type: 'radio' as const,
|
|
104
|
+
label: mode.label,
|
|
105
|
+
checked: self.chosenLayoutMode === mode.value,
|
|
106
|
+
disabled: self.graph ? !mode.available(self.graph) : false,
|
|
107
|
+
onClick: () => {
|
|
108
|
+
void self.switchLayout(mode.value)
|
|
109
|
+
},
|
|
110
|
+
})),
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
label: 'Color',
|
|
114
|
+
subMenu: COLOR_SCHEMES.map(scheme => ({
|
|
115
|
+
type: 'radio' as const,
|
|
116
|
+
label: scheme.label,
|
|
117
|
+
checked: self.chosenColorScheme === scheme.value,
|
|
118
|
+
onClick: () => {
|
|
119
|
+
self.setColorScheme(scheme.value)
|
|
120
|
+
},
|
|
121
|
+
})),
|
|
122
|
+
},
|
|
123
|
+
...(walks.length > 0 && self.liftsWalks
|
|
124
|
+
? [
|
|
125
|
+
{
|
|
126
|
+
label: 'Walk',
|
|
127
|
+
subMenu: [
|
|
128
|
+
{
|
|
129
|
+
label: 'None',
|
|
130
|
+
onClick: () => {
|
|
131
|
+
self.setWalkLayers([])
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
...(self.walkLayers.length > 1 && self.modeDrawsNodes
|
|
135
|
+
? [
|
|
136
|
+
{
|
|
137
|
+
label: 'Side by side',
|
|
138
|
+
subMenu: FACETS.map(({ value, label }) => ({
|
|
139
|
+
type: 'radio' as const,
|
|
140
|
+
label,
|
|
141
|
+
checked: self.facet.field === value,
|
|
142
|
+
onClick: () => {
|
|
143
|
+
self.setFacet(value)
|
|
144
|
+
},
|
|
145
|
+
})),
|
|
146
|
+
},
|
|
147
|
+
]
|
|
148
|
+
: []),
|
|
149
|
+
...(self.facetPanels &&
|
|
150
|
+
self.facet.field === 'walk' &&
|
|
151
|
+
!self.hostPlacesX
|
|
152
|
+
? [
|
|
153
|
+
{
|
|
154
|
+
label: 'Columns',
|
|
155
|
+
subMenu: [
|
|
156
|
+
undefined,
|
|
157
|
+
...self.facetPanels.map((_, i) => i + 1),
|
|
158
|
+
].map(columns => ({
|
|
159
|
+
type: 'radio' as const,
|
|
160
|
+
label:
|
|
161
|
+
columns === undefined ? 'Auto' : `${columns}`,
|
|
162
|
+
checked: self.facet.columns === columns,
|
|
163
|
+
onClick: () => {
|
|
164
|
+
self.setFacetColumns(columns)
|
|
165
|
+
},
|
|
166
|
+
})),
|
|
167
|
+
},
|
|
168
|
+
]
|
|
169
|
+
: []),
|
|
170
|
+
...(walks.length > WALK_MENU_ITEMS
|
|
171
|
+
? [
|
|
172
|
+
{
|
|
173
|
+
label: 'Choose walks...',
|
|
174
|
+
onClick: () => {
|
|
175
|
+
getSession(self).queueDialog(onClose => [
|
|
176
|
+
ChooseWalksDialog,
|
|
177
|
+
{ model: self, onClose },
|
|
178
|
+
])
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
]
|
|
182
|
+
: []),
|
|
183
|
+
...(walks.length > WALK_MENU_ITEMS
|
|
184
|
+
? walks.filter(walk =>
|
|
185
|
+
self.walkLayers.some(l => l.walk === walk.name),
|
|
186
|
+
)
|
|
187
|
+
: walks
|
|
188
|
+
).map(walk => ({
|
|
189
|
+
type: 'checkbox' as const,
|
|
190
|
+
label: walk.label,
|
|
191
|
+
checked: self.walkLayers.some(l => l.walk === walk.name),
|
|
192
|
+
onClick: () => {
|
|
193
|
+
self.toggleWalk(walk.name)
|
|
194
|
+
},
|
|
195
|
+
})),
|
|
196
|
+
...self.drawnWalks.map(lifted => ({
|
|
197
|
+
label: `Colour ${self.walkLabel(lifted.name)}`,
|
|
198
|
+
subMenu: [
|
|
199
|
+
{ type: 'subHeader' as const, label: 'Colour by' },
|
|
200
|
+
...WALK_FIELDS.map(field => ({
|
|
201
|
+
type: 'radio' as const,
|
|
202
|
+
label: field.label,
|
|
203
|
+
checked: lifted.encoding.field === field.value,
|
|
204
|
+
onClick: () => {
|
|
205
|
+
self.setWalkColor(lifted.name, {
|
|
206
|
+
field: field.value,
|
|
207
|
+
})
|
|
208
|
+
},
|
|
209
|
+
})),
|
|
210
|
+
{ type: 'subHeader' as const, label: 'Palette' },
|
|
211
|
+
// the rainbow is the reference-position ramp
|
|
212
|
+
...WALK_SCHEMES.filter(
|
|
213
|
+
scheme =>
|
|
214
|
+
scheme.value !== 'rainbow' ||
|
|
215
|
+
lifted.encoding.field === 'reference',
|
|
216
|
+
).map(scheme => ({
|
|
217
|
+
type: 'radio' as const,
|
|
218
|
+
label: scheme.label,
|
|
219
|
+
checked: lifted.encoding.scheme === scheme.value,
|
|
220
|
+
onClick: () => {
|
|
221
|
+
self.setWalkColor(lifted.name, {
|
|
222
|
+
scheme: scheme.value,
|
|
223
|
+
})
|
|
224
|
+
},
|
|
225
|
+
})),
|
|
226
|
+
],
|
|
227
|
+
})),
|
|
228
|
+
],
|
|
229
|
+
},
|
|
230
|
+
]
|
|
231
|
+
: []),
|
|
232
|
+
...(TUBE_MAP_MODES.has(self.chosenLayoutMode)
|
|
233
|
+
? [
|
|
234
|
+
{
|
|
235
|
+
label: 'Fold variants',
|
|
236
|
+
subMenu: TUBE_MAP_FOLDS.map(({ bp, label }) => ({
|
|
237
|
+
type: 'radio' as const,
|
|
238
|
+
label,
|
|
239
|
+
checked: self.tubeMapFold === bp,
|
|
240
|
+
disabled: bp > 0 && self.graph?.reads !== undefined,
|
|
241
|
+
onClick: () => {
|
|
242
|
+
self.setTubeMapFold(bp)
|
|
243
|
+
void self.recomputeLayout()
|
|
244
|
+
},
|
|
245
|
+
})),
|
|
246
|
+
},
|
|
247
|
+
]
|
|
248
|
+
: []),
|
|
249
|
+
...(self.chosenLayoutMode === 'walkrows' &&
|
|
250
|
+
self.repeatChoices.length > 0
|
|
251
|
+
? [
|
|
252
|
+
{
|
|
253
|
+
label: 'Repeat',
|
|
254
|
+
subMenu: [
|
|
255
|
+
{
|
|
256
|
+
type: 'radio' as const,
|
|
257
|
+
label: 'Whole window',
|
|
258
|
+
checked: self.repeatKey === '',
|
|
259
|
+
onClick: () => {
|
|
260
|
+
self.setRepeatKey('')
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
...self.repeatChoices.map(({ key, name, unit }) => ({
|
|
264
|
+
type: 'radio' as const,
|
|
265
|
+
label: `${name} · ${unit.toLocaleString()} bp unit`,
|
|
266
|
+
checked: self.repeatKey === key,
|
|
267
|
+
onClick: () => {
|
|
268
|
+
self.setRepeatKey(key)
|
|
269
|
+
},
|
|
270
|
+
})),
|
|
271
|
+
],
|
|
272
|
+
},
|
|
273
|
+
]
|
|
274
|
+
: []),
|
|
275
|
+
...(self.hostPlacesX
|
|
276
|
+
? []
|
|
277
|
+
: [
|
|
278
|
+
{
|
|
279
|
+
label: 'Zoom in',
|
|
280
|
+
onClick: () => {
|
|
281
|
+
self.zoom(
|
|
282
|
+
1.5,
|
|
283
|
+
self.viewBox.width / 2,
|
|
284
|
+
self.viewBox.height / 2,
|
|
285
|
+
)
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
label: 'Zoom out',
|
|
290
|
+
onClick: () => {
|
|
291
|
+
self.zoom(
|
|
292
|
+
1 / 1.5,
|
|
293
|
+
self.viewBox.width / 2,
|
|
294
|
+
self.viewBox.height / 2,
|
|
295
|
+
)
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
label: 'Zoom to fit',
|
|
300
|
+
onClick: () => {
|
|
301
|
+
self.zoomToFit()
|
|
302
|
+
},
|
|
303
|
+
},
|
|
304
|
+
]),
|
|
305
|
+
{
|
|
306
|
+
type: 'checkbox',
|
|
307
|
+
label: 'Mark bubbles',
|
|
308
|
+
checked: self.showBubbles,
|
|
309
|
+
onClick: () => {
|
|
310
|
+
self.setShowBubbles(!self.showBubbles)
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
type: 'checkbox',
|
|
315
|
+
label: 'Show deletion edges',
|
|
316
|
+
checked: self.showDeletionEdges,
|
|
317
|
+
onClick: () => {
|
|
318
|
+
self.setShowDeletionEdges(!self.showDeletionEdges)
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
type: 'checkbox',
|
|
323
|
+
label: 'Genes on the backbone',
|
|
324
|
+
checked: self.showGenes,
|
|
325
|
+
onClick: () => {
|
|
326
|
+
self.setShowGenes(!self.showGenes)
|
|
327
|
+
},
|
|
328
|
+
},
|
|
329
|
+
...(!self.host &&
|
|
330
|
+
self.modeDrawsNodes &&
|
|
331
|
+
(self.graph?.paths?.length ?? 0) > 1
|
|
332
|
+
? [
|
|
333
|
+
{
|
|
334
|
+
type: 'checkbox' as const,
|
|
335
|
+
label: 'Walk rows under the graph',
|
|
336
|
+
checked: self.walkStrip,
|
|
337
|
+
onClick: () => {
|
|
338
|
+
self.setWalkStrip(!self.walkStrip)
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
]
|
|
342
|
+
: []),
|
|
343
|
+
...(self.referenceStripApplies
|
|
344
|
+
? [
|
|
345
|
+
{
|
|
346
|
+
type: 'checkbox' as const,
|
|
347
|
+
label: 'Reference strip at bp',
|
|
348
|
+
checked: self.showReferenceStrip,
|
|
349
|
+
onClick: () => {
|
|
350
|
+
self.setShowReferenceStrip(!self.showReferenceStrip)
|
|
351
|
+
},
|
|
352
|
+
},
|
|
353
|
+
]
|
|
354
|
+
: []),
|
|
355
|
+
{
|
|
356
|
+
label: 'Export SVG',
|
|
357
|
+
disabled: self.figureUnavailable !== undefined,
|
|
358
|
+
disabledHelpText: self.figureUnavailable,
|
|
359
|
+
onClick: () => {
|
|
360
|
+
const svg = self.figure()
|
|
361
|
+
if (svg) {
|
|
362
|
+
downloadText(
|
|
363
|
+
svg,
|
|
364
|
+
`${(self.graph?.name ?? 'graph').replaceAll(/[^\w.-]+/g, '_')}.svg`,
|
|
365
|
+
)
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
label: 'Copy figure spec',
|
|
371
|
+
disabled: self.figureSpecUnavailable !== undefined,
|
|
372
|
+
disabledHelpText: self.figureSpecUnavailable,
|
|
373
|
+
onClick: () => {
|
|
374
|
+
const spec = self.figureSpec()
|
|
375
|
+
const session = getSession(self)
|
|
376
|
+
navigator.clipboard
|
|
377
|
+
.writeText(`${JSON.stringify(spec, null, 2)}\n`)
|
|
378
|
+
.then(() => {
|
|
379
|
+
session.notify(
|
|
380
|
+
'Figure spec copied. Save it as spec.json and run: npx -p @jbrowse/bandage-core bandage-figure spec.json -o figure.svg',
|
|
381
|
+
'info',
|
|
382
|
+
)
|
|
383
|
+
})
|
|
384
|
+
.catch((e: unknown) => {
|
|
385
|
+
session.notify(`Could not copy the figure spec: ${String(e)}`)
|
|
386
|
+
})
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
]
|
|
390
|
+
},
|
|
391
|
+
launchMenuItems(): MenuItem[] {
|
|
392
|
+
const items: MenuItem[] = []
|
|
393
|
+
for (const item of graphLaunchMenuItems({
|
|
394
|
+
contributors: self.launchableAssemblies,
|
|
395
|
+
syntenyTracks: self.syntenyLaunchTracks,
|
|
396
|
+
onShowLinear: target => {
|
|
397
|
+
self.showInLinearView(target)
|
|
398
|
+
},
|
|
399
|
+
onShowSynteny: trackId => {
|
|
400
|
+
self.showSyntenyView(trackId)
|
|
401
|
+
},
|
|
402
|
+
})) {
|
|
403
|
+
pushLaunchViewMenuItem(items, item)
|
|
404
|
+
}
|
|
405
|
+
return items
|
|
406
|
+
},
|
|
407
|
+
}))
|