@jbrowse/plugin-linear-comparative-view 2.7.2 → 2.8.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.
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { Feature } from '@jbrowse/core/util';
3
+ export default function LaunchSyntenyViewDialog({ model, feature, handleClose, }: {
4
+ model: unknown;
5
+ feature: Feature;
6
+ handleClose: () => void;
7
+ }): React.JSX.Element;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const react_1 = __importStar(require("react"));
27
+ const ui_1 = require("@jbrowse/core/ui");
28
+ const util_1 = require("@jbrowse/core/util");
29
+ const material_1 = require("@mui/material");
30
+ const util_2 = require("./util");
31
+ const mui_1 = require("tss-react/mui");
32
+ const useStyles = (0, mui_1.makeStyles)()({
33
+ padding: {
34
+ margin: 10,
35
+ border: '1px solid #ccc',
36
+ },
37
+ });
38
+ function LaunchSyntenyViewDialog({ model, feature, handleClose, }) {
39
+ const { classes } = useStyles();
40
+ const inverted = feature.get('strand') === -1;
41
+ const [horizontallyFlip, setHorizontallyFlip] = (0, react_1.useState)(inverted);
42
+ const [windowSize, setWindowSize] = (0, react_1.useState)('1000');
43
+ return (react_1.default.createElement(ui_1.Dialog, { open: true, title: "Launch synteny view", onClose: handleClose },
44
+ react_1.default.createElement(material_1.DialogContent, null,
45
+ inverted ? (react_1.default.createElement(material_1.FormControlLabel, { className: classes.padding, control: react_1.default.createElement(material_1.Checkbox, { checked: horizontallyFlip, onChange: event => setHorizontallyFlip(event.target.checked) }), label: "Note: The feature is inverted in orientation on the target\n sequence. This will result in the lower panel having genomic\n coordinates decreasing left to right. Horizontally flip?" })) : null,
46
+ react_1.default.createElement(material_1.TextField, { label: "Add window size in bp", value: windowSize, onChange: event => setWindowSize(event.target.value) })),
47
+ react_1.default.createElement(material_1.DialogActions, null,
48
+ react_1.default.createElement(material_1.Button, { variant: "contained", onClick: () => {
49
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
50
+ ;
51
+ (async () => {
52
+ try {
53
+ await (0, util_2.navToSynteny)({
54
+ feature,
55
+ windowSize: +windowSize,
56
+ horizontallyFlip,
57
+ model,
58
+ });
59
+ }
60
+ catch (e) {
61
+ (0, util_1.getSession)(model).notify(`${e}`, 'error');
62
+ }
63
+ })();
64
+ handleClose();
65
+ } }, "Submit"),
66
+ react_1.default.createElement(material_1.Button, { variant: "contained", color: "secondary", onClick: () => handleClose() }, "Cancel"))));
67
+ }
68
+ exports.default = LaunchSyntenyViewDialog;
@@ -0,0 +1,8 @@
1
+ import { Feature } from '@jbrowse/core/util';
2
+ import { IAnyStateTreeNode } from 'mobx-state-tree';
3
+ export declare function navToSynteny({ feature, windowSize: ws, model, horizontallyFlip, }: {
4
+ windowSize: number;
5
+ horizontallyFlip: boolean;
6
+ feature: Feature;
7
+ model: IAnyStateTreeNode;
8
+ }): Promise<void>;
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.navToSynteny = void 0;
4
+ const util_1 = require("@jbrowse/core/util");
5
+ const plugin_alignments_1 = require("@jbrowse/plugin-alignments");
6
+ const mobx_1 = require("mobx");
7
+ const { parseCigar } = plugin_alignments_1.MismatchParser;
8
+ function f(n) {
9
+ return Math.floor(n);
10
+ }
11
+ function findPosInCigar(cigar, startX) {
12
+ let featX = 0;
13
+ let mateX = 0;
14
+ for (let i = 0; i < cigar.length; i++) {
15
+ const len = +cigar[i];
16
+ const op = cigar[i + 1];
17
+ const min = Math.min(len, startX - featX);
18
+ if (featX >= startX) {
19
+ break;
20
+ }
21
+ else if (op === 'I') {
22
+ mateX += len;
23
+ }
24
+ else if (op === 'D') {
25
+ featX += min;
26
+ }
27
+ else if (op === 'M') {
28
+ mateX += min;
29
+ featX += min;
30
+ }
31
+ }
32
+ return [featX, mateX];
33
+ }
34
+ async function navToSynteny({ feature, windowSize: ws, model, horizontallyFlip, }) {
35
+ const session = (0, util_1.getSession)(model);
36
+ const track = (0, util_1.getContainingTrack)(model);
37
+ const view = (0, util_1.getContainingView)(model);
38
+ const reg = view.dynamicBlocks.contentBlocks[0];
39
+ const cigar = feature.get('CIGAR');
40
+ const strand = feature.get('strand');
41
+ const regStart = reg.start;
42
+ const regEnd = reg.end;
43
+ const featStart = feature.get('start');
44
+ const featEnd = feature.get('end');
45
+ const mate = feature.get('mate');
46
+ const mateStart = mate.start;
47
+ const mateEnd = mate.end;
48
+ const mateAsm = mate.assemblyName;
49
+ const mateRef = mate.refName;
50
+ const featAsm = reg.assemblyName;
51
+ const featRef = reg.refName;
52
+ let rMateStart;
53
+ let rMateEnd;
54
+ let rFeatStart;
55
+ let rFeatEnd;
56
+ if (cigar) {
57
+ const p = parseCigar(cigar);
58
+ const [fStartX, mStartX] = findPosInCigar(p, regStart - featStart);
59
+ const [fEndX, mEndX] = findPosInCigar(p, regEnd - featStart);
60
+ // avoid multiply by 0 with strand undefined
61
+ const flipper = strand === -1 ? -1 : 1;
62
+ rFeatStart = featStart + fStartX;
63
+ rFeatEnd = featStart + fEndX;
64
+ rMateStart = (strand === -1 ? mateEnd : mateStart) + mStartX * flipper;
65
+ rMateEnd = (strand === -1 ? mateEnd : mateStart) + mEndX * flipper;
66
+ }
67
+ else {
68
+ rFeatStart = featStart;
69
+ rFeatEnd = featEnd;
70
+ rMateStart = mateStart;
71
+ rMateEnd = mateEnd;
72
+ }
73
+ const trackId = track.configuration.trackId;
74
+ const view2 = session.addView('LinearSyntenyView', {
75
+ type: 'LinearSyntenyView',
76
+ views: [
77
+ {
78
+ id: `${Math.random()}`,
79
+ type: 'LinearGenomeView',
80
+ hideHeader: true,
81
+ },
82
+ {
83
+ id: `${Math.random()}`,
84
+ type: 'LinearGenomeView',
85
+ hideHeader: true,
86
+ },
87
+ ],
88
+ tracks: [
89
+ {
90
+ configuration: trackId,
91
+ type: 'SyntenyTrack',
92
+ displays: [
93
+ {
94
+ type: 'LinearSyntenyDisplay',
95
+ configuration: `${trackId}-LinearSyntenyDisplay`,
96
+ },
97
+ ],
98
+ },
99
+ ],
100
+ });
101
+ const l1 = `${featRef}:${f(rFeatStart - ws)}-${f(rFeatEnd + ws)}`;
102
+ const m1 = Math.min(rMateStart, rMateEnd);
103
+ const m2 = Math.max(rMateStart, rMateEnd);
104
+ const l2 = `${mateRef}:${f(m1 - ws)}-${f(m2 + ws)}${horizontallyFlip ? '[rev]' : ''}`;
105
+ await (0, mobx_1.when)(() => view2.width !== undefined);
106
+ await Promise.all([
107
+ view2.views[0].navToLocString(l1, featAsm),
108
+ view2.views[1].navToLocString(l2, mateAsm),
109
+ ]);
110
+ }
111
+ exports.navToSynteny = navToSynteny;
@@ -1,6 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import { AnyConfigurationSchemaType } from '@jbrowse/core/configuration';
3
- import { Feature } from '@jbrowse/core/util';
4
3
  /**
5
4
  * #stateModel LGVSyntenyDisplay
6
5
  * extends `LinearPileupDisplay`, displays location of "synteny" feature in a
@@ -35,7 +34,7 @@ declare function stateModelFactory(schema: AnyConfigurationSchemaType): import("
35
34
  renderInProgress: AbortController | undefined;
36
35
  filled: boolean;
37
36
  reactElement: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
38
- features: Map<string, Feature> | undefined;
37
+ features: Map<string, import("@jbrowse/core/util").Feature> | undefined;
39
38
  layout: any;
40
39
  status: string;
41
40
  error: unknown;
@@ -53,7 +52,7 @@ declare function stateModelFactory(schema: AnyConfigurationSchemaType): import("
53
52
  setMessage(messageText: string): void;
54
53
  setRendered(props: {
55
54
  reactElement: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
56
- features: Map<string, Feature>;
55
+ features: Map<string, import("@jbrowse/core/util").Feature>;
57
56
  layout: any;
58
57
  maxHeightReached: boolean;
59
58
  renderProps: any;
@@ -70,7 +69,9 @@ declare function stateModelFactory(schema: AnyConfigurationSchemaType): import("
70
69
  };
71
70
  fetchSizeLimit: {
72
71
  type: string;
73
- defaultValue: number;
72
+ defaultValue: number; /**
73
+ * #property
74
+ */
74
75
  description: string;
