react-msaview 1.3.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/bundle/index.js +283 -97265
  2. package/dist/StructureModel.d.ts +9 -0
  3. package/dist/StructureModel.js +11 -0
  4. package/dist/StructureModel.js.map +1 -0
  5. package/dist/UniprotTrack.d.ts +27 -0
  6. package/dist/UniprotTrack.js +52 -0
  7. package/dist/UniprotTrack.js.map +1 -0
  8. package/dist/colorSchemes.d.ts +2 -2
  9. package/dist/colorSchemes.js +24 -29
  10. package/dist/colorSchemes.js.map +1 -0
  11. package/dist/components/AboutDlg.d.ts +0 -1
  12. package/dist/components/AboutDlg.js +38 -48
  13. package/dist/components/AboutDlg.js.map +1 -0
  14. package/dist/components/AddTrackDlg.d.ts +0 -1
  15. package/dist/components/AddTrackDlg.js +13 -13
  16. package/dist/components/AddTrackDlg.js.map +1 -0
  17. package/dist/components/AnnotationDlg.d.ts +0 -1
  18. package/dist/components/AnnotationDlg.js +36 -48
  19. package/dist/components/AnnotationDlg.js.map +1 -0
  20. package/dist/components/BoxTrack.d.ts +3 -4
  21. package/dist/components/BoxTrack.js +51 -48
  22. package/dist/components/BoxTrack.js.map +1 -0
  23. package/dist/components/DetailsDlg.d.ts +0 -1
  24. package/dist/components/DetailsDlg.js +7 -7
  25. package/dist/components/DetailsDlg.js.map +1 -0
  26. package/dist/components/Header.d.ts +0 -1
  27. package/dist/components/Header.js +39 -34
  28. package/dist/components/Header.js.map +1 -0
  29. package/dist/components/ImportForm.d.ts +0 -1
  30. package/dist/components/ImportForm.js +59 -71
  31. package/dist/components/ImportForm.js.map +1 -0
  32. package/dist/components/MSACanvas.d.ts +0 -1
  33. package/dist/components/MSACanvas.js +71 -74
  34. package/dist/components/MSACanvas.js.map +1 -0
  35. package/dist/components/MSAView.d.ts +0 -1
  36. package/dist/components/MSAView.js +19 -38
  37. package/dist/components/MSAView.js.map +1 -0
  38. package/dist/components/MoreInfoDlg.d.ts +2 -3
  39. package/dist/components/MoreInfoDlg.js +5 -5
  40. package/dist/components/MoreInfoDlg.js.map +1 -0
  41. package/dist/components/ResizeHandles.d.ts +2 -3
  42. package/dist/components/ResizeHandles.js +31 -32
  43. package/dist/components/ResizeHandles.js.map +1 -0
  44. package/dist/components/Rubberband.d.ts +2 -1
  45. package/dist/components/Rubberband.js +42 -64
  46. package/dist/components/Rubberband.js.map +1 -0
  47. package/dist/components/Ruler.d.ts +0 -15
  48. package/dist/components/Ruler.js +18 -87
  49. package/dist/components/Ruler.js.map +1 -0
  50. package/dist/components/SettingsDlg.d.ts +0 -1
  51. package/dist/components/SettingsDlg.js +29 -22
  52. package/dist/components/SettingsDlg.js.map +1 -0
  53. package/dist/components/TextTrack.d.ts +3 -4
  54. package/dist/components/TextTrack.js +23 -24
  55. package/dist/components/TextTrack.js.map +1 -0
  56. package/dist/components/Track.d.ts +2 -3
  57. package/dist/components/Track.js +38 -38
  58. package/dist/components/Track.js.map +1 -0
  59. package/dist/components/TrackInfoDlg.d.ts +5 -3
  60. package/dist/components/TrackInfoDlg.js +12 -13
  61. package/dist/components/TrackInfoDlg.js.map +1 -0
  62. package/dist/components/TracklistDlg.d.ts +0 -1
  63. package/dist/components/TracklistDlg.js +9 -9
  64. package/dist/components/TracklistDlg.js.map +1 -0
  65. package/dist/components/TreeCanvas.d.ts +0 -1
  66. package/dist/components/TreeCanvas.js +135 -148
  67. package/dist/components/TreeCanvas.js.map +1 -0
  68. package/dist/components/TreeRuler.d.ts +0 -1
  69. package/dist/components/TreeRuler.js +3 -3
  70. package/dist/components/TreeRuler.js.map +1 -0
  71. package/dist/components/VerticalGuide.d.ts +6 -0
  72. package/dist/components/VerticalGuide.js +30 -0
  73. package/dist/components/VerticalGuide.js.map +1 -0
  74. package/dist/components/data/seq2.d.ts +3 -3
  75. package/dist/components/data/seq2.js +33 -3
  76. package/dist/components/data/seq2.js.map +1 -0
  77. package/{bundle/components/Ruler.d.ts → dist/components/util.d.ts} +1 -6
  78. package/dist/components/util.js +69 -0
  79. package/dist/components/util.js.map +1 -0
  80. package/dist/index.d.ts +2 -4
  81. package/dist/index.js +3 -3
  82. package/dist/index.js.map +1 -0
  83. package/dist/layout.js +14 -20
  84. package/dist/layout.js.map +1 -0
  85. package/dist/model.d.ts +94 -74
  86. package/dist/model.js +232 -473
  87. package/dist/model.js.map +1 -0
  88. package/dist/parseNewick.d.ts +1 -5
  89. package/dist/parseNewick.js +10 -7
  90. package/dist/parseNewick.js.map +1 -0
  91. package/dist/parsers/ClustalMSA.d.ts +6 -18
  92. package/dist/parsers/ClustalMSA.js +55 -64
  93. package/dist/parsers/ClustalMSA.js.map +1 -0
  94. package/dist/parsers/FastaMSA.d.ts +4 -9
  95. package/dist/parsers/FastaMSA.js +55 -64
  96. package/dist/parsers/FastaMSA.js.map +1 -0
  97. package/dist/parsers/StockholmMSA.d.ts +8 -13
  98. package/dist/parsers/StockholmMSA.js +78 -107
  99. package/dist/parsers/StockholmMSA.js.map +1 -0
  100. package/dist/util.d.ts +33 -4
  101. package/dist/util.js +76 -24
  102. package/dist/util.js.map +1 -0
  103. package/dist/version.d.ts +1 -0
  104. package/dist/version.js +2 -0
  105. package/dist/version.js.map +1 -0
  106. package/package.json +30 -30
  107. package/src/StructureModel.ts +11 -0
  108. package/src/UniprotTrack.ts +60 -0
  109. package/src/colorSchemes.ts +520 -0
  110. package/src/components/AboutDlg.tsx +64 -0
  111. package/src/components/AddTrackDlg.tsx +74 -0
  112. package/src/components/AnnotationDlg.tsx +144 -0
  113. package/src/components/BoxTrack.tsx +225 -0
  114. package/src/components/DetailsDlg.tsx +28 -0
  115. package/src/components/Header.tsx +117 -0
  116. package/src/components/ImportForm.tsx +192 -0
  117. package/src/components/MSACanvas.tsx +297 -0
  118. package/src/components/MSAView.tsx +132 -0
  119. package/src/components/MoreInfoDlg.tsx +21 -0
  120. package/src/components/ResizeHandles.tsx +137 -0
  121. package/src/components/Rubberband.tsx +271 -0
  122. package/src/components/Ruler.tsx +122 -0
  123. package/src/components/SettingsDlg.tsx +154 -0
  124. package/src/components/TextTrack.tsx +120 -0
  125. package/src/components/Track.tsx +150 -0
  126. package/src/components/TrackInfoDlg.tsx +59 -0
  127. package/src/components/TracklistDlg.tsx +61 -0
  128. package/src/components/TreeCanvas.tsx +633 -0
  129. package/src/components/TreeRuler.tsx +12 -0
  130. package/src/components/VerticalGuide.tsx +50 -0
  131. package/src/components/data/seq2.ts +35 -0
  132. package/src/components/util.ts +94 -0
  133. package/src/declare.d.ts +2 -0
  134. package/src/index.ts +2 -0
  135. package/src/layout.ts +83 -0
  136. package/src/model.ts +790 -0
  137. package/{bundle/parseNewick.d.ts → src/parseNewick.ts} +36 -5
  138. package/src/parsers/ClustalMSA.ts +79 -0
  139. package/src/parsers/FastaMSA.ts +82 -0
  140. package/src/parsers/StockholmMSA.ts +137 -0
  141. package/src/util.ts +142 -0
  142. package/src/version.ts +1 -0
  143. package/bundle/colorSchemes.d.ts +0 -16
  144. package/bundle/colorSchemes.js +0 -455
  145. package/bundle/components/AboutDlg.d.ts +0 -5
  146. package/bundle/components/AboutDlg.js +0 -47
  147. package/bundle/components/AddTrackDlg.d.ts +0 -8
  148. package/bundle/components/AddTrackDlg.js +0 -26
  149. package/bundle/components/AnnotationDlg.d.ts +0 -11
  150. package/bundle/components/AnnotationDlg.js +0 -77
  151. package/bundle/components/BoxTrack.d.ts +0 -7
  152. package/bundle/components/BoxTrack.js +0 -143
  153. package/bundle/components/DetailsDlg.d.ts +0 -8
  154. package/bundle/components/DetailsDlg.js +0 -12
  155. package/bundle/components/Header.d.ts +0 -6
  156. package/bundle/components/Header.js +0 -63
  157. package/bundle/components/ImportForm.d.ts +0 -6
  158. package/bundle/components/ImportForm.js +0 -89
  159. package/bundle/components/MSACanvas.d.ts +0 -6
  160. package/bundle/components/MSACanvas.js +0 -210
  161. package/bundle/components/MSAView.d.ts +0 -6
  162. package/bundle/components/MSAView.js +0 -88
  163. package/bundle/components/MoreInfoDlg.d.ts +0 -6
  164. package/bundle/components/MoreInfoDlg.js +0 -11
  165. package/bundle/components/ResizeHandles.d.ts +0 -8
  166. package/bundle/components/ResizeHandles.js +0 -110
  167. package/bundle/components/Rubberband.d.ts +0 -7
  168. package/bundle/components/Rubberband.js +0 -196
  169. package/bundle/components/Ruler.js +0 -121
  170. package/bundle/components/SettingsDlg.d.ts +0 -8
  171. package/bundle/components/SettingsDlg.js +0 -40
  172. package/bundle/components/TextTrack.d.ts +0 -7
  173. package/bundle/components/TextTrack.js +0 -72
  174. package/bundle/components/Track.d.ts +0 -11
  175. package/bundle/components/Track.js +0 -81
  176. package/bundle/components/TrackInfoDlg.d.ts +0 -6
  177. package/bundle/components/TrackInfoDlg.js +0 -33
  178. package/bundle/components/TracklistDlg.d.ts +0 -8
  179. package/bundle/components/TracklistDlg.js +0 -18
  180. package/bundle/components/TreeCanvas.d.ts +0 -6
  181. package/bundle/components/TreeCanvas.js +0 -431
  182. package/bundle/components/TreeRuler.d.ts +0 -6
  183. package/bundle/components/TreeRuler.js +0 -8
  184. package/bundle/components/data/seq2.d.ts +0 -3
  185. package/bundle/components/data/seq2.js +0 -3
  186. package/bundle/index.d.ts +0 -4
  187. package/bundle/layout.d.ts +0 -23
  188. package/bundle/layout.js +0 -53
  189. package/bundle/model.d.ts +0 -364
  190. package/bundle/model.js +0 -894
  191. package/bundle/parseNewick.js +0 -94
  192. package/bundle/parsers/ClustalMSA.d.ts +0 -39
  193. package/bundle/parsers/ClustalMSA.js +0 -77
  194. package/bundle/parsers/FastaMSA.d.ts +0 -26
  195. package/bundle/parsers/FastaMSA.js +0 -78
  196. package/bundle/parsers/StockholmMSA.d.ts +0 -75
  197. package/bundle/parsers/StockholmMSA.js +0 -142
  198. package/bundle/util.d.ts +0 -17
  199. package/bundle/util.js +0 -33
  200. package/dist/components/package.json +0 -62
