@jbrowse/plugin-dotplot-view 3.6.5 → 4.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 (210) hide show
  1. package/esm/ComparativeRenderer/index.d.ts +10 -10
  2. package/esm/ComparativeRenderer/index.js +4 -17
  3. package/esm/DiagonalizeDotplotRpc.d.ts +30 -0
  4. package/esm/DiagonalizeDotplotRpc.js +147 -0
  5. package/esm/DotplotDisplay/components/DotplotDisplay.d.ts +1 -1
  6. package/esm/DotplotDisplay/index.d.ts +3 -3
  7. package/esm/DotplotDisplay/index.js +4 -4
  8. package/esm/DotplotDisplay/renderDotplotBlock.d.ts +2 -1
  9. package/esm/DotplotDisplay/renderDotplotBlock.js +9 -4
  10. package/esm/DotplotDisplay/stateModelFactory.d.ts +148 -29
  11. package/esm/DotplotDisplay/stateModelFactory.js +17 -11
  12. package/esm/DotplotReadVsRef/DotplotReadVsRef.js +5 -6
  13. package/esm/DotplotReadVsRef/index.js +1 -1
  14. package/esm/DotplotRenderer/DotplotRenderer.d.ts +30 -48
  15. package/esm/DotplotRenderer/DotplotRenderer.js +55 -22
  16. package/esm/DotplotRenderer/clamp.d.ts +7 -0
  17. package/esm/DotplotRenderer/clamp.js +58 -0
  18. package/esm/DotplotRenderer/components/DotplotRendering.d.ts +1 -1
  19. package/esm/DotplotRenderer/components/DotplotRendering.js +1 -1
  20. package/esm/DotplotRenderer/configSchema.d.ts +3 -3
  21. package/esm/DotplotRenderer/configSchema.js +1 -1
  22. package/esm/DotplotRenderer/drawDotplot.d.ts +7 -6
  23. package/esm/DotplotRenderer/drawDotplot.js +95 -100
  24. package/esm/DotplotRenderer/index.js +4 -4
  25. package/esm/DotplotView/1dview.d.ts +25 -25
  26. package/esm/DotplotView/1dview.js +16 -4
  27. package/esm/DotplotView/components/Axes.d.ts +1 -1
  28. package/esm/DotplotView/components/Axes.js +31 -41
  29. package/esm/DotplotView/components/ColorBySelector.d.ts +5 -0
  30. package/esm/DotplotView/components/ColorBySelector.js +73 -0
  31. package/esm/DotplotView/components/DiagonalizationProgressDialog.d.ts +6 -0
  32. package/esm/DotplotView/components/DiagonalizationProgressDialog.js +123 -0
  33. package/esm/DotplotView/components/DotplotControls.d.ts +1 -1
  34. package/esm/DotplotView/components/DotplotControls.js +53 -15
  35. package/esm/DotplotView/components/DotplotGrid.d.ts +6 -0
  36. package/esm/DotplotView/components/{Grid.js → DotplotGrid.js} +19 -20
  37. package/esm/DotplotView/components/DotplotGridWrapper.d.ts +6 -0
  38. package/esm/DotplotView/components/DotplotGridWrapper.js +8 -0
  39. package/esm/DotplotView/components/DotplotTooltipClick.d.ts +2 -2
  40. package/esm/DotplotView/components/DotplotTooltipClick.js +4 -4
  41. package/esm/DotplotView/components/DotplotTooltipMouseover.d.ts +1 -1
  42. package/esm/DotplotView/components/DotplotTooltipMouseover.js +2 -2
  43. package/esm/DotplotView/components/DotplotTooltips.d.ts +15 -0
  44. package/esm/DotplotView/components/DotplotTooltips.js +7 -0
  45. package/esm/DotplotView/components/DotplotView.d.ts +2 -2
  46. package/esm/DotplotView/components/DotplotView.js +31 -171
  47. package/esm/DotplotView/components/DotplotWarnings.d.ts +1 -1
  48. package/esm/DotplotView/components/DotplotWarnings.js +7 -7
  49. package/esm/DotplotView/components/ExportSvgDialog.d.ts +1 -1
  50. package/esm/DotplotView/components/Header.d.ts +1 -1
  51. package/esm/DotplotView/components/Header.js +5 -5
  52. package/esm/DotplotView/components/ImportForm/ImportSyntenyOpenCustomTrack.d.ts +1 -1
  53. package/esm/DotplotView/components/ImportForm/ImportSyntenyOpenCustomTrack.js +6 -5
  54. package/esm/DotplotView/components/ImportForm/ImportSyntenyTrackSelector.d.ts +1 -1
  55. package/esm/DotplotView/components/ImportForm/ImportSyntenyTrackSelector.js +2 -3
  56. package/esm/DotplotView/components/ImportForm/TrackSelector.d.ts +10 -1
  57. package/esm/DotplotView/components/ImportForm/TrackSelector.js +8 -4
  58. package/esm/DotplotView/components/ImportForm/index.d.ts +1 -1
  59. package/esm/DotplotView/components/ImportForm/index.js +4 -10
  60. package/esm/DotplotView/components/ImportForm/selectors/AnchorsFileSelector.d.ts +1 -1
  61. package/esm/DotplotView/components/ImportForm/selectors/AnchorsFileSelector.js +2 -2
  62. package/esm/DotplotView/components/ImportForm/selectors/PifGzSelector.d.ts +1 -1
  63. package/esm/DotplotView/components/ImportForm/selectors/PifGzSelector.js +2 -2
  64. package/esm/DotplotView/components/ImportForm/selectors/SwapAssemblies.js +3 -3
  65. package/esm/DotplotView/components/ImportForm/selectors/SyntenyFileSelector.d.ts +1 -1
  66. package/esm/DotplotView/components/ImportForm/selectors/SyntenyFileSelector.js +3 -3
  67. package/esm/DotplotView/components/ImportForm/selectors/index.d.ts +3 -3
  68. package/esm/DotplotView/components/ImportForm/selectors/index.js +3 -3
  69. package/esm/DotplotView/components/MinLengthSlider.d.ts +5 -0
  70. package/esm/DotplotView/components/MinLengthSlider.js +39 -0
  71. package/esm/DotplotView/components/MouseInteractionLayer.d.ts +17 -0
  72. package/esm/DotplotView/components/MouseInteractionLayer.js +14 -0
  73. package/esm/DotplotView/components/OpacitySlider.d.ts +5 -0
  74. package/esm/DotplotView/components/OpacitySlider.js +37 -0
  75. package/esm/DotplotView/components/PanButtons.d.ts +1 -1
  76. package/esm/DotplotView/components/PanButtons.js +1 -1
  77. package/esm/DotplotView/components/SelectionContextMenu.d.ts +13 -0
  78. package/esm/DotplotView/components/SelectionContextMenu.js +39 -0
  79. package/esm/DotplotView/components/SliderTooltip.d.ts +2 -0
  80. package/esm/DotplotView/components/SliderTooltip.js +6 -0
  81. package/esm/DotplotView/components/WarningDialog.js +1 -1
  82. package/esm/DotplotView/components/hooks/useCtrlKeyTracking.d.ts +1 -0
  83. package/esm/DotplotView/components/hooks/useCtrlKeyTracking.js +21 -0
  84. package/esm/DotplotView/components/hooks/useCursorMode.d.ts +7 -0
  85. package/esm/DotplotView/components/hooks/useCursorMode.js +16 -0
  86. package/esm/DotplotView/components/hooks/useMouseCoordinates.d.ts +29 -0
  87. package/esm/DotplotView/components/hooks/useMouseCoordinates.js +49 -0
  88. package/esm/DotplotView/components/hooks/useMouseMoveHandler.d.ts +6 -0
  89. package/esm/DotplotView/components/hooks/useMouseMoveHandler.js +24 -0
  90. package/esm/DotplotView/components/hooks/useMouseUpHandler.d.ts +3 -0
  91. package/esm/DotplotView/components/hooks/useMouseUpHandler.js +28 -0
  92. package/esm/DotplotView/components/hooks/useWheelHandler.d.ts +8 -0
  93. package/esm/DotplotView/components/hooks/useWheelHandler.js +44 -0
  94. package/esm/DotplotView/components/util.d.ts +1 -1
  95. package/esm/DotplotView/components/util.js +18 -8
  96. package/esm/DotplotView/index.js +2 -2
  97. package/esm/DotplotView/model.d.ts +213 -90
  98. package/esm/DotplotView/model.js +147 -93
  99. package/esm/DotplotView/svgcomponents/SVGDotplotView.d.ts +1 -1
  100. package/esm/DotplotView/svgcomponents/SVGDotplotView.js +5 -6
  101. package/esm/DotplotView/types.d.ts +7 -1
  102. package/esm/LaunchDotplotView.js +6 -36
  103. package/esm/ServerSideRenderedBlockContent.js +6 -27
  104. package/esm/ServerSideSyntenyRendering.d.ts +1 -1
  105. package/esm/ServerSideSyntenyRendering.js +1 -1
  106. package/esm/index.d.ts +1 -0
  107. package/esm/index.js +9 -10
  108. package/esm/util.d.ts +1 -1
  109. package/package.json +28 -35
  110. package/dist/ComparativeRenderer/index.d.ts +0 -22
  111. package/dist/ComparativeRenderer/index.js +0 -53
  112. package/dist/DotplotDisplay/components/DotplotDisplay.d.ts +0 -6
  113. package/dist/DotplotDisplay/components/DotplotDisplay.js +0 -18
  114. package/dist/DotplotDisplay/index.d.ts +0 -5
  115. package/dist/DotplotDisplay/index.js +0 -36
  116. package/dist/DotplotDisplay/renderDotplotBlock.d.ts +0 -11
  117. package/dist/DotplotDisplay/renderDotplotBlock.js +0 -49
  118. package/dist/DotplotDisplay/stateModelFactory.d.ts +0 -102
  119. package/dist/DotplotDisplay/stateModelFactory.js +0 -119
  120. package/dist/DotplotReadVsRef/DotplotReadVsRef.d.ts +0 -3
  121. package/dist/DotplotReadVsRef/DotplotReadVsRef.js +0 -100
  122. package/dist/DotplotReadVsRef/index.d.ts +0 -2
  123. package/dist/DotplotReadVsRef/index.js +0 -41
  124. package/dist/DotplotRenderer/ComparativeRenderRpc.d.ts +0 -22
  125. package/dist/DotplotRenderer/ComparativeRenderRpc.js +0 -53
  126. package/dist/DotplotRenderer/DotplotRenderer.d.ts +0 -74
  127. package/dist/DotplotRenderer/DotplotRenderer.js +0 -102
  128. package/dist/DotplotRenderer/components/DotplotRendering.d.ts +0 -3
  129. package/dist/DotplotRenderer/components/DotplotRendering.js +0 -9
  130. package/dist/DotplotRenderer/configSchema.d.ts +0 -40
  131. package/dist/DotplotRenderer/configSchema.js +0 -57
  132. package/dist/DotplotRenderer/drawDotplot.d.ts +0 -21
  133. package/dist/DotplotRenderer/drawDotplot.js +0 -213
  134. package/dist/DotplotRenderer/index.d.ts +0 -2
  135. package/dist/DotplotRenderer/index.js +0 -17
  136. package/dist/DotplotView/1dview.d.ts +0 -199
  137. package/dist/DotplotView/1dview.js +0 -63
  138. package/dist/DotplotView/components/Axes.d.ts +0 -13
  139. package/dist/DotplotView/components/Axes.js +0 -107
  140. package/dist/DotplotView/components/CursorIcon.d.ts +0 -3
  141. package/dist/DotplotView/components/CursorIcon.js +0 -15
  142. package/dist/DotplotView/components/DotplotControls.d.ts +0 -5
  143. package/dist/DotplotView/components/DotplotControls.js +0 -115
  144. package/dist/DotplotView/components/DotplotTooltipClick.d.ts +0 -10
  145. package/dist/DotplotView/components/DotplotTooltipClick.js +0 -17
  146. package/dist/DotplotView/components/DotplotTooltipMouseover.d.ts +0 -9
  147. package/dist/DotplotView/components/DotplotTooltipMouseover.js +0 -16
  148. package/dist/DotplotView/components/DotplotView.d.ts +0 -5
  149. package/dist/DotplotView/components/DotplotView.js +0 -275
  150. package/dist/DotplotView/components/DotplotWarnings.d.ts +0 -5
  151. package/dist/DotplotView/components/DotplotWarnings.js +0 -53
  152. package/dist/DotplotView/components/ExportSvgDialog.d.ts +0 -7
  153. package/dist/DotplotView/components/ExportSvgDialog.js +0 -53
  154. package/dist/DotplotView/components/Grid.d.ts +0 -9
  155. package/dist/DotplotView/components/Grid.js +0 -47
  156. package/dist/DotplotView/components/Header.d.ts +0 -9
  157. package/dist/DotplotView/components/Header.js +0 -33
  158. package/dist/DotplotView/components/ImportForm/ImportSyntenyOpenCustomTrack.d.ts +0 -7
  159. package/dist/DotplotView/components/ImportForm/ImportSyntenyOpenCustomTrack.js +0 -78
  160. package/dist/DotplotView/components/ImportForm/ImportSyntenyTrackSelector.d.ts +0 -7
  161. package/dist/DotplotView/components/ImportForm/ImportSyntenyTrackSelector.js +0 -42
  162. package/dist/DotplotView/components/ImportForm/TrackSelector.d.ts +0 -7
  163. package/dist/DotplotView/components/ImportForm/TrackSelector.js +0 -23
  164. package/dist/DotplotView/components/ImportForm/getAdapter.d.ts +0 -117
  165. package/dist/DotplotView/components/ImportForm/getAdapter.js +0 -68
  166. package/dist/DotplotView/components/ImportForm/index.d.ts +0 -5
  167. package/dist/DotplotView/components/ImportForm/index.js +0 -76
  168. package/dist/DotplotView/components/ImportForm/selectors/AnchorsFileSelector.d.ts +0 -3
  169. package/dist/DotplotView/components/ImportForm/selectors/AnchorsFileSelector.js +0 -23
  170. package/dist/DotplotView/components/ImportForm/selectors/PifGzSelector.d.ts +0 -3
  171. package/dist/DotplotView/components/ImportForm/selectors/PifGzSelector.js +0 -13
  172. package/dist/DotplotView/components/ImportForm/selectors/SelectorTypes.d.ts +0 -23
  173. package/dist/DotplotView/components/ImportForm/selectors/SelectorTypes.js +0 -10
  174. package/dist/DotplotView/components/ImportForm/selectors/SwapAssemblies.d.ts +0 -13
  175. package/dist/DotplotView/components/ImportForm/selectors/SwapAssemblies.js +0 -32
  176. package/dist/DotplotView/components/ImportForm/selectors/SyntenyFileSelector.d.ts +0 -3
  177. package/dist/DotplotView/components/ImportForm/selectors/SyntenyFileSelector.js +0 -24
  178. package/dist/DotplotView/components/ImportForm/selectors/index.d.ts +0 -3
  179. package/dist/DotplotView/components/ImportForm/selectors/index.js +0 -12
  180. package/dist/DotplotView/components/ImportForm/util.d.ts +0 -10
  181. package/dist/DotplotView/components/ImportForm/util.js +0 -24
  182. package/dist/DotplotView/components/PanButtons.d.ts +0 -5
  183. package/dist/DotplotView/components/PanButtons.js +0 -47
  184. package/dist/DotplotView/components/WarningDialog.d.ts +0 -16
  185. package/dist/DotplotView/components/WarningDialog.js +0 -39
  186. package/dist/DotplotView/components/util.d.ts +0 -14
  187. package/dist/DotplotView/components/util.js +0 -82
  188. package/dist/DotplotView/index.d.ts +0 -2
  189. package/dist/DotplotView/index.js +0 -52
  190. package/dist/DotplotView/model.d.ts +0 -435
  191. package/dist/DotplotView/model.js +0 -487
  192. package/dist/DotplotView/svgcomponents/SVGBackground.d.ts +0 -4
  193. package/dist/DotplotView/svgcomponents/SVGBackground.js +0 -10
  194. package/dist/DotplotView/svgcomponents/SVGDotplotView.d.ts +0 -2
  195. package/dist/DotplotView/svgcomponents/SVGDotplotView.js +0 -30
  196. package/dist/DotplotView/types.d.ts +0 -12
  197. package/dist/DotplotView/types.js +0 -2
  198. package/dist/LaunchDotplotView.d.ts +0 -2
  199. package/dist/LaunchDotplotView.js +0 -43
  200. package/dist/ServerSideRenderedBlockContent.d.ts +0 -12
  201. package/dist/ServerSideRenderedBlockContent.js +0 -65
  202. package/dist/ServerSideSyntenyRendering.d.ts +0 -13
  203. package/dist/ServerSideSyntenyRendering.js +0 -23
  204. package/dist/index.d.ts +0 -7
  205. package/dist/index.js +0 -40
  206. package/dist/util.d.ts +0 -9
  207. package/dist/util.js +0 -7
  208. package/esm/DotplotRenderer/ComparativeRenderRpc.d.ts +0 -22
  209. package/esm/DotplotRenderer/ComparativeRenderRpc.js +0 -47
  210. package/esm/DotplotView/components/Grid.d.ts +0 -9
