@jbrowse/plugin-circular-view 3.7.0 → 4.0.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.
- package/esm/CircularView/components/CircularView.d.ts +2 -2
- package/esm/CircularView/components/CircularView.js +21 -15
- package/esm/CircularView/components/Controls.d.ts +2 -2
- package/esm/CircularView/components/Controls.js +3 -3
- package/esm/CircularView/components/ExportSvgDialog.d.ts +1 -1
- package/esm/CircularView/components/ImportForm.d.ts +2 -2
- package/esm/CircularView/components/ImportForm.js +4 -4
- package/esm/CircularView/components/Ruler.d.ts +2 -2
- package/esm/CircularView/components/Ruler.js +7 -7
- package/esm/CircularView/index.js +2 -2
- package/esm/CircularView/model.d.ts +73 -34
- package/esm/CircularView/model.js +146 -54
- package/esm/CircularView/slices.js +9 -1
- package/esm/CircularView/svgcomponents/SVGCircularView.d.ts +1 -1
- package/esm/CircularView/svgcomponents/SVGCircularView.js +3 -4
- package/esm/LaunchCircularView/index.js +6 -12
- package/esm/index.d.ts +1 -2
- package/esm/index.js +4 -7
- package/package.json +26 -32
- package/dist/BaseChordDisplay/components/BaseChordDisplay.d.ts +0 -11
- package/dist/BaseChordDisplay/components/BaseChordDisplay.js +0 -21
- package/dist/BaseChordDisplay/components/DisplayError.d.ts +0 -9
- package/dist/BaseChordDisplay/components/DisplayError.js +0 -9
- package/dist/BaseChordDisplay/components/Loading.d.ts +0 -8
- package/dist/BaseChordDisplay/components/Loading.js +0 -62
- package/dist/BaseChordDisplay/configSchema.d.ts +0 -9
- package/dist/BaseChordDisplay/configSchema.js +0 -16
- package/dist/BaseChordDisplay/index.d.ts +0 -3
- package/dist/BaseChordDisplay/index.js +0 -12
- package/dist/BaseChordDisplay/model.d.ts +0 -109
- package/dist/BaseChordDisplay/model.js +0 -166
- package/dist/BaseChordDisplay/renderReaction.d.ts +0 -27
- package/dist/BaseChordDisplay/renderReaction.js +0 -50
- package/dist/CircularView/components/CircularView.d.ts +0 -5
- package/dist/CircularView/components/CircularView.js +0 -60
- package/dist/CircularView/components/Controls.d.ts +0 -5
- package/dist/CircularView/components/Controls.js +0 -57
- package/dist/CircularView/components/ExportSvgDialog.d.ts +0 -7
- package/dist/CircularView/components/ExportSvgDialog.js +0 -53
- package/dist/CircularView/components/ImportForm.d.ts +0 -5
- package/dist/CircularView/components/ImportForm.js +0 -35
- package/dist/CircularView/components/Ruler.d.ts +0 -7
- package/dist/CircularView/components/Ruler.js +0 -106
- package/dist/CircularView/index.d.ts +0 -2
- package/dist/CircularView/index.js +0 -50
- package/dist/CircularView/model.d.ts +0 -107
- package/dist/CircularView/model.js +0 -376
- package/dist/CircularView/slices.d.ts +0 -45
- package/dist/CircularView/slices.js +0 -57
- package/dist/CircularView/svgcomponents/SVGBackground.d.ts +0 -5
- package/dist/CircularView/svgcomponents/SVGBackground.js +0 -10
- package/dist/CircularView/svgcomponents/SVGCircularView.d.ts +0 -4
- package/dist/CircularView/svgcomponents/SVGCircularView.js +0 -31
- package/dist/CircularView/viewportVisibleRegion.d.ts +0 -6
- package/dist/CircularView/viewportVisibleRegion.js +0 -153
- package/dist/LaunchCircularView/index.d.ts +0 -2
- package/dist/LaunchCircularView/index.js +0 -22
- package/dist/index.d.ts +0 -9
- package/dist/index.js +0 -37
- package/esm/BaseChordDisplay/components/BaseChordDisplay.d.ts +0 -11
- package/esm/BaseChordDisplay/components/BaseChordDisplay.js +0 -16
- package/esm/BaseChordDisplay/components/DisplayError.d.ts +0 -9
- package/esm/BaseChordDisplay/components/DisplayError.js +0 -7
- package/esm/BaseChordDisplay/components/Loading.d.ts +0 -8
- package/esm/BaseChordDisplay/components/Loading.js +0 -60
- package/esm/BaseChordDisplay/configSchema.d.ts +0 -9
- package/esm/BaseChordDisplay/configSchema.js +0 -13
- package/esm/BaseChordDisplay/index.d.ts +0 -3
- package/esm/BaseChordDisplay/index.js +0 -3
- package/esm/BaseChordDisplay/model.d.ts +0 -109
- package/esm/BaseChordDisplay/model.js +0 -163
- package/esm/BaseChordDisplay/renderReaction.d.ts +0 -27
- package/esm/BaseChordDisplay/renderReaction.js +0 -46
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
-
const util_1 = require("@jbrowse/core/util");
|
|
5
|
-
const color_1 = require("@jbrowse/core/util/color");
|
|
6
|
-
const styles_1 = require("@mui/material/styles");
|
|
7
|
-
const mobx_react_1 = require("mobx-react");
|
|
8
|
-
const mui_1 = require("tss-react/mui");
|
|
9
|
-
const useStyles = (0, mui_1.makeStyles)()({
|
|
10
|
-
rulerLabel: {
|
|
11
|
-
fontSize: '0.8rem',
|
|
12
|
-
fontWeight: 500,
|
|
13
|
-
lineHeight: 1.6,
|
|
14
|
-
letterSpacing: '0.0075em',
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
function sliceArcPath(slice, radiusPx, startBase, endBase) {
|
|
18
|
-
if (slice.flipped) {
|
|
19
|
-
;
|
|
20
|
-
[startBase, endBase] = [endBase, startBase];
|
|
21
|
-
}
|
|
22
|
-
const startXY = slice.bpToXY(startBase, radiusPx);
|
|
23
|
-
const endXY = slice.bpToXY(endBase, radiusPx);
|
|
24
|
-
const largeArc = Math.abs(endBase - startBase) / slice.bpPerRadian > Math.PI ? '1' : '0';
|
|
25
|
-
const sweepFlag = '1';
|
|
26
|
-
return [
|
|
27
|
-
'M',
|
|
28
|
-
...startXY,
|
|
29
|
-
'A',
|
|
30
|
-
radiusPx,
|
|
31
|
-
radiusPx,
|
|
32
|
-
'0',
|
|
33
|
-
largeArc,
|
|
34
|
-
sweepFlag,
|
|
35
|
-
...endXY,
|
|
36
|
-
].join(' ');
|
|
37
|
-
}
|
|
38
|
-
const ElisionRulerArc = (0, mobx_react_1.observer)(function ({ model, slice, region, }) {
|
|
39
|
-
const theme = (0, styles_1.useTheme)();
|
|
40
|
-
const { radiusPx: modelRadiusPx } = model;
|
|
41
|
-
const radiusPx = modelRadiusPx + 1;
|
|
42
|
-
const { endRadians, startRadians } = slice;
|
|
43
|
-
const startXY = (0, util_1.polarToCartesian)(radiusPx, startRadians);
|
|
44
|
-
const endXY = (0, util_1.polarToCartesian)(radiusPx, endRadians);
|
|
45
|
-
const widthPx = (endRadians - startRadians) * radiusPx;
|
|
46
|
-
const largeArc = endRadians - startRadians > Math.PI ? '1' : '0';
|
|
47
|
-
const centerRadians = (endRadians + startRadians) / 2;
|
|
48
|
-
const regionCount = `[${region.regions.length.toLocaleString()}]`;
|
|
49
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(RulerLabel, { text: regionCount, view: model, maxWidthPx: widthPx, radians: centerRadians, radiusPx: radiusPx, title: `${regionCount} more regions`, color: theme.palette.text.primary }), (0, jsx_runtime_1.jsx)("path", { d: [
|
|
50
|
-
'M',
|
|
51
|
-
...startXY,
|
|
52
|
-
'A',
|
|
53
|
-
radiusPx,
|
|
54
|
-
radiusPx,
|
|
55
|
-
'0',
|
|
56
|
-
largeArc,
|
|
57
|
-
'1',
|
|
58
|
-
...endXY,
|
|
59
|
-
].join(' '), ...(0, util_1.getStrokeProps)(theme.palette.text.secondary), strokeWidth: 2, strokeDasharray: "2,2", fill: "none" })] }));
|
|
60
|
-
});
|
|
61
|
-
const RulerLabel = (0, mobx_react_1.observer)(function ({ view, text, maxWidthPx, radians, radiusPx, title, color, }) {
|
|
62
|
-
const { classes } = useStyles();
|
|
63
|
-
const textXY = (0, util_1.polarToCartesian)(radiusPx + 5, radians);
|
|
64
|
-
if (!text) {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
else if (text.length * 6.5 < maxWidthPx) {
|
|
68
|
-
return ((0, jsx_runtime_1.jsxs)("text", { x: 0, y: 0, className: classes.rulerLabel, textAnchor: "middle", dominantBaseline: "middle", transform: `translate(${textXY}) rotate(${(0, util_1.radToDeg)(radians) + 90})`, ...(0, util_1.getFillProps)(color), children: [text, (0, jsx_runtime_1.jsx)("title", { children: title || text })] }));
|
|
69
|
-
}
|
|
70
|
-
else if (maxWidthPx > 4) {
|
|
71
|
-
const overallRotation = (0, util_1.radToDeg)(radians + view.offsetRadians - Math.PI / 2);
|
|
72
|
-
if (overallRotation >= 180) {
|
|
73
|
-
return ((0, jsx_runtime_1.jsxs)("text", { x: 0, y: 0, className: classes.rulerLabel, textAnchor: "start", dominantBaseline: "middle", transform: `translate(${textXY}) rotate(${(0, util_1.radToDeg)(radians)})`, fill: color, children: [text, (0, jsx_runtime_1.jsx)("title", { children: title || text })] }));
|
|
74
|
-
}
|
|
75
|
-
return ((0, jsx_runtime_1.jsxs)("text", { x: 0, y: 0, className: classes.rulerLabel, textAnchor: "end", dominantBaseline: "middle", transform: `translate(${textXY}) rotate(${(0, util_1.radToDeg)(radians) + 180})`, fill: color, children: [text, (0, jsx_runtime_1.jsx)("title", { children: title || text })] }));
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
const RegionRulerArc = (0, mobx_react_1.observer)(function ({ model, slice, region, }) {
|
|
82
|
-
const theme = (0, styles_1.useTheme)();
|
|
83
|
-
const { radiusPx } = model;
|
|
84
|
-
const { endRadians, startRadians } = slice;
|
|
85
|
-
const centerRadians = (endRadians + startRadians) / 2;
|
|
86
|
-
const widthPx = (endRadians - startRadians) * radiusPx;
|
|
87
|
-
const session = (0, util_1.getSession)(model);
|
|
88
|
-
const assembly = session.assemblyManager.get(region.assemblyName);
|
|
89
|
-
let color = assembly ? assembly.getRefNameColor(region.refName) : undefined;
|
|
90
|
-
if (color) {
|
|
91
|
-
try {
|
|
92
|
-
color = (0, color_1.makeContrasting)(color, theme.palette.background.paper);
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
color = theme.palette.text.primary;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
color = theme.palette.text.primary;
|
|
100
|
-
}
|
|
101
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(RulerLabel, { text: region.refName, view: model, maxWidthPx: widthPx, radians: centerRadians, radiusPx: radiusPx, color: color }), (0, jsx_runtime_1.jsx)("path", { d: sliceArcPath(slice, radiusPx + 1, region.start, region.end), stroke: color, strokeWidth: 2, fill: "none" })] }));
|
|
102
|
-
});
|
|
103
|
-
const Ruler = (0, mobx_react_1.observer)(function ({ model, slice, }) {
|
|
104
|
-
return slice.region.elided ? ((0, jsx_runtime_1.jsx)(ElisionRulerArc, { model: model, region: slice.region, slice: slice }, (0, util_1.assembleLocString)(slice.region.regions[0]))) : ((0, jsx_runtime_1.jsx)(RegionRulerArc, { region: slice.region, model: model, slice: slice }, (0, util_1.assembleLocString)(slice.region)));
|
|
105
|
-
});
|
|
106
|
-
exports.default = Ruler;
|
|
@@ -1,50 +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 = CircularViewF;
|
|
40
|
-
const react_1 = require("react");
|
|
41
|
-
const ViewType_1 = __importDefault(require("@jbrowse/core/pluggableElementTypes/ViewType"));
|
|
42
|
-
const model_1 = __importDefault(require("./model"));
|
|
43
|
-
function CircularViewF(pluginManager) {
|
|
44
|
-
pluginManager.addViewType(() => new ViewType_1.default({
|
|
45
|
-
ReactComponent: (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./components/CircularView')))),
|
|
46
|
-
stateModel: (0, model_1.default)(pluginManager),
|
|
47
|
-
name: 'CircularView',
|
|
48
|
-
displayName: 'Circular view',
|
|
49
|
-
}));
|
|
50
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
|
-
import type { SliceRegion } from './slices';
|
|
3
|
-
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
4
|
-
import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
|
|
5
|
-
import type { MenuItem } from '@jbrowse/core/ui';
|
|
6
|
-
import type { Region as IRegion } from '@jbrowse/core/util/types';
|
|
7
|
-
import type { Region } from '@jbrowse/core/util/types/mst';
|
|
8
|
-
import type { Instance, SnapshotOrInstance } from 'mobx-state-tree';
|
|
9
|
-
export interface ExportSvgOptions {
|
|
10
|
-
rasterizeLayers?: boolean;
|
|
11
|
-
filename?: string;
|
|
12
|
-
Wrapper?: React.FC<{
|
|
13
|
-
children: React.ReactNode;
|
|
14
|
-
}>;
|
|
15
|
-
themeName?: string;
|
|
16
|
-
}
|
|
17
|
-
declare function stateModelFactory(pluginManager: PluginManager): import("mobx-state-tree").IModelType<{
|
|
18
|
-
id: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
19
|
-
displayName: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<string>>;
|
|
20
|
-
minimized: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
21
|
-
} & {
|
|
22
|
-
type: import("mobx-state-tree").ISimpleType<"CircularView">;
|
|
23
|
-
offsetRadians: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
24
|
-
bpPerPx: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
25
|
-
tracks: import("mobx-state-tree").IArrayType<import("mobx-state-tree").IAnyType>;
|
|
26
|
-
hideVerticalResizeHandle: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
27
|
-
hideTrackSelectorButton: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
28
|
-
lockedFitToWindow: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
29
|
-
disableImportForm: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
30
|
-
height: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<number>, [undefined]>;
|
|
31
|
-
displayedRegions: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<IRegion[], IRegion[], IRegion[]>, [undefined]>;
|
|
32
|
-
scrollX: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
33
|
-
scrollY: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
34
|
-
minimumRadiusPx: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
35
|
-
spacingPx: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
36
|
-
paddingPx: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
37
|
-
lockedPaddingPx: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
38
|
-
minVisibleWidth: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
39
|
-
minimumBlockWidth: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
40
|
-
trackSelectorType: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
41
|
-
}, {
|
|
42
|
-
width: number;
|
|
43
|
-
} & {
|
|
44
|
-
menuItems(): MenuItem[];
|
|
45
|
-
} & {
|
|
46
|
-
setDisplayName(name: string): void;
|
|
47
|
-
setWidth(newWidth: number): void;
|
|
48
|
-
setMinimized(flag: boolean): void;
|
|
49
|
-
} & {
|
|
50
|
-
volatileWidth: number | undefined;
|
|
51
|
-
error: unknown;
|
|
52
|
-
} & {
|
|
53
|
-
readonly width: number;
|
|
54
|
-
readonly visibleSection: {
|
|
55
|
-
rho: [number, number];
|
|
56
|
-
theta: [number, number];
|
|
57
|
-
};
|
|
58
|
-
readonly circumferencePx: number;
|
|
59
|
-
readonly radiusPx: number;
|
|
60
|
-
readonly bpPerRadian: number;
|
|
61
|
-
readonly pxPerRadian: number;
|
|
62
|
-
readonly centerXY: [number, number];
|
|
63
|
-
readonly totalBp: number;
|
|
64
|
-
readonly maximumRadiusPx: number;
|
|
65
|
-
readonly maxBpPerPx: number;
|
|
66
|
-
readonly minBpPerPx: number;
|
|
67
|
-
readonly atMaxBpPerPx: boolean;
|
|
68
|
-
readonly atMinBpPerPx: boolean;
|
|
69
|
-
readonly tooSmallToLock: boolean;
|
|
70
|
-
readonly figureDimensions: [number, number];
|
|
71
|
-
readonly figureWidth: number;
|
|
72
|
-
readonly figureHeight: number;
|
|
73
|
-
readonly elidedRegions: SliceRegion[];
|
|
74
|
-
readonly assemblyNames: string[];
|
|
75
|
-
readonly initialized: boolean;
|
|
76
|
-
} & {
|
|
77
|
-
readonly staticSlices: import("./slices").Slice[];
|
|
78
|
-
} & {
|
|
79
|
-
readonly visibleStaticSlices: import("./slices").Slice[];
|
|
80
|
-
} & {
|
|
81
|
-
setWidth(newWidth: number): number;
|
|
82
|
-
setHeight(newHeight: number): number;
|
|
83
|
-
resizeHeight(distance: number): number;
|
|
84
|
-
resizeWidth(distance: number): number;
|
|
85
|
-
rotateClockwiseButton(): void;
|
|
86
|
-
rotateCounterClockwiseButton(): void;
|
|
87
|
-
rotateClockwise(distance?: number): void;
|
|
88
|
-
rotateCounterClockwise(distance?: number): void;
|
|
89
|
-
zoomInButton(): void;
|
|
90
|
-
zoomOutButton(): void;
|
|
91
|
-
setBpPerPx(newVal: number): void;
|
|
92
|
-
setModelViewWhenAdjust(secondCondition: boolean): void;
|
|
93
|
-
setDisplayedRegions(regions: SnapshotOrInstance<typeof Region>[]): void;
|
|
94
|
-
activateTrackSelector(): import("@jbrowse/core/util").Widget;
|
|
95
|
-
toggleTrack(trackId: string): boolean;
|
|
96
|
-
setError(error: unknown): void;
|
|
97
|
-
showTrack(trackId: string, initialSnapshot?: {}): void;
|
|
98
|
-
addTrackConf(configuration: AnyConfigurationModel, initialSnapshot?: {}): void;
|
|
99
|
-
hideTrack(trackId: string): number;
|
|
100
|
-
toggleFitToWindowLock(): boolean;
|
|
101
|
-
exportSvg(opts?: ExportSvgOptions): Promise<void>;
|
|
102
|
-
} & {
|
|
103
|
-
menuItems(): MenuItem[];
|
|
104
|
-
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
|
|
105
|
-
export type CircularViewStateModel = ReturnType<typeof stateModelFactory>;
|
|
106
|
-
export type CircularViewModel = Instance<CircularViewStateModel>;
|
|
107
|
-
export default stateModelFactory;
|
|
@@ -1,376 +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
|
-
const react_1 = require("react");
|
|
40
|
-
const configuration_1 = require("@jbrowse/core/configuration");
|
|
41
|
-
const models_1 = require("@jbrowse/core/pluggableElementTypes/models");
|
|
42
|
-
const Icons_1 = require("@jbrowse/core/ui/Icons");
|
|
43
|
-
const util_1 = require("@jbrowse/core/util");
|
|
44
|
-
const FolderOpen_1 = __importDefault(require("@mui/icons-material/FolderOpen"));
|
|
45
|
-
const PhotoCamera_1 = __importDefault(require("@mui/icons-material/PhotoCamera"));
|
|
46
|
-
const file_saver_1 = require("file-saver");
|
|
47
|
-
const mobx_1 = require("mobx");
|
|
48
|
-
const mobx_state_tree_1 = require("mobx-state-tree");
|
|
49
|
-
const slices_1 = require("./slices");
|
|
50
|
-
const viewportVisibleRegion_1 = require("./viewportVisibleRegion");
|
|
51
|
-
const ExportSvgDialog = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./components/ExportSvgDialog'))));
|
|
52
|
-
function stateModelFactory(pluginManager) {
|
|
53
|
-
const minHeight = 40;
|
|
54
|
-
const minWidth = 100;
|
|
55
|
-
const defaultHeight = 400;
|
|
56
|
-
return mobx_state_tree_1.types
|
|
57
|
-
.compose('CircularView', models_1.BaseViewModel, mobx_state_tree_1.types.model({
|
|
58
|
-
type: mobx_state_tree_1.types.literal('CircularView'),
|
|
59
|
-
offsetRadians: -Math.PI / 2,
|
|
60
|
-
bpPerPx: 200,
|
|
61
|
-
tracks: mobx_state_tree_1.types.array(pluginManager.pluggableMstType('track', 'stateModel')),
|
|
62
|
-
hideVerticalResizeHandle: false,
|
|
63
|
-
hideTrackSelectorButton: false,
|
|
64
|
-
lockedFitToWindow: true,
|
|
65
|
-
disableImportForm: false,
|
|
66
|
-
height: mobx_state_tree_1.types.optional(mobx_state_tree_1.types.number, defaultHeight),
|
|
67
|
-
displayedRegions: mobx_state_tree_1.types.optional(mobx_state_tree_1.types.frozen(), []),
|
|
68
|
-
scrollX: 0,
|
|
69
|
-
scrollY: 0,
|
|
70
|
-
minimumRadiusPx: 25,
|
|
71
|
-
spacingPx: 10,
|
|
72
|
-
paddingPx: 80,
|
|
73
|
-
lockedPaddingPx: 100,
|
|
74
|
-
minVisibleWidth: 6,
|
|
75
|
-
minimumBlockWidth: 20,
|
|
76
|
-
trackSelectorType: 'hierarchical',
|
|
77
|
-
}))
|
|
78
|
-
.volatile(() => ({
|
|
79
|
-
volatileWidth: undefined,
|
|
80
|
-
error: undefined,
|
|
81
|
-
}))
|
|
82
|
-
.views(self => ({
|
|
83
|
-
get width() {
|
|
84
|
-
if (self.volatileWidth === undefined) {
|
|
85
|
-
throw new Error('wait for view to be initialized first before accessing width');
|
|
86
|
-
}
|
|
87
|
-
return self.volatileWidth;
|
|
88
|
-
},
|
|
89
|
-
get visibleSection() {
|
|
90
|
-
const { scrollX, scrollY, width, height } = self;
|
|
91
|
-
return (0, viewportVisibleRegion_1.viewportVisibleSection)([scrollX, scrollX + width, scrollY, scrollY + height], this.centerXY, this.radiusPx);
|
|
92
|
-
},
|
|
93
|
-
get circumferencePx() {
|
|
94
|
-
let elidedBp = 0;
|
|
95
|
-
for (const r of this.elidedRegions) {
|
|
96
|
-
elidedBp += r.widthBp;
|
|
97
|
-
}
|
|
98
|
-
return (elidedBp / self.bpPerPx + self.spacingPx * this.elidedRegions.length);
|
|
99
|
-
},
|
|
100
|
-
get radiusPx() {
|
|
101
|
-
return this.circumferencePx / (2 * Math.PI);
|
|
102
|
-
},
|
|
103
|
-
get bpPerRadian() {
|
|
104
|
-
return self.bpPerPx * this.radiusPx;
|
|
105
|
-
},
|
|
106
|
-
get pxPerRadian() {
|
|
107
|
-
return this.radiusPx;
|
|
108
|
-
},
|
|
109
|
-
get centerXY() {
|
|
110
|
-
return [this.radiusPx + self.paddingPx, this.radiusPx + self.paddingPx];
|
|
111
|
-
},
|
|
112
|
-
get totalBp() {
|
|
113
|
-
let total = 0;
|
|
114
|
-
for (const region of self.displayedRegions) {
|
|
115
|
-
total += region.end - region.start;
|
|
116
|
-
}
|
|
117
|
-
return total;
|
|
118
|
-
},
|
|
119
|
-
get maximumRadiusPx() {
|
|
120
|
-
return self.lockedFitToWindow
|
|
121
|
-
? Math.min(self.width, self.height) / 2 - self.lockedPaddingPx
|
|
122
|
-
: 1000000;
|
|
123
|
-
},
|
|
124
|
-
get maxBpPerPx() {
|
|
125
|
-
const minCircumferencePx = 2 * Math.PI * self.minimumRadiusPx;
|
|
126
|
-
return this.totalBp / minCircumferencePx;
|
|
127
|
-
},
|
|
128
|
-
get minBpPerPx() {
|
|
129
|
-
const maxCircumferencePx = 2 * Math.PI * this.maximumRadiusPx;
|
|
130
|
-
return (0, util_1.clamp)(this.totalBp / maxCircumferencePx, 0.0000000001, this.maxBpPerPx);
|
|
131
|
-
},
|
|
132
|
-
get atMaxBpPerPx() {
|
|
133
|
-
return self.bpPerPx >= this.maxBpPerPx;
|
|
134
|
-
},
|
|
135
|
-
get atMinBpPerPx() {
|
|
136
|
-
return self.bpPerPx <= this.minBpPerPx;
|
|
137
|
-
},
|
|
138
|
-
get tooSmallToLock() {
|
|
139
|
-
return this.minBpPerPx <= 0.0000000001;
|
|
140
|
-
},
|
|
141
|
-
get figureDimensions() {
|
|
142
|
-
return [
|
|
143
|
-
this.radiusPx * 2 + 2 * self.paddingPx,
|
|
144
|
-
this.radiusPx * 2 + 2 * self.paddingPx,
|
|
145
|
-
];
|
|
146
|
-
},
|
|
147
|
-
get figureWidth() {
|
|
148
|
-
return this.figureDimensions[0];
|
|
149
|
-
},
|
|
150
|
-
get figureHeight() {
|
|
151
|
-
return this.figureDimensions[1];
|
|
152
|
-
},
|
|
153
|
-
get elidedRegions() {
|
|
154
|
-
const visible = [];
|
|
155
|
-
for (const region of self.displayedRegions) {
|
|
156
|
-
const widthBp = region.end - region.start;
|
|
157
|
-
const widthPx = widthBp / self.bpPerPx;
|
|
158
|
-
if (widthPx < self.minVisibleWidth) {
|
|
159
|
-
const lastVisible = visible.at(-1);
|
|
160
|
-
if (lastVisible === null || lastVisible === void 0 ? void 0 : lastVisible.elided) {
|
|
161
|
-
lastVisible.regions.push({ ...region });
|
|
162
|
-
lastVisible.widthBp += widthBp;
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
visible.push({
|
|
166
|
-
elided: true,
|
|
167
|
-
widthBp,
|
|
168
|
-
regions: [{ ...region }],
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
visible.push({ ...region, widthBp, elided: false });
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
for (let i = 0; i < visible.length; i += 1) {
|
|
177
|
-
const v = visible[i];
|
|
178
|
-
if (v.elided && v.regions.length === 1) {
|
|
179
|
-
visible[i] = { ...v, ...v.regions[0], elided: false };
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return visible;
|
|
183
|
-
},
|
|
184
|
-
get assemblyNames() {
|
|
185
|
-
const assemblyNames = [];
|
|
186
|
-
for (const displayedRegion of self.displayedRegions) {
|
|
187
|
-
if (!assemblyNames.includes(displayedRegion.assemblyName)) {
|
|
188
|
-
assemblyNames.push(displayedRegion.assemblyName);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
return assemblyNames;
|
|
192
|
-
},
|
|
193
|
-
get initialized() {
|
|
194
|
-
const { assemblyManager } = (0, util_1.getSession)(self);
|
|
195
|
-
return (self.volatileWidth !== undefined &&
|
|
196
|
-
this.assemblyNames.every(a => { var _a; return (_a = assemblyManager.get(a)) === null || _a === void 0 ? void 0 : _a.initialized; }));
|
|
197
|
-
},
|
|
198
|
-
}))
|
|
199
|
-
.views(self => ({
|
|
200
|
-
get staticSlices() {
|
|
201
|
-
return (0, slices_1.calculateStaticSlices)(self);
|
|
202
|
-
},
|
|
203
|
-
}))
|
|
204
|
-
.views(self => ({
|
|
205
|
-
get visibleStaticSlices() {
|
|
206
|
-
return self.staticSlices.filter(s => (0, slices_1.sliceIsVisible)(self, s));
|
|
207
|
-
},
|
|
208
|
-
}))
|
|
209
|
-
.actions(self => ({
|
|
210
|
-
setWidth(newWidth) {
|
|
211
|
-
self.volatileWidth = Math.max(newWidth, minWidth);
|
|
212
|
-
return self.volatileWidth;
|
|
213
|
-
},
|
|
214
|
-
setHeight(newHeight) {
|
|
215
|
-
self.height = Math.max(newHeight, minHeight);
|
|
216
|
-
return self.height;
|
|
217
|
-
},
|
|
218
|
-
resizeHeight(distance) {
|
|
219
|
-
const oldHeight = self.height;
|
|
220
|
-
const newHeight = this.setHeight(self.height + distance);
|
|
221
|
-
this.setModelViewWhenAdjust(!self.tooSmallToLock);
|
|
222
|
-
return newHeight - oldHeight;
|
|
223
|
-
},
|
|
224
|
-
resizeWidth(distance) {
|
|
225
|
-
const oldWidth = self.width;
|
|
226
|
-
const newWidth = this.setWidth(self.width + distance);
|
|
227
|
-
this.setModelViewWhenAdjust(!self.tooSmallToLock);
|
|
228
|
-
return newWidth - oldWidth;
|
|
229
|
-
},
|
|
230
|
-
rotateClockwiseButton() {
|
|
231
|
-
this.rotateClockwise(Math.PI / 6);
|
|
232
|
-
},
|
|
233
|
-
rotateCounterClockwiseButton() {
|
|
234
|
-
this.rotateCounterClockwise(Math.PI / 6);
|
|
235
|
-
},
|
|
236
|
-
rotateClockwise(distance = 0.17) {
|
|
237
|
-
self.offsetRadians += distance;
|
|
238
|
-
},
|
|
239
|
-
rotateCounterClockwise(distance = 0.17) {
|
|
240
|
-
self.offsetRadians -= distance;
|
|
241
|
-
},
|
|
242
|
-
zoomInButton() {
|
|
243
|
-
this.setBpPerPx(self.bpPerPx / 1.4);
|
|
244
|
-
},
|
|
245
|
-
zoomOutButton() {
|
|
246
|
-
this.setBpPerPx(self.bpPerPx * 1.4);
|
|
247
|
-
},
|
|
248
|
-
setBpPerPx(newVal) {
|
|
249
|
-
self.bpPerPx = (0, util_1.clamp)(newVal, self.minBpPerPx, self.maxBpPerPx);
|
|
250
|
-
},
|
|
251
|
-
setModelViewWhenAdjust(secondCondition) {
|
|
252
|
-
if (self.lockedFitToWindow && secondCondition) {
|
|
253
|
-
this.setBpPerPx(self.minBpPerPx);
|
|
254
|
-
}
|
|
255
|
-
},
|
|
256
|
-
setDisplayedRegions(regions) {
|
|
257
|
-
const previouslyEmpty = self.displayedRegions.length === 0;
|
|
258
|
-
self.displayedRegions = (0, mobx_state_tree_1.cast)(regions);
|
|
259
|
-
if (previouslyEmpty) {
|
|
260
|
-
this.setBpPerPx(self.minBpPerPx);
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
this.setBpPerPx(self.bpPerPx);
|
|
264
|
-
}
|
|
265
|
-
},
|
|
266
|
-
activateTrackSelector() {
|
|
267
|
-
if (self.trackSelectorType === 'hierarchical') {
|
|
268
|
-
const session = (0, util_1.getSession)(self);
|
|
269
|
-
if ((0, util_1.isSessionModelWithWidgets)(session)) {
|
|
270
|
-
const selector = session.addWidget('HierarchicalTrackSelectorWidget', 'hierarchicalTrackSelector', { view: self });
|
|
271
|
-
session.showWidget(selector);
|
|
272
|
-
return selector;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
throw new Error(`invalid track selector type ${self.trackSelectorType}`);
|
|
276
|
-
},
|
|
277
|
-
toggleTrack(trackId) {
|
|
278
|
-
const hiddenCount = this.hideTrack(trackId);
|
|
279
|
-
if (!hiddenCount) {
|
|
280
|
-
this.showTrack(trackId);
|
|
281
|
-
return true;
|
|
282
|
-
}
|
|
283
|
-
return false;
|
|
284
|
-
},
|
|
285
|
-
setError(error) {
|
|
286
|
-
self.error = error;
|
|
287
|
-
},
|
|
288
|
-
showTrack(trackId, initialSnapshot = {}) {
|
|
289
|
-
const schema = pluginManager.pluggableConfigSchemaType('track');
|
|
290
|
-
const conf = (0, mobx_state_tree_1.resolveIdentifier)(schema, (0, mobx_state_tree_1.getRoot)(self), trackId);
|
|
291
|
-
const trackType = pluginManager.getTrackType(conf.type);
|
|
292
|
-
if (!trackType) {
|
|
293
|
-
throw new Error(`unknown track type ${conf.type}`);
|
|
294
|
-
}
|
|
295
|
-
const viewType = pluginManager.getViewType(self.type);
|
|
296
|
-
const supportedDisplays = new Set(viewType.displayTypes.map(d => d.name));
|
|
297
|
-
const displayConf = conf.displays.find((d) => supportedDisplays.has(d.type));
|
|
298
|
-
const track = trackType.stateModel.create({
|
|
299
|
-
...initialSnapshot,
|
|
300
|
-
type: conf.type,
|
|
301
|
-
configuration: conf,
|
|
302
|
-
displays: [{ type: displayConf.type, configuration: displayConf }],
|
|
303
|
-
});
|
|
304
|
-
self.tracks.push(track);
|
|
305
|
-
},
|
|
306
|
-
addTrackConf(configuration, initialSnapshot = {}) {
|
|
307
|
-
const { type } = configuration;
|
|
308
|
-
const name = (0, configuration_1.readConfObject)(configuration, 'name');
|
|
309
|
-
const trackType = pluginManager.getTrackType(type);
|
|
310
|
-
if (!trackType) {
|
|
311
|
-
throw new Error(`unknown track type ${type}`);
|
|
312
|
-
}
|
|
313
|
-
const viewType = pluginManager.getViewType(self.type);
|
|
314
|
-
const supportedDisplays = new Set(viewType.displayTypes.map(d => d.name));
|
|
315
|
-
const displayConf = configuration.displays.find((d) => supportedDisplays.has(d.type));
|
|
316
|
-
self.tracks.push(trackType.stateModel.create({
|
|
317
|
-
...initialSnapshot,
|
|
318
|
-
name,
|
|
319
|
-
type,
|
|
320
|
-
configuration,
|
|
321
|
-
displays: [{ type: displayConf.type, configuration: displayConf }],
|
|
322
|
-
}));
|
|
323
|
-
},
|
|
324
|
-
hideTrack(trackId) {
|
|
325
|
-
const schema = pluginManager.pluggableConfigSchemaType('track');
|
|
326
|
-
const conf = (0, mobx_state_tree_1.resolveIdentifier)(schema, (0, mobx_state_tree_1.getRoot)(self), trackId);
|
|
327
|
-
const tracks = self.tracks.filter(t => t.configuration === conf);
|
|
328
|
-
(0, mobx_1.transaction)(() => {
|
|
329
|
-
for (const track of tracks) {
|
|
330
|
-
self.tracks.remove(track);
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
return tracks.length;
|
|
334
|
-
},
|
|
335
|
-
toggleFitToWindowLock() {
|
|
336
|
-
self.lockedFitToWindow = !self.lockedFitToWindow;
|
|
337
|
-
this.setModelViewWhenAdjust(self.atMinBpPerPx);
|
|
338
|
-
return self.lockedFitToWindow;
|
|
339
|
-
},
|
|
340
|
-
async exportSvg(opts = {}) {
|
|
341
|
-
const { renderToSvg } = await Promise.resolve().then(() => __importStar(require('./svgcomponents/SVGCircularView')));
|
|
342
|
-
const html = await renderToSvg(self, opts);
|
|
343
|
-
const blob = new Blob([html], { type: 'image/svg+xml' });
|
|
344
|
-
(0, file_saver_1.saveAs)(blob, opts.filename || 'image.svg');
|
|
345
|
-
},
|
|
346
|
-
}))
|
|
347
|
-
.views(self => ({
|
|
348
|
-
menuItems() {
|
|
349
|
-
return [
|
|
350
|
-
{
|
|
351
|
-
label: 'Return to import form',
|
|
352
|
-
onClick: () => {
|
|
353
|
-
self.setDisplayedRegions([]);
|
|
354
|
-
},
|
|
355
|
-
icon: FolderOpen_1.default,
|
|
356
|
-
},
|
|
357
|
-
{
|
|
358
|
-
label: 'Export SVG',
|
|
359
|
-
icon: PhotoCamera_1.default,
|
|
360
|
-
onClick: () => {
|
|
361
|
-
(0, util_1.getSession)(self).queueDialog(handleClose => [
|
|
362
|
-
ExportSvgDialog,
|
|
363
|
-
{ model: self, handleClose },
|
|
364
|
-
]);
|
|
365
|
-
},
|
|
366
|
-
},
|
|
367
|
-
{
|
|
368
|
-
label: 'Open track selector',
|
|
369
|
-
onClick: self.activateTrackSelector,
|
|
370
|
-
icon: Icons_1.TrackSelector,
|
|
371
|
-
},
|
|
372
|
-
];
|
|
373
|
-
},
|
|
374
|
-
}));
|
|
375
|
-
}
|
|
376
|
-
exports.default = stateModelFactory;
|