phyloio 2.1.0 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Examples/Website/phyloio.html +73 -71
- package/Examples/Website/src_worker_bcn_js.phylo.js +8093 -0
- package/Examples/Website/src_worker_distance_js.phylo.js +6257 -0
- package/README.md +16 -2
- package/dist/phylo.js +7 -7
- package/dist/src_worker_bcn_js.phylo.js +2 -2
- package/dist/src_worker_distance_js.phylo.js +1 -1
- package/{src_phylo_compare → dist-jest}/phylo.js +68 -132
- package/{src_phylo_compare → dist-jest}/src_utils_js.phylo.js +1 -1
- package/dist-jest/src_worker_bcn_js.phylo.js +350 -0
- package/dist-jest/src_worker_distance_js.phylo.js +219 -0
- package/{src_phylo_compare/vendors-node_modules_biojs-io-newick_src_index_js-node_modules_minhashjs_index_js.phylo.js → dist-jest/vendors-node_modules_biojs-io-newick_src_index_js-node_modules_minhashjs_index_js-node_module-7b40e5.phylo.js} +25 -15
- package/package-lock.json +19607 -0
- package/package.json +1 -1
- package/rerooting.test.js +297 -0
- package/src/api.js +19 -9
- package/src/container.js +408 -64
- package/src/interface.css +6 -0
- package/src/interface.js +371 -207
- package/src/model.js +19 -20
- package/src/tmp +12 -0
- package/src/utils.js +31 -1
- package/src/viewer.js +177 -88
- package/src_phylo_compare/fonts/fa-brands-400.eot +0 -0
- package/src_phylo_compare/fonts/fa-brands-400.svg +0 -3717
- package/src_phylo_compare/fonts/fa-brands-400.ttf +0 -0
- package/src_phylo_compare/fonts/fa-brands-400.woff +0 -0
- package/src_phylo_compare/fonts/fa-brands-400.woff2 +0 -0
- package/src_phylo_compare/fonts/fa-regular-400.eot +0 -0
- package/src_phylo_compare/fonts/fa-regular-400.svg +0 -801
- package/src_phylo_compare/fonts/fa-regular-400.ttf +0 -0
- package/src_phylo_compare/fonts/fa-regular-400.woff +0 -0
- package/src_phylo_compare/fonts/fa-regular-400.woff2 +0 -0
- package/src_phylo_compare/fonts/fa-solid-900.eot +0 -0
- package/src_phylo_compare/fonts/fa-solid-900.svg +0 -5034
- package/src_phylo_compare/fonts/fa-solid-900.ttf +0 -0
- package/src_phylo_compare/fonts/fa-solid-900.woff +0 -0
- package/src_phylo_compare/fonts/fa-solid-900.woff2 +0 -0
- package/src_phylo_compare/fonts/fa-v4compatibility.ttf +0 -0
- package/src_phylo_compare/fonts/fa-v4compatibility.woff2 +0 -0
- package/src_phylo_compare/src_worker_bcn_js.phylo.js +0 -341
- package/src_phylo_compare/src_worker_distance_js.phylo.js +0 -227
- package/src_phylo_compare.zip +0 -0
- /package/{src_phylo_compare → dist-jest}/vendors-node_modules_d3_index_js-node_modules_file-saver_dist_FileSaver_min_js.phylo.js +0 -0
package/package.json
CHANGED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const PhyloIO = require("./dist-jest/phylo.js").PhyloIO;
|
|
7
|
+
const utils = require('./src/utils.js')
|
|
8
|
+
|
|
9
|
+
var data = '((C,D)1,(A,(B,X)3)2,E);'
|
|
10
|
+
|
|
11
|
+
// get string made of concatenation of leaves name from node.leaves
|
|
12
|
+
const getSortedLeaves = (node) => {
|
|
13
|
+
return node.leaves.map(leaf => leaf.name).sort();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const verify_boostrap_default = (node, children) => {
|
|
17
|
+
|
|
18
|
+
var con_leaves = getSortedLeaves(node)
|
|
19
|
+
|
|
20
|
+
if ( con_leaves.length <= 1) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var str_leaves = JSON.stringify(con_leaves);
|
|
25
|
+
|
|
26
|
+
switch (str_leaves){
|
|
27
|
+
case JSON.stringify(['A', 'B', 'X']):
|
|
28
|
+
expect(node.extended_informations.Data).toBe("2");
|
|
29
|
+
break;
|
|
30
|
+
case JSON.stringify(['B', 'X']):
|
|
31
|
+
expect(node.extended_informations.Data).toBe("3");
|
|
32
|
+
break;
|
|
33
|
+
case JSON.stringify(['C', 'D']):
|
|
34
|
+
expect(node.extended_informations.Data).toBe("1");
|
|
35
|
+
break;
|
|
36
|
+
case JSON.stringify(['A', 'B', 'C', 'D', 'E', 'X']):
|
|
37
|
+
expect(node.extended_informations.Data).toBeUndefined();
|
|
38
|
+
break;
|
|
39
|
+
default:
|
|
40
|
+
expect(true).toBe(false);
|
|
41
|
+
break
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
test('test reroot on X' , () => {
|
|
46
|
+
|
|
47
|
+
const phylo = PhyloIO.init();
|
|
48
|
+
|
|
49
|
+
// >>> test with internal label for branches
|
|
50
|
+
var m1 = phylo._create_model(data, {'data_type' : 'nhx'})
|
|
51
|
+
m1.settings.edge_related_data.push('Data');
|
|
52
|
+
m1.traverse(m1.data,verify_boostrap_default);
|
|
53
|
+
|
|
54
|
+
// reroot on X
|
|
55
|
+
var x_node = m1.data.leaves.find(leaf => leaf.name === 'X');
|
|
56
|
+
m1.reroot(x_node);
|
|
57
|
+
m1.traverse(m1.data,function(node, children) {
|
|
58
|
+
|
|
59
|
+
var con_leaves = getSortedLeaves(node)
|
|
60
|
+
|
|
61
|
+
if ( con_leaves.length <= 1) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
var str_leaves = JSON.stringify(con_leaves);
|
|
66
|
+
|
|
67
|
+
switch (str_leaves){
|
|
68
|
+
case JSON.stringify(['C', 'D', 'E']):
|
|
69
|
+
expect(node.extended_informations.Data).toBe("2");
|
|
70
|
+
break;
|
|
71
|
+
case JSON.stringify(['C', 'D']):
|
|
72
|
+
expect(node.extended_informations.Data).toBe("1");
|
|
73
|
+
break;
|
|
74
|
+
case JSON.stringify(['A', 'B', 'C', 'D', 'E', 'X']):
|
|
75
|
+
expect(node.extended_informations.Data).toBeNull();
|
|
76
|
+
break;
|
|
77
|
+
case JSON.stringify(['A', 'C', 'D', 'E']):
|
|
78
|
+
expect(node.extended_informations.Data).toBe("3");
|
|
79
|
+
break;
|
|
80
|
+
case JSON.stringify(['A', 'B', 'C', 'D', 'E']):
|
|
81
|
+
expect(node.extended_informations.Data).toBeUndefined();
|
|
82
|
+
break;
|
|
83
|
+
default:
|
|
84
|
+
expect(true).toBe(false);
|
|
85
|
+
break
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// >>> test without internal label for branches
|
|
90
|
+
var m2 = phylo._create_model(data, {'data_type' : 'nhx'})
|
|
91
|
+
m2.traverse(m2.data,verify_boostrap_default);
|
|
92
|
+
|
|
93
|
+
// reroot on X
|
|
94
|
+
var x_node2 = m2.data.leaves.find(leaf => leaf.name === 'X');
|
|
95
|
+
m2.reroot(x_node2);
|
|
96
|
+
m2.traverse(m2.data,function(node, children) {
|
|
97
|
+
|
|
98
|
+
var con_leaves = getSortedLeaves(node)
|
|
99
|
+
|
|
100
|
+
if ( con_leaves.length <= 1) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
var str_leaves = JSON.stringify(con_leaves);
|
|
105
|
+
|
|
106
|
+
switch (str_leaves){
|
|
107
|
+
case JSON.stringify(['C', 'D', 'E']):
|
|
108
|
+
expect(node.extended_informations.Data).toBeUndefined()
|
|
109
|
+
break;
|
|
110
|
+
case JSON.stringify(['C', 'D']):
|
|
111
|
+
expect(node.extended_informations.Data).toBe("1");
|
|
112
|
+
break;
|
|
113
|
+
case JSON.stringify(['A', 'B', 'C', 'D', 'E', 'X']):
|
|
114
|
+
expect(node.extended_informations.Data).toBeUndefined();
|
|
115
|
+
break;
|
|
116
|
+
case JSON.stringify(['A', 'C', 'D', 'E']):
|
|
117
|
+
expect(node.extended_informations.Data).toBe("2");
|
|
118
|
+
break;
|
|
119
|
+
case JSON.stringify(['A', 'B', 'C', 'D', 'E']):
|
|
120
|
+
expect(node.extended_informations.Data).toBe("3");
|
|
121
|
+
break;
|
|
122
|
+
default:
|
|
123
|
+
expect(true).toBe(false);
|
|
124
|
+
break
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
test('test reroot on B/X > C/D > B/X ' , () => {
|
|
131
|
+
|
|
132
|
+
const phylo = PhyloIO.init();
|
|
133
|
+
|
|
134
|
+
// >>> test with internal label for branches
|
|
135
|
+
var m1 = phylo._create_model(data, {'data_type' : 'nhx'})
|
|
136
|
+
m1.settings.edge_related_data.push('Data');
|
|
137
|
+
m1.traverse(m1.data,verify_boostrap_default);
|
|
138
|
+
|
|
139
|
+
// reroot on BX
|
|
140
|
+
var bx_node = null;
|
|
141
|
+
m1.traverse(m1.data, function(node, children) {
|
|
142
|
+
|
|
143
|
+
var con_leaves = getSortedLeaves(node)
|
|
144
|
+
|
|
145
|
+
if ( con_leaves.length <= 1) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
var str_leaves = JSON.stringify(con_leaves);
|
|
150
|
+
|
|
151
|
+
if (str_leaves === JSON.stringify(['B', 'X'])) {
|
|
152
|
+
bx_node = node;
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
m1.reroot(bx_node);
|
|
156
|
+
m1.traverse(m1.data,function(node, children) {
|
|
157
|
+
|
|
158
|
+
var con_leaves = getSortedLeaves(node)
|
|
159
|
+
|
|
160
|
+
if ( con_leaves.length <= 1) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
var str_leaves = JSON.stringify(con_leaves);
|
|
165
|
+
|
|
166
|
+
switch (str_leaves){
|
|
167
|
+
case JSON.stringify(['C', 'D', 'E']):
|
|
168
|
+
expect(node.extended_informations.Data).toBe("2");
|
|
169
|
+
break;
|
|
170
|
+
case JSON.stringify(['C', 'D']):
|
|
171
|
+
expect(node.extended_informations.Data).toBe("1");
|
|
172
|
+
break;
|
|
173
|
+
case JSON.stringify(['A', 'B', 'C', 'D', 'E', 'X']):
|
|
174
|
+
expect(node.extended_informations.Data).toBeNull();
|
|
175
|
+
break;
|
|
176
|
+
case JSON.stringify(['A', 'C', 'D', 'E']):
|
|
177
|
+
expect(node.extended_informations.Data).toBe("3");
|
|
178
|
+
break;
|
|
179
|
+
case JSON.stringify(['B', 'X']):
|
|
180
|
+
expect(node.extended_informations.Data).toBe("3");
|
|
181
|
+
break;
|
|
182
|
+
default:
|
|
183
|
+
expect(true).toBe(false);
|
|
184
|
+
break
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
// reroot on CD
|
|
189
|
+
var cd_node = null;
|
|
190
|
+
m1.traverse(m1.data, function(node, children) {
|
|
191
|
+
|
|
192
|
+
var con_leaves = getSortedLeaves(node)
|
|
193
|
+
|
|
194
|
+
if ( con_leaves.length <= 1) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
var str_leaves = JSON.stringify(con_leaves);
|
|
199
|
+
|
|
200
|
+
if (str_leaves === JSON.stringify(['C', 'D'])) {
|
|
201
|
+
cd_node = node;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
m1.reroot(cd_node);
|
|
205
|
+
m1.traverse(m1.data,function(node, children) {
|
|
206
|
+
|
|
207
|
+
var con_leaves = getSortedLeaves(node)
|
|
208
|
+
|
|
209
|
+
if ( con_leaves.length <= 1) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
var str_leaves = JSON.stringify(con_leaves);
|
|
214
|
+
|
|
215
|
+
switch (str_leaves){
|
|
216
|
+
case JSON.stringify(['A', 'B', 'X']):
|
|
217
|
+
expect(node.extended_informations.Data).toBe("2");
|
|
218
|
+
break;
|
|
219
|
+
case JSON.stringify(['C', 'D']):
|
|
220
|
+
expect(node.extended_informations.Data).toBe("1");
|
|
221
|
+
break;
|
|
222
|
+
case JSON.stringify(['A', 'B', 'C', 'D', 'E', 'X']):
|
|
223
|
+
expect(node.extended_informations.Data).toBeNull();
|
|
224
|
+
break;
|
|
225
|
+
case JSON.stringify(['A', 'B', 'E', 'X']):
|
|
226
|
+
expect(node.extended_informations.Data).toBe("1");
|
|
227
|
+
break;
|
|
228
|
+
case JSON.stringify(['B', 'X']):
|
|
229
|
+
expect(node.extended_informations.Data).toBe("3");
|
|
230
|
+
break;
|
|
231
|
+
default:
|
|
232
|
+
expect(true).toBe(false);
|
|
233
|
+
break
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
// reroot on BX
|
|
238
|
+
var bx2_node = null;
|
|
239
|
+
m1.traverse(m1.data, function(node, children) {
|
|
240
|
+
|
|
241
|
+
var con_leaves = getSortedLeaves(node)
|
|
242
|
+
|
|
243
|
+
if ( con_leaves.length <= 1) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
var str_leaves = JSON.stringify(con_leaves);
|
|
248
|
+
|
|
249
|
+
console.log(str_leaves)
|
|
250
|
+
|
|
251
|
+
if (str_leaves === JSON.stringify(['B', 'X'])) {
|
|
252
|
+
|
|
253
|
+
bx2_node = node;
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
m1.reroot(bx2_node);
|
|
257
|
+
m1.traverse(m1.data,function(node, children) {
|
|
258
|
+
|
|
259
|
+
var con_leaves = getSortedLeaves(node)
|
|
260
|
+
|
|
261
|
+
if ( con_leaves.length <= 1) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
var str_leaves = JSON.stringify(con_leaves);
|
|
266
|
+
|
|
267
|
+
switch (str_leaves){
|
|
268
|
+
case JSON.stringify(['C', 'D', 'E']):
|
|
269
|
+
expect(node.extended_informations.Data).toBe("2");
|
|
270
|
+
break;
|
|
271
|
+
case JSON.stringify(['C', 'D']):
|
|
272
|
+
expect(node.extended_informations.Data).toBe("1");
|
|
273
|
+
break;
|
|
274
|
+
case JSON.stringify(['A', 'B', 'C', 'D', 'E', 'X']):
|
|
275
|
+
expect(node.extended_informations.Data).toBeNull();
|
|
276
|
+
break;
|
|
277
|
+
case JSON.stringify(['A', 'C', 'D', 'E']):
|
|
278
|
+
expect(node.extended_informations.Data).toBe("3");
|
|
279
|
+
break;
|
|
280
|
+
case JSON.stringify(['B', 'X']):
|
|
281
|
+
expect(node.extended_informations.Data).toBe("3");
|
|
282
|
+
break;
|
|
283
|
+
default:
|
|
284
|
+
expect(true).toBe(false);
|
|
285
|
+
break
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
})
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
package/src/api.js
CHANGED
|
@@ -11,6 +11,7 @@ export default class API {
|
|
|
11
11
|
constructor() {
|
|
12
12
|
|
|
13
13
|
this.settings = {
|
|
14
|
+
'version' : 1,
|
|
14
15
|
'phylostratigraphy' : false,
|
|
15
16
|
'share_phylo': ' https://beta.phylo.io/viewer/',
|
|
16
17
|
'share_post': ' https://beta.phylo.io/sharing/create/',
|
|
@@ -59,6 +60,7 @@ export default class API {
|
|
|
59
60
|
this.bound_container = [] // pair of container used for distance computation
|
|
60
61
|
this.session_token = null // unique session token for cloud saving
|
|
61
62
|
this.session_url = null // url for cloud saving
|
|
63
|
+
this.session_answer = null; // data from reply when generating session
|
|
62
64
|
this.phylo_embedded = false // phylo.io website mode
|
|
63
65
|
this.distance = {
|
|
64
66
|
'RF' : false,
|
|
@@ -418,7 +420,7 @@ export default class API {
|
|
|
418
420
|
|
|
419
421
|
screen_shot(params){screen_shot(params)}
|
|
420
422
|
|
|
421
|
-
generate_share_link(){
|
|
423
|
+
generate_share_link(callback){
|
|
422
424
|
|
|
423
425
|
var that = this
|
|
424
426
|
var xhr = new XMLHttpRequest();
|
|
@@ -428,22 +430,30 @@ export default class API {
|
|
|
428
430
|
if (this.readyState != 4) return;
|
|
429
431
|
|
|
430
432
|
else if (this.status == 201) {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
if (data.result
|
|
434
|
-
that.
|
|
435
|
-
that.session_url = that.settings.share_phylo + '?session=' +
|
|
433
|
+
let data = JSON.parse(this.responseText);
|
|
434
|
+
that.session_answer = data;
|
|
435
|
+
if (data.result === 'OK'){
|
|
436
|
+
that.token = data.session;
|
|
437
|
+
that.session_url = that.settings.share_phylo + '?session=' + data.session;
|
|
436
438
|
}
|
|
437
439
|
}
|
|
438
440
|
|
|
439
441
|
else if (this.status == 413) {
|
|
440
|
-
|
|
441
|
-
|
|
442
|
+
let data = JSON.parse(this.responseText);
|
|
443
|
+
that.session_url = 'ERROR_SIZE';
|
|
444
|
+
that.session_answer = data;
|
|
442
445
|
}
|
|
443
446
|
|
|
444
447
|
else if (this.status == 400) {
|
|
445
|
-
|
|
448
|
+
let data = JSON.parse(this.responseText) | {result: "Error", message: "The server does not accept this session data"};
|
|
449
|
+
that.session_answer = data
|
|
450
|
+
that.session_url = ""
|
|
451
|
+
}
|
|
452
|
+
else {
|
|
453
|
+
that.session_answer = {result: "Error", message: "The server is currently not available."}
|
|
454
|
+
that.session_url = ""
|
|
446
455
|
}
|
|
456
|
+
callback(that)
|
|
447
457
|
};
|
|
448
458
|
|
|
449
459
|
xhr.open("POST", this.settings.share_post, false);
|