@jbrowse/plugin-hic 4.0.3 → 4.1.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/LinearHicDisplay/afterAttach.js +16 -1
- package/esm/LinearHicDisplay/components/BaseDisplayComponent.d.ts +15 -2
- package/esm/LinearHicDisplay/components/BaseDisplayComponent.js +39 -1
- package/esm/LinearHicDisplay/components/ReactComponent.js +11 -6
- package/esm/LinearHicDisplay/model.d.ts +8 -0
- package/package.json +5 -4
|
@@ -24,6 +24,9 @@ export function doAfterAttach(self) {
|
|
|
24
24
|
}
|
|
25
25
|
})();
|
|
26
26
|
const performRender = async () => {
|
|
27
|
+
if (self.isMinimized) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
27
30
|
const view = getContainingView(self);
|
|
28
31
|
const { bpPerPx, dynamicBlocks } = view;
|
|
29
32
|
const regions = dynamicBlocks.contentBlocks;
|
|
@@ -43,6 +46,7 @@ export function doAfterAttach(self) {
|
|
|
43
46
|
const stopToken = createStopToken();
|
|
44
47
|
self.setRenderingStopToken(stopToken);
|
|
45
48
|
self.setLoading(true);
|
|
49
|
+
self.setCanvasDrawn(false);
|
|
46
50
|
const result = (await rpcManager.call(rpcSessionId, 'CoreRender', {
|
|
47
51
|
sessionId: rpcSessionId,
|
|
48
52
|
rendererType: 'HicRenderer',
|
|
@@ -61,11 +65,13 @@ export function doAfterAttach(self) {
|
|
|
61
65
|
if (result.imageData) {
|
|
62
66
|
self.setRenderingImageData(result.imageData);
|
|
63
67
|
self.setLastDrawnOffsetPx(view.offsetPx);
|
|
68
|
+
self.setLastDrawnBpPerPx(view.bpPerPx);
|
|
64
69
|
}
|
|
65
70
|
self.setFlatbushData(result.flatbush, result.items ?? [], result.maxScore ?? 0, result.yScalar ?? 1);
|
|
66
71
|
}
|
|
67
72
|
catch (error) {
|
|
68
73
|
if (!isAbortException(error)) {
|
|
74
|
+
console.error(error);
|
|
69
75
|
if (isAlive(self)) {
|
|
70
76
|
self.setError(error);
|
|
71
77
|
}
|
|
@@ -79,6 +85,9 @@ export function doAfterAttach(self) {
|
|
|
79
85
|
}
|
|
80
86
|
};
|
|
81
87
|
addDisposer(self, autorun(() => {
|
|
88
|
+
if (self.isMinimized) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
82
91
|
const view = getContainingView(self);
|
|
83
92
|
if (!view.initialized) {
|
|
84
93
|
return;
|
|
@@ -100,11 +109,17 @@ export function doAfterAttach(self) {
|
|
|
100
109
|
name: 'LinearHicDisplayRender',
|
|
101
110
|
}));
|
|
102
111
|
addDisposer(self, autorun(() => {
|
|
112
|
+
if (self.isMinimized) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
103
115
|
const view = getContainingView(self);
|
|
104
116
|
if (!view.initialized) {
|
|
105
117
|
return;
|
|
106
118
|
}
|
|
107
|
-
drawCanvasImageData(self.ref, self.renderingImageData);
|
|
119
|
+
const success = drawCanvasImageData(self.ref, self.renderingImageData);
|
|
120
|
+
if (isAlive(self)) {
|
|
121
|
+
self.setCanvasDrawn(success);
|
|
122
|
+
}
|
|
108
123
|
}, {
|
|
109
124
|
name: 'LinearHicDisplayCanvas',
|
|
110
125
|
}));
|
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface HicDisplayModel {
|
|
3
|
+
error?: unknown;
|
|
4
|
+
regionTooLarge?: boolean;
|
|
5
|
+
reload: () => void;
|
|
6
|
+
regionCannotBeRendered: () => React.ReactElement | null;
|
|
7
|
+
drawn: boolean;
|
|
8
|
+
loading: boolean;
|
|
9
|
+
statusMessage?: string;
|
|
10
|
+
}
|
|
11
|
+
declare const HicBaseDisplayComponent: ({ model, children, }: {
|
|
12
|
+
model: HicDisplayModel;
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
15
|
+
export default HicBaseDisplayComponent;
|
|
@@ -1 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ErrorMessage, LoadingEllipses } from '@jbrowse/core/ui';
|
|
4
|
+
import { makeStyles } from '@jbrowse/core/util/tss-react';
|
|
5
|
+
import { observer } from 'mobx-react';
|
|
6
|
+
const useStyles = makeStyles()({
|
|
7
|
+
loading: {
|
|
8
|
+
position: 'absolute',
|
|
9
|
+
top: 0,
|
|
10
|
+
left: 0,
|
|
11
|
+
right: 0,
|
|
12
|
+
bottom: 0,
|
|
13
|
+
backgroundColor: 'rgba(255, 255, 255, 0.15)',
|
|
14
|
+
backgroundImage: `repeating-linear-gradient(45deg, transparent, transparent 8px, rgba(0, 0, 0, 0.05) 8px, rgba(0, 0, 0, 0.05) 16px)`,
|
|
15
|
+
pointerEvents: 'none',
|
|
16
|
+
display: 'flex',
|
|
17
|
+
justifyContent: 'center',
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
zIndex: 1,
|
|
20
|
+
},
|
|
21
|
+
loadingMessage: {
|
|
22
|
+
zIndex: 2,
|
|
23
|
+
pointerEvents: 'none',
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
const HicBaseDisplayComponent = observer(function HicBaseDisplayComponent({ model, children, }) {
|
|
27
|
+
const { error, regionTooLarge } = model;
|
|
28
|
+
return error ? (_jsx(ErrorMessage, { error: error })) : regionTooLarge ? (model.regionCannotBeRendered()) : (_jsx(DataDisplay, { model: model, children: children }));
|
|
29
|
+
});
|
|
30
|
+
const DataDisplay = observer(function DataDisplay({ model, children, }) {
|
|
31
|
+
const { drawn, loading } = model;
|
|
32
|
+
return (_jsxs("div", { "data-testid": `drawn-${drawn}`, children: [children, loading ? _jsx(LoadingBar, { model: model }) : null] }));
|
|
33
|
+
});
|
|
34
|
+
const LoadingBar = observer(function LoadingBar({ model, }) {
|
|
35
|
+
const { classes } = useStyles();
|
|
36
|
+
const { statusMessage } = model;
|
|
37
|
+
return (_jsx("div", { className: classes.loading, children: _jsx("div", { className: classes.loadingMessage, children: _jsx(LoadingEllipses, { message: statusMessage }) }) }));
|
|
38
|
+
});
|
|
39
|
+
export default HicBaseDisplayComponent;
|
|
@@ -30,11 +30,14 @@ function screenToUnrotated(screenX, screenY, yScalar) {
|
|
|
30
30
|
const HicCanvas = observer(function HicCanvas({ model, }) {
|
|
31
31
|
const view = getContainingView(model);
|
|
32
32
|
const width = Math.round(view.dynamicBlocks.totalWidthPx);
|
|
33
|
-
const { height,
|
|
33
|
+
const { height, fullyDrawn, flatbush, flatbushItems, yScalar, showLegend, maxScore, colorScheme, useLogScale, lastDrawnOffsetPx, } = model;
|
|
34
34
|
const containerRef = useRef(null);
|
|
35
35
|
const [hoveredItem, setHoveredItem] = useState();
|
|
36
36
|
const [mousePosition, setMousePosition] = useState();
|
|
37
37
|
const [localMousePos, setLocalMousePos] = useState();
|
|
38
|
+
const canvasOffset = view.offsetPx >= 0
|
|
39
|
+
? (lastDrawnOffsetPx ?? 0) - view.offsetPx
|
|
40
|
+
: Math.max(0, -view.offsetPx);
|
|
38
41
|
const flatbushIndex = useMemo(() => (flatbush ? Flatbush.from(flatbush) : null), [flatbush]);
|
|
39
42
|
const cb = useCallback((ref) => {
|
|
40
43
|
model.setRef(ref);
|
|
@@ -46,7 +49,8 @@ const HicCanvas = observer(function HicCanvas({ model, }) {
|
|
|
46
49
|
return;
|
|
47
50
|
}
|
|
48
51
|
const rect = containerRef.current.getBoundingClientRect();
|
|
49
|
-
const
|
|
52
|
+
const mouseCanvasOffset = canvasOffset;
|
|
53
|
+
const screenX = event.clientX - rect.left - mouseCanvasOffset;
|
|
50
54
|
const screenY = event.clientY - rect.top;
|
|
51
55
|
setMousePosition({ x: event.clientX, y: event.clientY });
|
|
52
56
|
setLocalMousePos({ x: screenX, y: screenY });
|
|
@@ -59,7 +63,7 @@ const HicCanvas = observer(function HicCanvas({ model, }) {
|
|
|
59
63
|
else {
|
|
60
64
|
setHoveredItem(undefined);
|
|
61
65
|
}
|
|
62
|
-
}, [flatbushIndex, flatbushItems, yScalar]);
|
|
66
|
+
}, [flatbushIndex, flatbushItems, yScalar, canvasOffset]);
|
|
63
67
|
const onMouseLeave = useCallback(() => {
|
|
64
68
|
setHoveredItem(undefined);
|
|
65
69
|
setMousePosition(undefined);
|
|
@@ -70,12 +74,13 @@ const HicCanvas = observer(function HicCanvas({ model, }) {
|
|
|
70
74
|
position: 'relative',
|
|
71
75
|
width,
|
|
72
76
|
height,
|
|
73
|
-
|
|
77
|
+
overflow: 'hidden',
|
|
78
|
+
}, onMouseMove: onMouseMove, onMouseLeave: onMouseLeave, children: [_jsx("canvas", { "data-testid": `hic_canvas${fullyDrawn ? '_done' : ''}`, ref: cb, style: {
|
|
74
79
|
width,
|
|
75
80
|
height,
|
|
76
81
|
position: 'absolute',
|
|
77
|
-
left:
|
|
78
|
-
}, width: width * 2, height: height * 2 }), hoveredItem && localMousePos ? (_jsx(Crosshairs, { x: localMousePos.x, y: localMousePos.y, yScalar: yScalar, left:
|
|
82
|
+
left: canvasOffset,
|
|
83
|
+
}, width: width * 2, height: height * 2 }), hoveredItem && localMousePos ? (_jsx(Crosshairs, { x: localMousePos.x, y: localMousePos.y, yScalar: yScalar, left: canvasOffset, width: width, height: height })) : null, hoveredItem && mousePosition ? (_jsx(HicTooltip, { item: hoveredItem, x: mousePosition.x, y: mousePosition.y })) : null, showLegend && maxScore > 0 ? (_jsx(HicColorLegend, { maxScore: maxScore, colorScheme: colorScheme, useLogScale: useLogScale })) : null] }));
|
|
79
84
|
});
|
|
80
85
|
const LinearHicReactComponent = observer(function LinearHicReactComponent({ model, }) {
|
|
81
86
|
return (_jsx(BaseDisplayComponent, { model: model, children: _jsx(HicCanvas, { model: model }) }));
|
|
@@ -68,6 +68,7 @@ export default function stateModelFactory(configSchema: AnyConfigurationSchemaTy
|
|
|
68
68
|
}> | null;
|
|
69
69
|
readonly adapterConfig: any;
|
|
70
70
|
readonly parentTrack: import("@jbrowse/core/util").AbstractTrackModel;
|
|
71
|
+
readonly isMinimized: boolean;
|
|
71
72
|
readonly parentDisplay: any;
|
|
72
73
|
readonly effectiveRpcDriverName: any;
|
|
73
74
|
} & {
|
|
@@ -124,6 +125,7 @@ export default function stateModelFactory(configSchema: AnyConfigurationSchemaTy
|
|
|
124
125
|
}> | null;
|
|
125
126
|
readonly adapterConfig: any;
|
|
126
127
|
readonly parentTrack: import("@jbrowse/core/util").AbstractTrackModel;
|
|
128
|
+
readonly isMinimized: boolean;
|
|
127
129
|
readonly parentDisplay: any;
|
|
128
130
|
readonly effectiveRpcDriverName: any;
|
|
129
131
|
} & import("@jbrowse/mobx-state-tree").IStateTreeNode<import("@jbrowse/mobx-state-tree").IModelType<{
|
|
@@ -177,6 +179,7 @@ export default function stateModelFactory(configSchema: AnyConfigurationSchemaTy
|
|
|
177
179
|
}> | null;
|
|
178
180
|
readonly adapterConfig: any;
|
|
179
181
|
readonly parentTrack: import("@jbrowse/core/util").AbstractTrackModel;
|
|
182
|
+
readonly isMinimized: boolean;
|
|
180
183
|
readonly parentDisplay: any;
|
|
181
184
|
readonly effectiveRpcDriverName: any;
|
|
182
185
|
}, import("@jbrowse/mobx-state-tree")._NotCustomized, import("@jbrowse/mobx-state-tree")._NotCustomized>>;
|
|
@@ -228,19 +231,24 @@ export default function stateModelFactory(configSchema: AnyConfigurationSchemaTy
|
|
|
228
231
|
} & {
|
|
229
232
|
loading: boolean;
|
|
230
233
|
lastDrawnOffsetPx: number | undefined;
|
|
234
|
+
lastDrawnBpPerPx: number | undefined;
|
|
231
235
|
ref: HTMLCanvasElement | null;
|
|
232
236
|
renderingImageData: ImageBitmap | undefined;
|
|
233
237
|
renderingStopToken: import("@jbrowse/core/util").StopToken | undefined;
|
|
234
238
|
statusMessage: string | undefined;
|
|
239
|
+
canvasDrawn: boolean;
|
|
235
240
|
} & {
|
|
236
241
|
readonly drawn: boolean;
|
|
242
|
+
readonly fullyDrawn: boolean;
|
|
237
243
|
} & {
|
|
238
244
|
setLastDrawnOffsetPx(n: number): void;
|
|
245
|
+
setLastDrawnBpPerPx(n: number): void;
|
|
239
246
|
setLoading(f: boolean): void;
|
|
240
247
|
setRef(ref: HTMLCanvasElement | null): void;
|
|
241
248
|
setRenderingImageData(imageData: ImageBitmap | undefined): void;
|
|
242
249
|
setRenderingStopToken(token?: import("@jbrowse/core/util").StopToken): void;
|
|
243
250
|
setStatusMessage(msg?: string): void;
|
|
251
|
+
setCanvasDrawn(drawn: boolean): void;
|
|
244
252
|
} & {
|
|
245
253
|
beforeDestroy(): void;
|
|
246
254
|
} & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-hic",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.1",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "JBrowse 2 hic adapters, tracks, etc.",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"jbrowse",
|
|
@@ -21,14 +22,14 @@
|
|
|
21
22
|
],
|
|
22
23
|
"dependencies": {
|
|
23
24
|
"@jbrowse/mobx-state-tree": "^5.5.0",
|
|
25
|
+
"@mui/x-charts-vendor": "^8.26.0",
|
|
24
26
|
"generic-filehandle2": "^2.0.18",
|
|
25
|
-
"@mui/x-charts-vendor": "^8.23.0",
|
|
26
27
|
"hic-straw": "^2.1.4",
|
|
27
28
|
"mobx": "^6.15.0",
|
|
28
29
|
"mobx-react": "^9.2.1",
|
|
29
30
|
"rxjs": "^7.8.2",
|
|
30
|
-
"@jbrowse/plugin-linear-genome-view": "^4.
|
|
31
|
-
"@jbrowse/core": "^4.
|
|
31
|
+
"@jbrowse/plugin-linear-genome-view": "^4.1.1",
|
|
32
|
+
"@jbrowse/core": "^4.1.1"
|
|
32
33
|
},
|
|
33
34
|
"peerDependencies": {
|
|
34
35
|
"react": ">=18.0.0"
|