@jbrowse/plugin-linear-comparative-view 3.6.5 → 3.7.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 (57) hide show
  1. package/dist/LGVSyntenyDisplay/model.d.ts +17 -2
  2. package/dist/LinearComparativeView/components/ColorBySelector.d.ts +5 -0
  3. package/dist/LinearComparativeView/components/ColorBySelector.js +54 -0
  4. package/dist/LinearComparativeView/components/Header.js +7 -2
  5. package/dist/LinearComparativeView/components/MinLengthSlider.d.ts +5 -0
  6. package/dist/LinearComparativeView/components/MinLengthSlider.js +47 -0
  7. package/dist/LinearComparativeView/components/OpacitySlider.d.ts +5 -0
  8. package/dist/LinearComparativeView/components/OpacitySlider.js +46 -0
  9. package/dist/LinearComparativeView/components/RubberbandSpan.js +2 -2
  10. package/dist/LinearComparativeView/components/SliderTooltip.d.ts +2 -0
  11. package/dist/LinearComparativeView/components/SliderTooltip.js +9 -0
  12. package/dist/LinearComparativeView/components/useRangeSelect.js +10 -14
  13. package/dist/LinearComparativeView/model.d.ts +3 -0
  14. package/dist/LinearComparativeView/model.js +4 -0
  15. package/dist/LinearSyntenyDisplay/afterAttach.js +5 -3
  16. package/dist/LinearSyntenyDisplay/components/LinearSyntenyRendering.js +10 -5
  17. package/dist/LinearSyntenyDisplay/components/util.d.ts +2 -1
  18. package/dist/LinearSyntenyDisplay/components/util.js +43 -2
  19. package/dist/LinearSyntenyDisplay/drawSynteny.d.ts +3 -2
  20. package/dist/LinearSyntenyDisplay/drawSynteny.js +284 -45
  21. package/dist/LinearSyntenyDisplay/model.d.ts +6 -0
  22. package/dist/LinearSyntenyDisplay/model.js +12 -0
  23. package/dist/LinearSyntenyView/components/DiagonalizationProgressDialog.d.ts +6 -0
  24. package/dist/LinearSyntenyView/components/DiagonalizationProgressDialog.js +87 -0
  25. package/dist/LinearSyntenyView/model.d.ts +42 -11
  26. package/dist/LinearSyntenyView/model.js +70 -18
  27. package/dist/LinearSyntenyView/util/diagonalize.d.ts +27 -0
  28. package/dist/LinearSyntenyView/util/diagonalize.js +91 -0
  29. package/esm/LGVSyntenyDisplay/model.d.ts +17 -2
  30. package/esm/LinearComparativeView/components/ColorBySelector.d.ts +5 -0
  31. package/esm/LinearComparativeView/components/ColorBySelector.js +49 -0
  32. package/esm/LinearComparativeView/components/Header.js +8 -3
  33. package/esm/LinearComparativeView/components/MinLengthSlider.d.ts +5 -0
  34. package/esm/LinearComparativeView/components/MinLengthSlider.js +42 -0
  35. package/esm/LinearComparativeView/components/OpacitySlider.d.ts +5 -0
  36. package/esm/LinearComparativeView/components/OpacitySlider.js +41 -0
  37. package/esm/LinearComparativeView/components/RubberbandSpan.js +2 -2
  38. package/esm/LinearComparativeView/components/SliderTooltip.d.ts +2 -0
  39. package/esm/LinearComparativeView/components/SliderTooltip.js +6 -0
  40. package/esm/LinearComparativeView/components/useRangeSelect.js +11 -15
  41. package/esm/LinearComparativeView/model.d.ts +3 -0
  42. package/esm/LinearComparativeView/model.js +4 -0
  43. package/esm/LinearSyntenyDisplay/afterAttach.js +6 -4
  44. package/esm/LinearSyntenyDisplay/components/LinearSyntenyRendering.js +10 -5
  45. package/esm/LinearSyntenyDisplay/components/util.d.ts +2 -1
  46. package/esm/LinearSyntenyDisplay/components/util.js +43 -3
  47. package/esm/LinearSyntenyDisplay/drawSynteny.d.ts +3 -2
  48. package/esm/LinearSyntenyDisplay/drawSynteny.js +283 -45
  49. package/esm/LinearSyntenyDisplay/model.d.ts +6 -0
  50. package/esm/LinearSyntenyDisplay/model.js +12 -0
  51. package/esm/LinearSyntenyView/components/DiagonalizationProgressDialog.d.ts +6 -0
  52. package/esm/LinearSyntenyView/components/DiagonalizationProgressDialog.js +85 -0
  53. package/esm/LinearSyntenyView/model.d.ts +42 -11
  54. package/esm/LinearSyntenyView/model.js +70 -18
  55. package/esm/LinearSyntenyView/util/diagonalize.d.ts +27 -0
  56. package/esm/LinearSyntenyView/util/diagonalize.js +88 -0
  57. package/package.json +5 -5
