-
Notifications
You must be signed in to change notification settings - Fork 16
/
test.sh
executable file
·2253 lines (1992 loc) · 70.5 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
########## Test Suite for Gotree command line tools ##############
set -e
set -u
set -o pipefail
TESTDATA="tests/data"
GOTREE=./gotree
# gotree stats with comments before tree
echo "->gotree stats with []"
cat > input <<EOF
[comment](Tip3,Tip0,((Tip4,Tip2),Tip1));
(Tip4,Tip0,((Tip3,Tip2),Tip1));
[comment;():,](Tip2,Tip0,((Tip4,Tip3),Tip1));
(Tip2,Tip0,((Tip4,Tip3),Tip1));
EOF
cat > expected <<EOF
tips
5
5
5
5
EOF
${GOTREE} stats -i input | cut -f 3 > result
diff -q -b result expected
rm -f expected result input
# gotree annotate
echo "->gotree annotate"
cat > mapfile <<EOF
internal1:Tip6,Tip5,Tip1
EOF
cat > expected <<EOF
((Tip4,(Tip7,Tip2)),Tip0,((Tip8,(Tip9,Tip3)),((Tip6,Tip5),Tip1)internal1));
EOF
${GOTREE} generate yuletree --seed 10 | ${GOTREE} brlen clear | ${GOTREE} annotate -m mapfile > result
diff -q -b result expected
rm -f expected result mapfile
# gotree annotate
echo "->gotree annotate 2"
cat > mapfile <<EOF
ACGACTCATCTA:Tip6,Tip5,Tip1
ACGACTCATCTA:internal1
EOF
cat > intree <<EOF
((Tip4,(Tip7,Tip2)),Tip0,((Tip8,(Tip9,Tip3))internal1,((Tip6,Tip5),Tip1)));
EOF
cat > expected <<EOF
((Tip4,(Tip7,Tip2)),Tip0,((Tip8,(Tip9,Tip3))ACGACTCATCTA,((Tip6,Tip5),Tip1)ACGACTCATCTA));
EOF
${GOTREE} annotate -i intree -m mapfile > result
diff -q -b result expected
rm -f expected result intree mapfile
# gotree annotate
echo "->gotree annotate comment"
cat > mapfile <<EOF
internal1:Tip6,Tip5,Tip1
EOF
cat > expected <<EOF
((Tip4,(Tip7,Tip2)),Tip0,((Tip8,(Tip9,Tip3)),((Tip6,Tip5),Tip1)[internal1]));
EOF
${GOTREE} generate yuletree --seed 10 | ${GOTREE} brlen clear | ${GOTREE} annotate --comment -m mapfile > result
diff -q -b result expected
rm -f expected result mapfile
# gotree annotate
echo "->gotree annotate comment 2"
cat > mapfile <<EOF
ACGACTCATCTA:Tip6,Tip5,Tip1
ACGACTCATCTA:internal1
EOF
cat > intree <<EOF
((Tip4,(Tip7,Tip2)),Tip0,((Tip8,(Tip9,Tip3))internal1,((Tip6,Tip5),Tip1)));
EOF
cat > expected <<EOF
((Tip4,(Tip7,Tip2)),Tip0,((Tip8,(Tip9,Tip3))internal1[ACGACTCATCTA],((Tip6,Tip5),Tip1)[ACGACTCATCTA]));
EOF
${GOTREE} annotate -i intree --comment -m mapfile > result
diff -q -b result expected
rm -f expected result intree mapfile
# gotree annotate with tree
echo "->gotree annotate with tree"
cat > intree <<EOF
((Tip4,(Tip7,Tip2)n1)n2,Tip0,((Tip8,(Tip9,Tip3)n3)n4,((Tip6,Tip1)n5,Tip5)n6)n7);
EOF
cat > expected1 <<EOF
((Tip4,(Tip7,Tip2)n1_0_2)n2_0_3,Tip0,((Tip8,(Tip9,Tip3)n3_0_2)n4_0_3,((Tip6,Tip5),Tip1)n6_0_3)n7_0_6);
EOF
cat > expected2 <<EOF
((Tip4,(Tip7,Tip2)n1_0_2)n2_0_3,Tip0,((Tip8,(Tip9,Tip3)n3_0_2)n4_0_3,((Tip6,Tip5)n6_1_2,Tip1)n6_0_3)n7_0_6);
EOF
${GOTREE} generate yuletree --seed 10 | ${GOTREE} brlen clear | ${GOTREE} annotate -c intree > result
diff -q -b result expected1 || diff -q -b result expected2
rm -f expected1 expected2 result intree
# gotree annotate with tree
echo "->gotree annotate with tree comments"
cat > intree <<EOF
((Tip4,(Tip7,Tip2)n1)n2,Tip0,((Tip8,(Tip9,Tip3)n3)n4,((Tip6,Tip1)n5,Tip5)n6)n7);
EOF
cat > expected1 <<EOF
((Tip4,(Tip7,Tip2)[n1_0_2])[n2_0_3],Tip0,((Tip8,(Tip9,Tip3)[n3_0_2])[n4_0_3],((Tip6,Tip5),Tip1)[n6_0_3])[n7_0_6]);
EOF
cat > expected2 <<EOF
((Tip4,(Tip7,Tip2)[n1_0_2])[n2_0_3],Tip0,((Tip8,(Tip9,Tip3)[n3_0_2])[n4_0_3],((Tip6,Tip5)[n6_1_2],Tip1)[n6_0_3])[n7_0_6]);
EOF
${GOTREE} generate yuletree --seed 10 | ${GOTREE} brlen clear | ${GOTREE} annotate --comment -c intree > result
diff -q -b result expected1 || diff -q -b result expected2
rm -f expected result intree
# gotree brlen clear
echo "->gotree brlen clear"
cat > expected <<EOF
((Tip4,(Tip7,Tip2)),Tip0,((Tip8,(Tip9,Tip3)),((Tip6,Tip5),Tip1)));
(Tip5,Tip0,((Tip6,(Tip7,Tip4)),(Tip2,((Tip8,(Tip9,Tip3)),Tip1))));
(Tip6,Tip0,((((Tip5,Tip4),((Tip9,Tip8),Tip3)),(Tip7,Tip2)),Tip1));
(Tip3,Tip0,(((Tip6,Tip5),Tip2),(((Tip9,Tip8),Tip4),(Tip7,Tip1))));
(((Tip4,(Tip8,Tip3)),((Tip6,Tip5),Tip2)),Tip0,(Tip7,(Tip9,Tip1)));
(Tip4,Tip0,(Tip3,((((Tip8,Tip7),Tip5),((Tip9,Tip6),Tip2)),Tip1)));
(Tip5,Tip0,((Tip8,Tip2),((Tip7,Tip3),((Tip9,Tip4),(Tip6,Tip1)))));
((Tip9,Tip6),Tip0,((((Tip8,Tip4),Tip3),Tip2),((Tip7,Tip5),Tip1)));
(Tip9,Tip0,(Tip8,((Tip7,Tip4),((Tip6,Tip2),(Tip3,(Tip5,Tip1))))));
((((Tip7,(Tip8,(Tip9,Tip6))),Tip5),Tip4),Tip0,(Tip2,(Tip3,Tip1)));
EOF
${GOTREE} generate yuletree --seed 10 -n 10 | ${GOTREE} brlen clear > result
diff -q -b result expected
rm -f expected result
# gotree brlen scale
echo "->gotree brlen scale"
cat > input.tree <<EOF
((Tip4:1,(Tip7:1,Tip2:1):1):1,Tip0:1,((Tip8:1,(Tip9:1,Tip3:1):1):1,((Tip6:1,Tip5:1):1,Tip1:1):1):1);
(Tip5,Tip0,((Tip6,(Tip7,Tip4)),(Tip2,((Tip8,(Tip9,Tip3)),Tip1))));
(Tip6:0.5,Tip0:0.5,((((Tip5:0.5,Tip4:0.5):0.5,((Tip9:0.5,Tip8:0.5),Tip3:0.5):0.5):0.5,(Tip7:0.5,Tip2:0.5):0.5):0.5,Tip1:0.5):0.5);
EOF
cat > expected <<EOF
((Tip4:3,(Tip7:3,Tip2:3):3):3,Tip0:3,((Tip8:3,(Tip9:3,Tip3:3):3):3,((Tip6:3,Tip5:3):3,Tip1:3):3):3);
(Tip5,Tip0,((Tip6,(Tip7,Tip4)),(Tip2,((Tip8,(Tip9,Tip3)),Tip1))));
(Tip6:1.5,Tip0:1.5,((((Tip5:1.5,Tip4:1.5):1.5,((Tip9:1.5,Tip8:1.5),Tip3:1.5):1.5):1.5,(Tip7:1.5,Tip2:1.5):1.5):1.5,Tip1:1.5):1.5);
EOF
${GOTREE} brlen scale -i input.tree -f 3.0 > result
diff -q -b result expected
rm -f expected result input.tree
# gotree support scale
echo "->gotree support scale"
cat > input.tree <<EOF
((a,b)99,(c,d)50,(e,f)0,g);
EOF
cat > expected.1 <<EOF
((a,b)0.99,(c,d)0.5,(e,f)0,g);
EOF
cat > expected.2 <<EOF
((a,b)198,(c,d)100,(e,f)0,g);
EOF
${GOTREE} support scale -i input.tree -f 0.01 > result.1
${GOTREE} support scale -i input.tree -f 2 > result.2
diff -q -b result.1 expected.1
diff -q -b result.2 expected.2
rm -f expected.1 expected.2 result.1 result.2 input.tree
# gotree support clear
echo "->gotree support clear"
cat > expected <<EOF
((Tip4,(Tip7,Tip2)),Tip0,((Tip8,(Tip9,Tip3)),((Tip6,Tip5),Tip1)));
(Tip5,Tip0,((Tip6,(Tip7,Tip4)),(Tip2,((Tip8,(Tip9,Tip3)),Tip1))));
(Tip6,Tip0,((((Tip5,Tip4),((Tip9,Tip8),Tip3)),(Tip7,Tip2)),Tip1));
(Tip3,Tip0,(((Tip6,Tip5),Tip2),(((Tip9,Tip8),Tip4),(Tip7,Tip1))));
(((Tip4,(Tip8,Tip3)),((Tip6,Tip5),Tip2)),Tip0,(Tip7,(Tip9,Tip1)));
(Tip4,Tip0,(Tip3,((((Tip8,Tip7),Tip5),((Tip9,Tip6),Tip2)),Tip1)));
(Tip5,Tip0,((Tip8,Tip2),((Tip7,Tip3),((Tip9,Tip4),(Tip6,Tip1)))));
((Tip9,Tip6),Tip0,((((Tip8,Tip4),Tip3),Tip2),((Tip7,Tip5),Tip1)));
(Tip9,Tip0,(Tip8,((Tip7,Tip4),((Tip6,Tip2),(Tip3,(Tip5,Tip1))))));
((((Tip7,(Tip8,(Tip9,Tip6))),Tip5),Tip4),Tip0,(Tip2,(Tip3,Tip1)));
EOF
${GOTREE} generate yuletree --seed 10 -n 10 | ${GOTREE} support setrand | ${GOTREE} support clear | ${GOTREE} brlen clear > result
diff -q -b result expected
rm -f expected result
# gotree comment clear
echo "->gotree comment clear"
cat > input <<EOF
(t1[c1],t2[c2],(t3[c3],t4[c4])[c5]);
EOF
cat > expected <<EOF
(t1,t2,(t3,t4));
EOF
${GOTREE} comment clear -i input > result
diff -q -b result expected
rm -f expected result input
# gotree comment clear nodes+edges
echo "->gotree comment clear (nodes+edges)"
cat > input <<EOF
(t1[n1]:1[e1],t2[n2]:1[e2],(t3[n3]:1[e3],t4[n4]:1[e4])[n5]:1[e5]);
EOF
cat > expected <<EOF
(t1:1,t2:1,(t3:1,t4:1):1);
EOF
${GOTREE} comment clear -i input > result
diff -q -b result expected
rm -f expected result input
# gotree comment clear nodes only
echo "->gotree comment clear (nodes)"
cat > input <<EOF
(t1[n1]:1[e1],t2[n2]:1[e2],(t3[n3]:1[e3],t4[n4]:1[e4])[n5]:1[e5]);
EOF
cat > expected <<EOF
(t1:1[e1],t2:1[e2],(t3:1[e3],t4:1[e4]):1[e5]);
EOF
${GOTREE} comment clear --nodes-only -i input > result
diff -q -b result expected
rm -f expected result input
# gotree comment clear edges only
echo "->gotree comment clear (edges)"
cat > input <<EOF
(t1[n1]:1[e1],t2[n2]:1[e2],(t3[n3]:1[e3],t4[n4]:1[e4])[n5]:1[e5]);
EOF
cat > expected <<EOF
(t1[n1]:1,t2[n2]:1,(t3[n3]:1,t4[n4]:1)[n5]:1);
EOF
${GOTREE} comment clear --edges-only -i input > result
diff -q -b result expected
rm -f expected result input
# gotree comment transfer
echo "->gotree comment transfer"
cat > input <<EOF
(t1:1,t2:1,(t3:1,t4:1)n5:1);
EOF
cat > expected <<EOF
(t1:1,t2:1,(t3:1,t4:1)[n5]:1);
EOF
${GOTREE} comment transfer -i input > result
diff -q -b result expected
rm -f expected result input
# gotree comment transfer --reverse
echo "->gotree comment transfer --reverse"
cat > input <<EOF
(t1:1,t2:1,(t3:1,t4:1)[n5]:1);
EOF
cat > expected <<EOF
(t1:1,t2:1,(t3:1,t4:1)n5:1);
EOF
${GOTREE} comment transfer --reverse -i input > result
diff -q -b result expected
rm -f expected result input
# gotree collapse length
echo "->gotree collapse length"
cat > expected <<EOF
((Tip4,(Tip7,Tip2)),Tip0,(Tip8,Tip9,Tip3),((Tip6,Tip5),Tip1));
EOF
${GOTREE} generate yuletree --seed 10 | ${GOTREE} collapse length -l 0.05 | ${GOTREE} brlen clear > result
diff -q -b result expected
rm -f expected result
echo "->gotree collapse support root + tips"
cat > expected <<EOF
(A:1,B:1,C:1,D:1);
EOF
echo "((A:1,B:1)0.2:1,(C:1,D:1)0.1:1);" | ${GOTREE} collapse support -s 1 --root > result
diff -q -b result expected
rm -f expected result
echo "->gotree collapse length root + tips"
cat > expected <<EOF
(A:0,B:0,C:0,D:0);
EOF
echo "((A:1,B:1)0.2:1,(C:1,D:1)0.1:1);" | ${GOTREE} collapse length -l 2 --root --tips > result
diff -q -b result expected
rm -f expected result
echo "->gotree collapse depth root + tips"
cat > expected <<EOF
(A:0,B:0,C:0,D:0);
EOF
echo "((A:1,B:1)0.2:1,(C:1,D:1)0.1:1);" | ${GOTREE} collapse depth -m 0 -M 10 --root --tips > result
diff -q -b result expected
rm -f expected result
# gotree collapse support
echo "->gotree collapse support"
cat > expected <<EOF
(Tip0,((Tip1,Tip6,Tip5)0.9167074899036827,Tip8,Tip9,Tip3)0.925128845219594,Tip4,Tip7,Tip2);
EOF
${GOTREE} generate yuletree --seed 10 | ${GOTREE} support setrand --seed 10 | ${GOTREE} collapse support -s 0.7 | ${GOTREE} brlen clear > result
diff -q -b result expected
rm -f expected result
# gotree collapse depth
echo "->gotree collapse depth"
cat > expected <<EOF
((Tip4,Tip7,Tip2),Tip0,((Tip8,Tip9,Tip3),(Tip1,Tip6,Tip5)));
EOF
${GOTREE} generate yuletree --seed 10 | ${GOTREE} collapse depth -m 2 -M 2 | ${GOTREE} brlen clear > result
diff -q -b result expected
rm -f expected result
# gotree collapse id
echo "->gotree collapse id/name"
cat > input <<EOF
((Tip4,Tip7,Tip2),Tip0,((Tip8,Tip9,Tip3),(Tip1,Tip6,Tip5)));
EOF
cat > expected <<EOF
(Tip0,Tip4,Tip7,Tip2,Tip8,Tip9,Tip3,Tip1,Tip6,Tip5);
EOF
cat > expected2 <<EOF
(Tip0,Tip4,Tip7,Tip2,(Tip1,Tip6,Tip5),Tip8,Tip9,Tip3);
EOF
cat > br <<EOF
0
5
6
10
EOF
cat > br2 <<EOF
0
5
6
EOF
${GOTREE} collapse name -i input --id -b br > result
diff -q -b result expected
${GOTREE} collapse name -i input --id -b br2 > result
diff -q -b result expected2
rm -f input expected result br br2 expected2
# gotree collapse single
echo "->gotree collapse single"
cat > test_input <<EOF
((((A,B)),((C))),(D,(E)));
EOF
cat > expected <<EOF
(((A,B),C),(D,E));
EOF
${GOTREE} collapse single -i test_input > result
diff -q -b result expected
rm -f expected result test_input
# gotree compare trees
echo "->gotree compare trees"
cat > expected <<EOF
tree reference common compared
0 7 0 7
EOF
${GOTREE} compare trees -i <(${GOTREE} generate yuletree --seed 10) -c <(${GOTREE} generate yuletree --seed 12 -n 1) > result
diff -q -b expected result
rm -f expected result
# gotree compare trees weighted
echo "->gotree compare trees weighted"
cat > input <<EOF
(A:0.1,(B:0.1,(H:0.1,(D:0.1,(J:0.1,(((G:0.1,E:0.1):0.1,(F:0.1,I:0.1):0.1):0.1,C:0.1):0.1):0.1):0.1):0.1):0.1);
(A:0.1,(B:0.1,(D:0.1,((J:0.1,H:0.1):0.1,(((G:0.1,E:0.1):0.1,(F:0.1,I:0.1):0.1):0.1,C:0.1):0.1):0.1):0.1):0.1);
(A:0.1,(B:0.1,(D:0.1,(H:0.1,(J:0.1,(((G:0.1,E:0.1):0.1,(F:0.1,I:0.1):0.1):0.1,C:0.1):0.1):0.1):0.1):0.1):0.1);
(A:0.1,(B:0.1,(E:0.1,(G:0.1,((F:0.1,I:0.1):0.1,((J:0.1,(H:0.1,D:0.1):0.1):0.1,C:0.1):0.1):0.1):0.1):0.1):0.1);
(A:0.1,(B:0.1,(E:0.1,(G:0.1,((F:0.1,I:0.1):0.1,(((J:0.1,H:0.1):0.1,D:0.1):0.1,C:0.1):0.1):0.1):0.1):0.1):0.1);
(A:0.1,(B:0.1,(E:0.1,((F:0.1,I:0.1):0.1,(G:0.1,((J:0.1,(H:0.1,D:0.1):0.1):0.1,C:0.1):0.1):0.1):0.1):0.1):0.1);
(A:0.1,(B:0.1,(E:0.1,((F:0.1,I:0.1):0.1,(G:0.1,(((J:0.1,H:0.1):0.1,D:0.1):0.1,C:0.1):0.1):0.1):0.1):0.1):0.1);
(A:0.1,(B:0.1,(E:0.1,((G:0.1,(F:0.1,I:0.1):0.1):0.1,((J:0.1,(H:0.1,D:0.1):0.1):0.1,C:0.1):0.1):0.1):0.1):0.1);
(A:0.1,(B:0.1,(E:0.1,((G:0.1,(F:0.1,I:0.1):0.1):0.1,(((J:0.1,H:0.1):0.1,D:0.1):0.1,C:0.1):0.1):0.1):0.1):0.1);
(A:0.1,(B:0.1,(E:0.1,(G:0.1,((F:0.1,I:0.1):0.1,((J:0.1,(H:0.1,D:0.1):0.1):0.1,C:0.1):0.1):0.1):0.1):0.1):0.1);
(A:0.1,(B:0.1,(D:0.1,(H:0.1,(J:0.1,(((G:0.1,E:0.1):0.1,(F:0.1,I:0.1):0.1):0.1,C:0.1):0.1):0.1):0.1):0.1):0.1);
(A:0.1,(B:0.1,(E:0.1,((G:0.1,(F:0.1,I:0.1):0.1):0.1,((J:0.1,(H:0.1,D:0.1):0.1):0.1,C:0.1):0.1):0.1):0.1):0.1);
EOF
cat > expected <<EOF
KF KF KF KF KF KF KF KF KF KF KF KF
0.000000E+00 2.000000E-01 1.414214E-01 3.162278E-01 3.162278E-01 3.162278E-01 3.162278E-01 3.162278E-01 3.162278E-01 3.162278E-01 1.414214E-01 3.162278E-01
2.000000E-01 0.000000E+00 1.414214E-01 3.162278E-01 2.828427E-01 3.162278E-01 2.828427E-01 3.162278E-01 2.828427E-01 3.162278E-01 1.414214E-01 3.162278E-01
1.414214E-01 1.414214E-01 0.000000E+00 3.162278E-01 3.162278E-01 3.162278E-01 3.162278E-01 3.162278E-01 3.162278E-01 3.162278E-01 0.000000E+00 3.162278E-01
3.162278E-01 3.162278E-01 3.162278E-01 0.000000E+00 1.414214E-01 1.414214E-01 2.000000E-01 1.414214E-01 2.000000E-01 0.000000E+00 3.162278E-01 1.414214E-01
3.162278E-01 2.828427E-01 3.162278E-01 1.414214E-01 0.000000E+00 2.000000E-01 1.414214E-01 2.000000E-01 1.414214E-01 1.414214E-01 3.162278E-01 2.000000E-01
3.162278E-01 3.162278E-01 3.162278E-01 1.414214E-01 2.000000E-01 0.000000E+00 1.414214E-01 1.414214E-01 2.000000E-01 1.414214E-01 3.162278E-01 1.414214E-01
3.162278E-01 2.828427E-01 3.162278E-01 2.000000E-01 1.414214E-01 1.414214E-01 0.000000E+00 2.000000E-01 1.414214E-01 2.000000E-01 3.162278E-01 2.000000E-01
3.162278E-01 3.162278E-01 3.162278E-01 1.414214E-01 2.000000E-01 1.414214E-01 2.000000E-01 0.000000E+00 1.414214E-01 1.414214E-01 3.162278E-01 0.000000E+00
3.162278E-01 2.828427E-01 3.162278E-01 2.000000E-01 1.414214E-01 2.000000E-01 1.414214E-01 1.414214E-01 0.000000E+00 2.000000E-01 3.162278E-01 1.414214E-01
3.162278E-01 3.162278E-01 3.162278E-01 0.000000E+00 1.414214E-01 1.414214E-01 2.000000E-01 1.414214E-01 2.000000E-01 0.000000E+00 3.162278E-01 1.414214E-01
1.414214E-01 1.414214E-01 0.000000E+00 3.162278E-01 3.162278E-01 3.162278E-01 3.162278E-01 3.162278E-01 3.162278E-01 3.162278E-01 0.000000E+00 3.162278E-01
3.162278E-01 3.162278E-01 3.162278E-01 1.414214E-01 2.000000E-01 1.414214E-01 2.000000E-01 0.000000E+00 1.414214E-01 1.414214E-01 3.162278E-01 0.000000E+00
EOF
var=1
while IFS= read -r line; do
echo "$line" | ${GOTREE} compare trees --weighted -c input | cut -d $'\t' -f3 > $var.txt
var=$((var + 1))
done < input
# Make a pretty table
paste {1,2,3,4,5,6,7,8,9,10,11,12}.txt > result
# Remove temp files
rm {1,2,3,4,5,6,7,8,9,10,11,12}.txt
diff -q -b expected result
rm -f expected input result
# gotree compare edges
echo "->gotree compare edges"
cat > expected <<EOF
tree brid length support terminal depth topodepth rootdepth rightname found comment transfer taxatomove comparednodename comparedlength comparedsupport comparedtopodepth comparedid comparedcomment
0 0 0.1824683850061218 N/A false 1 3 -1 false [] 2 +Tip4,+Tip2 Tip7 0.2281203179753742 N/A 1 14 []
0 1 0.020616211789029896 N/A true 0 1 -1 Tip4 true [] 0 Tip4 0.32980883896257585 N/A 1 2 []
0 2 0.25879284932877245 N/A false 1 2 -1 false [] 1 +Tip2 Tip7 0.2281203179753742 N/A 1 14 []
0 3 0.09740195047110385 N/A true 0 1 -1 Tip7 true [] 0 Tip7 0.2281203179753742 N/A 1 14 []
0 4 0.015450672710905129 N/A true 0 1 -1 Tip2 true [] 0 Tip2 0.037584651176611125 N/A 1 11 []
0 5 0.25919865790518115 N/A true 0 1 -1 Tip0 true [] 0 Tip0 0.11291296397843323 N/A 1 3 []
0 6 0.04593880904706901 N/A false 1 4 -1 false [] 3 +Tip2,+Tip7,-Tip6 0.05806229063227526 N/A 3 4 []
0 7 0.1920960924280275 N/A false 1 3 -1 false [] 1 +Tip3 0.005131510752894519 N/A 2 8 []
0 8 0.027845992087631298 N/A true 0 1 -1 Tip8 true [] 0 Tip8 0.060367242116658816 N/A 1 10 []
0 9 0.01026581233891113 N/A false 1 2 -1 false [] 1 +Tip3 Tip9 0.16045157517594316 N/A 1 9 []
0 10 0.13492605122032592 N/A true 0 1 -1 Tip9 true [] 0 Tip9 0.16045157517594316 N/A 1 9 []
0 11 0.10309294031874587 N/A true 0 1 -1 Tip3 true [] 0 Tip3 0.35163191615522493 N/A 1 5 []
0 12 0.30150414585026103 N/A false 1 3 -1 false [] 2 +Tip6,-Tip7 0.12937482578337411 N/A 3 12 []
0 13 0.05817538156872999 N/A false 1 2 -1 false [] 1 +Tip6 Tip5 0.054439044275040135 N/A 1 15 []
0 14 0.3779897840448691 N/A true 0 1 -1 Tip6 true [] 0 Tip6 0.05325654013915672 N/A 1 1 []
0 15 0.1120177846434196 N/A true 0 1 -1 Tip5 true [] 0 Tip5 0.054439044275040135 N/A 1 15 []
0 16 0.239082088939295 N/A true 0 1 -1 Tip1 true [] 0 Tip1 0.013105562909283169 N/A 1 16 []
EOF
${GOTREE} compare edges -i <(${GOTREE} generate yuletree --seed 10) -c <(${GOTREE} generate yuletree --seed 12 -n 1) -m --moved-taxa > result 2>/dev/null
diff -q -b expected result
rm -f expected result
# gotree compare edges
echo "->gotree compare edges /2 (same tree)"
cat > expected <<EOF
tree brid length support terminal depth topodepth rootdepth rightname found comment transfer taxatomove comparednodename comparedlength comparedsupport comparedtopodepth comparedid comparedcomment
0 0 0.1824683850061218 N/A false 1 3 -1 true [] 0 0.1824683850061218 N/A 3 0 []
0 1 0.020616211789029896 N/A true 0 1 -1 Tip4 true [] 0 Tip4 0.020616211789029896 N/A 1 1 []
0 2 0.25879284932877245 N/A false 1 2 -1 true [] 0 0.25879284932877245 N/A 2 2 []
0 3 0.09740195047110385 N/A true 0 1 -1 Tip7 true [] 0 Tip7 0.09740195047110385 N/A 1 3 []
0 4 0.015450672710905129 N/A true 0 1 -1 Tip2 true [] 0 Tip2 0.015450672710905129 N/A 1 4 []
0 5 0.25919865790518115 N/A true 0 1 -1 Tip0 true [] 0 Tip0 0.25919865790518115 N/A 1 5 []
0 6 0.04593880904706901 N/A false 1 4 -1 true [] 0 0.04593880904706901 N/A 4 6 []
0 7 0.1920960924280275 N/A false 1 3 -1 true [] 0 0.1920960924280275 N/A 3 7 []
0 8 0.027845992087631298 N/A true 0 1 -1 Tip8 true [] 0 Tip8 0.027845992087631298 N/A 1 8 []
0 9 0.01026581233891113 N/A false 1 2 -1 true [] 0 0.01026581233891113 N/A 2 9 []
0 10 0.13492605122032592 N/A true 0 1 -1 Tip9 true [] 0 Tip9 0.13492605122032592 N/A 1 10 []
0 11 0.10309294031874587 N/A true 0 1 -1 Tip3 true [] 0 Tip3 0.10309294031874587 N/A 1 11 []
0 12 0.30150414585026103 N/A false 1 3 -1 true [] 0 0.30150414585026103 N/A 3 12 []
0 13 0.05817538156872999 N/A false 1 2 -1 true [] 0 0.05817538156872999 N/A 2 13 []
0 14 0.3779897840448691 N/A true 0 1 -1 Tip6 true [] 0 Tip6 0.3779897840448691 N/A 1 14 []
0 15 0.1120177846434196 N/A true 0 1 -1 Tip5 true [] 0 Tip5 0.1120177846434196 N/A 1 15 []
0 16 0.239082088939295 N/A true 0 1 -1 Tip1 true [] 0 Tip1 0.239082088939295 N/A 1 16 []
EOF
${GOTREE} compare edges -i <(${GOTREE} generate yuletree --seed 10) -c <(${GOTREE} generate yuletree --seed 10 -n 1) -m --moved-taxa > result 2>/dev/null
diff -q -b expected result
rm -f expected result
# gotree compare tips
echo "->gotree compare tips"
cat > expected <<EOF
(Tree 0) > Tip11
(Tree 0) > Tip10
(Tree 0) = 10
EOF
${GOTREE} compare tips -i <(${GOTREE} generate yuletree --seed 10) -c <(${GOTREE} generate yuletree --seed 12 -n 1 -l 12) > result
diff -q -b expected result
rm -f expected result
# gotree compare tips file
echo "->gotree compare tips file"
cat > expected <<EOF
(Tree 0) > Tip11
(Tree 0) > Tip10
(Tree 0) = 10
EOF
cat > tipfile <<EOF
Tip0
Tip1
Tip2
Tip3
Tip4
Tip5
Tip6
Tip7
Tip8
Tip9
Tip11
Tip10
EOF
${GOTREE} compare tips -i <(${GOTREE} generate yuletree --seed 10) -f tipfile > result
diff -q -b <(sort expected) <(sort result)
rm -f expected result
# # gotree compare distances
# echo "->gotree compare distances"
# cat > expected <<EOF
# tree_id er_id ec_id tdist ec_length ec_support ec_topodepth moving_taxa
# 0 0 0 3 0.018862750655150758 N/A 2 +Tip6,-Tip2,-Tip7
# 0 0 4 4 0.05806229063227526 N/A 3 +Tip0,+Tip6,-Tip2,-Tip7
# 0 0 6 5 0.006167968511774678 N/A 4 +Tip0,+Tip3,+Tip6,-Tip2,-Tip7
# 0 0 7 4 0.03856952076464118 N/A 3 +Tip8,+Tip9,-Tip4,-Tip7
# 0 0 8 5 0.005131510752894519 N/A 2 +Tip0,+Tip1,+Tip3,+Tip5,+Tip6
# 0 0 12 4 0.12937482578337411 N/A 3 +Tip1,+Tip5,-Tip2,-Tip4
# 0 0 13 3 0.00518311446616857 N/A 2 +Tip5,-Tip2,-Tip4
# 0 2 0 4 0.018862750655150758 N/A 2 +Tip4,+Tip6,-Tip2,-Tip7
# 0 2 4 5 0.05806229063227526 N/A 3 +Tip0,+Tip4,+Tip6,-Tip2,-Tip7
# 0 2 6 4 0.006167968511774678 N/A 4 +Tip1,+Tip5,+Tip8,+Tip9
# 0 2 7 3 0.03856952076464118 N/A 3 +Tip8,+Tip9,-Tip7
# 0 2 8 4 0.005131510752894519 N/A 2 +Tip8,+Tip9,-Tip2,-Tip7
# 0 2 12 3 0.12937482578337411 N/A 3 +Tip1,+Tip5,-Tip2
# 0 2 13 2 0.00518311446616857 N/A 2 +Tip5,-Tip2
# 0 6 0 4 0.018862750655150758 N/A 2 +Tip0,+Tip2,+Tip7,-Tip6
# 0 6 4 3 0.05806229063227526 N/A 3 +Tip2,+Tip7,-Tip6
# 0 6 6 4 0.006167968511774678 N/A 4 +Tip2,+Tip7,-Tip3,-Tip6
# 0 6 7 5 0.03856952076464118 N/A 3 +Tip0,+Tip4,+Tip7,-Tip8,-Tip9
# 0 6 8 4 0.005131510752894519 N/A 2 -Tip1,-Tip3,-Tip5,-Tip6
# 0 6 12 5 0.12937482578337411 N/A 3 +Tip0,+Tip2,+Tip4,-Tip1,-Tip5
# 0 6 13 4 0.00518311446616857 N/A 2 +Tip0,+Tip2,+Tip4,-Tip5
# 0 7 0 5 0.018862750655150758 N/A 2 +Tip0,+Tip1,+Tip2,+Tip5,+Tip7
# 0 7 4 4 0.05806229063227526 N/A 3 +Tip1,+Tip2,+Tip5,+Tip7
# 0 7 6 5 0.006167968511774678 N/A 4 +Tip0,+Tip4,+Tip6,-Tip8,-Tip9
# 0 7 7 2 0.03856952076464118 N/A 3 +Tip2,-Tip3
# 0 7 8 1 0.005131510752894519 N/A 2 -Tip3
# 0 7 12 4 0.12937482578337411 N/A 3 +Tip0,+Tip2,+Tip4,+Tip6
# 0 7 13 5 0.00518311446616857 N/A 2 +Tip0,+Tip1,+Tip2,+Tip4,+Tip6
# 0 9 0 4 0.018862750655150758 N/A 2 +Tip4,+Tip6,-Tip3,-Tip9
# 0 9 4 5 0.05806229063227526 N/A 3 +Tip0,+Tip4,+Tip6,-Tip3,-Tip9
# 0 9 6 4 0.006167968511774678 N/A 4 +Tip0,+Tip4,+Tip6,-Tip9
# 0 9 7 3 0.03856952076464118 N/A 3 +Tip2,+Tip8,-Tip3
# 0 9 8 2 0.005131510752894519 N/A 2 +Tip8,-Tip3
# 0 9 12 5 0.12937482578337411 N/A 3 +Tip0,+Tip2,+Tip4,+Tip6,+Tip8
# 0 9 13 4 0.00518311446616857 N/A 2 +Tip5,+Tip7,-Tip3,-Tip9
# 0 12 0 3 0.018862750655150758 N/A 2 +Tip4,-Tip1,-Tip5
# 0 12 4 4 0.05806229063227526 N/A 3 +Tip0,+Tip4,-Tip1,-Tip5
# 0 12 6 5 0.006167968511774678 N/A 4 +Tip0,+Tip3,+Tip4,-Tip1,-Tip5
# 0 12 7 4 0.03856952076464118 N/A 3 +Tip0,+Tip3,+Tip4,+Tip7
# 0 12 8 5 0.005131510752894519 N/A 2 +Tip0,+Tip2,+Tip3,+Tip4,+Tip7
# 0 12 12 2 0.12937482578337411 N/A 3 +Tip7,-Tip6
# 0 12 13 3 0.00518311446616857 N/A 2 +Tip7,-Tip1,-Tip6
# 0 13 0 2 0.018862750655150758 N/A 2 +Tip4,-Tip5
# 0 13 4 3 0.05806229063227526 N/A 3 +Tip0,+Tip4,-Tip5
# 0 13 6 4 0.006167968511774678 N/A 4 +Tip0,+Tip3,+Tip4,-Tip5
# 0 13 7 5 0.03856952076464118 N/A 3 +Tip0,+Tip1,+Tip3,+Tip4,+Tip7
# 0 13 8 4 0.005131510752894519 N/A 2 +Tip8,+Tip9,-Tip5,-Tip6
# 0 13 12 3 0.12937482578337411 N/A 3 +Tip1,+Tip7,-Tip6
# 0 13 13 2 0.00518311446616857 N/A 2 +Tip7,-Tip6
# EOF
# ${GOTREE} compare distances -i <(${GOTREE} generate yuletree --seed 10) -c <(${GOTREE} generate yuletree --seed 12 -n 1) > result 2>/dev/null
# diff -q -b expected result
# rm -f expected result
# goree compute bipartitiontree
echo "->gotree compute bipartitiontree"
cat > expected <<EOF
((Tip4:1,Tip7:1,Tip0:1,Tip8:1,Tip9:1,Tip6:1,Tip5:1):1,Tip1:1,Tip2:1,Tip3:1);
EOF
${GOTREE} generate yuletree --seed 10 | ${GOTREE} compute bipartitiontree Tip1 Tip2 Tip3 > result
diff -q -b expected result
rm -f result expected
# gotree compute consensus
echo "->gotree compute consensus"
cat > expected_comp <<EOF
tree reference common compared
0 0 5 0
EOF
cat > expected_tree <<EOF
(Tip0:0.12347870000000004,(Tip9:0.12811019999999992,(Tip8:0.018413999999999993,Tip3:0.10146340000000001)0.87:0.012998850574712643)1:0.08962310000000002,(Tip1:0.17112029999999998,Tip6:0.30890189999999984,Tip5:0.0929547)0.97:0.07447020618556698,(Tip4:0.030012499999999987,(Tip7:0.09010099999999997,Tip2:0.015264200000000006)1:0.10734890000000002)1:0.09298299999999998);
EOF
${GOTREE} compute consensus -i ${TESTDATA}/bootstap_test.nw.gz -f 0.7 | ${GOTREE} compare trees -i expected_tree -c - > result
diff -q -b expected_comp result
rm -f expected_comp expected_tree result
echo "->gotree compute classical bootstrap"
cat > expected <<EOF
(Tip0,(Tip4,(Tip7,Tip2)1)1,((Tip9,(Tip8,Tip3)0.87)1,(Tip1,(Tip6,Tip5)0.65)0.97)0.67);
EOF
${GOTREE} compute support fbp -i ${TESTDATA}/bootstap_inferred_test.nw.gz -b ${TESTDATA}/bootstap_test.nw.gz 2>/dev/null | ${GOTREE} brlen clear > result
diff -q -b expected result
${GOTREE} compute support classical -i ${TESTDATA}/bootstap_inferred_test.nw.gz -b ${TESTDATA}/bootstap_test.nw.gz 2>/dev/null | ${GOTREE} brlen clear > result
diff -q -b expected result
rm -f expected result
echo "->gotree compute booster supports"
cat > expected <<EOF
(Tip0,(Tip4,(Tip7,Tip2)1)1,((Tip9,(Tip8,Tip3)0.87)1,(Tip1,(Tip6,Tip5)0.65)0.985)0.89);
EOF
${GOTREE} compute support booster -i ${TESTDATA}/bootstap_inferred_test.nw.gz -b ${TESTDATA}/bootstap_test.nw.gz --silent -l /dev/null | ${GOTREE} brlen clear > result
diff -q -b expected result
${GOTREE} compute support tbe -i ${TESTDATA}/bootstap_inferred_test.nw.gz -b ${TESTDATA}/bootstap_test.nw.gz --silent -l /dev/null | ${GOTREE} brlen clear > result
diff -q -b expected result
rm -f expected result
echo "->gotree compute edgetrees"
cat > expected <<EOF
((Tip4:1,Tip7:1,Tip2:1):1,Tip0:1,Tip8:1,Tip9:1,Tip3:1,Tip6:1,Tip5:1,Tip1:1);
((Tip7:1,Tip2:1):1,Tip4:1,Tip0:1,Tip8:1,Tip9:1,Tip3:1,Tip6:1,Tip5:1,Tip1:1);
((Tip8:1,Tip9:1,Tip3:1,Tip6:1,Tip5:1,Tip1:1):1,Tip4:1,Tip7:1,Tip2:1,Tip0:1);
((Tip8:1,Tip9:1,Tip3:1):1,Tip4:1,Tip7:1,Tip2:1,Tip0:1,Tip6:1,Tip5:1,Tip1:1);
((Tip9:1,Tip3:1):1,Tip4:1,Tip7:1,Tip2:1,Tip0:1,Tip8:1,Tip6:1,Tip5:1,Tip1:1);
((Tip6:1,Tip5:1,Tip1:1):1,Tip4:1,Tip7:1,Tip2:1,Tip0:1,Tip8:1,Tip9:1,Tip3:1);
((Tip6:1,Tip5:1):1,Tip4:1,Tip7:1,Tip2:1,Tip0:1,Tip8:1,Tip9:1,Tip3:1,Tip1:1);
EOF
${GOTREE} generate yuletree --seed 10 | ${GOTREE} compute edgetrees > result
diff -q -b expected result
rm -f expected result
echo "->gotree compute edgetrees"
cat > expected <<EOF
((Tip4:1,Tip7:1,Tip2:1):1,Tip0:1,Tip8:1,Tip9:1,Tip3:1,Tip6:1,Tip5:1,Tip1:1);
((Tip7:1,Tip2:1):1,Tip4:1,Tip0:1,Tip8:1,Tip9:1,Tip3:1,Tip6:1,Tip5:1,Tip1:1);
((Tip8:1,Tip9:1,Tip3:1,Tip6:1,Tip5:1,Tip1:1):1,Tip4:1,Tip7:1,Tip2:1,Tip0:1);
((Tip8:1,Tip9:1,Tip3:1):1,Tip4:1,Tip7:1,Tip2:1,Tip0:1,Tip6:1,Tip5:1,Tip1:1);
((Tip9:1,Tip3:1):1,Tip4:1,Tip7:1,Tip2:1,Tip0:1,Tip8:1,Tip6:1,Tip5:1,Tip1:1);
((Tip6:1,Tip5:1,Tip1:1):1,Tip4:1,Tip7:1,Tip2:1,Tip0:1,Tip8:1,Tip9:1,Tip3:1);
((Tip6:1,Tip5:1):1,Tip4:1,Tip7:1,Tip2:1,Tip0:1,Tip8:1,Tip9:1,Tip3:1,Tip1:1);
EOF
${GOTREE} generate yuletree --seed 10 | ${GOTREE} compute edgetrees > result
diff -q -b expected result
rm -f expected result
echo "->gotree compute mutations --eems"
cat > input_align <<EOF
>A
A
>B
A
>AB
A
>C
A
>D
C
>CD
C
>ABCD
C
>E
T
>F
T
>EF
T
>G
T
>H
G
>GH
G
>EFGH
G
>ABCDEFGH
G
EOF
cat > input_tree <<EOF
(((A,B)AB,(C,D)CD)ABCD,((E,F)EF,(G,H)GH)EFGH)ABCDEFGH;
EOF
cat > expected <<EOF
Tree ID Site Parent Character Child Character Nb EEMs
0 0 G T 2
0 0 C A 2
0 0 G C 1
EOF
${GOTREE} compute mutations -a input_align -i input_tree --eems >results
diff -q -b <(sort expected) <(sort results)
rm -f expected input_tree input_align results
echo "->gotree divide"
cat > expected1 <<EOF
((Tip4,(Tip7,Tip2)),Tip0,((Tip8,(Tip9,Tip3)),((Tip6,Tip5),Tip1)));
EOF
cat > expected2 <<EOF
(Tip5,Tip0,((Tip6,(Tip7,Tip4)),(Tip2,((Tip8,(Tip9,Tip3)),Tip1))));
EOF
${GOTREE} generate yuletree --seed 10 -n 2 | ${GOTREE} brlen clear | ${GOTREE} divide -o div
diff -q -b expected1 div_000.nw
diff -q -b expected2 div_001.nw
rm -f expected1 expected2 div_000.nw div_001.nw
echo "->gotree generate yuletree"
cat > expected <<EOF
((Tip4:0.020616211789029896,(Tip7:0.09740195047110385,Tip2:0.015450672710905129):0.25879284932877245):0.1824683850061218,Tip0:0.25919865790518115,((Tip8:0.027845992087631298,(Tip9:0.13492605122032592,Tip3:0.10309294031874587):0.01026581233891113):0.1920960924280275,((Tip6:0.3779897840448691,Tip5:0.1120177846434196):0.05817538156872999,Tip1:0.239082088939295):0.30150414585026103):0.04593880904706901);
EOF
${GOTREE} generate yuletree --seed 10 -n 1 > result
diff -q -b expected result
rm -f expected result
echo "->gotree generate balancedtree"
cat > expected <<EOF
(((Tip0:0.04593880904706901,Tip1:0.13604994737755394):0.06718605070537677,(Tip2:0.19852695409349608,Tip3:0.002749016032849596):0.2485396648662035):0.25919865790518115,((Tip4:0.12467449897149811,Tip5:0.10033210749794116):0.1824683850061218,(Tip6:0.30150414585026103,Tip7:0.08184535681853511):0.020616211789029896):0.054743875470795914,(((Tip8:0.1120177846434196,Tip9:0.18347097513974125):0.05817538156872999,(Tip10:0.25879284932877245,Tip11:0.09740195047110385):0.3779897840448691):0.239082088939295,((Tip12:0.1920960924280275,Tip13:0.027845992087631298):0.015450672710905129,(Tip14:0.0440885662122905,Tip15:0.14809735366802398):0.17182241382980687):0.03199874235185574):0.13756099791982077);
EOF
${GOTREE} generate balancedtree --seed 10 -d 4 > result
diff -q -b expected result
rm -f expected result
echo "->gotree generate caterpillartree"
cat > expected <<EOF
((((((((Tip9:0.09740195047110385,Tip8:0.015450672710905129):0.25879284932877245,Tip7:0.18347097513974125):0.3779897840448691,Tip6:0.05817538156872999):0.239082088939295,Tip5:0.08184535681853511):0.10033210749794116,Tip4:0.12467449897149811):0.1824683850061218,Tip3:0.002749016032849596):0.13604994737755394,Tip2:0.04593880904706901):0.06718605070537677,Tip0:0.0540687078328298,Tip1:0.054743875470795914);
EOF
${GOTREE} generate caterpillartree --seed 10 > result
diff -q -b expected result
rm -f expected result
echo "->gotree generate uniformtree"
cat > expected <<EOF
(Tip5:0.08184535681853511,Tip0:0.30150414585026103,((Tip9:0.13492605122032592,Tip6:0.10309294031874587):0.01026581233891113,((Tip7:0.09740195047110385,(Tip8:0.027845992087631298,((Tip4:0.020616211789029896,Tip3:0.12467449897149811):0.1824683850061218,Tip2:0.19852695409349608):0.0440885662122905):0.1920960924280275):0.25879284932877245,Tip1:0.06718605070537677):0.1120177846434196):0.05817538156872999);
EOF
${GOTREE} generate uniformtree --seed 10 > result
diff -q -b expected result
rm -f expected result
echo "->gotree matrix"
cat > expected.brlen <<EOF
5
Tip0 0.000000000000 0.503664421046 0.566341541883 0.441187414330 0.462283254700
Tip1 0.503664421046 0.000000000000 0.551608647118 0.334576901471 0.447550359936
Tip2 0.566341541883 0.551608647118 0.000000000000 0.489131640402 0.145290710761
Tip3 0.441187414330 0.334576901471 0.489131640402 0.000000000000 0.385073353220
Tip4 0.462283254700 0.447550359936 0.145290710761 0.385073353220 0.000000000000
EOF
cat > expected.boot <<EOF
5
Tip0 0.000000000000 2.800000000000 2.800000000000 2.800000000000 2.800000000000
Tip1 2.800000000000 0.000000000000 3.600000000000 2.000000000000 3.600000000000
Tip2 2.800000000000 3.600000000000 0.000000000000 3.600000000000 2.000000000000
Tip3 2.800000000000 2.000000000000 3.600000000000 0.000000000000 3.600000000000
Tip4 2.800000000000 3.600000000000 2.000000000000 3.600000000000 0.000000000000
EOF
cat > expected.none <<EOF
5
Tip0 0.000000000000 3.000000000000 3.000000000000 3.000000000000 3.000000000000
Tip1 3.000000000000 0.000000000000 4.000000000000 2.000000000000 4.000000000000
Tip2 3.000000000000 4.000000000000 0.000000000000 4.000000000000 2.000000000000
Tip3 3.000000000000 2.000000000000 4.000000000000 0.000000000000 4.000000000000
Tip4 3.000000000000 4.000000000000 2.000000000000 4.000000000000 0.000000000000
EOF
echo "((Tip4:0.020616211789029896,Tip2:0.12467449897149811)0.8:0.1824683850061218,Tip0:0.25919865790518115,(Tip3:0.13604994737755394,Tip1:0.19852695409349608)0.8:0.04593880904706901);" > intree
${GOTREE} matrix -i intree > result
diff -q -b expected.brlen result
${GOTREE} matrix -i intree --metric boot > result
diff -q -b expected.boot result
${GOTREE} matrix -i intree --metric none > result
diff -q -b expected.none result
rm -f expected.brlen expected.boot expected.none result intree
echo "->gotree matrix --avg"
cat > intree <<EOF
(1:1,2:0,(3:1,4:1):0);
(1:1,2:2,(3:2,4:2):1);
(1:3,2:2,(3:3,4:2):1);
(1:2,2:2,(3:0,4:1):1);
EOF
cat > expected <<EOF
4
1 0.000000000000 3.250000000000 4.000000000000 4.000000000000
2 3.250000000000 0.000000000000 3.750000000000 3.750000000000
3 4.000000000000 3.750000000000 0.000000000000 3.000000000000
4 4.000000000000 3.750000000000 3.000000000000 0.000000000000
EOF
${GOTREE} matrix -i intree --avg > result
diff -q -b expected result
rm -f expected intree result
echo "->gotree brlen setmin 1"
cat > expected <<EOF
((Tip4:1,(Tip7:1,Tip2:1):1):1,Tip0:1,((Tip8:1,(Tip9:1,Tip3:1):1):1,((Tip6:1,Tip5:1):1,Tip1:1):1):1);
EOF
${GOTREE} generate yuletree --seed 10 -l 10 | ${GOTREE} brlen setmin -l 1 > result
diff -q -b expected result
rm -f expected result
echo "->gotree brlen setmin 10"
cat > expected <<EOF
((Tip4:10,(Tip7:10,Tip2:10):10):10,Tip0:10,((Tip8:10,(Tip9:10,Tip3:10):10):10,((Tip6:10,Tip5:10):10,Tip1:10):10):10);
EOF
${GOTREE} generate yuletree --seed 10 -l 10 | ${GOTREE} brlen clear | ${GOTREE} brlen setmin -l 10 > result
diff -q -b expected result
rm -f expected result
echo "->gotree brlen add"
cat > expected1 <<EOF
(A:11,(B:1,C:1):11);
EOF
cat > expected2 <<EOF
(A:10,(B,C):11);
EOF
cat > expected3 <<EOF
(A:11,(B:1,C:1):10);
EOF
echo "(A:10.0,(B,C):10);" | $GOTREE brlen add -l 1.0 > result
diff -q -b expected1 result
rm -f expected result
echo "(A:10.0,(B,C):10);" | $GOTREE brlen add -l 1.0 --external=false > result
diff -q -b expected2 result
rm -f expected result
echo "(A:10.0,(B,C):10);" | $GOTREE brlen add -l 1.0 --internal=false > result
diff -q -b expected3 result
rm -f expected result
echo "->gotree prune"
cat > expected <<EOF
((Tip4,(Tip7,Tip2)),((Tip8,(Tip9,Tip3)),((Tip6,Tip5),Tip1)),Tip0);
EOF
${GOTREE} generate yuletree --seed 10 -l 20 | ${GOTREE} prune -i - -c <(${GOTREE} generate yuletree --seed 12 -l 10) | ${GOTREE} brlen clear > result
diff -q -b expected result
rm -f expected result
echo "->gotree prune tipfile"
cat > expected <<EOF
((Tip4,(Tip7,Tip2)),((Tip8,(Tip9,Tip3)),((Tip6,Tip5),Tip1)),Tip0);
EOF
cat > tipfile <<EOF
Tip6
Tip4
Tip0
Tip3
Tip9
Tip8
Tip2
Tip7
Tip5
Tip1
EOF
${GOTREE} generate yuletree --seed 10 -l 20 | ${GOTREE} prune -i - -f tipfile -r | ${GOTREE} brlen clear > result
diff -q -b expected result
rm -f expected result tipfile
# echo "->gotree brlen setrand"
# cat > expected <<EOF
# ((Tip4:0.11181011331618643,(Tip7:0.21688356961855743,Tip2:0.21695890315161873):0.007486847792469759):0.02262551762264341,Tip0:0.07447903650558614,((Tip8:0.05414175839023796,(Tip9:0.34924246250387486,Tip3:0.023925115233614132):0.1890483249199916):0.03146499978313507,((Tip6:0.31897358778004786,Tip5:0.29071259678750266):0.04826059603128351,Tip1:0.02031669307269784):0.052025373286913534):0.011401847253594477);
# EOF
# ${GOTREE} generate yuletree --seed 10 | ${GOTREE} brlen setrand --seed 13 > result
# diff -q -b expected result
# rm -f expected result
echo "->gotree support setrand"
cat > expected <<EOF
((Tip4,(Tip7,Tip2)0.2550878763278657)0.6418716208549535,Tip0,((Tip8,(Tip9,Tip3)0.9581212767194948)0.24992593115716047,((Tip6,Tip5)0.2962112349523319,Tip1)0.2923644736644398)0.20284376043157062);
EOF
${GOTREE} generate yuletree --seed 10 | ${GOTREE} support setrand --seed 12 | ${GOTREE} brlen clear > result
diff -q -b expected result
rm -f expected result
echo "->gotree rename"
cat > mapfile <<EOF
Tip0 Tax0
Tip1 Tax1
Tip2 Tax2
Tip3 Tax3
Tip4 Tax4
Tip5 Tax5
Tip6 Tax6
Tip7 Tax7
Tip8 Tax8
Tip9 Tax9
EOF
cat > expected <<EOF
((Tax4,(Tax7,Tax2)),Tax0,((Tax8,(Tax9,Tax3)),((Tax6,Tax5),Tax1)));
EOF
${GOTREE} generate yuletree --seed 10 | ${GOTREE} rename -m mapfile | ${GOTREE} brlen clear > result
diff -q -b expected result
rm -f expected result mapfile
echo "->gotree rename auto"
cat > mapfile <<EOF
Tip4 T0001
Tip7 T0002
Tip0 T0004
Tip9 T0006
Tip3 T0007
Tip1 T0010
Tip2 T0003
Tip8 T0005
Tip6 T0008
Tip5 T0009
EOF
cat > expected <<EOF
((T0001,(T0002,T0003)),T0004,((T0005,(T0006,T0007)),((T0008,T0009),T0010)));
EOF
${GOTREE} generate yuletree --seed 10 | ${GOTREE} rename -a -m mapfile2 -l 5 | ${GOTREE} brlen clear > result
diff -q -b expected result
diff -q -b <(sort mapfile) <(sort mapfile2)
rm -f expected result mapfile mapfile2
echo "->gotree rename auto several trees"
cat > mapfile <<EOF
Tip4 T0001
Tip2 T0003
Tip8 T0005
Tip9 T0006
Tip1 T0010
Tip11 T0012
Tip14 T0014
Tip0 T0004
Tip3 T0007
Tip5 T0009
Tip12 T0011
Tip10 T0013
Tip13 T0015
Tip15 T0016
Tip7 T0002
Tip6 T0008
EOF
cat > input <<EOF
((Tip4,(Tip7,Tip2)),Tip0,((Tip8,(Tip9,Tip3)),((Tip6,Tip5),Tip1)));
((Tip12,Tip11),Tip0,((Tip4,(Tip7,Tip2)),((Tip8,(Tip9,Tip3)),(((Tip10,Tip6),(Tip14,Tip5)),(Tip13,Tip1)))));
((Tip12,Tip11),Tip0,((Tip4,(Tip7,(Tip15,Tip2))),((Tip8,(Tip9,Tip3)),(((Tip10,Tip6),(Tip14,Tip5)),(Tip13,Tip1)))));
EOF
cat > expected <<EOF
((T0001,(T0002,T0003)),T0004,((T0005,(T0006,T0007)),((T0008,T0009),T0010)));
((T0011,T0012),T0004,((T0001,(T0002,T0003)),((T0005,(T0006,T0007)),(((T0013,T0008),(T0014,T0009)),(T0015,T0010)))));
((T0011,T0012),T0004,((T0001,(T0002,(T0016,T0003))),((T0005,(T0006,T0007)),(((T0013,T0008),(T0014,T0009)),(T0015,T0010)))));
EOF
${GOTREE} rename -i input -a -m mapfile2 -l 5 | ${GOTREE} brlen clear > result
diff -q -b expected result
diff -q -b <(sort mapfile) <(sort mapfile2)
rm -f expected result mapfile mapfile2 input
echo "->gotree rename regexp"
cat > mapfile <<EOF
Tip4 Leaf4
Tip7 Leaf7
Tip0 Leaf0
Tip9 Leaf9
Tip3 Leaf3
Tip1 Leaf1
Tip2 Leaf2
Tip8 Leaf8
Tip6 Leaf6
Tip5 Leaf5
EOF
cat > expected <<EOF
((Leaf4,(Leaf7,Leaf2)),Leaf0,((Leaf8,(Leaf9,Leaf3)),((Leaf6,Leaf5),Leaf1)));
EOF
${GOTREE} generate yuletree --seed 10 | ${GOTREE} rename --regexp 'Tip(\d+)' --replace 'Leaf$1' -m mapfile2 | ${GOTREE} brlen clear > result
diff -q -b expected result
diff -q -b <(sort mapfile) <(sort mapfile2)
rm -f expected result mapfile mapfile2
echo "->gotree reroot outgroup"
cat > expected <<EOF
((((Tip4,(Tip7,Tip2)),Tip0),((Tip6,Tip5),Tip1)),(Tip8,(Tip9,Tip3)));
EOF
${GOTREE} generate yuletree --seed 10 | ${GOTREE} reroot outgroup Tip3 Tip8 Tip9 | ${GOTREE} brlen clear > result
diff -q -b expected result
rm -f expected result
echo "->gotree reroot midpoint"
cat > expected <<EOF
(((Tip6,Tip5),Tip1),(((Tip4,(Tip7,Tip2)),Tip0),(Tip8,(Tip9,Tip3))));
EOF
${GOTREE} generate yuletree --seed 10 | ${GOTREE} reroot midpoint | ${GOTREE} brlen clear> result
diff -q -b expected result
rm -f expected result