jbrowse-plugin-graphgenomeviewer 9.0.0 → 9.1.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 (231) hide show
  1. package/dist/chunks/AddTrackWorkflow-NKX57TBD.js +2 -0
  2. package/dist/chunks/AddTrackWorkflow-NKX57TBD.js.map +7 -0
  3. package/dist/chunks/GbzBaseSyntenyAdapter-V5WC3WDU.js +9 -0
  4. package/dist/chunks/GbzBaseSyntenyAdapter-V5WC3WDU.js.map +7 -0
  5. package/dist/chunks/GraphGenomeView-XPSOKJYF.js +10 -0
  6. package/dist/chunks/GraphGenomeView-XPSOKJYF.js.map +7 -0
  7. package/dist/chunks/GraphSettingsDialog-GXZGESAF.js +2 -0
  8. package/dist/chunks/GraphSettingsDialog-GXZGESAF.js.map +7 -0
  9. package/dist/chunks/HighlightColorDialog-4IZ7TVKH.js +2 -0
  10. package/dist/chunks/{HighlightColorDialog-F4IARMEO.js.map → HighlightColorDialog-4IZ7TVKH.js.map} +3 -3
  11. package/dist/chunks/LinearGraphDisplay-KTRPJ7TC.js +2 -0
  12. package/dist/chunks/MinigraphBubbleAdapter-AQQKKQB7.js +2 -0
  13. package/dist/chunks/MinigraphBubbleAdapter-AQQKKQB7.js.map +7 -0
  14. package/dist/chunks/RgfaTabixAdapter-6KXWQZIB.js +2 -0
  15. package/dist/chunks/{RgfaTabixAdapter-7QKNUHKX.js.map → RgfaTabixAdapter-6KXWQZIB.js.map} +1 -1
  16. package/dist/chunks/WalkFormsAdapter-XUL6CPR2.js +2 -0
  17. package/dist/chunks/WalkFormsAdapter-XUL6CPR2.js.map +7 -0
  18. package/dist/chunks/WalkTabixSyntenyAdapter-V5TDUHFA.js +2 -0
  19. package/dist/chunks/{WalkTabixSyntenyAdapter-KI7ESKKP.js.map → WalkTabixSyntenyAdapter-V5TDUHFA.js.map} +3 -3
  20. package/dist/chunks/chunk-2JCLWDPA.js +2 -0
  21. package/dist/chunks/chunk-2JCLWDPA.js.map +7 -0
  22. package/dist/chunks/chunk-2TMRTF2T.js +4 -0
  23. package/dist/chunks/chunk-2TMRTF2T.js.map +7 -0
  24. package/dist/chunks/chunk-3CTVGI6C.js +2 -0
  25. package/dist/chunks/chunk-3CTVGI6C.js.map +7 -0
  26. package/dist/chunks/chunk-4QUWP4KD.js +2 -0
  27. package/dist/chunks/chunk-4QUWP4KD.js.map +7 -0
  28. package/dist/chunks/chunk-4YSZIJBZ.js +4 -0
  29. package/dist/chunks/{chunk-47UWMS4O.js.map → chunk-4YSZIJBZ.js.map} +4 -4
  30. package/dist/chunks/chunk-54ZVDV3O.js +2 -0
  31. package/dist/chunks/chunk-54ZVDV3O.js.map +7 -0
  32. package/dist/chunks/chunk-5DK3PP4N.js +2 -0
  33. package/dist/chunks/chunk-5DK3PP4N.js.map +7 -0
  34. package/dist/chunks/chunk-EGZZ3ADM.js +2 -0
  35. package/dist/chunks/chunk-EGZZ3ADM.js.map +7 -0
  36. package/dist/chunks/{chunk-OSEQDKL3.js → chunk-GH6WRWYC.js} +1 -1
  37. package/dist/chunks/{chunk-OSEQDKL3.js.map → chunk-GH6WRWYC.js.map} +1 -1
  38. package/dist/chunks/chunk-I2GHOE2S.js +4 -0
  39. package/dist/chunks/chunk-I2GHOE2S.js.map +7 -0
  40. package/dist/chunks/chunk-IAB4ZGCR.js +3 -0
  41. package/dist/chunks/chunk-IAB4ZGCR.js.map +7 -0
  42. package/dist/chunks/{chunk-HFBUC6GF.js → chunk-JH7I3SYQ.js} +2 -2
  43. package/dist/chunks/{chunk-HFBUC6GF.js.map → chunk-JH7I3SYQ.js.map} +2 -2
  44. package/dist/chunks/{chunk-VAWAASUT.js → chunk-MSAVT4CG.js} +1 -1
  45. package/dist/chunks/{chunk-VAWAASUT.js.map → chunk-MSAVT4CG.js.map} +1 -1
  46. package/dist/chunks/chunk-N4H4SII4.js +2 -0
  47. package/dist/chunks/chunk-N4H4SII4.js.map +7 -0
  48. package/dist/chunks/{chunk-MPUAUZSJ.js → chunk-P5SI66S3.js} +1 -1
  49. package/dist/chunks/{chunk-MPUAUZSJ.js.map → chunk-P5SI66S3.js.map} +1 -1
  50. package/dist/chunks/chunk-RSNSHOEE.js +3 -0
  51. package/dist/chunks/chunk-RSNSHOEE.js.map +7 -0
  52. package/dist/chunks/chunk-TBC7SPZD.js +6 -0
  53. package/dist/chunks/chunk-TBC7SPZD.js.map +7 -0
  54. package/dist/chunks/chunk-VPKTQAAQ.js +3 -0
  55. package/dist/chunks/chunk-VPKTQAAQ.js.map +7 -0
  56. package/dist/chunks/chunk-WCFLR4AJ.js +2 -0
  57. package/dist/chunks/{chunk-TLUGH4VW.js.map → chunk-WCFLR4AJ.js.map} +1 -1
  58. package/dist/chunks/{chunk-FLKXKTS2.js → chunk-WKD7ALOU.js} +2 -2
  59. package/dist/chunks/{chunk-FLKXKTS2.js.map → chunk-WKD7ALOU.js.map} +2 -2
  60. package/dist/chunks/chunk-X67CQRA4.js +2 -0
  61. package/dist/chunks/chunk-X67CQRA4.js.map +7 -0
  62. package/dist/chunks/{chunk-AQSLN3RH.js → chunk-XZU7RJUH.js} +2 -2
  63. package/dist/chunks/{chunk-AQSLN3RH.js.map → chunk-XZU7RJUH.js.map} +1 -1
  64. package/dist/chunks/chunk-YROUE32O.js +2 -0
  65. package/dist/chunks/chunk-YROUE32O.js.map +7 -0
  66. package/dist/chunks/chunk-ZV6BRYEP.js +4 -0
  67. package/dist/chunks/chunk-ZV6BRYEP.js.map +7 -0
  68. package/dist/chunks/chunk-ZVMXECJA.js +2 -0
  69. package/dist/chunks/chunk-ZVMXECJA.js.map +7 -0
  70. package/dist/chunks/{renderSvg-DLJTA2B3.js → renderSvg-7DAEH3FR.js} +2 -2
  71. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +5 -5
  72. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +4 -4
  73. package/package.json +3 -3
  74. package/src/GbzBaseSyntenyAdapter/configSchema.ts +2 -2
  75. package/src/GetSubgraph.ts +6 -0
  76. package/src/GraphAddTrackWorkflow/AddTrackWorkflow.test.tsx +36 -1
  77. package/src/GraphAddTrackWorkflow/AddTrackWorkflow.tsx +12 -5
  78. package/src/GraphAddTrackWorkflow/buildTrackConfig.test.ts +40 -0
  79. package/src/GraphAddTrackWorkflow/buildTrackConfig.ts +10 -7
  80. package/src/GraphAddTrackWorkflow/graphManifest.ts +1 -1
  81. package/src/GraphAddTrackWorkflow/index.ts +4 -0
  82. package/src/GraphAddTrackWorkflow/walkReference.test.ts +22 -0
  83. package/src/GraphAddTrackWorkflow/walkReference.ts +25 -0
  84. package/src/GraphComputeLayout.test.ts +16 -0
  85. package/src/GraphComputeLayout.ts +3 -1
  86. package/src/GraphGenomeView/components/ElTree.tsx +37 -7
  87. package/src/GraphGenomeView/components/GenePins.tsx +6 -8
  88. package/src/GraphGenomeView/components/GraphCanvas.tsx +10 -7
  89. package/src/GraphGenomeView/components/GraphLoadStatus.test.tsx +40 -0
  90. package/src/GraphGenomeView/components/GraphLoadStatus.tsx +41 -12
  91. package/src/GraphGenomeView/components/GraphSettingsDialog.tsx +5 -4
  92. package/src/GraphGenomeView/components/GraphStats.tsx +3 -3
  93. package/src/GraphGenomeView/components/GraphToolbar.tsx +3 -3
  94. package/src/GraphGenomeView/components/HighlightColorDialog.tsx +8 -2
  95. package/src/GraphGenomeView/components/HoverTooltip.test.tsx +45 -0
  96. package/src/GraphGenomeView/components/HoverTooltip.tsx +13 -0
  97. package/src/GraphGenomeView/components/ImportForm.test.tsx +38 -0
  98. package/src/GraphGenomeView/components/ImportForm.tsx +37 -5
  99. package/src/GraphGenomeView/components/LabelLayer.tsx +5 -2
  100. package/src/GraphGenomeView/components/PaneLayer.tsx +15 -0
  101. package/src/{LinearGraphDisplay → GraphGenomeView}/components/SubgraphContextSelect.test.tsx +5 -8
  102. package/src/{LinearGraphDisplay → GraphGenomeView}/components/SubgraphContextSelect.tsx +6 -4
  103. package/src/{LinearGraphDisplay → GraphGenomeView}/components/SubgraphHaplotypesField.test.tsx +4 -9
  104. package/src/{LinearGraphDisplay → GraphGenomeView}/components/SubgraphHaplotypesField.tsx +12 -12
  105. package/src/GraphGenomeView/components/WalkRowsOverlay.test.tsx +73 -0
  106. package/src/GraphGenomeView/components/WalkRowsOverlay.tsx +119 -49
  107. package/src/GraphGenomeView/components/WalkStrip.tsx +5 -0
  108. package/src/GraphGenomeView/components/usePaneGestures.test.tsx +16 -0
  109. package/src/GraphGenomeView/components/usePaneGestures.ts +48 -40
  110. package/src/GraphGenomeView/model.color.test.ts +467 -0
  111. package/src/GraphGenomeView/model.fit.test.ts +1034 -0
  112. package/src/GraphGenomeView/model.launch.test.ts +799 -0
  113. package/src/GraphGenomeView/model.layout.test.ts +1149 -0
  114. package/src/GraphGenomeView/model.load.test.ts +907 -0
  115. package/src/GraphGenomeView/model.ts +110 -10
  116. package/src/GraphGenomeView/model.walkRows.test.ts +1152 -0
  117. package/src/GraphGenomeView/modelTestMocks.ts +109 -0
  118. package/src/GraphGenomeView/modelTestSupport.ts +137 -0
  119. package/src/GraphGenomeView/pane/fitViews.ts +3 -1
  120. package/src/GraphGenomeView/pane/graphViews.ts +9 -7
  121. package/src/GraphGenomeView/pane/launchActions.ts +2 -4
  122. package/src/GraphGenomeView/pane/loadActions.ts +125 -39
  123. package/src/GraphGenomeView/pane/paneBase.test.ts +23 -0
  124. package/src/GraphGenomeView/pane/paneBase.ts +12 -14
  125. package/src/GraphGenomeView/pane/renderingActions.ts +29 -20
  126. package/src/GraphGenomeView/pane/settingActions.ts +9 -8
  127. package/src/GraphGenomeView/pane/walkRowViews.ts +9 -13
  128. package/src/GraphGenomeView/repeats/walkCalls.ts +3 -1
  129. package/src/GraphGenomeView/subgraphLoad.test.ts +117 -9
  130. package/src/GraphGenomeView/viewModel.ts +5 -27
  131. package/src/GraphGenomeView/walkRowGroups.test.ts +103 -0
  132. package/src/GraphGenomeView/walkRowGroups.ts +37 -1
  133. package/src/LinearGraphDisplay/LinearGraphDisplay.test.ts +94 -80
  134. package/src/LinearGraphDisplay/configSchema.ts +0 -2
  135. package/src/LinearGraphDisplay/graphFacetConfigSchema.ts +0 -4
  136. package/src/LinearGraphDisplay/index.ts +1 -3
  137. package/src/LinearGraphDisplay/model.ts +136 -161
  138. package/src/MinigraphBubbleAdapter/MinigraphBubbleAdapter.ts +1 -1
  139. package/src/MinigraphBubbleAdapter/configSchema.ts +1 -1
  140. package/src/RgfaTabixAdapter/configSchema.ts +2 -2
  141. package/src/RgfaTabixAdapter/walkFiles.test.ts +15 -1
  142. package/src/RgfaTabixAdapter/walkReader.ts +3 -5
  143. package/src/WalkFormsAdapter/WalkFormsAdapter.test.ts +40 -1
  144. package/src/WalkFormsAdapter/WalkFormsAdapter.ts +74 -44
  145. package/src/WalkFormsAdapter/configSchema.ts +13 -2
  146. package/src/WalkFormsAdapter/formRows.ts +2 -2
  147. package/src/WalkFormsAdapter/formsMenu.test.ts +54 -7
  148. package/src/WalkFormsAdapter/formsMenu.ts +40 -16
  149. package/src/WalkFormsAdapter/formsMenuHost.test.ts +11 -6
  150. package/src/WalkTabixSyntenyAdapter/WalkTabixSyntenyAdapter.test.ts +6 -0
  151. package/src/WalkTabixSyntenyAdapter/WalkTabixSyntenyAdapter.ts +1 -1
  152. package/src/WalkTabixSyntenyAdapter/configSchema.ts +2 -2
  153. package/src/adapterImplementing.ts +11 -6
  154. package/src/graphTrackConfig.ts +5 -0
  155. package/src/graphTrackDefaults/graphTrackDefaults.test.ts +31 -0
  156. package/src/graphTrackDefaults/index.ts +24 -18
  157. package/src/hoverSync/graphViewHighlights.ts +2 -2
  158. package/src/hoverSync/lgvHover.test.ts +1 -1
  159. package/src/hoverSync/lgvHover.ts +7 -3
  160. package/src/isRecord.ts +4 -0
  161. package/src/launchFromGraph/linearViewTarget.ts +10 -4
  162. package/src/launchFromGraph/syntenyTracks.ts +5 -2
  163. package/src/locationName.test.ts +20 -0
  164. package/src/locationName.ts +10 -8
  165. package/src/nodeLimitError.ts +13 -0
  166. package/src/panSNAliases/index.ts +4 -3
  167. package/src/panSNTabix.test.ts +4 -0
  168. package/src/panSNTabix.ts +26 -57
  169. package/src/slotDefaults.test.ts +12 -0
  170. package/src/slotDefaults.ts +12 -0
  171. package/src/tabixSlots.ts +51 -0
  172. package/src/version.ts +1 -1
  173. package/dist/chunks/AddTrackWorkflow-3PX4I4DX.js +0 -2
  174. package/dist/chunks/AddTrackWorkflow-3PX4I4DX.js.map +0 -7
  175. package/dist/chunks/GbzBaseSyntenyAdapter-YUT5RT7G.js +0 -2
  176. package/dist/chunks/GbzBaseSyntenyAdapter-YUT5RT7G.js.map +0 -7
  177. package/dist/chunks/GraphGenomeView-XFKLX3VQ.js +0 -10
  178. package/dist/chunks/GraphGenomeView-XFKLX3VQ.js.map +0 -7
  179. package/dist/chunks/GraphTrackSettingsDialog-KOYYI2XH.js +0 -4
  180. package/dist/chunks/GraphTrackSettingsDialog-KOYYI2XH.js.map +0 -7
  181. package/dist/chunks/HighlightColorDialog-F4IARMEO.js +0 -2
  182. package/dist/chunks/LinearGraphDisplay-BZ44C6S3.js +0 -2
  183. package/dist/chunks/MinigraphBubbleAdapter-2KIWDIY7.js +0 -2
  184. package/dist/chunks/MinigraphBubbleAdapter-2KIWDIY7.js.map +0 -7
  185. package/dist/chunks/RgfaTabixAdapter-7QKNUHKX.js +0 -2
  186. package/dist/chunks/WalkFormsAdapter-5NDOULY6.js +0 -2
  187. package/dist/chunks/WalkFormsAdapter-5NDOULY6.js.map +0 -7
  188. package/dist/chunks/WalkTabixSyntenyAdapter-KI7ESKKP.js +0 -2
  189. package/dist/chunks/chunk-3HSJ7SAT.js +0 -2
  190. package/dist/chunks/chunk-3HSJ7SAT.js.map +0 -7
  191. package/dist/chunks/chunk-42VF2CSA.js +0 -4
  192. package/dist/chunks/chunk-42VF2CSA.js.map +0 -7
  193. package/dist/chunks/chunk-47UWMS4O.js +0 -4
  194. package/dist/chunks/chunk-7PVPO366.js +0 -2
  195. package/dist/chunks/chunk-7PVPO366.js.map +0 -7
  196. package/dist/chunks/chunk-AXUXLPO3.js +0 -6
  197. package/dist/chunks/chunk-AXUXLPO3.js.map +0 -7
  198. package/dist/chunks/chunk-CJ4VON23.js +0 -2
  199. package/dist/chunks/chunk-CJ4VON23.js.map +0 -7
  200. package/dist/chunks/chunk-I2XBA4H7.js +0 -9
  201. package/dist/chunks/chunk-I2XBA4H7.js.map +0 -7
  202. package/dist/chunks/chunk-KIURR66K.js +0 -3
  203. package/dist/chunks/chunk-KIURR66K.js.map +0 -7
  204. package/dist/chunks/chunk-LQSOJR7D.js +0 -2
  205. package/dist/chunks/chunk-LQSOJR7D.js.map +0 -7
  206. package/dist/chunks/chunk-M2D7NUOY.js +0 -2
  207. package/dist/chunks/chunk-M2D7NUOY.js.map +0 -7
  208. package/dist/chunks/chunk-M6YSANSW.js +0 -2
  209. package/dist/chunks/chunk-M6YSANSW.js.map +0 -7
  210. package/dist/chunks/chunk-N4ZFGZDN.js +0 -2
  211. package/dist/chunks/chunk-N4ZFGZDN.js.map +0 -7
  212. package/dist/chunks/chunk-P76SUZFP.js +0 -4
  213. package/dist/chunks/chunk-P76SUZFP.js.map +0 -7
  214. package/dist/chunks/chunk-R34FRICP.js +0 -4
  215. package/dist/chunks/chunk-R34FRICP.js.map +0 -7
  216. package/dist/chunks/chunk-SXMUGZXP.js +0 -2
  217. package/dist/chunks/chunk-SXMUGZXP.js.map +0 -7
  218. package/dist/chunks/chunk-T7NMFIRW.js +0 -2
  219. package/dist/chunks/chunk-T7NMFIRW.js.map +0 -7
  220. package/dist/chunks/chunk-TLUGH4VW.js +0 -2
  221. package/dist/chunks/chunk-Y4TLRGAC.js +0 -2
  222. package/dist/chunks/chunk-Y4TLRGAC.js.map +0 -7
  223. package/dist/chunks/chunk-ZXJRZKWF.js +0 -2
  224. package/dist/chunks/chunk-ZXJRZKWF.js.map +0 -7
  225. package/src/GraphGenomeView/model.test.ts +0 -5416
  226. package/src/GraphGenomeView/retiredNodeColor.test.ts +0 -46
  227. package/src/GraphGenomeView/retiredNodeColor.ts +0 -76
  228. package/src/LinearGraphDisplay/components/GraphTrackSettingsDialog.tsx +0 -22
  229. package/src/LinearGraphDisplay/graphFacetConfigSchema.test.ts +0 -13
  230. /package/dist/chunks/{LinearGraphDisplay-BZ44C6S3.js.map → LinearGraphDisplay-KTRPJ7TC.js.map} +0 -0
  231. /package/dist/chunks/{renderSvg-DLJTA2B3.js.map → renderSvg-7DAEH3FR.js.map} +0 -0