@@ -3,17 +3,21 @@ import { getConf } from '@jbrowse/core/configuration';
3
3
  import BaseViewModel from '@jbrowse/core/pluggableElementTypes/models/BaseViewModel';
4
4
  import { TrackSelector as TrackSelectorIcon } from '@jbrowse/core/ui/Icons';
5
5
  import { getSession, getTickDisplayStr, isSessionModelWithWidgets, localStorageGetBoolean, localStorageGetItem, max, measureText, minmax, } from '@jbrowse/core/util';
6
- import { getParentRenderProps } from '@jbrowse/core/util/tracks';
6
+ import { getParentRenderProps, hideTrackGeneric, showTrackGeneric, toggleTrackGeneric, } from '@jbrowse/core/util/tracks';
7
7
  import { ElementId } from '@jbrowse/core/util/types/mst';
8
+ import { addDisposer, cast, getParent, getSnapshot, types, } from '@jbrowse/mobx-state-tree';
8
9
  import FolderOpenIcon from '@mui/icons-material/FolderOpen';
9
10
  import PhotoCameraIcon from '@mui/icons-material/PhotoCamera';
10
- import { saveAs } from 'file-saver';
11
- import { autorun, observable, transaction } from 'mobx';
12
- import { addDisposer, cast, getParent, getRoot, getSnapshot, resolveIdentifier, types, } from 'mobx-state-tree';
13
- import { Dotplot1DView, DotplotHView, DotplotVView } from './1dview';
14
- import { getBlockLabelKeysToHide, makeTicks } from './components/util';
15
- const ExportSvgDialog = lazy(() => import('./components/ExportSvgDialog'));
11
+ import { autorun, observable } from 'mobx';
12
+ import { Dotplot1DView, DotplotHView, DotplotVView } from "./1dview.js";
13
+ import { getBlockLabelKeysToHide, makeTicks } from "./components/util.js";
14
+ const ExportSvgDialog = lazy(() => import("./components/ExportSvgDialog.js"));
16
15
  const ReturnToImportFormDialog = lazy(() => import('@jbrowse/core/ui/ReturnToImportFormDialog'));
