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,191 @@
|
|
|
1
|
+
import {
|
|
2
|
+
backboneNodes,
|
|
3
|
+
backboneSpan,
|
|
4
|
+
} from '@jbrowse/bandage-core/anchoredNodes'
|
|
5
|
+
import { nodeReferenceSpan } from '@jbrowse/bandage-core/referenceSpan'
|
|
6
|
+
import { readConfObject } from '@jbrowse/core/configuration'
|
|
7
|
+
import { getContainingView, getSession } from '@jbrowse/core/util'
|
|
8
|
+
|
|
9
|
+
import { withGraphViews } from './graphViews'
|
|
10
|
+
import {
|
|
11
|
+
contributingAssemblies,
|
|
12
|
+
nodeOwnLocation,
|
|
13
|
+
resolveContributors,
|
|
14
|
+
resolveLocationAssembly,
|
|
15
|
+
} from '../../launchFromGraph/contributors'
|
|
16
|
+
import {
|
|
17
|
+
canonicalAssemblyName,
|
|
18
|
+
paddedLocation,
|
|
19
|
+
withReferenceRegion,
|
|
20
|
+
} from '../../launchFromGraph/launchFromGraph'
|
|
21
|
+
import { linearViewTarget } from '../../launchFromGraph/linearViewTarget'
|
|
22
|
+
import { GENE_ADAPTER_TYPES, pickGeneTrack } from '../genes/geneFeatures'
|
|
23
|
+
import { isLinearHost } from '../host'
|
|
24
|
+
|
|
25
|
+
import type { LinearHost } from '../host'
|
|
26
|
+
|
|
27
|
+
export const withLaunchViews = withGraphViews
|
|
28
|
+
.views(self => ({
|
|
29
|
+
// Every assembly this graph names a segment from, with the locus each one
|
|
30
|
+
// contributes here. rGFA's SN tag is what makes this knowable: the graph
|
|
31
|
+
// states its own contributors, so the view can offer a way out to each of
|
|
32
|
+
// them without consulting an alignment.
|
|
33
|
+
//
|
|
34
|
+
// Gaps larger than the backbone span split a contributor's segments into
|
|
35
|
+
// separate loci and the widest wins, so a sample that also contributes
|
|
36
|
+
// sequence from a distant duplication is launched at the locus on screen
|
|
37
|
+
// rather than at the union of the two.
|
|
38
|
+
get contributingAssemblies() {
|
|
39
|
+
const graph = self.graph
|
|
40
|
+
const backbone = graph ? backboneNodes(graph) : []
|
|
41
|
+
return graph
|
|
42
|
+
? contributingAssemblies(graph, {
|
|
43
|
+
maxGap: backbone.length > 0 ? backboneSpan(backbone) : Infinity,
|
|
44
|
+
})
|
|
45
|
+
: []
|
|
46
|
+
},
|
|
47
|
+
}))
|
|
48
|
+
.views(self => ({
|
|
49
|
+
// A node's PanSN sample as an assembly this session can open, or
|
|
50
|
+
// undefined. The graph's spelling and the assembly's need not agree:
|
|
51
|
+
// HPRC writes `CHM13` where the assembly is UCSC's `hs1`. The track the
|
|
52
|
+
// graph was cut from states that pairing in its `assemblyNameToPanSN`,
|
|
53
|
+
// so its map is read first, then `assemblyManager`'s names and aliases.
|
|
54
|
+
//
|
|
55
|
+
// `has` before `get`, deliberately: `get` reports an unknown name to
|
|
56
|
+
// `Core-handleUnrecognizedAssembly`, which asks every installed plugin to
|
|
57
|
+
// go supply it, and this is a probe run for hundreds of haplotypes per
|
|
58
|
+
// graph.
|
|
59
|
+
get assemblyResolver() {
|
|
60
|
+
const { assemblyManager } = getSession(self)
|
|
61
|
+
const panSN = self.sourceAdapter?.assemblyNameToPanSN as
|
|
62
|
+
Record<string, string> | undefined
|
|
63
|
+
const byPrefix = new Map(
|
|
64
|
+
Object.entries(panSN ?? {}).map(([asm, prefix]) => [prefix, asm]),
|
|
65
|
+
)
|
|
66
|
+
const loaded = (name: string | undefined) =>
|
|
67
|
+
name !== undefined && assemblyManager.has(name)
|
|
68
|
+
? (assemblyManager.get(name)?.name ?? name)
|
|
69
|
+
: undefined
|
|
70
|
+
return (sample: string) => loaded(byPrefix.get(sample)) ?? loaded(sample)
|
|
71
|
+
},
|
|
72
|
+
// Each assembly's gene track among the session's tracks, picked as the
|
|
73
|
+
// backbone's is, so a walk row can read its haplotype's own annotation.
|
|
74
|
+
// One pass over the tracks, not one per row.
|
|
75
|
+
get geneTracksByAssembly() {
|
|
76
|
+
const byAssembly = new Map<
|
|
77
|
+
string,
|
|
78
|
+
{ trackId: string; name: string; adapterType: string }[]
|
|
79
|
+
>()
|
|
80
|
+
for (const t of getSession(self).tracks) {
|
|
81
|
+
const adapterType = (readConfObject(t, 'adapter') as { type: string })
|
|
82
|
+
.type
|
|
83
|
+
if (!GENE_ADAPTER_TYPES.has(adapterType)) {
|
|
84
|
+
continue
|
|
85
|
+
}
|
|
86
|
+
const track = {
|
|
87
|
+
trackId: t.trackId as string,
|
|
88
|
+
name: readConfObject(t, 'name') as string,
|
|
89
|
+
adapterType,
|
|
90
|
+
}
|
|
91
|
+
for (const name of readConfObject(t, 'assemblyNames') as string[]) {
|
|
92
|
+
const asm = canonicalAssemblyName(getSession(self), name)
|
|
93
|
+
byAssembly.set(asm, [...(byAssembly.get(asm) ?? []), track])
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return new Map(
|
|
97
|
+
[...byAssembly].flatMap(([asm, tracks]) => {
|
|
98
|
+
const picked = pickGeneTrack(tracks, '')
|
|
99
|
+
return picked ? [[asm, picked] as const] : []
|
|
100
|
+
}),
|
|
101
|
+
)
|
|
102
|
+
},
|
|
103
|
+
}))
|
|
104
|
+
.views(self => ({
|
|
105
|
+
// The contributors a view can actually be opened on: those naming an
|
|
106
|
+
// assembly this session has loaded. Every strain of an E. coli pangenome
|
|
107
|
+
// demo is its own assembly, so all of them resolve; an HPRC graph names
|
|
108
|
+
// hundreds of haplotypes that no session loads, so only the reference
|
|
109
|
+
// does.
|
|
110
|
+
get launchableAssemblies() {
|
|
111
|
+
return resolveContributors(
|
|
112
|
+
withReferenceRegion(self.contributingAssemblies, self.graphRegion),
|
|
113
|
+
self.assemblyResolver,
|
|
114
|
+
)
|
|
115
|
+
},
|
|
116
|
+
// Whether there is a linear view this graph may draw a highlight into —
|
|
117
|
+
// the paired one, or the session's only one on the reference assembly.
|
|
118
|
+
// Read by the node menu, which offers the item only when it would land
|
|
119
|
+
// somewhere.
|
|
120
|
+
get canHighlightInLinearView() {
|
|
121
|
+
const region = self.graphRegion
|
|
122
|
+
return (
|
|
123
|
+
region !== undefined &&
|
|
124
|
+
linearViewTarget({
|
|
125
|
+
views: [...getSession(self).views],
|
|
126
|
+
connectedViewId: self.connectedViewId,
|
|
127
|
+
assemblyName: region.assemblyName,
|
|
128
|
+
}) !== undefined
|
|
129
|
+
)
|
|
130
|
+
},
|
|
131
|
+
// Where one node can be opened: on its own assembly, and on the reference
|
|
132
|
+
// the graph was cut against. Both are padded to a readable window — a
|
|
133
|
+
// base-level allele is a few bp, and a linear view framed on exactly that
|
|
134
|
+
// shows no context at all.
|
|
135
|
+
nodeLaunchTargets(nodeId: string) {
|
|
136
|
+
const node = self.nodeById?.get(nodeId)
|
|
137
|
+
const own = node ? nodeOwnLocation(node) : undefined
|
|
138
|
+
const ownAssembly = own
|
|
139
|
+
? resolveLocationAssembly(self.assemblyResolver, own)
|
|
140
|
+
: undefined
|
|
141
|
+
const region = self.graphRegion
|
|
142
|
+
const nodeById = self.nodeById
|
|
143
|
+
const neighbors = self.nodeNeighbors
|
|
144
|
+
const span =
|
|
145
|
+
region && nodeById && neighbors
|
|
146
|
+
? nodeReferenceSpan({ nodeId, nodeById, neighbors })
|
|
147
|
+
: undefined
|
|
148
|
+
const onReference =
|
|
149
|
+
region && span
|
|
150
|
+
? {
|
|
151
|
+
sample: region.assemblyName,
|
|
152
|
+
haplotype: undefined,
|
|
153
|
+
refName: region.refName,
|
|
154
|
+
...span,
|
|
155
|
+
}
|
|
156
|
+
: undefined
|
|
157
|
+
return {
|
|
158
|
+
own:
|
|
159
|
+
own && ownAssembly
|
|
160
|
+
? { location: paddedLocation(own), assembly: ownAssembly }
|
|
161
|
+
: undefined,
|
|
162
|
+
reference:
|
|
163
|
+
region && onReference
|
|
164
|
+
? {
|
|
165
|
+
location: paddedLocation(onReference),
|
|
166
|
+
assembly: region.assemblyName,
|
|
167
|
+
}
|
|
168
|
+
: undefined,
|
|
169
|
+
// Unpadded: a mark is of the node, the same span its hover band
|
|
170
|
+
// draws. The padding above is room to read a view opened on it.
|
|
171
|
+
highlight:
|
|
172
|
+
region && onReference
|
|
173
|
+
? { location: onReference, assembly: region.assemblyName }
|
|
174
|
+
: undefined,
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
}))
|
|
178
|
+
.views(self => ({
|
|
179
|
+
// The linear view this pane draws inside, when a display hosts it: x is
|
|
180
|
+
// that view's window and the cut is re-made when the window leaves it.
|
|
181
|
+
// A pane that is a view of its own has none.
|
|
182
|
+
get host(): LinearHost | undefined {
|
|
183
|
+
let view: unknown
|
|
184
|
+
try {
|
|
185
|
+
view = getContainingView(self)
|
|
186
|
+
} catch {
|
|
187
|
+
return undefined
|
|
188
|
+
}
|
|
189
|
+
return isLinearHost(view) ? view : undefined
|
|
190
|
+
},
|
|
191
|
+
}))
|