jbrowse-plugin-graphgenomeviewer 7.4.3 → 7.5.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.
Files changed (170) hide show
  1. package/README.md +10 -7
  2. package/dist/chunks/{AddTrackWorkflow-LK25EC3H.js → AddTrackWorkflow-NLSZYK56.js} +2 -2
  3. package/dist/chunks/{GbzBaseSyntenyAdapter-EKLUEECW.js → GbzBaseSyntenyAdapter-4KVWVUN6.js} +2 -2
  4. package/dist/chunks/{GbzBaseSyntenyAdapter-EKLUEECW.js.map → GbzBaseSyntenyAdapter-4KVWVUN6.js.map} +1 -1
  5. package/dist/chunks/{GraphGenomeView-P3XMSKUQ.js → GraphGenomeView-KI4FQ5A7.js} +2 -2
  6. package/dist/chunks/GraphTrackSettingsDialog-UQNMDXTE.js +4 -0
  7. package/dist/chunks/GraphTrackSettingsDialog-UQNMDXTE.js.map +7 -0
  8. package/dist/chunks/{HighlightColorDialog-G6AFRYUD.js → HighlightColorDialog-D4RCUCUF.js} +2 -2
  9. package/dist/chunks/LinearGraphDisplay-RPZUZSM2.js +2 -0
  10. package/dist/chunks/{LinearGraphDisplay-O4SQSXJJ.js.map → LinearGraphDisplay-RPZUZSM2.js.map} +2 -2
  11. package/dist/chunks/MinigraphBubbleAdapter-TJYI7KEN.js +2 -0
  12. package/dist/chunks/{MinigraphBubbleAdapter-3NJ2VLN2.js.map → MinigraphBubbleAdapter-TJYI7KEN.js.map} +1 -1
  13. package/dist/chunks/RgfaTabixAdapter-5ZMJLFZP.js +2 -0
  14. package/dist/chunks/RgfaTabixAdapter-5ZMJLFZP.js.map +7 -0
  15. package/dist/chunks/WalkFormsAdapter-CAJOWOEX.js +2 -0
  16. package/dist/chunks/WalkFormsAdapter-CAJOWOEX.js.map +7 -0
  17. package/dist/chunks/WalkTabixSyntenyAdapter-VI3KA2GX.js +2 -0
  18. package/dist/chunks/{WalkTabixSyntenyAdapter-NHNSZZBX.js.map → WalkTabixSyntenyAdapter-VI3KA2GX.js.map} +2 -2
  19. package/dist/chunks/{chunk-MCE6STZR.js → chunk-22ANI2KL.js} +2 -2
  20. package/dist/chunks/{chunk-MCE6STZR.js.map → chunk-22ANI2KL.js.map} +1 -1
  21. package/dist/chunks/chunk-42KD4AVY.js +2 -0
  22. package/dist/chunks/{chunk-OKRGO7XA.js.map → chunk-42KD4AVY.js.map} +4 -4
  23. package/dist/chunks/chunk-4NIWMRKH.js +2 -0
  24. package/dist/chunks/chunk-4NIWMRKH.js.map +7 -0
  25. package/dist/chunks/chunk-BCOXRUNQ.js +3 -0
  26. package/dist/chunks/chunk-BCOXRUNQ.js.map +7 -0
  27. package/dist/chunks/chunk-DAPI7M4M.js +4 -0
  28. package/dist/chunks/chunk-DAPI7M4M.js.map +7 -0
  29. package/dist/chunks/chunk-DEWZOJSC.js +2 -0
  30. package/dist/chunks/{chunk-6OXXT2YP.js.map → chunk-DEWZOJSC.js.map} +4 -4
  31. package/dist/chunks/{chunk-K4TFAHGC.js → chunk-FCMXEFJA.js} +1 -1
  32. package/dist/chunks/{chunk-K4TFAHGC.js.map → chunk-FCMXEFJA.js.map} +1 -1
  33. package/dist/chunks/{chunk-UOFWYS6T.js → chunk-GYY6LF5L.js} +1 -1
  34. package/dist/chunks/{chunk-UOFWYS6T.js.map → chunk-GYY6LF5L.js.map} +1 -1
  35. package/dist/chunks/{chunk-F2DMEJEK.js → chunk-HHMJNAA3.js} +2 -2
  36. package/dist/chunks/{chunk-NPV7SRJD.js → chunk-HTTONSO4.js} +2 -2
  37. package/dist/chunks/{chunk-NPV7SRJD.js.map → chunk-HTTONSO4.js.map} +1 -1
  38. package/dist/chunks/{chunk-MVVXRZXV.js → chunk-JRJHXLGP.js} +2 -2
  39. package/dist/chunks/{chunk-MVVXRZXV.js.map → chunk-JRJHXLGP.js.map} +2 -2
  40. package/dist/chunks/chunk-K4JL57NR.js +2 -0
  41. package/dist/chunks/chunk-K4JL57NR.js.map +7 -0
  42. package/dist/chunks/chunk-KOC23YNN.js +4 -0
  43. package/dist/chunks/chunk-KOC23YNN.js.map +7 -0
  44. package/dist/chunks/{chunk-MNCPMOHJ.js → chunk-LTNFVL2F.js} +2 -2
  45. package/dist/chunks/chunk-OZEKEYT3.js +2 -0
  46. package/dist/chunks/{chunk-ZAYC5OMQ.js.map → chunk-OZEKEYT3.js.map} +4 -4
  47. package/dist/chunks/{chunk-DUPBXBYE.js → chunk-POUV7OPY.js} +2 -2
  48. package/dist/chunks/{chunk-DUPBXBYE.js.map → chunk-POUV7OPY.js.map} +1 -1
  49. package/dist/chunks/{chunk-CNNZDE6I.js → chunk-SPL3UO2D.js} +2 -2
  50. package/dist/chunks/{chunk-CNNZDE6I.js.map → chunk-SPL3UO2D.js.map} +1 -1
  51. package/dist/chunks/{chunk-QJ43NDYS.js → chunk-TYV6UXJA.js} +2 -2
  52. package/dist/chunks/chunk-UR2MJJUP.js +2 -0
  53. package/dist/chunks/chunk-VTMJQFN5.js +2 -0
  54. package/dist/chunks/chunk-VTMJQFN5.js.map +7 -0
  55. package/dist/chunks/{chunk-CXOMX2I6.js → chunk-XZGYJ3JC.js} +1 -1
  56. package/dist/chunks/{chunk-CXOMX2I6.js.map → chunk-XZGYJ3JC.js.map} +1 -1
  57. package/dist/chunks/{chunk-TGSDXZXI.js → chunk-Z3IKZAYC.js} +2 -2
  58. package/dist/chunks/{chunk-TGSDXZXI.js.map → chunk-Z3IKZAYC.js.map} +1 -1
  59. package/dist/chunks/chunk-ZV5FNOHS.js +3 -0
  60. package/dist/chunks/chunk-ZV5FNOHS.js.map +7 -0
  61. package/dist/chunks/{renderSvg-7G6NWBXF.js → renderSvg-3PPAEMBT.js} +2 -2
  62. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +4 -4
  63. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +4 -4
  64. package/package.json +3 -3
  65. package/src/GraphComputeLayout.test.ts +24 -0
  66. package/src/GraphComputeLayout.ts +4 -2
  67. package/src/GraphGenomeView/components/GraphSettingsDialog.tsx +16 -0
  68. package/src/GraphGenomeView/components/WalkRowsOverlay.tsx +83 -0
  69. package/src/GraphGenomeView/components/usePaneGestures.test.tsx +82 -5
  70. package/src/GraphGenomeView/components/usePaneGestures.ts +10 -4
  71. package/src/GraphGenomeView/graphLayers.ts +14 -1
  72. package/src/GraphGenomeView/legendSections.ts +32 -0
  73. package/src/GraphGenomeView/model.test.ts +294 -113
  74. package/src/GraphGenomeView/model.ts +3 -10
  75. package/src/GraphGenomeView/nodeSize.test.ts +21 -5
  76. package/src/GraphGenomeView/nodeSize.ts +24 -8
  77. package/src/GraphGenomeView/pane/fitViews.ts +5 -110
  78. package/src/GraphGenomeView/pane/graphViews.ts +96 -20
  79. package/src/GraphGenomeView/pane/launchActions.ts +55 -33
  80. package/src/GraphGenomeView/pane/launchViews.ts +46 -0
  81. package/src/GraphGenomeView/pane/loadActions.ts +85 -25
  82. package/src/GraphGenomeView/pane/morph.test.ts +25 -1
  83. package/src/GraphGenomeView/pane/morph.ts +3 -1
  84. package/src/GraphGenomeView/pane/paneBase.ts +5 -7
  85. package/src/GraphGenomeView/pane/renderingActions.ts +61 -2
  86. package/src/GraphGenomeView/pane/settingActions.ts +62 -4
  87. package/src/GraphGenomeView/pane/walkRowViews.ts +17 -6
  88. package/src/GraphGenomeView/tubeMapPanels.ts +2 -1
  89. package/src/GraphGenomeView/viewModel.ts +4 -9
  90. package/src/GraphGenomeView/walkRowBlocks.ts +50 -0
  91. package/src/LinearGraphDisplay/LinearGraphDisplay.test.ts +35 -5
  92. package/src/LinearGraphDisplay/components/GraphStatusChrome.test.tsx +18 -0
  93. package/src/LinearGraphDisplay/components/GraphStatusChrome.tsx +4 -2
  94. package/src/LinearGraphDisplay/components/SubgraphHaplotypesField.test.tsx +41 -1
  95. package/src/LinearGraphDisplay/components/SubgraphHaplotypesField.tsx +33 -19
  96. package/src/LinearGraphDisplay/configSchema.ts +4 -3
  97. package/src/RgfaTabixAdapter/RgfaTabixAdapter.ts +2 -9
  98. package/src/RgfaTabixAdapter/configSchema.ts +3 -3
  99. package/src/RgfaTabixAdapter/walkFiles.test.ts +6 -6
  100. package/src/WalkFormsAdapter/WalkFormsAdapter.test.ts +204 -0
  101. package/src/WalkFormsAdapter/WalkFormsAdapter.ts +232 -0
  102. package/src/WalkFormsAdapter/configSchema.ts +127 -0
  103. package/src/WalkFormsAdapter/formRows.test.ts +258 -0
  104. package/src/WalkFormsAdapter/formRows.ts +231 -0
  105. package/src/WalkFormsAdapter/formsMenu.test.ts +237 -0
  106. package/src/WalkFormsAdapter/formsMenu.ts +202 -0
  107. package/src/WalkFormsAdapter/index.ts +21 -0
  108. package/src/WalkFormsAdapter/pinned.ts +33 -0
  109. package/src/WalkTabixSyntenyAdapter/WalkTabixSyntenyAdapter.test.ts +5 -5
  110. package/src/WalkTabixSyntenyAdapter/WalkTabixSyntenyAdapter.ts +3 -6
  111. package/src/WalkTabixSyntenyAdapter/configSchema.ts +2 -2
  112. package/src/hoverSync/graphViewHighlights.test.ts +53 -0
  113. package/src/hoverSync/graphViewHighlights.ts +25 -0
  114. package/src/hoverSync/lgvHover.test.ts +100 -1
  115. package/src/hoverSync/lgvHover.ts +77 -6
  116. package/src/index.ts +4 -0
  117. package/src/launchFromGraph/contributors.test.ts +52 -0
  118. package/src/launchFromGraph/contributors.ts +105 -1
  119. package/src/launchFromGraph/launchFromGraph.ts +2 -2
  120. package/src/panSNAliases/panSNAliases.test.ts +2 -2
  121. package/src/panSNTabix.test.ts +28 -0
  122. package/src/panSNTabix.ts +26 -8
  123. package/src/version.ts +1 -1
  124. package/dist/chunks/GraphTrackSettingsDialog-UTYH6HEC.js +0 -6
  125. package/dist/chunks/GraphTrackSettingsDialog-UTYH6HEC.js.map +0 -7
  126. package/dist/chunks/LinearGraphDisplay-O4SQSXJJ.js +0 -2
  127. package/dist/chunks/MinigraphBubbleAdapter-3NJ2VLN2.js +0 -2
  128. package/dist/chunks/RgfaTabixAdapter-55DGDID2.js +0 -2
  129. package/dist/chunks/RgfaTabixAdapter-55DGDID2.js.map +0 -7
  130. package/dist/chunks/WalkTabixSyntenyAdapter-NHNSZZBX.js +0 -2
  131. package/dist/chunks/chunk-4I3K4RHE.js +0 -2
  132. package/dist/chunks/chunk-4I3K4RHE.js.map +0 -7
  133. package/dist/chunks/chunk-6OXXT2YP.js +0 -2
  134. package/dist/chunks/chunk-NFH2U74B.js +0 -2
  135. package/dist/chunks/chunk-OKRGO7XA.js +0 -2
  136. package/dist/chunks/chunk-P7VMOTUM.js +0 -3
  137. package/dist/chunks/chunk-P7VMOTUM.js.map +0 -7
  138. package/dist/chunks/chunk-RU4WSKBO.js +0 -3
  139. package/dist/chunks/chunk-RU4WSKBO.js.map +0 -7
  140. package/dist/chunks/chunk-WGTLNVST.js +0 -2
  141. package/dist/chunks/chunk-WGTLNVST.js.map +0 -7
  142. package/dist/chunks/chunk-XQFBLJU5.js +0 -4
  143. package/dist/chunks/chunk-XQFBLJU5.js.map +0 -7
  144. package/dist/chunks/chunk-Y5DNBFDY.js +0 -3
  145. package/dist/chunks/chunk-Y5DNBFDY.js.map +0 -7
  146. package/dist/chunks/chunk-ZAYC5OMQ.js +0 -2
  147. package/src/launchFromGraph/launchTracks.test.ts +0 -95
  148. package/src/launchFromGraph/launchTracks.ts +0 -49
  149. /package/dist/chunks/{AddTrackWorkflow-LK25EC3H.js.map → AddTrackWorkflow-NLSZYK56.js.map} +0 -0
  150. /package/dist/chunks/{GraphGenomeView-P3XMSKUQ.js.map → GraphGenomeView-KI4FQ5A7.js.map} +0 -0
  151. /package/dist/chunks/{HighlightColorDialog-G6AFRYUD.js.map → HighlightColorDialog-D4RCUCUF.js.map} +0 -0
  152. /package/dist/chunks/{chunk-F2DMEJEK.js.map → chunk-HHMJNAA3.js.map} +0 -0
  153. /package/dist/chunks/{chunk-MNCPMOHJ.js.map → chunk-LTNFVL2F.js.map} +0 -0
  154. /package/dist/chunks/{chunk-QJ43NDYS.js.map → chunk-TYV6UXJA.js.map} +0 -0
  155. /package/dist/chunks/{chunk-NFH2U74B.js.map → chunk-UR2MJJUP.js.map} +0 -0
  156. /package/dist/chunks/{renderSvg-7G6NWBXF.js.map → renderSvg-3PPAEMBT.js.map} +0 -0
  157. /package/src/RgfaTabixAdapter/test_data/{walks4_follow.GRCh38.walks.bed.gz → walks5_follow.GRCh38.walks.bed.gz} +0 -0
  158. /package/src/RgfaTabixAdapter/test_data/{walks4_follow.GRCh38.walks.bed.gz.tbi → walks5_follow.GRCh38.walks.bed.gz.tbi} +0 -0
  159. /package/src/RgfaTabixAdapter/test_data/{walks4_header.GRCh38.walks.bed.gz → walks5_header.GRCh38.walks.bed.gz} +0 -0
  160. /package/src/RgfaTabixAdapter/test_data/{walks4_header.GRCh38.walks.bed.gz.tbi → walks5_header.GRCh38.walks.bed.gz.tbi} +0 -0
  161. /package/src/RgfaTabixAdapter/test_data/{walks4_inversion.GRCh38.walks.bed.gz → walks5_inversion.GRCh38.walks.bed.gz} +0 -0
  162. /package/src/RgfaTabixAdapter/test_data/{walks4_inversion.GRCh38.walks.bed.gz.tbi → walks5_inversion.GRCh38.walks.bed.gz.tbi} +0 -0
  163. /package/src/RgfaTabixAdapter/test_data/{walks4_lanepairs.GRCh38.walks.bed.gz → walks5_lanepairs.GRCh38.walks.bed.gz} +0 -0
  164. /package/src/RgfaTabixAdapter/test_data/{walks4_lanepairs.GRCh38.walks.bed.gz.tbi → walks5_lanepairs.GRCh38.walks.bed.gz.tbi} +0 -0
  165. /package/src/RgfaTabixAdapter/test_data/{walks4_maxnode.GRCh38.walks.bed.gz → walks5_maxnode.GRCh38.walks.bed.gz} +0 -0
  166. /package/src/RgfaTabixAdapter/test_data/{walks4_maxnode.GRCh38.walks.bed.gz.tbi → walks5_maxnode.GRCh38.walks.bed.gz.tbi} +0 -0
  167. /package/src/RgfaTabixAdapter/test_data/{walks4_rejoin.GRCh38.walks.bed.gz → walks5_rejoin.GRCh38.walks.bed.gz} +0 -0
  168. /package/src/RgfaTabixAdapter/test_data/{walks4_rejoin.GRCh38.walks.bed.gz.tbi → walks5_rejoin.GRCh38.walks.bed.gz.tbi} +0 -0
  169. /package/src/RgfaTabixAdapter/test_data/{walks4_twopart.GRCh38.walks.bed.gz → walks5_twopart.GRCh38.walks.bed.gz} +0 -0
  170. /package/src/RgfaTabixAdapter/test_data/{walks4_twopart.GRCh38.walks.bed.gz.tbi → walks5_twopart.GRCh38.walks.bed.gz.tbi} +0 -0
