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,142 +1,113 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
1
  import Stockholm from 'stockholm-js';
13
2
  import parseNewick from '../parseNewick';
14
3
  import { generateNodeIds } from '../util';
15
- var StockholmMSA = /** @class */ (function () {
16
- function StockholmMSA(text, currentAlignment) {
17
- var res = Stockholm.parseAll(text);
4
+ export default class StockholmMSA {
5
+ constructor(text, currentAlignment) {
6
+ const res = Stockholm.parseAll(text);
18
7
  this.data = res;
19
8
  this.MSA = res[currentAlignment];
20
9
  }
21
- StockholmMSA.prototype.getMSA = function () {
10
+ getMSA() {
22
11
  return this.MSA;
23
- };
24
- StockholmMSA.prototype.getRow = function (name) {
12
+ }
13
+ getRow(name) {
25
14
  var _a, _b;
26
15
  return (_b = (_a = this.MSA) === null || _a === void 0 ? void 0 : _a.seqdata[name]) === null || _b === void 0 ? void 0 : _b.split('');
27
- };
28
- StockholmMSA.prototype.getWidth = function () {
16
+ }
17
+ getWidth() {
29
18
  var _a;
30
- var name = Object.keys((_a = this.MSA) === null || _a === void 0 ? void 0 : _a.seqdata)[0];
19
+ const name = Object.keys((_a = this.MSA) === null || _a === void 0 ? void 0 : _a.seqdata)[0];
31
20
  return this.getRow(name).length;
32
- };
33
- Object.defineProperty(StockholmMSA.prototype, "alignmentNames", {
34
- get: function () {
35
- return this.data.map(function (aln, index) { var _a; return ((_a = aln.gf.DE) === null || _a === void 0 ? void 0 : _a[0]) || "Alignment " + (index + 1); });
36
- },
37
- enumerable: false,
38
- configurable: true
39
- });
40
- StockholmMSA.prototype.getDetails = function () {
21
+ }
22
+ get alignmentNames() {
23
+ return this.data.map((aln, idx) => { var _a; return ((_a = aln.gf.DE) === null || _a === void 0 ? void 0 : _a[0]) || `Alignment ${idx + 1}`; });
24
+ }
25
+ getHeader() {
41
26
  var _a, _b;
42
27
  return {
43
28
  General: this.MSA.gf,
44
29
  Accessions: (_a = this.MSA.gs) === null || _a === void 0 ? void 0 : _a.AC,
45
30
  Dbxref: (_b = this.MSA.gs) === null || _b === void 0 ? void 0 : _b.DR,
46
31
  };
47
- };
48
- StockholmMSA.prototype.getRowDetails = function (rowName) {
32
+ }
33
+ getRowData(rowName) {
49
34
  var _a, _b;
50
35
  return {
51
36
  name: rowName,
52
37
  accession: (_a = this.MSA.gs) === null || _a === void 0 ? void 0 : _a.AC[rowName],
53
38
  dbxref: (_b = this.MSA.gs) === null || _b === void 0 ? void 0 : _b.DR[rowName],
54
39
  };
55
- };
56
- StockholmMSA.prototype.getNames = function () {
40
+ }
41
+ getNames() {
57
42
  return Object.keys(this.MSA.seqdata);
58
- };
59
- StockholmMSA.prototype.getSeqCoords = function () { };
60
- StockholmMSA.prototype.getStructures = function () {
43
+ }
44
+ getSeqCoords() { }
45
+ getStructures() {
61
46
  var _a;
62
- var pdbRegex = /PDB; +(\S+) +(\S); ([0-9]+)-([0-9]+)/;
63
- var ent = this.MSA;
64
- return Object.entries(((_a = ent.gs) === null || _a === void 0 ? void 0 : _a.DR) || {})
65
- .map(function (_a) {
66
- var id = _a[0], dr = _a[1];
67
- return [id, pdbRegex.exec(dr)];
68
- })
69
- .filter(function (item) { return !!item[1]; })
70
- .map(function (_a) {
71
- var id = _a[0], match = _a[1];
72
- var pdb = match[1].toLowerCase();
73
- var chain = match[2];
74
- var startPos = +match[3];
75
- var endPos = +match[4];
76
- return { id: id, pdb: pdb, chain: chain, startPos: startPos, endPos: endPos };
77
- })
78
- .reduce(function (a, b) {
79
- var id = b.id, rest = __rest(b, ["id"]);
80
- if (!a[id]) {
81
- a[id] = [];
47
+ const pdbRegex = /PDB; +(\S+) +(\S); ([0-9]+)-([0-9]+)/;
48
+ const ent = this.MSA;
49
+ const args = Object.entries(((_a = ent.gs) === null || _a === void 0 ? void 0 : _a.DR) || {})
50
+ .map(([id, dr]) => [id, pdbRegex.exec(dr)])
51
+ .filter((item) => !!item[1])
52
+ .map(([id, match]) => {
53
+ const pdb = match[1].toLowerCase();
54
+ const chain = match[2];
55
+ const startPos = +match[3];
56
+ const endPos = +match[4];
57
+ return { id, pdb, chain, startPos, endPos };
58
+ });
59
+ const ret = {};
60
+ for (const entry of args) {
61
+ const { id, ...rest } = entry;
62
+ if (!ret[id]) {
63
+ ret[id] = [];
82
64
  }
83
- a[id].push(rest);
84
- return a;
85
- }, {});
86
- };
87
- StockholmMSA.prototype.getTree = function () {
65
+ ret[id].push(rest);
66
+ }
67
+ return ret;
68
+ }
69
+ getTree() {
88
70
  var _a, _b, _c;
89
- var tree = (_c = (_b = (_a = this.MSA) === null || _a === void 0 ? void 0 : _a.gf) === null || _b === void 0 ? void 0 : _b.NH) === null || _c === void 0 ? void 0 : _c[0];
71
+ const tree = (_c = (_b = (_a = this.MSA) === null || _a === void 0 ? void 0 : _a.gf) === null || _b === void 0 ? void 0 : _b.NH) === null || _c === void 0 ? void 0 : _c[0];
90
72
  return tree
91
73
  ? generateNodeIds(parseNewick(tree))
92
74
  : {
93
75
  id: 'root',
76
+ name: 'root',
94
77
  noTree: true,
95
- branchset: this.getNames().map(function (name) { return ({
78
+ branchset: this.getNames().map(name => ({
96
79
  id: name,
97
- name: name,
98
- }); }),
80
+ branchset: [],
81
+ name,
82
+ })),
99
83
  };
100
- };
101
- Object.defineProperty(StockholmMSA.prototype, "seqConsensus", {
102
- get: function () {
103
- var _a;
104
- return (_a = this.MSA.gc) === null || _a === void 0 ? void 0 : _a.seq_cons;
105
- },
106
- enumerable: false,
107
- configurable: true
108
- });
109
- Object.defineProperty(StockholmMSA.prototype, "secondaryStructureConsensus", {
110
- get: function () {
111
- var _a;
112
- return (_a = this.MSA.gc) === null || _a === void 0 ? void 0 : _a.SS_cons;
113
- },
114
- enumerable: false,
115
- configurable: true
116
- });
117
- Object.defineProperty(StockholmMSA.prototype, "tracks", {
118
- get: function () {
119
- return [
120
- {
121
- id: 'seqConsensus',
122
- name: 'Sequence consensus',
123
- data: this.seqConsensus,
124
- customColorScheme: {},
125
- },
126
- {
127
- id: 'secondaryStruct',
128
- name: 'Secondary-structure',
129
- data: this.secondaryStructureConsensus,
130
- customColorScheme: {
131
- '>': 'pink',
132
- '<': 'lightblue',
133
- },
84
+ }
85
+ get seqConsensus() {
86
+ var _a;
87
+ return (_a = this.MSA.gc) === null || _a === void 0 ? void 0 : _a.seq_cons;
88
+ }
89
+ get secondaryStructureConsensus() {
90
+ var _a;
91
+ return (_a = this.MSA.gc) === null || _a === void 0 ? void 0 : _a.SS_cons;
92
+ }
93
+ get tracks() {
94
+ return [
95
+ {
96
+ id: 'seqConsensus',
97
+ name: 'Sequence consensus',
98
+ data: this.seqConsensus,
99
+ customColorScheme: {},
100
+ },
101
+ {
102
+ id: 'secondaryStruct',
103
+ name: 'Secondary-structure',
104
+ data: this.secondaryStructureConsensus,
105
+ customColorScheme: {
106
+ '>': 'pink',
107
+ '<': 'lightblue',
134
108
  },
135
- ];
136
- },
137
- enumerable: false,
138
- configurable: true
139
- });
140
- return StockholmMSA;
141
- }());
142
- export default StockholmMSA;
109
+ },
110
+ ];
111
+ }
112
+ }
113
+ //# sourceMappingURL=StockholmMSA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StockholmMSA.js","sourceRoot":"","sources":["../../src/parsers/StockholmMSA.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAA;AACpC,OAAO,WAAW,MAAM,gBAAgB,CAAA;AAExC,OAAO,EAAe,eAAe,EAAE,MAAM,SAAS,CAAA;AAiBtD,MAAM,CAAC,OAAO,OAAO,YAAY;IAI/B,YAAY,IAAY,EAAE,gBAAwB;QAChD,MAAM,GAAG,GAAG,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QACpC,IAAI,CAAC,IAAI,GAAG,GA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ierarchy';
2
+ import { Theme } from '@mui/material';
1
3
  export declare function transform<T>(obj: Record<string, T>, cb: (arg0: [string, T]) => [string, T]): {
2
4
  [k: string]: T;
3
5
  };
4
- export declare type Node = {
6
+ interface Node {
5
7
  branchset?: Node[];
6
- };
7
- export declare type NodeWithIds = {
8
+ name?: string;
9
+ [key: string]: unknown;
10
+ }
11
+ export type NodeWithIds = {
8
12
  id: string;
13
+ name: string;
9
14
  branchset: NodeWithIds[];
15
+ length?: number;
16
+ noTree?: boolean;
17
+ };
18
+ export type NodeWithIdsAndLength = {
19
+ id: string;
20
+ name: string;
21
+ branchset: NodeWithIdsAndLength[];
10
22
  noTree?: boolean;
23
+ length: number;
11
24
  };
12
25
  export declare function generateNodeIds(tree: Node, parent?: string, depth?: number): NodeWithIds;
13
26
  export declare function colorContrast(colorScheme: {
14
27
  [key: string]: string;
15
- }, theme: any): {
28
+ }, theme: Theme): {
16
29
  [k: string]: string;
17
30
  };
31
+ export declare function parseGFF(str?: string): {
32
+ seq_id: string;
33
+ source: string;
34
+ type: string;
35
+ start: number;
36
+ end: number;
37
+ score: number;
38
+ strand: string;
39
+ phase: string;
40
+ }[] | undefined;
41
+ export declare function skipBlanks(blanks: number[], arg: string | string[]): string;
42
+ export declare function setBrLength(d: HierarchyNode<NodeWithIds>, y0: number, k: number): void;
43
+ export declare function maxLength(d: HierarchyNode<NodeWithIds>): number;
44
+ export declare function collapse(d: HierarchyNode<NodeWithIds>): void;
45
+ export declare function clamp(min: number, num: number, max: number): number;
46
+ export {};
package/dist/util.js CHANGED
@@ -1,33 +1,85 @@
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
1
  import Color from 'color';
2
+ import { max } from 'd3-array';
13
3
  export function transform(obj, cb) {
14
4
  return Object.fromEntries(Object.entries(obj).map(cb));
15
5
  }
16
- export function generateNodeIds(tree, parent, depth) {
6
+ export function generateNodeIds(tree, parent = 'node', depth = 0) {
17
7
  var _a;
18
- if (parent === void 0) { parent = 'node'; }
19
- if (depth === void 0) { depth = 0; }
20
- var id = parent + "-" + depth;
21
- return __assign(__assign({}, tree), { id: id, branchset: ((_a = tree.branchset) === null || _a === void 0 ? void 0 : _a.map(function (b, i) {
22
- return generateNodeIds(b, id + "-" + i, depth + 1);
23
- })) || [] });
8
+ const id = `${parent}-${depth}`;
9
+ return {
10
+ ...tree,
11
+ id,
12
+ name: tree.name || id,
13
+ branchset: ((_a = tree.branchset) === null || _a === void 0 ? void 0 : _a.map((b, i) => generateNodeIds(b, `${id}-${i}`, depth + 1))) || [],
14
+ };
24
15
  }
25
16
  export function colorContrast(colorScheme, theme) {
26
- return transform(colorScheme, function (_a) {
27
- var letter = _a[0], color = _a[1];
28
- return [
29
- letter,
30
- theme.palette.getContrastText(Color(color).hex()),
31
- ];
17
+ return transform(colorScheme, ([letter, color]) => [
18
+ letter,
19
+ theme.palette.getContrastText(Color(color).hex()),
20
+ ]);
21
+ }
22
+ export function parseGFF(str) {
23
+ return str === null || str === void 0 ? void 0 : str.split('\n').map(f => f.trim()).filter(f => !!f && !f.startsWith('#')).map(f => {
24
+ const [seq_id, source, type, start, end, score, strand, phase, col9] = f.split('\t');
25
+ return {
26
+ seq_id,
27
+ source,
28
+ type,
29
+ start: +start,
30
+ end: +end,
31
+ score: +score,
32
+ strand,
33
+ phase,
34
+ ...Object.fromEntries(col9
35
+ .split(';')
36
+ .map(f => f.trim())
37
+ .filter(f => !!f)
38
+ .map(f => f.split('='))
39
+ .map(([key, val]) => [
40
+ key.trim(),
41
+ decodeURIComponent(val).trim().split(',').join(' '),
42
+ ])),
43
+ };
32
44
  });
33
45
  }
46
+ export function skipBlanks(blanks, arg) {
47
+ let s = '';
48
+ let b = 0;
49
+ for (let j = 0; j < arg.length; j++) {
50
+ if (j === blanks[b]) {
51
+ b++;
52
+ }
53
+ else {
54
+ s += arg[j];
55
+ }
56
+ }
57
+ return s;
58
+ }
59
+ export function setBrLength(d, y0, k) {
60
+ var _a;
61
+ // @ts-expect-error
62
+ d.len = (y0 += Math.max(d.data.length || 0, 0)) * k;
63
+ (_a = d.children) === null || _a === void 0 ? void 0 : _a.forEach(d => {
64
+ setBrLength(d, y0, k);
65
+ });
66
+ }
67
+ export function maxLength(d) {
68
+ return ((d.data.length || 1) + (d.children ? max(d.children, maxLength) || 0 : 0));
69
+ }
70
+ // Collapse the node and all it's children, from
71
+ // https://bl.ocks.org/d3noob/43a860bc0024792f8803bba8ca0d5ecd
72
+ export function collapse(d) {
73
+ if (d.children) {
74
+ // @ts-expect-error
75
+ d._children = d.children;
76
+ // @ts-expect-error
77
+ d._children.forEach(collapse);
78
+ // @ts-expect-error
79
+ d.children = null;
80
+ }
81
+ }
82
+ export function clamp(min, num, max) {
83
+ return Math.min(Math.max(num, min), max);
84
+ }
85
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAG9B,MAAM,UAAU,SAAS,CACvB,GAAsB,EACtB,EAAsC;IAEtC,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;AACxD,CAAC;AAwBD,MAAM,UAAU,eAAe,CAC7B,IAAU,EACV,MAAM,GAAG,MAAM,EACf,KAAK,GAAG,CAAC;;IAET,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,KAAK,EAAE,CAAA;IAE/B,OAAO;QACL,GAAG,IAAI;QACP,EAAE;QACF,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,EA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C,CAAC,CAAA;IACvB,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,CAA6B;IACrD,OAAO,CACL,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC1E,CAAA;AACH,CAAC;AAED,gDAAgD;AAChD,8DAA8D;AAC9D,MAAM,UAAU,QAAQ,CAAC,CAA6B;IACpD,IAAI,CAAC,CAAC,QAAQ,EAAE;QACd,mBAAmB;QACnB,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,QAAQ,CAAA;QACxB,mBAAmB;QACnB,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QAC7B,mBAAmB;QACnB,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAA;KAClB;AACH,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,GAAW,EAAE,GAAW,EAAE,GAAW;IACzD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAA;AAC1C,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const version = "1.3.2";
@@ -0,0 +1,2 @@
1
+ export const version = "1.3.2";
2
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC"}
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
- "version": "1.3.1",
2
+ "name": "react-msaview",
3
+ "type": "module",
4
+ "author": "Colin",
5
+ "version": "2.0.0",
3
6
  "license": "MIT",
4
7
  "main": "dist/index.js",
5
- "typings": "dist/index.d.ts",
6
8
  "files": [
7
9
  "dist",
8
- "bundle"
10
+ "bundle",
11
+ "src"
9
12
  ],
10
13
  "engines": {
11
14
  "node": ">=10"
@@ -13,50 +16,47 @@
13
16
  "scripts": {
14
17
  "lint": "eslint src",
15
18
  "clean": "rimraf dist",
16
- "prestart": "npm run clean",
17
19
  "prebuild": "npm run clean",
18
- "start": "yarn tsc --watch",
19
- "build": "yarn tsc && rollup -c",
20
+ "prepublishOnly": "node -p \"'export const version = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/version.ts",
21
+ "build": "tsc && rollup -c",
20
22
  "preversion": "npm run build",
21
23
  "postversion": "git push --follow-tags"
22
24
  },
23
25
  "peerDependencies": {
24
- "@jbrowse/core": ">=1.5.1",
25
- "@material-ui/core": ">=4.12.2",
26
+ "@jbrowse/core": ">=2.0.0",
27
+ "@mui/icons-material": ">=5.0.0",
28
+ "@mui/material": ">=5.0.0",
29
+ "mobx": ">=6.0.0",
30
+ "mobx-react": ">=7.0.0",
31
+ "mobx-state-tree": ">=5.0.0",
26
32
  "react": ">=16.8.0",
27
33
  "react-dom": ">=16.8.0"
28
34
  },
29
- "name": "react-msaview",
30
- "author": "Colin",
31
35
  "devDependencies": {
32
- "@rollup/plugin-commonjs": "^21.0.1",
33
- "@rollup/plugin-json": "^4.1.0",
34
- "@rollup/plugin-node-resolve": "^13.0.6",
35
- "@rollup/plugin-typescript": "^8.3.0",
36
+ "@rollup/plugin-commonjs": "^24.1.0",
37
+ "@rollup/plugin-json": "^6.0.0",
38
+ "@rollup/plugin-node-resolve": "^15.0.2",
39
+ "@rollup/plugin-replace": "^5.0.2",
40
+ "@rollup/plugin-terser": "^0.4.1",
41
+ "@rollup/plugin-typescript": "^11.1.0",
36
42
  "@types/color": "^3.0.1",
37
- "@types/d3": "^6.7.0",
38
- "@types/lodash": "^4.14.170",
39
- "@types/react": "^17.0.3",
40
- "@types/react-dom": "^17.0.2",
41
- "concurrently": "^6.2.0",
42
- "eslint-config-react-app": "^6.0.0",
43
- "react": "^17.0.1",
44
- "react-dom": "^17.0.1",
45
- "rollup": "^2.60.2",
46
- "rollup-plugin-node-builtins": "^2.1.2",
47
- "rollup-plugin-node-polyfills": "^0.2.1",
48
- "rollup-plugin-polyfill-node": "^0.7.0",
43
+ "@types/d3": "^7.4.0",
44
+ "@types/react": "^18.2.0",
45
+ "@types/react-dom": "^18.2.1",
46
+ "rollup": "^3.21.3",
47
+ "rollup-plugin-polyfill-node": "^0.12.0",
49
48
  "tslib": "^2.1.0",
50
- "typescript": "^4.2.3"
49
+ "typescript": "^5.0.4"
51
50
  },
52
51
  "dependencies": {
53
52
  "clustal-js": "^1.0.3",
54
53
  "color": "^3.1.3",
55
54
  "copy-to-clipboard": "^3.3.1",
56
- "d3-array": "^2.12.0",
57
- "d3-hierarchy": "^2.0.0",
55
+ "d3-array": "^3.2.3",
56
+ "d3-hierarchy": "^3.1.2",
58
57
  "normalize-wheel": "^1.0.1",
59
58
  "rbush": "^3.0.1",
60
- "stockholm-js": "^1.0.10"
59
+ "stockholm-js": "^1.0.10",
60
+ "tss-react": "^4.8.3"
61
61
  }
62
62
  }
@@ -0,0 +1,11 @@
1
+ import { types } from 'mobx-state-tree'
2
+
3
+ export const StructureModel = types.model({
4
+ id: types.identifier,
5
+ structure: types.model({
6
+ pdb: types.string,
7
+ startPos: types.number,
8
+ endPos: types.number,
9
+ }),
10
+ range: types.maybe(types.string),
11
+ })
@@ -0,0 +1,60 @@
1
+ import { types, addDisposer } from 'mobx-state-tree'
2
+ import { autorun } from 'mobx'
3
+
4
+ // locals
5
+ import { parseGFF } from './util'
6
+
7
+ export const UniprotTrack = types
8
+ .model({
9
+ id: types.string,
10
+ accession: types.string,
11
+ name: types.string,
12
+ associatedRowName: types.string,
13
+ height: types.optional(types.number, 100),
14
+ })
15
+ .volatile(() => ({
16
+ error: undefined as unknown,
17
+ data: undefined as string | undefined,
18
+ }))
19
+ .actions(self => ({
20
+ setError(error: unknown) {
21
+ self.error = error
22
+ },
23
+ setData(data: string) {
24
+ self.data = data
25
+ },
26
+ }))
27
+ .actions(self => ({
28
+ afterCreate() {
29
+ addDisposer(
30
+ self,
31
+ autorun(async () => {
32
+ try {
33
+ const { accession } = self
34
+ const url = `https://rest.uniprot.org/uniprotkb/${accession}.gff`
35
+ const response = await fetch(url)
36
+ if (!response.ok) {
37
+ throw new Error(
38
+ `HTTP ${
39
+ response.status
40
+ } fetching ${url}: ${await response.text()}`,
41
+ )
42
+ }
43
+ self.setData(await response.text())
44
+ } catch (e) {
45
+ console.error(e)
46
+ self.setError(e)
47
+ }
48
+ }),
49
+ )
50
+ },
51
+ }))
52
+ .views(self => ({
53
+ get loading() {
54
+ return !self.data
55
+ },
56
+
57
+ get features() {
58
+ return parseGFF(self.data)
59
+ },
60
+ }))