TNT_Script/guoyi.run

468 lines
14 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-02-27 01:24:22 +08:00
/*Arguments*/
2023-09-14 00:08:43 +08:00
if ( (argnumber == 0) | (argnumber >7) )
2023-02-27 01:24:22 +08:00
silent -console;
2023-09-13 20:57:13 +08:00
quote - /----------------------------------------------------\;
quote - | GUOYI TNT SCRIPT 2022-2023 MIT |;
quote - | You need to give your filename |;
quote - | shell> tnt run guoyi.tnt filename, (Linux & Mac) |;
quote - | shell> tnt run guoyi.run filename(semicolon) (Win) |;
quote - | ============================== |;
quote - | === Parameters Details === |;
quote - | ============================== |;
2023-09-14 00:08:43 +08:00
quote - | filename type weight K cons resamp prefix |;
quote - | - type should be 32, dna, prot, num |;
2023-09-13 20:57:13 +08:00
quote - | num=number, dna=DNA, prot=protein |;
quote - | 32=max number allowed (default) |;
quote - | - weight should be iw, ew, eiw |;
quote - | iw=implied weight, ew=equal weight |;
quote - | eiw=extended implied weight (default) |;
2023-09-14 00:08:43 +08:00
quote - | N.B. K of ew must followed 0 (=NA) |;
quote - | - K is 12 (default) following Goloboff |;
quote - | et al. 2017 (Cladistics 34: 407437) |;
quote - | it must more than 0 |;
2023-09-13 20:57:13 +08:00
quote - | - cons should be str, mjr, hlf |;
quote - | mjr=majority rule, hlf=half |;
quote - | str=strict (default) |;
2023-09-14 00:08:43 +08:00
quote - | - resamp should be sum of what you want |;
2023-09-17 02:37:10 +08:00
quote - | jak=1, boot=2, relative bremer=4 sym=8 |;
quote - | i.e. jak+boot+sym+bremer=15 (default) |;
2023-09-14 00:08:43 +08:00
quote - | - prefix can be empty, or a string |;
quote - | default is empty |;
2023-09-13 20:57:13 +08:00
quote - \----------------------------------------------------/;
2023-02-27 01:24:22 +08:00
proc/;
end
2023-09-13 20:57:13 +08:00
/*Basic settings*/
2023-09-17 02:37:10 +08:00
taxname+100;
2023-09-13 20:57:13 +08:00
taxname=;
2023-09-17 02:37:10 +08:00
mxram 500;
2023-09-13 20:57:13 +08:00
if(argnumber>=2)
nstates %2;
else
nstates 32;
end
nstates NOGAPS;
/*Set K*/
if(argnumber>2 )
if (eqstring [ %3 ew ])
quote Equal weighting is used;
if (argnumber>=4)
if (%4!=0)
quote Warning: equal weighting %4 should be fullfilled with 0;
end
end
end
if ((eqstring [ %3 iw ]) | (eqstring [ %3 eiw ]))
if (argnumber>=4)
piwe=%4;
else
piwe=12;
end
end
else
piwe=12;
end
/*Reopen tnt*/
procedure %1;
hold 10000;
2023-02-27 01:24:22 +08:00
/*Report what will be done*/
quote - /-----------------------------------------------\;
2023-09-13 20:57:13 +08:00
if(argnumber>2)
if (eqstring [ %3 iw ])
if (argnumber>3)
quote - | Implied weighting will be used, K is %4. |;
else
quote - | Implied weighting will be used, K is 12. |;
end
end
if (eqstring [ %3 eiw ])
if (argnumber>3)
quote - | Ex-implied weighting will be used, K is %4. |;
else
quote - | Ex-implied weighting will be used, K is 12. |;
end
end
if (eqstring [ %3 ew ])
quote - | Equal weighting will be used. |;
end
else
quote - | Ex-implied weighting will be used, K is 12. |;
end
if (ntax<=25)
quote - | Implicit enumeration will be performed. |;
end
if ((ntax>25) && (ntax < 75))
quote - | TBR Mult will be performed. |;
end
if (ntax>=75)
2023-09-17 02:37:10 +08:00
quote - | Xmult will be performed. |;
2023-09-13 20:57:13 +08:00
end
if (argnumber>=5)
if (eqstring [ %5 mjr ])
quote - | Majority-rule consensus will be used. |;
end
if (eqstring [ %5 hlf ])
quote - | Half strict consensus will be used. |;
end
if(eqstring [ %5 str ])
2023-02-27 01:24:22 +08:00
quote - | Strict consensus will be used. |;
2023-09-13 20:57:13 +08:00
end
end
if (argnumber<5)
quote - | Strict consensus will be used. |;
end
if (argnumber>=6)
if (%6==1)
quote - | Jackknifing |;
end
if (%6==2)
quote - | Bootstrap |;
end
if (%6==3)
quote - | Jackknifing and bootstrap |;
end
if (%6==4)
quote - | Relative bremer support |;
end
if (%6==5)
quote - | Jackknifing and relative bremer support |;
end
if (%6==6)
quote - | Bootstrap and relative bremer support |;
end
if (%6==7)
quote - | Jackknifing, bootstrap and relative bremer |;
end
2023-09-17 02:37:10 +08:00
if (%6==8)
quote - | Symmetric resampling |;
end
if (%6==9)
quote - | Jackknifing and symmetric resampling |;
end
if (%6==10)
quote - | Bootstrap and symmetric resampling |;
end
if (%6==11)
quote - | Jackknifing, bootstrap and symmetric |;
quote - | resampling |;
end
if (%6==12)
quote - | Symmetric resampling and relative bremer |;
end
if (%6==13)
quote - | Jackknifing, symmetric resampling and |;
quote - | relative bremer |;
end
if (%6==14)
quote - | Bootstrap, symmetric resampling and |;
quote - | relative bremer |;
end
if (%6==15)
quote - | Jackknifing, bootstrap, symmetric |;
quote - | resampling and relative bremer support |;
end
2023-09-13 20:57:13 +08:00
end
if (argnumber<6)
2023-09-17 02:37:10 +08:00
quote - | Jackknifing, bootstrap, symmetric |;
quote - | resampling and relative bremer support |;
2023-09-13 20:57:13 +08:00
end
quote - | will be shown on the resample.svg. |;
quote - | Apomorphic characters mapping will be shown |;
quote - | on the apo.svg and saved to apo*.tre. |;
2023-02-27 01:24:22 +08:00
quote - | TL, CI and RI will be calculated finally. |;
quote - \------------------------------------------------/;
/*Implied weighting settings*/
2023-09-13 20:57:13 +08:00
if(argnumber>2)
if (eqstring [ %3 iw ])
piwe&;
end
if (eqstring [ %3 eiw ])
xpiwe(*;
piwe&;
end
else
xpiwe(*;
piwe&;
end
/*Search trees*/
2023-09-17 02:37:10 +08:00
if(argnumber>2)
if(eqstring [ %3 ew ] | eqstring [ %3 iw ] )
if (ntax<=25)
ienum;
else
if (ntax<=74)
mult=replic 1000 tbr hold 1000;
bbreak=tbr fill;
end
if (ntax>74)
sect: slack 40;
2023-09-18 15:17:34 +08:00
xmult=hit 50 replications 20 drift 10 ratchet 10 fuse 10 hold 1 keepall;
2023-09-17 02:37:10 +08:00
end
2023-09-13 20:57:13 +08:00
end
2023-09-17 02:43:05 +08:00
else
if (ntax<=74)
mult=replic 1000 tbr hold 1000;
bbreak=tbr fill;
else
sect: slack 40;
2023-09-18 15:17:34 +08:00
xmult=hit 50 replications 20 drift 20 ratchet 10 fuse 10 hold 1 keepall;
2023-09-17 02:43:05 +08:00
end
2023-09-17 02:37:10 +08:00
end
2023-09-13 20:57:13 +08:00
else
mult=replic 1000 tbr hold 1000;
bbreak=tbr fill;
if (ntax>74)
sect: slack 1000;
2023-09-18 15:17:34 +08:00
xmult=hit 50 replications 20 drift 10 ratchet 10 fuse 10 hold 1 keepall;
2023-09-13 20:57:13 +08:00
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-02-26 03:32:18 +08:00
taxname=;
2023-09-14 00:08:43 +08:00
tsave = %7.trees.ctf;
tsave *= %7.trees.tnt.tre;
2023-02-26 03:32:18 +08:00
2023-02-27 01:24:22 +08:00
/*Consensus tree*/
2023-09-13 20:57:13 +08:00
if (argnumber<=4)
nelsen *;
else
if (eqstring [ %5 str ])
nelsen *;
end
if (eqstring [ %5 mjr ])
majority *;
end
if (eqstring [ %5 hlf ])
comcomp *;
end
end
2023-07-19 19:47:57 +08:00
/*Tree vault store*/
hold /+0;
tvault >/;
2023-07-19 19:47:57 +08:00
/*Export consensus tree*/
tchoose /;
2023-09-14 00:08:43 +08:00
export - %7.original.tre;
2023-07-19 19:47:57 +08:00
taxname-;
2023-09-14 00:08:43 +08:00
export - %7.original_no.tre;
tsave = %7.original.ctf;
tsave *= %7.original.tnt.tre;
2023-02-26 03:32:18 +08:00
/*Caulculate TL/CI/RI score*/
report-;
var-;
var =
0 themin
1 themax
2 CI
3 RI
4 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=;
2023-07-20 20:53:29 +08:00
/*Apomorphic characters*/
2023-09-14 00:08:43 +08:00
export = %7.winclada.tre;
2023-07-20 20:53:29 +08:00
taxname =;
ttags=;
apo >0;
quote - /----------------------------------------------\;
quote - apomorphy tags start ;
ttags/;
quote - apomorphy tags stop ;
quote - \----------------------------------------------/;
2023-09-14 00:08:43 +08:00
ttags & %7.apo.svg thickness 7 italics fontsize 15;
export < %7.apo.tre;
2023-07-20 20:53:29 +08:00
taxname-;
2023-09-14 00:08:43 +08:00
export - %7.apo_no.tre;
2023-07-20 20:53:29 +08:00
ttags-;
/*Get jak/boot/relative-bremer support*/
2023-07-19 19:47:57 +08:00
tchoose/;
2023-02-26 03:32:18 +08:00
ttags=;
ttags]; /*in one line*/
2023-09-13 20:57:13 +08:00
/* jak=1, boot=2, bremer=4, */
/* jak+boot=3, */
/* jak+brember=5, boot+bremer=6, */
/* jak+boot+bremer=7, */
2023-09-17 02:37:10 +08:00
/* sym=8, */
/* jak+sym=9, boot+sym=10, bremer+sym=12 */
/* jak+boot+sym=11, jak+bremer+sym=13, */
/* boot+bremer+sym=14, */
/* jak+sym+boot+bremer=15 */
2023-09-13 20:57:13 +08:00
if (argnumber<=5)
/*jakknifing*/
resample jak replications 1000 from 0;
/*bootstrap*/
resample boot replications 1000 from 0;
2023-09-17 02:37:10 +08:00
/*symmetric resampling*/
resample sym replications 1000 from 0;
2023-09-13 20:57:13 +08:00
/*relative bremer*/
sub 1; hold +1000; bbreak=fill;
sub 3; hold +3000; bbreak=fill;
sub 5; hold +5000; bbreak=fill;
sub 7; hold +7000; bbreak=fill;
bsupport[;
else
2023-09-17 02:37:10 +08:00
if((%6==1) | (%6==3) | (%6==5) | (%6==7) | (%6==9) | (%6==11) | (%6==13) | (%6==15))
2023-09-13 20:57:13 +08:00
resample jak replications 1000 from 0;
end
2023-09-17 02:37:10 +08:00
if((%6==2) | (%6==3) | (%6==6) | (%6==7) | (%6==10) | (%6==11) | (%6==14) | (%6==15))
2023-09-13 20:57:13 +08:00
resample boot replications 1000 from 0;
end
2023-09-17 02:37:10 +08:00
if((%6==8) | (%6==9) | (%6==10) | (%6==11) | (%6==12) | (%6==13) | (%6==14) | (%6==15))
resample sym replications 1000 from 0;
end
if((%6==4) | (%6==5) | (%6==6) | (%6==7) | (%6==12) | (%6==13) | (%6==14) | (%6==15))
2023-09-13 20:57:13 +08:00
sub 1; hold +1000; bbreak=fill;
sub 3; hold +3000; bbreak=fill;
sub 5; hold +5000; bbreak=fill;
sub 7; hold +7000; bbreak=fill;
bsupport[;
end
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;
2023-07-19 19:47:57 +08:00
quote - /----------------------------------------------\;
quote - resample tags start ;
ttags/;
quote - resample tags stop ;
quote - \----------------------------------------------/;
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-;
/*Report CI/RI/TL */
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';
2023-02-27 01:24:22 +08:00
/*Report*/
quote - /----------------------------------------------\;
quote - | The analysis has been finished. |;
quote - | The file `tnt.log` contains |;
quote - | K, TL, CI and RI |;
quote - | The file `trees*.tre` contain |;
quote - | trees found by mult and xmult |;
2023-07-19 19:47:57 +08:00
quote - | The file `original*.tre` contain |;
quote - | strict consensus tree without label |;
quote - | The file `resample*.tre` contain |;
2023-07-19 19:47:57 +08:00
quote - | consensus tree with support |;
quote - | The file `apo*.tre` contain |;
quote - | tree with apomorphic character |;
2023-02-27 01:24:22 +08:00
quote - | The file `*_no.tre` contain |;
2023-07-20 20:53:29 +08:00
quote - | tree with `taxname-` |;
2023-07-19 19:47:57 +08:00
quote - | The file `*.ctf` tree file is |;
quote - | only readable for TNT |;
quote - | The file `*.tnt.tre` contain |;
quote - | is the ctf file with taxname |;
quote - | The file `resample.svg` contain |;
2023-09-13 20:57:13 +08:00
if (argnumber>=5)
if(eqstring [ %5 mjr ])
quote - | majority rule consensus tree with |;
end
if(eqstring [ %5 hlf ])
quote - | half strict consensus tree with |;
end
if(eqstring [ %5 str ])
quote - | strict consensus tree with |;
end
else
2023-02-27 01:24:22 +08:00
quote - | strict consensus tree with |;
2023-09-13 20:57:13 +08:00
end
if (argnumber>=6)
if (%6==1)
quote - | jackknifing |;
end
if (%6==2)
quote - | bootstrap |;
end
if (%6==3)
quote - | jackknifing and bootstrap |;
end
if (%6==4)
quote - | relative bremer support |;
end
if (%6==5)
quote - | jackknifing and relative bremer |;
quote - | support |;
end
if (%6==6)
quote - | bootstrap and relative bremer |;
quote - | support |;
end
if (%6==7)
quote - | jackknifing, bootstrap and |;
quote - | relative bremer support |;
end
2023-09-17 02:37:10 +08:00
if (%6==8)
quote - | symmetric resampling |;
end
if (%6==9)
quote - | Jackknifing and symmetric resample |;
end
if (%6==10)
quote - | Bootstrap and symmetric resample |;
end
if (%6==11)
2023-09-13 20:57:13 +08:00
quote - | jackknifing, bootstrap and |;
2023-09-17 02:37:10 +08:00
quote - | symmetric resample |;
end
if (%6==12)
quote - | relative bremer support and |;
quote - | symmetric resampling |;
end
if (%6==13)
quote - | Jackknifing, symmetric resample and |;
quote - | relative bremer support |;
end
if (%6==14)
quote - | bootstrap, symmetric resmaple and |;
2023-09-13 20:57:13 +08:00
quote - | relative bremer support |;
2023-09-17 02:37:10 +08:00
end
if (%6==15)
quote - | jackknifing, bootstrap, symmetric |;
quote - | resample and relative bremer support|;
end
else
quote - | jackknifing, bootstrap, symmetric |;
quote - | resample and relative bremer support|;
2023-09-13 20:57:13 +08:00
end
quote - | The file `apo.svg` contain the |;
quote - | tree with apomorphy mapping |;
quote - | The file `winclada.tre` can be |;
quote - | converted by tnt2winclada |;
2023-02-27 01:24:22 +08:00
quote - \----------------------------------------------/;
/*Quit*/
zzz;