react-msaview 2.1.1 → 2.1.3
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/index.js +3 -3
- package/dist/components/Header.js +4 -4
- package/dist/components/Header.js.map +1 -1
- package/dist/components/MSAView.js +2 -4
- package/dist/components/MSAView.js.map +1 -1
- package/dist/components/Rubberband.js +2 -2
- package/dist/components/Rubberband.js.map +1 -1
- package/dist/components/TreeCanvasBlock.js +9 -6
- package/dist/components/TreeCanvasBlock.js.map +1 -1
- package/dist/components/TreeMenu.js +4 -2
- package/dist/components/TreeMenu.js.map +1 -1
- package/dist/components/dialogs/{DetailsDlg.d.ts → MetadataDlg.d.ts} +2 -2
- package/dist/components/dialogs/{DetailsDlg.js → MetadataDlg.js} +5 -4
- package/dist/components/dialogs/MetadataDlg.js.map +1 -0
- package/dist/components/dialogs/TreeNodeInfoDlg.d.ts +9 -0
- package/dist/components/dialogs/TreeNodeInfoDlg.js +16 -0
- package/dist/components/dialogs/TreeNodeInfoDlg.js.map +1 -0
- package/dist/model.d.ts +336 -13
- package/dist/model.js +382 -30
- package/dist/model.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -2
- package/src/components/Header.tsx +5 -5
- package/src/components/MSAView.tsx +2 -4
- package/src/components/Rubberband.tsx +2 -2
- package/src/components/TreeCanvasBlock.tsx +9 -5
- package/src/components/TreeMenu.tsx +4 -2
- package/src/components/dialogs/{DetailsDlg.tsx → MetadataDlg.tsx} +7 -3
- package/src/components/dialogs/TreeNodeInfoDlg.tsx +38 -0
- package/src/model.ts +440 -113
- package/src/version.ts +1 -1
- package/dist/components/dialogs/DetailsDlg.js.map +0 -1
- package/dist/components/dialogs/MoreInfoDlg.d.ts +0 -6
- package/dist/components/dialogs/MoreInfoDlg.js +0 -11
- package/dist/components/dialogs/MoreInfoDlg.js.map +0 -1
- package/src/components/dialogs/MoreInfoDlg.tsx +0 -21
package/dist/model.js
CHANGED
|
@@ -17,45 +17,144 @@ import parseNewick from './parseNewick';
|
|
|
17
17
|
import colorSchemes from './colorSchemes';
|
|
18
18
|
import { UniprotTrack } from './UniprotTrack';
|
|
19
19
|
import { StructureModel } from './StructureModel';
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
/**
|
|
21
|
+
* #stateModel MsaView
|
|
22
|
+
*/
|
|
23
|
+
function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
24
|
+
const model = types
|
|
25
|
+
.compose(BaseViewModel, types.model('MsaView', {
|
|
26
|
+
/**
|
|
27
|
+
* #property
|
|
28
|
+
*/
|
|
22
29
|
id: ElementId,
|
|
30
|
+
/**
|
|
31
|
+
* #property
|
|
32
|
+
*/
|
|
23
33
|
type: types.literal('MsaView'),
|
|
34
|
+
/**
|
|
35
|
+
* #property
|
|
36
|
+
*/
|
|
24
37
|
height: types.optional(types.number, 550),
|
|
38
|
+
/**
|
|
39
|
+
* #property
|
|
40
|
+
*/
|
|
25
41
|
treeAreaWidth: types.optional(types.number, 400),
|
|
42
|
+
/**
|
|
43
|
+
* #property
|
|
44
|
+
*/
|
|
26
45
|
treeWidth: types.optional(types.number, 300),
|
|
46
|
+
/**
|
|
47
|
+
* #property
|
|
48
|
+
*/
|
|
27
49
|
rowHeight: 20,
|
|
50
|
+
/**
|
|
51
|
+
* #property
|
|
52
|
+
*/
|
|
28
53
|
scrollY: 0,
|
|
54
|
+
/**
|
|
55
|
+
* #property
|
|
56
|
+
*/
|
|
29
57
|
scrollX: 0,
|
|
58
|
+
/**
|
|
59
|
+
* #property
|
|
60
|
+
*/
|
|
30
61
|
resizeHandleWidth: 5,
|
|
62
|
+
/**
|
|
63
|
+
* #property
|
|
64
|
+
*/
|
|
31
65
|
blockSize: 1000,
|
|
66
|
+
/**
|
|
67
|
+
* #property
|
|
68
|
+
*/
|
|
32
69
|
mouseRow: types.maybe(types.number),
|
|
70
|
+
/**
|
|
71
|
+
* #property
|
|
72
|
+
*/
|
|
33
73
|
mouseCol: types.maybe(types.number),
|
|
74
|
+
/**
|
|
75
|
+
* #property
|
|
76
|
+
*/
|
|
34
77
|
selectedStructures: types.array(StructureModel),
|
|
78
|
+
/**
|
|
79
|
+
* #property
|
|
80
|
+
*/
|
|
35
81
|
labelsAlignRight: false,
|
|
82
|
+
/**
|
|
83
|
+
* #property
|
|
84
|
+
*/
|
|
36
85
|
colWidth: 16,
|
|
86
|
+
/**
|
|
87
|
+
* #property
|
|
88
|
+
*/
|
|
37
89
|
showBranchLen: true,
|
|
90
|
+
/**
|
|
91
|
+
* #property
|
|
92
|
+
*/
|
|
38
93
|
bgColor: true,
|
|
94
|
+
/**
|
|
95
|
+
* #property
|
|
96
|
+
*/
|
|
39
97
|
drawTree: true,
|
|
98
|
+
/**
|
|
99
|
+
* #property
|
|
100
|
+
*/
|
|
40
101
|
drawNodeBubbles: true,
|
|
102
|
+
/**
|
|
103
|
+
* #property
|
|
104
|
+
*/
|
|
41
105
|
highResScaleFactor: 2,
|
|
106
|
+
/**
|
|
107
|
+
* #property
|
|
108
|
+
*/
|
|
42
109
|
colorSchemeName: 'maeditor',
|
|
110
|
+
/**
|
|
111
|
+
* #property
|
|
112
|
+
*/
|
|
43
113
|
treeFilehandle: types.maybe(FileLocation),
|
|
114
|
+
/**
|
|
115
|
+
* #property
|
|
116
|
+
*/
|
|
44
117
|
msaFilehandle: types.maybe(FileLocation),
|
|
118
|
+
/**
|
|
119
|
+
* #property
|
|
120
|
+
*/
|
|
121
|
+
treeMetadataFilehandle: types.maybe(FileLocation),
|
|
122
|
+
/**
|
|
123
|
+
* #property
|
|
124
|
+
*/
|
|
45
125
|
currentAlignment: 0,
|
|
126
|
+
/**
|
|
127
|
+
* #property
|
|
128
|
+
*/
|
|
46
129
|
collapsed: types.array(types.string),
|
|
130
|
+
/**
|
|
131
|
+
* #property
|
|
132
|
+
*/
|
|
47
133
|
showOnly: types.maybe(types.string),
|
|
134
|
+
/**
|
|
135
|
+
* #property
|
|
136
|
+
*/
|
|
48
137
|
boxTracks: types.array(UniprotTrack),
|
|
138
|
+
/**
|
|
139
|
+
* #property
|
|
140
|
+
*/
|
|
49
141
|
turnedOffTracks: types.map(types.boolean),
|
|
142
|
+
/**
|
|
143
|
+
* #property
|
|
144
|
+
*/
|
|
50
145
|
annotatedRegions: types.array(types.model({
|
|
51
146
|
start: types.number,
|
|
52
147
|
end: types.number,
|
|
53
148
|
attributes: types.frozen(),
|
|
54
149
|
})),
|
|
150
|
+
/**
|
|
151
|
+
* #property
|
|
152
|
+
*/
|
|
55
153
|
data: types.optional(types
|
|
56
154
|
.model({
|
|
57
155
|
tree: types.maybe(types.string),
|
|
58
156
|
msa: types.maybe(types.string),
|
|
157
|
+
treeMetadata: types.maybe(types.string),
|
|
59
158
|
})
|
|
60
159
|
.actions(self => ({
|
|
61
160
|
setTree(tree) {
|
|
@@ -64,12 +163,18 @@ const MSAModel = types
|
|
|
64
163
|
setMSA(msa) {
|
|
65
164
|
self.msa = msa;
|
|
66
165
|
},
|
|
166
|
+
setTreeMetadata(treeMetadata) {
|
|
167
|
+
self.treeMetadata = treeMetadata;
|
|
168
|
+
},
|
|
67
169
|
})), { tree: '', msa: '' }),
|
|
68
|
-
})
|
|
170
|
+
}))
|
|
69
171
|
.volatile(() => ({
|
|
70
172
|
rulerHeight: 20,
|
|
71
173
|
error: undefined,
|
|
72
|
-
margin: {
|
|
174
|
+
margin: {
|
|
175
|
+
left: 20,
|
|
176
|
+
top: 20,
|
|
177
|
+
},
|
|
73
178
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
179
|
DialogComponent: undefined,
|
|
75
180
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -78,23 +183,38 @@ const MSAModel = types
|
|
|
78
183
|
annotPos: undefined,
|
|
79
184
|
}))
|
|
80
185
|
.actions(self => ({
|
|
186
|
+
/**
|
|
187
|
+
* #action
|
|
188
|
+
*/
|
|
81
189
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
82
190
|
setDialogComponent(dlg, props) {
|
|
83
191
|
self.DialogComponent = dlg;
|
|
84
192
|
self.DialogProps = props;
|
|
85
193
|
},
|
|
194
|
+
/**
|
|
195
|
+
* #action
|
|
196
|
+
*/
|
|
86
197
|
setHeight(height) {
|
|
87
198
|
self.height = height;
|
|
88
199
|
},
|
|
200
|
+
/**
|
|
201
|
+
* #action
|
|
202
|
+
*/
|
|
89
203
|
addStructureToSelection(elt) {
|
|
90
204
|
self.selectedStructures.push(elt);
|
|
91
205
|
},
|
|
206
|
+
/**
|
|
207
|
+
* #action
|
|
208
|
+
*/
|
|
92
209
|
removeStructureFromSelection(elt) {
|
|
93
210
|
const r = self.selectedStructures.find(node => node.id === elt.id);
|
|
94
211
|
if (r) {
|
|
95
212
|
self.selectedStructures.remove(r);
|
|
96
213
|
}
|
|
97
214
|
},
|
|
215
|
+
/**
|
|
216
|
+
* #action
|
|
217
|
+
*/
|
|
98
218
|
toggleStructureSelection(elt) {
|
|
99
219
|
const r = self.selectedStructures.find(node => node.id === elt.id);
|
|
100
220
|
if (r) {
|
|
@@ -104,47 +224,88 @@ const MSAModel = types
|
|
|
104
224
|
self.selectedStructures.push(elt);
|
|
105
225
|
}
|
|
106
226
|
},
|
|
227
|
+
/**
|
|
228
|
+
* #action
|
|
229
|
+
*/
|
|
107
230
|
clearSelectedStructures() {
|
|
108
|
-
|
|
109
|
-
self.selectedStructures = [];
|
|
231
|
+
self.selectedStructures = cast([]);
|
|
110
232
|
},
|
|
233
|
+
/**
|
|
234
|
+
* #action
|
|
235
|
+
*/
|
|
111
236
|
setError(error) {
|
|
112
237
|
self.error = error;
|
|
113
238
|
},
|
|
239
|
+
/**
|
|
240
|
+
* #action
|
|
241
|
+
*/
|
|
114
242
|
setMousePos(col, row) {
|
|
115
243
|
self.mouseCol = col;
|
|
116
244
|
self.mouseRow = row;
|
|
117
245
|
},
|
|
246
|
+
/**
|
|
247
|
+
* #action
|
|
248
|
+
*/
|
|
118
249
|
setRowHeight(n) {
|
|
119
250
|
self.rowHeight = n;
|
|
120
251
|
},
|
|
252
|
+
/**
|
|
253
|
+
* #action
|
|
254
|
+
*/
|
|
121
255
|
setColWidth(n) {
|
|
122
256
|
self.colWidth = n;
|
|
123
257
|
},
|
|
258
|
+
/**
|
|
259
|
+
* #action
|
|
260
|
+
*/
|
|
124
261
|
setColorSchemeName(name) {
|
|
125
262
|
self.colorSchemeName = name;
|
|
126
263
|
},
|
|
264
|
+
/**
|
|
265
|
+
* #action
|
|
266
|
+
*/
|
|
127
267
|
setScrollY(n) {
|
|
128
268
|
self.scrollY = n;
|
|
129
269
|
},
|
|
270
|
+
/**
|
|
271
|
+
* #action
|
|
272
|
+
*/
|
|
130
273
|
setScrollX(n) {
|
|
131
274
|
self.scrollX = n;
|
|
132
275
|
},
|
|
276
|
+
/**
|
|
277
|
+
* #action
|
|
278
|
+
*/
|
|
133
279
|
setTreeAreaWidth(n) {
|
|
134
280
|
self.treeAreaWidth = n;
|
|
135
281
|
},
|
|
282
|
+
/**
|
|
283
|
+
* #action
|
|
284
|
+
*/
|
|
136
285
|
setTreeWidth(n) {
|
|
137
286
|
self.treeWidth = n;
|
|
138
287
|
},
|
|
288
|
+
/**
|
|
289
|
+
* #action
|
|
290
|
+
*/
|
|
139
291
|
setCurrentAlignment(n) {
|
|
140
292
|
self.currentAlignment = n;
|
|
141
293
|
},
|
|
294
|
+
/**
|
|
295
|
+
* #action
|
|
296
|
+
*/
|
|
142
297
|
toggleLabelsAlignRight() {
|
|
143
298
|
self.labelsAlignRight = !self.labelsAlignRight;
|
|
144
299
|
},
|
|
300
|
+
/**
|
|
301
|
+
* #action
|
|
302
|
+
*/
|
|
145
303
|
toggleDrawTree() {
|
|
146
304
|
self.drawTree = !self.drawTree;
|
|
147
305
|
},
|
|
306
|
+
/**
|
|
307
|
+
* #action
|
|
308
|
+
*/
|
|
148
309
|
toggleCollapsed(node) {
|
|
149
310
|
if (self.collapsed.includes(node)) {
|
|
150
311
|
self.collapsed.remove(node);
|
|
@@ -153,24 +314,45 @@ const MSAModel = types
|
|
|
153
314
|
self.collapsed.push(node);
|
|
154
315
|
}
|
|
155
316
|
},
|
|
317
|
+
/**
|
|
318
|
+
* #action
|
|
319
|
+
*/
|
|
156
320
|
setShowOnly(node) {
|
|
157
321
|
self.showOnly = node;
|
|
158
322
|
},
|
|
323
|
+
/**
|
|
324
|
+
* #action
|
|
325
|
+
*/
|
|
159
326
|
toggleBranchLen() {
|
|
160
327
|
self.showBranchLen = !self.showBranchLen;
|
|
161
328
|
},
|
|
329
|
+
/**
|
|
330
|
+
* #action
|
|
331
|
+
*/
|
|
162
332
|
toggleBgColor() {
|
|
163
333
|
self.bgColor = !self.bgColor;
|
|
164
334
|
},
|
|
335
|
+
/**
|
|
336
|
+
* #action
|
|
337
|
+
*/
|
|
165
338
|
toggleNodeBubbles() {
|
|
166
339
|
self.drawNodeBubbles = !self.drawNodeBubbles;
|
|
167
340
|
},
|
|
341
|
+
/**
|
|
342
|
+
* #action
|
|
343
|
+
*/
|
|
168
344
|
setData(data) {
|
|
169
345
|
self.data = cast(data);
|
|
170
346
|
},
|
|
347
|
+
/**
|
|
348
|
+
* #action
|
|
349
|
+
*/
|
|
171
350
|
async setMSAFilehandle(msaFilehandle) {
|
|
172
351
|
self.msaFilehandle = msaFilehandle;
|
|
173
352
|
},
|
|
353
|
+
/**
|
|
354
|
+
* #action
|
|
355
|
+
*/
|
|
174
356
|
async setTreeFilehandle(treeFilehandle) {
|
|
175
357
|
if (treeFilehandle && 'blobId' in treeFilehandle) {
|
|
176
358
|
const r = await openLocation(treeFilehandle).readFile('utf8');
|
|
@@ -180,12 +362,24 @@ const MSAModel = types
|
|
|
180
362
|
self.treeFilehandle = treeFilehandle;
|
|
181
363
|
}
|
|
182
364
|
},
|
|
365
|
+
/**
|
|
366
|
+
* #action
|
|
367
|
+
*/
|
|
183
368
|
setMSA(result) {
|
|
184
369
|
self.data.setMSA(result);
|
|
185
370
|
},
|
|
371
|
+
/**
|
|
372
|
+
* #action
|
|
373
|
+
*/
|
|
186
374
|
setTree(result) {
|
|
187
375
|
self.data.setTree(result);
|
|
188
376
|
},
|
|
377
|
+
/**
|
|
378
|
+
* #action
|
|
379
|
+
*/
|
|
380
|
+
setTreeMetadata(result) {
|
|
381
|
+
self.data.setTreeMetadata(result);
|
|
382
|
+
},
|
|
189
383
|
afterCreate() {
|
|
190
384
|
addDisposer(self, autorun(async () => {
|
|
191
385
|
const { treeFilehandle } = self;
|
|
@@ -199,6 +393,18 @@ const MSAModel = types
|
|
|
199
393
|
}
|
|
200
394
|
}
|
|
201
395
|
}));
|
|
396
|
+
addDisposer(self, autorun(async () => {
|
|
397
|
+
const { treeMetadataFilehandle } = self;
|
|
398
|
+
if (treeMetadataFilehandle) {
|
|
399
|
+
try {
|
|
400
|
+
this.setTreeMetadata(await openLocation(treeMetadataFilehandle).readFile('utf8'));
|
|
401
|
+
}
|
|
402
|
+
catch (e) {
|
|
403
|
+
console.error(e);
|
|
404
|
+
this.setError(e);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}));
|
|
202
408
|
addDisposer(self, autorun(async () => {
|
|
203
409
|
const { msaFilehandle } = self;
|
|
204
410
|
if (msaFilehandle) {
|
|
@@ -219,6 +425,9 @@ const MSAModel = types
|
|
|
219
425
|
let oldValX = 0;
|
|
220
426
|
let oldValY = 0;
|
|
221
427
|
return {
|
|
428
|
+
/**
|
|
429
|
+
* #getter
|
|
430
|
+
*/
|
|
222
431
|
get initialized() {
|
|
223
432
|
return ((self.data.msa ||
|
|
224
433
|
self.data.tree ||
|
|
@@ -226,6 +435,9 @@ const MSAModel = types
|
|
|
226
435
|
self.treeFilehandle) &&
|
|
227
436
|
!self.error);
|
|
228
437
|
},
|
|
438
|
+
/**
|
|
439
|
+
* #getter
|
|
440
|
+
*/
|
|
229
441
|
get blocksX() {
|
|
230
442
|
const { scrollX, blockSize: size, colWidth } = self;
|
|
231
443
|
const ret = -(size * Math.floor(scrollX / size)) - size;
|
|
@@ -242,6 +454,9 @@ const MSAModel = types
|
|
|
242
454
|
}
|
|
243
455
|
return oldBlocksX;
|
|
244
456
|
},
|
|
457
|
+
/**
|
|
458
|
+
* #getter
|
|
459
|
+
*/
|
|
245
460
|
get blocksY() {
|
|
246
461
|
const { scrollY, blockSize: size, rowHeight } = self;
|
|
247
462
|
const ret = -(size * Math.floor(scrollY / size)) - 2 * size;
|
|
@@ -261,19 +476,34 @@ const MSAModel = types
|
|
|
261
476
|
};
|
|
262
477
|
})
|
|
263
478
|
.views(self => ({
|
|
479
|
+
/**
|
|
480
|
+
* #getter
|
|
481
|
+
*/
|
|
264
482
|
get blocks2d() {
|
|
265
483
|
return self.blocksY.flatMap(by => self.blocksX.map(bx => [bx, by]));
|
|
266
484
|
},
|
|
485
|
+
/**
|
|
486
|
+
* #getter
|
|
487
|
+
*/
|
|
267
488
|
get done() {
|
|
268
489
|
return self.initialized && (self.data.msa || self.data.tree);
|
|
269
490
|
},
|
|
491
|
+
/**
|
|
492
|
+
* #getter
|
|
493
|
+
*/
|
|
270
494
|
get colorScheme() {
|
|
271
495
|
return colorSchemes[self.colorSchemeName];
|
|
272
496
|
},
|
|
497
|
+
/**
|
|
498
|
+
* #getter
|
|
499
|
+
*/
|
|
273
500
|
get header() {
|
|
274
501
|
var _a;
|
|
275
502
|
return ((_a = this.MSA) === null || _a === void 0 ? void 0 : _a.getHeader()) || {};
|
|
276
503
|
},
|
|
504
|
+
/**
|
|
505
|
+
* #method
|
|
506
|
+
*/
|
|
277
507
|
getRowData(name) {
|
|
278
508
|
var _a;
|
|
279
509
|
const matches = name.match(/\S+\/(\d+)-(\d+)/);
|
|
@@ -282,19 +512,40 @@ const MSAModel = types
|
|
|
282
512
|
...(matches && { range: { start: +matches[1], end: +matches[2] } }),
|
|
283
513
|
};
|
|
284
514
|
},
|
|
515
|
+
/**
|
|
516
|
+
* #getter
|
|
517
|
+
*/
|
|
285
518
|
get currentAlignmentName() {
|
|
286
519
|
return this.alignmentNames[self.currentAlignment];
|
|
287
520
|
},
|
|
521
|
+
/**
|
|
522
|
+
* #getter
|
|
523
|
+
*/
|
|
288
524
|
get alignmentNames() {
|
|
289
525
|
var _a;
|
|
290
526
|
return ((_a = this.MSA) === null || _a === void 0 ? void 0 : _a.alignmentNames) || [];
|
|
291
527
|
},
|
|
528
|
+
/**
|
|
529
|
+
* #getter
|
|
530
|
+
*/
|
|
292
531
|
get noTree() {
|
|
293
532
|
return !!this.tree.noTree;
|
|
294
533
|
},
|
|
534
|
+
/**
|
|
535
|
+
* #getter
|
|
536
|
+
*/
|
|
295
537
|
get menuItems() {
|
|
296
538
|
return [];
|
|
297
539
|
},
|
|
540
|
+
/**
|
|
541
|
+
* #getter
|
|
542
|
+
*/
|
|
543
|
+
get treeMetadata() {
|
|
544
|
+
return self.data.treeMetadata ? JSON.parse(self.data.treeMetadata) : {};
|
|
545
|
+
},
|
|
546
|
+
/**
|
|
547
|
+
* #getter
|
|
548
|
+
*/
|
|
298
549
|
get MSA() {
|
|
299
550
|
const text = self.data.msa;
|
|
300
551
|
if (text) {
|
|
@@ -310,10 +561,16 @@ const MSAModel = types
|
|
|
310
561
|
}
|
|
311
562
|
return null;
|
|
312
563
|
},
|
|
564
|
+
/**
|
|
565
|
+
* #getter
|
|
566
|
+
*/
|
|
313
567
|
get numColumns() {
|
|
314
568
|
var _a;
|
|
315
569
|
return ((((_a = this.MSA) === null || _a === void 0 ? void 0 : _a.getWidth()) || 0) - this.blanks.length) * self.colWidth;
|
|
316
570
|
},
|
|
571
|
+
/**
|
|
572
|
+
* #getter
|
|
573
|
+
*/
|
|
317
574
|
get tree() {
|
|
318
575
|
var _a;
|
|
319
576
|
return self.data.tree
|
|
@@ -325,17 +582,28 @@ const MSAModel = types
|
|
|
325
582
|
name: 'empty',
|
|
326
583
|
};
|
|
327
584
|
},
|
|
585
|
+
/**
|
|
586
|
+
* #getter
|
|
587
|
+
*/
|
|
328
588
|
get rowNames() {
|
|
329
589
|
return this.hierarchy.leaves().map(node => node.data.name);
|
|
330
590
|
},
|
|
331
|
-
|
|
591
|
+
/**
|
|
592
|
+
* #getter
|
|
593
|
+
*/ get mouseOverRowName() {
|
|
332
594
|
return self.mouseRow !== undefined
|
|
333
595
|
? this.rowNames[self.mouseRow]
|
|
334
596
|
: undefined;
|
|
335
597
|
},
|
|
598
|
+
/**
|
|
599
|
+
* #method
|
|
600
|
+
*/
|
|
336
601
|
getMouseOverResidue(rowName) {
|
|
337
602
|
return this.columns[rowName];
|
|
338
603
|
},
|
|
604
|
+
/**
|
|
605
|
+
* #getter
|
|
606
|
+
*/
|
|
339
607
|
get root() {
|
|
340
608
|
let hier = hierarchy(this.tree, d => d.branchset)
|
|
341
609
|
.sum(d => (d.branchset ? 0 : 1))
|
|
@@ -354,17 +622,28 @@ const MSAModel = types
|
|
|
354
622
|
}
|
|
355
623
|
return hier;
|
|
356
624
|
},
|
|
625
|
+
/**
|
|
626
|
+
* #getter
|
|
627
|
+
*/
|
|
357
628
|
get structures() {
|
|
358
629
|
var _a;
|
|
359
630
|
return ((_a = this.MSA) === null || _a === void 0 ? void 0 : _a.getStructures()) || {};
|
|
360
631
|
},
|
|
632
|
+
/**
|
|
633
|
+
* #getter
|
|
634
|
+
*/
|
|
361
635
|
get inverseStructures() {
|
|
362
636
|
return Object.fromEntries(Object.entries(this.structures).flatMap(([key, val]) => val.map(pdbEntry => [pdbEntry.pdb, { id: key }])));
|
|
363
637
|
},
|
|
638
|
+
/**
|
|
639
|
+
* #getter
|
|
640
|
+
*/
|
|
364
641
|
get msaAreaWidth() {
|
|
365
|
-
// @ts-expect-error
|
|
366
642
|
return self.width - self.treeAreaWidth;
|
|
367
643
|
},
|
|
644
|
+
/**
|
|
645
|
+
* #getter
|
|
646
|
+
*/
|
|
368
647
|
get blanks() {
|
|
369
648
|
var _a;
|
|
370
649
|
const blanks = [];
|
|
@@ -385,18 +664,30 @@ const MSAModel = types
|
|
|
385
664
|
}
|
|
386
665
|
return blanks;
|
|
387
666
|
},
|
|
667
|
+
/**
|
|
668
|
+
* #getter
|
|
669
|
+
*/
|
|
388
670
|
get rows() {
|
|
389
671
|
return this.hierarchy
|
|
390
672
|
.leaves()
|
|
391
673
|
.map(({ data }) => { var _a; return [data.name, (_a = this.MSA) === null || _a === void 0 ? void 0 : _a.getRow(data.name)]; })
|
|
392
674
|
.filter((f) => !!f[1]);
|
|
393
675
|
},
|
|
676
|
+
/**
|
|
677
|
+
* #getter
|
|
678
|
+
*/
|
|
394
679
|
get columns() {
|
|
395
680
|
return Object.fromEntries(this.rows.map((row, index) => [row[0], this.columns2d[index]]));
|
|
396
681
|
},
|
|
682
|
+
/**
|
|
683
|
+
* #getter
|
|
684
|
+
*/
|
|
397
685
|
get columns2d() {
|
|
398
686
|
return this.rows.map(r => r[1]).map(str => skipBlanks(this.blanks, str));
|
|
399
687
|
},
|
|
688
|
+
/**
|
|
689
|
+
* #getter
|
|
690
|
+
*/
|
|
400
691
|
get colStats() {
|
|
401
692
|
const r = [];
|
|
402
693
|
const columns = this.columns2d;
|
|
@@ -412,7 +703,10 @@ const MSAModel = types
|
|
|
412
703
|
}
|
|
413
704
|
return r;
|
|
414
705
|
},
|
|
415
|
-
|
|
706
|
+
/**
|
|
707
|
+
* #getter
|
|
708
|
+
* generates a new tree that is clustered with x,y positions
|
|
709
|
+
*/
|
|
416
710
|
get hierarchy() {
|
|
417
711
|
const root = this.root;
|
|
418
712
|
const clust = cluster()
|
|
@@ -422,11 +716,17 @@ const MSAModel = types
|
|
|
422
716
|
setBrLength(root, (root.data.length = 0), self.treeWidth / maxLength(root));
|
|
423
717
|
return root;
|
|
424
718
|
},
|
|
719
|
+
/**
|
|
720
|
+
* #getter
|
|
721
|
+
*/
|
|
425
722
|
get totalHeight() {
|
|
426
723
|
return this.root.leaves().length * self.rowHeight;
|
|
427
724
|
},
|
|
428
725
|
}))
|
|
429
726
|
.actions(self => ({
|
|
727
|
+
/**
|
|
728
|
+
* #action
|
|
729
|
+
*/
|
|
430
730
|
addUniprotTrack(node) {
|
|
431
731
|
if (self.boxTracks.some(t => t.name === node.name)) {
|
|
432
732
|
if (self.turnedOffTracks.has(node.name)) {
|
|
@@ -441,12 +741,21 @@ const MSAModel = types
|
|
|
441
741
|
});
|
|
442
742
|
}
|
|
443
743
|
},
|
|
744
|
+
/**
|
|
745
|
+
* #action
|
|
746
|
+
*/
|
|
444
747
|
doScrollY(deltaY) {
|
|
445
748
|
self.scrollY = clamp(-self.totalHeight + 10, self.scrollY + deltaY, 0);
|
|
446
749
|
},
|
|
750
|
+
/**
|
|
751
|
+
* #action
|
|
752
|
+
*/
|
|
447
753
|
doScrollX(deltaX) {
|
|
448
754
|
self.scrollX = clamp(-self.numColumns + (self.msaAreaWidth - 100), self.scrollX + deltaX, 0);
|
|
449
755
|
},
|
|
756
|
+
/**
|
|
757
|
+
* #action
|
|
758
|
+
*/
|
|
450
759
|
setMouseoveredColumn(n, chain, file) {
|
|
451
760
|
var _a;
|
|
452
761
|
let j = 0;
|
|
@@ -465,6 +774,9 @@ const MSAModel = types
|
|
|
465
774
|
self.mouseCol = undefined;
|
|
466
775
|
}
|
|
467
776
|
},
|
|
777
|
+
/**
|
|
778
|
+
* #action
|
|
779
|
+
*/
|
|
468
780
|
toggleTrack(id) {
|
|
469
781
|
if (self.turnedOffTracks.has(id)) {
|
|
470
782
|
self.turnedOffTracks.delete(id);
|
|
@@ -475,14 +787,23 @@ const MSAModel = types
|
|
|
475
787
|
},
|
|
476
788
|
}))
|
|
477
789
|
.views(self => ({
|
|
790
|
+
/**
|
|
791
|
+
* #getter
|
|
792
|
+
*/
|
|
478
793
|
get secondaryStructureConsensus() {
|
|
479
794
|
var _a;
|
|
480
795
|
return (_a = self.MSA) === null || _a === void 0 ? void 0 : _a.secondaryStructureConsensus;
|
|
481
796
|
},
|
|
797
|
+
/**
|
|
798
|
+
* #getter
|
|
799
|
+
*/
|
|
482
800
|
get seqConsensus() {
|
|
483
801
|
var _a;
|
|
484
802
|
return (_a = self.MSA) === null || _a === void 0 ? void 0 : _a.seqConsensus;
|
|
485
803
|
},
|
|
804
|
+
/**
|
|
805
|
+
* #getter
|
|
806
|
+
*/
|
|
486
807
|
get conservation() {
|
|
487
808
|
if (self.columns2d.length) {
|
|
488
809
|
for (let i = 0; i < self.columns2d[0].length; i++) {
|
|
@@ -494,6 +815,9 @@ const MSAModel = types
|
|
|
494
815
|
}
|
|
495
816
|
return ['a'];
|
|
496
817
|
},
|
|
818
|
+
/**
|
|
819
|
+
* #getter
|
|
820
|
+
*/
|
|
497
821
|
get tracks() {
|
|
498
822
|
const blanks = self.blanks;
|
|
499
823
|
const adapterTracks = self.MSA
|
|
@@ -551,13 +875,22 @@ const MSAModel = types
|
|
|
551
875
|
: [];
|
|
552
876
|
return [...adapterTracks, ...boxTracks, ...annotationTracks];
|
|
553
877
|
},
|
|
878
|
+
/**
|
|
879
|
+
* #getter
|
|
880
|
+
*/
|
|
554
881
|
get turnedOnTracks() {
|
|
555
882
|
return this.tracks.filter(f => !self.turnedOffTracks.has(f.model.id));
|
|
556
883
|
},
|
|
557
|
-
|
|
884
|
+
/**
|
|
885
|
+
* #method
|
|
886
|
+
* returns coordinate in the current relative coordinate scheme
|
|
887
|
+
*/
|
|
558
888
|
pxToBp(coord) {
|
|
559
889
|
return Math.floor((coord - self.scrollX) / self.colWidth);
|
|
560
890
|
},
|
|
891
|
+
/**
|
|
892
|
+
* #method
|
|
893
|
+
*/
|
|
561
894
|
rowSpecificBpToPx(rowName, position) {
|
|
562
895
|
var _a;
|
|
563
896
|
const { rowNames, rows, blanks } = self;
|
|
@@ -566,6 +899,7 @@ const MSAModel = types
|
|
|
566
899
|
const details = self.getRowData(rowName);
|
|
567
900
|
const offset = ((_a = details.range) === null || _a === void 0 ? void 0 : _a.start) || 0;
|
|
568
901
|
const current = position - offset;
|
|
902
|
+
const s = new Set(self.blanks);
|
|
569
903
|
if (current < 0) {
|
|
570
904
|
return 0;
|
|
571
905
|
}
|
|
@@ -578,22 +912,29 @@ const MSAModel = types
|
|
|
578
912
|
}
|
|
579
913
|
let count = 0;
|
|
580
914
|
for (let k = 0; k < row.length; k++) {
|
|
581
|
-
if (
|
|
915
|
+
if (s.has(k) && k < i + 1) {
|
|
582
916
|
count++;
|
|
583
917
|
}
|
|
584
918
|
}
|
|
585
919
|
return i - count;
|
|
586
920
|
},
|
|
921
|
+
/**
|
|
922
|
+
* #method
|
|
923
|
+
*/
|
|
587
924
|
globalBpToPx(position) {
|
|
588
925
|
var _a;
|
|
589
926
|
let count = 0;
|
|
927
|
+
const s = new Set(self.blanks);
|
|
590
928
|
for (let k = 0; k < ((_a = self.rows[0]) === null || _a === void 0 ? void 0 : _a[1].length); k++) {
|
|
591
|
-
if (
|
|
929
|
+
if (s.has(k) && k < position + 1) {
|
|
592
930
|
count++;
|
|
593
931
|
}
|
|
594
932
|
}
|
|
595
933
|
return position - count;
|
|
596
934
|
},
|
|
935
|
+
/**
|
|
936
|
+
* #method
|
|
937
|
+
*/
|
|
597
938
|
relativePxToBp(rowName, position) {
|
|
598
939
|
const { rowNames, rows } = self;
|
|
599
940
|
const index = rowNames.indexOf(rowName);
|
|
@@ -612,6 +953,9 @@ const MSAModel = types
|
|
|
612
953
|
}
|
|
613
954
|
return 0;
|
|
614
955
|
},
|
|
956
|
+
/**
|
|
957
|
+
* #method
|
|
958
|
+
*/
|
|
615
959
|
getPos(pos) {
|
|
616
960
|
let j = 0;
|
|
617
961
|
for (let i = 0, k = 0; i < pos; i++, j++) {
|
|
@@ -624,6 +968,9 @@ const MSAModel = types
|
|
|
624
968
|
},
|
|
625
969
|
}))
|
|
626
970
|
.actions(self => ({
|
|
971
|
+
/**
|
|
972
|
+
* #action
|
|
973
|
+
*/
|
|
627
974
|
addAnnotation(start, end, attributes) {
|
|
628
975
|
self.annotatedRegions.push({
|
|
629
976
|
start: self.getPos(start),
|
|
@@ -631,28 +978,33 @@ const MSAModel = types
|
|
|
631
978
|
attributes,
|
|
632
979
|
});
|
|
633
980
|
},
|
|
634
|
-
|
|
981
|
+
/**
|
|
982
|
+
* #action
|
|
983
|
+
*/
|
|
984
|
+
setAnnotationClickBoundaries(left, right) {
|
|
635
985
|
self.annotPos = { left, right };
|
|
636
986
|
},
|
|
637
|
-
|
|
987
|
+
/**
|
|
988
|
+
* #action
|
|
989
|
+
*/
|
|
990
|
+
clearAnnotationClickBoundaries() {
|
|
638
991
|
self.annotPos = undefined;
|
|
639
992
|
},
|
|
640
|
-
}))
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
},
|
|
993
|
+
}))
|
|
994
|
+
.postProcessSnapshot(result => {
|
|
995
|
+
const snap = result;
|
|
996
|
+
const { data: { tree, msa, treeMetadata }, ...rest } = snap;
|
|
997
|
+
// remove the MSA/tree data from the tree if the filehandle available in
|
|
998
|
+
// which case it can be reloaded on refresh
|
|
999
|
+
return {
|
|
1000
|
+
data: {
|
|
1001
|
+
// https://andreasimonecosta.dev/posts/the-shortest-way-to-conditionally-insert-properties-into-an-object-literal/
|
|
1002
|
+
...(!result.treeFilehandle && { tree }),
|
|
1003
|
+
...(!result.msaFilehandle && { msa }),
|
|
1004
|
+
...(!result.treeMetadataFilehandle && { treeMetadata }),
|
|
1005
|
+
},
|
|
1006
|
+
...rest,
|
|
1007
|
+
};
|
|
656
1008
|
});
|
|
657
1009
|
export default model;
|
|
658
1010
|
//# sourceMappingURL=model.js.map
|