@jbrowse/plugin-linear-genome-view 1.7.9 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/dist/BaseLinearDisplay/components/BaseLinearDisplay.d.ts +1 -5
  2. package/dist/BaseLinearDisplay/components/BaseLinearDisplay.js +118 -226
  3. package/dist/BaseLinearDisplay/components/BaseLinearDisplay.js.map +1 -0
  4. package/dist/BaseLinearDisplay/components/Block.js +53 -74
  5. package/dist/BaseLinearDisplay/components/Block.js.map +1 -0
  6. package/dist/BaseLinearDisplay/components/LinearBlocks.d.ts +11 -1
  7. package/dist/BaseLinearDisplay/components/LinearBlocks.js +64 -103
  8. package/dist/BaseLinearDisplay/components/LinearBlocks.js.map +1 -0
  9. package/dist/BaseLinearDisplay/components/ServerSideRenderedBlockContent.js +145 -175
  10. package/dist/BaseLinearDisplay/components/ServerSideRenderedBlockContent.js.map +1 -0
  11. package/dist/BaseLinearDisplay/components/Tooltip.d.ts +8 -0
  12. package/dist/BaseLinearDisplay/components/Tooltip.js +118 -0
  13. package/dist/BaseLinearDisplay/components/Tooltip.js.map +1 -0
  14. package/dist/BaseLinearDisplay/index.js +13 -40
  15. package/dist/BaseLinearDisplay/index.js.map +1 -0
  16. package/dist/BaseLinearDisplay/models/BaseLinearDisplayModel.d.ts +20 -15
  17. package/dist/BaseLinearDisplay/models/BaseLinearDisplayModel.js +605 -683
  18. package/dist/BaseLinearDisplay/models/BaseLinearDisplayModel.js.map +1 -0
  19. package/dist/BaseLinearDisplay/models/baseLinearDisplayConfigSchema.js +15 -22
  20. package/dist/BaseLinearDisplay/models/baseLinearDisplayConfigSchema.js.map +1 -0
  21. package/dist/BaseLinearDisplay/models/serverSideRenderedBlock.d.ts +7 -8
  22. package/dist/BaseLinearDisplay/models/serverSideRenderedBlock.js +266 -312
  23. package/dist/BaseLinearDisplay/models/serverSideRenderedBlock.js.map +1 -0
  24. package/dist/LinearBareDisplay/configSchema.js +11 -17
  25. package/dist/LinearBareDisplay/configSchema.js.map +1 -0
  26. package/dist/LinearBareDisplay/index.js +7 -20
  27. package/dist/LinearBareDisplay/index.js.map +1 -0
  28. package/dist/LinearBareDisplay/model.d.ts +16 -14
  29. package/dist/LinearBareDisplay/model.js +36 -42
  30. package/dist/LinearBareDisplay/model.js.map +1 -0
  31. package/dist/LinearBasicDisplay/components/SetMaxHeight.d.ts +1 -1
  32. package/dist/LinearBasicDisplay/components/SetMaxHeight.js +76 -85
  33. package/dist/LinearBasicDisplay/components/SetMaxHeight.js.map +1 -0
  34. package/dist/LinearBasicDisplay/configSchema.js +15 -23
  35. package/dist/LinearBasicDisplay/configSchema.js.map +1 -0
  36. package/dist/LinearBasicDisplay/index.js +10 -22
  37. package/dist/LinearBasicDisplay/index.js.map +1 -0
  38. package/dist/LinearBasicDisplay/model.d.ts +20 -15
  39. package/dist/LinearBasicDisplay/model.js +180 -159
  40. package/dist/LinearBasicDisplay/model.js.map +1 -0
  41. package/dist/LinearGenomeView/components/CenterLine.d.ts +2 -8
  42. package/dist/LinearGenomeView/components/CenterLine.js +60 -74
  43. package/dist/LinearGenomeView/components/CenterLine.js.map +1 -0
  44. package/dist/LinearGenomeView/components/ExportSvgDialog.js +141 -141
  45. package/dist/LinearGenomeView/components/ExportSvgDialog.js.map +1 -0
  46. package/dist/LinearGenomeView/components/Header.js +70 -123
  47. package/dist/LinearGenomeView/components/Header.js.map +1 -0
  48. package/dist/LinearGenomeView/components/HelpDialog.d.ts +0 -1
  49. package/dist/LinearGenomeView/components/HelpDialog.js +62 -45
  50. package/dist/LinearGenomeView/components/HelpDialog.js.map +1 -0
  51. package/dist/LinearGenomeView/components/ImportForm.js +223 -320
  52. package/dist/LinearGenomeView/components/ImportForm.js.map +1 -0
  53. package/dist/LinearGenomeView/components/LinearGenomeView.js +64 -120
  54. package/dist/LinearGenomeView/components/LinearGenomeView.js.map +1 -0
  55. package/dist/LinearGenomeView/components/LinearGenomeViewSvg.js +198 -337
  56. package/dist/LinearGenomeView/components/LinearGenomeViewSvg.js.map +1 -0
  57. package/dist/LinearGenomeView/components/MiniControls.js +64 -78
  58. package/dist/LinearGenomeView/components/MiniControls.js.map +1 -0
  59. package/dist/LinearGenomeView/components/OverviewRubberBand.js +226 -293
  60. package/dist/LinearGenomeView/components/OverviewRubberBand.js.map +1 -0
  61. package/dist/LinearGenomeView/components/OverviewScaleBar.d.ts +24 -8
  62. package/dist/LinearGenomeView/components/OverviewScaleBar.js +277 -365
  63. package/dist/LinearGenomeView/components/OverviewScaleBar.js.map +1 -0
  64. package/dist/LinearGenomeView/components/RefNameAutocomplete.d.ts +1 -1
  65. package/dist/LinearGenomeView/components/RefNameAutocomplete.js +237 -324
  66. package/dist/LinearGenomeView/components/RefNameAutocomplete.js.map +1 -0
  67. package/dist/LinearGenomeView/components/RubberBand.js +229 -296
  68. package/dist/LinearGenomeView/components/RubberBand.js.map +1 -0
  69. package/dist/LinearGenomeView/components/Ruler.js +45 -90
  70. package/dist/LinearGenomeView/components/Ruler.js.map +1 -0
  71. package/dist/LinearGenomeView/components/ScaleBar.d.ts +8 -399
  72. package/dist/LinearGenomeView/components/ScaleBar.js +121 -167
  73. package/dist/LinearGenomeView/components/ScaleBar.js.map +1 -0
  74. package/dist/LinearGenomeView/components/SearchBox.js +158 -205
  75. package/dist/LinearGenomeView/components/SearchBox.js.map +1 -0
  76. package/dist/LinearGenomeView/components/SearchResultsDialog.d.ts +0 -1
  77. package/dist/LinearGenomeView/components/SearchResultsDialog.js +105 -150
  78. package/dist/LinearGenomeView/components/SearchResultsDialog.js.map +1 -0
  79. package/dist/LinearGenomeView/components/SequenceDialog.js +219 -272
  80. package/dist/LinearGenomeView/components/SequenceDialog.js.map +1 -0
  81. package/dist/LinearGenomeView/components/TrackContainer.js +116 -156
  82. package/dist/LinearGenomeView/components/TrackContainer.js.map +1 -0
  83. package/dist/LinearGenomeView/components/TrackLabel.d.ts +6 -42
  84. package/dist/LinearGenomeView/components/TrackLabel.js +115 -150
  85. package/dist/LinearGenomeView/components/TrackLabel.js.map +1 -0
  86. package/dist/LinearGenomeView/components/TracksContainer.d.ts +1 -1
  87. package/dist/LinearGenomeView/components/TracksContainer.js +172 -199
  88. package/dist/LinearGenomeView/components/TracksContainer.js.map +1 -0
  89. package/dist/LinearGenomeView/components/VerticalGuides.d.ts +2 -3
  90. package/dist/LinearGenomeView/components/VerticalGuides.js +66 -104
  91. package/dist/LinearGenomeView/components/VerticalGuides.js.map +1 -0
  92. package/dist/LinearGenomeView/components/ZoomControls.js +72 -87
  93. package/dist/LinearGenomeView/components/ZoomControls.js.map +1 -0
  94. package/dist/LinearGenomeView/components/util.d.ts +12 -0
  95. package/dist/LinearGenomeView/components/util.js +95 -13
  96. package/dist/LinearGenomeView/components/util.js.map +1 -0
  97. package/dist/LinearGenomeView/index.d.ts +6 -11
  98. package/dist/LinearGenomeView/index.js +1163 -1387
  99. package/dist/LinearGenomeView/index.js.map +1 -0
  100. package/dist/LinearGenomeView/util.js +76 -83
  101. package/dist/LinearGenomeView/util.js.map +1 -0
  102. package/dist/index.d.ts +101 -51
  103. package/dist/index.js +225 -284
  104. package/dist/index.js.map +1 -0
  105. package/esm/BaseLinearDisplay/components/BaseLinearDisplay.d.ts +9 -0
  106. package/esm/BaseLinearDisplay/components/BaseLinearDisplay.js +68 -0
  107. package/esm/BaseLinearDisplay/components/BaseLinearDisplay.js.map +1 -0
  108. package/esm/BaseLinearDisplay/components/Block.d.ts +15 -0
  109. package/esm/BaseLinearDisplay/components/Block.js +46 -0
  110. package/esm/BaseLinearDisplay/components/Block.js.map +1 -0
  111. package/esm/BaseLinearDisplay/components/LinearBlocks.d.ts +22 -0
  112. package/esm/BaseLinearDisplay/components/LinearBlocks.js +62 -0
  113. package/esm/BaseLinearDisplay/components/LinearBlocks.js.map +1 -0
  114. package/esm/BaseLinearDisplay/components/ServerSideRenderedBlockContent.d.ts +4 -0
  115. package/esm/BaseLinearDisplay/components/ServerSideRenderedBlockContent.js +113 -0
  116. package/esm/BaseLinearDisplay/components/ServerSideRenderedBlockContent.js.map +1 -0
  117. package/esm/BaseLinearDisplay/components/Tooltip.d.ts +8 -0
  118. package/esm/BaseLinearDisplay/components/Tooltip.js +64 -0
  119. package/esm/BaseLinearDisplay/components/Tooltip.js.map +1 -0
  120. package/esm/BaseLinearDisplay/index.d.ts +5 -0
  121. package/esm/BaseLinearDisplay/index.js +4 -0
  122. package/esm/BaseLinearDisplay/index.js.map +1 -0
  123. package/esm/BaseLinearDisplay/models/BaseLinearDisplayModel.d.ts +232 -0
  124. package/esm/BaseLinearDisplay/models/BaseLinearDisplayModel.js +541 -0
  125. package/esm/BaseLinearDisplay/models/BaseLinearDisplayModel.js.map +1 -0
  126. package/esm/BaseLinearDisplay/models/baseLinearDisplayConfigSchema.d.ts +1 -0
  127. package/esm/BaseLinearDisplay/models/baseLinearDisplayConfigSchema.js +14 -0
  128. package/esm/BaseLinearDisplay/models/baseLinearDisplayConfigSchema.js.map +1 -0
  129. package/esm/BaseLinearDisplay/models/serverSideRenderedBlock.d.ts +96 -0
  130. package/esm/BaseLinearDisplay/models/serverSideRenderedBlock.js +225 -0
  131. package/esm/BaseLinearDisplay/models/serverSideRenderedBlock.js.map +1 -0
  132. package/esm/LinearBareDisplay/configSchema.d.ts +2 -0
  133. package/esm/LinearBareDisplay/configSchema.js +9 -0
  134. package/esm/LinearBareDisplay/configSchema.js.map +1 -0
  135. package/esm/LinearBareDisplay/index.d.ts +2 -0
  136. package/esm/LinearBareDisplay/index.js +3 -0
  137. package/esm/LinearBareDisplay/index.js.map +1 -0
  138. package/esm/LinearBareDisplay/model.d.ts +194 -0
  139. package/esm/LinearBareDisplay/model.js +28 -0
  140. package/esm/LinearBareDisplay/model.js.map +1 -0
  141. package/esm/LinearBasicDisplay/components/SetMaxHeight.d.ts +10 -0
  142. package/esm/LinearBasicDisplay/components/SetMaxHeight.js +40 -0
  143. package/esm/LinearBasicDisplay/components/SetMaxHeight.js.map +1 -0
  144. package/esm/LinearBasicDisplay/configSchema.d.ts +2 -0
  145. package/esm/LinearBasicDisplay/configSchema.js +14 -0
  146. package/esm/LinearBasicDisplay/configSchema.js.map +1 -0
  147. package/esm/LinearBasicDisplay/index.d.ts +2 -0
  148. package/esm/LinearBasicDisplay/index.js +3 -0
  149. package/esm/LinearBasicDisplay/index.js.map +1 -0
  150. package/esm/LinearBasicDisplay/model.d.ts +218 -0
  151. package/esm/LinearBasicDisplay/model.js +127 -0
  152. package/esm/LinearBasicDisplay/model.js.map +1 -0
  153. package/esm/LinearGenomeView/components/CenterLine.d.ts +8 -0
  154. package/esm/LinearGenomeView/components/CenterLine.js +40 -0
  155. package/esm/LinearGenomeView/components/CenterLine.js.map +1 -0
  156. package/esm/LinearGenomeView/components/ExportSvgDialog.d.ts +6 -0
  157. package/esm/LinearGenomeView/components/ExportSvgDialog.js +52 -0
  158. package/esm/LinearGenomeView/components/ExportSvgDialog.js.map +1 -0
  159. package/esm/LinearGenomeView/components/Header.d.ts +7 -0
  160. package/esm/LinearGenomeView/components/Header.js +81 -0
  161. package/esm/LinearGenomeView/components/Header.js.map +1 -0
  162. package/esm/LinearGenomeView/components/HelpDialog.d.ts +4 -0
  163. package/esm/LinearGenomeView/components/HelpDialog.js +58 -0
  164. package/esm/LinearGenomeView/components/HelpDialog.js.map +1 -0
  165. package/esm/LinearGenomeView/components/ImportForm.d.ts +7 -0
  166. package/esm/LinearGenomeView/components/ImportForm.js +141 -0
  167. package/esm/LinearGenomeView/components/ImportForm.js.map +1 -0
  168. package/esm/LinearGenomeView/components/LinearGenomeView.d.ts +7 -0
  169. package/esm/LinearGenomeView/components/LinearGenomeView.js +67 -0
  170. package/esm/LinearGenomeView/components/LinearGenomeView.js.map +1 -0
  171. package/esm/LinearGenomeView/components/LinearGenomeViewSvg.d.ts +4 -0
  172. package/esm/LinearGenomeView/components/LinearGenomeViewSvg.js +132 -0
  173. package/esm/LinearGenomeView/components/LinearGenomeViewSvg.js.map +1 -0
  174. package/esm/LinearGenomeView/components/MiniControls.d.ts +6 -0
  175. package/esm/LinearGenomeView/components/MiniControls.js +25 -0
  176. package/esm/LinearGenomeView/components/MiniControls.js.map +1 -0
  177. package/esm/LinearGenomeView/components/OverviewRubberBand.d.ts +22 -0
  178. package/esm/LinearGenomeView/components/OverviewRubberBand.js +194 -0
  179. package/esm/LinearGenomeView/components/OverviewRubberBand.js.map +1 -0
  180. package/esm/LinearGenomeView/components/OverviewScaleBar.d.ts +148 -0
  181. package/esm/LinearGenomeView/components/OverviewScaleBar.js +287 -0
  182. package/esm/LinearGenomeView/components/OverviewScaleBar.js.map +1 -0
  183. package/esm/LinearGenomeView/components/RefNameAutocomplete.d.ts +22 -0
  184. package/esm/LinearGenomeView/components/RefNameAutocomplete.js +136 -0
  185. package/esm/LinearGenomeView/components/RefNameAutocomplete.js.map +1 -0
  186. package/esm/LinearGenomeView/components/RubberBand.d.ts +9 -0
  187. package/esm/LinearGenomeView/components/RubberBand.js +198 -0
  188. package/esm/LinearGenomeView/components/RubberBand.js.map +1 -0
  189. package/esm/LinearGenomeView/components/Ruler.d.ts +27 -0
  190. package/esm/LinearGenomeView/components/Ruler.js +50 -0
  191. package/esm/LinearGenomeView/components/Ruler.js.map +1 -0
  192. package/esm/LinearGenomeView/components/ScaleBar.d.ts +10 -0
  193. package/esm/LinearGenomeView/components/ScaleBar.js +112 -0
  194. package/esm/LinearGenomeView/components/ScaleBar.js.map +1 -0
  195. package/esm/LinearGenomeView/components/SearchBox.d.ts +8 -0
  196. package/esm/LinearGenomeView/components/SearchBox.js +94 -0
  197. package/esm/LinearGenomeView/components/SearchBox.js.map +1 -0
  198. package/esm/LinearGenomeView/components/SearchResultsDialog.d.ts +7 -0
  199. package/esm/LinearGenomeView/components/SearchResultsDialog.js +107 -0
  200. package/esm/LinearGenomeView/components/SearchResultsDialog.js.map +1 -0
  201. package/esm/LinearGenomeView/components/SequenceDialog.d.ts +8 -0
  202. package/esm/LinearGenomeView/components/SequenceDialog.js +147 -0
  203. package/esm/LinearGenomeView/components/SequenceDialog.js.map +1 -0
  204. package/esm/LinearGenomeView/components/TrackContainer.d.ts +9 -0
  205. package/esm/LinearGenomeView/components/TrackContainer.js +109 -0
  206. package/esm/LinearGenomeView/components/TrackContainer.js.map +1 -0
  207. package/esm/LinearGenomeView/components/TrackLabel.d.ts +8 -0
  208. package/esm/LinearGenomeView/components/TrackLabel.js +89 -0
  209. package/esm/LinearGenomeView/components/TrackLabel.js.map +1 -0
  210. package/esm/LinearGenomeView/components/TracksContainer.d.ts +10 -0
  211. package/esm/LinearGenomeView/components/TracksContainer.js +142 -0
  212. package/esm/LinearGenomeView/components/TracksContainer.js.map +1 -0
  213. package/esm/LinearGenomeView/components/VerticalGuides.d.ts +8 -0
  214. package/esm/LinearGenomeView/components/VerticalGuides.js +71 -0
  215. package/esm/LinearGenomeView/components/VerticalGuides.js.map +1 -0
  216. package/esm/LinearGenomeView/components/ZoomControls.d.ts +7 -0
  217. package/esm/LinearGenomeView/components/ZoomControls.js +32 -0
  218. package/esm/LinearGenomeView/components/ZoomControls.js.map +1 -0
  219. package/esm/LinearGenomeView/components/util.d.ts +14 -0
  220. package/esm/LinearGenomeView/components/util.js +17 -0
  221. package/esm/LinearGenomeView/components/util.js.map +1 -0
  222. package/esm/LinearGenomeView/index.d.ts +288 -0
  223. package/esm/LinearGenomeView/index.js +1124 -0
  224. package/esm/LinearGenomeView/index.js.map +1 -0
  225. package/esm/LinearGenomeView/util.d.ts +14 -0
  226. package/esm/LinearGenomeView/util.js +62 -0
  227. package/esm/LinearGenomeView/util.js.map +1 -0
  228. package/esm/index.d.ts +615 -0
  229. package/esm/index.js +127 -0
  230. package/esm/index.js.map +1 -0
  231. package/package.json +21 -13
  232. package/src/BaseLinearDisplay/components/BaseLinearDisplay.tsx +6 -90
  233. package/src/BaseLinearDisplay/components/Block.tsx +5 -5
  234. package/src/BaseLinearDisplay/components/LinearBlocks.tsx +4 -4
  235. package/src/BaseLinearDisplay/components/ServerSideRenderedBlockContent.tsx +7 -8
  236. package/src/BaseLinearDisplay/components/Tooltip.tsx +107 -0
  237. package/src/BaseLinearDisplay/models/BaseLinearDisplayModel.tsx +16 -8
  238. package/src/BaseLinearDisplay/models/serverSideRenderedBlock.ts +1 -1
  239. package/src/LinearBasicDisplay/components/SetMaxHeight.tsx +10 -7
  240. package/src/LinearBasicDisplay/model.ts +21 -15
  241. package/src/LinearGenomeView/components/CenterLine.tsx +6 -11
  242. package/src/LinearGenomeView/components/ExportSvgDialog.tsx +5 -5
  243. package/src/LinearGenomeView/components/Header.tsx +12 -16
  244. package/src/LinearGenomeView/components/HelpDialog.tsx +10 -9
  245. package/src/LinearGenomeView/components/ImportForm.tsx +24 -37
  246. package/src/LinearGenomeView/components/LinearGenomeView.test.js +18 -8
  247. package/src/LinearGenomeView/components/LinearGenomeView.tsx +20 -13
  248. package/src/LinearGenomeView/components/MiniControls.tsx +29 -40
  249. package/src/LinearGenomeView/components/OverviewRubberBand.tsx +6 -10
  250. package/src/LinearGenomeView/components/OverviewScaleBar.tsx +103 -93
  251. package/src/LinearGenomeView/components/RefNameAutocomplete.tsx +13 -44
  252. package/src/LinearGenomeView/components/RubberBand.tsx +12 -17
  253. package/src/LinearGenomeView/components/Ruler.tsx +5 -11
  254. package/src/LinearGenomeView/components/ScaleBar.tsx +27 -34
  255. package/src/LinearGenomeView/components/SearchBox.tsx +22 -32
  256. package/src/LinearGenomeView/components/SearchResultsDialog.tsx +7 -7
  257. package/src/LinearGenomeView/components/SequenceDialog.tsx +9 -9
  258. package/src/LinearGenomeView/components/TrackContainer.tsx +12 -12
  259. package/src/LinearGenomeView/components/TrackLabel.tsx +37 -50
  260. package/src/LinearGenomeView/components/TracksContainer.tsx +8 -13
  261. package/src/LinearGenomeView/components/VerticalGuides.tsx +9 -11
  262. package/src/LinearGenomeView/components/ZoomControls.tsx +12 -13
  263. package/src/LinearGenomeView/components/__snapshots__/LinearGenomeView.test.js.snap +504 -568
  264. package/src/LinearGenomeView/components/util.ts +43 -0
  265. package/src/LinearGenomeView/index.test.ts +21 -5
  266. package/src/LinearGenomeView/index.tsx +101 -88
  267. package/src/index.ts +36 -31
  268. package/dist/LinearBareDisplay/index.test.js +0 -33
  269. package/dist/LinearGenomeView/components/LinearGenomeView.test.js +0 -234
  270. package/dist/LinearGenomeView/components/ScaleBar.test.js +0 -180
  271. package/dist/LinearGenomeView/index.test.js +0 -1170
  272. package/dist/LinearGenomeView/util.test.js +0 -78