75
76
  };
76
77
  height: {
@@ -208,7 +209,7 @@ declare function stateModelFactory(schema: AnyConfigurationSchemaType): import("
208
209
  regionCannotBeRendered(_region: import("@jbrowse/core/util").Region): import("react").JSX.Element | null;
209
210
  } & {
210
211
  featureIdUnderMouse: string | undefined;
211
- contextMenuFeature: Feature | undefined;
212
+ contextMenuFeature: import("@jbrowse/core/util").Feature | undefined;
212
213
  } & {
213
214
  readonly blockType: "dynamicBlocks" | "staticBlocks";
214
215
  readonly blockDefinitions: import("@jbrowse/core/util/blockTypes").BlockSet;
@@ -218,18 +219,18 @@ declare function stateModelFactory(schema: AnyConfigurationSchemaType): import("
218
219
  readonly selectedFeatureId: string | undefined;
219
220
  readonly DisplayMessageComponent: import("react").FC<any> | undefined;
220
221
  } & {
221
- readonly features: import("@jbrowse/core/util/compositeMap").default<string, Feature>;
222
- readonly featureUnderMouse: Feature | undefined;
222
+ readonly features: import("@jbrowse/core/util/compositeMap").default<string, import("@jbrowse/core/util").Feature>;
223
+ readonly featureUnderMouse: import("@jbrowse/core/util").Feature | undefined;
223
224
  getFeatureOverlapping(blockKey: string, x: number, y: number): string | undefined;
224
225
  getFeatureByID(blockKey: string, id: string): [number, number, number, number] | undefined;
225
226
  searchFeatureByID(id: string): [number, number, number, number] | undefined;
226
227
  } & {
227
228
  addBlock(key: string, block: import("@jbrowse/core/util/blockTypes").BaseBlock): void;
228
229
  deleteBlock(key: string): void;
229
- selectFeature(feature: Feature): void;
230
+ selectFeature(feature: import("@jbrowse/core/util").Feature): void;
230
231
  clearFeatureSelection(): void;
231
232
  setFeatureIdUnderMouse(feature?: string | undefined): void;
232
- setContextMenuFeature(feature?: Feature | undefined): void;
233
+ setContextMenuFeature(feature?: import("@jbrowse/core/util").Feature | undefined): void;
233
234
  } & {
234
235
  reload(): Promise<void>;
235
236
  } & {
@@ -241,7 +242,7 @@ declare function stateModelFactory(schema: AnyConfigurationSchemaType): import("
241
242
  afterAttach(): void;
242
243
  } & {
243
244
  colorTagMap: import("mobx").ObservableMap<string, string>;
244
- featureUnderMouseVolatile: Feature | undefined;
245
+ featureUnderMouseVolatile: import("@jbrowse/core/util").Feature | undefined;
245
246
  tagsReady: boolean;
246
247
  } & {
247
248
  readonly autorunReady: boolean;
@@ -256,9 +257,9 @@ declare function stateModelFactory(schema: AnyConfigurationSchemaType): import("
256
257
  extra?: import("@jbrowse/plugin-alignments/src/shared/color").ExtraColorBy | undefined;
257
258
  }): void;
258
259
  updateColorTagMap(uniqueTag: string[]): void;
259
- setFeatureUnderMouse(feat?: Feature | undefined): void;
260
- selectFeature(feature: Feature): void;
261
- copyFeatureToClipboard(feature: Feature): void;
260
+ setFeatureUnderMouse(feat?: import("@jbrowse/core/util").Feature | undefined): void;
261
+ selectFeature(feature: import("@jbrowse/core/util").Feature): void;
262
+ copyFeatureToClipboard(feature: import("@jbrowse/core/util").Feature): void;
262
263
  setConfig(conf: {
263
264
  [x: string]: any;
264
265
  } & import("mobx-state-tree/dist/internal").NonEmptyObject & {
@@ -275,7 +276,7 @@ declare function stateModelFactory(schema: AnyConfigurationSchemaType): import("
275
276
  } & {
276
277
  readonly maxHeight: any;
277
278
  readonly featureHeightSetting: any;
278
- readonly featureUnderMouse: Feature | undefined;
279
+ readonly featureUnderMouse: import("@jbrowse/core/util").Feature | undefined;
279
280
  renderReady(): boolean;
280
281
  readonly filters: import("@jbrowse/core/pluggableElementTypes/renderers/util/serializableFilterChain").default;
281
282
  } & {
@@ -1,112 +1,34 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
+ const react_1 = require("react");
3
27
  const configuration_1 = require("@jbrowse/core/configuration");
4
28
  const util_1 = require("@jbrowse/core/util");
5
29
  const plugin_alignments_1 = require("@jbrowse/plugin-alignments");
6
30
  const mobx_state_tree_1 = require("mobx-state-tree");
7
- const mobx_1 = require("mobx");
8
- const { parseCigar } = plugin_alignments_1.MismatchParser;
9
- function findPosInCigar(cigar, startX) {
10
- let featX = 0;
11
- let mateX = 0;
12
- for (let i = 0; i < cigar.length; i++) {
13
- const len = +cigar[i];
14
- const op = cigar[i + 1];
15
- const min = Math.min(len, startX - featX);
16
- if (featX >= startX) {
17
- break;
18
- }
19
- else if (op === 'I') {
20
- mateX += len;
21
- }
22
- else if (op === 'D') {
23
- featX += min;
24
- }
25
- else if (op === 'M') {
26
- mateX += min;
27
- featX += min;
28
- }
29
- }
30
- return [featX, mateX];
31
- }
32
- async function navToSynteny(feature, self) {
33
- const session = (0, util_1.getSession)(self);
34
- const track = (0, util_1.getContainingTrack)(self);
35
- const view = (0, util_1.getContainingView)(self);
36
- const reg = view.dynamicBlocks.contentBlocks[0];
37
- const cigar = feature.get('CIGAR');
38
- const strand = feature.get('strand');
39
- const regStart = reg.start;
40
- const regEnd = reg.end;
41
- const featStart = feature.get('start');
42
- const featEnd = feature.get('end');
43
- const mate = feature.get('mate');
44
- const mateStart = mate.start;
45
- const mateEnd = mate.end;
46
- const mateAsm = mate.assemblyName;
47
- const mateRef = mate.refName;
48
- const featAsm = reg.assemblyName;
49
- const featRef = reg.refName;
50
- let rMateStart;
51
- let rMateEnd;
52
- let rFeatStart;
53
- let rFeatEnd;
54
- if (cigar) {
55
- const p = parseCigar(cigar);
56
- const [fStartX, mStartX] = findPosInCigar(p, regStart - featStart);
57
- const [fEndX, mEndX] = findPosInCigar(p, regEnd - featStart);
58
- // avoid multiply by 0 with strand undefined
59
- const flipper = strand === -1 ? -1 : 1;
60
- rFeatStart = featStart + fStartX;
61
- rFeatEnd = featStart + fEndX;
62
- rMateStart = (strand === -1 ? mateEnd : mateStart) + mStartX * flipper;
63
- rMateEnd = (strand === -1 ? mateEnd : mateStart) + mEndX * flipper;
64
- }
65
- else {
66
- rFeatStart = featStart;
67
- rFeatEnd = featEnd;
68
- rMateStart = mateStart;
69
- rMateEnd = mateEnd;
70
- }
71
- const trackId = track.configuration.trackId;
72
- const view2 = session.addView('LinearSyntenyView', {
73
- type: 'LinearSyntenyView',
74
- views: [
75
- {
76
- id: `${Math.random()}`,
77
- type: 'LinearGenomeView',
78
- hideHeader: true,
79
- },
80
- {
81
- id: `${Math.random()}`,
82
- type: 'LinearGenomeView',
83
- hideHeader: true,
84
- },
85
- ],
86
- tracks: [
87
- {
88
- configuration: trackId,
89
- type: 'SyntenyTrack',
90
- displays: [
91
- {
92
- type: 'LinearSyntenyDisplay',
93
- configuration: `${trackId}-LinearSyntenyDisplay`,
94
- },
95
- ],
96
- },
97
- ],
98
- });
99
- const f = (n) => Math.floor(n);
100
- const l1 = `${featRef}:${f(rFeatStart)}-${f(rFeatEnd)}`;
101
- const m1 = Math.min(rMateStart, rMateEnd);
102
- const m2 = Math.max(rMateStart, rMateEnd);
103
- const l2 = `${mateRef}:${f(m1)}-${f(m2)}${strand === -1 ? '[rev]' : ''}`;
104
- await (0, mobx_1.when)(() => view2.width !== undefined);
105
- await Promise.all([
106
- view2.views[0].navToLocString(l1, featAsm),
107
- view2.views[1].navToLocString(l2, mateAsm),
108
- ]);
109
- }
31
+ const LaunchSyntenyViewDialog = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./components/LaunchSyntenyViewDialog'))));
110
32
  /**
111
33
  * #stateModel LGVSyntenyDisplay
112
34
  * extends `LinearPileupDisplay`, displays location of "synteny" feature in a
@@ -135,7 +57,16 @@ function stateModelFactory(schema) {
135
57
  ? [
136
58
  {
137
59
  label: 'Open synteny view for this position',
138
- onClick: () => navToSynteny(feature, self),
60
+ onClick: () => {
61
+ (0, util_1.getSession)(self).queueDialog(handleClose => [
62
+ LaunchSyntenyViewDialog,
63
+ {
64
+ model: self,
65
+ handleClose,
66
+ feature,
67
+ },
68
+ ]);
69
+ },
139
70
  },
140
71
  ]
141
72
  : []),
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { Feature } from '@jbrowse/core/util';
3
+ export default function LaunchSyntenyViewDialog({ model, feature, handleClose, }: {
4
+ model: unknown;
5
+ feature: Feature;
6
+ handleClose: () => void;
7
+ }): React.JSX.Element;
@@ -0,0 +1,42 @@
1
+ import React, { useState } from 'react';
2
+ import { Dialog } from '@jbrowse/core/ui';
3
+ import { getSession } from '@jbrowse/core/util';
4
+ import { Button, Checkbox, DialogActions, DialogContent, FormControlLabel, TextField, } from '@mui/material';
5
+ import { navToSynteny } from './util';
6
+ import { makeStyles } from 'tss-react/mui';
7
+ const useStyles = makeStyles()({
8
+ padding: {
9
+ margin: 10,
10
+ border: '1px solid #ccc',
11
+ },
12
+ });
13
+ export default function LaunchSyntenyViewDialog({ model, feature, handleClose, }) {
14
+ const { classes } = useStyles();
15
+ const inverted = feature.get('strand') === -1;
16
+ const [horizontallyFlip, setHorizontallyFlip] = useState(inverted);
17
+ const [windowSize, setWindowSize] = useState('1000');
18
+ return (React.createElement(Dialog, { open: true, title: "Launch synteny view", onClose: handleClose },
19
+ React.createElement(DialogContent, null,
20
+ inverted ? (React.createElement(FormControlLabel, { className: classes.padding, control: React.createElement(Checkbox, { checked: horizontallyFlip, onChange: event => setHorizontallyFlip(event.target.checked) }), label: "Note: The feature is inverted in orientation on the target\n sequence. This will result in the lower panel having genomic\n coordinates decreasing left to right. Horizontally flip?" })) : null,
21
+ React.createElement(TextField, { label: "Add window size in bp", value: windowSize, onChange: event => setWindowSize(event.target.value) })),
22
+ React.createElement(DialogActions, null,
23
+ React.createElement(Button, { variant: "contained", onClick: () => {
24
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
25
+ ;
26
+ (async () => {
27
+ try {
28
+ await navToSynteny({
29
+ feature,
30
+ windowSize: +windowSize,
31
+ horizontallyFlip,
32
+ model,
33
+ });
34
+ }
35
+ catch (e) {
36
+ getSession(model).notify(`${e}`, 'error');
37
+ }
38
+ })();
39
+ handleClose();
40
+ } }, "Submit"),
41
+ React.createElement(Button, { variant: "contained", color: "secondary", onClick: () => handleClose() }, "Cancel"))));
42
+ }
@@ -0,0 +1,8 @@
1
+ import { Feature } from '@jbrowse/core/util';
2
+ import { IAnyStateTreeNode } from 'mobx-state-tree';
3
+ export declare function navToSynteny({ feature, windowSize: ws, model, horizontallyFlip, }: {
4
+ windowSize: number;
5
+ horizontallyFlip: boolean;
6
+ feature: Feature;
7
+ model: IAnyStateTreeNode;
8
+ }): Promise<void>;
@@ -0,0 +1,107 @@
1
+ import { getSession, getContainingTrack, getContainingView, } from '@jbrowse/core/util';
2
+ import { MismatchParser } from '@jbrowse/plugin-alignments';
3
+ import { when } from 'mobx';
4
+ const { parseCigar } = MismatchParser;
5
+ function f(n) {
6
+ return Math.floor(n);
7
+ }
8
+ function findPosInCigar(cigar, startX) {
9
+ let featX = 0;
10
+ let mateX = 0;
11
+ for (let i = 0; i < cigar.length; i++) {
12
+ const len = +cigar[i];
13
+ const op = cigar[i + 1];
14
+ const min = Math.min(len, startX - featX);
15
+ if (featX >= startX) {
16
+ break;
17
+ }
18
+ else if (op === 'I') {
19
+ mateX += len;
20
+ }
21
+ else if (op === 'D') {
22
+ featX += min;
23
+ }
24
+ else if (op === 'M') {
25
+ mateX += min;
26
+ featX += min;
27
+ }
28
+ }
29
+ return [featX, mateX];
30
+ }
31
+ export async function navToSynteny({ feature, windowSize: ws, model, horizontallyFlip, }) {
32
+ const session = getSession(model);
33
+ const track = getContainingTrack(model);
34
+ const view = getContainingView(model);
35
+ const reg = view.dynamicBlocks.contentBlocks[0];
36
+ const cigar = feature.get('CIGAR');
37
+ const strand = feature.get('strand');
38
+ const regStart = reg.start;
39
+ const regEnd = reg.end;
40
+ const featStart = feature.get('start');
41
+ const featEnd = feature.get('end');
42
+ const mate = feature.get('mate');
43
+ const mateStart = mate.start;
44
+ const mateEnd = mate.end;
45
+ const mateAsm = mate.assemblyName;
46
+ const mateRef = mate.refName;
47
+ const featAsm = reg.assemblyName;
48
+ const featRef = reg.refName;
49
+ let rMateStart;
50
+ let rMateEnd;
51
+ let rFeatStart;
52
+ let rFeatEnd;
53
+ if (cigar) {
54
+ const p = parseCigar(cigar);
55
+ const [fStartX, mStartX] = findPosInCigar(p, regStart - featStart);
56
+ const [fEndX, mEndX] = findPosInCigar(p, regEnd - featStart);
57
+ // avoid multiply by 0 with strand undefined
58
+ const flipper = strand === -1 ? -1 : 1;
59
+ rFeatStart = featStart + fStartX;
60
+ rFeatEnd = featStart + fEndX;
61
+ rMateStart = (strand === -1 ? mateEnd : mateStart) + mStartX * flipper;
62
+ rMateEnd = (strand === -1 ? mateEnd : mateStart) + mEndX * flipper;
63
+ }
64
+ else {
65
+ rFeatStart = featStart;
66
+ rFeatEnd = featEnd;
67
+ rMateStart = mateStart;
68
+ rMateEnd = mateEnd;
69
+ }
70
+ const trackId = track.configuration.trackId;
71
+ const view2 = session.addView('LinearSyntenyView', {
72
+ type: 'LinearSyntenyView',
73
+ views: [
74
+ {
75
+ id: `${Math.random()}`,
76
+ type: 'LinearGenomeView',
77
+ hideHeader: true,
78
+ },
79
+ {
80
+ id: `${Math.random()}`,
81
+ type: 'LinearGenomeView',
82
+ hideHeader: true,
83
+ },
84
+ ],
85
+ tracks: [
86
+ {
87
+ configuration: trackId,
88
+ type: 'SyntenyTrack',
89
+ displays: [
90
+ {
91
+ type: 'LinearSyntenyDisplay',
92
+ configuration: `${trackId}-LinearSyntenyDisplay`,
93
+ },
94
+ ],
95
+ },
96
+ ],
97
+ });
98
+ const l1 = `${featRef}:${f(rFeatStart - ws)}-${f(rFeatEnd + ws)}`;
99
+ const m1 = Math.min(rMateStart, rMateEnd);
100
+ const m2 = Math.max(rMateStart, rMateEnd);
101
+ const l2 = `${mateRef}:${f(m1 - ws)}-${f(m2 + ws)}${horizontallyFlip ? '[rev]' : ''}`;
102
+ await when(() => view2.width !== undefined);
103
+ await Promise.all([
104
+ view2.views[0].navToLocString(l1, featAsm),
105
+ view2.views[1].navToLocString(l2, mateAsm),
106
+ ]);
107
+ }
@@ -1,6 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import { AnyConfigurationSchemaType } from '@jbrowse/core/configuration';
3
- import { Feature } from '@jbrowse/core/util';
4
3
  /**
5
4
  * #stateModel LGVSyntenyDisplay
6
5
  * extends `LinearPileupDisplay`, displays location of "synteny" feature in a
@@ -35,7 +34,7 @@ declare function stateModelFactory(schema: AnyConfigurationSchemaType): import("
35
34
  renderInProgress: AbortController | undefined;
36
35
  filled: boolean;
37
36
  reactElement: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
38
- features: Map<string, Feature> | undefined;
37
+ features: Map<string, import("@jbrowse/core/util").Feature> | undefined;
39
38
  layout: any;
40
39
  status: string;
41
40
  error: unknown;
@@ -53,7 +52,7 @@ declare function stateModelFactory(schema: AnyConfigurationSchemaType): import("
53
52
  setMessage(messageText: string): void;
54
53
  setRendered(props: {
55
54
  reactElement: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
56
- features: Map<string, Feature>;
55
+ features: Map<string, import("@jbrowse/core/util").Feature>;
57
56
  layout: any;
58
57
  maxHeightReached: boolean;
59
58
  renderProps: any;
@@ -70,7 +69,9 @@ declare function stateModelFactory(schema: AnyConfigurationSchemaType): import("
70
69
  };
71
70
  fetchSizeLimit: {
72
71
  type: string;
73
- defaultValue: number;
72
+ defaultValue: number; /**
73
+ * #property
74
+ */
74
75
  description: string;
75
76
  };
76
77
  height: {
@@ -208,7 +209,7 @@ declare function stateModelFactory(schema: AnyConfigurationSchemaType): import("
208
209
  regionCannotBeRendered(_region: import("@jbrowse/core/util").Region): import("react").JSX.Element | null;
209
210
  } & {
210
211
  featureIdUnderMouse: string | undefined;
211
- contextMenuFeature: Feature | undefined;
212
+ contextMenuFeature: import("@jbrowse/core/util").Feature | undefined;
212
213
  } & {
213
214
  readonly blockType: "dynamicBlocks" | "staticBlocks";
214
215
  readonly blockDefinitions: import("@jbrowse/core/util/blockTypes").BlockSet;
@@ -218,18 +219,18 @@ declare function stateModelFactory(schema: AnyConfigurationSchemaType): import("
218
219
  readonly selectedFeatureId: string | undefined;
219
220
  readonly DisplayMessageComponent: import("react").FC<any> | undefined;
220
221
  } & {
221
- readonly features: import("@jbrowse/core/util/compositeMap").default<string, Feature>;
222
- readonly featureUnderMouse: Feature | undefined;
222
+ readonly features: import("@jbrowse/core/util/compositeMap").default<string, import("@jbrowse/core/util").Feature>;
223
+ readonly featureUnderMouse: import("@jbrowse/core/util").Feature | undefined;
223
224
  getFeatureOverlapping(blockKey: string, x: number, y: number): string | undefined;
224
225
  getFeatureByID(blockKey: string, id: string): [number, number, number, number] | undefined;
225
226
  searchFeatureByID(id: string): [number, number, number, number] | undefined;
226
227
  } & {
227
228
  addBlock(key: string, block: import("@jbrowse/core/util/blockTypes").BaseBlock): void;
228
229
  deleteBlock(key: string): void;
229
- selectFeature(feature: Feature): void;
230
+ selectFeature(feature: import("@jbrowse/core/util").Feature): void;
230
231
  clearFeatureSelection(): void;
231
232
  setFeatureIdUnderMouse(feature?: string | undefined): void;
232
- setContextMenuFeature(feature?: Feature | undefined): void;
233
+ setContextMenuFeature(feature?: import("@jbrowse/core/util").Feature | undefined): void;
233
234
  } & {
234
235
  reload(): Promise<void>;
235
236
  } & {
@@ -241,7 +242,7 @@ declare function stateModelFactory(schema: AnyConfigurationSchemaType): import("
241
242
  afterAttach(): void;
242
243
  } & {
243
244
  colorTagMap: import("mobx").ObservableMap<string, string>;
244
- featureUnderMouseVolatile: Feature | undefined;
245
+ featureUnderMouseVolatile: import("@jbrowse/core/util").Feature | undefined;
245
246
  tagsReady: boolean;
246
247
  } & {
247
248
  readonly autorunReady: boolean;
@@ -256,9 +257,9 @@ declare function stateModelFactory(schema: AnyConfigurationSchemaType): import("
256
257
  extra?: import("@jbrowse/plugin-alignments/src/shared/color").ExtraColorBy | undefined;
257
258
  }): void;
258
259
  updateColorTagMap(uniqueTag: string[]): void;
259
- setFeatureUnderMouse(feat?: Feature | undefined): void;
260
- selectFeature(feature: Feature): void;
261
- copyFeatureToClipboard(feature: Feature): void;
260
+ setFeatureUnderMouse(feat?: import("@jbrowse/core/util").Feature | undefined): void;
261
+ selectFeature(feature: import("@jbrowse/core/util").Feature): void;
262
+ copyFeatureToClipboard(feature: import("@jbrowse/core/util").Feature): void;
262
263
  setConfig(conf: {
263
264
  [x: string]: any;
264
265
  } & import("mobx-state-tree/dist/internal").NonEmptyObject & {
@@ -275,7 +276,7 @@ declare function stateModelFactory(schema: AnyConfigurationSchemaType): import("
275
276
  } & {
276
277
  readonly maxHeight: any;
277
278
  readonly featureHeightSetting: any;
278
- readonly featureUnderMouse: Feature | undefined;
279
+ readonly featureUnderMouse: import("@jbrowse/core/util").Feature | undefined;
279
280
  renderReady(): boolean;
280
281
  readonly filters: import("@jbrowse/core/pluggableElementTypes/renderers/util/serializableFilterChain").default;
281
282
  } & {
@@ -1,110 +1,9 @@
1
+ import { lazy } from 'react';
1
2
  import { ConfigurationReference, } from '@jbrowse/core/configuration';
2
- import { getSession, getContainingTrack, getContainingView, } from '@jbrowse/core/util';
3
- import { MismatchParser, SharedLinearPileupDisplayMixin, } from '@jbrowse/plugin-alignments';
3
+ import { getSession } from '@jbrowse/core/util';
4
+ import { SharedLinearPileupDisplayMixin } from '@jbrowse/plugin-alignments';
4
5
  import { types } from 'mobx-state-tree';
5
- import { when } from 'mobx';
6
- const { parseCigar } = MismatchParser;
7
- function findPosInCigar(cigar, startX) {
8
- let featX = 0;
9
- let mateX = 0;
10
- for (let i = 0; i < cigar.length; i++) {
11
- const len = +cigar[i];
12
- const op = cigar[i + 1];
13
- const min = Math.min(len, startX - featX);
14
- if (featX >= startX) {
15
- break;
16
- }
17
- else if (op === 'I') {
18
- mateX += len;
19
- }
20
- else if (op === 'D') {
21
- featX += min;
22
- }
23
- else if (op === 'M') {
24
- mateX += min;
25
- featX += min;
26
- }
27
- }
28
- return [featX, mateX];
29
- }
30
- async function navToSynteny(feature, self) {
31
- const session = getSession(self);
32
- const track = getContainingTrack(self);
33
- const view = getContainingView(self);
34
- const reg = view.dynamicBlocks.contentBlocks[0];
35
- const cigar = feature.get('CIGAR');
36
- const strand = feature.get('strand');
37
- const regStart = reg.start;
38
- const regEnd = reg.end;
39
- const featStart = feature.get('start');
40
- const featEnd = feature.get('end');
41
- const mate = feature.get('mate');
42
- const mateStart = mate.start;
43
- const mateEnd = mate.end;
44
- const mateAsm = mate.assemblyName;
45
- const mateRef = mate.refName;
46
- const featAsm = reg.assemblyName;
47
- const featRef = reg.refName;
48
- let rMateStart;
49
- let rMateEnd;
50
- let rFeatStart;
51
- let rFeatEnd;
52
- if (cigar) {
53
- const p = parseCigar(cigar);
54
- const [fStartX, mStartX] = findPosInCigar(p, regStart - featStart);
55
- const [fEndX, mEndX] = findPosInCigar(p, regEnd - featStart);
56
- // avoid multiply by 0 with strand undefined
57
- const flipper = strand === -1 ? -1 : 1;
58
- rFeatStart = featStart + fStartX;
59
- rFeatEnd = featStart + fEndX;
60
- rMateStart = (strand === -1 ? mateEnd : mateStart) + mStartX * flipper;
61
- rMateEnd = (strand === -1 ? mateEnd : mateStart) + mEndX * flipper;
62
- }
63
- else {
64
- rFeatStart = featStart;
65
- rFeatEnd = featEnd;
66
- rMateStart = mateStart;
67
- rMateEnd = mateEnd;
68
- }
69
- const trackId = track.configuration.trackId;
70
- const view2 = session.addView('LinearSyntenyView', {
71
- type: 'LinearSyntenyView',
72
- views: [
73
- {
74
- id: `${Math.random()}`,
75
- type: 'LinearGenomeView',
76
- hideHeader: true,
77
- },
78
- {
79
- id: `${Math.random()}`,
80
- type: 'LinearGenomeView',
81
- hideHeader: true,
82
- },
83
- ],
84
- tracks: [
85
- {
86
- configuration: trackId,
87
- type: 'SyntenyTrack',
88
- displays: [
89
- {
90
- type: 'LinearSyntenyDisplay',
91
- configuration: `${trackId}-LinearSyntenyDisplay`,
92
- },
93
- ],
94
- },
95
- ],
96
- });
97
- const f = (n) => Math.floor(n);
98
- const l1 = `${featRef}:${f(rFeatStart)}-${f(rFeatEnd)}`;
99
- const m1 = Math.min(rMateStart, rMateEnd);
100
- const m2 = Math.max(rMateStart, rMateEnd);
101
- const l2 = `${mateRef}:${f(m1)}-${f(m2)}${strand === -1 ? '[rev]' : ''}`;
102
- await when(() => view2.width !== undefined);
103
- await Promise.all([
104
- view2.views[0].navToLocString(l1, featAsm),
105
- view2.views[1].navToLocString(l2, mateAsm),
106
- ]);
107
- }
6
+ const LaunchSyntenyViewDialog = lazy(() => import('./components/LaunchSyntenyViewDialog'));
108
7
  /**
109
8
  * #stateModel LGVSyntenyDisplay
110
9
  * extends `LinearPileupDisplay`, displays location of "synteny" feature in a
@@ -133,7 +32,16 @@ function stateModelFactory(schema) {
133
32
  ? [
134
33
  {
135
34
  label: 'Open synteny view for this position',
136
- onClick: () => navToSynteny(feature, self),
35
+ onClick: () => {
36
+ getSession(self).queueDialog(handleClose => [
37
+ LaunchSyntenyViewDialog,
38
+ {
39
+ model: self,
40
+ handleClose,
41
+ feature,
42
+ },
43
+ ]);
44
+ },
137
45
  },
138
46
  ]
139
47
  : []),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-linear-comparative-view",
3
- "version": "2.7.2",
3
+ "version": "2.8.0",
4
4
  "description": "JBrowse 2 linear comparative view",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -62,5 +62,5 @@
62
62
  "publishConfig": {
63
63
  "access": "public"
64
64
  },
65
- "gitHead": "9052b295f2d322e729254457ed9fe2231fb22cce"
65
+ "gitHead": "ee8c2bdc8bd4f1a70b1eefda984f04a2830d9ca0"
66
66
  }