@jbrowse/plugin-sv-inspector 3.7.0 → 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.
@@ -2,9 +2,9 @@ import { readConfObject } from '@jbrowse/core/configuration';
2
2
  import { BaseViewModel } from '@jbrowse/core/pluggableElementTypes/models';
3
3
  import { getSession } from '@jbrowse/core/util';
4
4
  import { ElementId } from '@jbrowse/core/util/types/mst';
5
+ import { addDisposer, types } from '@jbrowse/mobx-state-tree';
5
6
  import FolderOpenIcon from '@mui/icons-material/FolderOpen';
6
7
  import { autorun, reaction } from 'mobx';
7
- import { addDisposer, types } from 'mobx-state-tree';
8
8
  function SvInspectorViewF(pluginManager) {
9
9
  const SpreadsheetViewType = pluginManager.getViewType('SpreadsheetView');
10
10
  const CircularViewType = pluginManager.getViewType('CircularView');
@@ -30,6 +30,7 @@ function SvInspectorViewF(pluginManager) {
30
30
  hideTrackSelectorButton: true,
31
31
  disableImportForm: true,
32
32
  })),
33
+ init: types.frozen(),
33
34
  }))
34
35
  .volatile(() => ({
35
36
  width: 800,
@@ -45,12 +46,12 @@ function SvInspectorViewF(pluginManager) {
45
46
  : undefined;
46
47
  },
47
48
  get showCircularView() {
48
- var _a;
49
- return !!((_a = self.spreadsheetView.spreadsheet) === null || _a === void 0 ? void 0 : _a.rowSet);
49
+ return !!self.spreadsheetView.spreadsheet?.rowSet;
50
50
  },
51
51
  get features() {
52
- var _a, _b;
53
- return (((_b = structuredClone((_a = self.spreadsheetView.spreadsheet) === null || _a === void 0 ? void 0 : _a.visibleRows)) === null || _b === void 0 ? void 0 : _b.map(row => row.feature).filter(f => !!f)) || []);
52
+ return (structuredClone(self.spreadsheetView.spreadsheet?.visibleRows)
53
+ ?.map(row => row.feature)
54
+ .filter(f => !!f) || []);
54
55
  },
55
56
  get featuresAdapterConfigSnapshot() {
56
57
  return {
@@ -62,8 +63,8 @@ function SvInspectorViewF(pluginManager) {
62
63
  return [
63
64
  ...new Set([
64
65
  ...this.features.map(r => r.refName),
65
- ...this.features.flatMap(r => { var _a; return (_a = r.INFO) === null || _a === void 0 ? void 0 : _a.CHR2; }),
66
- ...this.features.flatMap(r => { var _a; return (_a = r.mate) === null || _a === void 0 ? void 0 : _a.refName; }),
66
+ ...this.features.flatMap(r => r.INFO?.CHR2),
67
+ ...this.features.flatMap(r => r.mate?.refName),
67
68
  ].filter(f => !!f)),
68
69
  ];
69
70
  },
@@ -75,7 +76,7 @@ function SvInspectorViewF(pluginManager) {
75
76
  },
76
77
  get canonicalFeatureRefNameSet() {
77
78
  const asm = this.currentAssembly;
78
- return new Set((asm === null || asm === void 0 ? void 0 : asm.initialized)
79
+ return new Set(asm?.initialized
79
80
  ? this.featureRefNames.map(r => asm.getCanonicalRefName(r) || r)
80
81
  : []);
81
82
  },
@@ -113,6 +114,9 @@ function SvInspectorViewF(pluginManager) {
113
114
  setOnlyDisplayRelevantRegionsInCircularView(val) {
114
115
  self.onlyDisplayRelevantRegionsInCircularView = val;
115
116
  },
117
+ setInit(init) {
118
+ self.init = init;
119
+ },
116
120
  }))
117
121
  .views(self => ({
118
122
  menuItems() {
@@ -134,6 +138,33 @@ function SvInspectorViewF(pluginManager) {
134
138
  return newHeight - oldHeight;
135
139
  },
136
140
  afterAttach() {
141
+ addDisposer(self, autorun(async function svInspectorViewInitAutorun() {
142
+ const { init, width } = self;
143
+ if (!width || !init) {
144
+ return;
145
+ }
146
+ const session = getSession(self);
147
+ try {
148
+ const exts = init.uri.split('.');
149
+ let ext = exts.pop()?.toUpperCase();
150
+ if (ext === 'GZ') {
151
+ ext = exts.pop()?.toUpperCase();
152
+ }
153
+ self.spreadsheetView.importWizard.setFileType(init.fileType || ext || '');
154
+ self.spreadsheetView.importWizard.setSelectedAssemblyName(init.assembly);
155
+ self.spreadsheetView.importWizard.setFileSource({
156
+ uri: init.uri,
157
+ locationType: 'UriLocation',
158
+ });
159
+ await self.spreadsheetView.importWizard.import(init.assembly);
160
+ self.setInit(undefined);
161
+ }
162
+ catch (e) {
163
+ console.error(e);
164
+ session.notifyError(`${e}`, e);
165
+ self.setInit(undefined);
166
+ }
167
+ }, { name: 'SvInspectorViewInit' }));
137
168
  addDisposer(self, autorun(() => {
138
169
  const borderWidth = 1;
139
170
  if (self.showCircularView) {
@@ -154,7 +185,7 @@ function SvInspectorViewF(pluginManager) {
154
185
  }));
155
186
  addDisposer(self, autorun(async () => {
156
187
  const { onlyDisplayRelevantRegionsInCircularView, circularView, canonicalFeatureRefNameSet, currentAssembly, } = self;
157
- if (!circularView.initialized || !(currentAssembly === null || currentAssembly === void 0 ? void 0 : currentAssembly.regions)) {
188
+ if (!circularView.initialized || !currentAssembly?.regions) {
158
189
  return;
159
190
  }
160
191
  else if (onlyDisplayRelevantRegionsInCircularView) {
@@ -196,7 +227,7 @@ function SvInspectorViewF(pluginManager) {
196
227
  },
197
228
  }))
198
229
  .postProcessSnapshot(snap => {
199
- const { circularView, ...rest } = snap;
230
+ const { init, circularView, ...rest } = snap;
200
231
  return rest;
201
232
  });
202
233
  }
package/esm/index.js CHANGED
@@ -1,13 +1,10 @@
1
1
  import Plugin from '@jbrowse/core/Plugin';
2
2
  import { isAbstractMenuManager } from '@jbrowse/core/util/types';
3
3
  import TableChartIcon from '@mui/icons-material/TableChart';
4
- import LaunchSvInspectorViewF from './LaunchSvInspectorView';
5
- import SvInspectorViewF from './SvInspectorView';
4
+ import LaunchSvInspectorViewF from "./LaunchSvInspectorView/index.js";
5
+ import SvInspectorViewF from "./SvInspectorView/index.js";
6
6
  export default class SvInspectorViewPlugin extends Plugin {
7
- constructor() {
8
- super(...arguments);
9
- this.name = 'SvInspectorViewPlugin';
10
- }
7
+ name = 'SvInspectorViewPlugin';
11
8
  install(pluginManager) {
12
9
  SvInspectorViewF(pluginManager);
13
10
  LaunchSvInspectorViewF(pluginManager);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-sv-inspector",
3
- "version": "3.7.0",
3
+ "version": "4.0.0",
4
4
  "description": "JBrowse 2 SV inspector view",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -15,47 +15,41 @@
15
15
  "directory": "plugins/sv-inspector"
16
16
  },
17
17
  "author": "JBrowse Team",
18
- "distMain": "dist/index.js",
19
- "srcMain": "src/index.ts",
20
- "main": "dist/index.js",
18
+ "main": "esm/index.js",
21
19
  "files": [
22
- "dist",
23
20
  "esm"
24
21
  ],
25
- "scripts": {
26
- "build": "npm-run-all build:*",
27
- "test": "cd ../..; jest --passWithNoTests plugins/sv-inspector",
28
- "prepublishOnly": "yarn test",
29
- "prepack": "yarn build && yarn useDist",
30
- "postpack": "yarn useSrc",
31
- "useDist": "node ../../scripts/useDist.js",
32
- "useSrc": "node ../../scripts/useSrc.js",
33
- "prebuild": "npm run clean",
34
- "build:esm": "tsc --build tsconfig.build.esm.json",
35
- "build:commonjs": "tsc --build tsconfig.build.commonjs.json",
36
- "clean": "rimraf dist esm *.tsbuildinfo"
37
- },
38
22
  "dependencies": {
39
- "@jbrowse/core": "^3.7.0",
40
- "@jbrowse/plugin-circular-view": "^3.7.0",
41
- "@jbrowse/plugin-spreadsheet-view": "^3.7.0",
42
- "@jbrowse/sv-core": "^3.7.0",
43
- "@mui/icons-material": "^7.0.0",
44
- "@mui/material": "^7.0.0",
45
- "mobx": "^6.0.0",
46
- "mobx-react": "^9.0.0",
47
- "mobx-state-tree": "^5.0.0",
48
- "tss-react": "^4.0.0"
23
+ "@jbrowse/mobx-state-tree": "^5.5.0",
24
+ "@mui/icons-material": "^7.3.6",
25
+ "@mui/material": "^7.3.6",
26
+ "mobx": "^6.15.0",
27
+ "mobx-react": "^9.2.1",
28
+ "@jbrowse/core": "^4.0.0",
29
+ "@jbrowse/sv-core": "^4.0.0",
30
+ "@jbrowse/plugin-circular-view": "^4.0.0",
31
+ "@jbrowse/plugin-spreadsheet-view": "^4.0.0"
49
32
  },
50
33
  "peerDependencies": {
51
34
  "react": ">=18.0.0",
52
35
  "react-dom": ">=18.0.0"
53
36
  },
54
- "distModule": "esm/index.js",
55
- "srcModule": "src/index.ts",
56
- "module": "esm/index.js",
57
37
  "publishConfig": {
58
38
  "access": "public"
59
39
  },
60
- "gitHead": "85bdd0d58286b7adbfd408146b15847676317635"
61
- }
40
+ "sideEffects": false,
41
+ "scripts": {
42
+ "build": "pnpm run /^build:/",
43
+ "test": "cd ../..; jest --passWithNoTests plugins/sv-inspector",
44
+ "prebuild": "pnpm clean",
45
+ "build:esm": "tsc -p tsconfig.build.esm.json",
46
+ "clean": "rimraf esm *.tsbuildinfo"
47
+ },
48
+ "types": "esm/index.d.ts",
49
+ "exports": {
50
+ ".": {
51
+ "types": "./esm/index.d.ts",
52
+ "import": "./esm/index.js"
53
+ }
54
+ }
55
+ }
@@ -1,2 +0,0 @@
1
- import type PluginManager from '@jbrowse/core/PluginManager';
2
- export default function LaunchSvInspectorViewF(pluginManager: PluginManager): void;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = LaunchSvInspectorViewF;
4
- function LaunchSvInspectorViewF(pluginManager) {
5
- pluginManager.addToExtensionPoint('LaunchView-SvInspectorView', async ({ session, assembly, uri, fileType, }) => {
6
- var _a, _b;
7
- const view = session.addView('SvInspectorView');
8
- const exts = uri.split('.');
9
- let ext = (_a = exts.pop()) === null || _a === void 0 ? void 0 : _a.toUpperCase();
10
- if (ext === 'GZ') {
11
- ext = (_b = exts.pop()) === null || _b === void 0 ? void 0 : _b.toUpperCase();
12
- }
13
- view.spreadsheetView.importWizard.setFileType(fileType || ext || '');
14
- view.spreadsheetView.importWizard.setSelectedAssemblyName(assembly);
15
- view.spreadsheetView.importWizard.setFileSource({
16
- uri,
17
- locationType: 'UriLocation',
18
- });
19
- await view.spreadsheetView.importWizard.import(assembly);
20
- });
21
- }
@@ -1,5 +0,0 @@
1
- import type { SvInspectorViewModel } from '../model';
2
- declare const CircularViewOptions: ({ svInspector, }: {
3
- svInspector: SvInspectorViewModel;
4
- }) => import("react/jsx-runtime").JSX.Element;
5
- export default CircularViewOptions;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const jsx_runtime_1 = require("react/jsx-runtime");
4
- const material_1 = require("@mui/material");
5
- const mobx_react_1 = require("mobx-react");
6
- const mui_1 = require("tss-react/mui");
7
- const useStyles = (0, mui_1.makeStyles)()(theme => ({
8
- circularViewOptions: {
9
- padding: theme.spacing(1),
10
- },
11
- }));
12
- const CircularViewOptions = (0, mobx_react_1.observer)(function ({ svInspector, }) {
13
- const { classes } = useStyles();
14
- return ((0, jsx_runtime_1.jsx)("div", { className: classes.circularViewOptions, style: { height: svInspector.circularViewOptionsBarHeight }, children: (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Checkbox, { checked: svInspector.onlyDisplayRelevantRegionsInCircularView, onChange: e => {
15
- svInspector.setOnlyDisplayRelevantRegionsInCircularView(e.target.checked);
16
- } }), label: "show only regions with data" }) }));
17
- });
18
- exports.default = CircularViewOptions;
@@ -1,5 +0,0 @@
1
- import type { SvInspectorViewModel } from '../model';
2
- declare const SvInspectorView: ({ model, }: {
3
- model: SvInspectorViewModel;
4
- }) => import("react/jsx-runtime").JSX.Element;
5
- export default SvInspectorView;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const jsx_runtime_1 = require("react/jsx-runtime");
7
- const ui_1 = require("@jbrowse/core/ui");
8
- const mobx_react_1 = require("mobx-react");
9
- const mui_1 = require("tss-react/mui");
10
- const CircularViewOptions_1 = __importDefault(require("./CircularViewOptions"));
11
- const useStyles = (0, mui_1.makeStyles)()(theme => ({
12
- resizeHandleVert: {
13
- background: theme.palette.action.selected,
14
- width: 4,
15
- boxSizing: 'border-box',
16
- borderTop: '1px solid #fafafa',
17
- },
18
- resizeHandleHoriz: {
19
- background: theme.palette.action.selected,
20
- height: 4,
21
- boxSizing: 'border-box',
22
- borderTop: '1px solid #fafafa',
23
- },
24
- viewControls: {
25
- margin: 0,
26
- },
27
- viewsContainer: {
28
- display: 'flex',
29
- },
30
- container: {
31
- overflow: 'hidden',
32
- },
33
- }));
34
- const SvInspectorView = (0, mobx_react_1.observer)(function ({ model, }) {
35
- const { classes } = useStyles();
36
- const { SpreadsheetViewReactComponent, CircularViewReactComponent, showCircularView, } = model;
37
- return ((0, jsx_runtime_1.jsxs)("div", { className: classes.container, children: [(0, jsx_runtime_1.jsxs)("div", { className: classes.viewsContainer, children: [(0, jsx_runtime_1.jsx)("div", { style: {
38
- width: model.spreadsheetView.width,
39
- }, className: classes.container, children: (0, jsx_runtime_1.jsx)(SpreadsheetViewReactComponent, { model: model.spreadsheetView }) }), showCircularView ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ui_1.ResizeHandle, { onDrag: distance => {
40
- const ret1 = model.circularView.resizeWidth(-distance);
41
- return model.spreadsheetView.resizeWidth(-ret1);
42
- }, vertical: true, flexbox: true, className: classes.resizeHandleVert }), (0, jsx_runtime_1.jsxs)("div", { style: { width: model.circularView.width }, children: [(0, jsx_runtime_1.jsx)(CircularViewOptions_1.default, { svInspector: model }), (0, jsx_runtime_1.jsx)(CircularViewReactComponent, { model: model.circularView })] })] })) : null] }), (0, jsx_runtime_1.jsx)(ui_1.ResizeHandle, { onDrag: model.resizeHeight, className: classes.resizeHandleHoriz })] }));
43
- });
44
- exports.default = SvInspectorView;
@@ -1,2 +0,0 @@
1
- import type PluginManager from '@jbrowse/core/PluginManager';
2
- export default function SvInspectorViewF(pluginManager: PluginManager): void;
@@ -1,79 +0,0 @@
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 () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.default = SvInspectorViewF;
40
- const react_1 = require("react");
41
- const ViewType_1 = __importDefault(require("@jbrowse/core/pluggableElementTypes/ViewType"));
42
- const util_1 = require("@jbrowse/core/util");
43
- const sv_core_1 = require("@jbrowse/sv-core");
44
- const mobx_state_tree_1 = require("mobx-state-tree");
45
- const model_1 = __importDefault(require("./model"));
46
- function defaultOnChordClick(feature, chordTrack) {
47
- ;
48
- (async () => {
49
- const session = (0, util_1.getSession)(chordTrack);
50
- try {
51
- session.setSelection(feature);
52
- const view = (0, util_1.getContainingView)(chordTrack);
53
- const parentView = (0, mobx_state_tree_1.getParent)(view);
54
- const stableViewId = `${parentView.id}_spawned`;
55
- await (0, sv_core_1.navToMultiLevelBreak)({
56
- assemblyName: view.assemblyNames[0],
57
- session,
58
- stableViewId,
59
- feature,
60
- });
61
- }
62
- catch (e) {
63
- console.error(e);
64
- session.notifyError(`${e}`, e);
65
- }
66
- })();
67
- }
68
- function SvInspectorViewF(pluginManager) {
69
- pluginManager.jexl.addFunction('defaultOnChordClick', defaultOnChordClick);
70
- pluginManager.addViewType(() => {
71
- const stateModel = (0, model_1.default)(pluginManager);
72
- return new ViewType_1.default({
73
- name: 'SvInspectorView',
74
- displayName: 'SV inspector',
75
- stateModel,
76
- ReactComponent: (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./components/SvInspectorView')))),
77
- });
78
- });
79
- }