TNT_Script/guoyi.run

538 lines
12 KiB
Text
Raw Normal View History

2023-09-13 20:57:13 +08:00
macro=;
2023-02-26 03:32:18 +08:00
2023-09-14 00:08:43 +08:00
log %7.tnt.log;
2023-10-10 00:25:05 +08:00
/*primary notification*/
2023-09-20 23:48:36 +08:00
if ( (argnumber == 0) || (argnumber >7) )
2023-02-27 01:24:22 +08:00
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 |
| - 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: 407437) |
| 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+br+jak+boot+sym=7.3 (default) |
| - prefix can be empty, or a string |
| default is empty |
\----------------------------------------------------/;
2023-02-27 01:24:22 +08:00
proc/;
end
2023-10-10 00:25:05 +08:00
/*Var for handling args*/
var:
dojak doboot dosym dobrs dorbrs rsmp dobremer
dostr domjr dohlf
doew doiw doeiw dowt wttype
kvalue
search;
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;
/*handle weighting type*/
if (argnumber>=3)
if (eqstring [ %3 ew ])
set doew 1;
set wttype 1;
else
if (eqstring [ %3 iw ])
set doiw 1;
set wttype 2;
else
if (eqstring [ %3 eiw ])
set doeiw 1;
set wttype 3;
else
errmsg Weighting type must be ew, iw or eiw;
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))
errmsg Equal weighting (ew) must be followed with 0 instead of 'kvalue';
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
2023-10-10 00:35:15 +08:00
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
2023-10-10 00:25:05 +08:00
stop
end
if ('rsmp' != 0)
errmsg Input %6 is illegal;
end
if ('dobrs' || 'dorbrs')
set dobremer 1;
end
/*handle consensus type*/
if (argnumber>=6)
if ('dobremer')
set dostr 1;
if (eqstring [ %5 str ])
else
if (eqstring [ %5 mjr ])
errmsg Bremer support or any bremer support variations must use strict consensus;
else
if (eqstring [ %5 hlf ])
errmsg Bremer support or any bremer support variations must use strict consensus;
else
errmsg Consensus type must be str mjr or hlf;
end end end
else
if (eqstring [ %5 str ])
set dostr 1;
else
if (eqstring [ %5 mjr ])
set domjr 1;
else
if (eqstring [ %5 hlf ])
set dohlf 1;
else
errmsg Consensus type must be str mjr or hlf;
end end end
end
else
if (argnumber==5)
if ((eqstring [ %5 mjr ]) || (eqstring [ %5 hlf ]))
errmsg Bremer support or any bremer support variations must use strict consensus;
else
if (eqstring [ %5 str ])
set dostr 1;
else
errmsg Consensus type must be str mjr or hlf;
end end
else
set dostr 1;
end end
/*handle search*/
if (ntax<=25)
if ('doeiw')
2023-10-10 00:35:15 +08:00
set search 2;
2023-10-10 00:25:05 +08:00
else
2023-10-10 00:35:15 +08:00
set search 1;
2023-10-10 00:25:05 +08:00
end
else
if (ntax<75)
2023-10-10 00:35:15 +08:00
set search 2;
2023-10-10 00:25:05 +08:00
else
2023-10-10 00:35:15 +08:00
set search 3;
2023-10-10 00:25:05 +08:00
end
end
2023-09-13 20:57:13 +08:00
/*Basic settings*/
2023-09-20 21:29:12 +08:00
taxname+1000;
2023-09-13 20:57:13 +08:00
taxname=;
mxram 10240;
2023-09-13 20:57:13 +08:00
if(argnumber>=2)
nstates %2;
else
nstates 32;
end
nstates NOGAPS;
2023-10-10 00:25:05 +08:00
/*Set K*/
if ('dowt')
piwe='kvalue';
2023-09-13 20:57:13 +08:00
end
/*Reopen tnt*/
procedure %1;
hold 10000;
2023-02-27 01:24:22 +08:00
/*Report what will be done*/
quote
/-----------------------------------------------\;
2023-10-10 00:25:05 +08:00
if ('wttype'==1)
quote
| Equal weighting will be used. |;
2023-09-13 20:57:13 +08:00
else
2023-10-10 00:25:05 +08:00
if ('wttype'==2)
quote
2023-10-10 00:25:05 +08:00
| 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
2023-10-10 00:25:05 +08:00
if ('search'==2)
quote
| TBR Mult will be performed. |;
else
2023-10-10 00:25:05 +08:00
if ('search'==3)
quote
| Xmult will be performed. |;
end end end
2023-10-10 00:25:05 +08:00
if ('dostr')
quote
| Strict consensus will be used. |;
else
2023-10-10 00:25:05 +08:00
if ('domjr')
quote
| Majority-rule consensus will be used. |;
2023-10-10 00:25:05 +08:00
else
if ('dohlf')
quote
| Half strict consensus will be used. |;
2023-10-10 00:25:05 +08:00
end end end
2023-10-10 00:25:05 +08:00
if ('dorbrs')
quote
| relative bremer support |;
2023-10-10 00:49:27 +08:00
end
2023-10-10 00:25:05 +08:00
if ('dobrs')
quote
| bremer support |;
2023-10-10 00:49:27 +08:00
end
2023-10-10 00:25:05 +08:00
if ('dojak')
quote
2023-10-10 00:25:05 +08:00
| jackknifing |;
2023-10-10 00:49:27 +08:00
end
2023-10-10 00:25:05 +08:00
if ('doboot')
quote
| bootstrap |;
2023-10-10 00:49:27 +08:00
end
2023-10-10 00:25:05 +08:00
if ('dosym')
| symmetric resampling |;
2023-10-10 00:49:27 +08:00
end
2023-10-10 00:25:05 +08:00
quote
| will be shown on the resample.svg. |
| Apomorphic characters mapping will be shown |
| on the apo.svg and saved to apo*.tre. |
| TL, CI and RI will be calculated finally. |
\------------------------------------------------/;
2023-02-27 01:24:22 +08:00
/*Implied weighting settings*/
2023-10-10 00:25:05 +08:00
if ('doiw')
piwe&;
2023-09-13 20:57:13 +08:00
else
2023-10-10 00:25:05 +08:00
if ('doeiw')
2023-09-13 20:57:13 +08:00
xpiwe(*;
log %7.eiw.log;
2023-09-13 20:57:13 +08:00
piwe&;
log/;
2023-10-10 00:25:05 +08:00
log + %7.tnt.log;
end end
/*Search trees*/
2023-10-10 00:25:05 +08:00
if ('search'==1)
ienum;
2023-09-13 20:57:13 +08:00
else
2023-10-10 00:25:05 +08:00
if ('search'==2)
2023-10-09 17:55:52 +08:00
mult=replic 1000 tbr hold 10;
2023-10-10 00:25:05 +08:00
bbreak=tbr fill;
else
if ('search'==3)
sect: slack 40;
xmult=hit 50 replications 20 drift 10 ratchet 10 fuse 10 hold 1 keepall;
end end end
2023-02-27 01:24:22 +08:00
/*Export trees*/
2023-09-14 00:08:43 +08:00
export= %7.trees.tre;
2023-02-26 03:32:18 +08:00
taxname-;
2023-09-14 00:08:43 +08:00
export= %7.trees_no.tre;
2023-10-09 17:00:29 +08:00
tsave *= %7.trees.tnt.tre;
2023-02-26 03:32:18 +08:00
taxname=;
2023-09-14 00:08:43 +08:00
tsave = %7.trees.ctf;
2023-02-26 03:32:18 +08:00
/*Get npars number*/
var: npars;
set npars ntrees;
2023-07-20 20:53:29 +08:00
2023-10-10 00:25:05 +08:00
/*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;
2023-10-10 00:35:15 +08:00
/*Store consensus tree to tree vault*/
2023-10-10 00:36:11 +08:00
hold /+0;
2023-10-10 00:35:15 +08:00
tv>/;
tchoose 0.'npars';
/*Get rbr/br/jak/boot/sym support and get consensus tree*/
2023-02-26 03:32:18 +08:00
ttags=;
ttags]; /*in one line*/
/* jak=1, boot=2, sym=4, */
2023-09-13 20:57:13 +08:00
/* jak+boot=3, */
/* jak+sym=5, boot+sym=6, */
/* jak+boot+sym=7, */
2023-10-10 00:25:05 +08:00
/* relative-bremer=0.1, bremer=0.2 */
/* bremer+relative-bremer=0.3 */
2023-10-10 00:25:05 +08:00
if ('dobremer')
2023-10-09 17:00:29 +08:00
/*set value of suboptimal from most parsimony tree */
sub: 0;
/*calculate relative bremer support*/
2023-10-10 00:25:05 +08:00
if ('dorbrs')
2023-10-09 17:55:52 +08:00
bs ]!! 0;
2023-10-10 00:25:05 +08:00
end
/*calculate bremer support*/
2023-10-10 00:25:05 +08:00
if ('dobrs')
macfloat 1; /*set the br value float*/
2023-10-09 17:55:52 +08:00
bsupport !! 0;
2023-10-10 00:25:05 +08:00
end
2023-10-10 00:25:05 +08:00
end
2023-10-10 00:35:15 +08:00
/*Choose final tree*/
tv<;
2023-10-10 00:25:05 +08:00
tchoose/;
2023-10-10 00:25:05 +08:00
/*adjust to zero following Pablo Goloboff*/
sub 0;
2023-10-09 17:00:29 +08:00
2023-10-10 00:25:05 +08:00
/*jakknifing*/
if ('dojak')
resample jak replications 1000 from 0; /*from 0 will orphan other trees*/
2023-10-10 00:25:05 +08:00
end
2023-10-10 00:25:05 +08:00
/*bootstrap*/
if ('doboot')
resample boot replications 1000 from 0;
end
2023-10-10 00:25:05 +08:00
/*symmetric resampling*/
if ('dosym')
resample sym replications 1000 from 0;
2023-09-13 20:57:13 +08:00
end
2023-02-27 01:24:22 +08:00
/*Export consensus tree with supports*/
2023-09-14 00:08:43 +08:00
ttags & %7.resample.svg thickness 7 italics fontsize 15;
log %7.resample.log;
quote /-------------resample tags start---------------\;
2023-07-19 19:47:57 +08:00
ttags/;
quote \-------------resample tags stop----------------/;
log/;
log + %7.tnt.log;
2023-09-14 00:08:43 +08:00
export < %7.resample.tre;
2023-02-26 03:32:18 +08:00
taxname-;
2023-09-14 00:08:43 +08:00
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*/
set RI ('themax'-'TL')/('themax'-'themin'); /*RI=1 character fits perfetcly*/
report=;
/*Report CI/RI/TL */
log %7.report.log;
2023-02-27 01:24:22 +08:00
macfloat 3;
quote Consistency Index (CI) is 'CI';
quote Retention Index (RI) is 'RI';
quote Tree Length (TL) is 'TL';
log/;
log + %7.tnt.log;
2023-02-27 01:24:22 +08:00
/*Report*/
quote
/----------------------------------------------\
| The analysis has been finished. |
| The file `tnt.log` contains |
| K, TL, CI and RI |
| The file `trees*.tre` contain |
| trees found by mult and xmult |
| The file `original*.tre` contain |
2023-10-10 00:49:27 +08:00
| 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 ctf file with taxname |
| The file `resample.svg` contain |;
2023-10-10 00:25:05 +08:00
if ('dostr')
quote
| strict consensus tree with |;
2023-09-13 20:57:13 +08:00
else
2023-10-10 00:25:05 +08:00
if ('domjr')
quote
| majority-rule consensus tree with |;
2023-10-10 00:25:05 +08:00
else
if ('dohlf')
quote
| half strict consensus tree with |;
2023-10-10 00:25:05 +08:00
end end end
2023-09-13 20:57:13 +08:00
2023-10-10 00:25:05 +08:00
if ('dorbrs')
quote
| relative bremer support |;
2023-10-10 00:49:27 +08:00
end
2023-10-10 00:25:05 +08:00
if ('dobrs')
quote
| bremer support |;
2023-10-10 00:49:27 +08:00
end
2023-10-10 00:25:05 +08:00
if ('dojak')
quote
| jackknifing |;
2023-10-10 00:49:27 +08:00
end
2023-10-10 00:25:05 +08:00
if ('doboot')
quote
| bootstrap |;
2023-10-10 00:49:27 +08:00
end
2023-10-10 00:25:05 +08:00
if ('dosym')
quote
| symmetric resampling |;
2023-10-10 00:49:27 +08:00
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
2023-09-13 20:57:13 +08:00
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` contain the |
| tree tags in text |
| The file `homo.log` contain the report |
| of character homoplasy |
2023-10-10 00:49:27 +08:00
if ('doeiw')
| The file `eiw.log` contain the report |
2023-10-10 00:49:27 +08:00
end
| of character concavities |
| The file `winclada.tre` can be |
| converted by tnt2winclada |
2023-10-10 00:49:27 +08:00
| The file `original.tnt.tre` can be read |
| by winclada after reading tnt file |
\----------------------------------------------/;
2023-02-27 01:24:22 +08:00
/*Quit*/
zzz;