@jbrowse/plugin-dotplot-view 2.6.1

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 (263) hide show
  1. package/LICENSE +201 -0
  2. package/dist/ComparativeRenderer/index.d.ts +27 -0
  3. package/dist/ComparativeRenderer/index.js +59 -0
  4. package/dist/ComparativeRenderer/index.js.map +1 -0
  5. package/dist/DotplotDisplay/components/DotplotDisplay.d.ts +8 -0
  6. package/dist/DotplotDisplay/components/DotplotDisplay.js +24 -0
  7. package/dist/DotplotDisplay/components/DotplotDisplay.js.map +1 -0
  8. package/dist/DotplotDisplay/index.d.ts +12 -0
  9. package/dist/DotplotDisplay/index.js +48 -0
  10. package/dist/DotplotDisplay/index.js.map +1 -0
  11. package/dist/DotplotDisplay/renderDotplotBlock.d.ts +11 -0
  12. package/dist/DotplotDisplay/renderDotplotBlock.js +57 -0
  13. package/dist/DotplotDisplay/renderDotplotBlock.js.map +1 -0
  14. package/dist/DotplotDisplay/stateModelFactory.d.ts +138 -0
  15. package/dist/DotplotDisplay/stateModelFactory.js +165 -0
  16. package/dist/DotplotDisplay/stateModelFactory.js.map +1 -0
  17. package/dist/DotplotReadVsRef/DotplotReadVsRef.d.ts +3 -0
  18. package/dist/DotplotReadVsRef/DotplotReadVsRef.js +102 -0
  19. package/dist/DotplotReadVsRef/DotplotReadVsRef.js.map +1 -0
  20. package/dist/DotplotReadVsRef/index.d.ts +2 -0
  21. package/dist/DotplotReadVsRef/index.js +42 -0
  22. package/dist/DotplotReadVsRef/index.js.map +1 -0
  23. package/dist/DotplotRenderer/ComparativeRenderRpc.d.ts +27 -0
  24. package/dist/DotplotRenderer/ComparativeRenderRpc.js +59 -0
  25. package/dist/DotplotRenderer/ComparativeRenderRpc.js.map +1 -0
  26. package/dist/DotplotRenderer/DotplotRenderer.d.ts +69 -0
  27. package/dist/DotplotRenderer/DotplotRenderer.js +274 -0
  28. package/dist/DotplotRenderer/DotplotRenderer.js.map +1 -0
  29. package/dist/DotplotRenderer/components/DotplotRendering.d.ts +5 -0
  30. package/dist/DotplotRenderer/components/DotplotRendering.js +13 -0
  31. package/dist/DotplotRenderer/components/DotplotRendering.js.map +1 -0
  32. package/dist/DotplotRenderer/configSchema.d.ts +61 -0
  33. package/dist/DotplotRenderer/configSchema.js +83 -0
  34. package/dist/DotplotRenderer/configSchema.js.map +1 -0
  35. package/dist/DotplotRenderer/index.d.ts +3 -0
  36. package/dist/DotplotRenderer/index.js +17 -0
  37. package/dist/DotplotRenderer/index.js.map +1 -0
  38. package/dist/DotplotView/1dview.d.ts +307 -0
  39. package/dist/DotplotView/1dview.js +95 -0
  40. package/dist/DotplotView/1dview.js.map +1 -0
  41. package/dist/DotplotView/blockTypes.d.ts +61 -0
  42. package/dist/DotplotView/blockTypes.js +117 -0
  43. package/dist/DotplotView/blockTypes.js.map +1 -0
  44. package/dist/DotplotView/components/Axes.d.ts +14 -0
  45. package/dist/DotplotView/components/Axes.js +127 -0
  46. package/dist/DotplotView/components/Axes.js.map +1 -0
  47. package/dist/DotplotView/components/CursorIcon.d.ts +4 -0
  48. package/dist/DotplotView/components/CursorIcon.js +19 -0
  49. package/dist/DotplotView/components/CursorIcon.js.map +1 -0
  50. package/dist/DotplotView/components/DotplotTooltip.d.ts +19 -0
  51. package/dist/DotplotView/components/DotplotTooltip.js +128 -0
  52. package/dist/DotplotView/components/DotplotTooltip.js.map +1 -0
  53. package/dist/DotplotView/components/DotplotView.d.ts +6 -0
  54. package/dist/DotplotView/components/DotplotView.js +272 -0
  55. package/dist/DotplotView/components/DotplotView.js.map +1 -0
  56. package/dist/DotplotView/components/DotplotWarnings.d.ts +6 -0
  57. package/dist/DotplotView/components/DotplotWarnings.js +40 -0
  58. package/dist/DotplotView/components/DotplotWarnings.js.map +1 -0
  59. package/dist/DotplotView/components/ExportSvgDialog.d.ts +8 -0
  60. package/dist/DotplotView/components/ExportSvgDialog.js +76 -0
  61. package/dist/DotplotView/components/ExportSvgDialog.js.map +1 -0
  62. package/dist/DotplotView/components/Grid.d.ts +10 -0
  63. package/dist/DotplotView/components/Grid.js +60 -0
  64. package/dist/DotplotView/components/Grid.js.map +1 -0
  65. package/dist/DotplotView/components/Header.d.ts +10 -0
  66. package/dist/DotplotView/components/Header.js +168 -0
  67. package/dist/DotplotView/components/Header.js.map +1 -0
  68. package/dist/DotplotView/components/ImportCustomTrack.d.ts +11 -0
  69. package/dist/DotplotView/components/ImportCustomTrack.js +180 -0
  70. package/dist/DotplotView/components/ImportCustomTrack.js.map +1 -0
  71. package/dist/DotplotView/components/ImportForm.d.ts +6 -0
  72. package/dist/DotplotView/components/ImportForm.js +121 -0
  73. package/dist/DotplotView/components/ImportForm.js.map +1 -0
  74. package/dist/DotplotView/components/ImportSyntenyTrackSelector.d.ts +9 -0
  75. package/dist/DotplotView/components/ImportSyntenyTrackSelector.js +69 -0
  76. package/dist/DotplotView/components/ImportSyntenyTrackSelector.js.map +1 -0
  77. package/dist/DotplotView/components/PanButtons.d.ts +6 -0
  78. package/dist/DotplotView/components/PanButtons.js +60 -0
  79. package/dist/DotplotView/components/PanButtons.js.map +1 -0
  80. package/dist/DotplotView/components/WarningDialog.d.ts +16 -0
  81. package/dist/DotplotView/components/WarningDialog.js +41 -0
  82. package/dist/DotplotView/components/WarningDialog.js.map +1 -0
  83. package/dist/DotplotView/components/util.d.ts +19 -0
  84. package/dist/DotplotView/components/util.js +90 -0
  85. package/dist/DotplotView/components/util.js.map +1 -0
  86. package/dist/DotplotView/index.d.ts +2 -0
  87. package/dist/DotplotView/index.js +44 -0
  88. package/dist/DotplotView/index.js.map +1 -0
  89. package/dist/DotplotView/model.d.ts +616 -0
  90. package/dist/DotplotView/model.js +647 -0
  91. package/dist/DotplotView/model.js.map +1 -0
  92. package/dist/DotplotView/svgcomponents/SVGBackground.d.ts +5 -0
  93. package/dist/DotplotView/svgcomponents/SVGBackground.js +13 -0
  94. package/dist/DotplotView/svgcomponents/SVGBackground.js.map +1 -0
  95. package/dist/DotplotView/svgcomponents/SVGDotplotView.d.ts +2 -0
  96. package/dist/DotplotView/svgcomponents/SVGDotplotView.js +47 -0
  97. package/dist/DotplotView/svgcomponents/SVGDotplotView.js.map +1 -0
  98. package/dist/LaunchDotplotView.d.ts +2 -0
  99. package/dist/LaunchDotplotView.js +45 -0
  100. package/dist/LaunchDotplotView.js.map +1 -0
  101. package/dist/ServerSideRenderedBlockContent.d.ts +12 -0
  102. package/dist/ServerSideRenderedBlockContent.js +87 -0
  103. package/dist/ServerSideRenderedBlockContent.js.map +1 -0
  104. package/dist/ServerSideSyntenyRendering.d.ts +23 -0
  105. package/dist/ServerSideSyntenyRendering.js +54 -0
  106. package/dist/ServerSideSyntenyRendering.js.map +1 -0
  107. package/dist/index.d.ts +7 -0
  108. package/dist/index.js +44 -0
  109. package/dist/index.js.map +1 -0
  110. package/dist/util.d.ts +9 -0
  111. package/dist/util.js +9 -0
  112. package/dist/util.js.map +1 -0
  113. package/esm/ComparativeRenderer/index.d.ts +27 -0
  114. package/esm/ComparativeRenderer/index.js +53 -0
  115. package/esm/ComparativeRenderer/index.js.map +1 -0
  116. package/esm/DotplotDisplay/components/DotplotDisplay.d.ts +8 -0
  117. package/esm/DotplotDisplay/components/DotplotDisplay.js +19 -0
  118. package/esm/DotplotDisplay/components/DotplotDisplay.js.map +1 -0
  119. package/esm/DotplotDisplay/index.d.ts +12 -0
  120. package/esm/DotplotDisplay/index.js +41 -0
  121. package/esm/DotplotDisplay/index.js.map +1 -0
  122. package/esm/DotplotDisplay/renderDotplotBlock.d.ts +11 -0
  123. package/esm/DotplotDisplay/renderDotplotBlock.js +49 -0
  124. package/esm/DotplotDisplay/renderDotplotBlock.js.map +1 -0
  125. package/esm/DotplotDisplay/stateModelFactory.d.ts +138 -0
  126. package/esm/DotplotDisplay/stateModelFactory.js +158 -0
  127. package/esm/DotplotDisplay/stateModelFactory.js.map +1 -0
  128. package/esm/DotplotReadVsRef/DotplotReadVsRef.d.ts +3 -0
  129. package/esm/DotplotReadVsRef/DotplotReadVsRef.js +98 -0
  130. package/esm/DotplotReadVsRef/DotplotReadVsRef.js.map +1 -0
  131. package/esm/DotplotReadVsRef/index.d.ts +2 -0
  132. package/esm/DotplotReadVsRef/index.js +36 -0
  133. package/esm/DotplotReadVsRef/index.js.map +1 -0
  134. package/esm/DotplotRenderer/ComparativeRenderRpc.d.ts +27 -0
  135. package/esm/DotplotRenderer/ComparativeRenderRpc.js +53 -0
  136. package/esm/DotplotRenderer/ComparativeRenderRpc.js.map +1 -0
  137. package/esm/DotplotRenderer/DotplotRenderer.d.ts +69 -0
  138. package/esm/DotplotRenderer/DotplotRenderer.js +268 -0
  139. package/esm/DotplotRenderer/DotplotRenderer.js.map +1 -0
  140. package/esm/DotplotRenderer/components/DotplotRendering.d.ts +5 -0
  141. package/esm/DotplotRenderer/components/DotplotRendering.js +8 -0
  142. package/esm/DotplotRenderer/components/DotplotRendering.js.map +1 -0
  143. package/esm/DotplotRenderer/configSchema.d.ts +61 -0
  144. package/esm/DotplotRenderer/configSchema.js +81 -0
  145. package/esm/DotplotRenderer/configSchema.js.map +1 -0
  146. package/esm/DotplotRenderer/index.d.ts +3 -0
  147. package/esm/DotplotRenderer/index.js +12 -0
  148. package/esm/DotplotRenderer/index.js.map +1 -0
  149. package/esm/DotplotView/1dview.d.ts +307 -0
  150. package/esm/DotplotView/1dview.js +87 -0
  151. package/esm/DotplotView/1dview.js.map +1 -0
  152. package/esm/DotplotView/blockTypes.d.ts +61 -0
  153. package/esm/DotplotView/blockTypes.js +109 -0
  154. package/esm/DotplotView/blockTypes.js.map +1 -0
  155. package/esm/DotplotView/components/Axes.d.ts +14 -0
  156. package/esm/DotplotView/components/Axes.js +121 -0
  157. package/esm/DotplotView/components/Axes.js.map +1 -0
  158. package/esm/DotplotView/components/CursorIcon.d.ts +4 -0
  159. package/esm/DotplotView/components/CursorIcon.js +11 -0
  160. package/esm/DotplotView/components/CursorIcon.js.map +1 -0
  161. package/esm/DotplotView/components/DotplotTooltip.d.ts +19 -0
  162. package/esm/DotplotView/components/DotplotTooltip.js +101 -0
  163. package/esm/DotplotView/components/DotplotTooltip.js.map +1 -0
  164. package/esm/DotplotView/components/DotplotView.d.ts +6 -0
  165. package/esm/DotplotView/components/DotplotView.js +244 -0
  166. package/esm/DotplotView/components/DotplotView.js.map +1 -0
  167. package/esm/DotplotView/components/DotplotWarnings.d.ts +6 -0
  168. package/esm/DotplotView/components/DotplotWarnings.js +15 -0
  169. package/esm/DotplotView/components/DotplotWarnings.js.map +1 -0
  170. package/esm/DotplotView/components/ExportSvgDialog.d.ts +8 -0
  171. package/esm/DotplotView/components/ExportSvgDialog.js +50 -0
  172. package/esm/DotplotView/components/ExportSvgDialog.js.map +1 -0
  173. package/esm/DotplotView/components/Grid.d.ts +10 -0
  174. package/esm/DotplotView/components/Grid.js +53 -0
  175. package/esm/DotplotView/components/Grid.js.map +1 -0
  176. package/esm/DotplotView/components/Header.d.ts +10 -0
  177. package/esm/DotplotView/components/Header.js +140 -0
  178. package/esm/DotplotView/components/Header.js.map +1 -0
  179. package/esm/DotplotView/components/ImportCustomTrack.d.ts +11 -0
  180. package/esm/DotplotView/components/ImportCustomTrack.js +152 -0
  181. package/esm/DotplotView/components/ImportCustomTrack.js.map +1 -0
  182. package/esm/DotplotView/components/ImportForm.d.ts +6 -0
  183. package/esm/DotplotView/components/ImportForm.js +93 -0
  184. package/esm/DotplotView/components/ImportForm.js.map +1 -0
  185. package/esm/DotplotView/components/ImportSyntenyTrackSelector.d.ts +9 -0
  186. package/esm/DotplotView/components/ImportSyntenyTrackSelector.js +44 -0
  187. package/esm/DotplotView/components/ImportSyntenyTrackSelector.js.map +1 -0
  188. package/esm/DotplotView/components/PanButtons.d.ts +6 -0
  189. package/esm/DotplotView/components/PanButtons.js +55 -0
  190. package/esm/DotplotView/components/PanButtons.js.map +1 -0
  191. package/esm/DotplotView/components/WarningDialog.d.ts +16 -0
  192. package/esm/DotplotView/components/WarningDialog.js +36 -0
  193. package/esm/DotplotView/components/WarningDialog.js.map +1 -0
  194. package/esm/DotplotView/components/util.d.ts +19 -0
  195. package/esm/DotplotView/components/util.js +83 -0
  196. package/esm/DotplotView/components/util.js.map +1 -0
  197. package/esm/DotplotView/index.d.ts +2 -0
  198. package/esm/DotplotView/index.js +15 -0
  199. package/esm/DotplotView/index.js.map +1 -0
  200. package/esm/DotplotView/model.d.ts +616 -0
  201. package/esm/DotplotView/model.js +616 -0
  202. package/esm/DotplotView/model.js.map +1 -0
  203. package/esm/DotplotView/svgcomponents/SVGBackground.d.ts +5 -0
  204. package/esm/DotplotView/svgcomponents/SVGBackground.js +7 -0
  205. package/esm/DotplotView/svgcomponents/SVGBackground.js.map +1 -0
  206. package/esm/DotplotView/svgcomponents/SVGDotplotView.d.ts +2 -0
  207. package/esm/DotplotView/svgcomponents/SVGDotplotView.js +40 -0
  208. package/esm/DotplotView/svgcomponents/SVGDotplotView.js.map +1 -0
  209. package/esm/LaunchDotplotView.d.ts +2 -0
  210. package/esm/LaunchDotplotView.js +42 -0
  211. package/esm/LaunchDotplotView.js.map +1 -0
  212. package/esm/ServerSideRenderedBlockContent.d.ts +12 -0
  213. package/esm/ServerSideRenderedBlockContent.js +62 -0
  214. package/esm/ServerSideRenderedBlockContent.js.map +1 -0
  215. package/esm/ServerSideSyntenyRendering.d.ts +23 -0
  216. package/esm/ServerSideSyntenyRendering.js +29 -0
  217. package/esm/ServerSideSyntenyRendering.js.map +1 -0
  218. package/esm/index.d.ts +7 -0
  219. package/esm/index.js +38 -0
  220. package/esm/index.js.map +1 -0
  221. package/esm/util.d.ts +9 -0
  222. package/esm/util.js +5 -0
  223. package/esm/util.js.map +1 -0
  224. package/package.json +69 -0
  225. package/src/ComparativeRenderer/index.ts +87 -0
  226. package/src/DotplotDisplay/components/DotplotDisplay.tsx +34 -0
  227. package/src/DotplotDisplay/index.ts +48 -0
  228. package/src/DotplotDisplay/renderDotplotBlock.ts +60 -0
  229. package/src/DotplotDisplay/stateModelFactory.tsx +196 -0
  230. package/src/DotplotReadVsRef/DotplotReadVsRef.ts +115 -0
  231. package/src/DotplotReadVsRef/index.ts +50 -0
  232. package/src/DotplotRenderer/ComparativeRenderRpc.ts +87 -0
  233. package/src/DotplotRenderer/DotplotRenderer.ts +328 -0
  234. package/src/DotplotRenderer/__image_snapshots__/linear-synteny-renderer-test-ts-test-rendering-a-simple-synteny-from-fake-data-1-snap.png +0 -0
  235. package/src/DotplotRenderer/components/DotplotRendering.tsx +12 -0
  236. package/src/DotplotRenderer/configSchema.ts +92 -0
  237. package/src/DotplotRenderer/index.ts +16 -0
  238. package/src/DotplotView/1dview.ts +98 -0
  239. package/src/DotplotView/blockTypes.ts +140 -0
  240. package/src/DotplotView/components/Axes.tsx +246 -0
  241. package/src/DotplotView/components/CursorIcon.tsx +24 -0
  242. package/src/DotplotView/components/DotplotTooltip.tsx +163 -0
  243. package/src/DotplotView/components/DotplotView.tsx +348 -0
  244. package/src/DotplotView/components/DotplotWarnings.tsx +26 -0
  245. package/src/DotplotView/components/ExportSvgDialog.tsx +129 -0
  246. package/src/DotplotView/components/Grid.tsx +112 -0
  247. package/src/DotplotView/components/Header.tsx +182 -0
  248. package/src/DotplotView/components/ImportCustomTrack.tsx +262 -0
  249. package/src/DotplotView/components/ImportForm.tsx +209 -0
  250. package/src/DotplotView/components/ImportSyntenyTrackSelector.tsx +90 -0
  251. package/src/DotplotView/components/PanButtons.tsx +93 -0
  252. package/src/DotplotView/components/WarningDialog.tsx +74 -0
  253. package/src/DotplotView/components/util.ts +118 -0
  254. package/src/DotplotView/index.ts +16 -0
  255. package/src/DotplotView/model.test.ts +17 -0
  256. package/src/DotplotView/model.ts +719 -0
  257. package/src/DotplotView/svgcomponents/SVGBackground.tsx +21 -0
  258. package/src/DotplotView/svgcomponents/SVGDotplotView.tsx +68 -0
  259. package/src/LaunchDotplotView.ts +63 -0
  260. package/src/ServerSideRenderedBlockContent.tsx +86 -0
  261. package/src/ServerSideSyntenyRendering.tsx +54 -0
  262. package/src/index.ts +41 -0
  263. package/src/util.ts +14 -0
