react-msaview 1.2.10 → 1.3.2
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/bundle/colorSchemes.d.ts +16 -0
- package/bundle/colorSchemes.js +455 -0
- package/bundle/components/AboutDlg.d.ts +5 -0
- package/bundle/components/AboutDlg.js +47 -0
- package/bundle/components/AddTrackDlg.d.ts +8 -0
- package/bundle/components/AddTrackDlg.js +26 -0
- package/bundle/components/AnnotationDlg.d.ts +11 -0
- package/bundle/components/AnnotationDlg.js +77 -0
- package/bundle/components/BoxTrack.d.ts +7 -0
- package/bundle/components/BoxTrack.js +143 -0
- package/bundle/components/DetailsDlg.d.ts +8 -0
- package/bundle/components/DetailsDlg.js +12 -0
- package/bundle/components/Header.d.ts +6 -0
- package/bundle/components/Header.js +63 -0
- package/bundle/components/ImportForm.d.ts +6 -0
- package/bundle/components/ImportForm.js +89 -0
- package/bundle/components/MSACanvas.d.ts +6 -0
- package/bundle/components/MSACanvas.js +210 -0
- package/bundle/components/MSAView.d.ts +6 -0
- package/bundle/components/MSAView.js +88 -0
- package/bundle/components/MoreInfoDlg.d.ts +6 -0
- package/bundle/components/MoreInfoDlg.js +11 -0
- package/bundle/components/ResizeHandles.d.ts +8 -0
- package/bundle/components/ResizeHandles.js +110 -0
- package/bundle/components/Rubberband.d.ts +7 -0
- package/bundle/components/Rubberband.js +196 -0
- package/bundle/components/Ruler.d.ts +20 -0
- package/bundle/components/Ruler.js +121 -0
- package/bundle/components/SettingsDlg.d.ts +8 -0
- package/bundle/components/SettingsDlg.js +40 -0
- package/bundle/components/TextTrack.d.ts +7 -0
- package/bundle/components/TextTrack.js +72 -0
- package/bundle/components/Track.d.ts +11 -0
- package/bundle/components/Track.js +81 -0
- package/bundle/components/TrackInfoDlg.d.ts +6 -0
- package/bundle/components/TrackInfoDlg.js +33 -0
- package/bundle/components/TracklistDlg.d.ts +8 -0
- package/bundle/components/TracklistDlg.js +18 -0
- package/bundle/components/TreeCanvas.d.ts +6 -0
- package/bundle/components/TreeCanvas.js +431 -0
- package/bundle/components/TreeRuler.d.ts +6 -0
- package/bundle/components/TreeRuler.js +8 -0
- package/bundle/components/data/seq2.d.ts +3 -0
- package/bundle/components/data/seq2.js +3 -0
- package/bundle/index.d.ts +4 -0
- package/bundle/index.js +97100 -0
- package/bundle/layout.d.ts +23 -0
- package/bundle/layout.js +53 -0
- package/bundle/model.d.ts +364 -0
- package/bundle/model.js +894 -0
- package/bundle/parseNewick.d.ts +64 -0
- package/bundle/parseNewick.js +94 -0
- package/bundle/parsers/ClustalMSA.d.ts +39 -0
- package/bundle/parsers/ClustalMSA.js +77 -0
- package/bundle/parsers/FastaMSA.d.ts +26 -0
- package/bundle/parsers/FastaMSA.js +78 -0
- package/bundle/parsers/StockholmMSA.d.ts +75 -0
- package/bundle/parsers/StockholmMSA.js +142 -0
- package/bundle/util.d.ts +17 -0
- package/bundle/util.js +33 -0
- package/dist/colorSchemes.js +1 -1
- package/dist/components/AboutDlg.js +1 -1
- package/dist/components/AddTrackDlg.js +1 -1
- package/dist/components/AnnotationDlg.js +1 -1
- package/dist/components/BoxTrack.js +4 -4
- package/dist/components/Header.js +1 -1
- package/dist/components/ImportForm.js +10 -2
- package/dist/components/MSACanvas.js +2 -2
- package/dist/components/Rubberband.js +1 -1
- package/dist/components/Ruler.js +2 -2
- package/dist/components/SettingsDlg.js +3 -3
- package/dist/components/TextTrack.js +1 -1
- package/dist/components/TreeCanvas.js +2 -1
- package/dist/components/package.json +13 -6
- package/dist/model.d.ts +68 -4
- package/dist/model.js +8 -6
- package/dist/parsers/StockholmMSA.js +1 -1
- package/dist/util.js +2 -2
- package/package.json +13 -6
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import React, { useRef, useMemo, useEffect } from 'react';
|
|
2
|
+
import { observer } from 'mobx-react';
|
|
3
|
+
import { getSnapshot, isStateTreeNode } from 'mobx-state-tree';
|
|
4
|
+
import Layout from '../layout';
|
|
5
|
+
var AnnotationBlock = observer(function (_a) {
|
|
6
|
+
var track = _a.track, model = _a.model, offsetX = _a.offsetX;
|
|
7
|
+
var blockSize = model.blockSize, colWidth = model.colWidth, blanks = model.blanks, rowHeight = model.rowHeight, highResScaleFactor = model.highResScaleFactor, scrollX = model.scrollX;
|
|
8
|
+
var _b = track.model, height = _b.height, features = _b.features, associatedRowName = _b.associatedRowName;
|
|
9
|
+
var feats = isStateTreeNode(features)
|
|
10
|
+
? getSnapshot(features)
|
|
11
|
+
: features;
|
|
12
|
+
var layout = useMemo(function () {
|
|
13
|
+
var temp = new Layout();
|
|
14
|
+
feats === null || feats === void 0 ? void 0 : feats.forEach(function (feature, index) {
|
|
15
|
+
var start = feature.start, end = feature.end;
|
|
16
|
+
if (associatedRowName) {
|
|
17
|
+
var s = model.rowSpecificBpToPx(associatedRowName, start - 1);
|
|
18
|
+
var e = model.rowSpecificBpToPx(associatedRowName, end);
|
|
19
|
+
temp.addRect("" + index, s, e, rowHeight, feature);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
var s = model.globalBpToPx(start - 1);
|
|
23
|
+
var e = model.globalBpToPx(end);
|
|
24
|
+
temp.addRect("" + index, s, e, rowHeight, feature);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return temp;
|
|
28
|
+
}, [rowHeight, feats, associatedRowName, model, blanks]);
|
|
29
|
+
var ref = useRef(null);
|
|
30
|
+
var labelRef = useRef(null);
|
|
31
|
+
var mouseoverRef = useRef(null);
|
|
32
|
+
useEffect(function () {
|
|
33
|
+
if (!ref.current) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
var ctx = ref.current.getContext('2d');
|
|
37
|
+
if (!ctx) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
ctx.resetTransform();
|
|
41
|
+
ctx.scale(highResScaleFactor, highResScaleFactor);
|
|
42
|
+
ctx.clearRect(0, 0, blockSize, height);
|
|
43
|
+
ctx.translate(-offsetX, 0);
|
|
44
|
+
ctx.textAlign = 'center';
|
|
45
|
+
ctx.font = ctx.font.replace(/\d+px/, Math.max(8, rowHeight - 8) + "px");
|
|
46
|
+
var xStart = Math.max(0, Math.floor(offsetX / colWidth));
|
|
47
|
+
ctx.fillStyle = 'goldenrod';
|
|
48
|
+
layout.rectangles.forEach(function (value) {
|
|
49
|
+
var minX = value.minX, maxX = value.maxX, minY = value.minY, maxY = value.maxY;
|
|
50
|
+
var x1 = (minX - xStart) * colWidth + offsetX - (offsetX % colWidth);
|
|
51
|
+
var x2 = (maxX - xStart) * colWidth + offsetX - (offsetX % colWidth);
|
|
52
|
+
if (x2 - x1 > 0) {
|
|
53
|
+
ctx.fillRect(x1, minY, x2 - x1, (maxY - minY) / 2);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}, [
|
|
57
|
+
associatedRowName,
|
|
58
|
+
blockSize,
|
|
59
|
+
colWidth,
|
|
60
|
+
layout.rectangles,
|
|
61
|
+
model,
|
|
62
|
+
rowHeight,
|
|
63
|
+
height,
|
|
64
|
+
offsetX,
|
|
65
|
+
highResScaleFactor,
|
|
66
|
+
features,
|
|
67
|
+
blanks,
|
|
68
|
+
]);
|
|
69
|
+
useEffect(function () {
|
|
70
|
+
if (!labelRef.current) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
var ctx = labelRef.current.getContext('2d');
|
|
74
|
+
if (!ctx) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
// this logic is very similar to MSACanvas
|
|
78
|
+
ctx.resetTransform();
|
|
79
|
+
ctx.scale(highResScaleFactor, highResScaleFactor);
|
|
80
|
+
ctx.clearRect(0, 0, blockSize, height);
|
|
81
|
+
ctx.translate(-offsetX, 0);
|
|
82
|
+
ctx.textAlign = 'center';
|
|
83
|
+
ctx.font = ctx.font.replace(/\d+px/, Math.max(8, rowHeight - 8) + "px");
|
|
84
|
+
ctx.fillStyle = 'black';
|
|
85
|
+
ctx.textAlign = 'left';
|
|
86
|
+
layout.rectangles.forEach(function (value) {
|
|
87
|
+
var _a, _b, _c, _d;
|
|
88
|
+
var minX = value.minX, maxX = value.maxX, maxY = value.maxY, minY = value.minY;
|
|
89
|
+
var feature = value.data;
|
|
90
|
+
var x1 = minX * colWidth;
|
|
91
|
+
var x2 = maxX * colWidth;
|
|
92
|
+
if (x2 - x1 > 0) {
|
|
93
|
+
var note = (_b = (_a = feature.attributes) === null || _a === void 0 ? void 0 : _a.Note) === null || _b === void 0 ? void 0 : _b[0];
|
|
94
|
+
var name_1 = (_d = (_c = feature.attributes) === null || _c === void 0 ? void 0 : _c.Name) === null || _d === void 0 ? void 0 : _d[0];
|
|
95
|
+
var type = feature.type;
|
|
96
|
+
ctx.fillText([type, name_1, note].filter(function (f) { return !!f; }).join(' - '), Math.max(Math.min(-scrollX, x2), x1), minY + (maxY - minY));
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}, [
|
|
100
|
+
blockSize,
|
|
101
|
+
colWidth,
|
|
102
|
+
scrollX,
|
|
103
|
+
highResScaleFactor,
|
|
104
|
+
height,
|
|
105
|
+
layout.rectangles,
|
|
106
|
+
offsetX,
|
|
107
|
+
features,
|
|
108
|
+
model,
|
|
109
|
+
rowHeight,
|
|
110
|
+
blanks,
|
|
111
|
+
]);
|
|
112
|
+
return !features ? null : (React.createElement(React.Fragment, null,
|
|
113
|
+
React.createElement("canvas", { ref: ref, height: height * highResScaleFactor, width: blockSize * highResScaleFactor, style: {
|
|
114
|
+
position: 'absolute',
|
|
115
|
+
left: scrollX + offsetX,
|
|
116
|
+
width: blockSize,
|
|
117
|
+
height: height,
|
|
118
|
+
} }),
|
|
119
|
+
React.createElement("canvas", { ref: labelRef, height: height * highResScaleFactor, width: blockSize * highResScaleFactor, style: {
|
|
120
|
+
position: 'absolute',
|
|
121
|
+
left: scrollX + offsetX,
|
|
122
|
+
width: blockSize,
|
|
123
|
+
height: height,
|
|
124
|
+
} }),
|
|
125
|
+
React.createElement("canvas", { ref: mouseoverRef, height: height * highResScaleFactor, width: blockSize * highResScaleFactor, style: {
|
|
126
|
+
position: 'absolute',
|
|
127
|
+
left: scrollX + offsetX,
|
|
128
|
+
width: blockSize,
|
|
129
|
+
height: height,
|
|
130
|
+
} })));
|
|
131
|
+
});
|
|
132
|
+
var AnnotationTrack = observer(function (_a) {
|
|
133
|
+
var model = _a.model, track = _a.track;
|
|
134
|
+
var blocksX = model.blocksX, msaAreaWidth = model.msaAreaWidth;
|
|
135
|
+
var height = track.model.height;
|
|
136
|
+
return (React.createElement("div", { style: {
|
|
137
|
+
position: 'relative',
|
|
138
|
+
height: height,
|
|
139
|
+
width: msaAreaWidth,
|
|
140
|
+
overflow: 'hidden',
|
|
141
|
+
} }, blocksX.map(function (bx) { return (React.createElement(AnnotationBlock, { track: track, key: bx, model: model, offsetX: bx })); })));
|
|
142
|
+
});
|
|
143
|
+
export default AnnotationTrack;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Dialog, DialogTitle, DialogContent } from '@material-ui/core';
|
|
3
|
+
import { observer } from 'mobx-react';
|
|
4
|
+
import { Attributes } from '@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail';
|
|
5
|
+
export default observer(function (_a) {
|
|
6
|
+
var model = _a.model, onClose = _a.onClose, open = _a.open;
|
|
7
|
+
var alignmentDetails = model.alignmentDetails;
|
|
8
|
+
return (React.createElement(Dialog, { onClose: function () { return onClose(); }, open: open },
|
|
9
|
+
React.createElement(DialogTitle, null, "Metadata"),
|
|
10
|
+
React.createElement(DialogContent, null,
|
|
11
|
+
React.createElement(Attributes, { attributes: alignmentDetails }))));
|
|
12
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { IconButton, Select, Typography } from '@material-ui/core';
|
|
3
|
+
import { observer } from 'mobx-react';
|
|
4
|
+
import SettingsDialog from './SettingsDlg';
|
|
5
|
+
import AboutDialog from './AboutDlg';
|
|
6
|
+
import DetailsDialog from './DetailsDlg';
|
|
7
|
+
import TracklistDialog from './TracklistDlg';
|
|
8
|
+
//icons
|
|
9
|
+
import FolderOpenIcon from '@material-ui/icons/FolderOpen';
|
|
10
|
+
import SettingsIcon from '@material-ui/icons/Settings';
|
|
11
|
+
import HelpIcon from '@material-ui/icons/Help';
|
|
12
|
+
import AssignmentIcon from '@material-ui/icons/Assignment';
|
|
13
|
+
import ListIcon from '@material-ui/icons/List';
|
|
14
|
+
var InfoArea = observer(function (_a) {
|
|
15
|
+
var model = _a.model;
|
|
16
|
+
var mouseOverRowName = model.mouseOverRowName, mouseCol = model.mouseCol;
|
|
17
|
+
return (React.createElement("div", null,
|
|
18
|
+
React.createElement(Typography, { display: "inline" },
|
|
19
|
+
"Row name: ",
|
|
20
|
+
mouseOverRowName),
|
|
21
|
+
React.createElement("span", { style: { marginLeft: 10 } }),
|
|
22
|
+
React.createElement(Typography, { display: "inline" },
|
|
23
|
+
"Position: ",
|
|
24
|
+
mouseCol)));
|
|
25
|
+
});
|
|
26
|
+
var Header = observer(function (_a) {
|
|
27
|
+
var model = _a.model;
|
|
28
|
+
var _b = useState(false), settingsDialogVisible = _b[0], setSettingsDialogVisible = _b[1];
|
|
29
|
+
var _c = useState(false), aboutDialogVisible = _c[0], setAboutDialogVisible = _c[1];
|
|
30
|
+
var _d = useState(false), detailsDialogVisible = _d[0], setDetailsDialogVisible = _d[1];
|
|
31
|
+
var _e = useState(false), tracklistDialogVisible = _e[0], setTracklistDialogVisible = _e[1];
|
|
32
|
+
var currentAlignment = model.currentAlignment, alignmentNames = model.alignmentNames;
|
|
33
|
+
return (React.createElement("div", { style: { display: 'flex' } },
|
|
34
|
+
React.createElement(IconButton, { onClick: function () {
|
|
35
|
+
model.setData({ tree: '', msa: '' });
|
|
36
|
+
model.setTreeFilehandle(undefined);
|
|
37
|
+
model.setMSAFilehandle(undefined);
|
|
38
|
+
model.setScrollY(0);
|
|
39
|
+
model.setScrollX(0);
|
|
40
|
+
model.setCurrentAlignment(0);
|
|
41
|
+
} },
|
|
42
|
+
React.createElement(FolderOpenIcon, null)),
|
|
43
|
+
React.createElement(IconButton, { onClick: function () { return setSettingsDialogVisible(true); } },
|
|
44
|
+
React.createElement(SettingsIcon, null)),
|
|
45
|
+
React.createElement(IconButton, { onClick: function () { return setDetailsDialogVisible(true); } },
|
|
46
|
+
React.createElement(AssignmentIcon, null)),
|
|
47
|
+
React.createElement(IconButton, { onClick: function () { return setTracklistDialogVisible(true); } },
|
|
48
|
+
React.createElement(ListIcon, null)),
|
|
49
|
+
settingsDialogVisible ? (React.createElement(SettingsDialog, { open: true, model: model, onClose: function () { return setSettingsDialogVisible(false); } })) : null,
|
|
50
|
+
aboutDialogVisible ? (React.createElement(AboutDialog, { open: true, onClose: function () { return setAboutDialogVisible(false); } })) : null,
|
|
51
|
+
detailsDialogVisible ? (React.createElement(DetailsDialog, { open: true, model: model, onClose: function () { return setDetailsDialogVisible(false); } })) : null,
|
|
52
|
+
tracklistDialogVisible ? (React.createElement(TracklistDialog, { open: true, model: model, onClose: function () { return setTracklistDialogVisible(false); } })) : null,
|
|
53
|
+
alignmentNames.length > 0 ? (React.createElement(Select, { native: true, value: currentAlignment, onChange: function (event) {
|
|
54
|
+
model.setCurrentAlignment(+event.target.value);
|
|
55
|
+
model.setScrollX(0);
|
|
56
|
+
model.setScrollY(0);
|
|
57
|
+
} }, alignmentNames.map(function (option, index) { return (React.createElement("option", { key: option + "-" + index, value: index }, option)); }))) : null,
|
|
58
|
+
React.createElement(InfoArea, { model: model }),
|
|
59
|
+
React.createElement("div", { style: { flex: 1 } }),
|
|
60
|
+
React.createElement(IconButton, { onClick: function () { return setAboutDialogVisible(true); } },
|
|
61
|
+
React.createElement(HelpIcon, null))));
|
|
62
|
+
});
|
|
63
|
+
export default Header;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Button, Container, Grid, Typography, Link } from '@material-ui/core';
|
|
3
|
+
import { observer } from 'mobx-react';
|
|
4
|
+
import { transaction } from 'mobx';
|
|
5
|
+
import { FileSelector } from '@jbrowse/core/ui';
|
|
6
|
+
import { smallTree, smallMSA, smallMSAOnly } from './data/seq2';
|
|
7
|
+
var ListItem = function (_a) {
|
|
8
|
+
var onClick = _a.onClick, model = _a.model, children = _a.children;
|
|
9
|
+
return (React.createElement("li", null,
|
|
10
|
+
React.createElement(Link, { onClick: function (event) {
|
|
11
|
+
model.setError(undefined);
|
|
12
|
+
event.preventDefault();
|
|
13
|
+
onClick();
|
|
14
|
+
}, href: "#" },
|
|
15
|
+
React.createElement(Typography, null, children))));
|
|
16
|
+
};
|
|
17
|
+
export default observer(function (_a) {
|
|
18
|
+
var model = _a.model;
|
|
19
|
+
var _b = useState(), msaFile = _b[0], setMsaFile = _b[1];
|
|
20
|
+
var _c = useState(), treeFile = _c[0], setTreeFile = _c[1];
|
|
21
|
+
var error = model.error;
|
|
22
|
+
return (React.createElement(Container, null,
|
|
23
|
+
React.createElement("div", { style: { width: '50%' } },
|
|
24
|
+
error ? (React.createElement("div", { style: { padding: 20 } },
|
|
25
|
+
React.createElement(Typography, { color: "error" },
|
|
26
|
+
"Error: ", "" + error))) : null,
|
|
27
|
+
React.createElement(Typography, null, "Open an MSA file (stockholm or clustal format) and/or a tree file (newick format)."),
|
|
28
|
+
React.createElement(Typography, { color: "error" }, "Note: you can open up just an MSA or just a tree, both are not required. Some MSA files e.g. stockholm format have an embedded tree also and this is fine, and opening a separate tree file is not required.")),
|
|
29
|
+
React.createElement(Grid, { container: true, spacing: 10, justifyContent: "center", alignItems: "center" },
|
|
30
|
+
React.createElement(Grid, { item: true },
|
|
31
|
+
React.createElement(Typography, null, "MSA file or URL"),
|
|
32
|
+
React.createElement(FileSelector, { location: msaFile, setLocation: setMsaFile }),
|
|
33
|
+
React.createElement(Typography, null, "Tree file or URL"),
|
|
34
|
+
React.createElement(FileSelector, { location: treeFile, setLocation: setTreeFile })),
|
|
35
|
+
React.createElement(Grid, { item: true },
|
|
36
|
+
React.createElement(Button, { onClick: function () {
|
|
37
|
+
model.setError(undefined);
|
|
38
|
+
if (msaFile) {
|
|
39
|
+
model.setMSAFilehandle(msaFile);
|
|
40
|
+
}
|
|
41
|
+
if (treeFile) {
|
|
42
|
+
model.setTreeFilehandle(treeFile);
|
|
43
|
+
}
|
|
44
|
+
}, variant: "contained", color: "primary", disabled: !msaFile && !treeFile }, "Open")),
|
|
45
|
+
React.createElement(Grid, { item: true },
|
|
46
|
+
React.createElement(Typography, null, "Examples"),
|
|
47
|
+
React.createElement("ul", null,
|
|
48
|
+
React.createElement(ListItem, { model: model, onClick: function () {
|
|
49
|
+
model.setTreeFilehandle({
|
|
50
|
+
uri: 'https://jbrowse.org/genomes/newick_trees/sarscov2phylo.pub.ft.nh',
|
|
51
|
+
});
|
|
52
|
+
} }, "230k COVID-19 samples (tree only)"),
|
|
53
|
+
React.createElement(ListItem, { model: model, onClick: function () {
|
|
54
|
+
model.setData({ msa: smallMSA, tree: smallTree });
|
|
55
|
+
} }, "Small protein MSA+tree"),
|
|
56
|
+
React.createElement(ListItem, { model: model, onClick: function () {
|
|
57
|
+
model.setData({ msa: smallMSAOnly });
|
|
58
|
+
} }, "Small MSA only"),
|
|
59
|
+
React.createElement(ListItem, { model: model, onClick: function () {
|
|
60
|
+
model.setMSAFilehandle({
|
|
61
|
+
uri: 'https://ihh.github.io/abrowse/build/pfam-cov2.stock',
|
|
62
|
+
});
|
|
63
|
+
} }, "PFAM SARS-CoV2 multi-stockholm"),
|
|
64
|
+
React.createElement(ListItem, { model: model, onClick: function () {
|
|
65
|
+
model.setMSAFilehandle({
|
|
66
|
+
uri: 'https://jbrowse.org/genomes/multiple_sequence_alignments/Lysine.stock',
|
|
67
|
+
});
|
|
68
|
+
} }, "Lysine stockholm file"),
|
|
69
|
+
React.createElement(ListItem, { model: model, onClick: function () {
|
|
70
|
+
model.setMSAFilehandle({
|
|
71
|
+
uri: 'https://jbrowse.org/genomes/multiple_sequence_alignments/PF01601_full.txt',
|
|
72
|
+
});
|
|
73
|
+
} }, "PF01601 stockholm file (SARS-CoV2 spike protein)"),
|
|
74
|
+
React.createElement(ListItem, { model: model, onClick: function () {
|
|
75
|
+
model.setMSAFilehandle({
|
|
76
|
+
uri: 'https://jbrowse.org/genomes/multiple_sequence_alignments/europe_covid.fa',
|
|
77
|
+
});
|
|
78
|
+
} }, "Europe COVID full genomes (LR883044.1 and 199 other sequences)"),
|
|
79
|
+
React.createElement(ListItem, { model: model, onClick: function () {
|
|
80
|
+
transaction(function () {
|
|
81
|
+
model.setMSAFilehandle({
|
|
82
|
+
uri: 'https://jbrowse.org/genomes/multiple_sequence_alignments/rhv_test-only.aligned_with_mafft_auto.fa',
|
|
83
|
+
});
|
|
84
|
+
model.setTreeFilehandle({
|
|
85
|
+
uri: 'https://jbrowse.org/genomes/multiple_sequence_alignments/rhv_test-only.aligned_with_mafft_auto.nh',
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
} }, "MAFFT+VeryFastTree(17.9k samples)"))))));
|
|
89
|
+
});
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import React, { useEffect, useState, useRef, useMemo } from 'react';
|
|
2
|
+
import { Typography, CircularProgress, useTheme } from '@material-ui/core';
|
|
3
|
+
import { observer } from 'mobx-react';
|
|
4
|
+
import normalizeWheel from 'normalize-wheel';
|
|
5
|
+
import { colorContrast } from '../util';
|
|
6
|
+
import { getClustalXColor, getPercentIdentityColor } from '../colorSchemes';
|
|
7
|
+
var MSABlock = observer(function (_a) {
|
|
8
|
+
var model = _a.model, offsetX = _a.offsetX, offsetY = _a.offsetY;
|
|
9
|
+
var MSA = model.MSA, colWidth = model.colWidth, bgColor = model.bgColor, columns = model.columns, rowHeight = model.rowHeight, scrollY = model.scrollY, scrollX = model.scrollX, hierarchy = model.hierarchy, colorScheme = model.colorScheme, colorSchemeName = model.colorSchemeName, blockSize = model.blockSize, highResScaleFactor = model.highResScaleFactor, colStats = model.colStats;
|
|
10
|
+
var theme = useTheme();
|
|
11
|
+
var contrastScheme = useMemo(function () { return colorContrast(colorScheme, theme); }, [colorScheme, theme]);
|
|
12
|
+
var ref = useRef(null);
|
|
13
|
+
useEffect(function () {
|
|
14
|
+
if (!ref.current) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
var ctx = ref.current.getContext('2d');
|
|
18
|
+
if (!ctx) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
ctx.resetTransform();
|
|
22
|
+
ctx.scale(highResScaleFactor, highResScaleFactor);
|
|
23
|
+
ctx.clearRect(0, 0, blockSize, blockSize);
|
|
24
|
+
ctx.translate(-offsetX, rowHeight / 2 - offsetY);
|
|
25
|
+
ctx.textAlign = 'center';
|
|
26
|
+
ctx.font = ctx.font.replace(/\d+px/, Math.max(8, rowHeight - 8) + "px");
|
|
27
|
+
var leaves = hierarchy.leaves();
|
|
28
|
+
var b = blockSize;
|
|
29
|
+
// slice vertical rows, e.g. tree leaves, avoid negative slice
|
|
30
|
+
var yStart = Math.max(0, Math.floor((offsetY - rowHeight) / rowHeight));
|
|
31
|
+
var yEnd = Math.max(0, Math.ceil((offsetY + b + rowHeight) / rowHeight));
|
|
32
|
+
// slice horizontal visible letters, avoid negative slice
|
|
33
|
+
var xStart = Math.max(0, Math.floor(offsetX / colWidth));
|
|
34
|
+
var xEnd = Math.max(0, Math.ceil((offsetX + b) / colWidth));
|
|
35
|
+
var visibleLeaves = leaves.slice(yStart, yEnd);
|
|
36
|
+
visibleLeaves.forEach(function (node) {
|
|
37
|
+
var _a;
|
|
38
|
+
var
|
|
39
|
+
//@ts-ignore
|
|
40
|
+
y = node.x, name = node.data.name;
|
|
41
|
+
var str = (_a = columns[name]) === null || _a === void 0 ? void 0 : _a.slice(xStart, xEnd);
|
|
42
|
+
for (var i = 0; i < (str === null || str === void 0 ? void 0 : str.length); i++) {
|
|
43
|
+
var letter = str[i];
|
|
44
|
+
var color = colorSchemeName === 'clustalx_protein_dynamic'
|
|
45
|
+
? getClustalXColor(colStats[xStart + i], model, name, xStart + i)
|
|
46
|
+
: colorSchemeName === 'percent_identity_dynamic'
|
|
47
|
+
? getPercentIdentityColor(colStats[xStart + i], model, name, xStart + i)
|
|
48
|
+
: colorScheme[letter.toUpperCase()];
|
|
49
|
+
if (bgColor) {
|
|
50
|
+
var x = i * colWidth + offsetX - (offsetX % colWidth);
|
|
51
|
+
ctx.fillStyle = color || 'white';
|
|
52
|
+
ctx.fillRect(x, y - rowHeight, colWidth, rowHeight);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
if (rowHeight >= 10 && colWidth >= rowHeight / 2) {
|
|
57
|
+
visibleLeaves.forEach(function (node) {
|
|
58
|
+
var _a;
|
|
59
|
+
var
|
|
60
|
+
//@ts-ignore
|
|
61
|
+
y = node.x, name = node.data.name;
|
|
62
|
+
var str = (_a = columns[name]) === null || _a === void 0 ? void 0 : _a.slice(xStart, xEnd);
|
|
63
|
+
for (var i = 0; i < (str === null || str === void 0 ? void 0 : str.length); i++) {
|
|
64
|
+
var letter = str[i];
|
|
65
|
+
var color = colorScheme[letter.toUpperCase()];
|
|
66
|
+
var contrast = contrastScheme[letter.toUpperCase()] || 'black';
|
|
67
|
+
var x = i * colWidth + offsetX - (offsetX % colWidth);
|
|
68
|
+
//note: -rowHeight/4 matches +rowHeight/4 in tree
|
|
69
|
+
ctx.fillStyle = bgColor ? contrast : color || 'black';
|
|
70
|
+
ctx.fillText(letter, x + colWidth / 2, y - rowHeight / 4);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}, [
|
|
75
|
+
MSA,
|
|
76
|
+
highResScaleFactor,
|
|
77
|
+
columns,
|
|
78
|
+
colorScheme,
|
|
79
|
+
contrastScheme,
|
|
80
|
+
bgColor,
|
|
81
|
+
rowHeight,
|
|
82
|
+
colWidth,
|
|
83
|
+
hierarchy,
|
|
84
|
+
offsetX,
|
|
85
|
+
offsetY,
|
|
86
|
+
blockSize,
|
|
87
|
+
]);
|
|
88
|
+
return (React.createElement("canvas", { ref: ref, onMouseMove: function (event) {
|
|
89
|
+
if (!ref.current) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
var _a = ref.current.getBoundingClientRect(), left = _a.left, top = _a.top;
|
|
93
|
+
var mouseX = event.clientX - left;
|
|
94
|
+
var mouseY = event.clientY - top;
|
|
95
|
+
model.setMousePos(Math.floor((mouseX + offsetX) / colWidth) + 1, Math.floor((mouseY + offsetY) / rowHeight));
|
|
96
|
+
}, onMouseLeave: function () { return model.setMousePos(); }, width: blockSize * highResScaleFactor, height: blockSize * highResScaleFactor, style: {
|
|
97
|
+
position: 'absolute',
|
|
98
|
+
top: scrollY + offsetY,
|
|
99
|
+
left: scrollX + offsetX,
|
|
100
|
+
width: blockSize,
|
|
101
|
+
height: blockSize,
|
|
102
|
+
} }));
|
|
103
|
+
});
|
|
104
|
+
var MSACanvas = observer(function (_a) {
|
|
105
|
+
var model = _a.model;
|
|
106
|
+
var MSA = model.MSA, msaFilehandle = model.msaFilehandle, height = model.height, msaAreaWidth = model.msaAreaWidth, blocks2d = model.blocks2d;
|
|
107
|
+
var ref = useRef(null);
|
|
108
|
+
// wheel
|
|
109
|
+
var scheduled = useRef(false);
|
|
110
|
+
var deltaX = useRef(0);
|
|
111
|
+
var deltaY = useRef(0);
|
|
112
|
+
// mouse click-and-drag scrolling
|
|
113
|
+
var prevX = useRef(0);
|
|
114
|
+
var prevY = useRef(0);
|
|
115
|
+
var _b = useState(false), mouseDragging = _b[0], setMouseDragging = _b[1];
|
|
116
|
+
useEffect(function () {
|
|
117
|
+
var curr = ref.current;
|
|
118
|
+
if (!curr) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
function onWheel(origEvent) {
|
|
122
|
+
var event = normalizeWheel(origEvent);
|
|
123
|
+
deltaX.current += event.pixelX;
|
|
124
|
+
deltaY.current += event.pixelY;
|
|
125
|
+
if (!scheduled.current) {
|
|
126
|
+
scheduled.current = true;
|
|
127
|
+
requestAnimationFrame(function () {
|
|
128
|
+
model.doScrollX(-deltaX.current);
|
|
129
|
+
model.doScrollY(-deltaY.current);
|
|
130
|
+
deltaX.current = 0;
|
|
131
|
+
deltaY.current = 0;
|
|
132
|
+
scheduled.current = false;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
origEvent.preventDefault();
|
|
136
|
+
}
|
|
137
|
+
curr.addEventListener('wheel', onWheel);
|
|
138
|
+
return function () {
|
|
139
|
+
curr.removeEventListener('wheel', onWheel);
|
|
140
|
+
};
|
|
141
|
+
}, [model]);
|
|
142
|
+
useEffect(function () {
|
|
143
|
+
var cleanup = function () { };
|
|
144
|
+
function globalMouseMove(event) {
|
|
145
|
+
event.preventDefault();
|
|
146
|
+
var currX = event.clientX;
|
|
147
|
+
var currY = event.clientY;
|
|
148
|
+
var distanceX = currX - prevX.current;
|
|
149
|
+
var distanceY = currY - prevY.current;
|
|
150
|
+
if (distanceX || distanceY) {
|
|
151
|
+
// use rAF to make it so multiple event handlers aren't fired per-frame
|
|
152
|
+
// see https://calendar.perfplanet.com/2013/the-runtime-performance-checklist/
|
|
153
|
+
if (!scheduled.current) {
|
|
154
|
+
scheduled.current = true;
|
|
155
|
+
window.requestAnimationFrame(function () {
|
|
156
|
+
model.doScrollX(distanceX);
|
|
157
|
+
model.doScrollY(distanceY);
|
|
158
|
+
scheduled.current = false;
|
|
159
|
+
prevX.current = event.clientX;
|
|
160
|
+
prevY.current = event.clientY;
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function globalMouseUp() {
|
|
166
|
+
prevX.current = 0;
|
|
167
|
+
if (mouseDragging) {
|
|
168
|
+
setMouseDragging(false);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (mouseDragging) {
|
|
172
|
+
window.addEventListener('mousemove', globalMouseMove, true);
|
|
173
|
+
window.addEventListener('mouseup', globalMouseUp, true);
|
|
174
|
+
cleanup = function () {
|
|
175
|
+
window.removeEventListener('mousemove', globalMouseMove, true);
|
|
176
|
+
window.removeEventListener('mouseup', globalMouseUp, true);
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
return cleanup;
|
|
180
|
+
}, [model, mouseDragging]);
|
|
181
|
+
return (React.createElement("div", { ref: ref, onMouseDown: function (event) {
|
|
182
|
+
// check if clicking a draggable element or a resize handle
|
|
183
|
+
var target = event.target;
|
|
184
|
+
if (target.draggable || target.dataset.resizer) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
// otherwise do click and drag scroll
|
|
188
|
+
if (event.button === 0) {
|
|
189
|
+
prevX.current = event.clientX;
|
|
190
|
+
prevY.current = event.clientY;
|
|
191
|
+
setMouseDragging(true);
|
|
192
|
+
}
|
|
193
|
+
}, onMouseUp: function (event) {
|
|
194
|
+
event.preventDefault();
|
|
195
|
+
setMouseDragging(false);
|
|
196
|
+
}, onMouseLeave: function (event) {
|
|
197
|
+
event.preventDefault();
|
|
198
|
+
}, style: {
|
|
199
|
+
position: 'relative',
|
|
200
|
+
height: height,
|
|
201
|
+
width: msaAreaWidth,
|
|
202
|
+
overflow: 'hidden',
|
|
203
|
+
} }, !MSA && !msaFilehandle ? null : !MSA ? (React.createElement("div", { style: { position: 'absolute', left: '50%', top: '50%' } },
|
|
204
|
+
React.createElement(CircularProgress, null),
|
|
205
|
+
React.createElement(Typography, null, "Loading..."))) : (blocks2d.map(function (_a) {
|
|
206
|
+
var bx = _a[0], by = _a[1];
|
|
207
|
+
return (React.createElement(MSABlock, { key: bx + "_" + by, model: model, offsetX: bx, offsetY: by }));
|
|
208
|
+
}))));
|
|
209
|
+
});
|
|
210
|
+
export default MSACanvas;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import React, { useRef, useEffect } from 'react';
|
|
13
|
+
import { observer } from 'mobx-react';
|
|
14
|
+
import { Typography } from '@material-ui/core';
|
|
15
|
+
import ImportForm from './ImportForm';
|
|
16
|
+
import Rubberband from './Rubberband';
|
|
17
|
+
import TreeCanvas from './TreeCanvas';
|
|
18
|
+
import MSACanvas from './MSACanvas';
|
|
19
|
+
import Ruler from './Ruler';
|
|
20
|
+
import TreeRuler from './TreeRuler';
|
|
21
|
+
import Header from './Header';
|
|
22
|
+
import Track from './Track';
|
|
23
|
+
import AnnotationDialog from './AnnotationDlg';
|
|
24
|
+
import { HorizontalResizeHandle, VerticalResizeHandle } from './ResizeHandles';
|
|
25
|
+
var MouseoverCanvas = observer(function (_a) {
|
|
26
|
+
var model = _a.model;
|
|
27
|
+
var ref = useRef(null);
|
|
28
|
+
var height = model.height, width = model.width, treeAreaWidth = model.treeAreaWidth, resizeHandleWidth = model.resizeHandleWidth, scrollX = model.scrollX, mouseCol = model.mouseCol, colWidth = model.colWidth;
|
|
29
|
+
useEffect(function () {
|
|
30
|
+
if (!ref.current) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
var ctx = ref.current.getContext('2d');
|
|
34
|
+
if (!ctx) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
ctx.resetTransform();
|
|
38
|
+
ctx.clearRect(0, 0, width, height);
|
|
39
|
+
if (mouseCol !== undefined) {
|
|
40
|
+
var x = (mouseCol - 1) * colWidth + scrollX + treeAreaWidth + resizeHandleWidth;
|
|
41
|
+
ctx.fillStyle = 'rgba(100,100,100,0.5)';
|
|
42
|
+
ctx.fillRect(x, 0, colWidth, height);
|
|
43
|
+
}
|
|
44
|
+
}, [
|
|
45
|
+
mouseCol,
|
|
46
|
+
colWidth,
|
|
47
|
+
scrollX,
|
|
48
|
+
height,
|
|
49
|
+
resizeHandleWidth,
|
|
50
|
+
treeAreaWidth,
|
|
51
|
+
width,
|
|
52
|
+
]);
|
|
53
|
+
return (React.createElement("canvas", { ref: ref, width: width, height: height, style: {
|
|
54
|
+
position: 'absolute',
|
|
55
|
+
top: 0,
|
|
56
|
+
left: 0,
|
|
57
|
+
width: width,
|
|
58
|
+
height: height,
|
|
59
|
+
zIndex: 1000,
|
|
60
|
+
pointerEvents: 'none',
|
|
61
|
+
} }));
|
|
62
|
+
});
|
|
63
|
+
export default observer(function (_a) {
|
|
64
|
+
var model = _a.model;
|
|
65
|
+
var done = model.done, initialized = model.initialized, treeAreaWidth = model.treeAreaWidth, height = model.height, resizeHandleWidth = model.resizeHandleWidth, turnedOnTracks = model.turnedOnTracks;
|
|
66
|
+
return (React.createElement("div", null,
|
|
67
|
+
!initialized ? (React.createElement(ImportForm, { model: model })) : !done ? (React.createElement(Typography, { variant: "h4" }, "Loading...")) : (React.createElement("div", null,
|
|
68
|
+
React.createElement("div", { style: { height: height, overflow: 'hidden' } },
|
|
69
|
+
React.createElement(Header, { model: model }),
|
|
70
|
+
React.createElement("div", null,
|
|
71
|
+
React.createElement("div", { style: { position: 'relative' } },
|
|
72
|
+
React.createElement("div", { style: { display: 'flex' } },
|
|
73
|
+
React.createElement("div", { style: { flexShrink: 0, width: treeAreaWidth } },
|
|
74
|
+
React.createElement(TreeRuler, { model: model })),
|
|
75
|
+
React.createElement(Rubberband, { model: model, ControlComponent: React.createElement(Ruler, { model: model }) })), turnedOnTracks === null || turnedOnTracks === void 0 ? void 0 :
|
|
76
|
+
turnedOnTracks.map(function (track) { return (React.createElement(Track, { key: track.model.id, model: model, track: track })); }),
|
|
77
|
+
React.createElement("div", { style: { display: 'flex' } },
|
|
78
|
+
React.createElement("div", { style: { flexShrink: 0, width: treeAreaWidth } },
|
|
79
|
+
React.createElement(TreeCanvas, { model: model })),
|
|
80
|
+
React.createElement(VerticalResizeHandle, { model: model }),
|
|
81
|
+
React.createElement(MSACanvas, { model: model }),
|
|
82
|
+
React.createElement(MouseoverCanvas, { model: model }))))),
|
|
83
|
+
React.createElement(HorizontalResizeHandle, { model: model }))),
|
|
84
|
+
model.DialogComponent ? (React.createElement(model.DialogComponent, __assign({}, (model.DialogProps || {}), { onClose: function () {
|
|
85
|
+
model.setDialogComponent(undefined, undefined);
|
|
86
|
+
} }))) : null,
|
|
87
|
+
model.annotPos ? (React.createElement(AnnotationDialog, { data: model.annotPos, model: model, onClose: function () { return model.clearAnnotPos(); } })) : null));
|
|
88
|
+
});
|