@jbrowse/plugin-dotplot-view 2.6.3 → 2.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/DotplotDisplay/components/DotplotDisplay.d.ts +3 -4
  2. package/dist/DotplotDisplay/components/DotplotDisplay.js +3 -3
  3. package/dist/DotplotDisplay/stateModelFactory.d.ts +4 -4
  4. package/dist/DotplotDisplay/stateModelFactory.js +3 -3
  5. package/dist/DotplotRenderer/DotplotRenderer.js +12 -4
  6. package/dist/DotplotRenderer/components/DotplotRendering.d.ts +2 -3
  7. package/dist/DotplotRenderer/components/DotplotRendering.js +3 -3
  8. package/dist/DotplotView/blockTypes.d.ts +1 -9
  9. package/dist/DotplotView/blockTypes.js +2 -15
  10. package/dist/DotplotView/components/Axes.js +37 -35
  11. package/dist/DotplotView/components/DotplotControls.d.ts +6 -0
  12. package/dist/DotplotView/components/DotplotControls.js +94 -0
  13. package/dist/DotplotView/components/DotplotTooltip.d.ts +0 -1
  14. package/dist/DotplotView/components/DotplotTooltip.js +1 -2
  15. package/dist/DotplotView/components/DotplotWarnings.d.ts +2 -2
  16. package/dist/DotplotView/components/DotplotWarnings.js +2 -1
  17. package/dist/DotplotView/components/Header.d.ts +2 -2
  18. package/dist/DotplotView/components/Header.js +5 -120
  19. package/dist/DotplotView/components/ImportCustomTrack.d.ts +1 -1
  20. package/dist/DotplotView/components/ImportCustomTrack.js +1 -1
  21. package/dist/DotplotView/components/ImportSyntenyTrackSelector.js +4 -1
  22. package/dist/DotplotView/components/PanButtons.d.ts +2 -2
  23. package/dist/DotplotView/components/PanButtons.js +2 -1
  24. package/dist/DotplotView/components/WarningDialog.d.ts +2 -2
  25. package/dist/DotplotView/components/WarningDialog.js +2 -1
  26. package/dist/DotplotView/components/util.js +2 -5
  27. package/dist/DotplotView/model.d.ts +13 -8
  28. package/dist/DotplotView/model.js +4 -1
  29. package/dist/DotplotView/svgcomponents/SVGBackground.js +2 -2
  30. package/dist/ServerSideRenderedBlockContent.d.ts +2 -2
  31. package/dist/ServerSideRenderedBlockContent.js +2 -1
  32. package/dist/ServerSideSyntenyRendering.d.ts +11 -16
  33. package/dist/ServerSideSyntenyRendering.js +3 -11
  34. package/esm/DotplotDisplay/components/DotplotDisplay.d.ts +3 -4
  35. package/esm/DotplotDisplay/components/DotplotDisplay.js +3 -3
  36. package/esm/DotplotDisplay/stateModelFactory.d.ts +4 -4
  37. package/esm/DotplotDisplay/stateModelFactory.js +3 -3
  38. package/esm/DotplotRenderer/DotplotRenderer.js +12 -4
  39. package/esm/DotplotRenderer/components/DotplotRendering.d.ts +2 -3
  40. package/esm/DotplotRenderer/components/DotplotRendering.js +3 -3
  41. package/esm/DotplotView/blockTypes.d.ts +1 -9
  42. package/esm/DotplotView/blockTypes.js +2 -15
  43. package/esm/DotplotView/components/Axes.js +37 -35
  44. package/esm/DotplotView/components/DotplotControls.d.ts +6 -0
  45. package/esm/DotplotView/components/DotplotControls.js +89 -0
  46. package/esm/DotplotView/components/DotplotTooltip.d.ts +0 -1
  47. package/esm/DotplotView/components/DotplotTooltip.js +1 -1
  48. package/esm/DotplotView/components/DotplotView.js +1 -1
  49. package/esm/DotplotView/components/DotplotWarnings.d.ts +2 -2
  50. package/esm/DotplotView/components/DotplotWarnings.js +2 -1
  51. package/esm/DotplotView/components/Header.d.ts +2 -2
  52. package/esm/DotplotView/components/Header.js +5 -97
  53. package/esm/DotplotView/components/ImportCustomTrack.d.ts +1 -1
  54. package/esm/DotplotView/components/ImportCustomTrack.js +1 -1
  55. package/esm/DotplotView/components/ImportSyntenyTrackSelector.js +4 -1
  56. package/esm/DotplotView/components/PanButtons.d.ts +2 -2
  57. package/esm/DotplotView/components/PanButtons.js +2 -1
  58. package/esm/DotplotView/components/WarningDialog.d.ts +2 -2
  59. package/esm/DotplotView/components/WarningDialog.js +2 -1
  60. package/esm/DotplotView/components/util.js +2 -5
  61. package/esm/DotplotView/model.d.ts +13 -8
  62. package/esm/DotplotView/model.js +4 -1
  63. package/esm/DotplotView/svgcomponents/SVGBackground.js +2 -2
  64. package/esm/ServerSideRenderedBlockContent.d.ts +2 -2
  65. package/esm/ServerSideRenderedBlockContent.js +2 -1
  66. package/esm/ServerSideSyntenyRendering.d.ts +11 -16
  67. package/esm/ServerSideSyntenyRendering.js +4 -12
  68. package/package.json +3 -4
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { DotplotViewModel } from '../model';
3
- declare const _default: ({ model, }: {
3
+ declare const PanButtons: ({ model, }: {
4
4
  model: DotplotViewModel;
5
5
  }) => React.JSX.Element;
6
- export default _default;
6
+ export default PanButtons;
@@ -29,7 +29,7 @@ const useStyles = (0, mui_1.makeStyles)()({
29
29
  margin: 0,
30
30
  },
31
31
  });
32
- exports.default = (0, mobx_react_1.observer)(function PanButtons({ model, }) {
32
+ const PanButtons = (0, mobx_react_1.observer)(function PanButtons({ model, }) {
33
33
  const { classes } = useStyles();
34
34
  return (react_1.default.createElement(material_1.Paper, { className: classes.dpad, elevation: 6 },
35
35
  react_1.default.createElement("div", null),
@@ -57,3 +57,4 @@ exports.default = (0, mobx_react_1.observer)(function PanButtons({ model, }) {
57
57
  } },
58
58
  react_1.default.createElement(ZoomOut_1.default, null))));
59
59
  });
60
+ exports.default = PanButtons;
@@ -9,8 +9,8 @@ interface TrackWarning {
9
9
  }[];
10
10
  }[];
11
11
  }