@@ -0,0 +1,33 @@
1
+ export interface Pinned {
2
+ refName: string
3
+ start: number
4
+ end: number
5
+ }
6
+
7
+ export type FloorBp = number | 'auto'
8
+
9
+ export function pinnedOf(value: unknown): Pinned | undefined {
10
+ const { refName, start, end } = (value ?? {}) as Partial<Pinned>
11
+ return typeof refName === 'string' &&
12
+ Number.isFinite(start) &&
13
+ Number.isFinite(end) &&
14
+ start! < end!
15
+ ? { refName, start: start!, end: end! }
16
+ : undefined
17
+ }
18
+
19
+ export function floorOf(value: unknown): FloorBp {
20
+ const n = Number(value)
21
+ return value !== 'auto' && Number.isFinite(n) ? n : 'auto'
22
+ }
23
+
24
+ const n = (x: number) => x.toLocaleString('en-US')
25
+
26
+ // 1-based and closed, as a locus box reads
27
+ export const pinnedLocus = ({ refName, start, end }: Pinned) =>
28
+ `${refName}:${n(start + 1)}-${n(end)}`
29
+
30
+ // Names the window in each warning toast, so a re-pin or floor change can take
31
+ // the old ones down
32
+ export const warningPrefix = (pinned: Pinned) =>
33
+ `Forms of ${pinnedLocus(pinned)}: `
@@ -34,7 +34,7 @@ const fixture = (name: string) =>
34
34
 
