jbrowse-plugin-graphgenomeviewer 7.1.0 → 7.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/README.md +17 -8
  2. package/dist/chunks/AddTrackWorkflow-RPH4ZFSX.js +2 -0
  3. package/dist/chunks/{AddTrackWorkflow-Q6RY23LF.js.map → AddTrackWorkflow-RPH4ZFSX.js.map} +2 -2
  4. package/dist/chunks/{ChooseSamplesDialog-BNVYBGJQ.js → ChooseSamplesDialog-JRN4YLBY.js} +2 -2
  5. package/dist/chunks/{ChooseWalksDialog-EN3C6AQA.js → ChooseWalksDialog-UXLFZTZJ.js} +2 -2
  6. package/dist/chunks/GbzBaseSyntenyAdapter-LRECKL74.js +2 -0
  7. package/dist/chunks/GbzBaseSyntenyAdapter-LRECKL74.js.map +7 -0
  8. package/dist/chunks/{GraphGenomeView-Z2WZKEEO.js → GraphGenomeView-NJ5XCREB.js} +2 -2
  9. package/dist/chunks/GraphTrackSettingsDialog-47PQ6LM7.js +6 -0
  10. package/dist/chunks/GraphTrackSettingsDialog-47PQ6LM7.js.map +7 -0
  11. package/dist/chunks/{HighlightColorDialog-EYBKFSJU.js → HighlightColorDialog-UK5VDDV6.js} +2 -2
  12. package/dist/chunks/{LinearGraphDisplay-WIBVWRQE.js → LinearGraphDisplay-TXTKAACH.js} +2 -2
  13. package/dist/chunks/MinigraphBubbleAdapter-HW7XQMAI.js +2 -0
  14. package/dist/chunks/MinigraphBubbleAdapter-HW7XQMAI.js.map +7 -0
  15. package/dist/chunks/RgfaTabixAdapter-PSKYWD2X.js +3 -0
  16. package/dist/chunks/RgfaTabixAdapter-PSKYWD2X.js.map +7 -0
  17. package/dist/chunks/{TrackWarningsDialog-QT4YEXGD.js → TrackWarningsDialog-TRYBOIHX.js} +2 -2
  18. package/dist/chunks/WalkTabixSyntenyAdapter-U53JLYVU.js +2 -0
  19. package/dist/chunks/WalkTabixSyntenyAdapter-U53JLYVU.js.map +7 -0
  20. package/dist/chunks/chunk-2MCOY3YG.js +3 -0
  21. package/dist/chunks/chunk-2MCOY3YG.js.map +7 -0
  22. package/dist/chunks/{chunk-EWFJBQDV.js → chunk-5O6YRJHL.js} +2 -2
  23. package/dist/chunks/{chunk-EWFJBQDV.js.map → chunk-5O6YRJHL.js.map} +1 -1
  24. package/dist/chunks/chunk-BUY2PV7D.js +2 -0
  25. package/dist/chunks/chunk-BUY2PV7D.js.map +7 -0
  26. package/dist/chunks/chunk-DVCZ3BOC.js +2 -0
  27. package/dist/chunks/chunk-DVCZ3BOC.js.map +7 -0
  28. package/dist/chunks/{chunk-SAMJE6GH.js → chunk-EGDLEQ47.js} +3 -3
  29. package/dist/chunks/{chunk-SAMJE6GH.js.map → chunk-EGDLEQ47.js.map} +4 -4
  30. package/dist/chunks/chunk-FHZXW7IG.js +2 -0
  31. package/dist/chunks/chunk-FHZXW7IG.js.map +7 -0
  32. package/dist/chunks/{chunk-DZ4OUKQV.js → chunk-FITPB5X6.js} +2 -2
  33. package/dist/chunks/{chunk-DZ4OUKQV.js.map → chunk-FITPB5X6.js.map} +1 -1
  34. package/dist/chunks/chunk-FVK2THE4.js +2 -0
  35. package/dist/chunks/chunk-FVK2THE4.js.map +7 -0
  36. package/dist/chunks/{chunk-AHFQHYJI.js → chunk-IBWORBGY.js} +2 -2
  37. package/dist/chunks/chunk-MND7GAOG.js +2 -0
  38. package/dist/chunks/chunk-MND7GAOG.js.map +7 -0
  39. package/dist/chunks/chunk-MURN3JPK.js +2 -0
  40. package/dist/chunks/chunk-MURN3JPK.js.map +7 -0
  41. package/dist/chunks/{chunk-3Q4RBDCL.js → chunk-N6PQZSAX.js} +1 -1
  42. package/dist/chunks/{chunk-3Q4RBDCL.js.map → chunk-N6PQZSAX.js.map} +1 -1
  43. package/dist/chunks/chunk-NWJYLP6Z.js +4 -0
  44. package/dist/chunks/chunk-NWJYLP6Z.js.map +7 -0
  45. package/dist/chunks/{chunk-YJHYBDYF.js → chunk-S75W27NT.js} +2 -2
  46. package/dist/chunks/{chunk-YJHYBDYF.js.map → chunk-S75W27NT.js.map} +1 -1
  47. package/dist/chunks/{chunk-IXQK7JAW.js → chunk-T4HOC6O3.js} +1 -1
  48. package/dist/chunks/{chunk-IXQK7JAW.js.map → chunk-T4HOC6O3.js.map} +1 -1
  49. package/dist/chunks/{chunk-AU73K7LX.js → chunk-TUKJRVBS.js} +1 -1
  50. package/dist/chunks/{chunk-AU73K7LX.js.map → chunk-TUKJRVBS.js.map} +1 -1
  51. package/dist/chunks/chunk-UGCNPRKC.js +2 -0
  52. package/dist/chunks/{chunk-E3WYW7Z6.js.map → chunk-UGCNPRKC.js.map} +2 -2
  53. package/dist/chunks/{chunk-YSTMDXXX.js → chunk-VJ3SO4CH.js} +1 -1
  54. package/dist/chunks/{chunk-YSTMDXXX.js.map → chunk-VJ3SO4CH.js.map} +1 -1
  55. package/dist/chunks/{chunk-XT766CZ5.js → chunk-W6EQLQ6H.js} +1 -1
  56. package/dist/chunks/{chunk-XT766CZ5.js.map → chunk-W6EQLQ6H.js.map} +1 -1
  57. package/dist/chunks/chunk-WAMBI7OX.js +2 -0
  58. package/dist/chunks/chunk-WAMBI7OX.js.map +7 -0
  59. package/dist/chunks/chunk-WCGVUZWP.js +2 -0
  60. package/dist/chunks/chunk-WCGVUZWP.js.map +7 -0
  61. package/dist/chunks/chunk-WEGWTC52.js +2 -0
  62. package/dist/chunks/chunk-WEGWTC52.js.map +7 -0
  63. package/dist/chunks/chunk-YU7T5WOQ.js +2 -0
  64. package/dist/chunks/{chunk-6OPB7FOJ.js.map → chunk-YU7T5WOQ.js.map} +2 -2
  65. package/dist/chunks/{chunk-446RWIA3.js → chunk-ZMOMFU2B.js} +1 -1
  66. package/dist/chunks/{chunk-446RWIA3.js.map → chunk-ZMOMFU2B.js.map} +1 -1
  67. package/dist/chunks/renderSvg-KSQI5DH6.js +2 -0
  68. package/dist/chunks/renderSvg-KSQI5DH6.js.map +7 -0
  69. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +4 -4
  70. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +4 -4
  71. package/package.json +8 -9
  72. package/src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.test.ts +12 -10
  73. package/src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.ts +31 -39
  74. package/src/GbzBaseSyntenyAdapter/configSchema.ts +5 -29
  75. package/src/GetGraphHaplotypes.ts +6 -15
  76. package/src/GetGraphReads.ts +7 -14
  77. package/src/GetSubgraph.ts +11 -20
  78. package/src/GraphAddTrackWorkflow/AddTrackWorkflow.test.tsx +73 -0
  79. package/src/GraphAddTrackWorkflow/AddTrackWorkflow.tsx +1 -0
  80. package/src/GraphAddTrackWorkflow/buildTrackConfig.test.ts +3 -2
  81. package/src/GraphAddTrackWorkflow/buildTrackConfig.ts +2 -11
  82. package/src/GraphAddTrackWorkflow/graphManifest.ts +15 -3
  83. package/src/GraphGenomeView/components/BubbleHalos.tsx +5 -24
  84. package/src/GraphGenomeView/components/ElTree.tsx +6 -1
  85. package/src/GraphGenomeView/components/FacetPanels.test.tsx +65 -0
  86. package/src/GraphGenomeView/components/FacetPanels.tsx +17 -12
  87. package/src/GraphGenomeView/components/GenePins.tsx +5 -22
  88. package/src/GraphGenomeView/components/GraphCanvas.tsx +40 -234
  89. package/src/GraphGenomeView/components/GraphSettingsDialog.tsx +102 -108
  90. package/src/GraphGenomeView/components/GraphToolbar.tsx +5 -6
  91. package/src/GraphGenomeView/components/HoverLayer.tsx +3 -7
  92. package/src/GraphGenomeView/components/HoverTooltip.test.tsx +39 -0
  93. package/src/GraphGenomeView/components/HoverTooltip.tsx +122 -0
  94. package/src/GraphGenomeView/components/LabelChip.tsx +3 -5
  95. package/src/GraphGenomeView/components/LabelLayer.tsx +4 -17
  96. package/src/GraphGenomeView/components/LabelledSelect.tsx +1 -1
  97. package/src/GraphGenomeView/components/Legend.tsx +14 -23
  98. package/src/GraphGenomeView/components/PaneContextMenu.test.tsx +48 -0
  99. package/src/GraphGenomeView/components/PaneContextMenu.tsx +144 -0
  100. package/src/GraphGenomeView/components/PaneLayer.tsx +91 -0
  101. package/src/GraphGenomeView/components/PaneSvg.tsx +32 -50
  102. package/src/GraphGenomeView/components/ReferenceStripOverlay.test.tsx +48 -0
  103. package/src/GraphGenomeView/components/ReferenceStripOverlay.tsx +13 -42
  104. package/src/GraphGenomeView/components/SettingsMenu.test.tsx +29 -0
  105. package/src/GraphGenomeView/components/SettingsMenu.tsx +56 -65
  106. package/src/GraphGenomeView/components/TubeMapOverlay.tsx +15 -46
  107. package/src/GraphGenomeView/components/WalkRowsOverlay.tsx +58 -132
  108. package/src/GraphGenomeView/components/WalkStrip.tsx +17 -20
  109. package/src/GraphGenomeView/components/WalkStripLocator.tsx +8 -15
  110. package/src/GraphGenomeView/components/usePaneGestures.test.tsx +35 -0
  111. package/src/GraphGenomeView/components/usePaneGestures.ts +88 -91
  112. package/src/GraphGenomeView/genes/geneFeatures.ts +27 -45
  113. package/src/GraphGenomeView/graphLayers.ts +4 -4
  114. package/src/GraphGenomeView/host.ts +1 -1
  115. package/src/GraphGenomeView/legendSections.test.ts +23 -1
  116. package/src/GraphGenomeView/legendSections.ts +68 -74
  117. package/src/GraphGenomeView/model.test.ts +373 -39
  118. package/src/GraphGenomeView/model.ts +67 -11
  119. package/src/GraphGenomeView/pane/fitViews.ts +57 -514
  120. package/src/GraphGenomeView/pane/graphViews.ts +219 -160
  121. package/src/GraphGenomeView/pane/hostViews.ts +2 -10
  122. package/src/GraphGenomeView/pane/keepInView.ts +5 -4
  123. package/src/GraphGenomeView/pane/launchActions.ts +117 -139
  124. package/src/GraphGenomeView/pane/launchViews.ts +8 -27
  125. package/src/GraphGenomeView/pane/loadActions.ts +208 -187
  126. package/src/GraphGenomeView/pane/morph.ts +3 -9
  127. package/src/GraphGenomeView/pane/paneBase.ts +22 -11
  128. package/src/GraphGenomeView/pane/renderingActions.ts +65 -11
  129. package/src/GraphGenomeView/pane/settingActions.ts +17 -42
  130. package/src/GraphGenomeView/pane/tubeMapViews.ts +445 -0
  131. package/src/GraphGenomeView/pane/walkRowViews.ts +29 -37
  132. package/src/GraphGenomeView/renderPipeline.test.ts +1 -1
  133. package/src/GraphGenomeView/repeats/repeatFeatures.test.ts +23 -0
  134. package/src/GraphGenomeView/repeats/repeatFeatures.ts +16 -23
  135. package/src/GraphGenomeView/repeats/walkCalls.test.ts +18 -0
  136. package/src/GraphGenomeView/repeats/walkCalls.ts +46 -38
  137. package/src/GraphGenomeView/subgraphLoad.test.ts +67 -3
  138. package/src/GraphGenomeView/trackFeatures.ts +24 -0
  139. package/src/GraphGenomeView/tubeMapPanels.ts +28 -36
  140. package/src/GraphGenomeView/viewModel.ts +8 -56
  141. package/src/GraphGenomeView/walkRowGroups.ts +104 -30
  142. package/src/GraphGenomeView/walkRowSpans.test.ts +6 -0
  143. package/src/GraphGenomeView/walkRowSpans.ts +22 -31
  144. package/src/GraphGenomeView/walkRowsCut.ts +8 -17
  145. package/src/LinearGraphDisplay/LinearGraphDisplay.test.ts +173 -26
  146. package/src/LinearGraphDisplay/components/SubgraphContextSelect.test.tsx +1 -1
  147. package/src/LinearGraphDisplay/components/SubgraphContextSelect.tsx +3 -3
  148. package/src/LinearGraphDisplay/components/SubgraphHaplotypesField.test.tsx +3 -3
  149. package/src/LinearGraphDisplay/components/SubgraphHaplotypesField.tsx +7 -10
  150. package/src/LinearGraphDisplay/configSchema.ts +0 -3
  151. package/src/LinearGraphDisplay/denseWindow.ts +8 -11
  152. package/src/LinearGraphDisplay/model.ts +89 -82
  153. package/src/MinigraphBubbleAdapter/MinigraphBubbleAdapter.test.ts +21 -0
  154. package/src/MinigraphBubbleAdapter/MinigraphBubbleAdapter.ts +6 -14
  155. package/src/MinigraphBubbleAdapter/configSchema.ts +3 -9
  156. package/src/MinigraphBubbleAdapter/index.ts +1 -2
  157. package/src/RgfaTabixAdapter/RgfaTabixAdapter.test.ts +45 -1
  158. package/src/RgfaTabixAdapter/RgfaTabixAdapter.ts +111 -276
  159. package/src/RgfaTabixAdapter/configSchema.ts +15 -49
  160. package/src/RgfaTabixAdapter/index.ts +1 -2
  161. package/src/RgfaTabixAdapter/rgfaBed.ts +25 -15
  162. package/src/RgfaTabixAdapter/rgfaCut.ts +139 -0
  163. package/src/RgfaTabixAdapter/test_data/walks2_twopart.GRCh38.walks.bed.gz +0 -0
  164. package/src/RgfaTabixAdapter/test_data/walks2_twopart.GRCh38.walks.bed.gz.tbi +0 -0
  165. package/src/RgfaTabixAdapter/walkFiles.test.ts +33 -0
  166. package/src/RgfaTabixAdapter/walkReader.ts +103 -27
  167. package/src/RgfaTabixAdapter/walkRowRuns.test.ts +53 -0
  168. package/src/RgfaTabixAdapter/walkRowRuns.ts +42 -24
  169. package/src/WalkTabixSyntenyAdapter/WalkTabixSyntenyAdapter.test.ts +37 -6
  170. package/src/WalkTabixSyntenyAdapter/WalkTabixSyntenyAdapter.ts +23 -45
  171. package/src/WalkTabixSyntenyAdapter/configSchema.ts +11 -24
  172. package/src/WalkTabixSyntenyAdapter/index.ts +1 -2
  173. package/src/WalkTabixSyntenyAdapter/walkLanes.ts +35 -43
  174. package/src/adapterImplementing.ts +27 -0
  175. package/src/graphTrackDefaults/index.ts +14 -20
  176. package/src/hoverSync/lgvHover.ts +2 -4
  177. package/src/launchFromGraph/contributors.ts +1 -5
  178. package/src/launchFromGraph/graphMenuItems.ts +3 -4
  179. package/src/launchFromGraph/launchFromGraph.test.ts +0 -1
  180. package/src/launchFromGraph/launchFromGraph.ts +8 -13
  181. package/src/panSNTabix.test.ts +1 -26
  182. package/src/panSNTabix.ts +54 -51
  183. package/src/synteny/lanePairs.ts +8 -0
  184. package/src/synteny/matchFeature.ts +52 -0
  185. package/src/tabixRange.ts +13 -10
  186. package/src/version.ts +1 -1
  187. package/dist/chunks/AddTrackWorkflow-Q6RY23LF.js +0 -2
  188. package/dist/chunks/GbzBaseSyntenyAdapter-TIXR4Y3J.js +0 -2
  189. package/dist/chunks/GbzBaseSyntenyAdapter-TIXR4Y3J.js.map +0 -7
  190. package/dist/chunks/GraphTrackSettingsDialog-TAM6PMXD.js +0 -6
  191. package/dist/chunks/GraphTrackSettingsDialog-TAM6PMXD.js.map +0 -7
  192. package/dist/chunks/MinigraphBubbleAdapter-AGI2UYQR.js +0 -2
  193. package/dist/chunks/MinigraphBubbleAdapter-AGI2UYQR.js.map +0 -7
  194. package/dist/chunks/RgfaTabixAdapter-2OL5X3HF.js +0 -3
  195. package/dist/chunks/RgfaTabixAdapter-2OL5X3HF.js.map +0 -7
  196. package/dist/chunks/WalkTabixSyntenyAdapter-UKFHCFOF.js +0 -2
  197. package/dist/chunks/WalkTabixSyntenyAdapter-UKFHCFOF.js.map +0 -7
  198. package/dist/chunks/chunk-5SFGHDQA.js +0 -2
  199. package/dist/chunks/chunk-5SFGHDQA.js.map +0 -7
  200. package/dist/chunks/chunk-6OPB7FOJ.js +0 -2
  201. package/dist/chunks/chunk-AMFIBQVR.js +0 -2
  202. package/dist/chunks/chunk-AMFIBQVR.js.map +0 -7
  203. package/dist/chunks/chunk-BJMRBVG3.js +0 -2
  204. package/dist/chunks/chunk-BJMRBVG3.js.map +0 -7
  205. package/dist/chunks/chunk-E3WYW7Z6.js +0 -2
  206. package/dist/chunks/chunk-EHCF6AXH.js +0 -2
  207. package/dist/chunks/chunk-EHCF6AXH.js.map +0 -7
  208. package/dist/chunks/chunk-GOFS7BXK.js +0 -3
  209. package/dist/chunks/chunk-GOFS7BXK.js.map +0 -7
  210. package/dist/chunks/chunk-IJQTSJGT.js +0 -4
  211. package/dist/chunks/chunk-IJQTSJGT.js.map +0 -7
  212. package/dist/chunks/chunk-J6NZIAZF.js +0 -2
  213. package/dist/chunks/chunk-J6NZIAZF.js.map +0 -7
  214. package/dist/chunks/chunk-LUTMKRXY.js +0 -2
  215. package/dist/chunks/chunk-LUTMKRXY.js.map +0 -7
  216. package/dist/chunks/chunk-MHPJB22Z.js +0 -2
  217. package/dist/chunks/chunk-MHPJB22Z.js.map +0 -7
  218. package/dist/chunks/chunk-TXI43PEN.js +0 -2
  219. package/dist/chunks/chunk-TXI43PEN.js.map +0 -7
  220. package/dist/chunks/chunk-WRH2EJKX.js +0 -2
  221. package/dist/chunks/chunk-WRH2EJKX.js.map +0 -7
  222. package/dist/chunks/chunk-WX26KTZM.js +0 -2
  223. package/dist/chunks/chunk-WX26KTZM.js.map +0 -7
  224. package/dist/chunks/renderSvg-ST2GBBOC.js +0 -2
  225. package/dist/chunks/renderSvg-ST2GBBOC.js.map +0 -7
  226. package/src/GraphGenomeView/components/WalkRowContextMenu.tsx +0 -105
  227. /package/dist/chunks/{ChooseSamplesDialog-BNVYBGJQ.js.map → ChooseSamplesDialog-JRN4YLBY.js.map} +0 -0
  228. /package/dist/chunks/{ChooseWalksDialog-EN3C6AQA.js.map → ChooseWalksDialog-UXLFZTZJ.js.map} +0 -0
  229. /package/dist/chunks/{GraphGenomeView-Z2WZKEEO.js.map → GraphGenomeView-NJ5XCREB.js.map} +0 -0
  230. /package/dist/chunks/{HighlightColorDialog-EYBKFSJU.js.map → HighlightColorDialog-UK5VDDV6.js.map} +0 -0
  231. /package/dist/chunks/{LinearGraphDisplay-WIBVWRQE.js.map → LinearGraphDisplay-TXTKAACH.js.map} +0 -0
  232. /package/dist/chunks/{TrackWarningsDialog-QT4YEXGD.js.map → TrackWarningsDialog-TRYBOIHX.js.map} +0 -0
  233. /package/dist/chunks/{chunk-AHFQHYJI.js.map → chunk-IBWORBGY.js.map} +0 -0