@@ -1,4 +1,4 @@
1
- import { useEffect, useState } from 'react';
1
+ import { useCallback, useEffect, useState } from 'react';
2
2
  import { transaction } from 'mobx';
3
3
  import { getRelativeX } from './util';
4
4
  export function useRangeSelect(ref, model) {
@@ -7,6 +7,11 @@ export function useRangeSelect(ref, model) {
7
7
  const [anchorPosition, setAnchorPosition] = useState();
8
8
  const [guideX, setGuideX] = useState();
9
9
  const mouseDragging = startX !== undefined && anchorPosition === undefined;
10
+ const handleClose = useCallback(() => {
11
+ setAnchorPosition(undefined);
12
+ setStartX(undefined);
13
+ setCurrentX(undefined);
14
+ }, []);
10
15
  useEffect(() => {
11
16
  function computeOffsets(offsetX) {
12
17
  if (startX === undefined) {
@@ -29,6 +34,10 @@ export function useRangeSelect(ref, model) {
29
34
  if (startX !== undefined && ref.current) {
30
35
  const { clientX, clientY } = event;
31
36
  const offsetX = getRelativeX(event, ref.current);
37
+ if (Math.abs(offsetX - startX) <= 3) {
38
+ handleClose();
39
+ return;
40
+ }
32
41
  setAnchorPosition({
33
42
  offsetX,
34
43
  clientX,
@@ -54,15 +63,7 @@ export function useRangeSelect(ref, model) {
54
63
  };
55
64
  }
56
65
  return () => { };
57
- }, [startX, mouseDragging, model, ref]);
58
- useEffect(() => {
59
- if (!mouseDragging &&
60
- currentX !== undefined &&
61
- startX !== undefined &&
62
- Math.abs(currentX - startX) <= 3) {
63
- handleClose();
64
- }
65
- }, [mouseDragging, currentX, startX]);
66
+ }, [startX, mouseDragging, model, ref, handleClose]);
66
67
  function mouseDown(event) {
67
68
  event.preventDefault();
68
69
  event.stopPropagation();
@@ -81,11 +82,6 @@ export function useRangeSelect(ref, model) {
81
82
  }
82
83
  });
83
84
  }
84
- function handleClose() {
85
- setAnchorPosition(undefined);
86
- setStartX(undefined);
87
- setCurrentX(undefined);
88
- }
89
85
  function handleMenuItemClick(_, callback) {
90
86
  callback();
91
87
  handleClose();
@@ -13,6 +13,7 @@ declare function stateModelFactory(pluginManager: PluginManager): import("mobx-s
13
13
  showIntraviewLinks: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
14
14
  linkViews: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
15
15
  interactiveOverlay: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
16
+ showDynamicControls: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
16
17
  levels: import("mobx-state-tree").IArrayType<import("mobx-state-tree").IModelType<{
17
18
  id: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
18
19
  type: import("mobx-state-tree").IType<string | undefined, string, string>;
@@ -303,6 +304,7 @@ declare function stateModelFactory(pluginManager: PluginManager): import("mobx-s
303
304
  removeView(view: LinearGenomeViewModel): void;
304
305
  setLevelHeight(newHeight: number, level?: number): number;
305
306
  setLinkViews(arg: boolean): void;
307
+ setShowDynamicControls(arg: boolean): void;
306
308
  activateTrackSelector(level: number): import("@jbrowse/core/util").Widget;
307
309
  toggleTrack(trackId: string, level?: number): void;
308
310
  showTrack(trackId: string, level?: number, initialSnapshot?: {}): void;
@@ -330,6 +332,7 @@ declare function stateModelFactory(pluginManager: PluginManager): import("mobx-s
330
332
  showIntraviewLinks: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
331
333
  linkViews: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
332
334
  interactiveOverlay: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
335
+ showDynamicControls: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
333
336
  levels: import("mobx-state-tree").IArrayType<import("mobx-state-tree").IModelType<{
334
337
  id: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
335
338
  type: import("mobx-state-tree").IType<string | undefined, string, string>;
@@ -17,6 +17,7 @@ function stateModelFactory(pluginManager) {
17
17
  showIntraviewLinks: true,
18
18
  linkViews: false,
19
19
  interactiveOverlay: false,
20
+ showDynamicControls: true,
20
21
  levels: types.array(LinearSyntenyViewHelper),
21
22
  views: types.array(pluginManager.getViewType('LinearGenomeView')
22
23
  .stateModel),
@@ -93,6 +94,9 @@ function stateModelFactory(pluginManager) {
93
94
  setLinkViews(arg) {
94
95
  self.linkViews = arg;
95
96
  },
97
+ setShowDynamicControls(arg) {
98
+ self.showDynamicControls = arg;
99
+ },
96
100
  activateTrackSelector(level) {
97
101
  if (self.trackSelectorType === 'hierarchical') {
98
102
  const session = getSession(self);
@@ -3,7 +3,7 @@ import { bpToPx } from '@jbrowse/core/util/Base1DUtils';
3
3
  import { MismatchParser } from '@jbrowse/plugin-alignments';
4
4
  import { autorun, reaction } from 'mobx';
5
5
  import { addDisposer, getSnapshot } from 'mobx-state-tree';
6
- import { drawMouseoverSynteny, drawRef } from './drawSynteny';
6
+ import { drawCigarClickMap, drawMouseoverClickMap, drawRef, } from './drawSynteny';
7
7
  export function doAfterAttach(self) {
8
8
  addDisposer(self, autorun(() => {
9
9
  var _a, _b;
@@ -17,11 +17,12 @@ export function doAfterAttach(self) {
17
17
  if (!ctx1 || !ctx3) {
18
18
  return;
19
19
  }
20
+ const { alpha } = self;
20
21
  const height = self.height;
21
22
  const width = view.width;
22
23
  ctx1.clearRect(0, 0, width, height);
23
- ctx3.clearRect(0, 0, width, height);
24
- drawRef(self, ctx1, ctx3);
24
+ drawRef(self, ctx1);
25
+ drawCigarClickMap(self, ctx3);
25
26
  }));
26
27
  addDisposer(self, autorun(() => {
27
28
  const view = getContainingView(self);
@@ -29,7 +30,8 @@ export function doAfterAttach(self) {
29
30
  !view.views.every(a => a.displayedRegions.length > 0 && a.initialized)) {
30
31
  return;
31
32
  }
32
- drawMouseoverSynteny(self);
33
+ const { clickId, mouseoverId } = self;
34
+ drawMouseoverClickMap(self);
33
35
  }));
34
36
  addDisposer(self, reaction(() => {
35
37
  const view = getContainingView(self);
@@ -151,11 +151,16 @@ const LinearSyntenyRendering = observer(function ({ model, }) {
151
151
  const { f, cigar } = model.featPositions[id];
152
152
  const unitMultiplier2 = Math.floor(MAX_COLOR_RANGE / cigar.length);
153
153
  const cigarIdx = getId(r2, g2, b2, unitMultiplier2);
154
- setTooltip(getTooltip({
155
- feature: f,
156
- cigarOp: cigar[cigarIdx],
157
- cigarOpLen: cigar[cigarIdx + 1],
158
- }));
154
+ if (cigarIdx % 2 === 0 && (r2 !== 0 || g2 !== 0 || b2 !== 0)) {
155
+ setTooltip(getTooltip({
156
+ feature: f,
157
+ cigarOp: cigar[cigarIdx + 1],
158
+ cigarOpLen: cigar[cigarIdx],
159
+ }));
160
+ }
161
+ else {
162
+ setTooltip('');
163
+ }
159
164
  }
160
165
  }
161
166
  }, onMouseLeave: () => {
@@ -32,13 +32,14 @@ export declare function drawMatchSimple({ feature, ctx, offsets, level, cb, heig
32
32
  hideTiny?: boolean;
33
33
  }): void;
34
34
  export declare function draw(ctx: CanvasRenderingContext2D, x1: number, x2: number, y1: number, x3: number, x4: number, y2: number, mid: number, drawCurves?: boolean): void;
35
+ export declare function drawLocationMarkers(ctx: CanvasRenderingContext2D, x1: number, x2: number, y1: number, x3: number, x4: number, y2: number, mid: number, bpPerPx1: number, bpPerPx2: number, drawCurves?: boolean): void;
35
36
  export declare function drawBox(ctx: CanvasRenderingContext2D, x1: number, x2: number, y1: number, x3: number, x4: number, y2: number): void;
36
37
  export declare function drawBezierBox(ctx: CanvasRenderingContext2D, x1: number, x2: number, y1: number, x3: number, x4: number, y2: number, mid: number): void;
37
38
  export declare function onSynClick(event: React.MouseEvent, model: LinearSyntenyDisplayModel): import("../model").FeatPos | undefined;
38
39
  export declare function onSynContextClick(event: React.MouseEvent, model: LinearSyntenyDisplayModel, setAnchorEl: (arg: ClickCoord) => void): void;
39
40
  export declare function getTooltip({ feature, cigarOp, cigarOpLen, }: {
40
41
  feature: Feature;
41
- cigarOp?: string;
42
42
  cigarOpLen?: string;
43
+ cigarOp?: string;
43
44
  }): string;
44
45
  export {};
@@ -1,4 +1,4 @@
1
- import { assembleLocString, doesIntersect2, getContainingTrack, getContainingView, getSession, isSessionModelWithWidgets, } from '@jbrowse/core/util';
1
+ import { assembleLocString, doesIntersect2, getContainingTrack, getContainingView, getSession, isSessionModelWithWidgets, toLocale, } from '@jbrowse/core/util';
2
2
  import { MAX_COLOR_RANGE, getId } from '../drawSynteny';
3
3
  export function drawMatchSimple({ feature, ctx, offsets, level, cb, height, drawCurves, oobLimit, viewWidth, hideTiny, }) {
4
4
  const { p11, p12, p21, p22 } = feature;
@@ -42,6 +42,42 @@ export function draw(ctx, x1, x2, y1, x3, x4, y2, mid, drawCurves) {
42
42
  drawBox(ctx, x1, x2, y1, x3, x4, y2);
43
43
  }
44
44
  }
45
+ export function drawLocationMarkers(ctx, x1, x2, y1, x3, x4, y2, mid, bpPerPx1, bpPerPx2, drawCurves) {
46
+ const width1 = Math.abs(x2 - x1);
47
+ const width2 = Math.abs(x4 - x3);
48
+ const averageWidth = (width1 + width2) / 2;
49
+ if (averageWidth < 30) {
50
+ return;
51
+ }
52
+ const targetPixelSpacing = 20;
53
+ const numMarkers = Math.max(2, Math.floor(averageWidth / targetPixelSpacing) + 1);
54
+ const prevStrokeStyle = ctx.strokeStyle;
55
+ const prevLineWidth = ctx.lineWidth;
56
+ ctx.strokeStyle = 'rgba(0, 0, 0, 0.25)';
57
+ ctx.lineWidth = 0.5;
58
+ ctx.beginPath();
59
+ if (drawCurves) {
60
+ for (let step = 0; step < numMarkers; step++) {
61
+ const t = step / numMarkers;
62
+ const topX = x1 + (x2 - x1) * t;
63
+ const bottomX = x4 + (x3 - x4) * t;
64
+ ctx.moveTo(topX, y1);
65
+ ctx.bezierCurveTo(topX, mid, bottomX, mid, bottomX, y2);
66
+ }
67
+ }
68
+ else {
69
+ for (let step = 0; step < numMarkers; step++) {
70
+ const t = step / numMarkers;
71
+ const topX = x1 + (x2 - x1) * t;
72
+ const bottomX = x4 + (x3 - x4) * t;
73
+ ctx.moveTo(topX, y1);
74
+ ctx.lineTo(bottomX, y2);
75
+ }
76
+ }
77
+ ctx.stroke();
78
+ ctx.strokeStyle = prevStrokeStyle;
79
+ ctx.lineWidth = prevLineWidth;
80
+ }
45
81
  export function drawBox(ctx, x1, x2, y1, x3, x4, y2) {
46
82
  ctx.beginPath();
47
83
  ctx.moveTo(x1, y1);
@@ -122,7 +158,11 @@ export function onSynContextClick(event, model, setAnchorEl) {
122
158
  const f = model.featPositions[id];
123
159
  if (f) {
124
160
  model.setClickId(f.f.id());
125
- setAnchorEl({ clientX, clientY, feature: f });
161
+ setAnchorEl({
162
+ clientX,
163
+ clientY,
164
+ feature: f,
165
+ });
126
166
  }
127
167
  }
128
168
  export function getTooltip({ feature, cigarOp, cigarOpLen, }) {
@@ -140,7 +180,7 @@ export function getTooltip({ feature, cigarOp, cigarOpLen, }) {
140
180
  `Query len: ${l1.toLocaleString('en-US')}`,
141
181
  `Target len: ${l2.toLocaleString('en-US')}`,
142
182
  identity ? `Identity: ${identity.toPrecision(2)}` : '',
143
- cigarOp ? `CIGAR operator: ${cigarOp}${cigarOpLen}` : '',
183
+ cigarOp ? `CIGAR operator: ${toLocale(+cigarOpLen)}${cigarOp}` : '',
144
184
  n1 ? `Name 1: ${n1}` : '',
145
185
  n2 ? `Name 2: ${n2}` : '',
146
186
  ]
@@ -1,5 +1,6 @@
1
1
  import type { LinearSyntenyDisplayModel } from './model';
2
2
  export declare const MAX_COLOR_RANGE: number;
3
3
  export declare function getId(r: number, g: number, b: number, unitMultiplier: number): number;
4
- export declare function drawRef(model: LinearSyntenyDisplayModel, ctx1: CanvasRenderingContext2D, ctx3?: CanvasRenderingContext2D): void;
5
- export declare function drawMouseoverSynteny(model: LinearSyntenyDisplayModel): void;
4
+ export declare function drawCigarClickMap(model: LinearSyntenyDisplayModel, cigarClickMapCanvas: CanvasRenderingContext2D): void;
5
+ export declare function drawRef(model: LinearSyntenyDisplayModel, mainCanvas: CanvasRenderingContext2D): void;
6
+ export declare function drawMouseoverClickMap(model: LinearSyntenyDisplayModel): void;