35
35
  function makeAdapter(
36
36
  slots: Record<string, unknown> = {},
37
- name = 'walks4_header',
37
+ name = 'walks5_header',
38
38
  ) {
39
39
  const local = (path: string) => ({
40
40
  localPath: path,
@@ -111,7 +111,7 @@ test('a fetch for some haplotypes answers those lanes in the order asked, named
111
111
  })
112
112
 
113
113
  test('a fetch for some haplotypes reads them against a reference walk named without a haplotype', async () => {
114
- const found = await feats(makeAdapter({}, 'walks4_twopart'), {
114
+ const found = await feats(makeAdapter({}, 'walks5_twopart'), {
115
115
  haplotypes: ['HG002#1'],
116
116
  })
117
117
  expect(found.map(summary)).toEqual([
@@ -172,7 +172,7 @@ test('a batch of lane pairs answers each pair what it answers alone', async () =
172
172
  expect(batch).toHaveLength(2)
173
173
  })
174
174
 
175
- // walks4_lanepairs, a 5.5 kb reference of 2 kb flanks around three 500 bp
175
+ // walks5_lanepairs, a 5.5 kb reference of 2 kb flanks around three 500 bp
176
176
  // nodes, in 1 kb chunks:
177
177
  // W GRCh38 0 chr1 >1>2>3>4>5
178
178
  // W HG002 1 chr1 >1>2>3>4>5
@@ -180,7 +180,7 @@ test('a batch of lane pairs answers each pair what it answers alone', async () =
180
180
  // W HG00097 1 chr1 >1>2>6>2>6>2>3>4>5 2 three times, 6 a 30 bp spacer
181
181
  test('a lane pair matches through a copy-number array, and draws an inversion between the lanes as a reverse-strand record', async () => {
182
182
  const found = await firstValueFrom(
183
- makeAdapter({}, 'walks4_lanepairs')
183
+ makeAdapter({}, 'walks5_lanepairs')
184
184
  .getFeatures(
185
185
  { ...window, end: 5500 },
186
186
  {
@@ -554,7 +554,7 @@ test('a walk turned against the reference for 10 kb or more gains a reverse-stra
554
554
  // W HG00097 1 chr1 >1>2>3>4>5
555
555
  test('the anchor window answers a haplotype turned against the reference with a reverse-strand record of the turned stretch', async () => {
556
556
  const records = await firstValueFrom(
557
- makeAdapter({}, 'walks4_inversion')
557
+ makeAdapter({}, 'walks5_inversion')
558
558
  .getFeatures({ ...window, end: 55_000 }, {})
559
559
  .pipe(toArray()),
560
560
  )
@@ -101,12 +101,9 @@ export default class WalkTabixSyntenyAdapter extends ComparativeAdapterBase<Walk
101
101
  * asks for, and the nodes and links they visit
102
102
  */
103
103
  async getSubgraph(region: Region, opts: SubgraphAdapterOptions = {}) {
104
- const refName = await this.refNames.resolve(region, { signal: opts.signal })
105
- if (refName === undefined) {
106
- throw new Error(
107
- `${region.assemblyName} ${region.refName} is not in this graph's index; the graph is cut on ${this.anchor}, mapped to its PanSN prefix in assemblyNameToPanSN`,
108
- )
109
- }
104
+ const refName = await this.refNames.resolveForCut(region, {
105
+ signal: opts.signal,
106
+ })
110
107
  return this.walks.subgraph(refName, region, opts)
111
108
  }
112
109
 
@@ -25,7 +25,7 @@ import type { Instance } from '@jbrowse/mobx-state-tree'
25
25
  *
26
26
  * `walksUri` takes the prefix of one reference's walk file, `<prefix>.<sample>`,
27
27
  * and resolves `<walksUri>.walks.bed.gz` and its `.tbi`. The adapter reads walk
28
- * format 4, which gfa-to-tabix writes from 1.2, through @jbrowse/graph-walks.
28
+ * format 5, which gfa-to-tabix writes from 1.4, through @jbrowse/graph-walks.
29
29
  * Only a window on the anchor is answered.
30
30
  *
31
31
  * #example
@@ -56,7 +56,7 @@ const WalkTabixSyntenyAdapter = ConfigurationSchema(
56
56
  },
57
57
  /**
58
58
  * #slot
59
- * a `gfa-to-tabix --walks` file in walk format 4
59
+ * a `gfa-to-tabix --walks` file in walk format 5
60
60
  */
61
61
  walksLocation: fileLocationSlot('/path/to/graph.walks.bed.gz'),
62
62
  /**
@@ -200,3 +200,56 @@ describe("the drawing view has to be on the highlight's assembly", () => {
200
200
  expect(graphViewHighlights(noAssembly, 'lgv1', ['Sakai'])).toHaveLength(1)
201
201
  })
202
202
  })
203
+
204
+ describe("a hovered node's span on a haplotype's own assembly", () => {
205
+ const onHap = {
206
+ refName: 'CM094351.1',
207
+ start: 1200,
208
+ end: 1500,
209
+ assemblyName: 'HG002.1',
210
+ }
211
+
212
+ // the stack's rows and a view opened beside are not the graph's pair
213
+ test('draws in a view of that assembly, paired or not', () => {
214
+ const views = [
215
+ graphView({
216
+ connectedViewId: 'lgv-ref',
217
+ assemblyHoverHighlights: [onHap],
218
+ }),
219
+ linearView('lgv-ref'),
220
+ linearView('lgv-hap'),
221
+ ]
222
+ expect(graphViewHighlights(views, 'lgv-hap', ['HG002.1'])).toEqual([
223
+ { key: 'graph1-0', region: onHap },
224
+ ])
225
+ })
226
+
227
+ test('draws nowhere else, nor where the view states no assemblies', () => {
228
+ const views = [graphView({ assemblyHoverHighlights: [onHap] })]
229
+ expect(graphViewHighlights(views, 'lgv1', ['hg38'])).toEqual([])
230
+ expect(graphViewHighlights(views, 'lgv1')).toEqual([])
231
+ })
232
+
233
+ test("comes from a graph track's display too", () => {
234
+ const views = [
235
+ {
236
+ ...linearView('lgv-ref'),
237
+ tracks: [
238
+ {
239
+ displays: [
240
+ {
241
+ id: 'display1',
242
+ type: 'LinearGraphDisplay',
243
+ assemblyHoverHighlights: [onHap],
244
+ },
245
+ ],
246
+ },
247
+ ],
248
+ },
249
+ linearView('lgv-hap'),
250
+ ]
251
+ expect(graphViewHighlights(views, 'lgv-hap', ['HG002.1'])).toEqual([
252
+ { key: 'display1-0', region: onHap },
253
+ ])
254
+ })
255
+ })
@@ -124,6 +124,31 @@ export function graphViewHighlights(
124
124
  }
125
125
  }
126
126
  }
127
+ // A hovered node's span on each haplotype's own assembly goes to any
128
+ // view of that assembly, paired or not: the assembly name says where it
129
+ // belongs, and those views are a synteny stack's rows or opened beside
130
+ for (const graph of isRecord(view)
131
+ ? [
132
+ ...trackGraphs(view),
133
+ ...(view.type === 'GraphGenomeView' ? [view] : []),
134
+ ]
135
+ : []) {
136
+ const spans = Array.isArray(graph.assemblyHoverHighlights)
137
+ ? graph.assemblyHoverHighlights
138
+ : []
139
+ spans.forEach((value: unknown, i) => {
140
+ const region = readRegion(value)
141
+ if (
142
+ region?.assemblyName !== undefined &&
143
+ linearAssemblyNames?.includes(region.assemblyName)
144
+ ) {
145
+ highlights.push({
146
+ key: `${typeof graph.id === 'string' ? graph.id : 'graph'}-${i}`,
147
+ region,
148
+ })
149
+ }
150
+ })
151
+ }
127
152
  if (
128
153
  isRecord(view) &&
129
154
  view.type === 'GraphGenomeView' &&
@@ -1,5 +1,13 @@
1
- import { hoverInRegion, nodeForLgvHover, readLgvHover } from './lgvHover'
1
+ import {
2
+ bubbleForLgvHover,
3
+ hoverFromPair,
4
+ hoverInRegion,
5
+ nodeForLgvHover,
6
+ readLgvHover,
7
+ readSelectedFeature,
8
+ } from './lgvHover'
2
9
 
10
+ import type { MinigraphBubble } from '@jbrowse/bandage-core/bubbles/bubbleLine'
3
11
  import type { GraphNode } from '@jbrowse/bandage-core/types'
4
12
 
5
13
  // The shape LinearGenomeViewContainer writes on mousemove: `hoverPosition` is a
@@ -200,3 +208,94 @@ test('a coordinate past the graph resolves to nothing', () => {
200
208
  nodeForLgvHover({ hover: { refName: 'chr1', coord: 9999 }, nodes: NODES }),
201
209
  ).toBeNull()
202
210
  })
211
+
212
+ describe('the bubble a linear-view feature names', () => {
213
+ const bubble = (over: Partial<MinigraphBubble>): MinigraphBubble => ({
214
+ refName: 'chr1',
215
+ start: 5,
216
+ end: 8,
217
+ segmentCount: 3,
218
+ pathCount: 2,
219
+ inversion: false,
220
+ shortestAlleleLength: 0,
221
+ longestAlleleLength: 2,
222
+ segments: '',
223
+ shortestAllele: undefined,
224
+ longestAllele: undefined,
225
+ ...over,
226
+ })
227
+ const indexed = bubble({ segments: 's10,s11,s12' })
228
+ const derived = bubble({ segments: 's21,s20,s22', key: 's20>s22' })
229
+ const bubbles = [indexed, derived]
230
+ const at = { refName: 'chr1', coord: 6 }
231
+
232
+ test("is the indexed bubble with a bubble feature's segments", () => {
233
+ expect(
234
+ bubbleForLgvHover(
235
+ { ...at, featureSegments: 's10,s11,s12', featureName: '2 bp' },
236
+ bubbles,
237
+ ),
238
+ ).toBe(indexed)
239
+ })
240
+
241
+ // vg deconstruct writes the snarl's ends as the record ID
242
+ test('is the bubble a graph-derived VCF record names, either way round', () => {
243
+ expect(bubbleForLgvHover({ ...at, featureName: '>s20>s22' }, bubbles)).toBe(
244
+ derived,
245
+ )
246
+ expect(bubbleForLgvHover({ ...at, featureName: '<s22<s20' }, bubbles)).toBe(
247
+ derived,
248
+ )
249
+ expect(bubbleForLgvHover({ ...at, featureName: '>s10>s12' }, bubbles)).toBe(
250
+ indexed,
251
+ )
252
+ })
253
+
254
+ test('is nothing for a feature that names no bubble', () => {
255
+ expect(bubbleForLgvHover({ ...at, featureName: 'rs123' }, bubbles)).toBe(
256
+ undefined,
257
+ )
258
+ expect(bubbleForLgvHover({ ...at, featureName: '>s20>s99' }, bubbles)).toBe(
259
+ undefined,
260
+ )
261
+ })
262
+
263
+ test('a selected feature reads as a hover at its start', () => {
264
+ const fields: Record<string, unknown> = {
265
+ refName: 'chr1',
266
+ start: 5,
267
+ name: '>s20>s22',
268
+ }
269
+ expect(
270
+ readSelectedFeature({ get: (key: string) => fields[key] }),
271
+ ).toMatchObject({ refName: 'chr1', coord: 5, featureName: '>s20>s22' })
272
+ expect(readSelectedFeature(undefined)).toBeUndefined()
273
+ })
274
+ })
275
+
276
+ // Two linear views on one locus: the graph paired with A must not light for
277
+ // a hover in B
278
+ describe('a hover from another linear view', () => {
279
+ const at = (viewId?: string) => ({ refName: 'chr1', coord: 3, viewId })
280
+ const live = new Set(['lgvA', 'lgvB'])
281
+
282
+ test('is read off the hover payload', () => {
283
+ expect(
284
+ readLgvHover({
285
+ hoverPosition: { refName: 'chr1', coord: 4 },
286
+ viewId: 'lgvB',
287
+ })?.viewId,
288
+ ).toBe('lgvB')
289
+ })
290
+
291
+ test('is ignored by a graph paired with an open view', () => {
292
+ expect(hoverFromPair(at('lgvA'), 'lgvA', live)).toBe(true)
293
+ expect(hoverFromPair(at('lgvB'), 'lgvA', live)).toBe(false)
294
+ })
295
+
296
+ test('reaches an unpaired graph, one whose pair closed, or from an older host', () => {
297
+ expect(hoverFromPair(at('lgvB'), undefined, live)).toBe(true)
298
+ expect(hoverFromPair(at('lgvB'), 'gone', live)).toBe(true)
299
+ expect(hoverFromPair(at(), 'lgvA', live)).toBe(true)
300
+ })
301
+ })
@@ -3,6 +3,7 @@ import { isBackbone } from '@jbrowse/bandage-core/anchoredNodes'
3
3
  import { isRecord } from '../isRecord'
4
4
 
5
5
  import type { SubgraphRegion } from '../GetSubgraph'
6
+ import type { MinigraphBubble } from '@jbrowse/bandage-core/bubbles/bubbleLine'
6
7
  import type { GraphNode } from '@jbrowse/bandage-core/types'
7
8
 
8
9
  // What a LinearGenomeView writes to `session.hovered` on every mousemove (see
@@ -33,6 +34,11 @@ export interface LgvHover {
33
34
  // hover that states no assembly is taken at its word rather than dropped.
34
35
  assemblyName?: string
35
36
  featureName?: string
37
+ // a bubble feature's comma-separated segment names (MinigraphBubbleAdapter)
38
+ featureSegments?: string
39
+ // the linear view hovered, which hosts from jbrowse-components b49f05f438
40
+ // state
41
+ viewId?: string
36
42
  }
37
43
 
38
44
  interface FeatureLike {
@@ -46,13 +52,13 @@ function isFeatureLike(value: unknown): value is FeatureLike {
46
52
  // A display hovers either a Feature, read with `get`, or a plain hit item with
47
53
  // a `name` of its own, which is what the canvas feature display hands over.
48
54
  // Reading only the first left the exact segment match dead on that display.
49
- function hoveredName(feature: unknown) {
50
- const name = isFeatureLike(feature)
51
- ? feature.get('name')
55
+ function hoveredField(feature: unknown, key: string) {
56
+ const value = isFeatureLike(feature)
57
+ ? feature.get(key)
52
58
  : isRecord(feature)
53
- ? feature.name
59
+ ? feature[key]
54
60
  : undefined
55
- return typeof name === 'string' ? name : undefined
61
+ return typeof value === 'string' ? value : undefined
56
62
  }
57
63
 
58
64
  // `hovered` is typed `unknown` on the session by design — it is a shared channel
@@ -71,13 +77,49 @@ export function readLgvHover(hovered: unknown): LgvHover | undefined {
71
77
  coord: typeof coord0 === 'number' ? coord0 : coord - 1,
72
78
  assemblyName:
73
79
  typeof assemblyName === 'string' ? assemblyName : undefined,
74
- featureName: hoveredName(hovered.hoverFeature),
80
+ featureName: hoveredField(hovered.hoverFeature, 'name'),
81
+ featureSegments: hoveredField(hovered.hoverFeature, 'segments'),
82
+ viewId: typeof hovered.viewId === 'string' ? hovered.viewId : undefined,
75
83
  }
76
84
  }
77
85
  }
78
86
  return result
79
87
  }
80
88
 
89
+ // Whether a hover may reach a graph paired with `paired`: one naming another
90
+ // view does not, while the paired view is still open. A hover naming no view,
91
+ // from an older host, and a graph whose pair has closed take any.
92
+ export function hoverFromPair(
93
+ hover: LgvHover,
94
+ paired: string | undefined,
95
+ liveViewIds: ReadonlySet<string>,
96
+ ) {
97
+ return (
98
+ hover.viewId === undefined ||
99
+ paired === undefined ||
100
+ !liveViewIds.has(paired) ||
101
+ hover.viewId === paired
102
+ )
103
+ }
104
+
105
+ // The feature a click in a linear view selected (`session.selection`, which
106
+ // core's feature widget sets), read as a hover at its start
107
+ export function readSelectedFeature(selection: unknown): LgvHover | undefined {
108
+ if (!isFeatureLike(selection)) {
109
+ return undefined
110
+ }
111
+ const refName = selection.get('refName')
112
+ const start = selection.get('start')
113
+ return typeof refName === 'string' && typeof start === 'number'
114
+ ? {
115
+ refName,
116
+ coord: start,
117
+ featureName: hoveredField(selection, 'name'),
118
+ featureSegments: hoveredField(selection, 'segments'),
119
+ }
120
+ : undefined
121
+ }
122
+
81
123
  // Whether a hover is one this graph can answer: the same assembly, the same
82
124
  // stable sequence, and inside the window the cut was made for.
83
125
  //
@@ -130,3 +172,32 @@ export function nodeForLgvHover({
130
172
  // An exact segment match wins over the coordinate it happens to sit at.
131
173
  return byName ?? byCoord ?? null
132
174
  }
175
+
176
+ // A bubble's two end segments, unordered: a derived bubble's key is
177
+ // `source>sink`, and an indexed one lists its segments source first
178
+ function bubbleEnds(b: Pick<MinigraphBubble, 'key' | 'segments'>) {
179
+ const ids = b.key?.split('>') ?? b.segments.split(',').filter(Boolean)
180
+ return ids.length >= 2 ? [ids[0]!, ids.at(-1)!].sort().join('\t') : undefined
181
+ }
182
+
183
+ // The ends a hovered feature names: a bubble feature's segments, or a vg
184
+ // deconstruct record's ID, `>source>sink` (`<sink<source` on the reverse)
185
+ function featureEnds(hover: LgvHover) {
186
+ if (hover.featureSegments) {
187
+ return bubbleEnds({ segments: hover.featureSegments })
188
+ }
189
+ const ids = /^([<>][^<>]+){2}$/.test(hover.featureName ?? '')
190
+ ? hover.featureName!.split(/[<>]/).filter(Boolean)
191
+ : []
192
+ return ids.length === 2 ? ids.sort().join('\t') : undefined
193
+ }
194
+
195
+ // The graph's bubble a linear-view feature names, so a bubble track or a
196
+ // graph-derived VCF lights the whole bubble rather than the backbone node at
197
+ // the pointer's bp
198
+ export function bubbleForLgvHover(hover: LgvHover, bubbles: MinigraphBubble[]) {
199
+ const ends = featureEnds(hover)
200
+ return ends === undefined
201
+ ? undefined
202
+ : bubbles.find(b => bubbleEnds(b) === ends)
203
+ }
package/src/index.ts CHANGED
@@ -14,6 +14,8 @@ import LaunchGraphGenomeViewF from './LaunchGraphGenomeView'
14
14
  import LinearGraphDisplayF from './LinearGraphDisplay/index'
15
15
  import MinigraphBubbleAdapterF from './MinigraphBubbleAdapter/index'
16
16
  import RgfaTabixAdapterF from './RgfaTabixAdapter/index'
17
+ import WalkFormsMenuF from './WalkFormsAdapter/formsMenu'
18
+ import WalkFormsAdapterF from './WalkFormsAdapter/index'
17
19
  import WalkTabixSyntenyAdapterF from './WalkTabixSyntenyAdapter/index'
18
20
  import GraphTrackDefaultsF from './graphTrackDefaults/index'
19
21
  import GraphHoverSyncF from './hoverSync/index'
@@ -38,6 +40,8 @@ export default class GraphGenomeViewPlugin extends Plugin {
38
40
  MinigraphBubbleAdapterF(pluginManager)
39
41
  GbzBaseSyntenyAdapterF(pluginManager)
40
42
  WalkTabixSyntenyAdapterF(pluginManager)
43
+ WalkFormsAdapterF(pluginManager)
44
+ WalkFormsMenuF(pluginManager)
41
45
  GraphAddTrackWorkflowF(pluginManager)
42
46
  GraphTrackDefaultsF(pluginManager)
43
47
  PanSNAliasesF(pluginManager)
@@ -1,8 +1,10 @@
1
+ import { PathVisits } from '@jbrowse/bandage-core/pathVisits'
1
2
  import { expect, test } from 'vitest'
2
3
 
3
4
  import {
4
5
  contributingAssemblies,
5
6
  locString,
7
+ nodeAssemblySpans,
6
8
  nodeOwnLocation,
7
9
  resolveContributors,
8
10
  resolveLocationAssembly,
@@ -141,6 +143,27 @@ test('a contributor resolves through an assembly alias, under its own name', ()
141
143
  ).toMatchObject({ refName: 'chr17', start: 83899576, end: 84041803 })
142
144
  })
143
145
 
146
+ test('two haplotypes on one contig name do not share a bare-sample assembly', () => {
147
+ const contributors = contributingAssemblies(
148
+ graph([
149
+ node('s1', 'GRCh38#0#chr6', 31000000, 5000, 0),
150
+ node('s2', 'HG002#1#chr6', 31100000, 300, 1),
151
+ node('s3', 'HG002#2#chr6', 31050000, 300, 1),
152
+ ]),
153
+ )
154
+ const bySample = (sample: string) =>
155
+ ({ HG002: 'HG002', 'HG002#2': 'HG002.2', GRCh38: 'hg38' })[sample]
156
+ expect(
157
+ resolveContributors(contributors, bySample).map(c => [
158
+ c.sample,
159
+ c.haplotype,
160
+ ]),
161
+ ).toEqual([
162
+ ['hg38', 'GRCh38#0'],
163
+ ['HG002.2', 'HG002#2'],
164
+ ])
165
+ })
166
+
144
167
  test('a locstring is 1-based inclusive', () => {
145
168
  expect(
146
169
  locString({
@@ -201,3 +224,32 @@ test('a haplotype-named graph contributes per haplotype, resolved at that depth
201
224
  resolveLocationAssembly(bySample, { sample: 'K12', haplotype: undefined }),
202
225
  ).toBeUndefined()
203
226
  })
227
+
228
+ test("a node's spans are where each walk through it passes it, on loaded assemblies", () => {
229
+ const allele = node('s7', 'HG002#1#CM1', 500, 300, 1)
230
+ const g = {
231
+ ...graph([allele]),
232
+ pathVisits: PathVisits.from([
233
+ [
234
+ 's7',
235
+ [
236
+ {
237
+ path: 'GRCh38#0#chr6',
238
+ sample: 'GRCh38',
239
+ start: 31000,
240
+ strand: '+',
241
+ },
242
+ { path: 'HG002#1#CM1', sample: 'HG002', start: 500, strand: '+' },
243
+ { path: 'HG002#2#CM2', sample: 'HG002', start: 9100, strand: '-' },
244
+ { path: 'NA1#1#chr6', sample: 'NA1', start: 40, strand: '+' },
245
+ ],
246
+ ],
247
+ ]),
248
+ }
249
+ const resolve = (sample: string) =>
250
+ ({ GRCh38: 'hg38', 'HG002#1': 'HG002.1', 'HG002#2': 'HG002.2' })[sample]
251
+ expect(nodeAssemblySpans(g, allele, resolve, 'hg38')).toEqual([
252
+ { assemblyName: 'HG002.1', refName: 'CM1', start: 500, end: 800 },
253
+ { assemblyName: 'HG002.2', refName: 'CM2', start: 9100, end: 9400 },
254
+ ])
255
+ })
@@ -44,6 +44,94 @@ function anchoredNodeLocation(node: AnchoredNode): GraphLocation {
44
44
  }
45
45
  }
46
46
 
47
+ export interface AssemblySpan {
48
+ assemblyName: string
49
+ refName: string
50
+ start: number
51
+ end: number
52
+ }
53
+
54
+ // Where a node's sequence sits on each loaded assembly: its own rGFA
55
+ // location, and where every walk through it passes it on that walk's contig.
56
+ // `except` is the assembly the reference band is already drawn on.
57
+ export function nodeAssemblySpans(
58
+ graph: Graph,
59
+ node: GraphNode,
60
+ resolve: (sample: string) => string | undefined,
61
+ except?: string,
62
+ ) {
63
+ const spans = new Map<string, AssemblySpan>()
64
+ const add = (loc: GraphLocation) => {
65
+ const assemblyName = resolveLocationAssembly(resolve, loc)
66
+ const key = `${assemblyName}\t${loc.refName}\t${loc.start}`
67
+ if (assemblyName !== undefined && assemblyName !== except) {
68
+ spans.set(key, {
69
+ assemblyName,
70
+ refName: loc.refName,
71
+ start: loc.start,
72
+ end: loc.end,
73
+ })
74
+ }
75
+ }
76
+ const own = nodeOwnLocation(node)
77
+ if (own) {
78
+ add(own)
79
+ }
80
+ for (const visit of graph.pathVisits?.get(node.name) ?? []) {
81
+ add({
82
+ sample: panSNSample(visit.path),
83
+ haplotype: panSNHaplotype(visit.path),
84
+ refName: panSNContig(visit.path),
85
+ start: visit.start,
86
+ end: visit.start + node.length,
87
+ })
88
+ }
89
+ return [...spans.values()]
90
+ }
91
+
92
+ // Each stable sequence off the reference that the cut's nodes lie on, with
93
+ // the loaded assembly holding it and the span its nodes cover there. A gene
94
+ // read over that span, renamed to `stableRefName`, lands on those nodes the
95
+ // way the reference's genes land on the backbone.
96
+ export function offReferenceContigs(
97
+ graph: Graph,
98
+ resolve: (sample: string) => string | undefined,
99
+ except?: string,
100
+ ) {
101
+ const contigs = new Map<string, AssemblySpan & { stableRefName: string }>()
102
+ // an HPRC cut names hundreds of haplotypes no session loads
103
+ const unloaded = new Set<string>()
104
+ for (const node of graph.nodes) {
105
+ if (!isAnchored(node) || node.stable.rank === 0) {
106
+ continue
107
+ }
108
+ const stableRefName = node.stable.refName
109
+ if (unloaded.has(stableRefName)) {
110
+ continue
111
+ }
112
+ const loc = anchoredNodeLocation(node)
113
+ const seen = contigs.get(stableRefName)
114
+ if (seen) {
115
+ seen.start = Math.min(seen.start, loc.start)
116
+ seen.end = Math.max(seen.end, loc.end)
117
+ continue
118
+ }
119
+ const assemblyName = resolveLocationAssembly(resolve, loc)
120
+ if (assemblyName === undefined || assemblyName === except) {
121
+ unloaded.add(stableRefName)
122
+ } else {
123
+ contigs.set(stableRefName, {
124
+ stableRefName,
125
+ assemblyName,
126
+ refName: loc.refName,
127
+ start: loc.start,
128
+ end: loc.end,
129
+ })
130
+ }
131
+ }
132
+ return [...contigs.values()]
133
+ }
134
+
47
135
  export interface Contributor extends GraphLocation {
48
136
  // lowest rank this assembly holds here: 0 means it is the reference backbone
49
137
  rank: number
@@ -188,12 +276,28 @@ export function resolveLocationAssembly(
188
276
  // among its aliases; matching on names alone leaves that donor unopenable unless
189
277
  // the reader renames their assembly after the graph. The resolved (canonical)
190
278
  // name replaces the sample, so a launch opens the assembly the session knows.
279
+ //
280
+ // A bare sample stands in for a haplotype unless two haplotypes of it share a
281
+ // contig name. HPRC's GenBank contigs differ per haplotype, so an `NA20809`
282
+ // assembly can hold both; two haplotypes each on `chr6` cannot both be it, and
283
+ // opening hap 2's coordinates on hap 1's sequence lands somewhere plausible
284
+ // and wrong.
191
285
  export function resolveContributors(
192
286
  contributors: Contributor[],
193
287
  resolve: (sample: string) => string | undefined,
194
288
  ) {
289
+ const haplotypesOn = new Map<string, number>()
290
+ const contig = (c: Contributor) => `${c.sample}\t${c.refName}`
291
+ for (const c of contributors) {
292
+ if (c.haplotype !== undefined) {
293
+ haplotypesOn.set(contig(c), (haplotypesOn.get(contig(c)) ?? 0) + 1)
294
+ }
295
+ }
195
296
  return contributors.flatMap(c => {
196
- const sample = resolveLocationAssembly(resolve, c)
297
+ const sample =
298
+ (haplotypesOn.get(contig(c)) ?? 0) > 1
299
+ ? resolve(c.haplotype!)
300
+ : resolveLocationAssembly(resolve, c)
197
301
  return sample === undefined ? [] : [{ ...c, sample }]
198
302
  })
199
303
  }
@@ -253,8 +253,8 @@ function assemblyNamesOfTrack(
253
253
  // point of launching from the graph instead of from a linear view.
254
254
  //
255
255
  // Panels carry THE GRAPH'S OWN TRACK and nothing else, which is a narrower rule
256
- // than the single-view launch's (see launchTracks, which scans the session for
257
- // the assembly's annotation). Tried that here: a gene track per panel takes
256
+ // than the single-view launch's (see showInLinearView, which adds the
257
+ // assembly's gene track). Tried that here: a gene track per panel takes
258
258
  // about 160px of a row that is otherwise a ruler, so on five strains the
259
259
  // annotation is most of the viewport and the ribbons — the thing the launch
260
260
  // exists to draw — are squeezed into the gaps, and `collapseEmptyRows` is here
@@ -123,11 +123,11 @@ describe("a lanes track anchored on an alias of the window's assembly", () => {
123
123
  {
124
124
  type: 'WalkTabixSyntenyAdapter',
125
125
  walksLocation: local(
126
- '../RgfaTabixAdapter/test_data/walks4_header.GRCh38.walks.bed.gz',
126
+ '../RgfaTabixAdapter/test_data/walks5_header.GRCh38.walks.bed.gz',
127
127
  ),
128
128
  walksIndex: {
129
129
  location: local(
130
- '../RgfaTabixAdapter/test_data/walks4_header.GRCh38.walks.bed.gz.tbi',
130
+ '../RgfaTabixAdapter/test_data/walks5_header.GRCh38.walks.bed.gz.tbi',
131
131
  ),
132
132
  },
133
133
  assemblyNames: ['GRCh38'],