@@ -1,13 +1,16 @@
1
+ import { regionLabel } from '@jbrowse/bandage-core/hoverText'
1
2
  import { readConfObject } from '@jbrowse/core/configuration'
2
3
 
3
- import { locLabel, locString } from './contributors'
4
+ import { locString } from './contributors'
4
5
  import { linearViewTarget } from './linearViewTarget'
5
6
 
6
7
  import type { Contributor, GraphLocation } from './contributors'
8
+ import type { SubgraphRegion } from '../GetSubgraph'
7
9
  import type { AnyConfigurationModel } from '@jbrowse/core/configuration'
8
10
 
9
11
  export interface TrackScanSession {
10
12
  tracks: AnyConfigurationModel[]
13
+ // core's getTrackName reads these
11
14
  assemblies: AnyConfigurationModel[]
12
15
  // optional, as a hand-built session in a test has none
13
16
  assemblyManager?: {
@@ -46,17 +49,11 @@ export interface GraphLaunchSession extends TrackScanSession {
46
49
  type: string,
47
50
  snapshot?: Record<string, unknown>,
48
51
  ) => Promise<{ id: string }>
49
- assemblyNames: string[]
50
52
  views: unknown[]
51
53
  // optional, as a hand-built session in a test has none
52
54
  notifyError?: (message: string, error?: unknown) => void
53
55
  // a highlight every linear view on its assembly draws
54
- addHighlight?: (highlight: {
55
- refName: string
56
- start: number
57
- end: number
58
- assemblyName: string
59
- }) => void
56
+ addHighlight?: (highlight: SubgraphRegion) => void
60
57
  }
61
58
 
62
59
  // A launch is a promise nothing waits on. Let go, a refusal moved nothing and
@@ -107,9 +104,7 @@ export function paddedLocation(
107
104
  // assemblies, or the reference is filtered out by the name this replaces.
108
105
  export function withReferenceRegion(
109
106
  contributors: Contributor[],
110
- region:
111
- | { refName: string; assemblyName: string; start: number; end: number }
112
- | undefined,
107
+ region: SubgraphRegion | undefined,
113
108
  ): Contributor[] {
114
109
  return region
115
110
  ? contributors.map(c =>
@@ -160,13 +155,13 @@ export function showInLinearView({
160
155
  if (existing) {
161
156
  reportFailure(
162
157
  session,
163
- `Could not show ${assembly} ${locLabel(location)}`,
158
+ `Could not show ${assembly} ${regionLabel(location)}`,
164
159
  Promise.resolve(existing.navToLocString(locString(location), assembly)),
165
160
  )
166
161
  viewId = existing.id
167
162
  } else {
168
163
  viewId = session.addView('LinearGenomeView', {
169
- displayName: `${assembly} — ${locLabel(location)}`,
164
+ displayName: `${assembly} — ${regionLabel(location)}`,
170
165
  init: { assembly, loc: locString(location), tracks },
171
166
  }).id
172
167
  }
@@ -1,29 +1,4 @@
1
- import {
2
- PanSNRefNames,
3
- buildRefNameLookup,
4
- resolveRefName,
5
- } from './panSNTabix.ts'
6
-
7
- // The reason both tabix graph adapters need this at all: a graph's stable
8
- // sequences are usually PanSN while the assembly asking for them uses the bare
9
- // contig, and a session may hold the same sample as one assembly or as two.
10
- test('a PanSN stable name resolves under its sample and under its haplotype', () => {
11
- const lookup = buildRefNameLookup([
12
- 'GRCh38#0#chr6',
13
- 'NA20809#2#CM094351.1',
14
- 'chrM',
15
- ])
16
- expect(resolveRefName(lookup, 'GRCh38', 'chr6')).toBe('GRCh38#0#chr6')
17
- expect(resolveRefName(lookup, 'GRCh38#0', 'chr6')).toBe('GRCh38#0#chr6')
18
- expect(resolveRefName(lookup, 'NA20809#2', 'CM094351.1')).toBe(
19
- 'NA20809#2#CM094351.1',
20
- )
21
- expect(resolveRefName(lookup, 'NA20809', 'CM094351.1')).toBe(
22
- 'NA20809#2#CM094351.1',
23
- )
24
- expect(resolveRefName(lookup, 'hg38', 'chrM')).toBe('chrM')
25
- expect(resolveRefName(lookup, 'NA20809#1', 'CM094351.1')).toBeUndefined()
26
- })
1
+ import { PanSNRefNames } from './panSNTabix.ts'
27
2
 
28
3
  // The index's names are read once and every query awaits that one read. It is
29
4
  // shared, so it cannot take on one caller's signal: a track fetch the user
package/src/panSNTabix.ts CHANGED
@@ -1,16 +1,17 @@
1
1
  import { TabixIndexedFile } from '@gmod/tabix'
2
2
  import {
3
3
  panSNContig,
4
- panSNHaplotype,
5
4
  panSNMatchesPrefix,
6
- panSNSample,
7
5
  resolvePanSNPrefix,
8
6
  } from '@jbrowse/bandage-core/pansn'
9
7
  import { ConfigurationSchema } from '@jbrowse/core/configuration'
10
8
  import { cachedSetup } from '@jbrowse/core/data_adapters/BaseAdapter'
11
9
  import { openLocation, openTabixIndexFilehandle } from '@jbrowse/core/util/io'
10
+ import { refNameLookup, resolveRefName } from '@jbrowse/graph-walks'
12
11
  import { types } from '@jbrowse/mobx-state-tree'
13
12
 
13
+ import { bytesForRegions } from './tabixRange.ts'
14
+
14
15
  import type {
15
16
  BaseFeatureDataAdapter,
16
17
  BaseOptions,
@@ -19,16 +20,12 @@ import type { Region } from '@jbrowse/core/util/types'
19
20
 
20
21
  // What a tabix-indexed graph track answers about its own reference names, for
21
22
  // the two adapters that read one: `RgfaTabixAdapter` over segments and links,
22
- // and `MinigraphBubbleAdapter` over bubbles.
23
- //
24
- // The two carried this verbatim — the opener, the cached lookup, `getRefNames`,
25
- // `resolve` — and the bubble adapter reached across into
26
- // `RgfaTabixAdapter/rgfaBed.ts` for the lookup half, which is a BED row grammar
27
- // and not this. Same reason `ComparativeAdapterBase` exists: the answers that do
28
- // not depend on which config slot names the file belong in one place.
23
+ // and `MinigraphBubbleAdapter` over bubbles. @jbrowse/graph-walks builds the
24
+ // name lookup.
29
25
  //
30
- // A class rather than a base class, for the reason that file records: a base
31
- // generic over the config cannot prove a slot name to `getConf`, so the adapter
26
+ // A class rather than a base class, for the reason ComparativeAdapterBase.ts
27
+ // records: a base generic over the config cannot prove a slot name to
28
+ // `getConf`, so the adapter
32
29
  // keeps the two lines that read its own slots and hands over the file. Reading
33
30
  // `assemblyNameToPanSN` IS hoistable, because every schema here declares it and
34
31
  // `resolvePanSNPrefix` is already generic over the base adapter type.
@@ -38,6 +35,12 @@ import type { Region } from '@jbrowse/core/util/types'
38
35
  // kB of compressed blocks, and re-fetching them per pan is the cost this avoids.
39
36
  const CHUNK_CACHE_SIZE = 50 * 2 ** 20
40
37
 
38
+ // A file slot whose default is a url, '' for none
39
+ export const fileLocationSlot = (uri: string) => ({
40
+ type: 'fileLocation' as const,
41
+ defaultValue: { uri, locationType: 'UriLocation' },
42
+ })
43
+
41
44
  /**
42
45
  * The index slot `openTabixSlot` reads: its own `location` and `indexType`
43
46
  */
@@ -54,10 +57,7 @@ export const tabixIndexSchema = (name: string, defaultUri = '') =>
54
57
  /**
55
58
  * #slot
56
59
  */
57
- location: {
58
- type: 'fileLocation',
59
- defaultValue: { uri: defaultUri, locationType: 'UriLocation' },
60
- },
60
+ location: fileLocationSlot(defaultUri),
61
61
  })
62
62
 
63
63
  // The index slot's snapshot for a file whose `.tbi`, or `.csi`, sits beside it
@@ -68,6 +68,20 @@ export function tbiBeside(uri: string, baseUri: unknown, csi: unknown) {
68
68
  }
69
69
  }
70
70
 
71
+ // The `walksUri` shorthand: `<walksUri>.walks.bed.gz` and its index
72
+ export function walksLocations(snap: Record<string, unknown>) {
73
+ const { walksUri, baseUri, csi } = snap
74
+ if (typeof walksUri !== 'string') {
75
+ return snap
76
+ }
77
+ const walks = `${walksUri}.walks.bed.gz`
78
+ return {
79
+ ...snap,
80
+ walksLocation: { uri: walks, baseUri },
81
+ walksIndex: tbiBeside(walks, baseUri, csi),
82
+ }
83
+ }
84
+
71
85
  // One indexed file from the pair of slots that names it: the data location, and
72
86
  // an index slot holding its own `location` and `indexType`. Paths, so the pair
73
87
  // can sit in a sub-schema.
@@ -88,41 +102,6 @@ export function openTabixSlot(
88
102
  })
89
103
  }
90
104
 
91
- // A tab can occur in neither half — both come out of BED columns.
92
- function qualifiedKey(assemblyName: string, refName: string) {
93
- return `${assemblyName}\t${refName}`
94
- }
95
-
96
- // The stable sequences in these files are usually PanSN (`K12#1#chr`) while the
97
- // assembly asking for them uses the bare contig (`chr` in assembly `K12`). One
98
- // map answers both spellings: the raw tabix name, plus a sample+contig key for
99
- // PanSN names.
100
- export function buildRefNameLookup(tabixRefNames: string[]) {
101
- const lookup = new Map<string, string>()
102
- for (const name of tabixRefNames) {
103
- lookup.set(name, name)
104
- const sample = panSNSample(name)
105
- if (sample !== name) {
106
- const contig = panSNContig(name)
107
- lookup.set(qualifiedKey(sample, contig), name)
108
- const haplotype = panSNHaplotype(name)
109
- if (haplotype !== undefined) {
110
- lookup.set(qualifiedKey(haplotype, contig), name)
111
- }
112
- }
113
- }
114
- return lookup
115
- }
116
-
117
- export function resolveRefName(
118
- lookup: Map<string, string>,
119
- assemblyName: string,
120
- refName: string,
121
- ) {
122
- const qualified = lookup.get(qualifiedKey(assemblyName, refName))
123
- return qualified === undefined ? lookup.get(refName) : qualified
124
- }
125
-
126
105
  /**
127
106
  * The reference-name half of a tabix graph track, against one indexed file.
128
107
  *
@@ -136,7 +115,7 @@ export class PanSNRefNames {
136
115
  // read going for the rest, and retries a failed read.
137
116
  private lookup = cachedSetup({
138
117
  setup: async opts =>
139
- buildRefNameLookup(await this.file.getReferenceSequenceNames(opts)),
118
+ refNameLookup(await this.file.getReferenceSequenceNames(opts)),
140
119
  })
141
120
 
142
121
  constructor(
@@ -179,4 +158,28 @@ export class PanSNRefNames {
179
158
  region.refName,
180
159
  )
181
160
  }
161
+
162
+ /**
163
+ * The compressed bytes a read of `regions` fetches from the file, as its
164
+ * index estimates them, for the display's byte gate. `queryStart` moves a
165
+ * region's start to where the read begins.
166
+ */
167
+ async regionBytes(
168
+ regions: Region[],
169
+ opts: BaseOptions = {},
170
+ queryStart = async (start: number) => start,
171
+ ) {
172
+ const spans = []
173
+ for (const region of regions) {
174
+ const refName = await this.resolve(region, opts)
175
+ if (refName !== undefined) {
176
+ spans.push({
177
+ refName,
178
+ start: await queryStart(region.start),
179
+ end: region.end,
180
+ })
181
+ }
182
+ }
183
+ return bytesForRegions(this.file, spans, opts)
184
+ }
182
185
  }
@@ -49,6 +49,14 @@ export function requestedPairs(opts: LaneFeatureOptions): LanePair[] {
49
49
  }
50
50
  }