@@ -17,7 +17,6 @@ import { WALK_GENE_ROWS } from './paneBase'
17
17
  import { resolveLocationAssembly } from '../../launchFromGraph/contributors'
18
18
 
19
19
  import type { WalkAxis, WalkRow } from '@jbrowse/bandage-core/layout/walkRows'
20
- import type { LayoutModeValue } from '@jbrowse/bandage-core/layoutModes'
21
20
 
22
21
  export const withWalkRowViews = withLaunchViews
23
22
  .views(self => ({
@@ -47,24 +46,21 @@ export const withWalkRowViews = withLaunchViews
47
46
  }
48
47
  return walkStripFrame(bars, { width: self.paneWidth })
49
48
  },
50
- // Whether a cut under `mode` must follow every snarl a walk leaves the
51
- // window by, so walks come back whole: walk rows measure them, and so does
52
- // the strip under a layout that draws nodes. Only a GBZ cut follows
53
- // snarls; a walk file cuts the same either way, so asking would re-fetch
54
- // an identical graph.
55
- cutsWholeWalksIn(mode: LayoutModeValue, walkStrip = self.walkStrip) {
56
- const m = layoutModeByValue(mode)
49
+ // Whether a cut must follow every snarl a walk leaves the window by, so
50
+ // walks come back whole: walk rows measure them, and so does the strip
51
+ // under a layout that draws nodes. Only a GBZ cut follows snarls; a walk
52
+ // file cuts the same either way, so asking would re-fetch an identical
53
+ // graph.
54
+ get cutsWholeWalks() {
55
+ const mode = layoutModeByValue(self.chosenLayoutMode)
57
56
  return (
58
57
  self.sourceAdapter?.type === 'GbzBaseSyntenyAdapter' &&
59
- wholeWalksRule(m, {
60
- walkStrip: walkStrip && m.drawsNodes,
58
+ wholeWalksRule(mode, {
59
+ walkStrip: self.walkStrip && mode.drawsNodes,
61
60
  host: !!self.host,
62
61
  })
63
62
  )
64
63
  },
65
- get cutsWholeWalks() {
66
- return this.cutsWholeWalksIn(self.chosenLayoutMode)
67
- },
68
64
  // Where each walk passes the hovered node, or the selected one
69
65
  get walkStripMarks() {
70
66
  const bars = this.walkStripRows
@@ -33,7 +33,9 @@ function agrees(walkBp: number, callBp: number) {
33
33
  function nearest(walks: number[], calls: number[]) {
34
34
  const W = walks.length
35
35
  const C = calls.length
36
- const cost = Array.from({ length: W + 1 }, () => new Array(C + 1).fill(0))
36
+ const cost = Array.from({ length: W + 1 }, () =>
37
+ new Array<number>(C + 1).fill(0),
38
+ )
37
39
  const paired = Array.from({ length: W + 1 }, () =>
38
40
  new Array<boolean>(C + 1).fill(false),
39
41
  )
@@ -114,6 +114,27 @@ async function cut(region: typeof ON_HG38, gfa = GFA) {
114
114
  return model
115
115
  }
116
116
 
117
+ // in a tree, as a session holds a view, so its reactions run
118
+ function attachedView(snapshot: Record<string, unknown> = {}) {
119
+ return types.model({ view: stateModelFactory() }).create({
120
+ view: {
121
+ type: 'GraphGenomeView',
122
+ layoutMode: 'auto',
123
+ loadedTrackId: TRACK.trackId,
124
+ loadedRegion: ON_HG38,
125
+ ...snapshot,
126
+ } as never,
127
+ }).view
128
+ }
129
+
130
+ function answerCutsWith(cut: unknown) {
131
+ mockRpcCall.mockImplementation((_sid: unknown, method: string) =>
132
+ method === 'GetSubgraph'
133
+ ? Promise.resolve(cut)
134
+ : Promise.reject(new Error(`Unexpected RPC: ${method}`)),
135
+ )
136
+ }
137
+
117
138
  beforeEach(() => {
118
139
  mockRpcCall.mockReset()
119
140
  mockSession.tracks = [TRACK]
@@ -309,7 +330,11 @@ describe('canceling and retrying', () => {
309
330
  })
310
331
 
311
332
  test('expanding a walk cuts again with its name', async () => {
312
- const model = await cut(ON_HG38)
333
+ answerCutsWith(GFA)
334
+ const model = attachedView()
335
+ await vi.waitFor(() => {
336
+ expect(model.hasGraph).toBe(true)
337
+ })
313
338
  mockRpcCall.mockClear()
314
339
  model.expandWalk('HG002#1#chr1')
315
340
  model.expandWalk('HG002#1#chr1')
@@ -337,14 +362,7 @@ describe('canceling and retrying', () => {
337
362
  ? Promise.resolve(tables)
338
363
  : Promise.reject(new Error(`Unexpected RPC: ${method}`)),
339
364
  )
340
- const { view: model } = types.model({ view: stateModelFactory() }).create({
341
- view: {
342
- type: 'GraphGenomeView',
343
- layoutMode: 'auto',
344
- loadedTrackId: TRACK.trackId,
345
- loadedRegion: ON_HG38,
346
- } as never,
347
- })
365
+ const model = attachedView()
348
366
  await vi.waitFor(() => {
349
367
  expect(model.hasGraph).toBe(true)
350
368
  })
@@ -361,6 +379,96 @@ describe('canceling and retrying', () => {
361
379
  })
362
380
  })
363
381
 
382
+ test("picking a sample in walk rows cuts again with its abridged walk's name", async () => {
383
+ const tables = gfaTables(
384
+ [
385
+ GFA,
386
+ 'W\tGRCh38\t0\tchr6\t32000000\t32001900\t>s1>s3',
387
+ 'W\tNA20809\t2\tCM094351.1\t31900800\t31903000\t>s1>h1>s3',
388
+ ].join('\n'),
389
+ )!
390
+ tables.walks.abridgedSteps = Float64Array.from([Number.NaN, 40])
391
+ tables.walks.abridgedBp = Float64Array.from([Number.NaN, 9000])
392
+ mockRpcCall.mockImplementation((_sid: unknown, method: string) =>
393
+ method === 'GetSubgraph'
394
+ ? Promise.resolve(tables)
395
+ : Promise.reject(new Error(`Unexpected RPC: ${method}`)),
396
+ )
397
+ const model = attachedView({ layoutMode: 'walkrows' })
398
+ await vi.waitFor(() => {
399
+ expect(model.hasGraph).toBe(true)
400
+ })
401
+ mockRpcCall.mockClear()
402
+ model.setWalkRowSamples(['NA20809'])
403
+ expect(model.expandedWalks).toEqual(['NA20809#2#CM094351.1'])
404
+ await vi.waitFor(() => {
405
+ expect(mockRpcCall).toHaveBeenCalledTimes(1)
406
+ })
407
+ expect(mockRpcCall.mock.calls[0]?.[2]).toMatchObject({
408
+ opts: { expand: ['NA20809#2#CM094351.1'] },
409
+ })
410
+ })
411
+
412
+ test('a cut option changed on a drawn view cuts again with it', async () => {
413
+ answerCutsWith(GFA)
414
+ const model = attachedView()
415
+ await vi.waitFor(() => {
416
+ expect(model.hasGraph).toBe(true)
417
+ })
418
+ mockRpcCall.mockClear()
419
+ model.setSubgraphHaplotypes(['NA20809'])
420
+ model.setSubgraphHaplotypes(['NA20809'])
421
+ expect(mockRpcCall).toHaveBeenCalledTimes(1)
422
+ expect(mockRpcCall.mock.calls[0]?.[2]).toMatchObject({
423
+ opts: { haplotypes: ['NA20809'] },
424
+ })
425
+ })
426
+
427
+ test('a sample filter over whole walks fetches nothing', async () => {
428
+ answerCutsWith(
429
+ gfaTables(
430
+ [
431
+ GFA,
432
+ 'W\tGRCh38\t0\tchr6\t32000000\t32001900\t>s1>s3',
433
+ 'W\tNA20809\t2\tCM094351.1\t31900800\t31903000\t>s1>h1>s3',
434
+ ].join('\n'),
435
+ ),
436
+ )
437
+ const model = attachedView({ layoutMode: 'walkrows' })
438
+ await vi.waitFor(() => {
439
+ expect(model.hasGraph).toBe(true)
440
+ })
441
+ mockRpcCall.mockClear()
442
+ model.setWalkRowSamples(['NA20809'])
443
+ expect(model.cutOptions.expandSamples).toEqual(['NA20809'])
444
+ expect(mockRpcCall).not.toHaveBeenCalled()
445
+ })
446
+
447
+ test('a layout change that changes the cut cuts once', async () => {
448
+ answerCutsWith(GFA)
449
+ const model = attachedView()
450
+ await vi.waitFor(() => {
451
+ expect(model.hasGraph).toBe(true)
452
+ })
453
+ mockRpcCall.mockClear()
454
+ void model.switchLayout('walkrows')
455
+ expect(mockRpcCall).toHaveBeenCalledTimes(1)
456
+ expect(mockRpcCall.mock.calls[0]?.[2]).toMatchObject({
457
+ opts: { walkRows: true },
458
+ })
459
+ })
460
+
461
+ test('closing the graph forgets the walks it expanded', async () => {
462
+ answerCutsWith(GFA)
463
+ const model = attachedView()
464
+ await vi.waitFor(() => {
465
+ expect(model.hasGraph).toBe(true)
466
+ })
467
+ model.expandWalk('HG002#1#chr1')
468
+ model.clearGraph()
469
+ expect(model.expandedWalks).toEqual([])
470
+ })
471
+
364
472
  test('a newer cut aborts the one it replaces', () => {
365
473
  pendingCuts()
366
474
  const model = launchedView()
@@ -2,13 +2,11 @@ import { LAYOUT_ENGINE_VALUES } from '@jbrowse/bandage-core/layoutEngines'
2
2
  import { LAYOUT_MODE_VALUES } from '@jbrowse/bandage-core/layoutModes'
3
3
  import { BaseViewModel } from '@jbrowse/core/pluggableElementTypes/models'
4
4
  import { getSession } from '@jbrowse/core/util'
5
- import { addDisposer, isAlive, types } from '@jbrowse/mobx-state-tree'
6
- import { reaction } from 'mobx'
5
+ import { isAlive, types } from '@jbrowse/mobx-state-tree'
7
6
 
8
7
  import { HOVER_HIGHLIGHT_VALUES } from './hoverHighlight'
9
8
  import { lenientMaybeEnum, lenientOptionalEnum } from './lenientEnum'
10
9
  import { GraphPane, fileName, formatSpanBp } from './model'
11
- import { liftFlatNodeColor } from './retiredNodeColor'
12
10
  import { canonicalRegion } from '../launchFromGraph/launchFromGraph'
13
11
 
14
12
  import type { GraphLayers } from './graphLayers'
@@ -53,11 +51,6 @@ export default function stateModelFactory() {
53
51
  hover: lenientMaybeEnum(HOVER_HIGHLIGHT_VALUES),
54
52
  }),
55
53
  )
56
- .preProcessSnapshot(snap =>
57
- snap.color === undefined
58
- ? snap
59
- : { ...snap, color: liftFlatNodeColor(snap.color) as NodeColor },
60
- )
61
54
  .views(self => ({
62
55
  get grammar(): GraphGrammar {
63
56
  return {
@@ -155,6 +148,7 @@ export default function stateModelFactory() {
155
148
  ),
156
149
  )
157
150
  } else {
151
+ self.markCut()
158
152
  return self.cutSubgraph(adapter, region, self.cutOptions)
159
153
  }
160
154
  return undefined
@@ -190,7 +184,7 @@ export default function stateModelFactory() {
190
184
  .waitForAssembly(stated.assemblyName)
191
185
  .catch(() => undefined)
192
186
  .then(() =>
193
- self.loadedRegion === stated
187
+ isAlive(self) && self.loadedRegion === stated
194
188
  ? loadRegion(canonicalRegion(session, stated))
195
189
  : undefined,
196
190
  )
@@ -205,9 +199,8 @@ export default function stateModelFactory() {
205
199
  setGfaLocation(location: FileLocation) {
206
200
  self.gfaLocation = location
207
201
  },
208
- // the strip's toggle cuts the track again too (afterAttach)
209
- relayoutFrom(from: LayoutModeValue) {
210
- return self.loadedTrackId && self.cutChangedFrom(from)
202
+ relayoutFrom(_from: LayoutModeValue) {
203
+ return self.loadedTrackId && self.cutStale
211
204
  ? self.load()
212
205
  : self.recomputeLayout()
213
206
  },
@@ -229,21 +222,6 @@ export default function stateModelFactory() {
229
222
  if (!self.graph) {
230
223
  void self.load()
231
224
  }
232
- addDisposer(
233
- self,
234
- reaction(
235
- () => self.walkStrip,
236
- on => {
237
- if (
238
- self.loadedTrackId &&
239
- self.cutsWholeWalks !==
240
- self.cutsWholeWalksIn(self.chosenLayoutMode, !on)
241
- ) {
242
- void self.load()
243
- }
244
- },
245
- ),
246
- )
247
225
  },
248
226
  }))
249
227
  }
@@ -1,3 +1,4 @@
1
+ import { serializeEl } from '@jbrowse/bandage-core/el'
1
2
  import { parseSamplesTsv } from '@jbrowse/core/util/samplesTsv'
2
3
 
3
4
  import {
@@ -7,8 +8,14 @@ import {
7
8
  metadataColumns,
8
9
  sectionIndexOf,
9
10
  sectionPlacement,
11
+ walkRowTrees,
12
+ walkRowTreesPanKey,
10
13
  } from './walkRowGroups'
11
14
 
15
+ import type { WalkRowSection } from './walkRowGroups'
16
+ import type { El } from '@jbrowse/bandage-core/el'
17
+ import type { WalkRow } from '@jbrowse/bandage-core/layout/walkRows'
18
+
12
19
  const TSV = [
13
20
  'name\tpopulation\tsuperpopulation',
14
21
  'GRCh38\t\t',
@@ -155,3 +162,99 @@ test('a point past either end names the end row, and a tie the upper row', () =>
155
162
  expect(place.rowAt(6, 6)).toBe(1)
156
163
  expect(place.rowAt(0, 0)).toBe(0)
157
164
  })
165
+
166
+ describe('panning the trees', () => {
167
+ function row(name: string, bp: number): WalkRow {
168
+ return {
169
+ name,
170
+ label: name,
171
+ sample: name,
172
+ bp,
173
+ offReferenceBp: 0,
174
+ gapBp: 0,
175
+ complete: true,
176
+ runs: [
177
+ { start: 0, bp: bp / 2, onReference: true, referenceStart: 1000 },
178
+ { start: bp / 2, bp: bp / 2, onReference: false },
179
+ ],
180
+ }
181
+ }
182
+ const bars = {
183
+ origin: 1000,
184
+ unit: 100,
185
+ reference: row('GRCh38', 3000),
186
+ rows: ['A', 'B', 'C', 'D', 'E'].map((name, i) => row(name, 1000 + 400 * i)),
187
+ }
188
+ const sections: WalkRowSection[] = [
189
+ { key: 'AFR', title: 'AFR', first: 1, count: 3 },
190
+ { key: 'EUR', title: 'EUR', first: 4, count: 2 },
191
+ ]
192
+ const pitch = { rowPx: 14, barPx: 8, readouts: true }
193
+
194
+ // each x and y moved back by the pan, to the hundredth of a px
195
+ function unpanned(node: El | string, dx: number, dy: number): El | string {
196
+ const back = (name: string, value: string | number | undefined) =>
197
+ typeof value !== 'number'
198
+ ? value
199
+ : /^x[12]?$/.test(name)
200
+ ? (value - dx).toFixed(2)
201
+ : /^y[12]?$/.test(name)
202
+ ? (value - dy).toFixed(2)
203
+ : value
204
+ return typeof node === 'string'
205
+ ? node
206
+ : {
207
+ ...node,
208
+ attrs: Object.fromEntries(
209
+ Object.entries(node.attrs).map(([name, value]) => [
210
+ name,
211
+ back(name, value),
212
+ ]),
213
+ ),
214
+ children: node.children.map(c => unpanned(c, dx, dy)),
215
+ }
216
+ }
217
+
218
+ // whether each pan kept the key of the last redraw, and whether drawing
219
+ // afresh matched that redraw moved by the pan
220
+ function pansThrough(groups: WalkRowSection[]) {
221
+ const place = sectionPlacement(groups, pitch.rowPx)
222
+ const frameAt = ([translateX, translateY]: [number, number]) => ({
223
+ scaleX: 0.1,
224
+ scaleY: 1,
225
+ translateX,
226
+ translateY,
227
+ width: 400,
228
+ height: 60,
229
+ ...pitch,
230
+ })
231
+ const keyAt = (at: [number, number]) =>
232
+ walkRowTreesPanKey(bars, place.rowY, frameAt(at))
233
+ const drawnAt = (at: [number, number]) =>
234
+ walkRowTrees(bars, groups, place.rowY, frameAt(at), {
235
+ idPrefix: 't',
236
+ }).map(tree => serializeEl(unpanned(tree, at[0], at[1])))
237
+ let redrawnAt: [number, number] = [-40, 30]
238
+ return Array.from({ length: 60 }, (_, k) => {
239
+ const at: [number, number] = [-40 + 9 * k, 30 - 3 * k]
240
+ const kept = keyAt(at) === keyAt(redrawnAt)
241
+ const moved =
242
+ JSON.stringify(drawnAt(at)) === JSON.stringify(drawnAt(redrawnAt))
243
+ redrawnAt = kept ? redrawnAt : at
244
+ return { kept, moved }
245
+ })
246
+ }
247
+
248
+ test.each([
249
+ ['ungrouped', []],
250
+ ['grouped', sections],
251
+ ])(
252
+ '%s, a pan keeps the key exactly when it only moves the trees',
253
+ (_, groups) => {
254
+ const pans = pansThrough(groups)
255
+ expect(pans.filter(p => p.kept !== p.moved)).toEqual([])
256
+ expect(pans.filter(p => !p.kept).length).toBeGreaterThan(3)
257
+ expect(pans.filter(p => p.kept).length).toBeGreaterThan(pans.length / 2)
258
+ },
259
+ )
260
+ })
@@ -1,4 +1,9 @@
1
- import { walkRowsTree } from '@jbrowse/bandage-core/layout/walkRowDraw'
1
+ import {
2
+ barEnd,
3
+ readoutPlacement,
4
+ walkRowReadout,
5
+ walkRowsTree,
6
+ } from '@jbrowse/bandage-core/layout/walkRowDraw'
2
7
  import { groupKeyComparator } from '@jbrowse/core/util/groupKeys'
3
8
 
4
9
  import type { El } from '@jbrowse/bandage-core/el'
@@ -220,3 +225,34 @@ export function walkRowTrees(
220
225
  }),
221
226
  ]
222
227
  }
228
+
229
+ // What walkRowTrees decides from where the frame sits rather than from its
230
+ // scale: which rows it culls past the pane's top and bottom, and which side of
231
+ // its bar's end each readout goes. While this holds, a pan only moves the
232
+ // trees.
233
+ export function walkRowTreesPanKey(
234
+ bars: WalkRowsWithCalls,
235
+ rowY: (i: number) => number,
236
+ frame: WalkRowsFrame & { barPx: number },
237
+ ) {
238
+ const { scaleX, scaleY, translateX, translateY, width, height, barPx } = frame
239
+ return [bars.reference, ...bars.rows]
240
+ .map((row, i) => {
241
+ const y = rowY(i) * scaleY + translateY
242
+ return y < -barPx || y > height + barPx
243
+ ? '-'
244
+ : (frame.readouts ?? true)
245
+ ? readoutPlacement(
246
+ walkRowReadout(
247
+ row,
248
+ i === 0 ? undefined : bars.reference,
249
+ bars.unit,
250
+ row.call,
251
+ ),
252
+ (bars.origin + barEnd(row)) * scaleX + translateX,
253
+ width,
254
+ ).anchor
255
+ : '+'
256
+ })
257
+ .join(' ')
258
+ }