@jbrowse/plugin-linear-comparative-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 (276) hide show
  1. package/LICENSE +201 -0
  2. package/dist/LGVSyntenyDisplay/configSchemaF.d.ts +52 -0
  3. package/dist/LGVSyntenyDisplay/configSchemaF.js +18 -0
  4. package/dist/LGVSyntenyDisplay/configSchemaF.js.map +1 -0
  5. package/dist/LGVSyntenyDisplay/index.d.ts +3 -0
  6. package/dist/LGVSyntenyDisplay/index.js +24 -0
  7. package/dist/LGVSyntenyDisplay/index.js.map +1 -0
  8. package/dist/LGVSyntenyDisplay/model.d.ts +380 -0
  9. package/dist/LGVSyntenyDisplay/model.js +154 -0
  10. package/dist/LGVSyntenyDisplay/model.js.map +1 -0
  11. package/dist/LaunchLinearSyntenyView.d.ts +2 -0
  12. package/dist/LaunchLinearSyntenyView.js +58 -0
  13. package/dist/LaunchLinearSyntenyView.js.map +1 -0
  14. package/dist/LinearComparativeDisplay/configSchemaF.d.ts +5 -0
  15. package/dist/LinearComparativeDisplay/configSchemaF.js +18 -0
  16. package/dist/LinearComparativeDisplay/configSchemaF.js.map +1 -0
  17. package/dist/LinearComparativeDisplay/index.d.ts +3 -0
  18. package/dist/LinearComparativeDisplay/index.js +24 -0
  19. package/dist/LinearComparativeDisplay/index.js.map +1 -0
  20. package/dist/LinearComparativeDisplay/stateModelFactory.d.ts +275 -0
  21. package/dist/LinearComparativeDisplay/stateModelFactory.js +172 -0
  22. package/dist/LinearComparativeDisplay/stateModelFactory.js.map +1 -0
  23. package/dist/LinearComparativeView/components/Header.d.ts +7 -0
  24. package/dist/LinearComparativeView/components/Header.js +89 -0
  25. package/dist/LinearComparativeView/components/Header.js.map +1 -0
  26. package/dist/LinearComparativeView/components/LinearComparativeView.d.ts +8 -0
  27. package/dist/LinearComparativeView/components/LinearComparativeView.js +99 -0
  28. package/dist/LinearComparativeView/components/LinearComparativeView.js.map +1 -0
  29. package/dist/LinearComparativeView/components/Rubberband.d.ts +9 -0
  30. package/dist/LinearComparativeView/components/Rubberband.js +225 -0
  31. package/dist/LinearComparativeView/components/Rubberband.js.map +1 -0
  32. package/dist/LinearComparativeView/index.d.ts +3 -0
  33. package/dist/LinearComparativeView/index.js +42 -0
  34. package/dist/LinearComparativeView/index.js.map +1 -0
  35. package/dist/LinearComparativeView/model.d.ts +326 -0
  36. package/dist/LinearComparativeView/model.js +346 -0
  37. package/dist/LinearComparativeView/model.js.map +1 -0
  38. package/dist/LinearReadVsRef/LinearReadVsRef.d.ts +7 -0
  39. package/dist/LinearReadVsRef/LinearReadVsRef.js +284 -0
  40. package/dist/LinearReadVsRef/LinearReadVsRef.js.map +1 -0
  41. package/dist/LinearReadVsRef/index.d.ts +2 -0
  42. package/dist/LinearReadVsRef/index.js +55 -0
  43. package/dist/LinearReadVsRef/index.js.map +1 -0
  44. package/dist/LinearSyntenyDisplay/afterAttach.d.ts +2 -0
  45. package/dist/LinearSyntenyDisplay/afterAttach.js +108 -0
  46. package/dist/LinearSyntenyDisplay/afterAttach.js.map +1 -0
  47. package/dist/LinearSyntenyDisplay/components/Component.d.ts +6 -0
  48. package/dist/LinearSyntenyDisplay/components/Component.js +87 -0
  49. package/dist/LinearSyntenyDisplay/components/Component.js.map +1 -0
  50. package/dist/LinearSyntenyDisplay/components/LinearSyntenyRendering.d.ts +6 -0
  51. package/dist/LinearSyntenyDisplay/components/LinearSyntenyRendering.js +160 -0
  52. package/dist/LinearSyntenyDisplay/components/LinearSyntenyRendering.js.map +1 -0
  53. package/dist/LinearSyntenyDisplay/components/SyntenyTooltip.d.ts +7 -0
  54. package/dist/LinearSyntenyDisplay/components/SyntenyTooltip.js +83 -0
  55. package/dist/LinearSyntenyDisplay/components/SyntenyTooltip.js.map +1 -0
  56. package/dist/LinearSyntenyDisplay/components/util.d.ts +27 -0
  57. package/dist/LinearSyntenyDisplay/components/util.js +84 -0
  58. package/dist/LinearSyntenyDisplay/components/util.js.map +1 -0
  59. package/dist/LinearSyntenyDisplay/configSchemaF.d.ts +23 -0
  60. package/dist/LinearSyntenyDisplay/configSchemaF.js +36 -0
  61. package/dist/LinearSyntenyDisplay/configSchemaF.js.map +1 -0
  62. package/dist/LinearSyntenyDisplay/drawSynteny.d.ts +5 -0
  63. package/dist/LinearSyntenyDisplay/drawSynteny.js +235 -0
  64. package/dist/LinearSyntenyDisplay/drawSynteny.js.map +1 -0
  65. package/dist/LinearSyntenyDisplay/index.d.ts +3 -0
  66. package/dist/LinearSyntenyDisplay/index.js +47 -0
  67. package/dist/LinearSyntenyDisplay/index.js.map +1 -0
  68. package/dist/LinearSyntenyDisplay/model.d.ts +333 -0
  69. package/dist/LinearSyntenyDisplay/model.js +179 -0
  70. package/dist/LinearSyntenyDisplay/model.js.map +1 -0
  71. package/dist/LinearSyntenyView/components/ExportSvgDialog.d.ts +8 -0
  72. package/dist/LinearSyntenyView/components/ExportSvgDialog.js +86 -0
  73. package/dist/LinearSyntenyView/components/ExportSvgDialog.js.map +1 -0
  74. package/dist/LinearSyntenyView/components/Icons.d.ts +4 -0
  75. package/dist/LinearSyntenyView/components/Icons.js +19 -0
  76. package/dist/LinearSyntenyView/components/Icons.js.map +1 -0
  77. package/dist/LinearSyntenyView/components/ImportCustomTrack.d.ts +11 -0
  78. package/dist/LinearSyntenyView/components/ImportCustomTrack.js +180 -0
  79. package/dist/LinearSyntenyView/components/ImportCustomTrack.js.map +1 -0
  80. package/dist/LinearSyntenyView/components/ImportForm.d.ts +6 -0
  81. package/dist/LinearSyntenyView/components/ImportForm.js +127 -0
  82. package/dist/LinearSyntenyView/components/ImportForm.js.map +1 -0
  83. package/dist/LinearSyntenyView/components/ImportSyntenyTrackSelector.d.ts +9 -0
  84. package/dist/LinearSyntenyView/components/ImportSyntenyTrackSelector.js +63 -0
  85. package/dist/LinearSyntenyView/components/ImportSyntenyTrackSelector.js.map +1 -0
  86. package/dist/LinearSyntenyView/components/LinearSyntenyView.d.ts +7 -0
  87. package/dist/LinearSyntenyView/components/LinearSyntenyView.js +38 -0
  88. package/dist/LinearSyntenyView/components/LinearSyntenyView.js.map +1 -0
  89. package/dist/LinearSyntenyView/index.d.ts +3 -0
  90. package/dist/LinearSyntenyView/index.js +42 -0
  91. package/dist/LinearSyntenyView/index.js.map +1 -0
  92. package/dist/LinearSyntenyView/model.d.ts +754 -0
  93. package/dist/LinearSyntenyView/model.js +170 -0
  94. package/dist/LinearSyntenyView/model.js.map +1 -0
  95. package/dist/LinearSyntenyView/svgcomponents/SVGBackground.d.ts +6 -0
  96. package/dist/LinearSyntenyView/svgcomponents/SVGBackground.js +13 -0
  97. package/dist/LinearSyntenyView/svgcomponents/SVGBackground.js.map +1 -0
  98. package/dist/LinearSyntenyView/svgcomponents/SVGLinearSyntenyView.d.ts +4 -0
  99. package/dist/LinearSyntenyView/svgcomponents/SVGLinearSyntenyView.js +85 -0
  100. package/dist/LinearSyntenyView/svgcomponents/SVGLinearSyntenyView.js.map +1 -0
  101. package/dist/SyntenyFeatureDetail/SyntenyFeatureDetail.d.ts +5 -0
  102. package/dist/SyntenyFeatureDetail/SyntenyFeatureDetail.js +66 -0
  103. package/dist/SyntenyFeatureDetail/SyntenyFeatureDetail.js.map +1 -0
  104. package/dist/SyntenyFeatureDetail/index.d.ts +3 -0
  105. package/dist/SyntenyFeatureDetail/index.js +58 -0
  106. package/dist/SyntenyFeatureDetail/index.js.map +1 -0
  107. package/dist/SyntenyTrack/configSchema.d.ts +75 -0
  108. package/dist/SyntenyTrack/configSchema.js +16 -0
  109. package/dist/SyntenyTrack/configSchema.js.map +1 -0
  110. package/dist/SyntenyTrack/index.d.ts +3 -0
  111. package/dist/SyntenyTrack/index.js +19 -0
  112. package/dist/SyntenyTrack/index.js.map +1 -0
  113. package/dist/index.d.ts +7 -0
  114. package/dist/index.js +47 -0
  115. package/dist/index.js.map +1 -0
  116. package/dist/util.d.ts +25 -0
  117. package/dist/util.js +77 -0
  118. package/dist/util.js.map +1 -0
  119. package/esm/LGVSyntenyDisplay/configSchemaF.d.ts +52 -0
  120. package/esm/LGVSyntenyDisplay/configSchemaF.js +16 -0
  121. package/esm/LGVSyntenyDisplay/configSchemaF.js.map +1 -0
  122. package/esm/LGVSyntenyDisplay/index.d.ts +3 -0
  123. package/esm/LGVSyntenyDisplay/index.js +19 -0
  124. package/esm/LGVSyntenyDisplay/index.js.map +1 -0
  125. package/esm/LGVSyntenyDisplay/model.d.ts +380 -0
  126. package/esm/LGVSyntenyDisplay/model.js +152 -0
  127. package/esm/LGVSyntenyDisplay/model.js.map +1 -0
  128. package/esm/LaunchLinearSyntenyView.d.ts +2 -0
  129. package/esm/LaunchLinearSyntenyView.js +55 -0
  130. package/esm/LaunchLinearSyntenyView.js.map +1 -0
  131. package/esm/LinearComparativeDisplay/configSchemaF.d.ts +5 -0
  132. package/esm/LinearComparativeDisplay/configSchemaF.js +16 -0
  133. package/esm/LinearComparativeDisplay/configSchemaF.js.map +1 -0
  134. package/esm/LinearComparativeDisplay/index.d.ts +3 -0
  135. package/esm/LinearComparativeDisplay/index.js +19 -0
  136. package/esm/LinearComparativeDisplay/index.js.map +1 -0
  137. package/esm/LinearComparativeDisplay/stateModelFactory.d.ts +275 -0
  138. package/esm/LinearComparativeDisplay/stateModelFactory.js +170 -0
  139. package/esm/LinearComparativeDisplay/stateModelFactory.js.map +1 -0
  140. package/esm/LinearComparativeView/components/Header.d.ts +7 -0
  141. package/esm/LinearComparativeView/components/Header.js +61 -0
  142. package/esm/LinearComparativeView/components/Header.js.map +1 -0
  143. package/esm/LinearComparativeView/components/LinearComparativeView.d.ts +8 -0
  144. package/esm/LinearComparativeView/components/LinearComparativeView.js +94 -0
  145. package/esm/LinearComparativeView/components/LinearComparativeView.js.map +1 -0
  146. package/esm/LinearComparativeView/components/Rubberband.d.ts +9 -0
  147. package/esm/LinearComparativeView/components/Rubberband.js +200 -0
  148. package/esm/LinearComparativeView/components/Rubberband.js.map +1 -0
  149. package/esm/LinearComparativeView/index.d.ts +3 -0
  150. package/esm/LinearComparativeView/index.js +14 -0
  151. package/esm/LinearComparativeView/index.js.map +1 -0
  152. package/esm/LinearComparativeView/model.d.ts +326 -0
  153. package/esm/LinearComparativeView/model.js +318 -0
  154. package/esm/LinearComparativeView/model.js.map +1 -0
  155. package/esm/LinearReadVsRef/LinearReadVsRef.d.ts +7 -0
  156. package/esm/LinearReadVsRef/LinearReadVsRef.js +258 -0
  157. package/esm/LinearReadVsRef/LinearReadVsRef.js.map +1 -0
  158. package/esm/LinearReadVsRef/index.d.ts +2 -0
  159. package/esm/LinearReadVsRef/index.js +49 -0
  160. package/esm/LinearReadVsRef/index.js.map +1 -0
  161. package/esm/LinearSyntenyDisplay/afterAttach.d.ts +2 -0
  162. package/esm/LinearSyntenyDisplay/afterAttach.js +104 -0
  163. package/esm/LinearSyntenyDisplay/afterAttach.js.map +1 -0
  164. package/esm/LinearSyntenyDisplay/components/Component.d.ts +6 -0
  165. package/esm/LinearSyntenyDisplay/components/Component.js +59 -0
  166. package/esm/LinearSyntenyDisplay/components/Component.js.map +1 -0
  167. package/esm/LinearSyntenyDisplay/components/LinearSyntenyRendering.d.ts +6 -0
  168. package/esm/LinearSyntenyDisplay/components/LinearSyntenyRendering.js +132 -0
  169. package/esm/LinearSyntenyDisplay/components/LinearSyntenyRendering.js.map +1 -0
  170. package/esm/LinearSyntenyDisplay/components/SyntenyTooltip.d.ts +7 -0
  171. package/esm/LinearSyntenyDisplay/components/SyntenyTooltip.js +58 -0
  172. package/esm/LinearSyntenyDisplay/components/SyntenyTooltip.js.map +1 -0
  173. package/esm/LinearSyntenyDisplay/components/util.d.ts +27 -0
  174. package/esm/LinearSyntenyDisplay/components/util.js +77 -0
  175. package/esm/LinearSyntenyDisplay/components/util.js.map +1 -0
  176. package/esm/LinearSyntenyDisplay/configSchemaF.d.ts +23 -0
  177. package/esm/LinearSyntenyDisplay/configSchemaF.js +31 -0
  178. package/esm/LinearSyntenyDisplay/configSchemaF.js.map +1 -0
  179. package/esm/LinearSyntenyDisplay/drawSynteny.d.ts +5 -0
  180. package/esm/LinearSyntenyDisplay/drawSynteny.js +229 -0
  181. package/esm/LinearSyntenyDisplay/drawSynteny.js.map +1 -0
  182. package/esm/LinearSyntenyDisplay/index.d.ts +3 -0
  183. package/esm/LinearSyntenyDisplay/index.js +19 -0
  184. package/esm/LinearSyntenyDisplay/index.js.map +1 -0
  185. package/esm/LinearSyntenyDisplay/model.d.ts +333 -0
  186. package/esm/LinearSyntenyDisplay/model.js +151 -0
  187. package/esm/LinearSyntenyDisplay/model.js.map +1 -0
  188. package/esm/LinearSyntenyView/components/ExportSvgDialog.d.ts +8 -0
  189. package/esm/LinearSyntenyView/components/ExportSvgDialog.js +60 -0
  190. package/esm/LinearSyntenyView/components/ExportSvgDialog.js.map +1 -0
  191. package/esm/LinearSyntenyView/components/Icons.d.ts +4 -0
  192. package/esm/LinearSyntenyView/components/Icons.js +11 -0
  193. package/esm/LinearSyntenyView/components/Icons.js.map +1 -0
  194. package/esm/LinearSyntenyView/components/ImportCustomTrack.d.ts +11 -0
  195. package/esm/LinearSyntenyView/components/ImportCustomTrack.js +152 -0
  196. package/esm/LinearSyntenyView/components/ImportCustomTrack.js.map +1 -0
  197. package/esm/LinearSyntenyView/components/ImportForm.d.ts +6 -0
  198. package/esm/LinearSyntenyView/components/ImportForm.js +99 -0
  199. package/esm/LinearSyntenyView/components/ImportForm.js.map +1 -0
  200. package/esm/LinearSyntenyView/components/ImportSyntenyTrackSelector.d.ts +9 -0
  201. package/esm/LinearSyntenyView/components/ImportSyntenyTrackSelector.js +38 -0
  202. package/esm/LinearSyntenyView/components/ImportSyntenyTrackSelector.js.map +1 -0
  203. package/esm/LinearSyntenyView/components/LinearSyntenyView.d.ts +7 -0
  204. package/esm/LinearSyntenyView/components/LinearSyntenyView.js +10 -0
  205. package/esm/LinearSyntenyView/components/LinearSyntenyView.js.map +1 -0
  206. package/esm/LinearSyntenyView/index.d.ts +3 -0
  207. package/esm/LinearSyntenyView/index.js +14 -0
  208. package/esm/LinearSyntenyView/index.js.map +1 -0
  209. package/esm/LinearSyntenyView/model.d.ts +754 -0
  210. package/esm/LinearSyntenyView/model.js +141 -0
  211. package/esm/LinearSyntenyView/model.js.map +1 -0
  212. package/esm/LinearSyntenyView/svgcomponents/SVGBackground.d.ts +6 -0
  213. package/esm/LinearSyntenyView/svgcomponents/SVGBackground.js +7 -0
  214. package/esm/LinearSyntenyView/svgcomponents/SVGBackground.js.map +1 -0
  215. package/esm/LinearSyntenyView/svgcomponents/SVGLinearSyntenyView.d.ts +4 -0
  216. package/esm/LinearSyntenyView/svgcomponents/SVGLinearSyntenyView.js +78 -0
  217. package/esm/LinearSyntenyView/svgcomponents/SVGLinearSyntenyView.js.map +1 -0
  218. package/esm/SyntenyFeatureDetail/SyntenyFeatureDetail.d.ts +5 -0
  219. package/esm/SyntenyFeatureDetail/SyntenyFeatureDetail.js +38 -0
  220. package/esm/SyntenyFeatureDetail/SyntenyFeatureDetail.js.map +1 -0
  221. package/esm/SyntenyFeatureDetail/index.d.ts +3 -0
  222. package/esm/SyntenyFeatureDetail/index.js +30 -0
  223. package/esm/SyntenyFeatureDetail/index.js.map +1 -0
  224. package/esm/SyntenyTrack/configSchema.d.ts +75 -0
  225. package/esm/SyntenyTrack/configSchema.js +14 -0
  226. package/esm/SyntenyTrack/configSchema.js.map +1 -0
  227. package/esm/SyntenyTrack/index.d.ts +3 -0
  228. package/esm/SyntenyTrack/index.js +14 -0
  229. package/esm/SyntenyTrack/index.js.map +1 -0
  230. package/esm/index.d.ts +7 -0
  231. package/esm/index.js +41 -0
  232. package/esm/index.js.map +1 -0
  233. package/esm/util.d.ts +25 -0
  234. package/esm/util.js +69 -0
  235. package/esm/util.js.map +1 -0
  236. package/package.json +67 -0
  237. package/src/LGVSyntenyDisplay/configSchemaF.ts +22 -0
  238. package/src/LGVSyntenyDisplay/index.ts +20 -0
  239. package/src/LGVSyntenyDisplay/model.ts +177 -0
  240. package/src/LaunchLinearSyntenyView.ts +86 -0
  241. package/src/LinearComparativeDisplay/configSchemaF.ts +22 -0
  242. package/src/LinearComparativeDisplay/index.ts +21 -0
  243. package/src/LinearComparativeDisplay/stateModelFactory.ts +212 -0
  244. package/src/LinearComparativeView/components/Header.tsx +103 -0
  245. package/src/LinearComparativeView/components/LinearComparativeView.tsx +152 -0
  246. package/src/LinearComparativeView/components/Rubberband.tsx +329 -0
  247. package/src/LinearComparativeView/index.ts +15 -0
  248. package/src/LinearComparativeView/model.ts +395 -0
  249. package/src/LinearReadVsRef/LinearReadVsRef.tsx +360 -0
  250. package/src/LinearReadVsRef/index.ts +58 -0
  251. package/src/LinearSyntenyDisplay/afterAttach.ts +149 -0
  252. package/src/LinearSyntenyDisplay/components/Component.tsx +75 -0
  253. package/src/LinearSyntenyDisplay/components/LinearSyntenyRendering.tsx +200 -0
  254. package/src/LinearSyntenyDisplay/components/SyntenyTooltip.tsx +82 -0
  255. package/src/LinearSyntenyDisplay/components/util.ts +142 -0
  256. package/src/LinearSyntenyDisplay/configSchemaF.ts +38 -0
  257. package/src/LinearSyntenyDisplay/drawSynteny.ts +266 -0
  258. package/src/LinearSyntenyDisplay/index.ts +21 -0
  259. package/src/LinearSyntenyDisplay/model.ts +187 -0
  260. package/src/LinearSyntenyView/components/ExportSvgDialog.tsx +148 -0
  261. package/src/LinearSyntenyView/components/Icons.tsx +24 -0
  262. package/src/LinearSyntenyView/components/ImportCustomTrack.tsx +262 -0
  263. package/src/LinearSyntenyView/components/ImportForm.tsx +221 -0
  264. package/src/LinearSyntenyView/components/ImportSyntenyTrackSelector.tsx +82 -0
  265. package/src/LinearSyntenyView/components/LinearSyntenyView.tsx +20 -0
  266. package/src/LinearSyntenyView/index.ts +15 -0
  267. package/src/LinearSyntenyView/model.test.ts +1605 -0
  268. package/src/LinearSyntenyView/model.ts +169 -0
  269. package/src/LinearSyntenyView/svgcomponents/SVGBackground.tsx +21 -0
  270. package/src/LinearSyntenyView/svgcomponents/SVGLinearSyntenyView.tsx +176 -0
  271. package/src/SyntenyFeatureDetail/SyntenyFeatureDetail.tsx +64 -0
  272. package/src/SyntenyFeatureDetail/index.ts +36 -0
  273. package/src/SyntenyTrack/configSchema.ts +23 -0
  274. package/src/SyntenyTrack/index.tsx +15 -0
  275. package/src/index.tsx +42 -0
  276. package/src/util.ts +124 -0