@@ -1,81 +0,0 @@
1
- import React, { useState, useRef, useEffect } from 'react';
2
- import normalizeWheel from 'normalize-wheel';
3
- import { observer } from 'mobx-react';
4
- import { IconButton, Menu, MenuItem, makeStyles } from '@material-ui/core';
5
- import ArrowDropDownIcon from '@material-ui/icons/ArrowDropDown';
6
- import TrackInfoDialog from './TrackInfoDlg';
7
- var useStyles = makeStyles(function () { return ({
8
- button: {
9
- padding: 0,
10
- },
11
- }); });
12
- export var TrackLabel = observer(function (_a) {
13
- var model = _a.model, track = _a.track;
14
- var _b = useState(), anchorEl = _b[0], setAnchorEl = _b[1];
15
- var _c = useState(false), trackInfoDlgOpen = _c[0], setTrackInfoDlgOpen = _c[1];
16
- var rowHeight = model.rowHeight, width = model.treeAreaWidth;
17
- var height = track.height, name = track.model.name;
18
- var classes = useStyles();
19
- var trackLabelHeight = Math.max(8, rowHeight - 8);
20
- return (React.createElement("div", { style: {
21
- width: width,
22
- height: height,
23
- flexShrink: 0,
24
- textAlign: 'right',
25
- fontSize: trackLabelHeight,
26
- } },
27
- name,
28
- React.createElement(IconButton, { className: classes.button, style: { width: trackLabelHeight, height: trackLabelHeight }, onClick: function (event) {
29
- setAnchorEl(event.target);
30
- } },
31
- React.createElement(ArrowDropDownIcon, null)),
32
- anchorEl ? (React.createElement(Menu, { anchorEl: anchorEl, transitionDuration: 0, open: true, onClose: function () {
33
- setAnchorEl(undefined);
34
- } },
35
- React.createElement(MenuItem, { dense: true, onClick: function () {
36
- model.toggleTrack(track.model.id);
37
- setAnchorEl(undefined);
38
- } }, "Close"),
39
- React.createElement(MenuItem, { dense: true, onClick: function () {
40
- setTrackInfoDlgOpen(true);
41
- setAnchorEl(undefined);
42
- } }, "Get info"))) : null,
43
- trackInfoDlgOpen ? (React.createElement(TrackInfoDialog, { model: track.model, onClose: function () { return setTrackInfoDlgOpen(false); } })) : null));
44
- });
45
- var Track = observer(function (_a) {
46
- var model = _a.model, track = _a.track;
47
- var resizeHandleWidth = model.resizeHandleWidth;
48
- var height = track.model.height;
49
- var ref = useRef(null);
50
- var scheduled = useRef(false);
51
- var deltaX = useRef(0);
52
- useEffect(function () {
53
- var curr = ref.current;
54
- if (!curr) {
55
- return;
56
- }
57
- function onWheel(origEvent) {
58
- var event = normalizeWheel(origEvent);
59
- deltaX.current += event.pixelX;
60
- if (!scheduled.current) {
61
- scheduled.current = true;
62
- requestAnimationFrame(function () {
63
- model.doScrollX(-deltaX.current);
64
- deltaX.current = 0;
65
- scheduled.current = false;
66
- });
67
- }
68
- origEvent.preventDefault();
69
- }
70
- curr.addEventListener('wheel', onWheel);
71
- return function () {
72
- curr.removeEventListener('wheel', onWheel);
73
- };
74
- }, [model]);
75
- return (React.createElement("div", { key: track.id, style: { display: 'flex', height: height } },
76
- React.createElement(TrackLabel, { model: model, track: track }),
77
- React.createElement("div", { style: { width: resizeHandleWidth, flexShrink: 0 } }),
78
- React.createElement("div", { ref: ref },
79
- React.createElement(track.ReactComponent, { model: model, track: track }))));
80
- });
81
- export default Track;
@@ -1,6 +0,0 @@
1
- /// <reference types="react" />
2
- declare const TrackInfoDialog: ({ model, onClose }: {
3
- model: any;
4
- onClose: () => void;
5
- }) => JSX.Element;
6
- export default TrackInfoDialog;
@@ -1,33 +0,0 @@
1
- import React, { useState } from 'react';
2
- import copy from 'copy-to-clipboard';
3
- import { observer } from 'mobx-react';
4
- import { Button, Dialog, DialogActions, DialogTitle, DialogContent, makeStyles, } from '@material-ui/core';
5
- var useStyles = makeStyles(function (theme) { return ({
6
- textArea: {
7
- padding: theme.spacing(2),
8
- overflow: 'auto',
9
- background: '#ddd',
10
- wordBreak: 'break-word',
11
- },
12
- }); });
13
- var TrackInfoDialog = observer(function (_a) {
14
- var model = _a.model, onClose = _a.onClose;
15
- var _b = useState('Copy to clipboard'), label = _b[0], setLabel = _b[1];
16
- var classes = useStyles();
17
- return (React.createElement(Dialog, { open: true, onClose: onClose, fullWidth: true, maxWidth: "lg" },
18
- React.createElement(DialogTitle, null,
19
- "Track info - ",
20
- model.name),
21
- React.createElement(DialogContent, null,
22
- React.createElement(Button, { variant: "contained", color: "primary", onClick: function () {
23
- copy(model.data);
24
- setLabel('Copied!');
25
- setTimeout(function () {
26
- setLabel('Copy to clipboard');
27
- }, 300);
28
- } }, label),
29
- React.createElement("pre", { className: classes.textArea }, model.data)),
30
- React.createElement(DialogActions, null,
31
- React.createElement(Button, { variant: "contained", onClick: onClose, color: "secondary" }, "Close"))));
32
- });
33
- export default TrackInfoDialog;
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- import { MsaViewModel } from '../model';
3
- declare const _default: ({ model, onClose, open, }: {
4
- model: MsaViewModel;
5
- onClose: () => void;
6
- open: boolean;
7
- }) => JSX.Element;
8
- export default _default;
@@ -1,18 +0,0 @@
1
- import React from 'react';
2
- import { Dialog, DialogTitle, DialogContent, FormControlLabel, FormGroup, Checkbox, DialogActions, Button, Typography, } from '@material-ui/core';
3
- import { observer } from 'mobx-react';
4
- export default observer(function (_a) {
5
- var model = _a.model, onClose = _a.onClose, open = _a.open;
6
- var tracks = model.tracks;
7
- return (React.createElement(Dialog, { onClose: function () { return onClose(); }, open: open },
8
- React.createElement(DialogTitle, null, "Add track"),
9
- React.createElement(DialogContent, null,
10
- React.createElement(Typography, null, "Open relevant per-alignment tracks e.g. protein domains"),
11
- React.createElement(FormGroup, null, tracks.map(function (track) {
12
- return (React.createElement(FormControlLabel, { key: track.model.id, control: React.createElement(Checkbox, { checked: !model.turnedOffTracks.has(track.model.id), onChange: function () {
13
- model.toggleTrack(track.model.id);
14
- } }), label: track.model.name }));
15
- })),
16
- React.createElement(DialogActions, null,
17
- React.createElement(Button, { onClick: function () { return onClose(); }, variant: "contained", color: "primary" }, "Close")))));
18
- });
@@ -1,6 +0,0 @@
1
- /// <reference types="react" />
2
- import { MsaViewModel } from '../model';
3
- declare const TreeCanvas: ({ model }: {
4
- model: MsaViewModel;
5
- }) => JSX.Element;
6
- export default TreeCanvas;
@@ -1,431 +0,0 @@
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, { useEffect, useRef, useState } from 'react';
13
- import { Menu, MenuItem } from '@material-ui/core';
14
- import normalizeWheel from 'normalize-wheel';
15
- import { observer } from 'mobx-react';
16
- import RBush from 'rbush';
17
- import MoreInfoDlg from './MoreInfoDlg';
18
- var extendBounds = 5;
19
- var radius = 3.5;
20
- var d = radius * 2;
21
- var padding = 600;
22
- var TreeMenu = observer(function (_a) {
23
- var _b, _c;
24
- var node = _a.node, onClose = _a.onClose, model = _a.model;
25
- var structures = model.structures;
26
- var nodeDetails = node ? model.getRowDetails(node.name) : undefined;
27
- return (React.createElement(React.Fragment, null,
28
- React.createElement(Menu, { anchorReference: "anchorPosition", anchorPosition: {
29
- top: node.y,
30
- left: node.x,
31
- }, transitionDuration: 0, keepMounted: true, open: Boolean(node), onClose: onClose },
32
- React.createElement(MenuItem, { dense: true, disabled: true }, node.name),
33
- React.createElement(MenuItem, { dense: true, onClick: function () {
34
- model.setDialogComponent(MoreInfoDlg, {
35
- info: model.getRowDetails(node.name),
36
- });
37
- onClose();
38
- } }, "More info..."), (_b = structures[node.name]) === null || _b === void 0 ? void 0 :
39
- _b.map(function (entry) {
40
- return !model.selectedStructures.find(function (n) { return n.id === node.name; }) ? (React.createElement(MenuItem, { key: JSON.stringify(entry), dense: true, onClick: function () {
41
- model.addStructureToSelection({
42
- structure: entry,
43
- id: node.name,
44
- });
45
- onClose();
46
- } },
47
- "Add PDB to selection (",
48
- entry.pdb,
49
- ")")) : (React.createElement(MenuItem, { key: JSON.stringify(entry), dense: true, onClick: function () {
50
- model.removeStructureFromSelection({
51
- structure: entry,
52
- id: node.name,
53
- });
54
- onClose();
55
- } },
56
- "Remove PDB from selection (",
57
- entry.pdb,
58
- ")"));
59
- }), (_c = nodeDetails.accession) === null || _c === void 0 ? void 0 :
60
- _c.map(function (accession) { return (React.createElement(MenuItem, { dense: true, key: accession, onClick: function () {
61
- model.addUniprotTrack({ name: nodeDetails.name, accession: accession });
62
- onClose();
63
- } },
64
- "Open UniProt track (",
65
- accession,
66
- ")")); }))));
67
- });
68
- var TreeBranchMenu = observer(function (_a) {
69
- var node = _a.node, model = _a.model, onClose = _a.onClose;
70
- return (React.createElement(Menu, { anchorReference: "anchorPosition", anchorPosition: {
71
- left: node.x,
72
- top: node.y,
73
- }, transitionDuration: 0, keepMounted: true, open: Boolean(node), onClose: onClose },
74
- React.createElement(MenuItem, { dense: true, disabled: true }, node.name),
75
- React.createElement(MenuItem, { dense: true, onClick: function () {
76
- model.toggleCollapsed(node.id);
77
- onClose();
78
- } }, model.collapsed.includes(node.id)
79
- ? 'Expand this node'
80
- : 'Collapse this node'),
81
- React.createElement(MenuItem, { dense: true, onClick: function () {
82
- model.showOnly === node.id
83
- ? model.setShowOnly(undefined)
84
- : model.setShowOnly(node.id);
85
- onClose();
86
- } }, model.showOnly === node.id
87
- ? 'Disable show only this node'
88
- : 'Show only this node')));
89
- });
90
- var TreeBlock = observer(function (_a) {
91
- var model = _a.model, offsetY = _a.offsetY;
92
- var ref = useRef(null);
93
- var clickMap = useRef(new RBush());
94
- var mouseoverRef = useRef(null);
95
- var _b = useState(), branchMenu = _b[0], setBranchMenu = _b[1];
96
- var _c = useState(), toggleNodeMenu = _c[0], setToggleNodeMenu = _c[1];
97
- var _d = useState(), hoverElt = _d[0], setHoverElt = _d[1];
98
- var hierarchy = model.hierarchy, rowHeight = model.rowHeight, scrollY = model.scrollY, treeWidth = model.treeWidth, showBranchLen = model.showBranchLen, collapsed = model.collapsed, margin = model.margin, labelsAlignRight = model.labelsAlignRight, noTree = model.noTree, blockSize = model.blockSize, drawNodeBubbles = model.drawNodeBubbles, drawTree = model.drawTree, treeAreaWidth = model.treeAreaWidth, structures = model.structures, highResScaleFactor = model.highResScaleFactor;
99
- useEffect(function () {
100
- clickMap.current.clear();
101
- if (!ref.current) {
102
- return;
103
- }
104
- var ctx = ref.current.getContext('2d');
105
- if (!ctx) {
106
- return;
107
- }
108
- ctx.resetTransform();
109
- ctx.scale(highResScaleFactor, highResScaleFactor);
110
- ctx.clearRect(0, 0, treeWidth + padding, blockSize);
111
- ctx.translate(margin.left, -offsetY);
112
- var font = ctx.font;
113
- ctx.font = font.replace(/\d+px/, Math.max(8, rowHeight - 8) + "px");
114
- if (!noTree && drawTree) {
115
- hierarchy.links().forEach(function (_a) {
116
- var source = _a.source, target = _a.target;
117
- var y = showBranchLen ? 'len' : 'y';
118
- //@ts-ignore
119
- var _b = source, sy = _b.x, _c = y, sx = _b[_c];
120
- //@ts-ignore
121
- var _d = target, ty = _d.x, _e = y, tx = _d[_e];
122
- var y1 = Math.min(sy, ty);
123
- var y2 = Math.max(sy, ty);
124
- //1d line intersection to check if line crosses block at all, this is
125
- //an optimization that allows us to skip drawing most tree links
126
- //outside the block
127
- if (offsetY + blockSize >= y1 && y2 >= offsetY) {
128
- ctx.beginPath();
129
- ctx.moveTo(sx, sy);
130
- ctx.lineTo(sx, ty);
131
- ctx.lineTo(tx, ty);
132
- ctx.stroke();
133
- }
134
- });
135
- if (drawNodeBubbles) {
136
- hierarchy.descendants().forEach(function (node) {
137
- var val = showBranchLen ? 'len' : 'y';
138
- var _a = node,
139
- //@ts-ignore
140
- y = _a.x,
141
- //@ts-ignore
142
- _b = val,
143
- //@ts-ignore
144
- x = _a[_b], data = _a.data;
145
- var _c = data.id, id = _c === void 0 ? '' : _c, _d = data.name, name = _d === void 0 ? '' : _d;
146
- if (y > offsetY - extendBounds &&
147
- y < offsetY + blockSize + extendBounds) {
148
- ctx.strokeStyle = 'black';
149
- ctx.fillStyle = collapsed.includes(id) ? 'black' : 'white';
150
- ctx.beginPath();
151
- ctx.arc(x, y, radius, 0, 2 * Math.PI);
152
- ctx.fill();
153
- ctx.stroke();
154
- clickMap.current.insert({
155
- minX: x - radius,
156
- maxX: x - radius + d,
157
- minY: y - radius,
158
- maxY: y - radius + d,
159
- branch: true,
160
- id: id,
161
- name: name,
162
- });
163
- }
164
- });
165
- }
166
- }
167
- if (rowHeight >= 10) {
168
- if (labelsAlignRight) {
169
- ctx.textAlign = 'right';
170
- ctx.setLineDash([1, 3]);
171
- }
172
- else {
173
- ctx.textAlign = 'start';
174
- }
175
- hierarchy.leaves().forEach(function (node) {
176
- var
177
- //@ts-ignore
178
- y = node.x,
179
- //@ts-ignore
180
- x = node.y, _a = node.data, name = _a.name, id = _a.id,
181
- //@ts-ignore
182
- len = node.len;
183
- if (y > offsetY - extendBounds &&
184
- y < offsetY + blockSize + extendBounds) {
185
- //note: +rowHeight/4 matches with -rowHeight/4 in msa
186
- var yp = y + rowHeight / 4;
187
- var xp = showBranchLen ? len : x;
188
- var width = ctx.measureText(name).width;
189
- var height = ctx.measureText('M').width; // use an 'em' for height
190
- var hasStructure = structures[name];
191
- ctx.fillStyle = hasStructure ? 'blue' : 'black';
192
- if (!drawTree && !labelsAlignRight) {
193
- ctx.fillText(name, 0, yp);
194
- clickMap.current.insert({
195
- minX: 0,
196
- maxX: width,
197
- minY: yp - height,
198
- maxY: yp,
199
- name: name,
200
- id: id,
201
- });
202
- }
203
- else if (labelsAlignRight) {
204
- var smallPadding = 2;
205
- var offset = treeAreaWidth - smallPadding - margin.left;
206
- if (drawTree && !noTree) {
207
- var width_1 = ctx.measureText(name).width;
208
- ctx.moveTo(xp + radius + 2, y);
209
- ctx.lineTo(offset - smallPadding - width_1, y);
210
- ctx.stroke();
211
- }
212
- ctx.fillText(name, offset, yp);
213
- clickMap.current.insert({
214
- minX: treeAreaWidth - margin.left - width,
215
- maxX: treeAreaWidth - margin.left,
216
- minY: yp - height,
217
- maxY: yp,
218
- name: name,
219
- id: id,
220
- });
221
- }
222
- else {
223
- ctx.fillText(name, xp + d, yp);
224
- clickMap.current.insert({
225
- minX: xp + d,
226
- maxX: xp + d + width,
227
- minY: yp - height,
228
- maxY: yp,
229
- name: name,
230
- id: id,
231
- });
232
- }
233
- }
234
- });
235
- ctx.setLineDash([]);
236
- }
237
- }, [
238
- collapsed,
239
- rowHeight,
240
- margin.left,
241
- hierarchy,
242
- offsetY,
243
- treeWidth,
244
- showBranchLen,
245
- noTree,
246
- blockSize,
247
- drawNodeBubbles,
248
- drawTree,
249
- labelsAlignRight,
250
- treeAreaWidth,
251
- structures,
252
- ]);
253
- useEffect(function () {
254
- var canvas = mouseoverRef.current;
255
- if (!canvas) {
256
- return;
257
- }
258
- var ctx = canvas.getContext('2d');
259
- if (!ctx) {
260
- return;
261
- }
262
- ctx.resetTransform();
263
- ctx.clearRect(0, 0, treeWidth + padding, blockSize);
264
- ctx.translate(margin.left, -offsetY);
265
- if (hoverElt) {
266
- var minX = hoverElt.minX, maxX = hoverElt.maxX, minY = hoverElt.minY, maxY = hoverElt.maxY;
267
- ctx.fillStyle = 'rgba(0,0,0,0.1)';
268
- ctx.fillRect(minX, minY, maxX - minX, maxY - minY);
269
- }
270
- }, [hoverElt, margin.left, offsetY, blockSize, treeWidth]);
271
- function hoverBranchClickMap(event) {
272
- var x = event.nativeEvent.offsetX - margin.left;
273
- var y = event.nativeEvent.offsetY;
274
- var entry = clickMap.current.search({
275
- minX: x,
276
- maxX: x + 1,
277
- minY: y + offsetY,
278
- maxY: y + 1 + offsetY,
279
- })[0];
280
- return entry && entry.branch
281
- ? __assign(__assign({}, entry), { x: event.clientX, y: event.clientY }) : undefined;
282
- }
283
- function hoverNameClickMap(event) {
284
- var x = event.nativeEvent.offsetX - margin.left;
285
- var y = event.nativeEvent.offsetY;
286
- var entry = clickMap.current.search({
287
- minX: x,
288
- maxX: x + 1,
289
- minY: y + offsetY,
290
- maxY: y + 1 + offsetY,
291
- })[0];
292
- return entry && !entry.branch
293
- ? __assign(__assign({}, entry), { x: event.clientX, y: event.clientY }) : undefined;
294
- }
295
- return (React.createElement(React.Fragment, null,
296
- (branchMenu === null || branchMenu === void 0 ? void 0 : branchMenu.id) ? (React.createElement(TreeBranchMenu, { node: branchMenu, model: model, onClose: function () { return setBranchMenu(undefined); } })) : null,
297
- (toggleNodeMenu === null || toggleNodeMenu === void 0 ? void 0 : toggleNodeMenu.id) ? (React.createElement(TreeMenu, { node: toggleNodeMenu, model: model, onClose: function () { return setToggleNodeMenu(undefined); } })) : null,
298
- React.createElement("canvas", { width: (treeWidth + padding) * highResScaleFactor, height: blockSize * highResScaleFactor, style: {
299
- width: treeWidth + padding,
300
- height: blockSize,
301
- top: scrollY + offsetY,
302
- left: 0,
303
- position: 'absolute',
304
- }, onMouseMove: function (event) {
305
- if (!ref.current) {
306
- return;
307
- }
308
- var ret = hoverNameClickMap(event) || hoverBranchClickMap(event);
309
- if (ret) {
310
- ref.current.style.cursor = 'pointer';
311
- }
312
- else {
313
- ref.current.style.cursor = 'default';
314
- }
315
- setHoverElt(hoverNameClickMap(event));
316
- }, onClick: function (event) {
317
- var x = event.clientX, y = event.clientY;
318
- var data = hoverBranchClickMap(event);
319
- if (data === null || data === void 0 ? void 0 : data.id) {
320
- setBranchMenu(__assign(__assign({}, data), { x: x, y: y }));
321
- }
322
- var data2 = hoverNameClickMap(event);
323
- if (data2 === null || data2 === void 0 ? void 0 : data2.id) {
324
- setToggleNodeMenu(__assign(__assign({}, data2), { x: x, y: y }));
325
- }
326
- }, ref: ref }),
327
- React.createElement("canvas", { style: {
328
- width: treeWidth + padding,
329
- height: blockSize,
330
- top: scrollY + offsetY,
331
- left: 0,
332
- position: 'absolute',
333
- pointerEvents: 'none',
334
- zIndex: 100,
335
- }, width: treeWidth + padding, height: blockSize, ref: mouseoverRef })));
336
- });
337
- var TreeCanvas = observer(function (_a) {
338
- var model = _a.model;
339
- var ref = useRef(null);
340
- var scheduled = useRef(false);
341
- var deltaY = useRef(0);
342
- var prevY = useRef(0);
343
- var treeWidth = model.treeWidth, height = model.height, blocksY = model.blocksY;
344
- var _b = useState(false), mouseDragging = _b[0], setMouseDragging = _b[1];
345
- useEffect(function () {
346
- var curr = ref.current;
347
- if (!curr) {
348
- return;
349
- }
350
- function onWheel(origEvent) {
351
- var event = normalizeWheel(origEvent);
352
- deltaY.current += event.pixelY;
353
- if (!scheduled.current) {
354
- scheduled.current = true;
355
- requestAnimationFrame(function () {
356
- model.doScrollY(-deltaY.current);
357
- deltaY.current = 0;
358
- scheduled.current = false;
359
- });
360
- }
361
- origEvent.preventDefault();
362
- }
363
- curr.addEventListener('wheel', onWheel);
364
- return function () {
365
- curr.removeEventListener('wheel', onWheel);
366
- };
367
- }, [model]);
368
- useEffect(function () {
369
- var cleanup = function () { };
370
- function globalMouseMove(event) {
371
- event.preventDefault();
372
- var currY = event.clientY;
373
- var distanceY = currY - prevY.current;
374
- if (distanceY) {
375
- // use rAF to make it so multiple event handlers aren't fired per-frame
376
- // see https://calendar.perfplanet.com/2013/the-runtime-performance-checklist/
377
- if (!scheduled.current) {
378
- scheduled.current = true;
379
- window.requestAnimationFrame(function () {
380
- model.doScrollY(distanceY);
381
- scheduled.current = false;
382
- prevY.current = event.clientY;
383
- });
384
- }
385
- }
386
- }
387
- function globalMouseUp() {
388
- prevY.current = 0;
389
- if (mouseDragging) {
390
- setMouseDragging(false);
391
- }
392
- }
393
- if (mouseDragging) {
394
- window.addEventListener('mousemove', globalMouseMove, true);
395
- window.addEventListener('mouseup', globalMouseUp, true);
396
- cleanup = function () {
397
- window.removeEventListener('mousemove', globalMouseMove, true);
398
- window.removeEventListener('mouseup', globalMouseUp, true);
399
- };
400
- }
401
- return cleanup;
402
- }, [model, mouseDragging]);
403
- function mouseDown(event) {
404
- // check if clicking a draggable element or a resize handle
405
- var target = event.target;
406
- if (target.draggable || target.dataset.resizer) {
407
- return;
408
- }
409
- // otherwise do click and drag scroll
410
- if (event.button === 0) {
411
- prevY.current = event.clientY;
412
- setMouseDragging(true);
413
- }
414
- }
415
- // this local mouseup is used in addition to the global because sometimes
416
- // the global add/remove are not called in time, resulting in issue #533
417
- function mouseUp(event) {
418
- event.preventDefault();
419
- setMouseDragging(false);
420
- }
421
- function mouseLeave(event) {
422
- event.preventDefault();
423
- }
424
- return (React.createElement("div", { ref: ref, onMouseDown: mouseDown, onMouseUp: mouseUp, onMouseLeave: mouseLeave, style: {
425
- height: height,
426
- position: 'relative',
427
- overflow: 'hidden',
428
- width: treeWidth + padding,
429
- } }, blocksY.map(function (block) { return (React.createElement(TreeBlock, { key: block, model: model, offsetY: block })); })));
430
- });
431
- export default TreeCanvas;
@@ -1,6 +0,0 @@
1
- /// <reference types="react" />
2
- import { MsaViewModel } from '../model';
3
- declare const TreeRuler: ({ model }: {
4
- model: MsaViewModel;
5
- }) => JSX.Element;
6
- export default TreeRuler;
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- import { observer } from 'mobx-react';
3
- var TreeRuler = observer(function (_a) {
4
- var model = _a.model;
5
- var treeWidth = model.treeWidth;
6
- return React.createElement("div", { style: { width: treeWidth } });
7
- });
8
- export default TreeRuler;
@@ -1,3 +0,0 @@
1
- export const smallMSA: "CLUSTAL O(1.2.3) multiple sequence alignment\nUniProt/Swiss-Prot|P26898|IL2RA_SHEEP MEPSLLMWRFFVFIVVPGCVTEACHDDPPSLRNA----------MFKVLRYE----VGTM\nUniProt/Swiss-Prot|P01590|IL2RA_MOUSE MEPRLLMLGFLSLTIVPSCRAELCLYDPPEVPNA----------TFKALSYK----NGTI\nUniProt/Swiss-Prot|P41690|IL2RA_FELCA MEPSLLLWGILTFVVVHGHVTELCDENPPDIQHA----------TFKALTYK----TGTM\nUniProt/Swiss-Prot|P01589|IL2RA_HUMAN MDSYLLMWGLLTFIMVPGCQAELCDDDPPEIPHA----------TFKAMAYK----EGTM\nUniProt/Swiss-Prot|Q5MNY4|IL2RA_MACMU MDPYLLMWGLLTFITVPGCQAELCDDDPPKITHA----------TFKAVAYK----EGTM\nUniProt/Swiss-Prot|Q95118|IL2RG_BOVIN -----------------------------------LLMWGLLT-----------------\nUniProt/Swiss-Prot|P40321|IL2RG_CANFA MLKPPLPLRSLLFLQLSLLGVGLNSTVPMPNGNEDIT------PDFFLTATPSETLSVSS\nUniProt/Swiss-Prot|P26896|IL2RB_RAT MATVDLSWRLPLYILLLLLATT--------------------------------WVSAAV\nUniProt/Swiss-Prot|Q8BZM1|GLMN_MOUSE PLPLRSLLFLQLPLLGVGLNP------------------PLPLRSLLFLQLPLLGVGLNP\nUniProt/Swiss-Prot|P36835|IL2_CAPHI -----------LLGVGLNPKFLTP------------------------------------\nUniProt/Swiss-Prot|Q7JFM4|IL2_AOTVO MLKPPLPLRSLLFLQLPLLGVGLNPKFLTPSGNEDIGGKPGTGGDFFLTSTPAGTLDVST\nUniProt/Swiss-Prot|Q29416|IL2_CANFA --------------LFLQLSLLG-------------------------------------\n";
2
- export const smallMSAOnly: "CLUSTAL O(1.2.4) multiple sequence alignment\n\n\nsp|P69905|HBA_HUMAN MVLSPADKTNVKAAWGKVGAHAGEYGAEALERMFLSFPTTKTYFPHFDLSHGSAQVKGHG\t60\nsp|P01942|HBA_MOUSE MVLSGEDKSNIKAAWGKIGGHGAEYGAEALERMFASFPTTKTYFPHFDVSHGSAQVKGHG\t60\nsp|P13786|HBAZ_CAPHI MSLTRTERTIILSLWSKISTQADVIGTETLERLFSCYPQAKTYFPHFDLHSGSAQLRAHG\t60\n * *: ::: : : *.*:. :. *:*:***:* .:* :********: ****::.**\n\nsp|P69905|HBA_HUMAN KKVADALTNAVAHVDDMPNALSALSDLHAHKLRVDPVNFKLLSHCLLVTLAAHLPAEFTP\t120\nsp|P01942|HBA_MOUSE KKVADALASAAGHLDDLPGALSALSDLHAHKLRVDPVNFKLLSHCLLVTLASHHPADFTP\t120\nsp|P13786|HBAZ_CAPHI SKVVAAVGDAVKSIDNVTSALSKLSELHAYVLRVDPVNFKFLSHCLLVTLASHFPADFTA\t120\n .**. *: .*. :*:: .*** **:***: *********:**********:* **:**\n\nsp|P69905|HBA_HUMAN AVHASLDKFLASVSTVLTSKYR\t142\nsp|P01942|HBA_MOUSE AVHASLDKFLASVSTVLTSKYR\t142\nsp|P13786|HBAZ_CAPHI DAHAAWDKFLSIVSGVLTEKYR\t142\n .**: ****: ** ***.***";
3
- export const smallTree: "(((UniProt/Swiss-Prot|P26898|IL2RA_SHEEP:0.24036,(UniProt/Swiss-Prot|P41690|IL2RA_FELCA:0.17737,(UniProt/Swiss-Prot|P01589|IL2RA_HUMAN:0.03906,UniProt/Swiss-Prot|Q5MNY4|IL2RA_MACMU:0.03787):0.13033):0.04964):0.02189,UniProt/Swiss-Prot|P01590|IL2RA_MOUSE:0.23072):0.06814,(((UniProt/Swiss-Prot|Q95118|IL2RG_BOVIN:0.09600,UniProt/Swiss-Prot|P40321|IL2RG_CANFA:0.09845):0.25333,UniProt/Swiss-Prot|Q29416|IL2_CANFA:-0.35055):0.10231,(UniProt/Swiss-Prot|P26896|IL2RB_RAT:0.33631,UniProt/Swiss-Prot|Q7JFM4|IL2_AOTVO:-0.33631):0.10166):0.01607,(UniProt/Swiss-Prot|Q8BZM1|GLMN_MOUSE:0.32378,UniProt/Swiss-Prot|P36835|IL2_CAPHI:-0.32378):0.09999)";
@@ -1,3 +0,0 @@
1
- export var smallMSA = "CLUSTAL O(1.2.3) multiple sequence alignment\nUniProt/Swiss-Prot|P26898|IL2RA_SHEEP MEPSLLMWRFFVFIVVPGCVTEACHDDPPSLRNA----------MFKVLRYE----VGTM\nUniProt/Swiss-Prot|P01590|IL2RA_MOUSE MEPRLLMLGFLSLTIVPSCRAELCLYDPPEVPNA----------TFKALSYK----NGTI\nUniProt/Swiss-Prot|P41690|IL2RA_FELCA MEPSLLLWGILTFVVVHGHVTELCDENPPDIQHA----------TFKALTYK----TGTM\nUniProt/Swiss-Prot|P01589|IL2RA_HUMAN MDSYLLMWGLLTFIMVPGCQAELCDDDPPEIPHA----------TFKAMAYK----EGTM\nUniProt/Swiss-Prot|Q5MNY4|IL2RA_MACMU MDPYLLMWGLLTFITVPGCQAELCDDDPPKITHA----------TFKAVAYK----EGTM\nUniProt/Swiss-Prot|Q95118|IL2RG_BOVIN -----------------------------------LLMWGLLT-----------------\nUniProt/Swiss-Prot|P40321|IL2RG_CANFA MLKPPLPLRSLLFLQLSLLGVGLNSTVPMPNGNEDIT------PDFFLTATPSETLSVSS\nUniProt/Swiss-Prot|P26896|IL2RB_RAT MATVDLSWRLPLYILLLLLATT--------------------------------WVSAAV\nUniProt/Swiss-Prot|Q8BZM1|GLMN_MOUSE PLPLRSLLFLQLPLLGVGLNP------------------PLPLRSLLFLQLPLLGVGLNP\nUniProt/Swiss-Prot|P36835|IL2_CAPHI -----------LLGVGLNPKFLTP------------------------------------\nUniProt/Swiss-Prot|Q7JFM4|IL2_AOTVO MLKPPLPLRSLLFLQLPLLGVGLNPKFLTPSGNEDIGGKPGTGGDFFLTSTPAGTLDVST\nUniProt/Swiss-Prot|Q29416|IL2_CANFA --------------LFLQLSLLG-------------------------------------\n";
2
- export var smallMSAOnly = "CLUSTAL O(1.2.4) multiple sequence alignment\n\n\nsp|P69905|HBA_HUMAN MVLSPADKTNVKAAWGKVGAHAGEYGAEALERMFLSFPTTKTYFPHFDLSHGSAQVKGHG\t60\nsp|P01942|HBA_MOUSE MVLSGEDKSNIKAAWGKIGGHGAEYGAEALERMFASFPTTKTYFPHFDVSHGSAQVKGHG\t60\nsp|P13786|HBAZ_CAPHI MSLTRTERTIILSLWSKISTQADVIGTETLERLFSCYPQAKTYFPHFDLHSGSAQLRAHG\t60\n * *: ::: : : *.*:. :. *:*:***:* .:* :********: ****::.**\n\nsp|P69905|HBA_HUMAN KKVADALTNAVAHVDDMPNALSALSDLHAHKLRVDPVNFKLLSHCLLVTLAAHLPAEFTP\t120\nsp|P01942|HBA_MOUSE KKVADALASAAGHLDDLPGALSALSDLHAHKLRVDPVNFKLLSHCLLVTLASHHPADFTP\t120\nsp|P13786|HBAZ_CAPHI SKVVAAVGDAVKSIDNVTSALSKLSELHAYVLRVDPVNFKFLSHCLLVTLASHFPADFTA\t120\n .**. *: .*. :*:: .*** **:***: *********:**********:* **:**\n\nsp|P69905|HBA_HUMAN AVHASLDKFLASVSTVLTSKYR\t142\nsp|P01942|HBA_MOUSE AVHASLDKFLASVSTVLTSKYR\t142\nsp|P13786|HBAZ_CAPHI DAHAAWDKFLSIVSGVLTEKYR\t142\n .**: ****: ** ***.***";
3
- export var smallTree = '(((UniProt/Swiss-Prot|P26898|IL2RA_SHEEP:0.24036,(UniProt/Swiss-Prot|P41690|IL2RA_FELCA:0.17737,(UniProt/Swiss-Prot|P01589|IL2RA_HUMAN:0.03906,UniProt/Swiss-Prot|Q5MNY4|IL2RA_MACMU:0.03787):0.13033):0.04964):0.02189,UniProt/Swiss-Prot|P01590|IL2RA_MOUSE:0.23072):0.06814,(((UniProt/Swiss-Prot|Q95118|IL2RG_BOVIN:0.09600,UniProt/Swiss-Prot|P40321|IL2RG_CANFA:0.09845):0.25333,UniProt/Swiss-Prot|Q29416|IL2_CANFA:-0.35055):0.10231,(UniProt/Swiss-Prot|P26896|IL2RB_RAT:0.33631,UniProt/Swiss-Prot|Q7JFM4|IL2_AOTVO:-0.33631):0.10166):0.01607,(UniProt/Swiss-Prot|Q8BZM1|GLMN_MOUSE:0.32378,UniProt/Swiss-Prot|P36835|IL2_CAPHI:-0.32378):0.09999)';
package/bundle/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import MSAView from './components/MSAView';
2
- import MSAModel, { MsaViewModel } from './model';
3
- export { MSAModel, MSAView };
4
- export type { MsaViewModel };
@@ -1,23 +0,0 @@
1
- export default class Layout {
2
- rectangles: Map<string, {
3
- minY: number;
4
- maxY: number;
5
- minX: number;
6
- maxX: number;
7
- id: string;
8
- data: unknown;
9
- }>;
10
- maxHeightReached: boolean;
11
- private maxHeight;
12
- private rbush;
13
- private pTotalHeight;
14
- constructor({ maxHeight, }?: {
15
- maxHeight?: number;
16
- });
17
- /**
18
- * @returns top position for the rect, or Null if laying
19
- * out the rect would exceed maxHeighe
20
- */
21
- addRect(id: string, left: number, right: number, height: number, data: unknown): number | null;
22
- get totalHeight(): number;
23
- }