@@ -1,1418 +1,1194 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.RESIZE_HANDLE_HEIGHT = exports.INTER_REGION_PADDING_WIDTH = exports.HEADER_OVERVIEW_HEIGHT = exports.HEADER_BAR_HEIGHT = void 0;
9
- Object.defineProperty(exports, "ReactComponent", {
10
- enumerable: true,
11
- get: function get() {
12
- return _LinearGenomeView.default;
13
- }
14
- });
15
- Object.defineProperty(exports, "RefNameAutocomplete", {
16
- enumerable: true,
17
- get: function get() {
18
- return _RefNameAutocomplete.default;
19
- }
20
- });
21
- exports.SPACING = exports.SCALE_BAR_HEIGHT = void 0;
22
- Object.defineProperty(exports, "SearchBox", {
23
- enumerable: true,
24
- get: function get() {
25
- return _SearchBox.default;
26
- }
27
- });
28
- exports.WIDGET_HEIGHT = void 0;
29
- Object.defineProperty(exports, "renderToSvg", {
30
- enumerable: true,
31
- get: function get() {
32
- return _LinearGenomeViewSvg.renderToSvg;
33
- }
34
- });
35
- exports.stateModelFactory = stateModelFactory;
36
-
37
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
38
-
39
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
40
-
41
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
42
-
43
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
44
-
45
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
46
-
47
- var _configuration = require("@jbrowse/core/configuration");
48
-
49
- var _models = require("@jbrowse/core/pluggableElementTypes/models");
50
-
51
- var _mst = require("@jbrowse/core/util/types/mst");
52
-
53
- var _ui = require("@jbrowse/core/ui");
54
-
55
- var _util = require("@jbrowse/core/util");
56
-
57
- var _calculateDynamicBlocks = _interopRequireDefault(require("@jbrowse/core/util/calculateDynamicBlocks"));
58
-
59
- var _calculateStaticBlocks = _interopRequireDefault(require("@jbrowse/core/util/calculateStaticBlocks"));
60
-
61
- var _tracks = require("@jbrowse/core/util/tracks");
62
-
63
- var _mobx = require("mobx");
64
-
65
- var _mobxStateTree = require("mobx-state-tree");
66
-
67
- var _Base1DViewModel = _interopRequireDefault(require("@jbrowse/core/util/Base1DViewModel"));
68
-
69
- var _clone = _interopRequireDefault(require("clone"));
70
-
71
- var _fileSaver = require("file-saver");
72
-
73
- var _Icons = require("@jbrowse/core/ui/Icons");
74
-
75
- var _SyncAlt = _interopRequireDefault(require("@material-ui/icons/SyncAlt"));
76
-
77
- var _Visibility = _interopRequireDefault(require("@material-ui/icons/Visibility"));
78
-
79
- var _Label = _interopRequireDefault(require("@material-ui/icons/Label"));
80
-
81
- var _FolderOpen = _interopRequireDefault(require("@material-ui/icons/FolderOpen"));
82
-
83
- var _PhotoCamera = _interopRequireDefault(require("@material-ui/icons/PhotoCamera"));
84
-
85
- var _ZoomIn = _interopRequireDefault(require("@material-ui/icons/ZoomIn"));
86
-
87
- var _MenuOpen = _interopRequireDefault(require("@material-ui/icons/MenuOpen"));
88
-
89
- var _LinearGenomeViewSvg = require("./components/LinearGenomeViewSvg");
90
-
91
- var _RefNameAutocomplete = _interopRequireDefault(require("./components/RefNameAutocomplete"));
92
-
93
- var _SearchBox = _interopRequireDefault(require("./components/SearchBox"));
94
-
95
- var _ExportSvgDialog = _interopRequireDefault(require("./components/ExportSvgDialog"));
96
-
97
- var _LinearGenomeView = _interopRequireDefault(require("./components/LinearGenomeView"));
98
-
99
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
100
-
101
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
102
-
103
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
104
-
105
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
106
-
107
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
108
-
109
- function calculateVisibleLocStrings(contentBlocks) {
110
- if (!contentBlocks.length) {
111
- return '';
112
- }
113
-
114
- var isSingleAssemblyName = contentBlocks.every(function (block) {
115
- return block.assemblyName === contentBlocks[0].assemblyName;
116
- });
117
- var locs = contentBlocks.map(function (block) {
118
- return (0, _util.assembleLocString)(_objectSpread(_objectSpread({}, block), {}, {
119
- start: Math.round(block.start),
120
- end: Math.round(block.end),
121
- assemblyName: isSingleAssemblyName ? undefined : block.assemblyName
122
- }));
123
- });
124
- return locs.join(' ');
125
- }
126
-
127
- var HEADER_BAR_HEIGHT = 48;
128
- exports.HEADER_BAR_HEIGHT = HEADER_BAR_HEIGHT;
129
- var HEADER_OVERVIEW_HEIGHT = 20;
130
- exports.HEADER_OVERVIEW_HEIGHT = HEADER_OVERVIEW_HEIGHT;
131
- var SCALE_BAR_HEIGHT = 17;
132
- exports.SCALE_BAR_HEIGHT = SCALE_BAR_HEIGHT;
133
- var RESIZE_HANDLE_HEIGHT = 3;
134
- exports.RESIZE_HANDLE_HEIGHT = RESIZE_HANDLE_HEIGHT;
135
- var INTER_REGION_PADDING_WIDTH = 2;
136
- exports.INTER_REGION_PADDING_WIDTH = INTER_REGION_PADDING_WIDTH;
137
- var SPACING = 7;
138
- exports.SPACING = SPACING;
139
- var WIDGET_HEIGHT = 32;
140
- exports.WIDGET_HEIGHT = WIDGET_HEIGHT;
141
-
142
- function localStorageGetItem(item) {
143
- return typeof localStorage !== 'undefined' ? localStorage.getItem(item) : undefined;
144
- }
145
-
146
- function stateModelFactory(pluginManager) {
147
- return _mobxStateTree.types.compose(_models.BaseViewModel, _mobxStateTree.types.model('LinearGenomeView', {
148
- id: _mst.ElementId,
149
- type: _mobxStateTree.types.literal('LinearGenomeView'),
150
- offsetPx: 0,
151
- bpPerPx: 1,
152
- displayedRegions: _mobxStateTree.types.array(_mst.Region),
153
- // we use an array for the tracks because the tracks are displayed in a
154
- // specific order that we need to keep.
155
- tracks: _mobxStateTree.types.array(pluginManager.pluggableMstType('track', 'stateModel')),
156
- hideHeader: false,
157
- hideHeaderOverview: false,
158
- trackSelectorType: _mobxStateTree.types.optional(_mobxStateTree.types.enumeration(['hierarchical']), 'hierarchical'),
159
- trackLabels: _mobxStateTree.types.optional(_mobxStateTree.types.string, function () {
160
- return localStorageGetItem('lgv-trackLabels') || 'overlapping';
161
- }),
162
- showCenterLine: _mobxStateTree.types.optional(_mobxStateTree.types.boolean, function () {
163
- var setting = localStorageGetItem('lgv-showCenterLine');
164
- return setting !== undefined && setting !== null ? !!+setting : false;
165
- }),
166
- showCytobandsSetting: _mobxStateTree.types.optional(_mobxStateTree.types.boolean, function () {
167
- var setting = localStorageGetItem('lgv-showCytobands');
168
- return setting !== undefined && setting !== null ? !!+setting : true;
169
- })
170
- })).volatile(function () {
171
- return {
172
- volatileWidth: undefined,
173
- minimumBlockWidth: 3,
174
- draggingTrackId: undefined,
175
- volatileError: undefined,
176
- // array of callbacks to run after the next set of the displayedRegions,
177
- // which is basically like an onLoad
178
- afterDisplayedRegionsSetCallbacks: [],
179
- scaleFactor: 1,
180
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
181
- trackRefs: {},
182
- coarseDynamicBlocks: [],
183
- coarseTotalBp: 0,
184
- leftOffset: undefined,
185
- rightOffset: undefined,
186
- searchResults: undefined,
187
- searchQuery: undefined,
188
- seqDialogDisplayed: false
189
- };
190
- }).views(function (self) {
191
- return {
192
- get width() {
193
- if (self.volatileWidth === undefined) {
194
- throw new Error('width undefined, make sure to check for model.initialized');
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
195
8
  }
196
-
197
- return self.volatileWidth;
198
- },
199
-
200
- get interRegionPaddingWidth() {
201
- return INTER_REGION_PADDING_WIDTH;
202
- }
203
-
9
+ return t;
204
10
  };
205
- }).views(function (self) {
206
- return {
207
- get assemblyErrors() {
208
- var _getSession = (0, _util.getSession)(self),
209
- assemblyManager = _getSession.assemblyManager;
210
-
211
- return this.assemblyNames.map(function (a) {
212
- var _assemblyManager$get;
213
-
214
- return (_assemblyManager$get = assemblyManager.get(a)) === null || _assemblyManager$get === void 0 ? void 0 : _assemblyManager$get.error;
215
- }).filter(function (f) {
216
- return !!f;
217
- }).join(', ');
218
- },
219
-
220
- get assembliesInitialized() {
221
- var _getSession2 = (0, _util.getSession)(self),
222
- assemblyManager = _getSession2.assemblyManager;
223
-
224
- return this.assemblyNames.every(function (a) {
225
- var _assemblyManager$get2;
226
-
227
- return (_assemblyManager$get2 = assemblyManager.get(a)) === null || _assemblyManager$get2 === void 0 ? void 0 : _assemblyManager$get2.initialized;
228
- });
229
- },
230
-
231
- get initialized() {
232
- return self.volatileWidth !== undefined && this.assembliesInitialized;
233
- },
234
-
235
- get hasDisplayedRegions() {
236
- return self.displayedRegions.length > 0;
237
- },
238
-
239
- get isSearchDialogDisplayed() {
240
- return self.searchResults !== undefined;
241
- },
242
-
243
- get scaleBarHeight() {
244
- return SCALE_BAR_HEIGHT + RESIZE_HANDLE_HEIGHT;
245
- },
246
-
247
- get headerHeight() {
248
- if (self.hideHeader) {
249
- return 0;
250
- }
251
-
252
- if (self.hideHeaderOverview) {
253
- return HEADER_BAR_HEIGHT;
254
- }
255
-
256
- return HEADER_BAR_HEIGHT + HEADER_OVERVIEW_HEIGHT;
257
- },
258
-
259
- get trackHeights() {
260
- return self.tracks.map(function (t) {
261
- return t.displays[0].height;
262
- }).reduce(function (a, b) {
263
- return a + b;
264
- }, 0);
265
- },
266
-
267
- get trackHeightsWithResizeHandles() {
268
- return this.trackHeights + self.tracks.length * RESIZE_HANDLE_HEIGHT;
269
- },
270
-
271
- get height() {
272
- return this.trackHeightsWithResizeHandles + this.headerHeight + this.scaleBarHeight;
273
- },
274
-
275
- get totalBp() {
276
- return self.displayedRegions.reduce(function (a, b) {
277
- return a + b.end - b.start;
278
- }, 0);
279
- },
280
-
281
- get maxBpPerPx() {
282
- return this.totalBp / (self.width * 0.9);
283
- },
284
-
285
- get minBpPerPx() {
286
- return 1 / 50;
287
- },
288
-
289
- get error() {
290
- return self.volatileError || this.assemblyErrors;
291
- },
292
-
293
- get maxOffset() {
294
- // objectively determined to keep the linear genome on the main screen
295
- var leftPadding = 10;
296
- return this.displayedRegionsTotalPx - leftPadding;
297
- },
298
-
299
- get minOffset() {
300
- // objectively determined to keep the linear genome on the main screen
301
- var rightPadding = 30;
302
- return -self.width + rightPadding;
303
- },
304
-
305
- get displayedRegionsTotalPx() {
306
- return this.totalBp / self.bpPerPx;
307
- },
308
-
309
- renderProps: function renderProps() {
310
- return _objectSpread(_objectSpread({}, (0, _tracks.getParentRenderProps)(self)), {}, {
311
- bpPerPx: self.bpPerPx,
312
- highResolutionScaling: (0, _configuration.getConf)((0, _util.getSession)(self), 'highResolutionScaling')
313
- });
314
- },
315
-
316
- get assemblyNames() {
317
- return (0, _toConsumableArray2.default)(new Set(self.displayedRegions.map(function (region) {
318
- return region.assemblyName;
319
- })));
320
- },
321
-
322
- searchScope: function searchScope(assemblyName) {
323
- return {
324
- assemblyName: assemblyName,
325
- includeAggregateIndexes: true,
326
- tracks: self.tracks
327
- };
328
- },
329
-
330
- /**
331
- * @param refName - refName of the displayedRegion
332
- * @param coord - coordinate at the displayed Region
333
- * @param regionNumber - optional param used as identifier when
334
- * there are multiple displayedRegions with the same refName
335
- * @returns offsetPx of the displayed region that it lands in
336
- */
337
- bpToPx: function bpToPx(_ref) {
338
- var refName = _ref.refName,
339
- coord = _ref.coord,
340
- regionNumber = _ref.regionNumber;
341
- return (0, _util.viewBpToPx)({
342
- refName: refName,
343
- coord: coord,
344
- regionNumber: regionNumber,
345
- self: self
346
- });
347
- },
348
-
349
- /**
350
- *
351
- * @param px - px in the view area, return value is the displayed regions
352
- * @returns BpOffset of the displayed region that it lands in
353
- */
354
- pxToBp: function pxToBp(px) {
355
- var bpSoFar = 0;
356
- var bp = (self.offsetPx + px) * self.bpPerPx;
357
- var n = self.displayedRegions.length;
358
-
359
- if (bp < 0) {
360
- var region = self.displayedRegions[0];
361
- var offset = bp;
362
- return _objectSpread(_objectSpread({}, (0, _mobxStateTree.getSnapshot)(region)), {}, {
363
- oob: true,
364
- coord: region.reversed ? Math.floor(region.end - offset) + 1 : Math.floor(region.start + offset) + 1,
365
- offset: offset,
366
- index: 0
367
- });
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (_) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ var __read = (this && this.__read) || function (o, n) {
50
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
51
+ if (!m) return o;
52
+ var i = m.call(o), r, ar = [], e;
53
+ try {
54
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
55
+ }
56
+ catch (error) { e = { error: error }; }
57
+ finally {
58
+ try {
59
+ if (r && !r.done && (m = i["return"])) m.call(i);
368
60
  }
369
-
370
- var interRegionPaddingBp = self.interRegionPaddingWidth * self.bpPerPx;
371
- var minimumBlockBp = self.minimumBlockWidth * self.bpPerPx;
372
-
373
- for (var index = 0; index < self.displayedRegions.length; index += 1) {
374
- var _region = self.displayedRegions[index];
375
- var len = _region.end - _region.start;
376
-
377
- var _offset = bp - bpSoFar;
378
-
379
- if (len + bpSoFar > bp && bpSoFar <= bp) {
380
- return _objectSpread(_objectSpread({}, (0, _mobxStateTree.getSnapshot)(_region)), {}, {
381
- oob: false,
382
- offset: _offset,
383
- coord: _region.reversed ? Math.floor(_region.end - _offset) + 1 : Math.floor(_region.start + _offset) + 1,
384
- index: index
385
- });
386
- } // add the interRegionPaddingWidth if the boundary is in the screen
387
- // e.g. offset>0 && offset<width
388
-
389
-
390
- if (_region.end - _region.start > minimumBlockBp && _offset / self.bpPerPx > 0 && _offset / self.bpPerPx < self.width) {
391
- bpSoFar += len + interRegionPaddingBp;
392
- } else {
393
- bpSoFar += len;
394
- }
61
+ finally { if (e) throw e.error; }
62
+ }
63
+ return ar;
64
+ };
65
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
66
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
67
+ if (ar || !(i in from)) {
68
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
69
+ ar[i] = from[i];
395
70
  }
396
-
397
- if (bp >= bpSoFar) {
398
- var _region2 = self.displayedRegions[n - 1];
399
-
400
- var _len = _region2.end - _region2.start;
401
-
402
- var _offset2 = bp - bpSoFar + _len;
403
-
404
- return _objectSpread(_objectSpread({}, (0, _mobxStateTree.getSnapshot)(_region2)), {}, {
405
- oob: true,
406
- offset: _offset2,
407
- coord: _region2.reversed ? Math.floor(_region2.end - _offset2) + 1 : Math.floor(_region2.start + _offset2) + 1,
408
- index: n - 1
409
- });
71
+ }
72
+ return to.concat(ar || Array.prototype.slice.call(from));
73
+ };
74
+ var __values = (this && this.__values) || function(o) {
75
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
76
+ if (m) return m.call(o);
77
+ if (o && typeof o.length === "number") return {
78
+ next: function () {
79
+ if (o && i >= o.length) o = void 0;
80
+ return { value: o && o[i++], done: !o };
410
81
  }
411
-
412
- return {
413
- coord: 0,
414
- index: 0,
415
- refName: '',
416
- oob: true,
417
- assemblyName: '',
418
- offset: 0,
419
- start: 0,
420
- end: 0,
421
- reversed: false
422
- };
423
- },
424
- getTrack: function getTrack(id) {
425
- return self.tracks.find(function (t) {
426
- return t.configuration.trackId === id;
427
- });
428
- },
429
- rankSearchResults: function rankSearchResults(results) {
430
- // order of rank
431
- var openTrackIds = self.tracks.map(function (track) {
432
- return track.configuration.trackId;
433
- });
434
- results.forEach(function (result) {
435
- if (openTrackIds !== []) {
436
- if (openTrackIds.includes(result.trackId)) {
437
- result.updateScore(result.getScore() + 1);
82
+ };
83
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
84
+ };
85
+ var __importDefault = (this && this.__importDefault) || function (mod) {
86
+ return (mod && mod.__esModule) ? mod : { "default": mod };
87
+ };
88
+ Object.defineProperty(exports, "__esModule", { value: true });
89
+ exports.ReactComponent = exports.SearchBox = exports.RefNameAutocomplete = exports.renderToSvg = exports.stateModelFactory = exports.WIDGET_HEIGHT = exports.SPACING = exports.INTER_REGION_PADDING_WIDTH = exports.RESIZE_HANDLE_HEIGHT = exports.SCALE_BAR_HEIGHT = exports.HEADER_OVERVIEW_HEIGHT = exports.HEADER_BAR_HEIGHT = void 0;
90
+ var configuration_1 = require("@jbrowse/core/configuration");
91
+ var models_1 = require("@jbrowse/core/pluggableElementTypes/models");
92
+ var mst_1 = require("@jbrowse/core/util/types/mst");
93
+ var ui_1 = require("@jbrowse/core/ui");
94
+ var util_1 = require("@jbrowse/core/util");
95
+ var calculateDynamicBlocks_1 = __importDefault(require("@jbrowse/core/util/calculateDynamicBlocks"));
96
+ var calculateStaticBlocks_1 = __importDefault(require("@jbrowse/core/util/calculateStaticBlocks"));
97
+ var tracks_1 = require("@jbrowse/core/util/tracks");
98
+ var mobx_1 = require("mobx");
99
+ var mobx_state_tree_1 = require("mobx-state-tree");
100
+ var Base1DViewModel_1 = __importDefault(require("@jbrowse/core/util/Base1DViewModel"));
101
+ var clone_1 = __importDefault(require("clone"));
102
+ var file_saver_1 = require("file-saver");
103
+ // icons
104
+ var Icons_1 = require("@jbrowse/core/ui/Icons");
105
+ var SyncAlt_1 = __importDefault(require("@mui/icons-material/SyncAlt"));
106
+ var Visibility_1 = __importDefault(require("@mui/icons-material/Visibility"));
107
+ var Label_1 = __importDefault(require("@mui/icons-material/Label"));
108
+ var FolderOpen_1 = __importDefault(require("@mui/icons-material/FolderOpen"));
109
+ var PhotoCamera_1 = __importDefault(require("@mui/icons-material/PhotoCamera"));
110
+ var ZoomIn_1 = __importDefault(require("@mui/icons-material/ZoomIn"));
111
+ var MenuOpen_1 = __importDefault(require("@mui/icons-material/MenuOpen"));
112
+ // locals
113
+ var LinearGenomeViewSvg_1 = require("./components/LinearGenomeViewSvg");
114
+ Object.defineProperty(exports, "renderToSvg", { enumerable: true, get: function () { return LinearGenomeViewSvg_1.renderToSvg; } });
115
+ var RefNameAutocomplete_1 = __importDefault(require("./components/RefNameAutocomplete"));
116
+ exports.RefNameAutocomplete = RefNameAutocomplete_1.default;
117
+ var SearchBox_1 = __importDefault(require("./components/SearchBox"));
118
+ exports.SearchBox = SearchBox_1.default;
119
+ var ExportSvgDialog_1 = __importDefault(require("./components/ExportSvgDialog"));
120
+ function calculateVisibleLocStrings(contentBlocks) {
121
+ if (!contentBlocks.length) {
122
+ return '';
123
+ }
124
+ var isSingleAssemblyName = contentBlocks.every(function (block) { return block.assemblyName === contentBlocks[0].assemblyName; });
125
+ var locs = contentBlocks.map(function (block) {
126
+ return (0, util_1.assembleLocString)(__assign(__assign({}, block), { start: Math.round(block.start), end: Math.round(block.end), assemblyName: isSingleAssemblyName ? undefined : block.assemblyName }));
127
+ });
128
+ return locs.join(' ');
129
+ }
130
+ exports.HEADER_BAR_HEIGHT = 48;
131
+ exports.HEADER_OVERVIEW_HEIGHT = 20;
132
+ exports.SCALE_BAR_HEIGHT = 17;
133
+ exports.RESIZE_HANDLE_HEIGHT = 3;
134
+ exports.INTER_REGION_PADDING_WIDTH = 2;
135
+ exports.SPACING = 7;
136
+ exports.WIDGET_HEIGHT = 32;
137
+ function localStorageGetItem(item) {
138
+ return typeof localStorage !== 'undefined'
139
+ ? localStorage.getItem(item)
140
+ : undefined;
141
+ }
142
+ function stateModelFactory(pluginManager) {
143
+ return mobx_state_tree_1.types
144
+ .compose(models_1.BaseViewModel, mobx_state_tree_1.types.model('LinearGenomeView', {
145
+ id: mst_1.ElementId,
146
+ type: mobx_state_tree_1.types.literal('LinearGenomeView'),
147
+ offsetPx: 0,
148
+ bpPerPx: 1,
149
+ displayedRegions: mobx_state_tree_1.types.array(mst_1.Region),
150
+ // we use an array for the tracks because the tracks are displayed in a
151
+ // specific order that we need to keep.
152
+ tracks: mobx_state_tree_1.types.array(pluginManager.pluggableMstType('track', 'stateModel')),
153
+ hideHeader: false,
154
+ hideHeaderOverview: false,
155
+ hideNoTracksActive: false,
156
+ trackSelectorType: mobx_state_tree_1.types.optional(mobx_state_tree_1.types.enumeration(['hierarchical']), 'hierarchical'),
157
+ trackLabels: mobx_state_tree_1.types.optional(mobx_state_tree_1.types.string, function () { return localStorageGetItem('lgv-trackLabels') || 'overlapping'; }),
158
+ showCenterLine: mobx_state_tree_1.types.optional(mobx_state_tree_1.types.boolean, function () {
159
+ var setting = localStorageGetItem('lgv-showCenterLine');
160
+ return setting !== undefined && setting !== null ? !!+setting : false;
161
+ }),
162
+ showCytobandsSetting: mobx_state_tree_1.types.optional(mobx_state_tree_1.types.boolean, function () {
163
+ var setting = localStorageGetItem('lgv-showCytobands');
164
+ return setting !== undefined && setting !== null ? !!+setting : true;
165
+ }),
166
+ }))
167
+ .volatile(function () { return ({
168
+ volatileWidth: undefined,
169
+ minimumBlockWidth: 3,
170
+ draggingTrackId: undefined,
171
+ volatileError: undefined,
172
+ // array of callbacks to run after the next set of the displayedRegions,
173
+ // which is basically like an onLoad
174
+ afterDisplayedRegionsSetCallbacks: [],
175
+ scaleFactor: 1,
176
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
177
+ trackRefs: {},
178
+ coarseDynamicBlocks: [],
179
+ coarseTotalBp: 0,
180
+ leftOffset: undefined,
181
+ rightOffset: undefined,
182
+ searchResults: undefined,
183
+ searchQuery: undefined,
184
+ seqDialogDisplayed: false,
185
+ }); })
186
+ .views(function (self) { return ({
187
+ get width() {
188
+ if (self.volatileWidth === undefined) {
189
+ throw new Error('width undefined, make sure to check for model.initialized');
190
+ }
191
+ return self.volatileWidth;
192
+ },
193
+ get interRegionPaddingWidth() {
194
+ return exports.INTER_REGION_PADDING_WIDTH;
195
+ },
196
+ get assemblyNames() {
197
+ return __spreadArray([], __read(new Set(self.displayedRegions.map(function (region) { return region.assemblyName; }))), false);
198
+ },
199
+ }); })
200
+ .views(function (self) { return ({
201
+ get assemblyErrors() {
202
+ var assemblyManager = (0, util_1.getSession)(self).assemblyManager;
203
+ var assemblyNames = self.assemblyNames;
204
+ return assemblyNames
205
+ .map(function (a) { var _a; return (_a = assemblyManager.get(a)) === null || _a === void 0 ? void 0 : _a.error; })
206
+ .filter(function (f) { return !!f; })
207
+ .join(', ');
208
+ },
209
+ get assembliesInitialized() {
210
+ var assemblyManager = (0, util_1.getSession)(self).assemblyManager;
211
+ var assemblyNames = self.assemblyNames;
212
+ return assemblyNames.every(function (a) { var _a; return (_a = assemblyManager.get(a)) === null || _a === void 0 ? void 0 : _a.initialized; });
213
+ },
214
+ get initialized() {
215
+ return self.volatileWidth !== undefined && this.assembliesInitialized;
216
+ },
217
+ get hasDisplayedRegions() {
218
+ return self.displayedRegions.length > 0;
219
+ },
220
+ get isSearchDialogDisplayed() {
221
+ return self.searchResults !== undefined;
222
+ },
223
+ get scaleBarHeight() {
224
+ return exports.SCALE_BAR_HEIGHT + exports.RESIZE_HANDLE_HEIGHT;
225
+ },
226
+ get headerHeight() {
227
+ if (self.hideHeader) {
228
+ return 0;
229
+ }
230
+ if (self.hideHeaderOverview) {
231
+ return exports.HEADER_BAR_HEIGHT;
232
+ }
233
+ return exports.HEADER_BAR_HEIGHT + exports.HEADER_OVERVIEW_HEIGHT;
234
+ },
235
+ get trackHeights() {
236
+ return self.tracks
237
+ .map(function (t) { return t.displays[0].height; })
238
+ .reduce(function (a, b) { return a + b; }, 0);
239
+ },
240
+ get trackHeightsWithResizeHandles() {
241
+ return this.trackHeights + self.tracks.length * exports.RESIZE_HANDLE_HEIGHT;
242
+ },
243
+ get height() {
244
+ return (this.trackHeightsWithResizeHandles +
245
+ this.headerHeight +
246
+ this.scaleBarHeight);
247
+ },
248
+ get totalBp() {
249
+ return self.displayedRegions.reduce(function (a, b) { return a + b.end - b.start; }, 0);
250
+ },
251
+ get maxBpPerPx() {
252
+ return this.totalBp / (self.width * 0.9);
253
+ },
254
+ get minBpPerPx() {
255
+ return 1 / 50;
256
+ },
257
+ get error() {
258
+ return self.volatileError || this.assemblyErrors;
259
+ },
260
+ get maxOffset() {
261
+ // objectively determined to keep the linear genome on the main screen
262
+ var leftPadding = 10;
263
+ return this.displayedRegionsTotalPx - leftPadding;
264
+ },
265
+ get minOffset() {
266
+ // objectively determined to keep the linear genome on the main screen
267
+ var rightPadding = 30;
268
+ return -self.width + rightPadding;
269
+ },
270
+ get displayedRegionsTotalPx() {
271
+ return this.totalBp / self.bpPerPx;
272
+ },
273
+ renderProps: function () {
274
+ return __assign(__assign({}, (0, tracks_1.getParentRenderProps)(self)), { bpPerPx: self.bpPerPx, highResolutionScaling: (0, configuration_1.getConf)((0, util_1.getSession)(self), 'highResolutionScaling') });
275
+ },
276
+ searchScope: function (assemblyName) {
277
+ return {
278
+ assemblyName: assemblyName,
279
+ includeAggregateIndexes: true,
280
+ tracks: self.tracks,
281
+ };
282
+ },
283
+ bpToPx: function (_a) {
284
+ var refName = _a.refName, coord = _a.coord, regionNumber = _a.regionNumber;
285
+ return (0, util_1.viewBpToPx)({ refName: refName, coord: coord, regionNumber: regionNumber, self: self });
286
+ },
287
+ /**
288
+ *
289
+ * @param px - px in the view area, return value is the displayed regions
290
+ * @returns BpOffset of the displayed region that it lands in
291
+ */
292
+ pxToBp: function (px) {
293
+ var bpSoFar = 0;
294
+ var bp = (self.offsetPx + px) * self.bpPerPx;
295
+ var n = self.displayedRegions.length;
296
+ if (bp < 0) {
297
+ var region = self.displayedRegions[0];
298
+ var offset = bp;
299
+ var snap = (0, mobx_state_tree_1.getSnapshot)(region);
300
+ return __assign(__assign({}, snap), { oob: true, coord: region.reversed
301
+ ? Math.floor(region.end - offset) + 1
302
+ : Math.floor(region.start + offset) + 1, offset: offset, index: 0 });
438
303
  }
439
- }
440
- });
441
- return results;
442
- },
443
- // modifies view menu action onClick to apply to all tracks of same type
444
- rewriteOnClicks: function rewriteOnClicks(trackType, viewMenuActions) {
445
- var _this = this;
446
-
447
- viewMenuActions.forEach(function (action) {
448
- // go to lowest level menu
449
- if ('subMenu' in action) {
450
- _this.rewriteOnClicks(trackType, action.subMenu);
451
- }
452
-
453
- if ('onClick' in action) {
454
- var holdOnClick = action.onClick;
455
-
456
- action.onClick = function () {
457
- for (var _len2 = arguments.length, args = new Array(_len2), _key = 0; _key < _len2; _key++) {
458
- args[_key] = arguments[_key];
459
- }
460
-
461
- self.tracks.forEach(function (track) {
462
- if (track.type === trackType) {
463
- holdOnClick.apply(track, [track].concat(args));
304
+ var interRegionPaddingBp = self.interRegionPaddingWidth * self.bpPerPx;
305
+ var minimumBlockBp = self.minimumBlockWidth * self.bpPerPx;
306
+ for (var index = 0; index < self.displayedRegions.length; index += 1) {
307
+ var region = self.displayedRegions[index];
308
+ var len = region.end - region.start;
309
+ var offset = bp - bpSoFar;
310
+ if (len + bpSoFar > bp && bpSoFar <= bp) {
311
+ var snap = (0, mobx_state_tree_1.getSnapshot)(region);
312
+ return __assign(__assign({}, snap), { oob: false, offset: offset, coord: region.reversed
313
+ ? Math.floor(region.end - offset) + 1
314
+ : Math.floor(region.start + offset) + 1, index: index });
315
+ }
316
+ // add the interRegionPaddingWidth if the boundary is in the screen
317
+ // e.g. offset>0 && offset<width
318
+ if (region.end - region.start > minimumBlockBp &&
319
+ offset / self.bpPerPx > 0 &&
320
+ offset / self.bpPerPx < self.width) {
321
+ bpSoFar += len + interRegionPaddingBp;
464
322
  }
465
- });
323
+ else {
324
+ bpSoFar += len;
325
+ }
326
+ }
327
+ if (bp >= bpSoFar) {
328
+ var region = self.displayedRegions[n - 1];
329
+ var len = region.end - region.start;
330
+ var offset = bp - bpSoFar + len;
331
+ var snap = (0, mobx_state_tree_1.getSnapshot)(region);
332
+ return __assign(__assign({}, snap), { oob: true, offset: offset, coord: region.reversed
333
+ ? Math.floor(region.end - offset) + 1
334
+ : Math.floor(region.start + offset) + 1, index: n - 1 });
335
+ }
336
+ return {
337
+ coord: 0,
338
+ index: 0,
339
+ refName: '',
340
+ oob: true,
341
+ assemblyName: '',
342
+ offset: 0,
343
+ start: 0,
344
+ end: 0,
345
+ reversed: false,
466
346
  };
467
- }
468
- });
469
- },
470
-
471
- get trackTypeActions() {
472
- var _this2 = this;
473
-
474
- var allActions = new Map();
475
- self.tracks.forEach(function (track) {
476
- var trackInMap = allActions.get(track.type);
477
-
478
- if (!trackInMap) {
479
- var viewMenuActions = (0, _clone.default)(track.viewMenuActions);
480
-
481
- _this2.rewriteOnClicks(track.type, viewMenuActions);
482
-
483
- allActions.set(track.type, viewMenuActions);
484
- }
485
- });
486
- return allActions;
487
- },
488
-
489
- get centerLineInfo() {
490
- return self.displayedRegions.length ? this.pxToBp(self.width / 2) : undefined;
491
- }
492
-
493
- };
494
- }).actions(function (self) {
495
- return {
496
- setShowCytobands: function setShowCytobands(flag) {
497
- self.showCytobandsSetting = flag;
498
- localStorage.setItem('lgv-showCytobands', "".concat(+flag));
499
- },
500
- setWidth: function setWidth(newWidth) {
501
- self.volatileWidth = newWidth;
502
- },
503
- setError: function setError(error) {
504
- self.volatileError = error;
505
- },
506
- toggleHeader: function toggleHeader() {
507
- self.hideHeader = !self.hideHeader;
508
- },
509
- toggleHeaderOverview: function toggleHeaderOverview() {
510
- self.hideHeaderOverview = !self.hideHeaderOverview;
511
- },
512
- scrollTo: function scrollTo(offsetPx) {
513
- var newOffsetPx = (0, _util.clamp)(offsetPx, self.minOffset, self.maxOffset);
514
- self.offsetPx = newOffsetPx;
515
- return newOffsetPx;
516
- },
517
- zoomTo: function zoomTo(bpPerPx) {
518
- var newBpPerPx = (0, _util.clamp)(bpPerPx, self.minBpPerPx, self.maxBpPerPx);
519
-
520
- if (newBpPerPx === self.bpPerPx) {
521
- return newBpPerPx;
522
- }
523
-
524
- var oldBpPerPx = self.bpPerPx;
525
- self.bpPerPx = newBpPerPx;
526
-
527
- if (Math.abs(oldBpPerPx - newBpPerPx) < 0.000001) {
528
- console.warn('zoomTo bpPerPx rounding error');
529
- return oldBpPerPx;
530
- } // tweak the offset so that the center of the view remains at the same coordinate
531
-
532
-
533
- var viewWidth = self.width;
534
- this.scrollTo(Math.round((self.offsetPx + viewWidth / 2) * oldBpPerPx / newBpPerPx - viewWidth / 2));
535
- return newBpPerPx;
536
- },
537
- setOffsets: function setOffsets(left, right) {
538
- // sets offsets used in the get sequence dialog
539
- self.leftOffset = left;
540
- self.rightOffset = right;
541
- },
542
- setSearchResults: function setSearchResults(results, query) {
543
- self.searchResults = results;
544
- self.searchQuery = query;
545
- },
546
- setSequenceDialogOpen: function setSequenceDialogOpen(open) {
547
- self.seqDialogDisplayed = open;
548
- },
549
- setNewView: function setNewView(bpPerPx, offsetPx) {
550
- this.zoomTo(bpPerPx);
551
- this.scrollTo(offsetPx);
552
- },
553
- horizontallyFlip: function horizontallyFlip() {
554
- self.displayedRegions = (0, _mobxStateTree.cast)(self.displayedRegions.slice().reverse().map(function (region) {
555
- return _objectSpread(_objectSpread({}, region), {}, {
556
- reversed: !region.reversed
557
- });
558
- }));
559
- this.scrollTo(self.totalBp / self.bpPerPx - self.offsetPx - self.width);
560
- },
561
- showTrack: function showTrack(trackId) {
562
- var initialSnapshot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
563
- var displayInitialSnapshot = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
564
- var trackConfigSchema = pluginManager.pluggableConfigSchemaType('track');
565
- var configuration = (0, _mobxStateTree.resolveIdentifier)(trackConfigSchema, (0, _mobxStateTree.getRoot)(self), trackId);
566
-
567
- if (!configuration) {
568
- throw new Error("Could not resolve identifier \"".concat(trackId, "\""));
569
- }
570
-
571
- var trackType = pluginManager.getTrackType(configuration === null || configuration === void 0 ? void 0 : configuration.type);
572
-
573
- if (!trackType) {
574
- throw new Error("Unknown track type ".concat(configuration.type));
575
- }
576
-
577
- var viewType = pluginManager.getViewType(self.type);
578
- var supportedDisplays = viewType.displayTypes.map(function (displayType) {
579
- return displayType.name;
580
- });
581
- var displayConf = configuration.displays.find(function (d) {
582
- return supportedDisplays.includes(d.type);
583
- });
584
-
585
- if (!displayConf) {
586
- throw new Error("Could not find a compatible display for view type ".concat(self.type));
587
- }
588
-
589
- var shownTracks = self.tracks.filter(function (t) {
590
- return t.configuration === configuration;
591
- });
592
-
593
- if (shownTracks.length === 0) {
594
- var track = trackType.stateModel.create(_objectSpread(_objectSpread({}, initialSnapshot), {}, {
595
- type: configuration.type,
596
- configuration: configuration,
597
- displays: [_objectSpread({
598
- type: displayConf.type,
599
- configuration: displayConf
600
- }, displayInitialSnapshot)]
601
- }));
602
- self.tracks.push(track);
603
- return track;
604
- }
605
-
606
- return shownTracks[0];
607
- },
608
- hideTrack: function hideTrack(trackId) {
609
- var trackConfigSchema = pluginManager.pluggableConfigSchemaType('track');
610
- var configuration = (0, _mobxStateTree.resolveIdentifier)(trackConfigSchema, (0, _mobxStateTree.getRoot)(self), trackId); // if we have any tracks with that configuration, turn them off
611
-
612
- var shownTracks = self.tracks.filter(function (t) {
613
- return t.configuration === configuration;
614
- });
615
- (0, _mobx.transaction)(function () {
616
- return shownTracks.forEach(function (t) {
617
- return self.tracks.remove(t);
618
- });
619
- });
620
- return shownTracks.length;
621
- }
622
- };
623
- }).actions(function (self) {
624
- return {
625
- moveTrack: function moveTrack(movingTrackId, targetTrackId) {
626
- var oldIndex = self.tracks.findIndex(function (track) {
627
- return track.id === movingTrackId;
628
- });
629
-
630
- if (oldIndex === -1) {
631
- throw new Error("Track ID ".concat(movingTrackId, " not found"));
632
- }
633
-
634
- var newIndex = self.tracks.findIndex(function (track) {
635
- return track.id === targetTrackId;
636
- });
637
-
638
- if (newIndex === -1) {
639
- throw new Error("Track ID ".concat(targetTrackId, " not found"));
640
- }
641
-
642
- var track = (0, _mobxStateTree.getSnapshot)(self.tracks[oldIndex]);
643
- self.tracks.splice(oldIndex, 1);
644
- self.tracks.splice(newIndex, 0, track);
645
- },
646
- closeView: function closeView() {
647
- var parent = (0, _util.getContainingView)(self);
648
-
649
- if (parent) {
650
- // I am embedded in a some other view
651
- if ((0, _util.isViewContainer)(parent)) {
652
- parent.removeView(self);
653
- }
654
- } else {
655
- // I am part of a session
656
- (0, _util.getSession)(self).removeView(self);
657
- }
658
- },
659
- toggleTrack: function toggleTrack(trackId) {
660
- // if we have any tracks with that configuration, turn them off
661
- var hiddenCount = self.hideTrack(trackId); // if none had that configuration, turn one on
662
-
663
- if (!hiddenCount) {
664
- self.showTrack(trackId);
665
- }
666
- },
667
- setTrackLabels: function setTrackLabels(setting) {
668
- self.trackLabels = setting;
669
- localStorage.setItem('lgv-trackLabels', setting);
670
- },
671
- toggleCenterLine: function toggleCenterLine() {
672
- self.showCenterLine = !self.showCenterLine;
673
- localStorage.setItem('lgv-showCenterLine', "".concat(+self.showCenterLine));
674
- },
675
- setDisplayedRegions: function setDisplayedRegions(regions) {
676
- self.displayedRegions = (0, _mobxStateTree.cast)(regions);
677
- self.zoomTo(self.bpPerPx);
678
- },
679
- activateTrackSelector: function activateTrackSelector() {
680
- if (self.trackSelectorType === 'hierarchical') {
681
- var session = (0, _util.getSession)(self);
682
-
683
- if ((0, _util.isSessionModelWithWidgets)(session)) {
684
- var selector = session.addWidget('HierarchicalTrackSelectorWidget', 'hierarchicalTrackSelector', {
685
- view: self
347
+ },
348
+ getTrack: function (id) {
349
+ return self.tracks.find(function (t) { return t.configuration.trackId === id; });
350
+ },
351
+ rankSearchResults: function (results) {
352
+ // order of rank
353
+ var openTrackIds = self.tracks.map(function (track) { return track.configuration.trackId; });
354
+ results.forEach(function (result) {
355
+ if (openTrackIds.includes(result.trackId)) {
356
+ result.updateScore(result.getScore() + 1);
357
+ }
686
358
  });
687
- session.showWidget(selector);
688
- return selector;
689
- }
690
- }
691
-
692
- throw new Error("invalid track selector type ".concat(self.trackSelectorType));
693
- },
694
- navToLocString: function navToLocString(locString, optAssemblyName) {
695
- var assemblyNames = self.assemblyNames;
696
-
697
- var _getSession3 = (0, _util.getSession)(self),
698
- assemblyManager = _getSession3.assemblyManager;
699
-
700
- var isValidRefName = assemblyManager.isValidRefName;
701
- var assemblyName = optAssemblyName || assemblyNames[0];
702
- var parsedLocStrings = locString.split(' ').filter(function (f) {
703
- return !!f.trim();
704
- }).map(function (l) {
705
- return (0, _util.parseLocString)(l, function (ref) {
706
- return isValidRefName(ref, assemblyName);
707
- });
708
- });
709
- var locations = parsedLocStrings.map(function (region) {
710
- var asmName = region.assemblyName || assemblyName;
711
- var asm = assemblyManager.get(asmName);
712
- var refName = region.refName;
713
-
714
- if (!asm) {
715
- throw new Error("assembly ".concat(asmName, " not found"));
716
- }
717
-
718
- var regions = asm.regions;
719
-
720
- if (!regions) {
721
- throw new Error("regions not loaded yet for ".concat(asmName));
722
- }
723
-
724
- var canonicalRefName = asm.getCanonicalRefName(region.refName);
725
-
726
- if (!canonicalRefName) {
727
- throw new Error("Could not find refName ".concat(refName, " in ").concat(asm.name));
728
- }
729
-
730
- var parentRegion = regions.find(function (region) {
731
- return region.refName === canonicalRefName;
732
- });
733
-
734
- if (!parentRegion) {
735
- throw new Error("Could not find refName ".concat(refName, " in ").concat(asmName));
736
- }
737
-
738
- return _objectSpread(_objectSpread({}, region), {}, {
739
- assemblyName: asmName,
740
- parentRegion: parentRegion
741
- });
742
- });
743
-
744
- if (locations.length === 1) {
745
- var loc = locations[0];
746
- this.setDisplayedRegions([_objectSpread({
747
- reversed: loc.reversed
748
- }, loc.parentRegion)]);
749
- var start = loc.start,
750
- end = loc.end,
751
- parentRegion = loc.parentRegion;
752
- this.navTo(_objectSpread(_objectSpread({}, loc), {}, {
753
- start: (0, _util.clamp)(start !== null && start !== void 0 ? start : 0, 0, parentRegion.end),
754
- end: (0, _util.clamp)(end !== null && end !== void 0 ? end : parentRegion.end, 0, parentRegion.end)
755
- }));
756
- } else {
757
- this.setDisplayedRegions( // @ts-ignore
758
- locations.map(function (r) {
759
- return r.start === undefined ? r.parentRegion : r;
760
- }));
761
- this.showAllRegions();
762
- }
763
- },
764
-
765
- /**
766
- * Navigate to a location based on its refName and optionally start, end,
767
- * and assemblyName. Can handle if there are multiple displayedRegions
768
- * from same refName. Only navigates to a location if it is entirely
769
- * within a displayedRegion. Navigates to the first matching location
770
- * encountered.
771
- *
772
- * Throws an error if navigation was unsuccessful
773
- *
774
- * @param location - a proposed location to navigate to
775
- */
776
- navTo: function navTo(query) {
777
- this.navToMultiple([query]);
778
- },
779
- navToMultiple: function navToMultiple(locations) {
780
- var firstLocation = locations[0];
781
- var refName = firstLocation.refName;
782
- var start = firstLocation.start,
783
- end = firstLocation.end,
784
- _firstLocation$assemb = firstLocation.assemblyName,
785
- assemblyName = _firstLocation$assemb === void 0 ? self.assemblyNames[0] : _firstLocation$assemb;
786
-
787
- if (start !== undefined && end !== undefined && start > end) {
788
- throw new Error("start \"".concat(start + 1, "\" is greater than end \"").concat(end, "\""));
789
- }
790
-
791
- var session = (0, _util.getSession)(self);
792
- var assemblyManager = session.assemblyManager;
793
- var assembly = assemblyManager.get(assemblyName);
794
-
795
- if (assembly) {
796
- var canonicalRefName = assembly.getCanonicalRefName(refName);
797
-
798
- if (canonicalRefName) {
799
- refName = canonicalRefName;
800
- }
801
- }
802
-
803
- var s = start;
804
- var e = end;
805
- var refNameMatched = false;
806
-
807
- var predicate = function predicate(r) {
808
- if (refName === r.refName) {
809
- refNameMatched = true;
810
-
811
- if (s === undefined) {
812
- s = r.start;
359
+ return results;
360
+ },
361
+ // modifies view menu action onClick to apply to all tracks of same type
362
+ rewriteOnClicks: function (trackType, viewMenuActions) {
363
+ var _this = this;
364
+ viewMenuActions.forEach(function (action) {
365
+ // go to lowest level menu
366
+ if ('subMenu' in action) {
367
+ _this.rewriteOnClicks(trackType, action.subMenu);
368
+ }
369
+ if ('onClick' in action) {
370
+ var holdOnClick_1 = action.onClick;
371
+ action.onClick = function () {
372
+ var args = [];
373
+ for (var _i = 0; _i < arguments.length; _i++) {
374
+ args[_i] = arguments[_i];
375
+ }
376
+ self.tracks.forEach(function (track) {
377
+ if (track.type === trackType) {
378
+ holdOnClick_1.apply(track, __spreadArray([track], __read(args), false));
379
+ }
380
+ });
381
+ };
382
+ }
383
+ });
384
+ },
385
+ get trackTypeActions() {
386
+ var _this = this;
387
+ var allActions = new Map();
388
+ self.tracks.forEach(function (track) {
389
+ var trackInMap = allActions.get(track.type);
390
+ if (!trackInMap) {
391
+ var viewMenuActions = (0, clone_1.default)(track.viewMenuActions);
392
+ _this.rewriteOnClicks(track.type, viewMenuActions);
393
+ allActions.set(track.type, viewMenuActions);
394
+ }
395
+ });
396
+ return allActions;
397
+ },
398
+ get centerLineInfo() {
399
+ return self.displayedRegions.length
400
+ ? this.pxToBp(self.width / 2)
401
+ : undefined;
402
+ },
403
+ }); })
404
+ .actions(function (self) { return ({
405
+ setShowCytobands: function (flag) {
406
+ self.showCytobandsSetting = flag;
407
+ localStorage.setItem('lgv-showCytobands', "".concat(+flag));
408
+ },
409
+ setWidth: function (newWidth) {
410
+ self.volatileWidth = newWidth;
411
+ },
412
+ setError: function (error) {
413
+ self.volatileError = error;
414
+ },
415
+ toggleHeader: function () {
416
+ self.hideHeader = !self.hideHeader;
417
+ },
418
+ toggleHeaderOverview: function () {
419
+ self.hideHeaderOverview = !self.hideHeaderOverview;
420
+ },
421
+ toggleNoTracksActive: function () {
422
+ self.hideNoTracksActive = !self.hideNoTracksActive;
423
+ },
424
+ scrollTo: function (offsetPx) {
425
+ var newOffsetPx = (0, util_1.clamp)(offsetPx, self.minOffset, self.maxOffset);
426
+ self.offsetPx = newOffsetPx;
427
+ return newOffsetPx;
428
+ },
429
+ zoomTo: function (bpPerPx) {
430
+ var newBpPerPx = (0, util_1.clamp)(bpPerPx, self.minBpPerPx, self.maxBpPerPx);
431
+ if (newBpPerPx === self.bpPerPx) {
432
+ return newBpPerPx;
813
433
  }
814
-
815
- if (e === undefined) {
816
- e = r.end;
434
+ var oldBpPerPx = self.bpPerPx;
435
+ self.bpPerPx = newBpPerPx;
436
+ if (Math.abs(oldBpPerPx - newBpPerPx) < 0.000001) {
437
+ console.warn('zoomTo bpPerPx rounding error');
438
+ return oldBpPerPx;
817
439
  }
818
-
819
- if (s >= r.start && s <= r.end && e <= r.end && e >= r.start) {
820
- return true;
440
+ // tweak the offset so that the center of the view remains at the same coordinate
441
+ var viewWidth = self.width;
442
+ this.scrollTo(Math.round(((self.offsetPx + viewWidth / 2) * oldBpPerPx) / newBpPerPx -
443
+ viewWidth / 2));
444
+ return newBpPerPx;
445
+ },
446
+ setOffsets: function (left, right) {
447
+ // sets offsets used in the get sequence dialog
448
+ self.leftOffset = left;
449
+ self.rightOffset = right;
450
+ },
451
+ setSearchResults: function (results, query) {
452
+ self.searchResults = results;
453
+ self.searchQuery = query;
454
+ },
455
+ setSequenceDialogOpen: function (open) {
456
+ self.seqDialogDisplayed = open;
457
+ },
458
+ setNewView: function (bpPerPx, offsetPx) {
459
+ this.zoomTo(bpPerPx);
460
+ this.scrollTo(offsetPx);
461
+ },
462
+ horizontallyFlip: function () {
463
+ self.displayedRegions = (0, mobx_state_tree_1.cast)(self.displayedRegions
464
+ .slice()
465
+ .reverse()
466
+ .map(function (region) { return (__assign(__assign({}, region), { reversed: !region.reversed })); }));
467
+ this.scrollTo(self.totalBp / self.bpPerPx - self.offsetPx - self.width);
468
+ },
469
+ showTrack: function (trackId, initialSnapshot, displayInitialSnapshot) {
470
+ if (initialSnapshot === void 0) { initialSnapshot = {}; }
471
+ if (displayInitialSnapshot === void 0) { displayInitialSnapshot = {}; }
472
+ var schema = pluginManager.pluggableConfigSchemaType('track');
473
+ var conf = (0, mobx_state_tree_1.resolveIdentifier)(schema, (0, mobx_state_tree_1.getRoot)(self), trackId);
474
+ if (!conf) {
475
+ throw new Error("Could not resolve identifier \"".concat(trackId, "\""));
821
476
  }
822
-
823
- s = start;
824
- e = end;
825
- }
826
-
827
- return false;
828
- };
829
-
830
- var lastIndex = (0, _util.findLastIndex)(self.displayedRegions, predicate);
831
- var index;
832
-
833
- while (index !== lastIndex) {
834
- try {
835
- var previousIndex = index;
836
- index = self.displayedRegions.slice(previousIndex === undefined ? 0 : previousIndex + 1).findIndex(predicate);
837
-
838
- if (previousIndex !== undefined) {
839
- index += previousIndex + 1;
477
+ var trackType = pluginManager.getTrackType(conf === null || conf === void 0 ? void 0 : conf.type);
478
+ if (!trackType) {
479
+ throw new Error("Unknown track type ".concat(conf.type));
840
480
  }
841
-
842
- if (!refNameMatched) {
843
- throw new Error("could not find a region with refName \"".concat(refName, "\""));
481
+ var viewType = pluginManager.getViewType(self.type);
482
+ var supportedDisplays = viewType.displayTypes.map(function (d) { return d.name; });
483
+ var displayConf = conf.displays.find(function (d) {
484
+ return supportedDisplays.includes(d.type);
485
+ });
486
+ if (!displayConf) {
487
+ throw new Error("Could not find a compatible display for view type ".concat(self.type));
844
488
  }
845
-
846
- if (s === undefined) {
847
- throw new Error("could not find a region with refName \"".concat(refName, "\" that contained an end position ").concat(e));
489
+ var t = self.tracks.filter(function (t) { return t.configuration === conf; });
490
+ if (t.length === 0) {
491
+ var track = trackType.stateModel.create(__assign(__assign({}, initialSnapshot), { type: conf.type, configuration: conf, displays: [
492
+ __assign({ type: displayConf.type, configuration: displayConf }, displayInitialSnapshot),
493
+ ] }));
494
+ self.tracks.push(track);
495
+ return track;
848
496
  }
849
-
850
- if (e === undefined) {
851
- throw new Error("could not find a region with refName \"".concat(refName, "\" that contained a start position ").concat(s + 1));
497
+ return t[0];
498
+ },
499
+ hideTrack: function (trackId) {
500
+ var schema = pluginManager.pluggableConfigSchemaType('track');
501
+ var conf = (0, mobx_state_tree_1.resolveIdentifier)(schema, (0, mobx_state_tree_1.getRoot)(self), trackId);
502
+ var t = self.tracks.filter(function (t) { return t.configuration === conf; });
503
+ (0, mobx_1.transaction)(function () { return t.forEach(function (t) { return self.tracks.remove(t); }); });
504
+ return t.length;
505
+ },
506
+ }); })
507
+ .actions(function (self) { return ({
508
+ moveTrack: function (movingId, targetId) {
509
+ var oldIndex = self.tracks.findIndex(function (track) { return track.id === movingId; });
510
+ if (oldIndex === -1) {
511
+ throw new Error("Track ID ".concat(movingId, " not found"));
852
512
  }
853
-
854
- if (index === -1) {
855
- throw new Error("could not find a region that completely contained \"".concat((0, _util.assembleLocString)(firstLocation), "\""));
513
+ var newIndex = self.tracks.findIndex(function (track) { return track.id === targetId; });
514
+ if (newIndex === -1) {
515
+ throw new Error("Track ID ".concat(targetId, " not found"));
856
516
  }
857
-
858
- if (locations.length === 1) {
859
- var f = self.displayedRegions[index];
860
- this.moveTo({
861
- index: index,
862
- offset: f.reversed ? f.end - e : s - f.start
863
- }, {
864
- index: index,
865
- offset: f.reversed ? f.end - s : e - f.start
866
- });
867
- return;
517
+ var track = (0, mobx_state_tree_1.getSnapshot)(self.tracks[oldIndex]);
518
+ self.tracks.splice(oldIndex, 1);
519
+ self.tracks.splice(newIndex, 0, track);
520
+ },
521
+ closeView: function () {
522
+ var parent = (0, util_1.getContainingView)(self);
523
+ if (parent) {
524
+ // I am embedded in a some other view
525
+ if ((0, util_1.isViewContainer)(parent)) {
526
+ parent.removeView(self);
527
+ }
868
528
  }
869
-
870
- var locationIndex = 0;
871
- var locationStart = 0;
872
- var locationEnd = 0;
873
-
874
- for (locationIndex; locationIndex < locations.length; locationIndex++) {
875
- var location = locations[locationIndex];
876
- var region = self.displayedRegions[index + locationIndex];
877
- locationStart = location.start || region.start;
878
- locationEnd = location.end || region.end;
879
-
880
- if (location.refName !== region.refName) {
881
- throw new Error("Entered location ".concat((0, _util.assembleLocString)(location), " does not match with displayed regions"));
882
- }
529
+ else {
530
+ // I am part of a session
531
+ (0, util_1.getSession)(self).removeView(self);
883
532
  }
884
-
885
- locationIndex -= 1;
886
- var startDisplayedRegion = self.displayedRegions[index];
887
- var endDisplayedRegion = self.displayedRegions[index + locationIndex];
888
- this.moveTo({
889
- index: index,
890
- offset: startDisplayedRegion.reversed ? startDisplayedRegion.end - e : s - startDisplayedRegion.start
891
- }, {
892
- index: index + locationIndex,
893
- offset: endDisplayedRegion.reversed ? endDisplayedRegion.end - locationStart : locationEnd - endDisplayedRegion.start
894
- });
895
- return;
896
- } catch (error) {
897
- if (index === lastIndex) {
898
- throw error;
533
+ },
534
+ toggleTrack: function (trackId) {
535
+ // if we have any tracks with that configuration, turn them off
536
+ var hiddenCount = self.hideTrack(trackId);
537
+ // if none had that configuration, turn one on
538
+ if (!hiddenCount) {
539
+ self.showTrack(trackId);
899
540
  }
900
- }
901
- }
902
- },
903
-
904
- /**
905
- * Navigate to a location based on user clicking and dragging on the
906
- * overview scale bar to select a region to zoom into.
907
- * Can handle if there are multiple displayedRegions from same refName.
908
- * Only navigates to a location if it is entirely within a displayedRegion.
909
- *
910
- * @param leftPx- `object as {start, end, index, offset}`, offset = start of user drag
911
- * @param rightPx- `object as {start, end, index, offset}`, offset = end of user drag
912
- */
913
- zoomToDisplayedRegions: function zoomToDisplayedRegions(leftPx, rightPx) {
914
- if (leftPx === undefined || rightPx === undefined) {
915
- return;
916
- }
917
-
918
- var singleRefSeq = leftPx.refName === rightPx.refName && leftPx.index === rightPx.index; // zooming into one displayed Region
919
-
920
- if (singleRefSeq && rightPx.offset < leftPx.offset || leftPx.index > rightPx.index) {
921
- ;
922
- var _ref2 = [rightPx, leftPx];
923
- leftPx = _ref2[0];
924
- rightPx = _ref2[1];
925
- }
926
-
927
- var startOffset = {
928
- start: leftPx.start,
929
- end: leftPx.end,
930
- index: leftPx.index,
931
- offset: leftPx.offset
932
- };
933
- var endOffset = {
934
- start: rightPx.start,
935
- end: rightPx.end,
936
- index: rightPx.index,
937
- offset: rightPx.offset
938
- };
939
-
940
- if (startOffset && endOffset) {
941
- this.moveTo(startOffset, endOffset);
942
- } else {
943
- var session = (0, _util.getSession)(self);
944
- session.notify('No regions found to navigate to', 'warning');
945
- }
946
- },
947
-
948
- /**
949
- * Helper method for the fetchSequence.
950
- * Retrieves the corresponding regions that were selected by the rubberband
951
- *
952
- * @param leftOffset - `object as {start, end, index, offset}`, offset = start of user drag
953
- * @param rightOffset - `object as {start, end, index, offset}`, offset = end of user drag
954
- * @returns array of Region[]
955
- */
956
- getSelectedRegions: function getSelectedRegions(leftOffset, rightOffset) {
957
- var simView = _Base1DViewModel.default.create(_objectSpread(_objectSpread({}, (0, _mobxStateTree.getSnapshot)(self)), {}, {
958
- interRegionPaddingWidth: self.interRegionPaddingWidth
959
- }));
960
-
961
- simView.setVolatileWidth(self.width);
962
- simView.zoomToDisplayedRegions(leftOffset, rightOffset);
963
- return simView.dynamicBlocks.contentBlocks.map(function (region) {
964
- return _objectSpread(_objectSpread({}, region), {}, {
965
- start: Math.floor(region.start),
966
- end: Math.ceil(region.end)
967
- });
968
- });
969
- },
970
- // schedule something to be run after the next time displayedRegions is set
971
- afterDisplayedRegionsSet: function afterDisplayedRegionsSet(cb) {
972
- self.afterDisplayedRegionsSetCallbacks.push(cb);
973
- },
974
-
975
- /**
976
- * offset is the base-pair-offset in the displayed region, index is the index of the
977
- * displayed region in the linear genome view
978
- *
979
- * @param start - object as `{start, end, offset, index}`
980
- * @param end - object as `{start, end, offset, index}`
981
- */
982
- moveTo: function moveTo(start, end) {
983
- // find locations in the modellist
984
- var bpSoFar = 0;
985
-
986
- if (start.index === end.index) {
987
- bpSoFar += end.offset - start.offset;
988
- } else {
989
- var s = self.displayedRegions[start.index];
990
- bpSoFar += s.end - s.start - start.offset;
991
-
992
- if (end.index - start.index >= 2) {
993
- for (var i = start.index + 1; i < end.index; i += 1) {
994
- bpSoFar += self.displayedRegions[i].end - self.displayedRegions[i].start;
541
+ },
542
+ setTrackLabels: function (setting) {
543
+ self.trackLabels = setting;
544
+ localStorage.setItem('lgv-trackLabels', setting);
545
+ },
546
+ toggleCenterLine: function () {
547
+ self.showCenterLine = !self.showCenterLine;
548
+ localStorage.setItem('lgv-showCenterLine', "".concat(+self.showCenterLine));
549
+ },
550
+ setDisplayedRegions: function (regions) {
551
+ self.displayedRegions = (0, mobx_state_tree_1.cast)(regions);
552
+ self.zoomTo(self.bpPerPx);
553
+ },
554
+ activateTrackSelector: function () {
555
+ if (self.trackSelectorType === 'hierarchical') {
556
+ var session = (0, util_1.getSession)(self);
557
+ if ((0, util_1.isSessionModelWithWidgets)(session)) {
558
+ var selector = session.addWidget('HierarchicalTrackSelectorWidget', 'hierarchicalTrackSelector', { view: self });
559
+ session.showWidget(selector);
560
+ return selector;
561
+ }
995
562
  }
996
- }
997
-
998
- bpSoFar += end.offset;
999
- }
1000
-
1001
- var targetBpPerPx = bpSoFar / (self.width - self.interRegionPaddingWidth * (end.index - start.index));
1002
- var newBpPerPx = self.zoomTo(targetBpPerPx); // If our target bpPerPx was smaller than the allowed minBpPerPx, adjust
1003
- // the scroll so the requested range is in the middle of the screen
1004
-
1005
- var extraBp = 0;
1006
-
1007
- if (targetBpPerPx < newBpPerPx) {
1008
- extraBp = (newBpPerPx - targetBpPerPx) * self.width / 2;
1009
- }
1010
-
1011
- var bpToStart = -extraBp;
1012
-
1013
- for (var _i = 0; _i < self.displayedRegions.length; _i += 1) {
1014
- var region = self.displayedRegions[_i];
1015
-
1016
- if (start.index === _i) {
1017
- bpToStart += start.offset;
1018
- break;
1019
- } else {
1020
- bpToStart += region.end - region.start;
1021
- }
1022
- }
1023
-
1024
- self.scrollTo(Math.round(bpToStart / self.bpPerPx) + self.interRegionPaddingWidth * start.index);
1025
- },
1026
- horizontalScroll: function horizontalScroll(distance) {
1027
- var oldOffsetPx = self.offsetPx; // newOffsetPx is the actual offset after the scroll is clamped
1028
-
1029
- var newOffsetPx = self.scrollTo(self.offsetPx + distance);
1030
- return newOffsetPx - oldOffsetPx;
1031
- },
1032
-
1033
- /**
1034
- * scrolls the view to center on the given bp. if that is not in any
1035
- * of the displayed regions, does nothing
1036
- * @param bp - basepair at which you want to center the view
1037
- * @param refName - refName of the displayedRegion you are centering at
1038
- * @param regionIndex - index of the displayedRegion
1039
- */
1040
- centerAt: function centerAt(bp, refName, regionIndex) {
1041
- var centerPx = self.bpToPx({
1042
- refName: refName,
1043
- coord: bp,
1044
- regionNumber: regionIndex
1045
- });
1046
-
1047
- if (centerPx) {
1048
- self.scrollTo(Math.round(centerPx.offsetPx - self.width / 2));
1049
- }
1050
- },
1051
- center: function center() {
1052
- var centerBp = self.totalBp / 2;
1053
- self.scrollTo(Math.round(centerBp / self.bpPerPx - self.width / 2));
1054
- },
1055
- showAllRegions: function showAllRegions() {
1056
- self.zoomTo(self.maxBpPerPx);
1057
- this.center();
1058
- },
1059
- showAllRegionsInAssembly: function showAllRegionsInAssembly(assemblyName) {
1060
- var session = (0, _util.getSession)(self);
1061
- var assemblyManager = session.assemblyManager;
1062
-
1063
- if (!assemblyName) {
1064
- var assemblyNames = (0, _toConsumableArray2.default)(new Set(self.displayedRegions.map(function (region) {
1065
- return region.assemblyName;
1066
- })));
1067
-
1068
- if (assemblyNames.length > 1) {
1069
- session.notify("Can't perform this with multiple assemblies currently");
1070
- return;
1071
- }
1072
-
1073
- ;
1074
-
1075
- var _assemblyNames = (0, _slicedToArray2.default)(assemblyNames, 1);
1076
-
1077
- assemblyName = _assemblyNames[0];
1078
- }
1079
-
1080
- var assembly = assemblyManager.get(assemblyName);
1081
-
1082
- if (assembly) {
1083
- var regions = assembly.regions;
1084
-
1085
- if (regions) {
1086
- this.setDisplayedRegions(regions);
1087
- self.zoomTo(self.maxBpPerPx);
1088
- this.center();
1089
- }
1090
- }
1091
- },
1092
- setDraggingTrackId: function setDraggingTrackId(idx) {
1093
- self.draggingTrackId = idx;
1094
- },
1095
- setScaleFactor: function setScaleFactor(factor) {
1096
- self.scaleFactor = factor;
1097
- }
1098
- };
1099
- }).actions(function (self) {
1100
- var cancelLastAnimation = function cancelLastAnimation() {};
1101
-
1102
- function slide(viewWidths) {
1103
- var _springAnimate = (0, _util.springAnimate)(self.offsetPx, self.offsetPx + self.width * viewWidths, self.scrollTo),
1104
- _springAnimate2 = (0, _slicedToArray2.default)(_springAnimate, 2),
1105
- animate = _springAnimate2[0],
1106
- cancelAnimation = _springAnimate2[1];
1107
-
1108
- cancelLastAnimation();
1109
- cancelLastAnimation = cancelAnimation;
1110
- animate();
1111
- }
1112
-
1113
- return {
1114
- slide: slide
1115
- };
1116
- }).actions(function (self) {
1117
- var cancelLastAnimation = function cancelLastAnimation() {};
1118
-
1119
- function zoom(targetBpPerPx) {
1120
- self.zoomTo(self.bpPerPx);
1121
-
1122
- if ( // already zoomed all the way in
1123
- targetBpPerPx < self.bpPerPx && self.bpPerPx === self.minBpPerPx || // already zoomed all the way out
1124
- targetBpPerPx > self.bpPerPx && self.bpPerPx === self.maxBpPerPx) {
1125
- return;
1126
- }
1127
-
1128
- var factor = self.bpPerPx / targetBpPerPx;
1129
-
1130
- var _springAnimate3 = (0, _util.springAnimate)(1, factor, self.setScaleFactor, function () {
1131
- self.zoomTo(targetBpPerPx);
1132
- self.setScaleFactor(1);
1133
- }),
1134
- _springAnimate4 = (0, _slicedToArray2.default)(_springAnimate3, 2),
1135
- animate = _springAnimate4[0],
1136
- cancelAnimation = _springAnimate4[1];
1137
-
1138
- cancelLastAnimation();
1139
- cancelLastAnimation = cancelAnimation;
1140
- animate();
1141
- }
1142
-
1143
- return {
1144
- zoom: zoom
1145
- };
1146
- }).views(function (self) {
1147
- return {
1148
- get canShowCytobands() {
1149
- return self.displayedRegions.length === 1 && this.anyCytobandsExist;
1150
- },
1151
-
1152
- get showCytobands() {
1153
- return this.canShowCytobands && self.showCytobandsSetting;
1154
- },
1155
-
1156
- get anyCytobandsExist() {
1157
- var _getSession4 = (0, _util.getSession)(self),
1158
- assemblyManager = _getSession4.assemblyManager;
1159
-
1160
- var assemblyNames = self.assemblyNames;
1161
- return assemblyNames.some(function (asm) {
1162
- var _assemblyManager$get3, _assemblyManager$get4;
1163
-
1164
- return (_assemblyManager$get3 = assemblyManager.get(asm)) === null || _assemblyManager$get3 === void 0 ? void 0 : (_assemblyManager$get4 = _assemblyManager$get3.cytobands) === null || _assemblyManager$get4 === void 0 ? void 0 : _assemblyManager$get4.length;
1165
- });
1166
- },
1167
-
1168
- get cytobandOffset() {
1169
- return this.showCytobands ? (0, _util.measureText)(self.displayedRegions[0].refName, 12) + 15 : 0;
1170
- }
1171
-
1172
- };
1173
- }).views(function (self) {
1174
- return {
1175
- menuItems: function menuItems() {
1176
- var canShowCytobands = self.canShowCytobands,
1177
- showCytobands = self.showCytobands;
1178
- var menuItems = [{
1179
- label: 'Return to import form',
1180
- onClick: function onClick() {
1181
- (0, _util.getSession)(self).queueDialog(function (handleClose) {
1182
- return [_ui.ReturnToImportFormDialog, {
1183
- model: self,
1184
- handleClose: handleClose
1185
- }];
1186
- });
1187
- },
1188
- icon: _FolderOpen.default
1189
- }, {
1190
- label: 'Export SVG',
1191
- icon: _PhotoCamera.default,
1192
- onClick: function onClick() {
1193
- (0, _util.getSession)(self).queueDialog(function (handleClose) {
1194
- return [_ExportSvgDialog.default, {
1195
- model: self,
1196
- handleClose: handleClose
1197
- }];
563
+ throw new Error("invalid track selector type ".concat(self.trackSelectorType));
564
+ },
565
+ navToLocString: function (locString, optAssemblyName) {
566
+ var assemblyNames = self.assemblyNames;
567
+ var assemblyManager = (0, util_1.getSession)(self).assemblyManager;
568
+ var isValidRefName = assemblyManager.isValidRefName;
569
+ var assemblyName = optAssemblyName || assemblyNames[0];
570
+ var parsedLocStrings;
571
+ var inputs = locString
572
+ .split(/(\s+)/)
573
+ .map(function (f) { return f.trim(); })
574
+ .filter(function (f) { return !!f; });
575
+ // first try interpreting as a whitespace-separated sequence of
576
+ // multiple locstrings
577
+ try {
578
+ parsedLocStrings = inputs.map(function (l) {
579
+ return (0, util_1.parseLocString)(l, function (ref) { return isValidRefName(ref, assemblyName); });
580
+ });
581
+ }
582
+ catch (e) {
583
+ // if this fails, try interpreting as a whitespace-separated refname,
584
+ // start, end if start and end are integer inputs
585
+ var _a = __read(inputs, 3), refName = _a[0], start = _a[1], end = _a[2];
586
+ if ("".concat(e).match(/Unknown reference sequence/) &&
587
+ Number.isInteger(+start) &&
588
+ Number.isInteger(+end)) {
589
+ parsedLocStrings = [
590
+ (0, util_1.parseLocString)(refName + ':' + start + '..' + end, function (ref) {
591
+ return isValidRefName(ref, assemblyName);
592
+ }),
593
+ ];
594
+ }
595
+ else {
596
+ throw e;
597
+ }
598
+ }
599
+ var locations = parsedLocStrings === null || parsedLocStrings === void 0 ? void 0 : parsedLocStrings.map(function (region) {
600
+ var asmName = region.assemblyName || assemblyName;
601
+ var asm = assemblyManager.get(asmName);
602
+ var refName = region.refName;
603
+ if (!asm) {
604
+ throw new Error("assembly ".concat(asmName, " not found"));
605
+ }
606
+ var regions = asm.regions;
607
+ if (!regions) {
608
+ throw new Error("regions not loaded yet for ".concat(asmName));
609
+ }
610
+ var canonicalRefName = asm.getCanonicalRefName(region.refName);
611
+ if (!canonicalRefName) {
612
+ throw new Error("Could not find refName ".concat(refName, " in ").concat(asm.name));
613
+ }
614
+ var parentRegion = regions.find(function (region) { return region.refName === canonicalRefName; });
615
+ if (!parentRegion) {
616
+ throw new Error("Could not find refName ".concat(refName, " in ").concat(asmName));
617
+ }
618
+ return __assign(__assign({}, region), { assemblyName: asmName, parentRegion: parentRegion });
1198
619
  });
1199
- }
1200
- }, {
1201
- label: 'Open track selector',
1202
- onClick: self.activateTrackSelector,
1203
- icon: _Icons.TrackSelector
1204
- }, {
1205
- label: 'Horizontally flip',
1206
- icon: _SyncAlt.default,
1207
- onClick: self.horizontallyFlip
1208
- }, {
1209
- type: 'divider'
1210
- }, {
1211
- label: 'Show all regions in assembly',
1212
- icon: _Visibility.default,
1213
- onClick: self.showAllRegionsInAssembly
1214
- }, {
1215
- label: 'Show center line',
1216
- icon: _Visibility.default,
1217
- type: 'checkbox',
1218
- checked: self.showCenterLine,
1219
- onClick: self.toggleCenterLine
1220
- }, {
1221
- label: 'Show header',
1222
- icon: _Visibility.default,
1223
- type: 'checkbox',
1224
- checked: !self.hideHeader,
1225
- onClick: self.toggleHeader
1226
- }, {
1227
- label: 'Show header overview',
1228
- icon: _Visibility.default,
1229
- type: 'checkbox',
1230
- checked: !self.hideHeaderOverview,
1231
- onClick: self.toggleHeaderOverview,
1232
- disabled: self.hideHeader
1233
- }, {
1234
- label: 'Track labels',
1235
- icon: _Label.default,
1236
- subMenu: [{
1237
- label: 'Overlapping',
1238
- icon: _Visibility.default,
1239
- type: 'radio',
1240
- checked: self.trackLabels === 'overlapping',
1241
- onClick: function onClick() {
1242
- return self.setTrackLabels('overlapping');
620
+ if (locations.length === 1) {
621
+ var loc = locations[0];
622
+ this.setDisplayedRegions([
623
+ __assign({ reversed: loc.reversed }, loc.parentRegion),
624
+ ]);
625
+ var start = loc.start, end = loc.end, parentRegion = loc.parentRegion;
626
+ this.navTo(__assign(__assign({}, loc), { start: (0, util_1.clamp)(start !== null && start !== void 0 ? start : 0, 0, parentRegion.end), end: (0, util_1.clamp)(end !== null && end !== void 0 ? end : parentRegion.end, 0, parentRegion.end) }));
1243
627
  }
1244
- }, {
1245
- label: 'Offset',
1246
- icon: _Visibility.default,
1247
- type: 'radio',
1248
- checked: self.trackLabels === 'offset',
1249
- onClick: function onClick() {
1250
- return self.setTrackLabels('offset');
628
+ else {
629
+ this.setDisplayedRegions(
630
+ // @ts-ignore
631
+ locations.map(function (r) { return (r.start === undefined ? r.parentRegion : r); }));
632
+ this.showAllRegions();
1251
633
  }
1252
- }, {
1253
- label: 'Hidden',
1254
- icon: _Visibility.default,
1255
- type: 'radio',
1256
- checked: self.trackLabels === 'hidden',
1257
- onClick: function onClick() {
1258
- return self.setTrackLabels('hidden');
634
+ },
635
+ /**
636
+ * Navigate to a location based on its refName and optionally start, end,
637
+ * and assemblyName. Can handle if there are multiple displayedRegions
638
+ * from same refName. Only navigates to a location if it is entirely
639
+ * within a displayedRegion. Navigates to the first matching location
640
+ * encountered.
641
+ *
642
+ * Throws an error if navigation was unsuccessful
643
+ *
644
+ * @param location - a proposed location to navigate to
645
+ */
646
+ navTo: function (query) {
647
+ this.navToMultiple([query]);
648
+ },
649
+ navToMultiple: function (locations) {
650
+ var firstLocation = locations[0];
651
+ var refName = firstLocation.refName;
652
+ var start = firstLocation.start, end = firstLocation.end, _a = firstLocation.assemblyName, assemblyName = _a === void 0 ? self.assemblyNames[0] : _a;
653
+ if (start !== undefined && end !== undefined && start > end) {
654
+ throw new Error("start \"".concat(start + 1, "\" is greater than end \"").concat(end, "\""));
1259
655
  }
1260
- }]
1261
- }].concat((0, _toConsumableArray2.default)(canShowCytobands ? [{
1262
- label: showCytobands ? 'Hide ideogram' : 'Show ideograms',
1263
- onClick: function onClick() {
1264
- self.setShowCytobands(!showCytobands);
1265
- }
1266
- }] : [])); // add track's view level menu options
1267
-
1268
- var _iterator = _createForOfIteratorHelper(self.trackTypeActions.entries()),
1269
- _step;
1270
-
1271
- try {
1272
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
1273
- var _step$value = (0, _slicedToArray2.default)(_step.value, 2),
1274
- _key2 = _step$value[0],
1275
- value = _step$value[1];
1276
-
1277
- if (value.length) {
1278
- menuItems.push({
1279
- type: 'divider'
1280
- }, {
1281
- type: 'subHeader',
1282
- label: _key2
1283
- });
1284
- value.forEach(function (action) {
1285
- menuItems.push(action);
1286
- });
656
+ var session = (0, util_1.getSession)(self);
657
+ var assemblyManager = session.assemblyManager;
658
+ var assembly = assemblyManager.get(assemblyName);
659
+ if (assembly) {
660
+ var canonicalRefName = assembly.getCanonicalRefName(refName);
661
+ if (canonicalRefName) {
662
+ refName = canonicalRefName;
663
+ }
664
+ }
665
+ var s = start;
666
+ var e = end;
667
+ var refNameMatched = false;
668
+ var predicate = function (r) {
669
+ if (refName === r.refName) {
670
+ refNameMatched = true;
671
+ if (s === undefined) {
672
+ s = r.start;
673
+ }
674
+ if (e === undefined) {
675
+ e = r.end;
676
+ }
677
+ if (s >= r.start && s <= r.end && e <= r.end && e >= r.start) {
678
+ return true;
679
+ }
680
+ s = start;
681
+ e = end;
682
+ }
683
+ return false;
684
+ };
685
+ var lastIndex = (0, util_1.findLastIndex)(self.displayedRegions, predicate);
686
+ var index;
687
+ while (index !== lastIndex) {
688
+ try {
689
+ var previousIndex = index;
690
+ index = self.displayedRegions
691
+ .slice(previousIndex === undefined ? 0 : previousIndex + 1)
692
+ .findIndex(predicate);
693
+ if (previousIndex !== undefined) {
694
+ index += previousIndex + 1;
695
+ }
696
+ if (!refNameMatched) {
697
+ throw new Error("could not find a region with refName \"".concat(refName, "\""));
698
+ }
699
+ if (s === undefined) {
700
+ throw new Error("could not find a region with refName \"".concat(refName, "\" that contained an end position ").concat(e));
701
+ }
702
+ if (e === undefined) {
703
+ throw new Error("could not find a region with refName \"".concat(refName, "\" that contained a start position ").concat(s + 1));
704
+ }
705
+ if (index === -1) {
706
+ throw new Error("could not find a region that completely contained \"".concat((0, util_1.assembleLocString)(firstLocation), "\""));
707
+ }
708
+ if (locations.length === 1) {
709
+ var f = self.displayedRegions[index];
710
+ this.moveTo({ index: index, offset: f.reversed ? f.end - e : s - f.start }, { index: index, offset: f.reversed ? f.end - s : e - f.start });
711
+ return;
712
+ }
713
+ var locationIndex = 0;
714
+ var locationStart = 0;
715
+ var locationEnd = 0;
716
+ for (locationIndex; locationIndex < locations.length; locationIndex++) {
717
+ var location_1 = locations[locationIndex];
718
+ var region = self.displayedRegions[index + locationIndex];
719
+ locationStart = location_1.start || region.start;
720
+ locationEnd = location_1.end || region.end;
721
+ if (location_1.refName !== region.refName) {
722
+ throw new Error("Entered location ".concat((0, util_1.assembleLocString)(location_1), " does not match with displayed regions"));
723
+ }
724
+ }
725
+ locationIndex -= 1;
726
+ var startDisplayedRegion = self.displayedRegions[index];
727
+ var endDisplayedRegion = self.displayedRegions[index + locationIndex];
728
+ this.moveTo({
729
+ index: index,
730
+ offset: startDisplayedRegion.reversed
731
+ ? startDisplayedRegion.end - e
732
+ : s - startDisplayedRegion.start,
733
+ }, {
734
+ index: index + locationIndex,
735
+ offset: endDisplayedRegion.reversed
736
+ ? endDisplayedRegion.end - locationStart
737
+ : locationEnd - endDisplayedRegion.start,
738
+ });
739
+ return;
740
+ }
741
+ catch (error) {
742
+ if (index === lastIndex) {
743
+ throw error;
744
+ }
745
+ }
746
+ }
747
+ },
748
+ /**
749
+ * Navigate to a location based on user clicking and dragging on the
750
+ * overview scale bar to select a region to zoom into.
751
+ * Can handle if there are multiple displayedRegions from same refName.
752
+ * Only navigates to a location if it is entirely within a displayedRegion.
753
+ *
754
+ * @param leftPx- `object as {start, end, index, offset}`, offset = start of user drag
755
+ * @param rightPx- `object as {start, end, index, offset}`, offset = end of user drag
756
+ */
757
+ zoomToDisplayedRegions: function (leftPx, rightPx) {
758
+ var _a;
759
+ if (leftPx === undefined || rightPx === undefined) {
760
+ return;
761
+ }
762
+ var singleRefSeq = leftPx.refName === rightPx.refName && leftPx.index === rightPx.index;
763
+ // zooming into one displayed Region
764
+ if ((singleRefSeq && rightPx.offset < leftPx.offset) ||
765
+ leftPx.index > rightPx.index) {
766
+ ;
767
+ _a = __read([rightPx, leftPx], 2), leftPx = _a[0], rightPx = _a[1];
768
+ }
769
+ var startOffset = {
770
+ start: leftPx.start,
771
+ end: leftPx.end,
772
+ index: leftPx.index,
773
+ offset: leftPx.offset,
774
+ };
775
+ var endOffset = {
776
+ start: rightPx.start,
777
+ end: rightPx.end,
778
+ index: rightPx.index,
779
+ offset: rightPx.offset,
780
+ };
781
+ if (startOffset && endOffset) {
782
+ this.moveTo(startOffset, endOffset);
1287
783
  }
1288
- }
1289
- } catch (err) {
1290
- _iterator.e(err);
1291
- } finally {
1292
- _iterator.f();
784
+ else {
785
+ var session = (0, util_1.getSession)(self);
786
+ session.notify('No regions found to navigate to', 'warning');
787
+ }
788
+ },
789
+ /**
790
+ * Helper method for the fetchSequence.
791
+ * Retrieves the corresponding regions that were selected by the rubberband
792
+ *
793
+ * @param leftOffset - `object as {start, end, index, offset}`, offset = start of user drag
794
+ * @param rightOffset - `object as {start, end, index, offset}`, offset = end of user drag
795
+ * @returns array of Region[]
796
+ */
797
+ getSelectedRegions: function (leftOffset, rightOffset) {
798
+ var snap = (0, mobx_state_tree_1.getSnapshot)(self);
799
+ var simView = Base1DViewModel_1.default.create(__assign(__assign({}, snap), { interRegionPaddingWidth: self.interRegionPaddingWidth }));
800
+ simView.setVolatileWidth(self.width);
801
+ simView.zoomToDisplayedRegions(leftOffset, rightOffset);
802
+ return simView.dynamicBlocks.contentBlocks.map(function (region) { return (__assign(__assign({}, region), { start: Math.floor(region.start), end: Math.ceil(region.end) })); });
803
+ },
804
+ // schedule something to be run after the next time displayedRegions is set
805
+ afterDisplayedRegionsSet: function (cb) {
806
+ self.afterDisplayedRegionsSetCallbacks.push(cb);
807
+ },
808
+ /**
809
+ * offset is the base-pair-offset in the displayed region, index is the index of the
810
+ * displayed region in the linear genome view
811
+ *
812
+ * @param start - object as `{start, end, offset, index}`
813
+ * @param end - object as `{start, end, offset, index}`
814
+ */
815
+ moveTo: function (start, end) {
816
+ // find locations in the modellist
817
+ var bpSoFar = 0;
818
+ if (start.index === end.index) {
819
+ bpSoFar += end.offset - start.offset;
820
+ }
821
+ else {
822
+ var s = self.displayedRegions[start.index];
823
+ bpSoFar += s.end - s.start - start.offset;
824
+ if (end.index - start.index >= 2) {
825
+ for (var i = start.index + 1; i < end.index; i += 1) {
826
+ bpSoFar +=
827
+ self.displayedRegions[i].end - self.displayedRegions[i].start;
828
+ }
829
+ }
830
+ bpSoFar += end.offset;
831
+ }
832
+ var targetBpPerPx = bpSoFar /
833
+ (self.width -
834
+ self.interRegionPaddingWidth * (end.index - start.index));
835
+ var newBpPerPx = self.zoomTo(targetBpPerPx);
836
+ // If our target bpPerPx was smaller than the allowed minBpPerPx, adjust
837
+ // the scroll so the requested range is in the middle of the screen
838
+ var extraBp = 0;
839
+ if (targetBpPerPx < newBpPerPx) {
840
+ extraBp = ((newBpPerPx - targetBpPerPx) * self.width) / 2;
841
+ }
842
+ var bpToStart = -extraBp;
843
+ for (var i = 0; i < self.displayedRegions.length; i += 1) {
844
+ var region = self.displayedRegions[i];
845
+ if (start.index === i) {
846
+ bpToStart += start.offset;
847
+ break;
848
+ }
849
+ else {
850
+ bpToStart += region.end - region.start;
851
+ }
852
+ }
853
+ self.scrollTo(Math.round(bpToStart / self.bpPerPx) +
854
+ self.interRegionPaddingWidth * start.index);
855
+ },
856
+ horizontalScroll: function (distance) {
857
+ var oldOffsetPx = self.offsetPx;
858
+ // newOffsetPx is the actual offset after the scroll is clamped
859
+ var newOffsetPx = self.scrollTo(self.offsetPx + distance);
860
+ return newOffsetPx - oldOffsetPx;
861
+ },
862
+ /**
863
+ * scrolls the view to center on the given bp. if that is not in any
864
+ * of the displayed regions, does nothing
865
+ * @param bp - basepair at which you want to center the view
866
+ * @param refName - refName of the displayedRegion you are centering at
867
+ * @param regionIndex - index of the displayedRegion
868
+ */
869
+ centerAt: function (bp, refName, regionIndex) {
870
+ var centerPx = self.bpToPx({
871
+ refName: refName,
872
+ coord: bp,
873
+ regionNumber: regionIndex,
874
+ });
875
+ if (centerPx) {
876
+ self.scrollTo(Math.round(centerPx.offsetPx - self.width / 2));
877
+ }
878
+ },
879
+ center: function () {
880
+ var centerBp = self.totalBp / 2;
881
+ self.scrollTo(Math.round(centerBp / self.bpPerPx - self.width / 2));
882
+ },
883
+ showAllRegions: function () {
884
+ self.zoomTo(self.maxBpPerPx);
885
+ this.center();
886
+ },
887
+ showAllRegionsInAssembly: function (assemblyName) {
888
+ var _a;
889
+ var session = (0, util_1.getSession)(self);
890
+ var assemblyManager = session.assemblyManager;
891
+ if (!assemblyName) {
892
+ var assemblyNames = __spreadArray([], __read(new Set(self.displayedRegions.map(function (region) { return region.assemblyName; }))), false);
893
+ if (assemblyNames.length > 1) {
894
+ session.notify("Can't perform this with multiple assemblies currently");
895
+ return;
896
+ }
897
+ ;
898
+ _a = __read(assemblyNames, 1), assemblyName = _a[0];
899
+ }
900
+ var assembly = assemblyManager.get(assemblyName);
901
+ if (assembly) {
902
+ var regions = assembly.regions;
903
+ if (regions) {
904
+ this.setDisplayedRegions(regions);
905
+ self.zoomTo(self.maxBpPerPx);
906
+ this.center();
907
+ }
908
+ }
909
+ },
910
+ setDraggingTrackId: function (idx) {
911
+ self.draggingTrackId = idx;
912
+ },
913
+ setScaleFactor: function (factor) {
914
+ self.scaleFactor = factor;
915
+ },
916
+ }); })
917
+ .actions(function (self) {
918
+ var cancelLastAnimation = function () { };
919
+ function slide(viewWidths) {
920
+ var _a = __read((0, util_1.springAnimate)(self.offsetPx, self.offsetPx + self.width * viewWidths, self.scrollTo), 2), animate = _a[0], cancelAnimation = _a[1];
921
+ cancelLastAnimation();
922
+ cancelLastAnimation = cancelAnimation;
923
+ animate();
1293
924
  }
1294
-
1295
- return menuItems;
1296
- }
1297
- };
1298
- }).views(function (self) {
1299
- var currentlyCalculatedStaticBlocks;
1300
- var stringifiedCurrentlyCalculatedStaticBlocks = '';
1301
- return {
1302
- get staticBlocks() {
1303
- var ret = (0, _calculateStaticBlocks.default)(self);
1304
- var sret = JSON.stringify(ret);
1305
-
1306
- if (stringifiedCurrentlyCalculatedStaticBlocks !== sret) {
1307
- currentlyCalculatedStaticBlocks = ret;
1308
- stringifiedCurrentlyCalculatedStaticBlocks = sret;
925
+ return { slide: slide };
926
+ })
927
+ .actions(function (self) {
928
+ var cancelLastAnimation = function () { };
929
+ function zoom(targetBpPerPx) {
930
+ self.zoomTo(self.bpPerPx);
931
+ if (
932
+ // already zoomed all the way in
933
+ (targetBpPerPx < self.bpPerPx && self.bpPerPx === self.minBpPerPx) ||
934
+ // already zoomed all the way out
935
+ (targetBpPerPx > self.bpPerPx && self.bpPerPx === self.maxBpPerPx)) {
936
+ return;
937
+ }
938
+ var factor = self.bpPerPx / targetBpPerPx;
939
+ var _a = __read((0, util_1.springAnimate)(1, factor, self.setScaleFactor, function () {
940
+ self.zoomTo(targetBpPerPx);
941
+ self.setScaleFactor(1);
942
+ }), 2), animate = _a[0], cancelAnimation = _a[1];
943
+ cancelLastAnimation();
944
+ cancelLastAnimation = cancelAnimation;
945
+ animate();
1309
946
  }
1310
-
1311
- return currentlyCalculatedStaticBlocks;
1312
- },
1313
-
1314
- get dynamicBlocks() {
1315
- return (0, _calculateDynamicBlocks.default)(self);
1316
- },
1317
-
1318
- get roundedDynamicBlocks() {
1319
- return this.dynamicBlocks.contentBlocks.map(function (block) {
1320
- return _objectSpread(_objectSpread({}, block), {}, {
1321
- start: Math.floor(block.start),
1322
- end: Math.ceil(block.end)
1323
- });
1324
- });
1325
- },
1326
-
1327
- get visibleLocStrings() {
1328
- return calculateVisibleLocStrings(this.dynamicBlocks.contentBlocks);
1329
- },
1330
-
1331
- get coarseVisibleLocStrings() {
1332
- return calculateVisibleLocStrings(self.coarseDynamicBlocks);
1333
- }
1334
-
1335
- };
1336
- }).actions(function (self) {
1337
- return {
1338
- // this "clears the view" and makes the view return to the import form
1339
- clearView: function clearView() {
1340
- self.setDisplayedRegions([]);
1341
- self.tracks.clear(); // it is necessary to run these after setting displayed regions empty
1342
- // or else model.offsetPx gets set to Infinity and breaks
1343
- // mobx-state-tree snapshot
1344
-
1345
- self.scrollTo(0);
1346
- self.zoomTo(10);
1347
- },
1348
- setCoarseDynamicBlocks: function setCoarseDynamicBlocks(blocks) {
1349
- self.coarseDynamicBlocks = blocks.contentBlocks;
1350
- self.coarseTotalBp = blocks.totalBp;
1351
- },
1352
- afterAttach: function afterAttach() {
1353
- var _this3 = this;
1354
-
1355
- (0, _mobxStateTree.addDisposer)(self, (0, _mobx.autorun)(function () {
1356
- if (self.initialized) {
1357
- _this3.setCoarseDynamicBlocks(self.dynamicBlocks);
1358
- }
1359
- }, {
1360
- delay: 150
1361
- }));
1362
- }
1363
- };
1364
- }).actions(function (self) {
1365
- return {
1366
- exportSvg: function exportSvg() {
1367
- var _arguments = arguments;
1368
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
1369
- var opts, html, blob;
1370
- return _regenerator.default.wrap(function _callee$(_context) {
1371
- while (1) {
1372
- switch (_context.prev = _context.next) {
1373
- case 0:
1374
- opts = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : {};
1375
- _context.next = 3;
1376
- return (0, _LinearGenomeViewSvg.renderToSvg)(self, opts);
1377
-
1378
- case 3:
1379
- html = _context.sent;
1380
- blob = new Blob([html], {
1381
- type: 'image/svg+xml'
1382
- });
1383
- (0, _fileSaver.saveAs)(blob, opts.filename || 'image.svg');
1384
-
1385
- case 6:
1386
- case "end":
1387
- return _context.stop();
1388
- }
947
+ return { zoom: zoom };
948
+ })
949
+ .views(function (self) { return ({
950
+ get canShowCytobands() {
951
+ return self.displayedRegions.length === 1 && this.anyCytobandsExist;
952
+ },
953
+ get showCytobands() {
954
+ return this.canShowCytobands && self.showCytobandsSetting;
955
+ },
956
+ get anyCytobandsExist() {
957
+ var assemblyManager = (0, util_1.getSession)(self).assemblyManager;
958
+ var assemblyNames = self.assemblyNames;
959
+ return assemblyNames.some(function (asm) { var _a, _b; return (_b = (_a = assemblyManager.get(asm)) === null || _a === void 0 ? void 0 : _a.cytobands) === null || _b === void 0 ? void 0 : _b.length; });
960
+ },
961
+ get cytobandOffset() {
962
+ return this.showCytobands
963
+ ? (0, util_1.measureText)(self.displayedRegions[0].refName, 12) + 15
964
+ : 0;
965
+ },
966
+ }); })
967
+ .views(function (self) { return ({
968
+ menuItems: function () {
969
+ var e_1, _a;
970
+ var canShowCytobands = self.canShowCytobands, showCytobands = self.showCytobands;
971
+ var menuItems = __spreadArray([
972
+ {
973
+ label: 'Return to import form',
974
+ onClick: function () {
975
+ (0, util_1.getSession)(self).queueDialog(function (handleClose) { return [
976
+ ui_1.ReturnToImportFormDialog,
977
+ { model: self, handleClose: handleClose },
978
+ ]; });
979
+ },
980
+ icon: FolderOpen_1.default,
981
+ },
982
+ {
983
+ label: 'Export SVG',
984
+ icon: PhotoCamera_1.default,
985
+ onClick: function () {
986
+ (0, util_1.getSession)(self).queueDialog(function (handleClose) { return [
987
+ ExportSvgDialog_1.default,
988
+ { model: self, handleClose: handleClose },
989
+ ]; });
990
+ },
991
+ },
992
+ {
993
+ label: 'Open track selector',
994
+ onClick: self.activateTrackSelector,
995
+ icon: Icons_1.TrackSelector,
996
+ },
997
+ {
998
+ label: 'Horizontally flip',
999
+ icon: SyncAlt_1.default,
1000
+ onClick: self.horizontallyFlip,
1001
+ },
1002
+ { type: 'divider' },
1003
+ {
1004
+ label: 'Show all regions in assembly',
1005
+ icon: Visibility_1.default,
1006
+ onClick: self.showAllRegionsInAssembly,
1007
+ },
1008
+ {
1009
+ label: 'Show center line',
1010
+ icon: Visibility_1.default,
1011
+ type: 'checkbox',
1012
+ checked: self.showCenterLine,
1013
+ onClick: self.toggleCenterLine,
1014
+ },
1015
+ {
1016
+ label: 'Show header',
1017
+ icon: Visibility_1.default,
1018
+ type: 'checkbox',
1019
+ checked: !self.hideHeader,
1020
+ onClick: self.toggleHeader,
1021
+ },
1022
+ {
1023
+ label: 'Show header overview',
1024
+ icon: Visibility_1.default,
1025
+ type: 'checkbox',
1026
+ checked: !self.hideHeaderOverview,
1027
+ onClick: self.toggleHeaderOverview,
1028
+ disabled: self.hideHeader,
1029
+ },
1030
+ {
1031
+ label: 'Show no tracks active button',
1032
+ icon: Visibility_1.default,
1033
+ type: 'checkbox',
1034
+ checked: !self.hideNoTracksActive,
1035
+ onClick: self.toggleNoTracksActive,
1036
+ },
1037
+ {
1038
+ label: 'Track labels',
1039
+ icon: Label_1.default,
1040
+ subMenu: [
1041
+ {
1042
+ label: 'Overlapping',
1043
+ icon: Visibility_1.default,
1044
+ type: 'radio',
1045
+ checked: self.trackLabels === 'overlapping',
1046
+ onClick: function () { return self.setTrackLabels('overlapping'); },
1047
+ },
1048
+ {
1049
+ label: 'Offset',
1050
+ icon: Visibility_1.default,
1051
+ type: 'radio',
1052
+ checked: self.trackLabels === 'offset',
1053
+ onClick: function () { return self.setTrackLabels('offset'); },
1054
+ },
1055
+ {
1056
+ label: 'Hidden',
1057
+ icon: Visibility_1.default,
1058
+ type: 'radio',
1059
+ checked: self.trackLabels === 'hidden',
1060
+ onClick: function () { return self.setTrackLabels('hidden'); },
1061
+ },
1062
+ ],
1063
+ }
1064
+ ], __read((canShowCytobands
1065
+ ? [
1066
+ {
1067
+ label: showCytobands ? 'Hide ideogram' : 'Show ideograms',
1068
+ onClick: function () {
1069
+ self.setShowCytobands(!showCytobands);
1070
+ },
1071
+ },
1072
+ ]
1073
+ : [])), false);
1074
+ try {
1075
+ // add track's view level menu options
1076
+ for (var _b = __values(self.trackTypeActions.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
1077
+ var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
1078
+ if (value.length) {
1079
+ menuItems.push({ type: 'divider' }, { type: 'subHeader', label: key });
1080
+ value.forEach(function (action) {
1081
+ menuItems.push(action);
1082
+ });
1083
+ }
1084
+ }
1389
1085
  }
1390
- }, _callee);
1391
- }))();
1392
- }
1393
- };
1394
- }).views(function (self) {
1395
- return {
1396
- rubberBandMenuItems: function rubberBandMenuItems() {
1397
- return [{
1398
- label: 'Zoom to region',
1399
- icon: _ZoomIn.default,
1400
- onClick: function onClick() {
1401
- var leftOffset = self.leftOffset,
1402
- rightOffset = self.rightOffset;
1403
-
1404
- if (leftOffset && rightOffset) {
1405
- self.moveTo(leftOffset, rightOffset);
1086
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1087
+ finally {
1088
+ try {
1089
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1090
+ }
1091
+ finally { if (e_1) throw e_1.error; }
1406
1092
  }
1407
- }
1408
- }, {
1409
- label: 'Get sequence',
1410
- icon: _MenuOpen.default,
1411
- onClick: function onClick() {
1412
- self.setSequenceDialogOpen(true);
1413
- }
1414
- }];
1415
- }
1416
- };
1417
- });
1418
- }
1093
+ return menuItems;
1094
+ },
1095
+ }); })
1096
+ .views(function (self) {
1097
+ var currentlyCalculatedStaticBlocks;
1098
+ var stringifiedCurrentlyCalculatedStaticBlocks = '';
1099
+ return {
1100
+ get staticBlocks() {
1101
+ var ret = (0, calculateStaticBlocks_1.default)(self);
1102
+ var sret = JSON.stringify(ret);
1103
+ if (stringifiedCurrentlyCalculatedStaticBlocks !== sret) {
1104
+ currentlyCalculatedStaticBlocks = ret;
1105
+ stringifiedCurrentlyCalculatedStaticBlocks = sret;
1106
+ }
1107
+ return currentlyCalculatedStaticBlocks;
1108
+ },
1109
+ get dynamicBlocks() {
1110
+ return (0, calculateDynamicBlocks_1.default)(self);
1111
+ },
1112
+ get roundedDynamicBlocks() {
1113
+ return this.dynamicBlocks.contentBlocks.map(function (block) {
1114
+ return __assign(__assign({}, block), { start: Math.floor(block.start), end: Math.ceil(block.end) });
1115
+ });
1116
+ },
1117
+ get visibleLocStrings() {
1118
+ return calculateVisibleLocStrings(this.dynamicBlocks.contentBlocks);
1119
+ },
1120
+ get coarseVisibleLocStrings() {
1121
+ return calculateVisibleLocStrings(self.coarseDynamicBlocks);
1122
+ },
1123
+ };
1124
+ })
1125
+ .actions(function (self) { return ({
1126
+ // this "clears the view" and makes the view return to the import form
1127
+ clearView: function () {
1128
+ self.setDisplayedRegions([]);
1129
+ self.tracks.clear();
1130
+ // it is necessary to run these after setting displayed regions empty
1131
+ // or else model.offsetPx gets set to Infinity and breaks
1132
+ // mobx-state-tree snapshot
1133
+ self.scrollTo(0);
1134
+ self.zoomTo(10);
1135
+ },
1136
+ setCoarseDynamicBlocks: function (blocks) {
1137
+ self.coarseDynamicBlocks = blocks.contentBlocks;
1138
+ self.coarseTotalBp = blocks.totalBp;
1139
+ },
1140
+ afterAttach: function () {
1141
+ var _this = this;
1142
+ (0, mobx_state_tree_1.addDisposer)(self, (0, mobx_1.autorun)(function () {
1143
+ if (self.initialized) {
1144
+ _this.setCoarseDynamicBlocks(self.dynamicBlocks);
1145
+ }
1146
+ }, { delay: 150 }));
1147
+ },
1148
+ }); })
1149
+ .actions(function (self) { return ({
1150
+ exportSvg: function (opts) {
1151
+ if (opts === void 0) { opts = {}; }
1152
+ return __awaiter(this, void 0, void 0, function () {
1153
+ var html, blob;
1154
+ return __generator(this, function (_a) {
1155
+ switch (_a.label) {
1156
+ case 0: return [4 /*yield*/, (0, LinearGenomeViewSvg_1.renderToSvg)(self, opts)];
1157
+ case 1:
1158
+ html = _a.sent();
1159
+ blob = new Blob([html], { type: 'image/svg+xml' });
1160
+ (0, file_saver_1.saveAs)(blob, opts.filename || 'image.svg');
1161
+ return [2 /*return*/];
1162
+ }
1163
+ });
1164
+ });
1165
+ },
1166
+ }); })
1167
+ .views(function (self) { return ({
1168
+ rubberBandMenuItems: function () {
1169
+ return [
1170
+ {
1171
+ label: 'Zoom to region',
1172
+ icon: ZoomIn_1.default,
1173
+ onClick: function () {
1174
+ var leftOffset = self.leftOffset, rightOffset = self.rightOffset;
1175
+ if (leftOffset && rightOffset) {
1176
+ self.moveTo(leftOffset, rightOffset);
1177
+ }
1178
+ },
1179
+ },
1180
+ {
1181
+ label: 'Get sequence',
1182
+ icon: MenuOpen_1.default,
1183
+ onClick: function () {
1184
+ self.setSequenceDialogOpen(true);
1185
+ },
1186
+ },
1187
+ ];
1188
+ },
1189
+ }); });
1190
+ }
1191
+ exports.stateModelFactory = stateModelFactory;
1192
+ var LinearGenomeView_1 = require("./components/LinearGenomeView");
1193
+ Object.defineProperty(exports, "ReactComponent", { enumerable: true, get: function () { return __importDefault(LinearGenomeView_1).default; } });
1194
+ //# sourceMappingURL=index.js.map