@@ -0,0 +1,182 @@
1
+ import React, { useState } from 'react'
2
+ import { IconButton, Typography } from '@mui/material'
3
+ import { observer } from 'mobx-react'
4
+ import { makeStyles } from 'tss-react/mui'
5
+ import { getBpDisplayStr } from '@jbrowse/core/util'
6
+ import { Menu } from '@jbrowse/core/ui'
7
+
8
+ // icons
9
+ import ZoomOut from '@mui/icons-material/ZoomOut'
10
+ import ZoomIn from '@mui/icons-material/ZoomIn'
11
+ import MoreVert from '@mui/icons-material/MoreVert'
12
+ import { CursorMouse, CursorMove } from './CursorIcon'
13
+ import { TrackSelector as TrackSelectorIcon } from '@jbrowse/core/ui/Icons'
14
+
15
+ // locals
16
+ import { DotplotViewModel } from '../model'
17
+ import DotplotWarnings from './DotplotWarnings'
18
+ import PanButtons from './PanButtons'
19
+
20
+ const useStyles = makeStyles()({
21
+ iconButton: {
22
+ margin: 5,
23
+ },
24
+ bp: {
25
+ display: 'flex',
26
+ alignItems: 'center',
27
+ marginLeft: 10,
28
+ },
29
+ spacer: {
30
+ flexGrow: 1,
31
+ },
32
+ headerBar: {
33
+ display: 'flex',
34
+ position: 'relative',
35
+ },
36
+ })
37
+
38
+ const DotplotControls = observer(({ model }: { model: DotplotViewModel }) => {
39
+ const { classes } = useStyles()
40
+ const [menuAnchorEl, setMenuAnchorEl] = useState<HTMLElement>()
41
+ return (
42
+ <div>
43
+ <IconButton onClick={model.zoomOutButton} className={classes.iconButton}>
44
+ <ZoomOut />
45
+ </IconButton>
46
+
47
+ <IconButton onClick={model.zoomInButton} className={classes.iconButton}>
48
+ <ZoomIn />
49
+ </IconButton>
50
+
51
+ <IconButton
52
+ onClick={() => model.activateTrackSelector()}
53
+ className={classes.iconButton}
54
+ title="Open track selector"
55
+ data-testid="circular_track_select"
56
+ >
57
+ <TrackSelectorIcon />
58
+ </IconButton>
59
+
60
+ <IconButton
61
+ onClick={event => setMenuAnchorEl(event.currentTarget)}
62
+ className={classes.iconButton}
63
+ >
64
+ <MoreVert />
65
+ </IconButton>
66
+
67
+ {menuAnchorEl ? (
68
+ <Menu
69
+ anchorEl={menuAnchorEl}
70
+ open
71
+ onMenuItemClick={(_event, callback) => {
72
+ callback()
73
+ setMenuAnchorEl(undefined)
74
+ }}
75
+ menuItems={[
76
+ {
77
+ onClick: () => model.squareView(),
78
+ label: 'Square view - same base pairs per pixel',
79
+ },
80
+ {
81
+ onClick: () => model.squareViewProportional(),
82
+ label: 'Rectanglularize view - same total bp',
83
+ },
84
+ {
85
+ onClick: () => model.showAllRegions(),
86
+ label: 'Show all regions',
87
+ },
88
+ {
89
+ onClick: () => model.setDrawCigar(!model.drawCigar),
90
+ type: 'checkbox',
91
+ label: 'Draw CIGAR',
92
+ checked: model.drawCigar,
93
+ },
94
+ {
95
+ onClick: () => model.setShowPanButtons(!model.showPanButtons),
96
+ label: 'Show pan buttons',
97
+ type: 'checkbox',
98
+ checked: model.showPanButtons,
99
+ },
100
+ {
101
+ label: 'Click and drag mode',
102
+ subMenu: [
103
+ {
104
+ onClick: () => model.setCursorMode('move'),
105
+ label: 'Pan by default, select region when ctrl key is held',
106
+ icon: CursorMove,
107
+ type: 'radio',
108
+ checked: model.cursorMode === 'move',
109
+ },
110
+ {
111
+ onClick: () => model.setCursorMode('crosshair'),
112
+ label: 'Select region by default, pan when ctrl key is held',
113
+ icon: CursorMouse,
114
+ type: 'radio',
115
+ checked: model.cursorMode === 'crosshair',
116
+ },
117
+ ],
118
+ },
119
+ {
120
+ label: 'Wheel scroll mode',
121
+ subMenu: [
122
+ {
123
+ onClick: () => model.setWheelMode('pan'),
124
+ label: 'Pans view',
125
+ type: 'radio',
126
+ checked: model.wheelMode === 'pan',
127
+ },
128
+ {
129
+ onClick: () => model.setWheelMode('zoom'),
130
+ label: 'Zooms view',
131
+ type: 'radio',
132
+ checked: model.wheelMode === 'zoom',
133
+ },
134
+ {
135
+ onClick: () => model.setWheelMode('none'),
136
+ label: 'Disable',
137
+ type: 'radio',
138
+ checked: model.wheelMode === 'none',
139
+ },
140
+ ],
141
+ },
142
+ ]}
143
+ onClose={() => setMenuAnchorEl(undefined)}
144
+ />
145
+ ) : null}
146
+ </div>
147
+ )
148
+ })
149
+
150
+ export default observer(function Header({
151
+ model,
152
+ selection,
153
+ }: {
154
+ model: DotplotViewModel
155
+ selection?: { width: number; height: number }
156
+ }) {
157
+ const { classes } = useStyles()
158
+ const { hview, vview, showPanButtons } = model
159
+ return (
160
+ <div className={classes.headerBar}>
161
+ <DotplotControls model={model} />
162
+ <Typography className={classes.bp} variant="body2" color="textSecondary">
163
+ x: {hview.assemblyNames.join(',')} {getBpDisplayStr(hview.currBp)}
164
+ <br />
165
+ y: {vview.assemblyNames.join(',')} {getBpDisplayStr(vview.currBp)}
166
+ </Typography>
167
+ {selection ? (
168
+ <Typography
169
+ className={classes.bp}
170
+ variant="body2"
171
+ color="textSecondary"
172
+ >
173
+ {`width:${getBpDisplayStr(hview.bpPerPx * selection.width)}`} <br />
174
+ {`height:${getBpDisplayStr(vview.bpPerPx * selection.height)}`}
175
+ </Typography>
176
+ ) : null}
177
+ <div className={classes.spacer} />
178
+ <DotplotWarnings model={model} />
179
+ {showPanButtons ? <PanButtons model={model} /> : null}
180
+ </div>
181
+ )
182
+ })
@@ -0,0 +1,262 @@
1
+ import React, { useState, useEffect } from 'react'
2
+ import { SnapshotIn } from 'mobx-state-tree'
3
+ import path from 'path'
4
+ import {
5
+ FormControlLabel,
6
+ Grid,
7
+ Paper,
8
+ Radio,
9
+ RadioGroup,
10
+ Typography,
11
+ } from '@mui/material'
12
+ import { ErrorMessage, FileSelector } from '@jbrowse/core/ui'
13
+ import { FileLocation } from '@jbrowse/core/util/types'
14
+ import { observer } from 'mobx-react'
15
+ import { AnyConfigurationModel } from '@jbrowse/core/configuration'
16
+
17
+ function getName(
18
+ sessionTrackData?: { uri: string } | { localPath: string } | { name: string },
19
+ ) {
20
+ return sessionTrackData
21
+ ? // @ts-expect-error
22
+ sessionTrackData.uri ||
23
+ // @ts-expect-error
24
+ sessionTrackData.localPath ||
25
+ // @ts-expect-error
26
+ sessionTrackData.name
27
+ : undefined
28
+ }
29
+
30
+ function stripGz(fileName: string) {
31
+ return fileName.endsWith('.gz') ? fileName.slice(0, -3) : fileName
32
+ }
33
+
34
+ function getAdapter({
35
+ radioOption,
36
+ assembly1,
37
+ assembly2,
38
+ fileLocation,
39
+ bed1Location,
40
+ bed2Location,
41
+ }: {
42
+ radioOption: string
43
+ assembly1: string
44
+ assembly2: string
45
+ fileLocation?: FileLocation
46
+ bed1Location?: FileLocation
47
+ bed2Location?: FileLocation
48
+ }) {
49
+ if (radioOption === '.paf') {
50
+ return {
51
+ type: 'PAFAdapter',
52
+ pafLocation: fileLocation,
53
+ queryAssembly: assembly1,
54
+ targetAssembly: assembly2,
55
+ }
56
+ } else if (radioOption === '.out') {
57
+ return {
58
+ type: 'MashMapAdapter',
59
+ outLocation: fileLocation,
60
+ queryAssembly: assembly1,
61
+ targetAssembly: assembly2,
62
+ }
63
+ } else if (radioOption === '.delta') {
64
+ return {
65
+ type: 'DeltaAdapter',
66
+ deltaLocation: fileLocation,
67
+ queryAssembly: assembly1,
68
+ targetAssembly: assembly2,
69
+ }
70
+ } else if (radioOption === '.chain') {
71
+ return {
72
+ type: 'ChainAdapter',
73
+ chainLocation: fileLocation,
74
+ queryAssembly: assembly1,
75
+ targetAssembly: assembly2,
76
+ }
77
+ } else if (radioOption === '.anchors') {
78
+ return {
79
+ type: 'MCScanAnchorsAdapter',
80
+ mcscanAnchorsLocation: fileLocation,
81
+ bed1Location,
82
+ bed2Location,
83
+ assemblyNames: [assembly1, assembly2],
84
+ }
85
+ } else if (radioOption === '.anchors.simple') {
86
+ return {
87
+ type: 'MCScanSimpleAnchorsAdapter',
88
+ mcscanSimpleAnchorsLocation: fileLocation,
89
+ bed1Location,
90
+ bed2Location,
91
+ assemblyNames: [assembly1, assembly2],
92
+ }
93
+ } else {
94
+ throw new Error('Unknown type')
95
+ }
96
+ }
97
+
98
+ type Conf = SnapshotIn<AnyConfigurationModel>
99
+
100
+ const OpenTrack = observer(
101
+ ({
102
+ sessionTrackData,
103
+ assembly1,
104
+ assembly2,
105
+ setSessionTrackData,
106
+ }: {
107
+ sessionTrackData: Conf
108
+ assembly1: string
109
+ assembly2: string
110
+ setSessionTrackData: (arg: Conf) => void
111
+ }) => {
112
+ const [bed2Location, setBed2Location] = useState<FileLocation>()
113
+ const [bed1Location, setBed1Location] = useState<FileLocation>()
114
+ const [fileLocation, setFileLocation] = useState<FileLocation>()
115
+ const [value, setValue] = useState('')
116
+ const [error, setError] = useState<unknown>()
117
+ const fileName = getName(fileLocation)
118
+
119
+ const radioOption =
120
+ value || (fileName ? path.extname(stripGz(fileName)) : '')
121
+
122
+ useEffect(() => {
123
+ try {
124
+ if (fileLocation) {
125
+ const fn = fileName ? path.basename(fileName) : 'MyTrack'
126
+ const trackId = `${fn}-${Date.now()}`
127
+ setError(undefined)
128
+
129
+ setSessionTrackData({
130
+ trackId,
131
+ name: fn,
132
+ assemblyNames: [assembly2, assembly1],
133
+ type: 'SyntenyTrack',
134
+ adapter: getAdapter({
135
+ radioOption,
136
+ assembly1,
137
+ assembly2,
138
+ fileLocation,
139
+ bed1Location,
140
+ bed2Location,
141
+ }),
142
+ })
143
+ }
144
+ } catch (e) {
145
+ console.error(e)
146
+ setError(e)
147
+ }
148
+ }, [
149
+ fileName,
150
+ assembly1,
151
+ assembly2,
152
+ bed1Location,
153
+ bed2Location,
154
+ fileLocation,
155
+ radioOption,
156
+ setSessionTrackData,
157
+ ])
158
+ return (
159
+ <Paper style={{ padding: 12 }}>
160
+ {error ? <ErrorMessage error={error} /> : null}
161
+ <Typography style={{ textAlign: 'center' }}>
162
+ Add a .paf, .out (MashMap), .delta (Mummer), .chain, .anchors or
163
+ .anchors.simple (MCScan) file to view in the dotplot. These file types
164
+ can also be gzipped. The first assembly should be the query sequence
165
+ (e.g. left column of the PAF) and the second assembly should be the
166
+ target sequence (e.g. right column of the PAF)
167
+ </Typography>
168
+ <RadioGroup
169
+ value={radioOption}
170
+ onChange={event => setValue(event.target.value)}
171
+ >
172
+ <Grid container justifyContent="center">
173
+ <Grid item>
174
+ <FormControlLabel value=".paf" control={<Radio />} label=".paf" />
175
+ </Grid>
176
+ <Grid item>
177
+ <FormControlLabel value=".out" control={<Radio />} label=".out" />
178
+ </Grid>
179
+ <Grid item>
180
+ <FormControlLabel
181
+ value=".delta"
182
+ control={<Radio />}
183
+ label=".delta"
184
+ />
185
+ </Grid>
186
+ <Grid item>
187
+ <FormControlLabel
188
+ value=".chain"
189
+ control={<Radio />}
190
+ label=".chain"
191
+ />
192
+ </Grid>
193
+ <Grid item>
194
+ <FormControlLabel
195
+ value=".anchors"
196
+ control={<Radio />}
197
+ label=".anchors"
198
+ />
199
+ </Grid>
200
+ <Grid item>
201
+ <FormControlLabel
202
+ value=".anchors.simple"
203
+ control={<Radio />}
204
+ label=".anchors.simple"
205
+ />
206
+ </Grid>
207
+ </Grid>
208
+ </RadioGroup>
209
+ <Grid container justifyContent="center">
210
+ <Grid item>
211
+ {value === '.anchors' || value === '.anchors.simple' ? (
212
+ <div>
213
+ <div style={{ margin: 20 }}>
214
+ Open the {value} and .bed files for both genome assemblies
215
+ from the MCScan (Python version) pipeline{' '}
216
+ <a href="https://github.com/tanghaibao/jcvi/wiki/MCscan-(Python-version)">
217
+ (more info)
218
+ </a>
219
+ </div>
220
+ <div style={{ display: 'flex' }}>
221
+ <div>
222
+ <FileSelector
223
+ name=".anchors file"
224
+ description=""
225
+ location={fileLocation}
226
+ setLocation={loc => setFileLocation(loc)}
227
+ />
228
+ </div>
229
+ <div>
230
+ <FileSelector
231
+ name="genome 1 .bed (left column of anchors file)"
232
+ description=""
233
+ location={bed1Location}
234
+ setLocation={loc => setBed1Location(loc)}
235
+ />
236
+ </div>
237
+ <div>
238
+ <FileSelector
239
+ name="genome 2 .bed (right column of anchors file)"
240
+ description=""
241
+ location={bed2Location}
242
+ setLocation={loc => setBed2Location(loc)}
243
+ />
244
+ </div>
245
+ </div>
246
+ </div>
247
+ ) : (
248
+ <FileSelector
249
+ name={value ? value + ' location' : ''}
250
+ description=""
251
+ location={fileLocation}
252
+ setLocation={loc => setFileLocation(loc)}
253
+ />
254
+ )}
255
+ </Grid>
256
+ </Grid>
257
+ </Paper>
258
+ )
259
+ },
260
+ )
261
+
262
+ export default OpenTrack
@@ -0,0 +1,209 @@
1
+ import React, { useState, useEffect } from 'react'
2
+ import {
3
+ Button,
4
+ Container,
5
+ FormControl,
6
+ FormLabel,
7
+ FormControlLabel,
8
+ Grid,
9
+ Paper,
10
+ Radio,
11
+ RadioGroup,
12
+ Typography,
13
+ } from '@mui/material'
14
+ import { makeStyles } from 'tss-react/mui'
15
+ import { observer } from 'mobx-react'
16
+ import { transaction } from 'mobx'
17
+ import { SnapshotIn } from 'mobx-state-tree'
18
+ import { AnyConfigurationModel } from '@jbrowse/core/configuration'
19
+ import { getSession, isSessionWithAddTracks } from '@jbrowse/core/util'
20
+ import { ErrorMessage, AssemblySelector } from '@jbrowse/core/ui'
21
+
22
+ // locals
23
+ import { DotplotViewModel } from '../model'
24
+ import ImportCustomTrack from './ImportCustomTrack'
25
+ import ImportSyntenyTrackSelector from './ImportSyntenyTrackSelector'
26
+
27
+ const useStyles = makeStyles()(theme => ({
28
+ importFormContainer: {
29
+ padding: theme.spacing(4),
30
+ margin: '0 auto',
31
+ },
32
+ assemblySelector: {
33
+ width: '75%',
34
+ margin: '0 auto',
35
+ },
36
+ }))
37
+
38
+ type Conf = SnapshotIn<AnyConfigurationModel>
39
+
40
+ function TrackSelector({
41
+ setSessionTrackData,
42
+ setShowTrackId,
43
+ sessionTrackData,
44
+ assembly1,
45
+ assembly2,
46
+ model,
47
+ }: {
48
+ sessionTrackData: Conf
49
+ setSessionTrackData: (arg: Conf) => void
50
+ setShowTrackId: (arg?: string) => void
51
+ model: DotplotViewModel
52
+ assembly1: string
53
+ assembly2: string
54
+ }) {
55
+ const [choice, setChoice] = useState('none')
56
+
57
+ useEffect(() => {
58
+ if (choice === 'none') {
59
+ setSessionTrackData(undefined)
60
+ setShowTrackId(undefined)
61
+ }
62
+ }, [choice, setSessionTrackData, setShowTrackId])
63
+ return (
64
+ <>
65
+ <FormControl>
66
+ <FormLabel id="group-label">
67
+ (Optional) Select or add a synteny track
68
+ </FormLabel>
69
+ <RadioGroup
70
+ row
71
+ value={choice}
72
+ onChange={event => setChoice(event.target.value)}
73
+ aria-labelledby="group-label"
74
+ >
75
+ <FormControlLabel value="none" control={<Radio />} label="None" />
76
+ <FormControlLabel
77
+ value="tracklist"
78
+ control={<Radio />}
79
+ label="Existing track"
80
+ />
81
+ <FormControlLabel
82
+ value="custom"
83
+ control={<Radio />}
84
+ label="New track"
85
+ />
86
+ </RadioGroup>
87
+ </FormControl>
88
+ {choice === 'custom' ? (
89
+ <ImportCustomTrack
90
+ setSessionTrackData={setSessionTrackData}
91
+ sessionTrackData={sessionTrackData}
92
+ assembly2={assembly2}
93
+ assembly1={assembly1}
94
+ />
95
+ ) : null}
96
+ {choice === 'tracklist' ? (
97
+ <ImportSyntenyTrackSelector
98
+ model={model}
99
+ assembly1={assembly1}
100
+ assembly2={assembly2}
101
+ setShowTrackId={setShowTrackId}
102
+ />
103
+ ) : null}
104
+ </>
105
+ )
106
+ }
107
+
108
+ const DotplotImportForm = observer(({ model }: { model: DotplotViewModel }) => {
109
+ const { classes } = useStyles()
110
+ const session = getSession(model)
111
+ const { assemblyNames } = session
112
+ const [assembly2, setAssembly2] = useState(assemblyNames[0] || '')
113
+ const [assembly1, setAssembly1] = useState(assemblyNames[0] || '')
114
+ const [error, setError] = useState<unknown>()
115
+ const [sessionTrackData, setSessionTrackData] = useState<Conf>()
116
+ const [showTrackId, setShowTrackId] = useState<string>()
117
+
118
+ function onOpenClick() {
119
+ try {
120
+ if (!isSessionWithAddTracks(session)) {
121
+ return
122
+ }
123
+ setError(undefined)
124
+ model.setError(undefined)
125
+ transaction(() => {
126
+ if (sessionTrackData) {
127
+ session.addTrackConf(sessionTrackData)
128
+ model.toggleTrack(sessionTrackData.trackId)
129
+ } else if (showTrackId) {
130
+ model.showTrack(showTrackId)
131
+ }
132
+
133
+ model.setViews([
134
+ { bpPerPx: 0.1, offsetPx: 0 },
135
+ { bpPerPx: 0.1, offsetPx: 0 },
136
+ ])
137
+ model.setAssemblyNames(assembly2, assembly1)
138
+ })
139
+ } catch (e) {
140
+ console.error(e)
141
+ setError(e)
142
+ }
143
+ }
144
+
145
+ // this is a combination of any displayed error message we have
146
+ const displayError = error || model.error
147
+ return (
148
+ <Container className={classes.importFormContainer}>
149
+ {displayError ? <ErrorMessage error={displayError} /> : null}
150
+ <Grid
151
+ container
152
+ spacing={1}
153
+ justifyContent="center"
154
+ alignItems="center"
155
+ className={classes.assemblySelector}
156
+ >
157
+ <Grid item>
158
+ <Paper style={{ padding: 12 }}>
159
+ <Typography style={{ textAlign: 'center' }}>
160
+ Select assemblies for dotplot view
161
+ </Typography>
162
+ <Grid
163
+ container
164
+ spacing={1}
165
+ justifyContent="center"
166
+ alignItems="center"
167
+ >
168
+ <Grid item>
169
+ <AssemblySelector
170
+ selected={assembly1}
171
+ onChange={val => setAssembly1(val)}
172
+ session={session}
173
+ />
174
+ </Grid>
175
+ <Grid item>
176
+ <AssemblySelector
177
+ selected={assembly2}
178
+ onChange={val => setAssembly2(val)}
179
+ session={session}
180
+ />
181
+ </Grid>
182
+ <Grid item>
183
+ <FormControl>
184
+ <Button
185
+ onClick={onOpenClick}
186
+ variant="contained"
187
+ color="primary"
188
+ >
189
+ Launch
190
+ </Button>
191
+ </FormControl>
192
+ </Grid>
193
+ </Grid>
194
+ </Paper>
195
+ <TrackSelector
196
+ setShowTrackId={setShowTrackId}
197
+ assembly2={assembly2}
198
+ assembly1={assembly1}
199
+ setSessionTrackData={setSessionTrackData}
200
+ sessionTrackData={sessionTrackData}
201
+ model={model}
202
+ />
203
+ </Grid>
204
+ </Grid>
205
+ </Container>
206
+ )
207
+ })
208
+
209
+ export default DotplotImportForm