12
- declare const _default: ({ trackWarnings, handleClose, }: {
12
+ declare const WarningDialog: ({ trackWarnings, handleClose, }: {
13
13
  handleClose: () => void;
14
14
  trackWarnings: TrackWarning[];
15
15
  }) => React.JSX.Element;
16
- export default _default;
16
+ export default WarningDialog;
@@ -16,7 +16,7 @@ const useStyles = (0, mui_1.makeStyles)()({
16
16
  minWidth: 600,
17
17
  },
18
18
  });
19
- exports.default = (0, mobx_react_1.observer)(function WarningDialog({ trackWarnings, handleClose, }) {
19
+ const WarningDialog = (0, mobx_react_1.observer)(function WarningDialog({ trackWarnings, handleClose, }) {
20
20
  const { classes } = useStyles();
21
21
  const rows = [];
22
22
  for (let i = 0; i < trackWarnings.length; i++) {
@@ -38,3 +38,4 @@ exports.default = (0, mobx_react_1.observer)(function WarningDialog({ trackWarni
38
38
  react_1.default.createElement("div", { style: { height: 600, width: '100%', overflow: 'auto' } },
39
39
  react_1.default.createElement(x_data_grid_1.DataGrid, { rows: rows, columns: columns, disableRowSelectionOnClick: true, rowHeight: 25, disableColumnMenu: true })))));
40
40
  });
41
+ exports.default = WarningDialog;
@@ -66,9 +66,7 @@ function makeTicks(regions, bpPerPx, emitMajor = true, emitMinor = true) {
66
66
  const ticks = [];
67
67
  const gridPitch = chooseGridPitch(bpPerPx, 60, 15);
68
68
  const iterPitch = gridPitch.minorPitch || gridPitch.majorPitch;
69
- for (let i = 0; i < regions.length; i++) {
70
- const region = regions[i];
71
- const { start, end, refName } = region;
69
+ for (const { start, end, refName } of regions) {
72
70
  let index = 0;
73
71
  const minBase = start;
74
72
  const maxBase = end;
@@ -77,8 +75,7 @@ function makeTicks(regions, bpPerPx, emitMajor = true, emitMinor = true) {
77
75
  ticks.push({ type: 'minor', base: base - 1, index, refName });
78
76
  index += 1;
79
77
  }
80
- else if (emitMajor &&
81
- Math.abs(base - region.start) > gridPitch.minorPitch) {
78
+ else if (emitMajor && Math.abs(base - start) > gridPitch.minorPitch) {
82
79
  ticks.push({ type: 'major', base: base - 1, index, refName });
83
80
  index += 1;
84
81
  }
@@ -213,28 +213,33 @@ export default function stateModelFactory(pm: PluginManager): import("mobx-state
213
213
  readonly textSearchAdapter: any;
214
214
  readonly adapterType: import("@jbrowse/core/pluggableElementTypes").AdapterType;
215
215
  readonly viewMenuActions: import("@jbrowse/core/ui").MenuItem[];
216
- readonly canConfigure: any;
216
+ readonly canConfigure: boolean | ({
217
+ [x: string]: any;
218
+ } & import("mobx-state-tree/dist/internal").NonEmptyObject & {
219
+ setSubschema(slotName: string, data: unknown): any;
220
+ } & import("mobx-state-tree").IStateTreeNode<import("@jbrowse/core/configuration").AnyConfigurationSchemaType>) | undefined;
217
221
  } & {
218
222
  setMinimized(flag: boolean): void;
219
- activateConfigurationUI(): void;
220
- showDisplay(displayId: string, initialSnapshot?: {} | undefined): void;
221
- hideDisplay(displayId: string): number;
222
- replaceDisplay(oldId: string, newId: string, initialSnapshot?: {} | undefined): void; /**
223
+ showDisplay(displayId: string, initialSnapshot?: {} | undefined): void; /**
223
224
  * #property
224
225
  */
226
+ hideDisplay(displayId: string): number;
227
+ replaceDisplay(oldId: string, newId: string, initialSnapshot?: {} | undefined): void;
225
228
  } & {
226
229
  trackMenuItems(): (import("@jbrowse/core/ui").MenuDivider | import("@jbrowse/core/ui").MenuSubHeader | import("@jbrowse/core/ui").NormalMenuItem | import("@jbrowse/core/ui").CheckboxMenuItem | import("@jbrowse/core/ui").RadioMenuItem | import("@jbrowse/core/ui").SubMenuItem | {
227
- type: string; /**
230
+ type: string;
231
+ label: string; /**
228
232
  * #property
229
233
  */
230
- label: string;
231
234
  subMenu: {
232
235
  type: string;
233
236
  label: string;
234
237
  checked: boolean;
235
238
  onClick: () => void;
236
239
  }[];
237
- })[];
240
+ })[]; /**
241
+ * #property
242
+ */
238
243
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
239
244
  viewTrackConfigs: import("mobx-state-tree").IArrayType<import("mobx-state-tree").IAnyModelType>;
240
245
  }, {
@@ -507,8 +507,11 @@ function stateModelFactory(pm) {
507
507
  },
508
508
  // if any of our assemblies are temporary assemblies
509
509
  beforeDestroy() {
510
+ var _a;
510
511
  const session = (0, util_1.getSession)(self);
511
- self.assemblyNames.forEach(asm => session.removeTemporaryAssembly(asm));
512
+ for (const name in self.assemblyNames) {
513
+ (_a = session.removeTemporaryAssembly) === null || _a === void 0 ? void 0 : _a.call(session, name);
514
+ }
512
515
  },
513
516
  afterAttach() {
514
517
  (0, mobx_state_tree_1.addDisposer)(self, (0, mobx_1.autorun)(() => {
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const react_1 = __importDefault(require("react"));
7
- const color_1 = __importDefault(require("color"));
8
7
  const material_1 = require("@mui/material");
8
+ const util_1 = require("@jbrowse/core/util");
9
9
  function SVGBackground({ width, height, }) {
10
10
  const theme = (0, material_1.useTheme)();
11
- return (react_1.default.createElement("rect", { x: 0, y: 0, width: width, height: height, fill: (0, color_1.default)(theme.palette.background.default).hex() }));
11
+ return (react_1.default.createElement("rect", { x: 0, y: 0, width: width, height: height, fill: (0, util_1.stripAlpha)(theme.palette.background.default) }));
12
12
  }
13
13
  exports.default = SVGBackground;
@@ -1,5 +1,5 @@
1
1
  import React, { CSSProperties } from 'react';
2
- declare const _default: ({ model, style, }: {
2
+ declare const ServerSideRenderedDotplotContent: ({ model, style, }: {
3
3
  model: {
4
4
  error?: unknown;
5
5
  message?: string;
@@ -9,4 +9,4 @@ declare const _default: ({ model, style, }: {
9
9
  };
10
10
  style: CSSProperties;
11
11
  }) => React.JSX.Element | null;
12
- export default _default;
12
+ export default ServerSideRenderedDotplotContent;
@@ -69,7 +69,7 @@ function BlockError({ error }) {
69
69
  return (react_1.default.createElement("div", { className: classes.blockError },
70
70
  react_1.default.createElement(material_1.Typography, null, `${error}`)));
71
71
  }
72
- exports.default = (0, mobx_react_1.observer)(function ({ model, style, }) {
72
+ const ServerSideRenderedDotplotContent = (0, mobx_react_1.observer)(function ({ model, style, }) {
73
73
  if (model.error) {
74
74
  return react_1.default.createElement(BlockError, { error: model.error, "data-testid": "reload_button" });
75
75
  }
@@ -84,3 +84,4 @@ exports.default = (0, mobx_react_1.observer)(function ({ model, style, }) {
84
84
  }
85
85
  return null;
86
86
  });
87
+ exports.default = ServerSideRenderedDotplotContent;
@@ -3,21 +3,16 @@ import React from 'react';
3
3
  * A block whose content is rendered outside of the main thread and hydrated by this
4
4
  * component.
5
5
  */
6
- declare function ServerSideSyntenyRendering({ model, }: {
7
- model: {
8
- imageData: string;
9
- style: Record<string, string>;
10
- renderProps: {
11
- width: number;
12
- height: number;
13
- highResolutionScaling?: number;
14
- };
15
- };
16
- }): React.JSX.Element;
17
- declare namespace ServerSideSyntenyRendering {
18
- var propTypes: {
19
- model: import("prop-types").Validator<any>;
6
+ interface ModelType {
7
+ imageData: string;
8
+ style: Record<string, string>;
9
+ renderProps: {
10
+ width: number;
11
+ height: number;
12
+ highResolutionScaling?: number;
20
13
  };
21
14
  }
22
- declare const _default: typeof ServerSideSyntenyRendering;
23
- export default _default;
15
+ declare const ServerSideSyntenyRendering: ({ model, }: {
16
+ model: ModelType;
17
+ }) => React.JSX.Element;
18
+ export default ServerSideSyntenyRendering;
@@ -23,15 +23,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
27
26
  const react_1 = __importStar(require("react"));
28
27
  const mobx_react_1 = require("mobx-react");
29
28
  const offscreenCanvasPonyfill_1 = require("@jbrowse/core/util/offscreenCanvasPonyfill");
30
- /**
31
- * A block whose content is rendered outside of the main thread and hydrated by this
32
- * component.
33
- */
34
- function ServerSideSyntenyRendering({ model, }) {
29
+ const ServerSideSyntenyRendering = (0, mobx_react_1.observer)(function ({ model, }) {
35
30
  const { imageData, style, renderProps } = model;
36
31
  const { width, height, highResolutionScaling = 1 } = renderProps;
37
32
  const featureCanvas = (0, react_1.useRef)(null);
@@ -46,8 +41,5 @@ function ServerSideSyntenyRendering({ model, }) {
46
41
  setDone(true);
47
42
  }, [height, imageData, width]);
48
43
  return (react_1.default.createElement("canvas", { "data-testid": `prerendered_canvas${done ? '_done' : ''}`, ref: featureCanvas, width: width * highResolutionScaling, height: height * highResolutionScaling, style: { width, height, ...style } }));
49
- }
50
- ServerSideSyntenyRendering.propTypes = {
51
- model: mobx_react_1.PropTypes.observableObject.isRequired,
52
- };
53
- exports.default = (0, mobx_react_1.observer)(ServerSideSyntenyRendering);
44
+ });
45
+ exports.default = ServerSideSyntenyRendering;
@@ -1,8 +1,7 @@
1
1
  import React from 'react';
2
2
  import { DotplotDisplayModel } from '../stateModelFactory';
3
- declare function DotplotDisplay(props: {
3
+ declare const DotplotDisplay: (props: {
4
4
  model: DotplotDisplayModel;
5
5
  children?: React.ReactNode;
6
- }): React.JSX.Element;
7
- declare const _default: typeof DotplotDisplay;
8
- export default _default;
6
+ }) => React.JSX.Element;
7
+ export default DotplotDisplay;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { observer } from 'mobx-react';
3
3
  import { getContainingView } from '@jbrowse/core/util';
4
- function DotplotDisplay(props) {
4
+ const DotplotDisplay = observer(function DotplotDisplay(props) {
5
5
  const { model, children } = props;
6
6
  const { offsetX = 0, offsetY = 0 } = model.data || {};
7
7
  const view = getContainingView(model);
@@ -14,5 +14,5 @@ function DotplotDisplay(props) {
14
14
  left,
15
15
  } }),
16
16
  children));
17
- }
18
- export default observer(DotplotDisplay);
17
+ });
18
+ export default DotplotDisplay;
@@ -50,7 +50,9 @@ export declare function stateModelFactory(configSchema: AnyConfigurationSchemaTy
50
50
  }>;
51
51
  readonly DisplayBlurb: React.FC<{
52
52
  model: {
53
- id: string;
53
+ id: string; /**
54
+ * #getter
55
+ */
54
56
  type: string;
55
57
  rpcDriverName: string | undefined;
56
58
  } & import("mobx-state-tree/dist/internal").NonEmptyObject & {
@@ -72,9 +74,7 @@ export declare function stateModelFactory(configSchema: AnyConfigurationSchemaTy
72
74
  renderProps(): any;
73
75
  readonly rendererType: import("@jbrowse/core/pluggableElementTypes").RendererType;
74
76
  readonly DisplayMessageComponent: React.FC<any> | undefined;
75
- trackMenuItems(): import("@jbrowse/core/ui").MenuItem[]; /**
76
- * #action
77
- */
77
+ trackMenuItems(): import("@jbrowse/core/ui").MenuItem[];
78
78
  readonly viewMenuActions: import("@jbrowse/core/ui").MenuItem[];
79
79
  regionCannotBeRendered(): null;
80
80
  } & {
@@ -37,9 +37,9 @@ export function stateModelFactory(configSchema) {
37
37
  })))
38
38
  .views(self => ({
39
39
  get shouldDisplay() {
40
- const view = getContainingView(self);
41
- return (view.vview.bpPerPx === self.data.bpPerPxY &&
42
- view.hview.bpPerPx === self.data.bpPerPxX);
40
+ const { vview, hview } = getContainingView(self);
41
+ return (vview.bpPerPx === self.data.bpPerPxY &&
42
+ hview.bpPerPx === self.data.bpPerPxX);
43
43
  },
44
44
  /**
45
45
  * #getter
@@ -43,7 +43,7 @@ export default class DotplotRenderer extends ComparativeRenderer {
43
43
  return args;
44
44
  }
45
45
  async drawDotplot(ctx, props) {
46
- var _a, _b, _c;
46
+ var _a, _b;
47
47
  const { config, views, height, drawCigar, theme } = props;
48
48
  const color = readConfObject(config, 'color');
49
49
  const posColor = readConfObject(config, 'posColor');
@@ -127,7 +127,7 @@ export default class DotplotRenderer extends ComparativeRenderer {
127
127
  width: vview.width,
128
128
  };
129
129
  const t = createJBrowseTheme(theme);
130
- (_c = hview.features) === null || _c === void 0 ? void 0 : _c.forEach(feature => {
130
+ for (const feature of hview.features || []) {
131
131
  const strand = feature.get('strand') || 1;
132
132
  const start = strand === 1 ? feature.get('start') : feature.get('end');
133
133
  const end = strand === 1 ? feature.get('end') : feature.get('start');
@@ -185,6 +185,8 @@ export default class DotplotRenderer extends ComparativeRenderer {
185
185
  const cigarOps = parseCigar(cigar);
186
186
  ctx.beginPath();
187
187
  ctx.moveTo(currX, height - currY);
188
+ let lastDrawnX = currX;
189
+ let lastDrawnY = currX;
188
190
  for (let i = 0; i < cigarOps.length; i += 2) {
189
191
  const val = +cigarOps[i];
190
192
  const op = cigarOps[i + 1];
@@ -200,7 +202,13 @@ export default class DotplotRenderer extends ComparativeRenderer {
200
202
  }
201
203
  currX = clampWithWarnX(currX, b1, b2, feature);
202
204
  currY = clampWithWarnY(currY, e1, e2, feature);
203
- ctx.lineTo(currX, height - currY);
205
+ // only draw a line segment if it is bigger than 0.5px
206
+ if (Math.abs(currX - lastDrawnX) > 0.5 ||
207
+ Math.abs(currY - lastDrawnY) > 0.5) {
208
+ ctx.lineTo(currX, height - currY);
209
+ lastDrawnX = currX;
210
+ lastDrawnY = currY;
211
+ }
204
212
  }
205
213
  ctx.stroke();
206
214
  }
@@ -228,7 +236,7 @@ export default class DotplotRenderer extends ComparativeRenderer {
228
236
  }
229
237
  }
230
238
  }
231
- });
239
+ }
232
240
  return { warnings };
233
241
  }
234
242
  async render(renderProps) {
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
2
  import { DotplotRenderArgsDeserialized } from '../DotplotRenderer';
3
- declare function DotplotRendering(props: DotplotRenderArgsDeserialized): React.JSX.Element;
4
- declare const _default: typeof DotplotRendering;
5
- export default _default;
3
+ declare const DotplotRendering: (props: DotplotRenderArgsDeserialized) => React.JSX.Element;
4
+ export default DotplotRendering;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { PrerenderedCanvas } from '@jbrowse/core/ui';
3
3
  import { observer } from 'mobx-react';
4
- function DotplotRendering(props) {
4
+ const DotplotRendering = observer(function (props) {
5
5
  return React.createElement(PrerenderedCanvas, { ...props });
6
- }
7
- export default observer(DotplotRendering);
6
+ });
7
+ export default DotplotRendering;
@@ -23,15 +23,7 @@ export declare class BaseBlock {
23
23
  /**
24
24
  * a block that should be shown as filled with data
25
25
  */
26
- constructor(data: any);
27
- /**
28
- * rename the reference sequence of this block and return a new one
29
- *
30
- * @param refName -
31
- * @returns either a new block with a renamed reference sequence,
32
- * or the same block, if the ref name is not actually different
33
- */
34
- renameReference(refName: string): any;
26
+ constructor(data: Record<string, any>);
35
27
  toRegion(): {
36
28
  refName: string;
37
29
  start: number;
@@ -1,3 +1,4 @@
1
+ import { sum } from '@jbrowse/core/util';
1
2
  export class BlockSet {
2
3
  constructor(blocks = []) {
3
4
  this.blocks = blocks;
@@ -28,7 +29,7 @@ export class BlockSet {
28
29
  }
29
30
  get totalWidthPx() {
30
31
  return this.blocks.length
31
- ? this.blocks.map(blocks => blocks.widthPx).reduce((a, b) => a + b)
32
+ ? sum(this.blocks.map(blocks => blocks.widthPx))
32
33
  : 0;
33
34
  }
34
35
  get offsetPx() {
@@ -53,20 +54,6 @@ export class BaseBlock {
53
54
  this.end = data.end;
54
55
  this.key = data.key;
55
56
  }
56
- /**
57
- * rename the reference sequence of this block and return a new one
58
- *
59
- * @param refName -
60
- * @returns either a new block with a renamed reference sequence,
61
- * or the same block, if the ref name is not actually different
62
- */
63
- renameReference(refName) {
64
- if (this.refName && refName !== this.refName) {
65
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
66
- return new this.constructor({ ...this, refName });
67
- }
68
- return this;
69
- }
70
57
  toRegion() {
71
58
  return {
72
59
  refName: this.refName,
@@ -38,6 +38,20 @@ export const HorizontalAxisRaw = observer(function ({ model, }) {
38
38
  width,
39
39
  staticBlocks: hview.staticBlocks,
40
40
  };
41
+ const ticks = hticks
42
+ .map(tick => {
43
+ var _a;
44
+ return [
45
+ tick,
46
+ (_a = bpToPx({
47
+ refName: tick.refName,
48
+ coord: tick.base,
49
+ self: hviewSnap,
50
+ })) === null || _a === void 0 ? void 0 : _a.offsetPx,
51
+ ];
52
+ })
53
+ .filter(f => f[1] !== undefined)
54
+ .map(f => [f[0], f[1] - offsetPx]);
41
55
  return (React.createElement(React.Fragment, null,
42
56
  dblocks
43
57
  .filter(region => !hide.has(region.key))
@@ -47,24 +61,12 @@ export const HorizontalAxisRaw = observer(function ({ model, }) {
47
61
  const xoff = Math.floor(x - hview.offsetPx);
48
62
  return (React.createElement("text", { transform: `rotate(${htextRotation},${xoff},${y})`, key: JSON.stringify(region), x: xoff, y: y + 1, fill: theme.palette.text.primary, fontSize: 11, dominantBaseline: "hanging", textAnchor: "end" }, region.refName));
49
63
  }),
50
- hticks.map(tick => {
51
- var _a;
52
- const x = (((_a = bpToPx({
53
- refName: tick.refName,
54
- coord: tick.base,
55
- self: hviewSnap,
56
- })) === null || _a === void 0 ? void 0 : _a.offsetPx) || 0) - offsetPx;
57
- return (React.createElement("line", { key: `line-${JSON.stringify(tick)}`, x1: x, x2: x, y1: 0, y2: tick.type === 'major' ? 6 : 4, strokeWidth: 1, stroke: theme.palette.divider }));
64
+ ticks.map(([tick, x]) => {
65
+ return (React.createElement("line", { key: `line-${JSON.stringify(tick)}`, x1: x, x2: x, y1: 0, y2: tick.type === 'major' ? 6 : 4, strokeWidth: 1, stroke: theme.palette.grey[400] }));
58
66
  }),
59
- hticks
60
- .filter(tick => tick.type === 'major')
61
- .map(tick => {
62
- var _a;
63
- const x = (((_a = bpToPx({
64
- refName: tick.refName,
65
- coord: tick.base,
66
- self: hviewSnap,
67
- })) === null || _a === void 0 ? void 0 : _a.offsetPx) || 0) - offsetPx;
67
+ ticks
68
+ .filter(t => t[0].type === 'major')
69
+ .map(([tick, x]) => {
68
70
  const y = 0;
69
71
  return x > 10 ? (React.createElement("text", { x: x - 7, y: y, transform: `rotate(${htextRotation},${x},${y})`, key: `text-${JSON.stringify(tick)}`, fill: theme.palette.text.primary, fontSize: 11, dominantBaseline: "middle", textAnchor: "end" }, getTickDisplayStr(tick.base + 1, bpPerPx))) : null;
70
72
  }),
@@ -87,6 +89,20 @@ export const VerticalAxisRaw = observer(function ({ model, }) {
87
89
  width,
88
90
  staticBlocks: vview.staticBlocks,
89
91
  };
92
+ const ticks = vticks
93
+ .map(tick => {
94
+ var _a;
95
+ return [
96
+ tick,
97
+ (_a = bpToPx({
98
+ refName: tick.refName,
99
+ coord: tick.base,
100
+ self: vviewSnap,
101
+ })) === null || _a === void 0 ? void 0 : _a.offsetPx,
102
+ ];
103
+ })
104
+ .filter(f => f[1] !== undefined)
105
+ .map(f => [f[0], f[1] - offsetPx]);
90
106
  return (React.createElement(React.Fragment, null,
91
107
  dblocks
92
108
  .filter(region => !hide.has(region.key))
@@ -96,24 +112,10 @@ export const VerticalAxisRaw = observer(function ({ model, }) {
96
112
  const yoff = Math.floor(viewHeight - y + offsetPx);
97
113
  return (React.createElement("text", { transform: `rotate(${vtextRotation},${x},${y})`, key: JSON.stringify(region), x: x, y: yoff, fill: theme.palette.text.primary, fontSize: 11, textAnchor: "end" }, region.refName));
98
114
  }),
99
- vticks.map(tick => {
100
- var _a;
101
- const y = (((_a = bpToPx({
102
- refName: tick.refName,
103
- coord: tick.base,
104
- self: vviewSnap,
105
- })) === null || _a === void 0 ? void 0 : _a.offsetPx) || 0) - offsetPx;
106
- return (React.createElement("line", { key: `line-${JSON.stringify(tick)}`, y1: viewHeight - y, y2: viewHeight - y, x1: borderX, x2: borderX - (tick.type === 'major' ? 6 : 4), strokeWidth: 1, stroke: theme.palette.divider }));
107
- }),
108
- vticks
109
- .filter(tick => tick.type === 'major')
110
- .map(tick => {
111
- var _a;
112
- const y = (((_a = bpToPx({
113
- refName: tick.refName,
114
- coord: tick.base,
115
- self: vviewSnap,
116
- })) === null || _a === void 0 ? void 0 : _a.offsetPx) || 0) - offsetPx;
115
+ ticks.map(([tick, y]) => (React.createElement("line", { key: `line-${JSON.stringify(tick)}`, y1: viewHeight - y, y2: viewHeight - y, x1: borderX, x2: borderX - (tick.type === 'major' ? 6 : 4), strokeWidth: 1, stroke: theme.palette.grey[400] }))),
116
+ ticks
117
+ .filter(t => t[0].type === 'major')
118
+ .map(([tick, y]) => {
117
119
  return y > 10 ? (React.createElement("text", { y: viewHeight - y - 3, x: borderX - 7, key: `text-${JSON.stringify(tick)}`, textAnchor: "end", fill: theme.palette.text.primary, dominantBaseline: "hanging", fontSize: 11 }, getTickDisplayStr(tick.base + 1, bpPerPx))) : null;
118
120
  }),
119
121
  React.createElement("text", { y: (viewHeight - borderY) / 2, x: 12, fill: theme.palette.text.primary, transform: `rotate(-90,12,${(viewHeight - borderY) / 2})`, textAnchor: "middle", fontSize: 11 }, vview.assemblyNames.join(','))));
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { DotplotViewModel } from '../model';
3
+ declare const DotplotControls: ({ model, }: {
4
+ model: DotplotViewModel;
5
+ }) => React.JSX.Element;
6
+ export default DotplotControls;
@@ -0,0 +1,89 @@
1
+ import React from 'react';
2
+ import { IconButton } from '@mui/material';
3
+ import { observer } from 'mobx-react';
4
+ import CascadingMenuButton from '@jbrowse/core/ui/CascadingMenuButton';
5
+ // icons
6
+ import ZoomOut from '@mui/icons-material/ZoomOut';
7
+ import ZoomIn from '@mui/icons-material/ZoomIn';
8
+ import MoreVert from '@mui/icons-material/MoreVert';
9
+ import { CursorMouse, CursorMove } from './CursorIcon';
10
+ import { TrackSelector as TrackSelectorIcon } from '@jbrowse/core/ui/Icons';
11
+ const DotplotControls = observer(function ({ model, }) {
12
+ return (React.createElement("div", null,
13
+ React.createElement(IconButton, { onClick: model.zoomOutButton },
14
+ React.createElement(ZoomOut, null)),
15
+ React.createElement(IconButton, { onClick: model.zoomInButton },
16
+ React.createElement(ZoomIn, null)),
17
+ React.createElement(IconButton, { onClick: () => model.activateTrackSelector(), title: "Open track selector" },
18
+ React.createElement(TrackSelectorIcon, null)),
19
+ React.createElement(CascadingMenuButton, { menuItems: [
20
+ {
21
+ onClick: () => model.squareView(),
22
+ label: 'Square view - same base pairs per pixel',
23
+ },
24
+ {
25
+ onClick: () => model.squareViewProportional(),
26
+ label: 'Rectanglularize view - same total bp',
27
+ },
28
+ {
29
+ onClick: () => model.showAllRegions(),
30
+ label: 'Show all regions',
31
+ },
32
+ {
33
+ onClick: () => model.setDrawCigar(!model.drawCigar),
34
+ type: 'checkbox',
35
+ label: 'Draw CIGAR',
36
+ checked: model.drawCigar,
37
+ },
38
+ {
39
+ onClick: () => model.setShowPanButtons(!model.showPanButtons),
40
+ label: 'Show pan buttons',
41
+ type: 'checkbox',
42
+ checked: model.showPanButtons,
43
+ },
44
+ {
45
+ label: 'Click and drag mode',
46
+ subMenu: [
47
+ {
48
+ onClick: () => model.setCursorMode('move'),
49
+ label: 'Pan by default, select region when ctrl key is held',
50
+ icon: CursorMove,
51
+ type: 'radio',
52
+ checked: model.cursorMode === 'move',
53
+ },
54
+ {
55
+ onClick: () => model.setCursorMode('crosshair'),
56
+ label: 'Select region by default, pan when ctrl key is held',
57
+ icon: CursorMouse,
58
+ type: 'radio',
59
+ checked: model.cursorMode === 'crosshair',
60
+ },
61
+ ],
62
+ },
63
+ {
64
+ label: 'Wheel scroll mode',
65
+ subMenu: [
66
+ {
67
+ onClick: () => model.setWheelMode('pan'),
68
+ label: 'Pans view',
69
+ type: 'radio',
70
+ checked: model.wheelMode === 'pan',
71
+ },
72
+ {
73
+ onClick: () => model.setWheelMode('zoom'),
74
+ label: 'Zooms view',
75
+ type: 'radio',
76
+ checked: model.wheelMode === 'zoom',
77
+ },
78
+ {
79
+ onClick: () => model.setWheelMode('none'),
80
+ label: 'Disable',
81
+ type: 'radio',
82
+ checked: model.wheelMode === 'none',
83
+ },
84
+ ],
85
+ },
86
+ ] },
87
+ React.createElement(MoreVert, null))));
88
+ });
89
+ export default DotplotControls;
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import { DotplotViewModel } from '../model';
3
- export declare function round(value: number): number;
4
3
  type Coord = [number, number] | undefined;
5
4
  export declare const TooltipWhereMouseovered: ({ model, mouserect, mouserectClient, xdistance, ydistance, }: {
6
5
  model: DotplotViewModel;
@@ -4,7 +4,7 @@ import { makeStyles } from 'tss-react/mui';
4
4
  import { locstr } from './util';
5
5
  import { Portal, alpha } from '@mui/material';
6
6
  import { usePopper } from 'react-popper';
7
- export function round(value) {
7
+ function round(value) {
8
8
  return Math.round(value * 1e5) / 1e5;
9
9
  }
10
10
  const useStyles = makeStyles()(theme => ({