-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathguoyi.run
629 lines (567 loc) · 13.4 KB
/
guoyi.run
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
macro=;
log %7.tnt.log;
/*primary notification*/
if ( (argnumber == 0) || (argnumber >7) )
silent -console;
quote
/----------------------------------------------------\
| GUOYI TNT SCRIPT 2022-2023 MIT |
| You need to give your filename |
| shell> tnt run guoyi.tnt filename, (Linux & Mac) |
| shell> tnt run guoyi.run filename(semicolon) (Win) |
| ============================== |
| === Parameters Details === |
| ============================== |
| filename type weight K cons resamp prefix |
| - filename extension must be lower case |
| fasta (fas/fasta), tnt (tnt/ss), nexus |
| (nex/nexus) format are allowed |
| - type should be 32, dna, prot, num |
| num=number, dna=DNA, prot=protein |
| 32=max number allowed (default) |
| - weight should be iw, ew, eiw |
| iw=implied weight, ew=equal weight |
| eiw=extended implied weight (default) |
| N.B. K of ew must followed 0 (=NA) |
| - K is 12 (default) following Goloboff |
| et al. 2017 (Cladistics 34: 407–437) |
| it must more than 0 |
| - cons should be str, mjr, hlf |
| mjr=majority rule, hlf=half |
| str=strict (default) |
| - resamp should be sum of what you want |
| jak=1, boot=2, sym=4 relative-bremer |
| (rbr)=0.1, bremer(br)=0.2 |
| i.e rbr+jak+boot+sym=7.1 (default) |
| - prefix can be empty, or a string |
| default is empty |
\----------------------------------------------------/;
proc/;
end
/*Var for handling args*/
var:
dojak doboot dosym dobrs dorbrs rsmp dobremer
dostr domjr dohlf contype
doew doiw doeiw dowt wtstring wttype
kvalue
search
isfas istnt isnex input;
set dojak 0; set doboot 0; set dosym 0; set dobrs 0; set dorbrs 0; set rsmp 0; set dobremer 0;
set dostr 0; set domjr 0; set dohlf 0;
set doew 0; set doiw 0; set doeiw 0; set dowt 0; set wttype 0;
set kvalue 12;
set search 0;
set isfas 0; set istnt 0; set isnex 0;
goto=%0;
/*Get prefix and extension of input*/
set input $%1;
/*confirm input format*/
if ((eqstring [ $input>. fas ]) || (eqstring [ $input>. fasta ]))
set isfas 1;
else
if ((eqstring [ $input>. tnt ]) || (eqstring [ $input>. ss ]))
set istnt 1;
else
if ((eqstring [ $input>. nex ]) || (eqstring [ $input>. nexus ]))
set isnex 1;
else
errmsg extension name of input file must be fas/fasta (for fas format), tnt/ss (for Hennig86/NONA/TNT format), nex/nexus (for nex format);
end end end
/*handle weighting type*/
if (argnumber>=3)
set wtstring $%3;
if (eqstring [ $wtstring ew ])
set doew 1;
set wttype 1;
else
if (eqstring [ $wtstring iw ])
set doiw 1;
set wttype 2;
else
if (eqstring [ $wtstring eiw ])
set doeiw 1;
set wttype 3;
else
goto wttypeerr;
end end end
else
set doeiw 1;
set wttype 3;
end
if ('doiw' || 'doeiw')
set dowt 1;
end
/*handle k value*/
if (argnumber>=4)
set kvalue %4;
if ( 'doew' && ('kvalue' != 0))
goto kvalueerr;
end
end
/*handle resmaple type*/
if (argnumber<6)
set dojak 1; set doboot 1; set dosym 1; set dorbrs 1;
else
set rsmp %6;
loop 1 5
if ('rsmp' >= 4)
set dosym 1;
set rsmp 'rsmp'-4;
else
if ('rsmp' >= 2)
set doboot 1;
set rsmp 'rsmp'-2;
else
if ('rsmp' >= 1)
set dojak 1;
set rsmp 'rsmp'-1;
else
if ('rsmp' >= 0.2)
set dobrs 1;
set rsmp 'rsmp'-0.2;
else
if ('rsmp' >= 0.1)
set dorbrs 1;
set rsmp 'rsmp'-0.1;
end end end end end
stop
end
if ('rsmp' != 0)
errmsg Input 'rsmp' is illegal;
end
if ('dobrs' || 'dorbrs')
set dobremer 1;
end
/*handle consensus type*/
if (argnumber>=6)
set contype $%5;
if ('dobremer')
set dostr 1;
if (eqstring [ $contype str ])
else
if (eqstring [ $contype mjr ])
goto bremererr;
else
if (eqstring [ $contype hlf ])
goto bremererr;
else
goto contypeerr;
end end end
else
if (eqstring [ $contype str ])
set dostr 1;
else
if (eqstring [ $contype mjr ])
set domjr 1;
else
if (eqstring [ $contype hlf ])
set dohlf 1;
else
goto contypeerr;
end end end
end
else
if (argnumber==5)
set contype $%5;
if ((eqstring [ $contype mjr ]) || (eqstring [ $contype hlf ]))
goto bremererr;
else
if (eqstring [ $contype str ])
set dostr 1;
else
goto contypeerr;
end end
else
set dostr 1;
end end
/*Basic settings*/
taxname+1000;
taxname=;
mxram 10240;
if(argnumber>=2)
nstates %2;
else
nstates 32;
end
nstates NOGAPS;
/*Set K*/
if ('dowt')
piwe='kvalue';
end
/*Reopen tnt*/
if ('istnt' || 'isnex')
procedure $input;
else
if ('isfas')
procedure & $input;
end end
hold 10000;
/*handle search*/
if (ntax<=24) /*taxa lower than 25 (including 25)*/
if ('doeiw')
set search 2;
else
set search 1;
end
else
if (ntax<74) /*taxa lower than 75 do mult*/
set search 2;
else
set search 3;
end
end
/*Report what will be done*/
quote
/-----------------------------------------------\;
if ('wttype'==1)
quote
| Equal weighting will be used. |;
else
if ('wttype'==2)
quote
| Implied weighting will be used, K is 'kvalue'. |;
else
if ('wttype'==3)
quote
| Ex-implied weighting will be used, K is 'kvalue'. |;
end end end
if ('search'==1)
quote
| Implicit enumeration will be performed. |;
else
if ('search'==2)
quote
| TBR Mult will be performed. |;
else
if ('search'==3)
quote
| Xmult will be performed. |;
end end end
if ('dostr')
quote
| Strict consensus will be used. |;
else
if ('domjr')
quote
| Majority-rule consensus will be used. |;
else
if ('dohlf')
quote
| Half strict consensus will be used. |;
end end end
quote
| resample.svg will contain a tree with |;
if ('dorbrs')
quote
| relative bremer support |;
end
if ('dobrs')
quote
| bremer support |;
end
if ('dojak')
quote
| jackknifing |;
end
if ('doboot')
quote
| bootstrap |;
end
if ('dosym')
quote
| symmetric resampling |;
end
quote
| Apomorphic characters mapping will be shown |
| on the apo.svg and saved to apo*.tre. |
| TL, CI and RI will be calculated finally. |
\------------------------------------------------/;
/*Implied weighting settings*/
if ('doiw')
piwe&;
else
if ('doeiw')
xpiwe(*;
log %7.eiw.log;
piwe&;
log/;
log + %7.tnt.log;
end end
/*Search trees*/
if ('search'==1)
ienum;
else
if ('search'==2)
mult=replic 1000 tbr hold 10;
bbreak=tbr fill;
else
if ('search'==3)
sect: slack 40;
xmult=hit 50 replications 20 drift 10 ratchet 10 fuse 10 hold 1 keepall;
bbreak=tbr fill;
end end end
/*Export trees*/
export= %7.trees.tre;
taxname-;
export= %7.trees_no.tre;
tsave *= %7.trees.tnt.tre;
taxname=;
tsave = %7.trees.ctf;
/*Get npars number*/
var: npars;
set npars ntrees;
/*Get consensus tree*/
if ('dostr')
nelsen * 0.'npars';
else
if ('domjr')
majority * 0.'npars';
else
if ('dohlf')
comcomp * 0.'npars';
end end end
/*Get the consensus tree number*/
var: contree;
set contree ntrees;
/*Store consensus tree to tree vault*/
hold /+0;
tv>/;
tchoose 0.'npars';
/*Get rbr/br/jak/boot/sym support and get consensus tree*/
ttags=;
ttags]; /*in one line*/
/* jak=1, boot=2, sym=4, */
/* jak+boot=3, */
/* jak+sym=5, boot+sym=6, */
/* jak+boot+sym=7, */
/* relative-bremer=0.1, bremer=0.2 */
/* bremer+relative-bremer=0.3 */
if ('dobremer')
/*set value of suboptimal from most parsimony tree */
sub: 0;
/*calculate relative bremer support*/
if ('dorbrs')
bs ]!! 0;
end
/*calculate bremer support*/
if ('dobrs')
macfloat 1; /*set the br value float*/
bsupport !! 0;
end
end
/*Choose final tree*/
tv<;
tchoose/;
/*adjust to zero following Pablo Goloboff*/
sub 0;
/*jakknifing*/
if ('dojak')
resample jak replications 1000 from 0; /*from 0 will orphan other trees*/
end
/*bootstrap*/
if ('doboot')
resample boot replications 1000 from 0;
end
/*symmetric resampling*/
if ('dosym')
resample sym replications 1000 from 0;
end
/*Export consensus tree with supports*/
ttags & %7.resample.svg thickness 7 italics fontsize 15;
log %7.resample.log;
quote /-------------resample tags start---------------\;
ttags/;
quote \-------------resample tags stop----------------/;
log/;
log + %7.tnt.log;
export < %7.resample.tre;
taxname-;
export - %7.resample_no.tre;
ttags-;
taxname=;
/*Export consensus tree*/
tchoose /;
export - %7.original.tre;
taxname-;
export - %7.original_no.tre;
tsave = %7.original.ctf;
tsave *= %7.original.tnt.tre;
/*Apomorphic characters*/
export = %7.winclada.tre;
taxname =;
ttags=;
apo >0;
log %7.apo.log;
quote /-----------apomorphy tags start --------------\;
ttags/;
quote \-----------apomorphy tags stop ---------------/;
log/;
log + %7.tnt.log;
ttags & %7.apo.svg thickness 7 italics fontsize 15;
export < %7.apo.tre;
taxname-;
export - %7.apo_no.tre;
ttags-;
/*Character Analysis*/
log %7.homo.log;
chomo;
cscores;
log/;
log + %7.tnt.log;
/*Caulculate TL/CI/RI score*/
report-;
var: themin themax CI RI TL ;
set themin minsteps;
set themax maxsteps;
set TL length[0];
set CI 'themin'/'TL'; /*CI=1 means no homoplasy*/
if ('themax' != 'themin')
set RI ('themax'-'TL')/('themax'-'themin'); /*RI=1 character fits perfetcly*/
else
set RI 999;
end
/*Report CI/RI/TL */
log %7.report.log;
macfloat 3;
quote Consistency Index (CI) is 'CI';
if ('RI' == 999)
quote Retention Index (RI) is NA;
else
quote Retention Index (RI) is 'RI';
end
quote Tree Length (TL) is 'TL';
log/;
watch-;
/*Generate ss file for winclada*/
log %7.winclada.ss;
/*get basic info*/
var: taxnum chanum;
set taxnum ntax+1;
set chanum nchar+1;
/*output head*/
quote
xread
'
Data saved from TNT
'
'chanum' 'taxnum';
/*outhead body*/
xread!;
/*output split symnol*/
runc!
tntprintf(";\n\n");
!
/*output the tread*/
taxname-;
tp*;
/*output the end*/
runc!
tntprintf("proc/;\n");
!
log/;
log + %7.tnt.log;
/*Report*/
quote
/----------------------------------------------\
| The analysis has been finished. |
| The file `tnt.log` contains |
| the performing details |
| The file `trees*.tre` contain |
| trees found by mult and xmult |
| The file `original*.tre` contain |
| consensus tree without label |
| The file `resample*.tre` contain |
| consensus tree with support |
| The file `apo*.tre` contain |
| tree with apomorphic character |
| The file `*_no.tre` contain |
| tree with `taxname-` |
| The file `*.ctf` tree file is |
| only readable for TNT |
| The file `*.tnt.tre` contain |
| is the tre file without taxname |
| The file `resample.svg` contain |;
if ('dostr')
quote
| strict consensus tree with |;
else
if ('domjr')
quote
| majority-rule consensus tree with |;
else
if ('dohlf')
quote
| half strict consensus tree with |;
end end end
if ('dorbrs')
quote
| relative bremer support |;
end
if ('dobrs')
quote
| bremer support |;
end
if ('dojak')
quote
| jackknifing |;
end
if ('doboot')
quote
| bootstrap |;
end
if ('dosym')
quote
| symmetric resampling |;
end
if ('doew')
quote
| under equal weighting |;
else
if ('doiw')
quote
| under implied weighting, |
| K value is 'kvalue' |;
else
if ('doeiw')
quote
| under extended implied weighting, |
| K value is 'kvalue' |;
end end end
quote
| The file `apo.svg` contains the |
| tree with apomorphy mapping |
| The file `report.log` contains the |
| CI RI TL publish-needed info |
| The file `resample/apo.log` contains |
| the tree tags text |
| The file `homo.log` contains the report |
| of character homoplasy |;
if ('doeiw')
quote
| The file `eiw.log` contains the report |
| of character concavities |;
end
quote
| The file `winclada.tre` can be |
| converted by tnt2winclada |
| The file `winclada.ss` can be read by |
| winclada directly |
\----------------------------------------------/;
/*Quit*/
zzz;
/*consensus type error*/
label contypeerr
errmsg Consensus type must be str mjr or hlf;
proc/;
/*weighting type error*/
label wttypeerr
errmsg Weighting type must be ew, iw or eiw;
proc/;
/*equal weighting k value error*/
label kvalueerr
errmsg Equal weighting (ew) must be followed with 0 instead of 'kvalue';
proc/;
/*bremer support not strict consensus error*/
label bremererr
errmsg Bremer support or any bremer support variations must use strict consensus;
proc/;