@@ -0,0 +1,200 @@
1
+ import React, { useState, useCallback } from 'react'
2
+ import { observer } from 'mobx-react'
3
+ import {
4
+ assembleLocString,
5
+ getContainingView,
6
+ getSession,
7
+ isSessionModelWithWidgets,
8
+ } from '@jbrowse/core/util'
9
+
10
+ // locals
11
+ import SyntenyTooltip from './SyntenyTooltip'
12
+ import { LinearSyntenyDisplayModel } from '../model'
13
+ import { getId, MAX_COLOR_RANGE } from '../drawSynteny'
14
+
15
+ export default observer(function LinearSyntenyRendering({
16
+ model,
17
+ }: {
18
+ model: LinearSyntenyDisplayModel
19
+ }) {
20
+ const highResolutionScaling = 1
21
+ const view = getContainingView(model)
22
+ const height = view.middleComparativeHeight
23
+ const width = view.width
24
+
25
+ const [tooltip, setTooltip] = useState('')
26
+ const [currX, setCurrX] = useState<number>()
27
+ const [currY, setCurrY] = useState<number>()
28
+
29
+ // these useCallbacks avoid new refs from being created on any mouseover, etc.
30
+ const k1 = useCallback(
31
+ (ref: HTMLCanvasElement) => model.setMouseoverCanvasRef(ref),
32
+ // eslint-disable-next-line react-hooks/exhaustive-deps
33
+ [model, height, width],
34
+ )
35
+ const k2 = useCallback(
36
+ (ref: HTMLCanvasElement) => model.setMainCanvasRef(ref),
37
+ // eslint-disable-next-line react-hooks/exhaustive-deps
38
+ [model, height, width],
39
+ )
40
+ const k3 = useCallback(
41
+ (ref: HTMLCanvasElement) => model.setClickMapCanvasRef(ref),
42
+ // eslint-disable-next-line react-hooks/exhaustive-deps
43
+ [model, height, width],
44
+ )
45
+ const k4 = useCallback(
46
+ (ref: HTMLCanvasElement) => model.setCigarClickMapCanvasRef(ref),
47
+ // eslint-disable-next-line react-hooks/exhaustive-deps
48
+ [model, height, width],
49
+ )
50
+
51
+ return (
52
+ <div style={{ position: 'relative' }}>
53
+ <canvas
54
+ ref={k1}
55
+ width={width}
56
+ height={height}
57
+ style={{ width, height, position: 'absolute', pointerEvents: 'none' }}
58
+ />
59
+ <canvas
60
+ ref={k2}
61
+ onMouseMove={event => {
62
+ const ref1 = model.clickMapCanvas
63
+ const ref2 = model.cigarClickMapCanvas
64
+ if (!ref1 || !ref2) {
65
+ return
66
+ }
67
+ const rect = ref1.getBoundingClientRect()
68
+ const ctx1 = ref1.getContext('2d')
69
+ const ctx2 = ref2.getContext('2d')
70
+ if (!ctx1 || !ctx2) {
71
+ return
72
+ }
73
+ const { clientX, clientY } = event
74
+ const x = clientX - rect.left
75
+ const y = clientY - rect.top
76
+ setCurrX(clientX)
77
+ setCurrY(clientY)
78
+ const [r1, g1, b1] = ctx1.getImageData(x, y, 1, 1).data
79
+ const [r2, g2, b2] = ctx2.getImageData(x, y, 1, 1).data
80
+ const unitMultiplier = Math.floor(MAX_COLOR_RANGE / model.numFeats)
81
+ const id = getId(r1, g1, b1, unitMultiplier)
82
+ model.setMouseoverId(model.featPositions[id]?.f.id())
83
+ if (id === -1) {
84
+ setTooltip('')
85
+ } else if (model.featPositions[id]) {
86
+ const { f, cigar } = model.featPositions[id]
87
+ // @ts-expect-error
88
+ const f1 = f.toJSON() as {
89
+ refName: string
90
+ start: number
91
+ end: number
92
+ strand?: number
93
+ assemblyName: string
94
+ identity?: number
95
+ name?: string
96
+ mate: {
97
+ start: number
98
+ end: number
99
+ refName: string
100
+ name: string
101
+ }
102
+ }
103
+ const f2 = f1.mate
104
+ const unitMultiplier2 = Math.floor(MAX_COLOR_RANGE / cigar.length)
105
+ const cigarIdx = getId(r2, g2, b2, unitMultiplier2)
106
+ const l1 = f1.end - f1.start
107
+ const l2 = f2.end - f2.start
108
+ const identity = f1.identity
109
+ const n1 = f1.name
110
+ const n2 = f2.name
111
+ const tooltip = [
112
+ `Loc1: ${assembleLocString(f1)}`,
113
+ `Loc2: ${assembleLocString(f2)}`,
114
+ `Inverted: ${f1.strand === -1}`,
115
+ `Query len: ${l1}`,
116
+ `Target len: ${l2}`,
117
+ ]
118
+ if (identity) {
119
+ tooltip.push(`Identity: ${identity}`)
120
+ }
121
+
122
+ if (cigar[cigarIdx]) {
123
+ tooltip.push(
124
+ `CIGAR operator: ${cigar[cigarIdx]}${cigar[cigarIdx + 1]}`,
125
+ )
126
+ }
127
+ if (n1 && n2) {
128
+ tooltip.push(`Name 1: ${n1}`, `Name 2: ${n2}`)
129
+ }
130
+ setTooltip(tooltip.join('<br/>'))
131
+ }
132
+ }}
133
+ onMouseLeave={() => model.setMouseoverId(undefined)}
134
+ onClick={event => {
135
+ const ref1 = model.clickMapCanvas
136
+ const ref2 = model.cigarClickMapCanvas
137
+ if (!ref1 || !ref2) {
138
+ return
139
+ }
140
+ const rect = ref1.getBoundingClientRect()
141
+ const ctx1 = ref1.getContext('2d')
142
+ const ctx2 = ref2.getContext('2d')
143
+ if (!ctx1 || !ctx2) {
144
+ return
145
+ }
146
+ const x = event.clientX - rect.left
147
+ const y = event.clientY - rect.top
148
+ const [r1, g1, b1] = ctx1.getImageData(x, y, 1, 1).data
149
+ const unitMultiplier = Math.floor(MAX_COLOR_RANGE / model.numFeats)
150
+ const id = getId(r1, g1, b1, unitMultiplier)
151
+ const f = model.featPositions[id]
152
+ if (!f) {
153
+ return
154
+ }
155
+ model.setClickId(f.f.id())
156
+ const session = getSession(model)
157
+ if (isSessionModelWithWidgets(session)) {
158
+ session.showWidget(
159
+ session.addWidget('SyntenyFeatureWidget', 'syntenyFeature', {
160
+ featureData: {
161
+ feature1: f.f.toJSON(),
162
+ feature2: f.f.get('mate'),
163
+ },
164
+ }),
165
+ )
166
+ }
167
+ }}
168
+ data-testid="synteny_canvas"
169
+ style={{ width, height, position: 'absolute' }}
170
+ width={width * highResolutionScaling}
171
+ height={height * highResolutionScaling}
172
+ />
173
+ <canvas
174
+ ref={k3}
175
+ style={{
176
+ imageRendering: 'pixelated',
177
+ pointerEvents: 'none',
178
+ visibility: 'hidden',
179
+ position: 'absolute',
180
+ }}
181
+ width={width}
182
+ height={height}
183
+ />
184
+ <canvas
185
+ ref={k4}
186
+ style={{
187
+ imageRendering: 'pixelated',
188
+ pointerEvents: 'none',
189
+ visibility: 'hidden',
190
+ position: 'absolute',
191
+ }}
192
+ width={width}
193
+ height={height}
194
+ />
195
+ {model.mouseoverId && tooltip && currX && currY ? (
196
+ <SyntenyTooltip x={currX} y={currY} title={tooltip} />
197
+ ) : null}
198
+ </div>
199
+ )
200
+ })
@@ -0,0 +1,82 @@
1
+ import React, { useMemo, useState } from 'react'
2
+ import { observer } from 'mobx-react'
3
+ import { Portal, alpha } from '@mui/material'
4
+ import { makeStyles } from 'tss-react/mui'
5
+ import { usePopper } from 'react-popper'
6
+ import { SanitizedHTML } from '@jbrowse/core/ui'
7
+
8
+ function round(value: number) {
9
+ return Math.round(value * 1e5) / 1e5
10
+ }
11
+
12
+ const useStyles = makeStyles()(theme => ({
13
+ // these styles come from
14
+ // https://github.com/mui-org/material-ui/blob/master/packages/material-ui/src/Tooltip/Tooltip.js
15
+ tooltip: {
16
+ position: 'absolute',
17
+ pointerEvents: 'none',
18
+ backgroundColor: alpha(theme.palette.grey[700], 0.9),
19
+ borderRadius: theme.shape.borderRadius,
20
+ color: theme.palette.common.white,
21
+ fontFamily: theme.typography.fontFamily,
22
+ padding: '4px 8px',
23
+ fontSize: theme.typography.pxToRem(12),
24
+ lineHeight: `${round(14 / 10)}em`,
25
+ maxWidth: 300,
26
+ wordWrap: 'break-word',
27
+ },
28
+ }))
29
+
30
+ const SyntenyTooltip = observer(function ({
31
+ x,
32
+ y,
33
+ title,
34
+ }: {
35
+ x: number
36
+ y: number
37
+ title: string
38
+ }) {
39
+ const [width, setWidth] = useState(0)
40
+ const [anchorEl, setAnchorEl] = useState<HTMLDivElement | null>(null)
41
+ const { classes } = useStyles()
42
+
43
+ // must be memoized a la https://github.com/popperjs/react-popper/issues/391
44
+ const virtElement = useMemo(
45
+ () => ({
46
+ getBoundingClientRect: () => {
47
+ return {
48
+ top: y,
49
+ left: x + width / 2,
50
+ bottom: y,
51
+ right: x,
52
+ width: 0,
53
+ height: 0,
54
+ x,
55
+ y,
56
+ toJSON() {},
57
+ }
58
+ },
59
+ }),
60
+ [x, y, width],
61
+ )
62
+ const { styles, attributes } = usePopper(virtElement, anchorEl)
63
+
64
+ return title ? (
65
+ <Portal>
66
+ <div
67
+ ref={ref => {
68
+ setWidth(ref?.getBoundingClientRect().width || 0)
69
+ setAnchorEl(ref)
70
+ }}
71
+ className={classes.tooltip}
72
+ // zIndex needed to go over widget drawer
73
+ style={{ ...styles.popper, zIndex: 100000 }}
74
+ {...attributes.popper}
75
+ >
76
+ <SanitizedHTML html={title} />
77
+ </div>
78
+ </Portal>
79
+ ) : null
80
+ })
81
+
82
+ export default SyntenyTooltip
@@ -0,0 +1,142 @@
1
+ import { doesIntersect2, Feature } from '@jbrowse/core/util'
2
+
3
+ interface Pos {
4
+ offsetPx: number
5
+ }
6
+
7
+ interface FeatPos {
8
+ p11: Pos
9
+ p12: Pos
10
+ p21: Pos
11
+ p22: Pos
12
+ f: Feature
13
+ cigar: string[]
14
+ }
15
+
16
+ export function drawMatchSimple({
17
+ feature,
18
+ ctx,
19
+ offsets,
20
+ cb,
21
+ height,
22
+ drawCurves,
23
+ oobLimit,
24
+ viewWidth,
25
+ hideTiny,
26
+ }: {
27
+ feature: FeatPos
28
+ ctx: CanvasRenderingContext2D
29
+ offsets: number[]
30
+ oobLimit: number
31
+ viewWidth: number
32
+ cb: (ctx: CanvasRenderingContext2D) => void
33
+ height: number
34
+ drawCurves?: boolean
35
+ hideTiny?: boolean
36
+ }) {
37
+ const { p11, p12, p21, p22 } = feature
38
+
39
+ const x11 = p11.offsetPx - offsets[0]
40
+ const x12 = p12.offsetPx - offsets[0]
41
+ const x21 = p21.offsetPx - offsets[1]
42
+ const x22 = p22.offsetPx - offsets[1]
43
+
44
+ const l1 = Math.abs(x12 - x11)
45
+ const l2 = Math.abs(x22 - x21)
46
+ const y1 = 0
47
+ const y2 = height
48
+ const mid = (y2 - y1) / 2
49
+ const minX = Math.min(x21, x22)
50
+ const maxX = Math.max(x21, x22)
51
+
52
+ if (!doesIntersect2(minX, maxX, -oobLimit, viewWidth + oobLimit)) {
53
+ return
54
+ }
55
+
56
+ // drawing a line if the results are thin: drawing a line results in much
57
+ // less pixellation than filling in a thin polygon
58
+ if (l1 <= 1 && l2 <= 1) {
59
+ // hideTiny can be used to avoid drawing mouseover for thin lines in this
60
+ // case
61
+ if (!hideTiny) {
62
+ ctx.beginPath()
63
+ ctx.moveTo(x11, y1)
64
+ if (drawCurves) {
65
+ ctx.bezierCurveTo(x11, mid, x21, mid, x21, y2)
66
+ } else {
67
+ ctx.lineTo(x21, y2)
68
+ }
69
+ ctx.stroke()
70
+ }
71
+ } else {
72
+ draw(ctx, x11, x12, y1, x22, x21, y2, mid, drawCurves)
73
+ cb(ctx)
74
+ }
75
+ }
76
+
77
+ export function draw(
78
+ ctx: CanvasRenderingContext2D,
79
+ x1: number,
80
+ x2: number,
81
+ y1: number,
82
+ x3: number,
83
+ x4: number,
84
+ y2: number,
85
+ mid: number,
86
+ drawCurves?: boolean,
87
+ ) {
88
+ if (drawCurves) {
89
+ drawBezierBox(ctx, x1, x2, y1, x3, x4, y2, mid)
90
+ } else {
91
+ drawBox(ctx, x1, x2, y1, x3, x4, y2)
92
+ }
93
+ }
94
+
95
+ export function drawBox(
96
+ ctx: CanvasRenderingContext2D,
97
+ x1: number,
98
+ x2: number,
99
+ y1: number,
100
+ x3: number,
101
+ x4: number,
102
+ y2: number,
103
+ ) {
104
+ ctx.beginPath()
105
+ ctx.moveTo(x1, y1)
106
+ ctx.lineTo(x2, y1)
107
+ ctx.lineTo(x3, y2)
108
+ ctx.lineTo(x4, y2)
109
+ ctx.closePath()
110
+ ctx.fill()
111
+ }
112
+
113
+ export function drawBezierBox(
114
+ ctx: CanvasRenderingContext2D,
115
+ x1: number,
116
+ x2: number,
117
+ y1: number,
118
+ x3: number,
119
+ x4: number,
120
+ y2: number,
121
+ mid: number,
122
+ ) {
123
+ const len1 = Math.abs(x1 - x2)
124
+ const len2 = Math.abs(x1 - x2)
125
+
126
+ // heuristic to not draw hourglass inversions with bezier curves when they
127
+ // are thin and far apart because it results in areas that are not drawn well
128
+ // demo https://codesandbox.io/s/fast-glitter-q3b1or?file=/src/index.js
129
+ if (len1 < 5 && len2 < 5 && x2 < x1 && Math.abs(x1 - x3) > 100) {
130
+ const tmp = x1
131
+ x1 = x2
132
+ x2 = tmp
133
+ }
134
+ ctx.beginPath()
135
+ ctx.moveTo(x1, y1)
136
+ ctx.lineTo(x2, y1)
137
+ ctx.bezierCurveTo(x2, mid, x3, mid, x3, y2)
138
+ ctx.lineTo(x4, y2)
139
+ ctx.bezierCurveTo(x4, mid, x1, mid, x1, y1)
140
+ ctx.closePath()
141
+ ctx.fill()
142
+ }
@@ -0,0 +1,38 @@
1
+ import { ConfigurationSchema } from '@jbrowse/core/configuration'
2
+ import PluginManager from '@jbrowse/core/PluginManager'
3
+ import baseConfigFactory from '../LinearComparativeDisplay/configSchemaF'
4
+
5
+ /**
6
+ * #config LinearSyntenyDisplay
7
+ */
8
+ function configSchemaFactory(pluginManager: PluginManager) {
9
+ return ConfigurationSchema(
10
+ 'LinearSyntenyDisplay',
11
+ {
12
+ /**
13
+ * #slot
14
+ * currently unused
15
+ */
16
+ trackIds: {
17
+ type: 'stringArray',
18
+ defaultValue: [],
19
+ },
20
+
21
+ /**
22
+ * #slot
23
+ * currently unused
24
+ */
25
+ middle: { type: 'boolean', defaultValue: true },
26
+ },
27
+ {
28
+ /**
29
+ * #baseConfiguration
30
+ * this refers to the LinearComparativeDisplay
31
+ */
32
+ baseConfiguration: baseConfigFactory(pluginManager),
33
+ explicitlyTyped: true,
34
+ },
35
+ )
36
+ }
37
+
38
+ export default configSchemaFactory