51
51
 
52
+ // The status a fetch of lane pairs shows while it reads
53
+ export function lanePairsStatus(pairs: LanePair[]) {
54
+ const [first] = pairs
55
+ return pairs.length === 1 && first
56
+ ? `Reading ${first.queryAssemblyName} against ${first.targetAssemblyName}`
57
+ : `Reading ${pairs.length} lane pairs`
58
+ }
59
+
52
60
  /**
53
61
  * The lane a haplotype draws on: the JBrowse assembly the config maps to its
54
62
  * `sample#haplotype` prefix, else to its sample, else the prefix itself. The
@@ -0,0 +1,52 @@
1
+ import SyntenyFeature from './SyntenyFeature.ts'
2
+
3
+ export interface MatchSide {
4
+ name: string
5
+ assemblyName: string
6
+ refName: string
7
+ start: number
8
+ end: number
9
+ }
10
+
11
+ /**
12
+ * One record of a walk aligned to another, on the target walk's contig with
13
+ * the query walk as its mate and the CIGAR read along the target, a `D` being
14
+ * target bases the query lacks. Each side's walk name and extent make the id.
15
+ */
16
+ export function matchFeature({
17
+ target,
18
+ query,
19
+ strand,
20
+ cigar,
21
+ matches,
22
+ columns,
23
+ }: {
24
+ target: MatchSide
25
+ query: MatchSide
26
+ strand: string
27
+ cigar: string
28
+ matches: number
29
+ columns: number
30
+ }) {
31
+ const id = `${target.name}:${target.start}-${target.end}|${query.name}:${query.start}-${query.end}`
32
+ return new SyntenyFeature({
33
+ uniqueId: id,
34
+ assemblyName: target.assemblyName,
35
+ refName: target.refName,
36
+ start: target.start,
37
+ end: target.end,
38
+ type: 'match',
39
+ strand: strand === '-' ? -1 : 1,
40
+ CIGAR: cigar,
41
+ syntenyId: id,
42
+ identity: matches / Math.max(columns, 1),
43
+ numMatches: matches,
44
+ blockLen: columns,
45
+ mate: {
46
+ refName: query.refName,
47
+ start: query.start,
48
+ end: query.end,
49
+ assemblyName: query.assemblyName,
50
+ },
51
+ })
52
+ }
package/src/tabixRange.ts CHANGED
@@ -1,14 +1,6 @@
1
- import type { TabixIndexedFile } from '@gmod/tabix'
1
+ import { checkRange } from '@jbrowse/graph-walks'
2
2
 
3
- // tabix-js loops forever on a NaN end and reads nothing for a NaN start
4
- // (GMOD/tabix-js#157), so every query refuses a range that is not finite first
5
- export function checkRange(refName: string, start: number, end: number) {
6
- if (!Number.isFinite(start) || !Number.isFinite(end)) {
7
- throw new Error(
8
- `${refName}:${start}-${end} is not a finite range to query the graph's index for`,
9
- )
10
- }
11
- }
3
+ import type { TabixIndexedFile } from '@gmod/tabix'
12
4
 
