@jbrowse/plugin-hic 4.0.4 → 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 +7 -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 +5 -0
- package/package.json +5 -4
|
@@ -46,6 +46,7 @@ export function doAfterAttach(self) {
|
|
|
46
46
|
const stopToken = createStopToken();
|
|
47
47
|
self.setRenderingStopToken(stopToken);
|
|
48
48
|
self.setLoading(true);
|
|
49
|
+
self.setCanvasDrawn(false);
|
|
49
50
|
const result = (await rpcManager.call(rpcSessionId, 'CoreRender', {
|
|
50
51
|
sessionId: rpcSessionId,
|
|
51
52
|
rendererType: 'HicRenderer',
|
|
@@ -64,11 +65,13 @@ export function doAfterAttach(self) {
|
|
|
64
65
|
if (result.imageData) {
|
|
65
66
|
self.setRenderingImageData(result.imageData);
|
|
66
67
|
self.setLastDrawnOffsetPx(view.offsetPx);
|
|
68
|
+
self.setLastDrawnBpPerPx(view.bpPerPx);
|
|
67
69
|
}
|
|
68
70
|
self.setFlatbushData(result.flatbush, result.items ?? [], result.maxScore ?? 0, result.yScalar ?? 1);
|
|
69
71
|
}
|
|
70
72
|
catch (error) {
|
|
71
73
|
if (!isAbortException(error)) {
|
|
74
|
+
console.error(error);
|
|
72
75
|
if (isAlive(self)) {
|
|
73
76
|
self.setError(error);
|
|
74
77
|
}
|
|
@@ -113,7 +116,10 @@ export function doAfterAttach(self) {
|
|
|
113
116
|
if (!view.initialized) {
|
|
114
117
|
return;
|
|
115
118
|
}
|
|
116
|
-
drawCanvasImageData(self.ref, self.renderingImageData);
|
|
119
|
+
const success = drawCanvasImageData(self.ref, self.renderingImageData);
|
|
120
|
+
if (isAlive(self)) {
|
|
121
|
+
self.setCanvasDrawn(success);
|
|
122
|
+
}
|
|
117
123
|
}, {
|
|
118
124
|
name: 'LinearHicDisplayCanvas',
|
|
119
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 }) }));
|
|
@@ -231,19 +231,24 @@ export default function stateModelFactory(configSchema: AnyConfigurationSchemaTy
|
|
|
231
231
|
} & {
|
|
232
232
|
loading: boolean;
|
|
233
233
|
lastDrawnOffsetPx: number | undefined;
|
|
234
|
+
lastDrawnBpPerPx: number | undefined;
|
|
234
235
|
ref: HTMLCanvasElement | null;
|
|
235
236
|
renderingImageData: ImageBitmap | undefined;
|
|
236
237
|
renderingStopToken: import("@jbrowse/core/util").StopToken | undefined;
|
|
237
238
|
statusMessage: string | undefined;
|
|
239
|
+
canvasDrawn: boolean;
|
|
238
240
|
} & {
|
|
239
241
|
readonly drawn: boolean;
|
|
242
|
+
readonly fullyDrawn: boolean;
|
|
240
243
|
} & {
|
|
241
244
|
setLastDrawnOffsetPx(n: number): void;
|
|
245
|
+
setLastDrawnBpPerPx(n: number): void;
|
|
242
246
|
setLoading(f: boolean): void;
|
|
243
247
|
setRef(ref: HTMLCanvasElement | null): void;
|
|
244
248
|
setRenderingImageData(imageData: ImageBitmap | undefined): void;
|
|
245
249
|
setRenderingStopToken(token?: import("@jbrowse/core/util").StopToken): void;
|
|
246
250
|
setStatusMessage(msg?: string): void;
|
|
251
|
+
setCanvasDrawn(drawn: boolean): void;
|
|
247
252
|
} & {
|
|
248
253
|
beforeDestroy(): void;
|
|
249
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",
|
|
24
|
-
"@mui/x-charts-vendor": "^8.
|
|
25
|
+
"@mui/x-charts-vendor": "^8.26.0",
|
|
25
26
|
"generic-filehandle2": "^2.0.18",
|
|
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/
|
|
31
|
-
"@jbrowse/
|
|
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"
|