16
+ const defaultHeight = 600;
17
+ const defaultBorderSize = 20;
18
+ const defaultTickSize = 5;
19
+ const defaultHtextRotation = -90;
20
+ const defaultFontSize = 15;
17
21
  function stringLenPx(a) {
18
22
  return measureText(a.slice(0, 30));
19
23
  }
@@ -30,12 +34,12 @@ export default function stateModelFactory(pm) {
30
34
  .compose('DotplotView', BaseViewModel, types.model({
31
35
  id: ElementId,
32
36
  type: types.literal('DotplotView'),
33
- height: 600,
34
- borderSize: 20,
35
- tickSize: 5,
37
+ height: defaultHeight,
38
+ borderSize: defaultBorderSize,
39
+ tickSize: defaultTickSize,
36
40
  vtextRotation: 0,
37
- htextRotation: -90,
38
- fontSize: 15,
41
+ htextRotation: defaultHtextRotation,
42
+ fontSize: defaultFontSize,
39
43
  trackSelectorType: 'hierarchical',
40
44
  assemblyNames: types.array(types.string),
41
45
  drawCigar: true,
@@ -43,6 +47,7 @@ export default function stateModelFactory(pm) {
43
47
  vview: types.optional(DotplotVView, {}),
44
48
  tracks: types.array(pm.pluggableMstType('track', 'stateModel')),
45
49
  viewTrackConfigs: types.array(pm.pluggableConfigSchemaType('track')),
50
+ init: types.frozen(),
46
51
  }))
47
52
  .volatile(() => ({
48
53
  volatileWidth: undefined,
@@ -77,13 +82,13 @@ export default function stateModelFactory(pm) {
77
82
  get assemblyErrors() {
78
83
  const { assemblyManager } = getSession(self);
79
84
  return self.assemblyNames
80
- .map(a => { var _a; return (_a = assemblyManager.get(a)) === null || _a === void 0 ? void 0 : _a.error; })
85
+ .map(a => assemblyManager.get(a)?.error)
81
86
  .filter(f => !!f)
82
87
  .join(', ');
83
88
  },
84
89
  get assembliesInitialized() {
85
90
  const { assemblyManager } = getSession(self);
86
- return self.assemblyNames.every(n => { var _a, _b; return (_b = (_a = assemblyManager.get(n)) === null || _a === void 0 ? void 0 : _a.initialized) !== null && _b !== void 0 ? _b : true; });
91
+ return self.assemblyNames.every(n => assemblyManager.get(n)?.initialized ?? true);
87
92
  },
88
93
  }))
89
94
  .views(self => ({
@@ -107,8 +112,20 @@ export default function stateModelFactory(pm) {
107
112
  ? []
108
113
  : makeTicks(staticBlocks.contentBlocks, bpPerPx);
109
114
  },
110
- get loading() {
111
- return self.assemblyNames.length > 0 && !this.initialized;
115
+ get hasSomethingToShow() {
116
+ return self.assemblyNames.length > 0 || !!self.init;
117
+ },
118
+ get showLoading() {
119
+ return (this.hasSomethingToShow &&
120
+ !this.initialized &&
121
+ !self.volatileError &&
122
+ !self.assemblyErrors);
123
+ },
124
+ get showImportForm() {
125
+ return !this.hasSomethingToShow || !!self.volatileError;
126
+ },
127
+ get loadingMessage() {
128
+ return this.showLoading ? 'Loading' : undefined;
112
129
  },
113
130
  get viewWidth() {
114
131
  return self.width - self.borderX;
@@ -164,14 +181,25 @@ export default function stateModelFactory(pm) {
164
181
  setError(e) {
165
182
  self.volatileError = e;
166
183
  },
184
+ setInit(init) {
185
+ self.init = init;
186
+ },
167
187
  zoomOut() {
168
188
  self.hview.zoomOut();
169
189
  self.vview.zoomOut();
190
+ if (self.hview.bpPerPx >= self.hview.maxBpPerPx * 0.99) {
191
+ self.hview.center();
192
+ }
193
+ if (self.vview.bpPerPx >= self.vview.maxBpPerPx * 0.99) {
194
+ self.vview.center();
195
+ }
170
196
  },
171
197
  zoomIn() {
172
198
  self.hview.zoomIn();
173
199
  self.vview.zoomIn();
174
200
  },
201
+ }))
202
+ .actions(self => ({
175
203
  activateTrackSelector() {
176
204
  if (self.trackSelectorType === 'hierarchical') {
177
205
  const session = getSession(self);
@@ -184,46 +212,18 @@ export default function stateModelFactory(pm) {
184
212
  throw new Error(`invalid track selector type ${self.trackSelectorType}`);
185
213
  },
186
214
  showTrack(trackId, initialSnapshot = {}) {
187
- const schema = pm.pluggableConfigSchemaType('track');
188
- const conf = resolveIdentifier(schema, getRoot(self), trackId);
189
- const trackType = pm.getTrackType(conf.type);
190
- if (!trackType) {
191
- throw new Error(`unknown track type ${conf.type}`);
192
- }
193
- const viewType = pm.getViewType(self.type);
194
- const displayConf = conf.displays.find((d) => viewType.displayTypes.find(type => type.name === d.type));
195
- if (!displayConf) {
196
- throw new Error(`could not find a compatible display for view type ${self.type}`);
197
- }
198
- const track = trackType.stateModel.create({
199
- ...initialSnapshot,
200
- type: conf.type,
201
- configuration: conf,
202
- displays: [{ type: displayConf.type, configuration: displayConf }],
203
- });
204
- self.tracks.push(track);
215
+ return showTrackGeneric(self, trackId, initialSnapshot);
205
216
  },
206
217
  hideTrack(trackId) {
207
- const schema = pm.pluggableConfigSchemaType('track');
208
- const conf = resolveIdentifier(schema, getRoot(self), trackId);
209
- const tracks = self.tracks.filter(t => t.configuration === conf);
210
- transaction(() => {
211
- for (const track of tracks) {
212
- self.tracks.remove(track);
213
- }
214
- });
215
- return tracks.length;
218
+ return hideTrackGeneric(self, trackId);
216
219
  },
217
220
  toggleTrack(trackId) {
218
- const hiddenCount = this.hideTrack(trackId);
219
- if (!hiddenCount) {
220
- this.showTrack(trackId);
221
- return true;
222
- }
223
- return false;
221
+ toggleTrackGeneric(self, trackId);
224
222
  },
225
223
  setAssemblyNames(target, query) {
226
224
  self.assemblyNames = cast([target, query]);
225
+ self.hview.setDisplayedRegions([]);
226
+ self.vview.setDisplayedRegions([]);
227
227
  },
228
228
  setViews(arr) {
229
229
  self.hview = cast(arr[0]);
@@ -249,12 +249,46 @@ export default function stateModelFactory(pm) {
249
249
  self.vview.moveTo(y2, y1);
250
250
  }
251
251
  },
252
+ calculateBorders() {
253
+ if (self.volatileWidth === undefined) {
254
+ return { borderX: self.borderX, borderY: self.borderY };
255
+ }
256
+ const { vview, hview, viewHeight, viewWidth } = self;
257
+ const padding = 40;
258
+ const vblocks = vview.dynamicBlocks.contentBlocks;
259
+ const hblocks = hview.dynamicBlocks.contentBlocks;
260
+ const hoffset = hview.offsetPx;
261
+ const voffset = vview.offsetPx;
262
+ const vhide = getBlockLabelKeysToHide(vblocks, viewHeight, voffset);
263
+ const hhide = getBlockLabelKeysToHide(hblocks, viewWidth, hoffset);
264
+ const by = pxWidthForBlocks(hblocks, vview.bpPerPx, hhide);
265
+ const bx = pxWidthForBlocks(vblocks, hview.bpPerPx, vhide);
266
+ return {
267
+ borderX: Math.max(bx + padding, 50),
268
+ borderY: Math.max(by + padding, 50),
269
+ };
270
+ },
252
271
  showAllRegions() {
272
+ self.hview.zoomTo(self.hview.maxBpPerPx);
273
+ self.vview.zoomTo(self.vview.maxBpPerPx);
274
+ const { borderX, borderY } = this.calculateBorders();
275
+ self.setBorderX(borderX);
276
+ self.setBorderY(borderY);
253
277
  self.hview.zoomTo(self.hview.maxBpPerPx);
254
278
  self.vview.zoomTo(self.vview.maxBpPerPx);
255
279
  self.vview.center();
256
280
  self.hview.center();
257
281
  },
282
+ initializeDisplayedRegions() {
283
+ const { hview, vview, assemblyNames } = self;
284
+ if (hview.displayedRegions.length && vview.displayedRegions.length) {
285
+ return;
286
+ }
287
+ const { assemblyManager } = getSession(self);
288
+ hview.setDisplayedRegions(assemblyManager.get(assemblyNames[0])?.regions || []);
289
+ vview.setDisplayedRegions(assemblyManager.get(assemblyNames[1])?.regions || []);
290
+ this.showAllRegions();
291
+ },
258
292
  onDotplotView(mousedown, mouseup) {
259
293
  const result = this.getCoords(mousedown, mouseup);
260
294
  if (result) {
@@ -283,9 +317,12 @@ export default function stateModelFactory(pm) {
283
317
  const trackConf = getParent(displayConf, 2);
284
318
  return {
285
319
  type: trackConf.type,
286
- configuration: trackConf,
320
+ configuration: getSnapshot(trackConf),
287
321
  displays: [
288
- { type: displayConf.type, configuration: displayConf },
322
+ {
323
+ type: displayConf.type,
324
+ configuration: getSnapshot(displayConf),
325
+ },
289
326
  ],
290
327
  };
291
328
  });
@@ -315,20 +352,40 @@ export default function stateModelFactory(pm) {
315
352
  }))
316
353
  .actions(self => ({
317
354
  async exportSvg(opts = {}) {
318
- const { renderToSvg } = await import('./svgcomponents/SVGDotplotView');
355
+ const { renderToSvg } = await import("./svgcomponents/SVGDotplotView.js");
319
356
  const html = await renderToSvg(self, opts);
320
- const blob = new Blob([html], { type: 'image/svg+xml' });
321
- saveAs(blob, opts.filename || 'image.svg');
357
+ const { saveAs } = await import('file-saver-es');
358
+ saveAs(new Blob([html], { type: 'image/svg+xml' }), opts.filename || 'image.svg');
322
359
  },
323
360
  beforeDestroy() {
324
- var _a;
325
361
  const session = getSession(self);
326
362
  for (const name of self.assemblyNames) {
327
- (_a = session.removeTemporaryAssembly) === null || _a === void 0 ? void 0 : _a.call(session, name);
363
+ session.removeTemporaryAssembly?.(name);
328
364
  }
329
365
  },
330
366
  afterAttach() {
331
- addDisposer(self, autorun(() => {
367
+ addDisposer(self, autorun(function dotplotInitAutorun() {
368
+ const { init, volatileWidth } = self;
369
+ if (!volatileWidth || !init) {
370
+ return;
371
+ }
372
+ const session = getSession(self);
373
+ const assemblyNames = init.views.map(v => v.assembly);
374
+ self.setAssemblyNames(assemblyNames[0], assemblyNames[1]);
375
+ if (init.tracks) {
376
+ for (const trackId of init.tracks) {
377
+ try {
378
+ self.showTrack(trackId);
379
+ }
380
+ catch (e) {
381
+ console.error(e);
382
+ session.notifyError(`${e}`, e);
383
+ }
384
+ }
385
+ }
386
+ self.setInit(undefined);
387
+ }, { name: 'DotplotInit' }));
388
+ addDisposer(self, autorun(function dotplotLocalStorageAutorun() {
332
389
  const s = (s) => JSON.stringify(s);
333
390
  const { showPanButtons, wheelMode, cursorMode } = self;
334
391
  if (typeof localStorage !== 'undefined') {
@@ -336,44 +393,22 @@ export default function stateModelFactory(pm) {
336
393
  localStorage.setItem('dotplot-cursorMode', cursorMode);
337
394
  localStorage.setItem('dotplot-wheelMode', wheelMode);
338
395
  }
339
- }));
340
- addDisposer(self, autorun(() => {
341
- const session = getSession(self);
342
- if (self.volatileWidth === undefined ||
343
- !self.assembliesInitialized) {
344
- return;
396
+ }, { name: 'DotplotLocalStorage' }));
397
+ addDisposer(self, autorun(function dotplotRegionsAutorun() {
398
+ void self.assemblyNames.slice();
399
+ if (self.volatileWidth !== undefined &&
400
+ self.assembliesInitialized) {
401
+ self.initializeDisplayedRegions();
345
402
  }
346
- if (self.hview.displayedRegions.length > 0 &&
347
- self.vview.displayedRegions.length > 0) {
348
- return;
349
- }
350
- const views = [self.hview, self.vview];
351
- transaction(() => {
352
- for (const [index, name] of self.assemblyNames.entries()) {
353
- const assembly = session.assemblyManager.get(name);
354
- const view = views[index];
355
- view.setDisplayedRegions((assembly === null || assembly === void 0 ? void 0 : assembly.regions) || []);
356
- }
357
- self.showAllRegions();
358
- });
359
- }, { delay: 1000 }));
360
- addDisposer(self, autorun(function borderSetter() {
403
+ }, { delay: 1000, name: 'DotplotRegions' }));
404
+ addDisposer(self, autorun(function dotplotBorderAutorun() {
361
405
  if (self.volatileWidth === undefined) {
362
406
  return;
363
407
  }
364
- const { vview, hview, viewHeight, viewWidth } = self;
365
- const padding = 40;
366
- const vblocks = vview.dynamicBlocks.contentBlocks;
367
- const hblocks = hview.dynamicBlocks.contentBlocks;
368
- const hoffset = hview.offsetPx;
369
- const voffset = vview.offsetPx;
370
- const vhide = getBlockLabelKeysToHide(vblocks, viewHeight, voffset);
371
- const hhide = getBlockLabelKeysToHide(hblocks, viewWidth, hoffset);
372
- const by = pxWidthForBlocks(hblocks, vview.bpPerPx, hhide);
373
- const bx = pxWidthForBlocks(vblocks, hview.bpPerPx, vhide);
374
- self.setBorderY(Math.max(by + padding, 50));
375
- self.setBorderX(Math.max(bx + padding, 50));
376
- }));
408
+ const { borderX, borderY } = self.calculateBorders();
409
+ self.setBorderX(borderX);
410
+ self.setBorderY(borderY);
411
+ }, { name: 'DotplotBorder' }));
377
412
  },
378
413
  squareView() {
379
414
  const { hview, vview } = self;
@@ -441,6 +476,25 @@ export default function stateModelFactory(pm) {
441
476
  get error() {
442
477
  return self.volatileError || self.assemblyErrors;
443
478
  },
444
- }));
479
+ }))
480
+ .postProcessSnapshot(snap => {
481
+ if (!snap) {
482
+ return snap;
483
+ }
484
+ const { init, height, borderSize, tickSize, vtextRotation, htextRotation, fontSize, trackSelectorType, drawCigar, assemblyNames, viewTrackConfigs, ...rest } = snap;
485
+ return {
486
+ ...rest,
487
+ ...(height !== defaultHeight ? { height } : {}),
488
+ ...(borderSize !== defaultBorderSize ? { borderSize } : {}),
489
+ ...(tickSize !== defaultTickSize ? { tickSize } : {}),
490
+ ...(vtextRotation ? { vtextRotation } : {}),
491
+ ...(htextRotation !== defaultHtextRotation ? { htextRotation } : {}),
492
+ ...(fontSize !== defaultFontSize ? { fontSize } : {}),
493
+ ...(trackSelectorType !== 'hierarchical' ? { trackSelectorType } : {}),
494
+ ...(!drawCigar ? { drawCigar } : {}),
495
+ ...(assemblyNames.length ? { assemblyNames } : {}),
496
+ ...(viewTrackConfigs.length ? { viewTrackConfigs } : {}),
497
+ };
498
+ });
445
499
  }
446
- export { Dotplot1DView } from './1dview';
500
+ export { Dotplot1DView } from "./1dview.js";
@@ -1,2 +1,2 @@
1
- import type { DotplotViewModel, ExportSvgOptions } from '../model';
1
+ import type { DotplotViewModel, ExportSvgOptions } from '../model.ts';
2
2
  export declare function renderToSvg(model: DotplotViewModel, opts: ExportSvgOptions): Promise<string>;
@@ -3,15 +3,14 @@ import { createJBrowseTheme } from '@jbrowse/core/ui';
3
3
  import { getSession, renderToStaticMarkup } from '@jbrowse/core/util';
4
4
  import { ThemeProvider } from '@mui/material';
5
5
  import { when } from 'mobx';
6
- import SVGBackground from './SVGBackground';
7
- import { HorizontalAxisRaw, VerticalAxisRaw } from '../components/Axes';
8
- import { GridRaw } from '../components/Grid';
6
+ import SVGBackground from "./SVGBackground.js";
7
+ import { HorizontalAxisRaw, VerticalAxisRaw } from "../components/Axes.js";
8
+ import DotplotGrid from "../components/DotplotGrid.js";
9
9
  export async function renderToSvg(model, opts) {
10
- var _a;
11
10
  await when(() => model.initialized);
12
11
  const { themeName = 'default', Wrapper = ({ children }) => children } = opts;
13
12
  const session = getSession(model);
14
- const theme = (_a = session.allThemes) === null || _a === void 0 ? void 0 : _a.call(session)[themeName];
13
+ const theme = session.allThemes?.()[themeName];
15
14
  const { width, borderX, viewWidth, viewHeight, tracks, height } = model;
16
15
  const shift = 50;
17
16
  const displayResults = await Promise.all(tracks.map(async (track) => {
@@ -20,5 +19,5 @@ export async function renderToSvg(model, opts) {
20
19
  return { track, result: await display.renderSvg({ ...opts, theme }) };
21
20
  }));
22
21
  const w = width + shift * 2;
23
- return renderToStaticMarkup(_jsx(ThemeProvider, { theme: createJBrowseTheme(theme), children: _jsx(Wrapper, { children: _jsxs("svg", { width: width, height: height, xmlns: "http://www.w3.org/2000/svg", xmlnsXlink: "http://www.w3.org/1999/xlink", viewBox: [0, 0, w, height].toString(), children: [_jsx(SVGBackground, { width: w, height: height }), _jsx(VerticalAxisRaw, { model: model }), _jsxs("g", { transform: `translate(${borderX} 0)`, children: [_jsx(GridRaw, { model: model }), _jsx("defs", { children: _jsx("clipPath", { id: "clip-ruler", children: _jsx("rect", { x: 0, y: 0, width: viewWidth, height: viewHeight }) }) }), _jsx("g", { clipPath: "url(#clip-ruler)", children: displayResults.map(({ result }, i) => (_jsx("g", { children: result }, i))) })] }), _jsx("g", { transform: `translate(${borderX} ${viewHeight})`, children: _jsx(HorizontalAxisRaw, { model: model }) })] }) }) }));
22
+ return renderToStaticMarkup(_jsx(ThemeProvider, { theme: createJBrowseTheme(theme), children: _jsx(Wrapper, { children: _jsxs("svg", { width: width, height: height, xmlns: "http://www.w3.org/2000/svg", xmlnsXlink: "http://www.w3.org/1999/xlink", viewBox: [0, 0, w, height].toString(), children: [_jsx(SVGBackground, { width: w, height: height }), _jsx(VerticalAxisRaw, { model: model }), _jsxs("g", { transform: `translate(${borderX} 0)`, children: [_jsx(DotplotGrid, { model: model }), _jsx("defs", { children: _jsx("clipPath", { id: "clip-ruler", children: _jsx("rect", { x: 0, y: 0, width: viewWidth, height: viewHeight }) }) }), _jsx("g", { clipPath: "url(#clip-ruler)", children: displayResults.map(({ result }, i) => (_jsx("g", { children: result }, i))) })] }), _jsx("g", { transform: `translate(${borderX} ${viewHeight})`, children: _jsx(HorizontalAxisRaw, { model: model }) })] }) }) }));
24
23
  }
@@ -1,5 +1,5 @@
1
1
  import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
2
- import type { SnapshotIn } from 'mobx-state-tree';
2
+ import type { SnapshotIn } from '@jbrowse/mobx-state-tree';
3
3
  export type Conf = SnapshotIn<AnyConfigurationModel>;
4
4
  export type ImportFormSyntenyTrack = {
5
5
  type: 'preConfigured';
@@ -10,3 +10,9 @@ export type ImportFormSyntenyTrack = {
10
10
  } | {
11
11
  type: 'none';
12
12
  };
13
+ export interface DotplotViewInit {
14
+ views: {
15
+ assembly: string;
16
+ }[];
17
+ tracks?: string[];
18
+ }
@@ -1,40 +1,10 @@
1
- import { transaction } from 'mobx';
2
1
  export default function LaunchDotplotView(pluginManager) {
3
2
  pluginManager.addToExtensionPoint('LaunchView-DotplotView', async ({ session, views, tracks = [], }) => {
4
- try {
5
- const model = session.addView('DotplotView', {});
6
- const assemblyNames = views.map(view => view.assembly);
7
- transaction(() => {
8
- model.setViews([
9
- { bpPerPx: 0.1, offsetPx: 0 },
10
- { bpPerPx: 0.1, offsetPx: 0 },
11
- ]);
12
- model.setAssemblyNames(assemblyNames[0], assemblyNames[1]);
13
- });
14
- const idsNotFound = [];
15
- for (const track of tracks) {
16
- tryTrack(model, track, idsNotFound);
17
- }
18
- if (idsNotFound.length) {
19
- throw new Error(`Could not resolve identifiers: ${idsNotFound.join(',')}`);
20
- }
21
- }
22
- catch (e) {
23
- session.notifyError(`${e}`, e);
24
- throw e;
25
- }
3
+ session.addView('DotplotView', {
4
+ init: {
5
+ views: views.map(v => ({ assembly: v.assembly })),
6
+ tracks,
7
+ },
8
+ });
26
9
  });
27
10
  }
28
- function tryTrack(model, trackId, idsNotFound) {
29
- try {
30
- model.showTrack(trackId);
31
- }
32
- catch (e) {
33
- if (/Could not resolve identifier/.exec(`${e}`)) {
34
- idsNotFound.push(trackId);
35
- }
36
- else {
37
- throw e;
38
- }
39
- }
40
- }
@@ -1,9 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect, useState } from 'react';
3
- import { LoadingEllipses } from '@jbrowse/core/ui';
4
- import { Typography } from '@mui/material';
2
+ import { ErrorMessage, LoadingEllipses } from '@jbrowse/core/ui';
3
+ import { makeStyles } from '@jbrowse/core/util/tss-react';
5
4
  import { observer } from 'mobx-react';
6
- import { makeStyles } from 'tss-react/mui';
7
5
  const useStyles = makeStyles()(theme => {
8
6
  const bg = theme.palette.action.disabledBackground;
9
7
  return {
@@ -13,39 +11,20 @@ const useStyles = makeStyles()(theme => {
13
11
  backgroundImage: `repeating-linear-gradient(45deg, transparent, transparent 5px, ${bg} 5px, ${bg} 10px)`,
14
12
  textAlign: 'center',
15
13
  },
16
- blockMessage: {
17
- backgroundColor: bg,
18
- padding: '10px',
19
- },
20
- blockError: {
21
- backgroundColor: bg,
22
- padding: '10px',
23
- color: 'red',
24
- },
25
14
  };
26
15
  });
27
16
  function LoadingMessage() {
28
- const [shown, setShown] = useState(false);
29
17
  const { classes } = useStyles();
30
- useEffect(() => {
31
- const timeout = setTimeout(() => {
32
- setShown(true);
33
- }, 300);
34
- return () => {
35
- clearTimeout(timeout);
36
- };
37
- }, []);
38
- return shown ? (_jsx("div", { className: classes.loading, children: _jsx(LoadingEllipses, {}) })) : null;
18
+ return (_jsx("div", { className: classes.loading, children: _jsx(LoadingEllipses, {}) }));
39
19
  }
40
20
  function BlockMessage({ messageText }) {
41
21
  const { classes } = useStyles();
42
- return (_jsx("div", { className: classes.blockMessage, children: _jsx(Typography, { children: messageText }) }));
22
+ return (_jsx("div", { className: classes.loading, children: _jsx(LoadingEllipses, { message: messageText }) }));
43
23
  }
44
24
  function BlockError({ error }) {
45
- const { classes } = useStyles();
46
- return (_jsx("div", { className: classes.blockError, children: _jsx(Typography, { children: `${error}` }) }));
25
+ return _jsx(ErrorMessage, { error: error });
47
26
  }
48
- const ServerSideRenderedDotplotContent = observer(function ({ model, style, }) {
27
+ const ServerSideRenderedDotplotContent = observer(function ServerSideRenderedDotplotContent({ model, style, }) {
49
28
  if (model.error) {
50
29
  return _jsx(BlockError, { error: model.error, "data-testid": "reload_button" });
51
30
  }
@@ -7,7 +7,7 @@ interface ModelType {
7
7
  highResolutionScaling?: number;
8
8
  };
9
9
  }
10
- declare const ServerSideSyntenyRendering: ({ model, }: {
10
+ declare const ServerSideSyntenyRendering: ({ model }: {
11
11
  model: ModelType;
12
12
  }) => import("react/jsx-runtime").JSX.Element;
13
13
  export default ServerSideSyntenyRendering;
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useEffect, useRef, useState } from 'react';
3
3
  import { drawImageOntoCanvasContext } from '@jbrowse/core/util/offscreenCanvasPonyfill';
4
4
  import { observer } from 'mobx-react';
5
- const ServerSideSyntenyRendering = observer(function ({ model, }) {
5
+ const ServerSideSyntenyRendering = observer(function ServerSideSyntenyRendering({ model }) {
6
6
  const { imageData, style, renderProps } = model;
7
7
  const { width, height, highResolutionScaling = 1 } = renderProps;
8
8
  const featureCanvas = useRef(null);
package/esm/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import Plugin from '@jbrowse/core/Plugin';
2
2
  import type PluginManager from '@jbrowse/core/PluginManager';
3
+ export type { DotplotImportFormSyntenyOption } from './DotplotView/components/ImportForm/TrackSelector';
3
4
  export default class DotplotPlugin extends Plugin {
4
5
  name: string;
5
6
  install(pluginManager: PluginManager): void;
package/esm/index.js CHANGED
@@ -1,17 +1,15 @@
1
1
  import Plugin from '@jbrowse/core/Plugin';
2
2
  import { isAbstractMenuManager } from '@jbrowse/core/util';
3
3
  import TimelineIcon from '@mui/icons-material/Timeline';
4
- import ComparativeRenderer from './ComparativeRenderer';
5
- import DotplotDisplayF from './DotplotDisplay';
6
- import DotplotReadVsRefMenuItem from './DotplotReadVsRef';
7
- import DotplotRendererF from './DotplotRenderer';
8
- import DotplotViewF from './DotplotView';
9
- import LaunchDotplotViewF from './LaunchDotplotView';
4
+ import ComparativeRenderer from "./ComparativeRenderer/index.js";
5
+ import DiagonalizeDotplotRpc from "./DiagonalizeDotplotRpc.js";
6
+ import DotplotDisplayF from "./DotplotDisplay/index.js";
7
+ import DotplotReadVsRefMenuItem from "./DotplotReadVsRef/index.js";
8
+ import DotplotRendererF from "./DotplotRenderer/index.js";
9
+ import DotplotViewF from "./DotplotView/index.js";
10
+ import LaunchDotplotViewF from "./LaunchDotplotView.js";
10
11
  export default class DotplotPlugin extends Plugin {
11
- constructor() {
12
- super(...arguments);
13
- this.name = 'DotplotPlugin';
14
- }
12
+ name = 'DotplotPlugin';
15
13
  install(pluginManager) {
16
14
  DotplotViewF(pluginManager);
17
15
  DotplotDisplayF(pluginManager);
@@ -19,6 +17,7 @@ export default class DotplotPlugin extends Plugin {
19
17
  LaunchDotplotViewF(pluginManager);
20
18
  DotplotReadVsRefMenuItem(pluginManager);
21
19
  pluginManager.addRpcMethod(() => new ComparativeRenderer(pluginManager));
20
+ pluginManager.addRpcMethod(() => new DiagonalizeDotplotRpc(pluginManager));
22
21
  }
23
22
  configure(pluginManager) {
24
23
  if (isAbstractMenuManager(pluginManager.rootModel)) {
package/esm/util.d.ts CHANGED
@@ -2,7 +2,7 @@ import type { Feature } from '@jbrowse/core/util';
2
2
  export interface ReducedFeature {
3
3
  refName: string;
4
4
  start: number;
5
- clipPos: number;
5
+ clipLengthAtStartOfRead: number;
6
6
  end: number;
7
7
  seqLength: number;
8
8
  }