13
5
  export async function getLines(
14
6
  file: TabixIndexedFile,
@@ -23,3 +15,14 @@ export async function getLines(
23
15
  checkRange(refName, start, end)
24
16
  return file.getLines(refName, start, end, opts)
25
17
  }
18
+
19
+ export async function bytesForRegions(
20
+ file: TabixIndexedFile,
21
+ regions: { refName: string; start: number; end: number }[],
22
+ opts: { signal?: AbortSignal },
23
+ ) {
24
+ for (const { refName, start, end } of regions) {
25
+ checkRange(refName, start, end)
26
+ }
27
+ return file.bytesForRegions(regions, opts)
28
+ }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '7.1.0'
1
+ export const version = '7.1.2'
@@ -1,2 +0,0 @@
1
- import{a as H,b as j,c as O,d as z,g as J}from"./chunk-EHCF6AXH.js";import"./chunk-5OI6LO4I.js";import"./chunk-7WIBGKBU.js";import"./chunk-OGQ6OQDN.js";import{d as w,e as R}from"./chunk-NDRLCGPC.js";import{b as T,h as G,j as S,m as A}from"./chunk-TENPGIPX.js";import{g as r}from"./chunk-6OPB7FOJ.js";import{A as N,B as _,C as W,F as b,a as v,e as x,f as p,o as E,s as B,t as I,u as P}from"./chunk-E3WYW7Z6.js";import{b as t,c as g,d as M}from"./chunk-JMBDTNUR.js";var s=JBrowseExports["@jbrowse/core/util/tss-react"],$=o=>s!=null&&o in Object(s)?s[o]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+o+"' from '@jbrowse/core/util/tss-react' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:o});var D=$("makeStyles"),oe=s&&s.__esModule?s.default:s;var ee=D()(o=>({paper:{margin:o.spacing(),padding:o.spacing()},field:{marginTop:o.spacing(2)},submit:{marginTop:25,marginBottom:100,display:"block"}})),te=["RgfaTabixAdapter","GbzBaseSyntenyAdapter","MinigraphBubbleAdapter"],ae=M(function({model:a}){let{classes:l}=ee(),f=S(a),d=w(a),[n,V]=r("RgfaTabixAdapter"),[i,X]=r(),[y,q]=r(),[k,K]=r(),m=n==="GbzBaseSyntenyAdapter",[C,Q]=r(""),[h,U]=r("Pangenome graph"),[F,u]=r(),[Y,L]=r(!1);async function Z(){if(!i||!a.assembly)return;u(void 0),L(!0);let e=n==="RgfaTabixAdapter"?await H(i,G(a).pluginManager):void 0;if(L(!1),!(!R(a)||!a.assembly))try{let c=h.trim();T({model:a,session:f,conf:J({choice:n,loc:i,indexLoc:y,readsLoc:m?k:void 0,manifest:e,assembly:a.assembly,sample:C,trackId:A({name:c}),name:c})})}catch(c){u(c)}}return g(N,{className:l.paper,children:[F?t(x,{error:F}):null,g(B,{children:[t(P,{children:"File type"}),t(W,{value:n,onChange:e=>{V(e.target.value),u(void 0)},children:te.map(e=>t(I,{value:e,control:t(_,{}),label:j[e]},e))})]}),t(p,{location:i,name:O[n],rootModel:d,setLocation:X}),t(p,{location:y,name:z[n],rootModel:d,setLocation:q}),m?t(p,{location:k,name:"Path to reads aligned to the graph as GAF (optional; a .gz is read by the .tbi beside it)",rootModel:d,setLocation:K}):null,t(b,{className:l.field,value:C,onChange:e=>{Q(e.target.value)},label:"Sample name in the graph",slotProps:{htmlInput:{"data-testid":"graph-sample-input"}},helperText:m?"Optional. The graph's sample for this assembly, e.g. GRCh38 where the assembly is hg38; leave blank when they share a name or the graph has one reference sample":"Optional. The PanSN prefix the graph gives this assembly, e.g. GRCh38 for HPRC's GRCh38#0#chr1; leave blank when the graph's stable names are bare",placeholder:"GRCh38",fullWidth:!0}),t(b,{className:l.field,value:h,helperText:"Track name",slotProps:{htmlInput:{"data-testid":"graph-track-name-input"}},onChange:e=>{U(e.target.value)}}),t(v,{session:f,helperText:"Select assembly to add track to",selected:a.assembly,onChange:e=>{a.setAssembly(e)},fullWidth:!0}),t(E,{variant:"contained",className:l.submit,disabled:!i||!h.trim()||!a.assembly||Y,onClick:()=>{Z()},children:"Submit"})]})}),ue=ae;export{ue as default};
2
- //# sourceMappingURL=AddTrackWorkflow-Q6RY23LF.js.map
@@ -1,2 +0,0 @@
1
- import{a as q,b as re,c as de,d as oe,e as T}from"./chunk-SAMJE6GH.js";import{a as ne}from"./chunk-KOB7YIMR.js";import{a as Z,b as U,c as X,d as g,e as C,f as M,g as k,h as E,i as z,k as Y}from"./chunk-YJHYBDYF.js";import"./chunk-EWFJBQDV.js";import{a as O,b as H}from"./chunk-3Q4RBDCL.js";import"./chunk-AU73K7LX.js";import"./chunk-IXQK7JAW.js";import{a as ae}from"./chunk-TXI43PEN.js";import{a as ee,c as L,f as te}from"./chunk-AMFIBQVR.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import{e as A,f as P,g as B}from"./chunk-446RWIA3.js";import"./chunk-E7J6SB5P.js";import{b as G,e as J,f as K,g as V}from"./chunk-5OI6LO4I.js";import"./chunk-7WIBGKBU.js";import{a as N}from"./chunk-OGQ6OQDN.js";import"./chunk-NDRLCGPC.js";import{e as W,o as $}from"./chunk-TENPGIPX.js";function F(n){let i=/\.gbz\.db$/i;return i.test(n)?n.replace(i,".haplotype-index.db"):void 0}function fe(n){return K(n)&&F(J(n))?V(n,i=>F(i)):void 0}function he(n){return n instanceof Error&&(/\bHTTP 40[34]\b/.test(n.message)||n.code==="ENOENT")}async function se(n,i){let t=fe(n);if(!t)return{};try{return await N(t,i).stat(),{location:t}}catch(e){return he(e)?{}:{unreadable:String(e)}}}var ge=5e3,ue=50*2**20,_=class extends Error{constructor(t){super(`this GAF is ${(t/2**20).toFixed(0)} MB without an index; bgzip it and index it with tabix -p gaf`);this.name="UnindexedGafTooLargeError"}};function ye(n,i){if(n.length<=i)return n;let t=n.length/i;return Array.from({length:i},(e,a)=>n[Math.floor(a*t)])}var ie=(n,i)=>n.path.some(t=>i.has(t.name)),v=class{constructor(i,t){this.file=i;this.tabix=t;this.whole=L({setup:async({signal:i})=>{let{size:t}=await this.file.stat();if(t>ue)throw new _(t);let e=await this.file.readFile({signal:i}),a=new TextDecoder().decode(e[0]===31&&e[1]===139?await ee(e):e);return H(a)}})}async readIndexed(i,t,e){let a=1/0,r=-1/0;for(let c of t){let s=Number(c);Number.isInteger(s)&&(a=Math.min(a,s),r=Math.max(r,s))}let o=[];return a<=r&&await i.getLines("{node}",a,r+1,{signal:e,lineCallback:c=>{let s=O(c);s&&ie(s,t)&&o.push(s)}}),o}async readsOver(i,{signal:t}={}){let e=this.tabix?await this.readIndexed(this.tabix,i,t):(await this.whole({signal:t})).filter(a=>ie(a,i));return{records:ye(e,ge),total:e.length}}};var I=class extends Error{constructor(t){super(t===void 0?"no haplotype index is set, so the walks cannot be named; build one with gbz-haplotype-index (cargo install gbz-haplotype-index) and set it as haplotypeIndexLocation":`the haplotype index beside the graph database could not be checked (${t}), so the walks cannot be named; if it is there, reload to try again, or set haplotypeIndexLocation`);this.name="NoHaplotypeIndexError"}},D=class extends Error{constructor(t,e){super(`the graph is cut on its reference, ${e}; a window on ${t} has no reference coordinates to cut at. Open the graph from a ${e} view, and find this haplotype's lane there`);this.name="HaplotypeWindowError"}};function be(n,i){return`${g(n)}#${n.contig}@${i.start.node}.${i.start.offset}`}function we({alignment:n,assemblyName:i,refName:t,lane:e}){let{refStart:a,refEnd:r,strand:o,cigar:c}=n;if(!(r<=a)){let{name:s,hapStart:p,hapEnd:l}=n,f=be(s,n),u={uniqueId:f,assemblyName:i,refName:t,start:a,end:r,type:"match",strand:o==="-"?-1:1,CIGAR:c,syntenyId:f,mate:{refName:s.contig,start:p,end:l,assemblyName:e}};return new q(u)}}function xe({pair:n,lane:i,mateLane:t}){let e=`${g(n.target)}#${n.target.contig}:${n.targetStart}-${n.targetEnd}|${g(n.query)}#${n.query.contig}:${n.queryStart}-${n.queryEnd}`;return new q({uniqueId:e,assemblyName:i,refName:n.target.contig,start:n.targetStart,end:n.targetEnd,type:"match",strand:n.strand==="-"?-1:1,CIGAR:n.cigar,syntenyId:e,identity:n.matches/Math.max(n.columns,1),numMatches:n.matches,blockLen:n.columns,mate:{refName:n.query.contig,start:n.queryStart,end:n.queryEnd,assemblyName:t}})}var Se=12e4;function Pe(n,i){let t=new Map;for(let a of n)for(let{name:r,start:o,end:c}of a.walkSpans()){let s=g(r);if(i.has(s)){let p=`${s}#${r.contig}`,l=t.get(p);l?l.push([o,c]):t.set(p,[[o,c]])}}let e=0;for(let a of t.values()){a.sort((r,o)=>r[0]-o[0]);for(let r=1;r<a.length;r++){let o=a[r][0]-a[r-1][1];o>0&&o<=Se&&(e=Math.max(e,o))}}return e}function Q(n,i){return n instanceof X&&(n.message=`Zoom in to about ${W(n.fitsBp)} to see ${i}`),n}var ce=n=>({...n,start:Math.floor(n.start),end:Math.ceil(n.end)}),j=class extends re{constructor(){super(...arguments);this.graph=L({label:"Opening pangenome database",setup:async()=>{let t=this.getConf("gbzDbLocation"),e=this.getConf("haplotypeIndexLocation"),a=G(e)?{location:e}:await se(t,this.pluginManager),r=a.location,o=await U.open({source:N(t,this.pluginManager),haplotypeIndex:r?N(r,this.pluginManager):void 0}),c=this.getConf("assemblyNames")[0];if(c===void 0)throw new Error("GbzBaseSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as");let s=await M(o),p=k({configured:this.getConf("referenceSample"),anchorPrefix:P(this,c),referenceSamples:s});return{db:o,anchor:c,referenceSample:p,referenceSamples:s,unreadableIndex:a.unreadable}}});this.gaf=L({label:"Opening reads",setup:async()=>{let t=this.getConf("readsLocation"),e=this.getConf(["readsIndex","location"]);return G(t)?new v(N(t,this.pluginManager),G(e)?te(this,["readsLocation"],["readsIndex"]):void 0):void 0}})}async referenceQuery(t,e){let{db:a,referenceSample:r}=await this.graph(e);return E(a,r,t)}async getHaplotypes(t={}){let{db:e,referenceSamples:a}=await this.graph(t),r=new Map;for(let o of await e.paths()){let c=g(o.name),s=r.get(c);s?s.contigs.includes(o.name.contig)||s.contigs.push(o.name.contig):r.set(c,{prefix:c,sample:o.name.sample,haplotype:o.name.haplotype,contigs:[o.name.contig],isReference:a.includes(o.name.sample)})}return[...r.values()]}async getHeader(t={}){let{anchor:e,referenceSample:a,referenceSamples:r}=await this.graph(t),o=B(this),c=[];for(let s of await this.getHaplotypes(t))s.sample!==a&&c.push({name:T(o,s.prefix),label:s.prefix,group:s.sample});return{hasCoarseTier:!1,anchorAssemblyName:e,referenceSample:a,referenceSamples:r,lanes:c}}async getRefNames(t={}){let{db:e,anchor:a,referenceSample:r}=await this.graph(t),{assemblyName:o}=t,c=o===a?void 0:P(this,o),s=(await e.paths()).filter(p=>o===a?p.isIndexed&&p.name.sample===r:A(g(p.name),c)).map(p=>p.name.contig);return[...new Set(s)]}keepPredicate(t,e){let a=t===void 0||t.length===0?void 0:t.map(r=>P(this,r));return a===void 0&&e===void 0?void 0:r=>C(r,a)&&(e===void 0||A(g(r),e))}async getSubgraph(t,e={}){let{signal:a}=e,{db:r,anchor:o,referenceSample:c,unreadableIndex:s}=await this.graph({signal:a}),{assemblyName:p,refName:l,start:f,end:u}=ce(t);if(p!==o)throw new D(p,o);let y=await this.referenceQuery(l,{signal:a});if(!y)throw new Error(`${c} has no indexed path ${l} in this graph`);let x=this.keepPredicate(e.haplotypes);if(x!==void 0&&!r.hasHaplotypeIndex)throw new I(s);let m=await Y(r,y,f,u,{context:this.getConf("context"),snarls:e.snarls??this.getConf("subgraphSnarls"),limit:this.getConf("nodeLimit"),signal:e.signal,keep:x}).catch(b=>{throw Q(b,"the graph")});return typeof m=="string"?m:ae(m,{start:f,end:u},e.walkRows)}async getReads(t,e={}){let a=await this.gaf(e);return a?a.readsOver(new Set(t),e):{records:[],total:0}}async laneHaplotypes(t,e){let a=P(this,t);return(await this.getHaplotypes(e)).filter(r=>A(r.prefix,a))}async anchorFeatures(t,e){let{db:a}=await this.graph(e),{assemblyName:r,refName:o,start:c,end:s}=t,p=P(this,e.targetAssemblyName),l=B(this),f=this.keepPredicate(e.haplotypes,p),u=await this.referenceQuery(o,e),y=this.getConf("nodeLimit");return(u?await $(`Reading graph ${o}:${c.toLocaleString()}-${s.toLocaleString()}`,e.statusCallback,()=>a.getAlignments({path:u,start:c,end:s,context:this.getConf("context"),haplotypes:"all",limit:y,signal:e.signal,keep:f}).catch(m=>{throw Q(z(m,y,s-c)??m,"lanes")})):[]).flatMap(m=>{let b=m.resolved?we({alignment:m,assemblyName:r,refName:o,lane:T(l,g(m.name))}):void 0;return b===void 0?[]:[b]})}async pairFeatures(t,e,a){let{db:r}=await this.graph(a),{refName:o,start:c,end:s}=t,l=(await Promise.all(e.map(async d=>({pair:d,featureSide:await this.laneHaplotypes(d.queryAssemblyName,a),mateSide:await this.laneHaplotypes(d.targetAssemblyName,a)})))).filter(({featureSide:d,mateSide:h})=>d.length>0&&h.length>0),f=new Set(l.flatMap(({featureSide:d,mateSide:h})=>[...d,...h].map(g))),u=await this.referenceQuery(o,a),y=this.getConf("nodeLimit"),x=this.getConf("context"),[m]=e,b=(d,h)=>r.getSubgraphs({path:d,start:c,end:s,context:h,snarls:this.getConf("subgraphSnarls"),haplotypes:"all",limit:y,signal:a.signal,keep:S=>f.has(g(S))}),pe=async d=>{let h=await b(d,x).catch(w=>{throw Q(z(w,y,s-c)??w,"lanes")}),S=Pe(h,f),R=Math.ceil(S/2)+2e3;return S>0&&R>x?b(d,R).catch(w=>{if(w instanceof Z)return h;throw w}):h};return(u&&m&&l.length>0?await $(e.length===1?`Reading ${m.queryAssemblyName} against ${m.targetAssemblyName}`:`Reading ${e.length} lane pairs`,a.statusCallback,()=>pe(u)):[]).flatMap(d=>l.flatMap(({pair:h,featureSide:S,mateSide:R})=>S.flatMap(w=>R.flatMap(le=>d.pairAlignments({target:w,query:le,bases:!1}).map(me=>xe({pair:me,lane:h.queryAssemblyName,mateLane:h.targetAssemblyName}))))))}getFeatures(t,e={}){let a=ce(t);return ne(async r=>{let{db:o,anchor:c,unreadableIndex:s}=await this.graph(e);if(!o.hasHaplotypeIndex)throw new I(s);if(a.assemblyName===c){let p=oe(e),l=p.length>0?await this.pairFeatures(a,p,e):await this.anchorFeatures(a,e);for(let f of l)r.next(f)}r.complete()},e.signal)}};export{D as HaplotypeWindowError,I as NoHaplotypeIndexError,de as PairTargetError,j as default,we as fragmentFeature,xe as pairFeature,Pe as widestWalkGap};
2
- //# sourceMappingURL=GbzBaseSyntenyAdapter-TIXR4Y3J.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../node_modules/.pnpm/@jbrowse+bandage-core@10.2.4/node_modules/@jbrowse/bandage-core/dist/chunks/chunk-VQWHMWLF.js", "../../src/GbzBaseSyntenyAdapter/companion.ts", "../../src/gaf/gafFile.ts", "../../src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.ts"],
4
- "sourcesContent": ["import {\n GBZ_CUT_DEFAULTS,\n cutWindowGFA,\n haplotypeWanted,\n referencePathQuery,\n referenceSamplesOf,\n resolveReferenceSample\n} from \"./chunk-Q7LYHGGQ.js\";\n\n// src/gbzCut.ts\nimport { GBZBase } from \"@gmod/gbz-base\";\nvar HPRC_GBZ = {\n db: \"https://s3-us-west-2.amazonaws.com/human-pangenomics/pangenomes/freeze/release2/minigraph-cactus/v2.1/hprc-v2.1-mc-grch38/hprc-v2.1-mc-grch38.gbz.db\",\n index: \"https://jbrowse.org/demos/hprc/hprc-v2.1-mc-grch38.haplotype-index.f3.db\"\n};\nfunction haplotypeIndexBeside(db) {\n const GBZ_DB = /\\.gbz\\.db$/i;\n return GBZ_DB.test(db) ? db.replace(GBZ_DB, \".haplotype-index.db\") : void 0;\n}\nfunction parseRegion(text) {\n const m = /^\\s*([^:\\s]+):([\\d,]+)-([\\d,]+)\\s*$/.exec(text);\n if (!m) {\n throw new Error(\n `\"${text}\" is not a region like chr6:160,614,798-160,647,758`\n );\n }\n const n = (s) => Number(s.replaceAll(\",\", \"\"));\n const region = { refName: m[1], start: n(m[2]), end: n(m[3]) };\n if (region.end <= region.start) {\n throw new Error(`\"${text}\" ends at or before it starts`);\n }\n return region;\n}\nasync function openGbz(db, index) {\n const base = await GBZBase.open({ source: db, haplotypeIndex: index });\n return { base, referenceSamples: await referenceSamplesOf(base) };\n}\nfunction referenceSample(ref, samples) {\n try {\n return resolveReferenceSample({\n configured: \"\",\n anchorPrefix: ref ?? samples[0] ?? \"\",\n referenceSamples: samples\n });\n } catch (e) {\n if (ref) {\n return ref;\n }\n throw e;\n }\n}\nasync function cutGbzRegion({ base, referenceSamples }, src, signal) {\n const region = parseRegion(src.region);\n const sample = referenceSample(src.referenceSample, referenceSamples);\n const query = await referencePathQuery(base, sample, region.refName);\n if (!query) {\n throw new Error(`${sample} has no indexed path named ${region.refName}`);\n }\n signal?.throwIfAborted();\n const wanted = src.haplotypes?.length ? src.haplotypes : void 0;\n const text = await cutWindowGFA(base, query, region.start, region.end, {\n context: src.context ?? GBZ_CUT_DEFAULTS.context,\n snarls: src.snarls ?? GBZ_CUT_DEFAULTS.snarls,\n limit: GBZ_CUT_DEFAULTS.limit,\n signal,\n keep: wanted ? (name) => haplotypeWanted(name, wanted) : void 0\n });\n return { text, region, sample };\n}\n\nexport {\n HPRC_GBZ,\n haplotypeIndexBeside,\n parseRegion,\n openGbz,\n cutGbzRegion\n};\n", "import { haplotypeIndexBeside } from '@jbrowse/bandage-core/gbzCut'\nimport { openLocation } from '@jbrowse/core/util/io'\n\nimport { locationName, readsSiblings, renamed } from '../locationName'\n\nimport type PluginManager from '@jbrowse/core/PluginManager'\nimport type { FileLocation } from '@jbrowse/core/util/types'\n\nexport function siblingCompanion(gbzDb: FileLocation) {\n return readsSiblings(gbzDb) && haplotypeIndexBeside(locationName(gbzDb))\n ? renamed(gbzDb, name => haplotypeIndexBeside(name)!)\n : undefined\n}\n\n// 404 is a missing file, and so is 403 from a bucket that does not let a\n// reader list it; anything else leaves the file's presence unknown\nfunction isMissing(error: unknown) {\n return (\n error instanceof Error &&\n (/\\bHTTP 40[34]\\b/.test(error.message) ||\n (error as { code?: unknown }).code === 'ENOENT')\n )\n}\n\n// `unreadable` is why a companion that may be there could not be checked, such\n// as a network error, or a server that answers a missing file without CORS\nexport async function findCompanion(\n gbzDb: FileLocation,\n pluginManager?: PluginManager,\n): Promise<{ location?: FileLocation; unreadable?: string }> {\n const candidate = siblingCompanion(gbzDb)\n if (!candidate) {\n return {}\n }\n try {\n await openLocation(candidate, pluginManager).stat()\n return { location: candidate }\n } catch (error) {\n return isMissing(error) ? {} : { unreadable: String(error) }\n }\n}\n", "import { unzip } from '@gmod/bgzf-filehandle'\nimport { parseGaf, parseGafLine } from '@jbrowse/bandage-core/gaf/parseGaf'\nimport { cachedSetup } from '@jbrowse/core/data_adapters/BaseAdapter'\n\nimport type { TabixIndexedFile } from '@gmod/tabix'\nimport type { GafRecord } from '@jbrowse/bandage-core/gaf/parseGaf'\n\ninterface WholeFile {\n stat(): Promise<{ size: number }>\n readFile(opts?: { signal?: AbortSignal }): Promise<Uint8Array>\n}\n\nexport interface GafReads {\n records: GafRecord[]\n // reads over the nodes before sampling\n total: number\n}\n\n// The tube map lays reads out on the main thread at about 40 ms per thousand\nexport const MAX_READS = 5000\n\n// An unindexed GAF is read whole, once, into the worker\nconst MAX_UNINDEXED_BYTES = 50 * 2 ** 20\n\nexport class UnindexedGafTooLargeError extends Error {\n override name = 'UnindexedGafTooLargeError'\n\n constructor(size: number) {\n super(\n `this GAF is ${(size / 2 ** 20).toFixed(0)} MB without an index; bgzip it and index it with tabix -p gaf`,\n )\n }\n}\n\n// Evenly spaced, so a pileup thins out rather than losing its right half\nfunction sample(records: GafRecord[], max: number) {\n if (records.length <= max) {\n return records\n }\n const stride = records.length / max\n return Array.from({ length: max }, (_, k) => records[Math.floor(k * stride)]!)\n}\n\nconst touches = (record: GafRecord, names: ReadonlySet<string>) =>\n record.path.some(step => names.has(step.name))\n\n// A GAF over a graph's segments: bgzipped and indexed with `tabix -p gaf`,\n// which keys each line by its lowest and highest node id and so needs numeric\n// segment names, or plain or gzipped and read whole.\nexport class GafFile {\n // Shared by every window, so the signal is cachedSetup's own, which aborts\n // once no caller is left waiting\n private whole = cachedSetup({\n setup: async ({ signal }) => {\n const { size } = await this.file.stat()\n if (size > MAX_UNINDEXED_BYTES) {\n throw new UnindexedGafTooLargeError(size)\n }\n const bytes = await this.file.readFile({ signal })\n const text = new TextDecoder().decode(\n bytes[0] === 0x1f && bytes[1] === 0x8b ? await unzip(bytes) : bytes,\n )\n return parseGaf(text)\n },\n })\n\n constructor(\n private file: WholeFile,\n private tabix?: TabixIndexedFile,\n ) {}\n\n private async readIndexed(\n tabix: TabixIndexedFile,\n names: ReadonlySet<string>,\n signal?: AbortSignal,\n ) {\n let lo = Infinity\n let hi = -Infinity\n for (const name of names) {\n const id = Number(name)\n if (Number.isInteger(id)) {\n lo = Math.min(lo, id)\n hi = Math.max(hi, id)\n }\n }\n const records: GafRecord[] = []\n if (lo <= hi) {\n // a GAF index ignores the refName, and getLines keeps a read whose node\n // ids span min..max when min < end && max >= start, hence hi + 1\n await tabix.getLines('{node}', lo, hi + 1, {\n signal,\n lineCallback: line => {\n const record = parseGafLine(line)\n if (record && touches(record, names)) {\n records.push(record)\n }\n },\n })\n }\n return records\n }\n\n async readsOver(\n names: ReadonlySet<string>,\n { signal }: { signal?: AbortSignal } = {},\n ): Promise<GafReads> {\n const records = this.tabix\n ? await this.readIndexed(this.tabix, names, signal)\n : (await this.whole({ signal })).filter(r => touches(r, names))\n return { records: sample(records, MAX_READS), total: records.length }\n }\n}\n", "import { GBZBase, SubgraphLimitError } from '@gmod/gbz-base'\nimport {\n NodeLimitError,\n cutWindowTables,\n haplotypePrefix,\n haplotypeWanted,\n nodeLimitError,\n referencePathQuery,\n referenceSamplesOf,\n resolveReferenceSample,\n} from '@jbrowse/bandage-core/gbzWindow'\nimport {\n assemblyByPanSNPrefix,\n panSNMatchesPrefix,\n resolvePanSNPrefix,\n} from '@jbrowse/bandage-core/pansn'\nimport { cachedSetup } from '@jbrowse/core/data_adapters/BaseAdapter'\nimport { getBpDisplayStr, updateStatus } from '@jbrowse/core/util'\nimport { openLocation } from '@jbrowse/core/util/io'\nimport { ObservableCreate } from '@jbrowse/core/util/rxjs'\n\nimport { findCompanion } from './companion.ts'\nimport { walkCutFor } from '../RgfaTabixAdapter/walkRowRuns.ts'\nimport { GafFile } from '../gaf/gafFile.ts'\nimport { locationIsSet } from '../locationName.ts'\nimport { openTabixSlot } from '../panSNTabix.ts'\nimport { ComparativeAdapterBase } from '../synteny/ComparativeAdapterBase.ts'\nimport SyntenyFeature from '../synteny/SyntenyFeature.ts'\nimport { laneAssemblyName, requestedPairs } from '../synteny/lanePairs.ts'\n\nimport type { GbzBaseSyntenyAdapterConfig } from './configSchema.ts'\nimport type { SubgraphAdapterOptions } from '../GetSubgraph.ts'\nimport type { GafReads } from '../gaf/gafFile.ts'\nimport type { LaneFeatureOptions, LanePair } from '../synteny/lanePairs.ts'\nimport type {\n HaplotypeAlignment,\n HaplotypeRef,\n PairAlignment,\n PathName,\n PathQuery,\n Subgraph,\n} from '@gmod/gbz-base'\nimport type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter'\nimport type { Feature, SimpleFeatureSerialized } from '@jbrowse/core/util'\nimport type { FileLocation, Region } from '@jbrowse/core/util/types'\n\nexport class NoHaplotypeIndexError extends Error {\n override name = 'NoHaplotypeIndexError'\n\n constructor(unreadable?: string) {\n super(\n unreadable === undefined\n ? 'no haplotype index is set, so the walks cannot be named; build one with gbz-haplotype-index (cargo install gbz-haplotype-index) and set it as haplotypeIndexLocation'\n : `the haplotype index beside the graph database could not be checked (${unreadable}), so the walks cannot be named; if it is there, reload to try again, or set haplotypeIndexLocation`,\n )\n }\n}\n\nexport interface GbzHaplotype {\n prefix: string\n sample: string\n haplotype: number\n contigs: string[]\n isReference: boolean\n}\n\n/**\n * One lane the header declares, in the shape MultiWaySyntenyDisplay's lane\n * picker reads: `name` is the lane's assembly name, the same string the\n * fetched features' mates carry, `label` its PanSN prefix and `group` its\n * sample, so a diploid sample's two lanes sit together\n */\ninterface GbzHeaderLane {\n name: string\n label: string\n group: string\n}\n\nexport { PairTargetError } from '../synteny/lanePairs.ts'\nexport type { LanePair } from '../synteny/lanePairs.ts'\n\nexport class HaplotypeWindowError extends Error {\n override name = 'HaplotypeWindowError'\n\n constructor(assemblyName: string, anchor: string) {\n super(\n `the graph is cut on its reference, ${anchor}; a window on ${assemblyName} has no reference coordinates to cut at. Open the graph from a ${anchor} view, and find this haplotype's lane there`,\n )\n }\n}\n\ntype ResolvedAlignment = Extract<HaplotypeAlignment, { resolved: true }>\n\n/**\n * The id of one haplotype fragment: the walk's GBWT position at its first node\n * in the window, which is a property of the graph, so the same fragment gets\n * the same id on a refetch of the same window and the display's hover and\n * selection survive it. `clipToRegion` suffixes the window.\n */\nfunction fragmentId(name: PathName, alignment: ResolvedAlignment) {\n return `${haplotypePrefix(name)}#${name.contig}@${alignment.start.node}.${alignment.start.offset}`\n}\n\nexport function fragmentFeature({\n alignment,\n assemblyName,\n refName,\n lane,\n}: {\n alignment: ResolvedAlignment\n assemblyName: string\n refName: string\n lane: string\n}) {\n const { refStart, refEnd, strand, cigar } = alignment\n if (refEnd <= refStart) {\n return undefined\n } else {\n const { name, hapStart, hapEnd } = alignment\n const id = fragmentId(name, alignment)\n const data: SimpleFeatureSerialized = {\n uniqueId: id,\n assemblyName,\n refName,\n start: refStart,\n end: refEnd,\n type: 'match',\n strand: strand === '-' ? -1 : 1,\n CIGAR: cigar,\n syntenyId: id,\n mate: {\n refName: name.contig,\n start: hapStart,\n end: hapEnd,\n assemblyName: lane,\n },\n }\n return new SyntenyFeature(data)\n }\n}\n\n/**\n * One record of a lane pair, on the target walk's own contig with the query\n * walk as its mate. gbz-base writes the CIGAR along the target, a `D` being\n * target bases the query lacks, which is the side a JBrowse feature is, so it\n * passes through unchanged.\n */\nexport function pairFeature({\n pair,\n lane,\n mateLane,\n}: {\n pair: PairAlignment\n lane: string\n mateLane: string\n}) {\n const id = `${haplotypePrefix(pair.target)}#${pair.target.contig}:${pair.targetStart}-${pair.targetEnd}|${haplotypePrefix(pair.query)}#${pair.query.contig}:${pair.queryStart}-${pair.queryEnd}`\n return new SyntenyFeature({\n uniqueId: id,\n assemblyName: lane,\n refName: pair.target.contig,\n start: pair.targetStart,\n end: pair.targetEnd,\n type: 'match',\n strand: pair.strand === '-' ? -1 : 1,\n CIGAR: pair.cigar,\n syntenyId: id,\n identity: pair.matches / Math.max(pair.columns, 1),\n numMatches: pair.matches,\n blockLen: pair.columns,\n mate: {\n refName: pair.query.contig,\n start: pair.queryStart,\n end: pair.queryEnd,\n assemblyName: mateLane,\n },\n })\n}\n\n// The longest detour a pair cut widens its context to take in\nconst BRIDGE_MAX_BP = 120_000\n\n/**\n * The widest gap, up to `BRIDGE_MAX_BP`, between two pieces of one kept walk:\n * a haplotype that left the cut's nodes for sequence the reference lacks and\n * came back. Two kept haplotypes that share that sequence only align across it\n * once its nodes are in the cut.\n */\nexport function widestWalkGap(subgraphs: Subgraph[], kept: Set<string>) {\n const byPath = new Map<string, [number, number][]>()\n for (const subgraph of subgraphs) {\n for (const { name, start, end } of subgraph.walkSpans()) {\n const prefix = haplotypePrefix(name)\n if (kept.has(prefix)) {\n const key = `${prefix}#${name.contig}`\n const spans = byPath.get(key)\n if (spans) {\n spans.push([start, end])\n } else {\n byPath.set(key, [[start, end]])\n }\n }\n }\n }\n let widest = 0\n for (const spans of byPath.values()) {\n spans.sort((a, b) => a[0] - b[0])\n for (let i = 1; i < spans.length; i++) {\n const gap = spans[i]![0] - spans[i - 1]![1]\n if (gap > 0 && gap <= BRIDGE_MAX_BP) {\n widest = Math.max(widest, gap)\n }\n }\n }\n return widest\n}\n\n// A window past the node limit fails as a zoom-in notice naming a span that\n// fits\nfunction zoomInNotice(error: unknown, what: string) {\n if (error instanceof NodeLimitError) {\n error.message = `Zoom in to about ${getBpDisplayStr(error.fitsBp)} to see ${what}`\n }\n return error\n}\n\n// gbz-base reads whole bp; a view asks at fractional ones\nconst wholeBp = (region: Region) => ({\n ...region,\n start: Math.floor(region.start),\n end: Math.ceil(region.end),\n})\n\nexport default class GbzBaseSyntenyAdapter extends ComparativeAdapterBase<GbzBaseSyntenyAdapterConfig> {\n private graph = cachedSetup({\n label: 'Opening pangenome database',\n setup: async () => {\n const gbzDb: FileLocation = this.getConf('gbzDbLocation')\n const configured: FileLocation = this.getConf('haplotypeIndexLocation')\n const companion = locationIsSet(configured)\n ? { location: configured }\n : await findCompanion(gbzDb, this.pluginManager)\n const indexLocation = companion.location\n const db = await GBZBase.open({\n source: openLocation(gbzDb, this.pluginManager),\n haplotypeIndex: indexLocation\n ? openLocation(indexLocation, this.pluginManager)\n : undefined,\n })\n const anchor = this.getConf('assemblyNames')[0]\n if (anchor === undefined) {\n throw new Error(\n 'GbzBaseSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as',\n )\n }\n const referenceSamples = await referenceSamplesOf(db)\n const referenceSample = resolveReferenceSample({\n configured: this.getConf('referenceSample'),\n anchorPrefix: resolvePanSNPrefix(this, anchor),\n referenceSamples,\n })\n return {\n db,\n anchor,\n referenceSample,\n referenceSamples,\n unreadableIndex: companion.unreadable,\n }\n },\n })\n\n /**\n * The indexed reference path a window on `refName` resolves against, or\n * undefined when the reference sample has no indexed path by that contig.\n */\n private async referenceQuery(\n refName: string,\n opts: BaseOptions,\n ): Promise<PathQuery | undefined> {\n const { db, referenceSample } = await this.graph(opts)\n return referencePathQuery(db, referenceSample, refName)\n }\n\n /**\n * Every haplotype the graph carries a walk for, `sample#haplotype` with its\n * contigs, from the Paths scan the adapter already makes; the lane picker's\n * source list. Reference samples are included and flagged.\n */\n async getHaplotypes(opts: BaseOptions = {}): Promise<GbzHaplotype[]> {\n const { db, referenceSamples } = await this.graph(opts)\n const byPrefix = new Map<string, GbzHaplotype>()\n for (const path of await db.paths()) {\n const prefix = haplotypePrefix(path.name)\n const entry = byPrefix.get(prefix)\n if (entry) {\n if (!entry.contigs.includes(path.name.contig)) {\n entry.contigs.push(path.name.contig)\n }\n } else {\n byPrefix.set(prefix, {\n prefix,\n sample: path.name.sample,\n haplotype: path.name.haplotype,\n contigs: [path.name.contig],\n isReference: referenceSamples.includes(path.name.sample),\n })\n }\n }\n return [...byPrefix.values()]\n }\n\n /**\n * `lanes` is every haplotype but the reference sample's own, which is the\n * anchor rather than a lane, declared up front so the display can offer the\n * whole graph's haplotypes before a fetch has placed any of them.\n */\n async getHeader(opts: BaseOptions = {}) {\n const { anchor, referenceSample, referenceSamples } = await this.graph(opts)\n const asmByPrefix = assemblyByPanSNPrefix(this)\n const lanes: GbzHeaderLane[] = []\n for (const haplotype of await this.getHaplotypes(opts)) {\n if (haplotype.sample !== referenceSample) {\n lanes.push({\n name: laneAssemblyName(asmByPrefix, haplotype.prefix),\n label: haplotype.prefix,\n group: haplotype.sample,\n })\n }\n }\n return {\n hasCoarseTier: false,\n anchorAssemblyName: anchor,\n referenceSample,\n referenceSamples,\n lanes,\n }\n }\n\n async getRefNames(opts: BaseOptions = {}) {\n const { db, anchor, referenceSample } = await this.graph(opts)\n const { assemblyName } = opts\n const prefix =\n assemblyName === anchor\n ? undefined\n : resolvePanSNPrefix(this, assemblyName)\n const contigs = (await db.paths())\n .filter(path =>\n assemblyName === anchor\n ? path.isIndexed && path.name.sample === referenceSample\n : panSNMatchesPrefix(haplotypePrefix(path.name), prefix),\n )\n .map(path => path.name.contig)\n return [...new Set(contigs)]\n }\n\n /**\n * The predicate gbz-base builds a window for, from the lanes a fetch asks\n * for. With a companion whose stray rows cover the window gbz-base walks\n * only the wanted haplotypes; otherwise it names every walk and keeps the\n * ones the predicate accepts, and throws rather than guess when a walk has\n * no name. Either way a cut holds those walks, the reference, and the nodes\n * they visit. Undefined when every haplotype is wanted.\n */\n //\n // `targetPrefix` is a pairwise view's one lane, and it belongs in here: left\n // to filter what came back, it handed gbz-base no predicate, and every\n // haplotype in the graph was walked for one to be kept.\n private keepPredicate(\n haplotypes: string[] | undefined,\n targetPrefix?: string,\n ) {\n const wantedPrefixes =\n haplotypes === undefined || haplotypes.length === 0\n ? undefined\n : haplotypes.map(lane => resolvePanSNPrefix(this, lane))\n return wantedPrefixes === undefined && targetPrefix === undefined\n ? undefined\n : (name: PathName) =>\n haplotypeWanted(name, wantedPrefixes) &&\n (targetPrefix === undefined ||\n panSNMatchesPrefix(haplotypePrefix(name), targetPrefix))\n }\n\n /**\n * The graph view's cut of the window, as tables: the reference walk, every\n * top-level snarl contained in it, and one walk per haplotype, PanSN-named\n * when the database (or its companion) carries the haplotype index and\n * `unknown#N` otherwise. The reference walk is the first, which is the one\n * the view anchors on by default. With `haplotypes` the walks are that\n * set's and the nodes those walks visit, the reference walk kept. With\n * `walkRows` the rows' runs come along, as on a walk-file cut.\n *\n * Only a window on the anchor can be cut: a haplotype lane's coordinates\n * are its own contig's, and the graph is indexed for random access on the\n * reference sample's paths alone.\n */\n async getSubgraph(region: Region, opts: SubgraphAdapterOptions = {}) {\n const { signal } = opts\n const { db, anchor, referenceSample, unreadableIndex } = await this.graph({\n signal,\n })\n const { assemblyName, refName, start, end } = wholeBp(region)\n if (assemblyName !== anchor) {\n throw new HaplotypeWindowError(assemblyName, anchor)\n }\n const query = await this.referenceQuery(refName, { signal })\n if (!query) {\n throw new Error(\n `${referenceSample} has no indexed path ${refName} in this graph`,\n )\n }\n const keep = this.keepPredicate(opts.haplotypes)\n if (keep !== undefined && !db.hasHaplotypeIndex) {\n throw new NoHaplotypeIndexError(unreadableIndex)\n }\n const cut = await cutWindowTables(db, query, start, end, {\n context: this.getConf('context'),\n snarls: opts.snarls ?? this.getConf('subgraphSnarls'),\n limit: this.getConf('nodeLimit'),\n signal: opts.signal,\n keep,\n }).catch((error: unknown) => {\n throw zoomInNotice(error, 'the graph')\n })\n return typeof cut === 'string'\n ? cut\n : walkCutFor(cut, { start, end }, opts.walkRows)\n }\n\n private gaf = cachedSetup({\n label: 'Opening reads',\n setup: async () => {\n const location: FileLocation = this.getConf('readsLocation')\n const index: FileLocation = this.getConf(['readsIndex', 'location'])\n return locationIsSet(location)\n ? new GafFile(\n openLocation(location, this.pluginManager),\n locationIsSet(index)\n ? openTabixSlot(this, ['readsLocation'], ['readsIndex'])\n : undefined,\n )\n : undefined\n },\n })\n\n /**\n * The reads over a cut's segments, from `readsLocation`, sampled down to\n * what the tube map lays out at interactive speed\n */\n async getReads(\n nodeNames: string[],\n opts: BaseOptions = {},\n ): Promise<GafReads> {\n const gaf = await this.gaf(opts)\n return gaf\n ? gaf.readsOver(new Set(nodeNames), opts)\n : { records: [], total: 0 }\n }\n\n private async laneHaplotypes(\n assemblyName: string,\n opts: BaseOptions,\n ): Promise<HaplotypeRef[]> {\n const prefix = resolvePanSNPrefix(this, assemblyName)\n return (await this.getHaplotypes(opts)).filter(haplotype =>\n panSNMatchesPrefix(haplotype.prefix, prefix),\n )\n }\n\n private async anchorFeatures(region: Region, opts: LaneFeatureOptions) {\n const { db } = await this.graph(opts)\n const { assemblyName, refName, start, end } = region\n const targetPrefix = resolvePanSNPrefix(this, opts.targetAssemblyName)\n const asmByPrefix = assemblyByPanSNPrefix(this)\n const keep = this.keepPredicate(opts.haplotypes, targetPrefix)\n const query = await this.referenceQuery(refName, opts)\n const nodeLimit: number = this.getConf('nodeLimit')\n const alignments = query\n ? await updateStatus(\n `Reading graph ${refName}:${start.toLocaleString()}-${end.toLocaleString()}`,\n opts.statusCallback,\n () =>\n db\n .getAlignments({\n path: query,\n start,\n end,\n context: this.getConf('context'),\n haplotypes: 'all',\n limit: nodeLimit,\n signal: opts.signal,\n keep,\n })\n .catch((error: unknown) => {\n throw zoomInNotice(\n nodeLimitError(error, nodeLimit, end - start) ?? error,\n 'lanes',\n )\n }),\n )\n : []\n return alignments.flatMap(alignment => {\n const feature = alignment.resolved\n ? fragmentFeature({\n alignment,\n assemblyName,\n refName,\n lane: laneAssemblyName(\n asmByPrefix,\n haplotypePrefix(alignment.name),\n ),\n })\n : undefined\n return feature === undefined ? [] : [feature]\n })\n }\n\n /**\n * Each pair's two lanes cut out of the anchor window alone, all pairs in one\n * cut, and each walk of a pair's query lane aligned to each walk of its\n * target lane on the nodes both visit, with no base compared. A pair's\n * records sit on its query lane's contigs, the lane the display draws on top.\n *\n * Whether the index has anchor rows changes only how fast gbz-base finds\n * the walks: both routes cut the same pieces.\n */\n private async pairFeatures(\n region: Region,\n pairs: LanePair[],\n opts: LaneFeatureOptions,\n ) {\n const { db } = await this.graph(opts)\n const { refName, start, end } = region\n const sides = await Promise.all(\n pairs.map(async pair => ({\n pair,\n featureSide: await this.laneHaplotypes(pair.queryAssemblyName, opts),\n mateSide: await this.laneHaplotypes(pair.targetAssemblyName, opts),\n })),\n )\n const answerable = sides.filter(\n ({ featureSide, mateSide }) =>\n featureSide.length > 0 && mateSide.length > 0,\n )\n const kept = new Set(\n answerable.flatMap(({ featureSide, mateSide }) =>\n [...featureSide, ...mateSide].map(haplotypePrefix),\n ),\n )\n const query = await this.referenceQuery(refName, opts)\n const nodeLimit: number = this.getConf('nodeLimit')\n const baseContext: number = this.getConf('context')\n const [first] = pairs\n const cut = (path: PathQuery, context: number) =>\n db.getSubgraphs({\n path,\n start,\n end,\n context,\n snarls: this.getConf('subgraphSnarls'),\n haplotypes: 'all',\n limit: nodeLimit,\n signal: opts.signal,\n keep: name => kept.has(haplotypePrefix(name)),\n })\n // a cut past the node limit for the wider context keeps the first one\n const bridged = async (path: PathQuery) => {\n const subgraphs = await cut(path, baseContext).catch((error: unknown) => {\n throw zoomInNotice(\n nodeLimitError(error, nodeLimit, end - start) ?? error,\n 'lanes',\n )\n })\n const gap = widestWalkGap(subgraphs, kept)\n const context = Math.ceil(gap / 2) + 2000\n return gap > 0 && context > baseContext\n ? cut(path, context).catch((error: unknown) => {\n if (error instanceof SubgraphLimitError) {\n return subgraphs\n }\n throw error\n })\n : subgraphs\n }\n const subgraphs =\n query && first && answerable.length > 0\n ? await updateStatus(\n pairs.length === 1\n ? `Reading ${first.queryAssemblyName} against ${first.targetAssemblyName}`\n : `Reading ${pairs.length} lane pairs`,\n opts.statusCallback,\n () => bridged(query),\n )\n : []\n return subgraphs.flatMap(subgraph =>\n answerable.flatMap(({ pair, featureSide, mateSide }) =>\n featureSide.flatMap(target =>\n mateSide.flatMap(mate =>\n subgraph\n .pairAlignments({ target, query: mate, bases: false })\n .map(alignment =>\n pairFeature({\n pair: alignment,\n lane: pair.queryAssemblyName,\n mateLane: pair.targetAssemblyName,\n }),\n ),\n ),\n ),\n ),\n )\n }\n\n getFeatures(asked: Region, opts: LaneFeatureOptions = {}) {\n const region = wholeBp(asked)\n return ObservableCreate<Feature>(async observer => {\n const { db, anchor, unreadableIndex } = await this.graph(opts)\n if (!db.hasHaplotypeIndex) {\n throw new NoHaplotypeIndexError(unreadableIndex)\n }\n // the graph is indexed on its reference alone, so a window on a\n // haplotype lane has no answer: a lane pair is read inside the anchor's\n if (region.assemblyName === anchor) {\n const pairs = requestedPairs(opts)\n const features =\n pairs.length > 0\n ? await this.pairFeatures(region, pairs, opts)\n : await this.anchorFeatures(region, opts)\n for (const feature of features) {\n observer.next(feature)\n }\n }\n observer.complete()\n }, opts.signal)\n }\n}\n"],
5
- "mappings": "ixBAeA,SAASA,EAAqBC,EAAI,CAChC,IAAMC,EAAS,cACf,OAAOA,EAAO,KAAKD,CAAE,EAAIA,EAAG,QAAQC,EAAQ,qBAAqB,EAAI,MACvE,CCVO,SAASC,GAAiBC,EAAqB,CACpD,OAAOC,EAAcD,CAAK,GAAKE,EAAqBC,EAAaH,CAAK,CAAC,EACnEI,EAAQJ,EAAOK,GAAQH,EAAqBG,CAAI,CAAE,EAClD,MACN,CAIA,SAASC,GAAUC,EAAgB,CACjC,OACEA,aAAiB,QAChB,kBAAkB,KAAKA,EAAM,OAAO,GAClCA,EAA6B,OAAS,SAE7C,CAIA,eAAsBC,GACpBR,EACAS,EAC2D,CAC3D,IAAMC,EAAYX,GAAiBC,CAAK,EACxC,GAAI,CAACU,EACH,MAAO,CAAC,EAEV,GAAI,CACF,aAAMC,EAAaD,EAAWD,CAAa,EAAE,KAAK,EAC3C,CAAE,SAAUC,CAAU,CAC/B,OAASH,EAAO,CACd,OAAOD,GAAUC,CAAK,EAAI,CAAC,EAAI,CAAE,WAAY,OAAOA,CAAK,CAAE,CAC7D,CACF,CCrBO,IAAMK,GAAY,IAGnBC,GAAsB,GAAK,GAAK,GAEzBC,EAAN,cAAwC,KAAM,CAGnD,YAAYC,EAAc,CACxB,MACE,gBAAgBA,EAAO,GAAK,IAAI,QAAQ,CAAC,CAAC,+DAC5C,EALF,KAAS,KAAO,2BAMhB,CACF,EAGA,SAASC,GAAOC,EAAsBC,EAAa,CACjD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,EAAQmD,EAAO7B,CAAI,EAC3C,MAAM,KAAK,eAAetB,EAAQsB,CAAI,EAC5C,QAAW4B,KAAWgB,EACpBF,EAAS,KAAKd,CAAO,CAEzB,CACAc,EAAS,SAAS,CACpB,EAAG1C,EAAK,MAAM,CAChB,CACF",
6
- "names": ["haplotypeIndexBeside", "db", "GBZ_DB", "siblingCompanion", "gbzDb", "readsSiblings", "haplotypeIndexBeside", "locationName", "renamed", "name", "isMissing", "error", "findCompanion", "pluginManager", "candidate", "openLocation", "MAX_READS", "MAX_UNINDEXED_BYTES", "UnindexedGafTooLargeError", "size", "sample", "records", "max", "stride", "_", "k", "touches", "record", "names", "step", "GafFile", "file", "tabix", "cachedSetup", "signal", "bytes", "text", "unzip", "parseGaf", "lo", "hi", "name", "id", "line", "parseGafLine", "r", "NoHaplotypeIndexError", "unreadable", "HaplotypeWindowError", "assemblyName", "anchor", "fragmentId", "name", "alignment", "haplotypePrefix", "fragmentFeature", "refName", "lane", "refStart", "refEnd", "strand", "cigar", "hapStart", "hapEnd", "id", "data", "SyntenyFeature", "pairFeature", "pair", "mateLane", "BRIDGE_MAX_BP", "widestWalkGap", "subgraphs", "kept", "byPath", "subgraph", "start", "end", "prefix", "key", "spans", "widest", "a", "b", "i", "gap", "zoomInNotice", "error", "what", "NodeLimitError", "getBpDisplayStr", "wholeBp", "region", "GbzBaseSyntenyAdapter", "ComparativeAdapterBase", "cachedSetup", "gbzDb", "configured", "companion", "locationIsSet", "findCompanion", "indexLocation", "db", "GBZBase", "openLocation", "referenceSamples", "referenceSamplesOf", "referenceSample", "resolveReferenceSample", "resolvePanSNPrefix", "location", "index", "GafFile", "openTabixSlot", "opts", "referencePathQuery", "byPrefix", "path", "entry", "asmByPrefix", "assemblyByPanSNPrefix", "lanes", "haplotype", "laneAssemblyName", "contigs", "panSNMatchesPrefix", "haplotypes", "targetPrefix", "wantedPrefixes", "haplotypeWanted", "signal", "unreadableIndex", "query", "keep", "cut", "cutWindowTables", "walkCutFor", "nodeNames", "gaf", "nodeLimit", "updateStatus", "nodeLimitError", "feature", "pairs", "answerable", "featureSide", "mateSide", "baseContext", "first", "context", "bridged", "SubgraphLimitError", "target", "mate", "asked", "ObservableCreate", "observer", "requestedPairs", "features"]
7
- }
@@ -1,6 +0,0 @@
1
- import{b as G}from"./chunk-J6NZIAZF.js";import{b as H,c as x}from"./chunk-E2QPSDQL.js";import{k as h}from"./chunk-YSTMDXXX.js";import"./chunk-MHPJB22Z.js";import"./chunk-AU73K7LX.js";import"./chunk-MVVXRZXV.js";import"./chunk-446RWIA3.js";import"./chunk-5OI6LO4I.js";import{g as u}from"./chunk-6OPB7FOJ.js";import{D as v,F as f,H as c,n as g,s as b,w as S,z as C}from"./chunk-E3WYW7Z6.js";import{b as a,c as l,d as i}from"./chunk-JMBDTNUR.js";var F=h()({section:{marginBottom:24},formControl:{minWidth:200}}),M=[{value:0,label:"None"},{value:1,label:"1 hop"},{value:2,label:"2 hops"}],I=i(function({model:t}){let{classes:e}=F();return t.adapterConfig.type==="RgfaTabixAdapter"&&!H(t.adapterConfig)?l("div",{className:e.section,children:[l(b,{className:e.formControl,children:[a(S,{children:"Graph context"}),a(v,{value:t.subgraphContext,label:"Graph context","data-testid":"graph-context-select",onChange:o=>{t.setSubgraphContext(o.target.value),t.cut()},children:M.map(({value:o,label:p})=>a(C,{value:o,children:p},o))})]}),a(c,{variant:"caption",component:"div",color:"text.secondary",children:"How far the cut follows links out of the region. At none, a detour that leaves the window draws as two stubs. No effect on gfa-to-tabix's default anchored index."})]}):null}),L=I;var N=h()({section:{marginBottom:24}});function P(n){let t=n.split(/[\s,]+/).map(e=>e.trim()).filter(e=>e!=="");return t.length===0?void 0:t}var T=i(function({model:t}){let[e,o]=u(t.cutHaplotypes?.join(", ")??""),p=()=>{let r=P(e)??[];r.join(`
2
- `)===(t.cutHaplotypes??[]).join(`
3
- `)||(t.setSubgraphHaplotypes(r),t.cut())};return a(f,{fullWidth:!0,label:"Haplotypes",placeholder:"every haplotype",value:e,slotProps:{htmlInput:{"data-testid":"graph-haplotypes-field"}},onChange:r=>{o(r.target.value)},onBlur:()=>{p()},onKeyDown:r=>{r.key==="Enter"&&p()}})}),w=i(function({model:t,names:e}){let[o,p]=u(t.cutHaplotypes??[]),[r,d]=u(!1),m=s=>{s.join(`
4
- `)!==(t.cutHaplotypes??[]).join(`
5
- `)&&(t.setSubgraphHaplotypes(s),t.cut())};return a(g,{multiple:!0,freeSolo:!0,disableCloseOnSelect:!0,options:e,value:o,open:r,onOpen:()=>{d(!0)},onClose:()=>{d(!1),m(o)},onChange:(s,y)=>{p(y),r||m(y)},renderInput:s=>a(f,{...s,label:"Haplotypes",placeholder:o.length===0?"every haplotype":void 0,slotProps:{...s.slotProps,htmlInput:{...s.slotProps.htmlInput,"data-testid":"graph-haplotypes-field"}}})})}),D=i(function({model:t}){let{classes:e}=N(),o=t.haplotypeNames,p=t.cutHaplotypes?.join(",")??"";return x(t.adapterConfig)?l("div",{className:e.section,children:[o?a(w,{model:t,names:o},p):a(T,{model:t},p),l(c,{variant:"caption",component:"div",color:"text.secondary",children:[o?`Which of the graph's ${o.length.toLocaleString()} haplotypes to cut, or a PanSN prefix (HG002 for both).`:"Which haplotypes to cut, as lane assembly names or PanSN prefixes (HG002#1, or HG002 for both) separated by commas."," ","Empty is every haplotype."]})]}):null}),k=D;function B({model:n,open:t,onClose:e}){return l(G,{model:n,open:t,onClose:e,children:[a(L,{model:n}),a(k,{model:n})]})}export{B as default};
6
- //# sourceMappingURL=GraphTrackSettingsDialog-TAM6PMXD.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/LinearGraphDisplay/components/SubgraphContextSelect.tsx", "../../src/LinearGraphDisplay/components/SubgraphHaplotypesField.tsx", "../../src/LinearGraphDisplay/components/GraphTrackSettingsDialog.tsx"],
4
- "sourcesContent": ["import {\n FormControl,\n InputLabel,\n MenuItem,\n Select,\n Typography,\n} from '@mui/material'\nimport { observer } from 'mobx-react'\nimport { makeStyles } from 'tss-react/mui'\n\nimport { walkIndexed } from '../../graphTrackConfig'\n\nimport type { LinearGraphCutModel } from '../model'\n\nconst useStyles = makeStyles()({\n section: {\n marginBottom: 24,\n },\n formControl: {\n minWidth: 200,\n },\n})\n\n// Only an rGFA cut from segment rows reads hops: a GBZ cut widens by its\n// adapter's bp `context`, and a walk-indexed cut follows its walks.\n// Hops past the region's own segments, each costing a tabix query per\n// off-reference segment already reached. One is the default: at none a single\n// detour draws as two unrelated stubs, which is a wrong picture of the graph\n// rather than a cheaper one. Two exists for a graph whose alleles have alleles\n// (HPRC's amylase window keeps growing at 2, the E. coli paa locus does not), and\n// it stops there because a frontier is still not a bubble decomposition. Cut an\n// exact slice with gfatools when that is what is wanted.\nconst SUBGRAPH_CONTEXTS = [\n { value: 0, label: 'None' },\n { value: 1, label: '1 hop' },\n { value: 2, label: '2 hops' },\n]\n\nconst SubgraphContextSelect = observer(function SubgraphContextSelect({\n model,\n}: {\n model: LinearGraphCutModel\n}) {\n const { classes } = useStyles()\n return model.adapterConfig.type === 'RgfaTabixAdapter' &&\n !walkIndexed(model.adapterConfig) ? (\n <div className={classes.section}>\n <FormControl className={classes.formControl}>\n <InputLabel>Graph context</InputLabel>\n <Select\n value={model.subgraphContext}\n label=\"Graph context\"\n data-testid=\"graph-context-select\"\n onChange={e => {\n model.setSubgraphContext(e.target.value)\n void model.cut()\n }}\n >\n {SUBGRAPH_CONTEXTS.map(({ value, label }) => (\n <MenuItem key={value} value={value}>\n {label}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n <Typography variant=\"caption\" component=\"div\" color=\"text.secondary\">\n How far the cut follows links out of the region. At none, a detour that\n leaves the window draws as two stubs. No effect on gfa-to-tabix&apos;s\n default anchored index.\n </Typography>\n </div>\n ) : null\n})\n\nexport default SubgraphContextSelect\n", "import { useState } from 'react'\n\nimport { Autocomplete, TextField, Typography } from '@mui/material'\nimport { observer } from 'mobx-react'\nimport { makeStyles } from 'tss-react/mui'\n\nimport { cutsByHaplotype } from '../../graphTrackConfig'\n\nimport type { LinearGraphCutModel } from '../model'\n\nconst useStyles = makeStyles()({\n section: {\n marginBottom: 24,\n },\n})\n\nexport function parseHaplotypeList(text: string) {\n const names = text\n .split(/[\\s,]+/)\n .map(name => name.trim())\n .filter(name => name !== '')\n return names.length === 0 ? undefined : names\n}\n\nconst HaplotypeListField = observer(function HaplotypeListField({\n model,\n}: {\n model: LinearGraphCutModel\n}) {\n const [draft, setDraft] = useState(model.cutHaplotypes?.join(', ') ?? '')\n const apply = () => {\n const parsed = parseHaplotypeList(draft) ?? []\n const unchanged =\n parsed.join('\\n') === (model.cutHaplotypes ?? []).join('\\n')\n if (!unchanged) {\n model.setSubgraphHaplotypes(parsed)\n void model.cut()\n }\n }\n return (\n <TextField\n fullWidth\n label=\"Haplotypes\"\n placeholder=\"every haplotype\"\n value={draft}\n slotProps={{ htmlInput: { 'data-testid': 'graph-haplotypes-field' } }}\n onChange={e => {\n setDraft(e.target.value)\n }}\n onBlur={() => {\n apply()\n }}\n onKeyDown={e => {\n if (e.key === 'Enter') {\n apply()\n }\n }}\n />\n )\n})\n\n// The haplotypes a walk-indexed graph's header names, searched as typed. A\n// typed prefix the list lacks (HG002 for both haplotypes) is kept too. The\n// set applies when the list closes or, with the list closed, as it changes.\nconst HaplotypePickField = observer(function HaplotypePickField({\n model,\n names,\n}: {\n model: LinearGraphCutModel\n names: string[]\n}) {\n const [draft, setDraft] = useState(model.cutHaplotypes ?? [])\n const [open, setOpen] = useState(false)\n const apply = (haplotypes: string[]) => {\n if (haplotypes.join('\\n') !== (model.cutHaplotypes ?? []).join('\\n')) {\n model.setSubgraphHaplotypes(haplotypes)\n void model.cut()\n }\n }\n return (\n <Autocomplete\n multiple\n freeSolo\n disableCloseOnSelect\n options={names}\n value={draft}\n open={open}\n onOpen={() => {\n setOpen(true)\n }}\n onClose={() => {\n setOpen(false)\n apply(draft)\n }}\n onChange={(_, value) => {\n setDraft(value)\n if (!open) {\n apply(value)\n }\n }}\n renderInput={params => (\n <TextField\n {...params}\n label=\"Haplotypes\"\n placeholder={draft.length === 0 ? 'every haplotype' : undefined}\n slotProps={{\n ...params.slotProps,\n htmlInput: {\n ...params.slotProps.htmlInput,\n 'data-testid': 'graph-haplotypes-field',\n },\n }}\n />\n )}\n />\n )\n})\n\n// Only a GBZ cut and a walk-indexed rGFA cut read the set. The inner field is\n// keyed on it so an outside change (a restored session, a launch) resets the\n// draft rather than fighting it.\nconst SubgraphHaplotypesField = observer(function SubgraphHaplotypesField({\n model,\n}: {\n model: LinearGraphCutModel\n}) {\n const { classes } = useStyles()\n const names = model.haplotypeNames\n const key = model.cutHaplotypes?.join(',') ?? ''\n return cutsByHaplotype(model.adapterConfig) ? (\n <div className={classes.section}>\n {names ? (\n <HaplotypePickField key={key} model={model} names={names} />\n ) : (\n <HaplotypeListField key={key} model={model} />\n )}\n <Typography variant=\"caption\" component=\"div\" color=\"text.secondary\">\n {names\n ? `Which of the graph's ${names.length.toLocaleString()} haplotypes to cut, or a PanSN prefix (HG002 for both).`\n : 'Which haplotypes to cut, as lane assembly names or PanSN prefixes (HG002#1, or HG002 for both) separated by commas.'}{' '}\n Empty is every haplotype.\n </Typography>\n </div>\n ) : null\n})\n\nexport default SubgraphHaplotypesField\n", "import SubgraphContextSelect from './SubgraphContextSelect'\nimport SubgraphHaplotypesField from './SubgraphHaplotypesField'\nimport GraphSettingsDialog from '../../GraphGenomeView/components/GraphSettingsDialog'\n\nimport type { LinearGraphCutModel } from '../model'\n\nexport default function GraphTrackSettingsDialog({\n model,\n open,\n onClose,\n}: {\n model: LinearGraphCutModel\n open: boolean\n onClose: () => void\n}) {\n return (\n <GraphSettingsDialog model={model} open={open} onClose={onClose}>\n <SubgraphContextSelect model={model} />\n <SubgraphHaplotypesField model={model} />\n </GraphSettingsDialog>\n )\n}\n"],
5
- "mappings": "2bAcA,IAAMA,EAAYC,EAAW,EAAE,CAC7B,QAAS,CACP,aAAc,EAChB,EACA,YAAa,CACX,SA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O,UACV,UAAW,CACT,GAAGA,EAAO,UAAU,UACpB,cAAe,wBACjB,CACF,EACF,EAEJ,CAEJ,CAAC,EAKKC,EAA0BlB,EAAS,SAAiC,CACxE,MAAAC,CACF,EAEG,CACD,GAAM,CAAE,QAAAkB,CAAQ,EAAI1B,EAAU,EACxBI,EAAQI,EAAM,eACdmB,EAAMnB,EAAM,eAAe,KAAK,GAAG,GAAK,GAC9C,OAAOoB,EAAgBpB,EAAM,aAAa,EACxCqB,EAAC,OAAI,UAAWH,EAAQ,QACrB,UAAAtB,EACCU,EAACG,EAAA,CAA6B,MAAOT,EAAO,MAAOJ,GAA1BuB,CAAiC,EAE1Db,EAACR,EAAA,CAA6B,MAAOE,GAAZmB,CAAmB,EAE9CE,EAACC,EAAA,CAAW,QAAQ,UAAU,UAAU,MAAM,MAAM,iBACjD,UAAA1B,EACG,wBAAwBA,EAAM,OAAO,eAAe,CAAC,0DACrD,sHAAuH,IAAI,6BAEjI,GACF,EACE,IACN,CAAC,EAEM2B,EAAQN,EC5IA,SAARO,EAA0C,CAC/C,MAAAC,EACA,KAAAC,EACA,QAAAC,CACF,EAIG,CACD,OACEC,EAACC,EAAA,CAAoB,MAAOJ,EAAO,KAAMC,EAAM,QAASC,EACtD,UAAAG,EAACC,EAAA,CAAsB,MAAON,EAAO,EACrCK,EAACE,EAAA,CAAwB,MAAOP,EAAO,GACzC,CAEJ",
6
- "names": ["useStyles", "makeStyles", "SUBGRAPH_CONTEXTS", "SubgraphContextSelect", "observer", "model", "classes", "walkIndexed", "jsxs", "FormControl", "jsx", "InputLabel", "Select", "e", "value", "label", "MenuItem", "Typography", "SubgraphContextSelect_default", "useStyles", "makeStyles", "parseHaplotypeList", "text", "names", "name", "HaplotypeListField", "observer", "model", "draft", "setDraft", "useState", "apply", "parsed", "jsx", "TextField", "e", "HaplotypePickField", "open", "setOpen", "haplotypes", "Autocomplete", "_", "value", "params", "SubgraphHaplotypesField", "classes", "key", "cutsByHaplotype", "jsxs", "Typography", "SubgraphHaplotypesField_default", "GraphTrackSettingsDialog", "model", "open", "onClose", "jsxs", "GraphSettingsDialog_default", "jsx", "SubgraphContextSelect_default", "SubgraphHaplotypesField_default"]
7
- }
@@ -1,2 +0,0 @@
1
- import{a as d}from"./chunk-WRH2EJKX.js";import{a as g,d as f,f as c}from"./chunk-XT766CZ5.js";import{a as u}from"./chunk-KOB7YIMR.js";import{b,f as p,g as m}from"./chunk-AMFIBQVR.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import"./chunk-446RWIA3.js";import"./chunk-OGQ6OQDN.js";import"./chunk-NDRLCGPC.js";import{a as i,o as l}from"./chunk-TENPGIPX.js";var r=class extends b{static{this.capabilities=["getFeatures","getRefNames"]}constructor(t,a,s){super(t,a,s),this.bubbles=p(this,["bubblesLocation"],["index"]),this.refNames=new m(this.bubbles,this)}async getRefNames(t={}){return this.refNames.assemblyRefNames(t)}async hasDataForRefName(){return!0}getFeatures(t,a={}){let{signal:s,statusCallback:h}=a;return u(async o=>{let n=await this.refNames.resolve(t,a);n!==void 0&&await l("Downloading bubbles",h,()=>d(this.bubbles,n,t.start,t.end,{signal:s,lineCallback:(A,y)=>{let e=g(A);o.next(new i({uniqueId:`bubble-${y}`,refName:t.refName,start:e.start,end:e.end,name:f(e),description:c(e),type:"bubble",score:e.segmentCount,segmentCount:e.segmentCount,pathCount:e.pathCount,inversion:e.inversion,shortestAlleleLength:e.shortestAlleleLength,longestAlleleLength:e.longestAlleleLength,segments:e.segments,shortestAllele:e.shortestAllele,longestAllele:e.longestAllele}))}})),o.complete()},s)}};export{r as default};
2
- //# sourceMappingURL=MinigraphBubbleAdapter-AGI2UYQR.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/MinigraphBubbleAdapter/MinigraphBubbleAdapter.ts"],
4
- "sourcesContent": ["import {\n bubbleDescription,\n bubbleLabel,\n parseBubbleLine,\n} from '@jbrowse/bandage-core/bubbles/bubbleLine'\nimport { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter'\nimport { SimpleFeature, updateStatus } from '@jbrowse/core/util'\nimport { ObservableCreate } from '@jbrowse/core/util/rxjs'\n\nimport { PanSNRefNames, openTabixSlot } from '../panSNTabix.ts'\nimport { getLines } from '../tabixRange.ts'\n\nimport type { MinigraphBubbleAdapterConfig } from './configSchema.ts'\nimport type PluginManager from '@jbrowse/core/PluginManager'\nimport type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter'\nimport type { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache'\nimport type { Feature } from '@jbrowse/core/util'\nimport type { Region } from '@jbrowse/core/util/types'\n\nexport default class MinigraphBubbleAdapter extends BaseFeatureDataAdapter<MinigraphBubbleAdapterConfig> {\n public static capabilities = ['getFeatures', 'getRefNames']\n\n private readonly bubbles\n // `gfatools bubble` names each row after the graph's stable sequence, so a\n // Minigraph-Cactus graph produces PanSN rows (`GRCh38#0#chr6`) where a plain\n // minigraph graph produces bare ones (`chr6`). Same resolution the segment\n // adapter does, through the same `assemblyNameToPanSN` slot.\n private readonly refNames\n\n public constructor(\n config: MinigraphBubbleAdapterConfig,\n getSubAdapter?: getSubAdapterType,\n pluginManager?: PluginManager,\n ) {\n super(config, getSubAdapter, pluginManager)\n this.bubbles = openTabixSlot(this, ['bubblesLocation'], ['index'])\n this.refNames = new PanSNRefNames(this.bubbles, this)\n }\n\n async getRefNames(opts: BaseOptions = {}) {\n return this.refNames.assemblyRefNames(opts)\n }\n\n public async hasDataForRefName() {\n return true\n }\n\n getFeatures(query: Region, opts: BaseOptions = {}) {\n const { signal, statusCallback } = opts\n return ObservableCreate<Feature>(async observer => {\n const tabixRefName = await this.refNames.resolve(query, opts)\n if (tabixRefName !== undefined) {\n await updateStatus('Downloading bubbles', statusCallback, () =>\n getLines(this.bubbles, tabixRefName, query.start, query.end, {\n signal,\n lineCallback: (line, fileOffset) => {\n const bubble = parseBubbleLine(line)\n observer.next(\n new SimpleFeature({\n uniqueId: `bubble-${fileOffset}`,\n refName: query.refName,\n start: bubble.start,\n end: bubble.end,\n // How variable this spot is, in two words, since that is the\n // whole point of the track.\n name: bubbleLabel(bubble),\n description: bubbleDescription(bubble),\n type: 'bubble',\n score: bubble.segmentCount,\n segmentCount: bubble.segmentCount,\n pathCount: bubble.pathCount,\n inversion: bubble.inversion,\n shortestAlleleLength: bubble.shortestAlleleLength,\n longestAlleleLength: bubble.longestAlleleLength,\n segments: bubble.segments,\n shortestAllele: bubble.shortestAllele,\n longestAllele: bubble.longestAllele,\n }),\n )\n },\n }),\n )\n }\n observer.complete()\n }, signal)\n }\n}\n"],
5
- "mappings": "kXAmBA,IAAqBA,EAArB,cAAoDC,CAAqD,CACvG,YAAc,aAAe,CAAC,cAAe,aAAa,EASnD,YACLC,EACAC,EACAC,EACA,CACA,MAAMF,EAAQC,EAAeC,CAAa,EAC1C,KAAK,QAAUC,EAAc,KAAM,CAAC,iBAAiB,EAAG,CAAC,OAAO,CAAC,EACjE,KAAK,SAAW,IAAIC,EAAc,KAAK,QAAS,IAAI,CACtD,CAEA,MAAM,YAAYC,EAAoB,CAAC,EAAG,CACxC,OAAO,KAAK,SAAS,iBAAiBA,CAAI,CAC5C,CAEA,MAAa,mBAAoB,CAC/B,MAAO,EACT,CAEA,YAAYC,EAAeD,EAAoB,CAAC,EAAG,CACjD,GAAM,CAAE,OAAAE,EAAQ,eAAAC,CAAe,EAAIH,EACnC,OAAOI,EAA0B,MAAMC,GAAY,CACjD,IAAMC,EAAe,MAAM,KAAK,SAAS,QAAQL,EAAOD,CAAI,EACxDM,IAAiB,QACnB,MAAMC,EAAa,sBAAuBJ,EAAgB,IACxDK,EAAS,KAAK,QAASF,EAAcL,EAAM,MAAOA,EAAM,IAAK,CAC3D,OAAAC,EACA,aAAc,CAACO,EAAMC,IAAe,CAClC,IAAMC,EAASC,EAAgBH,CAAI,EACnCJ,EAAS,KACP,IAAIQ,EAAc,CAChB,SAAU,UAAUH,CAAU,GAC9B,QAAST,EAAM,QACf,MAAOU,EAAO,MACd,IAAKA,EAAO,IAGZ,KAAMG,EAAYH,CAAM,EACxB,YAAaI,EAAkBJ,CAAM,EACrC,KAAM,SACN,MAAOA,EAAO,aACd,aAAcA,EAAO,aACrB,UAAWA,EAAO,UAClB,UAAWA,EAAO,UAClB,qBAAsBA,EAAO,qBAC7B,oBAAqBA,EAAO,oBAC5B,SAAUA,EAAO,SACjB,eAAgBA,EAAO,eACvB,cAAeA,EAAO,aACxB,CAAC,CACH,CACF,CACF,CAAC,CACH,EAEFN,EAAS,SAAS,CACpB,EAAGH,CAAM,CACX,CACF",
6
- "names": ["MinigraphBubbleAdapter", "BaseFeatureDataAdapter", "config", "getSubAdapter", "pluginManager", "openTabixSlot", "PanSNRefNames", "opts", "query", "signal", "statusCallback", "ObservableCreate", "observer", "tabixRefName", "updateStatus", "getLines", "line", "fileOffset", "bubble", "parseBubbleLine", "SimpleFeature", "bubbleLabel", "bubbleDescription"]
7
- }
@@ -1,3 +0,0 @@
1
- import{a as h}from"./chunk-WRH2EJKX.js";import{a as P,c as v,e as O}from"./chunk-WX26KTZM.js";import{a as T}from"./chunk-KOB7YIMR.js";import"./chunk-TXI43PEN.js";import{b as A,f as b,g as B}from"./chunk-AMFIBQVR.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import{f as I}from"./chunk-446RWIA3.js";import{b as M}from"./chunk-5OI6LO4I.js";import"./chunk-OGQ6OQDN.js";import"./chunk-NDRLCGPC.js";import{a as L,o as y}from"./chunk-TENPGIPX.js";function C(i){let e=i.split(" "),n=e.length>=8,s=n?5:0;return{anchored:n,segment:{refName:e[s],start:+e[s+1],end:+e[s+2],id:e[3],rank:+e[4],tags:e[n?8:5]??""}}}function Z(i){let e=i.tags.split(" ").find(s=>s.startsWith("SM:Z:"));if(e===void 0)return;let n=e.slice(5).split(",").map(s=>s.trim()).filter(Boolean);return n.length>0?n:void 0}function j(i){return{id:i.slice(0,-1),strand:i.slice(-1)}}function x(i){let e=i.split(" "),n=j(e[3]),s=j(e[4]);return{source:n.id,sourceStrand:n.strand,target:s.id,targetStrand:s.strand,sourceSegment:{id:n.id,refName:e[5],start:+e[6],end:+e[7],rank:+e[8],tags:e[13]??""},targetSegment:{id:s.id,refName:e[9],start:+e[10],end:+e[11],rank:+e[12],tags:e[14]??""}}}function k(i){return`${i.source}${i.sourceStrand}${i.target}${i.targetStrand}`}function W(i,e,n){let s=a=>a.rank!==0||a.refName!==n.refName?0:a.end<=n.start?-1:a.start>=n.end?1:0,t=new Map(i),r=new Map;for(let a of e)if(i.has(a.source)||i.has(a.target)||s(a.sourceSegment)*s(a.targetSegment)===-1){r.set(k(a),a);for(let f of[a.sourceSegment,a.targetSegment])t.has(f.id)||t.set(f.id,f)}for(let a of e)t.has(a.source)&&t.has(a.target)&&r.set(k(a),a);return{segments:t,links:r}}function D(i,e,n){let s=t=>t.refName!==n.refName||t.end<=n.start||t.start>=n.end;return[...G(i.filter(t=>t.rank>0),e,n.end-n.start),...G(i.filter(t=>t.rank===0&&s(t)),new Set(i.map(t=>t.id)),0)]}function G(i,e,n){let s=[...i].sort((r,a)=>w(r.refName,a.refName)||r.start-a.start),t=[];for(let r of s){let a=t.at(-1);a?.refName===r.refName&&r.start-a.end<=n?(a.needed||=r.start>a.end||e.has(r.id),a.end=Math.max(a.end,r.end)):t.push({refName:r.refName,start:r.start,end:r.end,needed:e.has(r.id)})}return t.filter(r=>r.needed).map(({refName:r,start:a,end:f})=>({refName:r,start:a,end:f}))}function H(i,e,n){let s=t=>e.has(t.id)||n.some(r=>r.refName===t.refName&&t.start>=r.start&&t.end<=r.end);return i.filter(t=>s(t.sourceSegment)&&s(t.targetSegment))}var E=/^[A-Za-z][A-Za-z0-9]:[AifZJHB]:/;function K(i){let{id:e,refName:n,start:s,end:t,rank:r,tags:a}=i,f=a.split(" ").filter(p=>E.test(p)),l=f.length===0?"":` ${f.join(" ")}`;return`S ${e} * LN:i:${t-s} SN:Z:${n} SO:i:${s} SR:i:${r}${l}`}function J(i){let{source:e,sourceStrand:n,target:s,targetStrand:t}=i;return`L ${e} ${n} ${s} ${t} 0M`}function w(i,e){return i<e?-1:i>e?1:0}function $(i,e){let n=[...i.values()].sort((t,r)=>w(t.refName,r.refName)||t.start-r.start||w(t.id,r.id)),s=[...e.keys()].sort((t,r)=>w(t,r));return["H VN:Z:1.0",...n.map(t=>K(t)),...s.map(t=>J(e.get(t)))].join(`
2
- `)}function _(i){return i.filter(e=>e.rank>0)}var F=class extends A{static{this.capabilities=["getFeatures","getRefNames"]}constructor(e,n,s){super(e,n,s),this.fine=this.openIndex([])}openIndex(e){let n=b(this,[...e,"segmentsLocation"],[...e,"segmentsIndex"]),s=this.getConf("walksLocation"),t=e.length===0&&M(s),r=b(this,[...e,"linksLocation"],[...e,"linksIndex"]),a=t?b(this,["walksLocation"],["walksIndex"]):void 0;return{segments:n,links:r,walkFile:a,walks:a?new v(a):void 0,refNames:new B(a??n,this)}}async getHaplotypeNames(e={}){let n=await this.fine.walks?.header(e);return n?.haplotypes.length?n.haplotypes:void 0}index(e="fine"){return e==="fine"?this.fine:(this.coarse??=this.openIndex(["coarse"]),this.coarse)}async getRefNames(e={}){return this.fine.refNames.assemblyRefNames(e)}async hasDataForRefName(){return!0}getFeatures(e,n={}){let{signal:s,statusCallback:t}=n;return T(async r=>{let a=await this.fine.refNames.resolve(e,n);if(a!==void 0){let{walks:f,walkFile:l}=this.fine,p=f?await f.queryStart(e.start,n):e.start;if(l&&f){await f.header(n);let S=[];await y("Downloading walks",t,()=>h(l,a,p,e.end,{signal:s,lineCallback:g=>{let o=g.split(" ");o[3]==="ref"&&S.push(o)}}));let d=new Set;for(let g of P(S))if(g.refName===a&&g.end>e.start&&!d.has(g.id)){d.add(g.id);let o=String(g.id);r.next(new L({uniqueId:o,refName:e.refName,start:g.start,end:g.end,name:o,type:"segment",rank:0,stableName:g.refName}))}r.complete();return}await y("Downloading segments",t,()=>h(this.fine.segments,a,p,e.end,{signal:s,lineCallback:S=>{let{segment:d,anchored:g}=C(S);if(g&&d.refName!==a||d.end<=e.start)return;let o=Z(d);r.next(new L({uniqueId:d.id,refName:e.refName,start:d.start,end:d.end,name:d.id,type:"segment",rank:d.rank,stableName:d.refName,...o&&{samples:o,sampleCount:o.length}}))}}))}r.complete()},s)}async getSubgraph(e,n={}){let{hops:s=0,signal:t,tier:r}=n,a=this.index(r),f=new Map,l=new Map,p=await a.refNames.resolve(e,{signal:t}),S=async(o,c,m)=>{let u=[];return await h(a.links,o,c,m,{signal:t,lineCallback:z=>{let N=x(z);l.set(k(N),N);for(let R of[N.sourceSegment,N.targetSegment])f.has(R.id)||(f.set(R.id,R),u.push(R))}}),u};if(p===void 0)throw new Error(`${e.assemblyName} ${e.refName} is not in this graph's index; a graph with PanSN names (GRCh38#0#chr1) needs ${e.assemblyName} mapped to its prefix in assemblyNameToPanSN`);if(a.walks)return O(a.walks,p,e,{signal:t,prefixes:n.haplotypes?.map(o=>I(this,o)),walkRows:n.walkRows,stepBudget:this.getConf("walkStepBudget"),byteBudget:this.getConf("walkByteBudget")});let d={anchored:!1};if(await h(a.segments,p,e.start,e.end,{signal:t,lineCallback:o=>{let c=C(o);d.anchored||=c.anchored,f.set(c.segment.id,c.segment)}}),d.anchored){let o=[];await h(a.links,p,e.start,e.end,{signal:t,lineCallback:m=>{o.push(x(m))}});let c=W(f,o,{refName:p,start:e.start,end:e.end});return $(c.segments,c.links)}let g=_(await S(p,e.start,e.end));for(let o=0;o<s;o++){let c=await Promise.all(g.map(m=>S(m.refName,m.start,m.end)));g=_(c.flat())}if(s>0){let o=D([...f.values()],new Set(g.map(m=>m.id)),{refName:p,start:e.start,end:e.end}),c=[];await Promise.all(o.map(m=>h(a.links,m.refName,m.start,m.end,{signal:t,lineCallback:u=>{c.push(x(u))}})));for(let m of H(c,f,o)){l.set(k(m),m);for(let u of[m.sourceSegment,m.targetSegment])f.has(u.id)||f.set(u.id,u)}}return $(f,l)}};export{F as default};
3
- //# sourceMappingURL=RgfaTabixAdapter-2OL5X3HF.js.map