Compare commits

..

No commits in common. "main" and "0.0.7" have entirely different histories.
main ... 0.0.7

11 changed files with 192 additions and 1052 deletions

54
3tnt.sh
View File

@ -1,54 +0,0 @@
#!/bin/bash
# Found TNT
if [ -z "tnt" ]; then
echo "TNT not found"
exit 1
fi
# Define input data
input_file=$1
if [ -z "$input_file" ]; then
echo "Usage: $0 <input_file> <guoyi.run>"
exit 1
fi
# Define tnt script
script_file=$2
if [ -z "$script_file" ]; then
echo "Usage: $0 <input_file> <guoyi.run>"
echo "Warning: guoyi.run will be set as /usr/share/tnt/tnt_scripts/guoyi.run"
script_file="/usr/share/tnt/tnt_scripts/guoyi.run"
fi
# Define three weighting functions
task1() {
echo "Equal Weighting started"
tnt run $script_file $input_file 3 ew 0 str 5 EW,
echo "Equal Weighting completed"
}
task2() {
echo "Implied Weighting started"
tnt run $script_file $input_file 3 iw 12 str 5 IW,
echo "Implied Weighting completed"
}
task3() {
echo "Extended Implied Weighting started"
tnt run $script_file $input_file 3 eiw 12 str 5 EIW,
echo "Extended Implied Weighting completed"
}
task1
task2
task3
echo "All tasks completed"

View File

@ -1,13 +1,15 @@
cmake_minimum_required(VERSION 3.0)
project(tnt_script)
project(tnt2winclada)
SET( CMAKE_EXPORT_COMPILE_COMMANDS ON )
set(CMAKE_CXX_STANDARD 11)
add_subdirectory(src_tnt2winclada)
add_subdirectory(src_tnt2figtree)
add_executable(tnt2winclada tnt2winclada.cpp)
target_compile_options(tnt2winclada PRIVATE -Wall -Wextra -pedantic)
install(TARGETS tnt2winclada DESTINATION /usr/bin)
install(FILES guoyi.run DESTINATION /usr/share/tnt/tnt_scripts)
install(FILES LICENSE DESTINATION /usr/share/licenses/tnt-guoyi-script)
install(FILES README.md DESTINATION /usr/share/doc/tnt-guoyi-script)
install(FILES LICENSE DESTINATION /usr/share/licenses/tnt2winclada)
install(FILES README.md DESTINATION /usr/share/doc/tnt2winclada)

136
README.md
View File

@ -1,8 +1,6 @@
# guoyi.run
# TNT Script used by Guoyi
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.8431529.svg)](https://doi.org/10.5281/zenodo.8431529)
TNT Script for Maximum Parsimony Analysis (Phylogeny)
The TNT script follows MIT and part of script is from setk.run belonging to Salvador Arias (Instituto Miguel Lillo, San Miguel de Tucumán, Argentina).
## Usage
@ -14,13 +12,13 @@ TNT Script for Maximum Parsimony Analysis (Phylogeny)
## Functions
- Extended implied weighting with K value setting (default, default K=12) or implied weighting with K value setting (default K=12) or equal weighting.
- Estimate implied weighting K value.
- Search trees via implicit enumeration (ntax<=25, but not for eiw) or TBR Mult (1000 times) with branch swapping (25<ntax<75, also for ntax<=25 with eiw) or Mult with branch swapping and Xmult (use random sectorial searches, produce 50 hits to best length and stop, 10 cycles of drifting, ratchet and fusing) (ntax>=75).
- Search trees via TBR Mult (1000 times) and Xmult (use random sectorial searches, produce 1,000 hits to best length and stop, 10 cycles of drifting, ratchet and fusing).
- Perform Strict consensus / Majority-rule consensus (without bremer support variations) / Half strict consensus (without bremer support variations).
- Perform Strict consensus.
- Calculate relative Bremer support, jackknifing (1,000 times), bootstrap (1,000 times) and symmetric resampling (1,000 times).
- Calculate Relative Bremer support, jackknifing (1,000 times), and bootstrap (1,000 times).
- Map apomorphic characters on the consensus tree.
@ -28,80 +26,74 @@ TNT Script for Maximum Parsimony Analysis (Phylogeny)
## Options
For Windows users
```
tnt run guoyi.run filename datatype weight 0/K cons resample prefix;
```
For Linux and Mac users
```
tnt run guoyi.run filename datatype weight 0/K cons resample prefix,
```
- datatype should be `32`, `dna`, `prot`, `num` or any types tnt allowed
- 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. ew must followed 0 (the K value position for ew iw and eiw)
- 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)
- resample should be sum of what you want
- relative bremer support (rbrs)=0.1, bremer support (brs)=0.2, jackknifing (jak)=1, bootstrap (boot)=2, symmetric resampling (sym)=4 i.e. rbrs+jak+boot+sym=7.1 (default)
- prefix can be empty or a string
- default is empty
## Results
- Results instructions are at the end of `tnt.log`.
- `*.tre` are trees with taxname, `*_no.tre` are trees without taxname.
- `trees.tre`, `resample.tre` are trees with taxname.
- `*.tnt.tre` can be read by TNT/WinClada directly.
- `trees_no.tre`, `resample_no.tre` are trees without taxname.
- `*.ctf` can only be read by TNT via `shortread`.
- `nelsen` can be replaced by `majority`.
- `*.svg` is the tree file, which can be edited by [inkscape](https://inkscape.org)
- `original*` is the consensus tree.
- `apo.tre` is the apomorphic character mapping tree.
- `resample.tre` is the consensus tree with support, which can be read by figtree after processing by tnt2figtree.
- `trees*.tre` contains he MPTs, which can be read by figtree after processing by tnt2figtree.
- `resample/apo.log` contains the tree tags.
- `eiw.log` contains character concavities.
- `homo.log` contains homoplasy report of all characters.
- `report.log` contains CI RI TL.
- `winclada.ss` includes data matrix and consensus tree and it can be read by winclada directly.
- `xmult` and `mult` replications and hold trees number can be adjusted.
- `winclada.tre` can be transferred to the acceptable format for WinClada by tnt2winclada and the output file can be put into Winclada with your tnt matrix file `filename` for mapping apomorphic characters and homoplasy.
## Cite
Cite this script is mandatory, list me (Guoyi Zhang) in your Acknowledgements is recommended. This script follows MIT License.
Cite this script is mandatory, list me (Guoyi Zhang) in your Acknowledgements is recommended.
# Further information
# TNT2WinClada
To make tnt exported trees can be readable by WinClada (Nixon, 2021) and FigTree, please check tnt2winclada and tnt2figtree in this repository.
```
~|~|\ |~|~ ~) | |o._ |~| _ _| _
| | \| | /_ \/\/ || ||_|(_|(_|(_|
runwincladtree.run can handle [wincladtree script](https://www.lillo.org.ar/phylogeny/tnt/scripts/wincladtree.run) with input file which must be $(PREFIX).winclada.ss or winclada.tree.
MIT, Guoyi Zhang, 2023
```
## Function
Convert TNT output tree file without tags and taxname, e.g. `winclada.tre` produced by TNT script, to WinClada acceptable format tree.
## Compile
### Linux & Unix
```
mkdir -p build && cd build
cmake ..
make && make install
```
### Windows
```
cl /EHsc tnt2winclada.cpp
```
## Usage
```
tnt2winclada -i ${input_file} -o ${output_file}
```
Interactive commands are also available.
```
tnt2winclada
~|~|\ |~|~ ~) | |o._ |~| _ _| _
| | \| | /_ \/\/ || ||_|(_|(_|(_|
TNT2WinClada
MIT, Guoyi Zhang, 2023
please type help to see more commands
tnt2winclada> help
help show interactive commands help
input <filename> input a TNT output tree from the specified file
output <filename> output a winclada accessible tree file
quit quit the program
exit exit the program
tnt2winclada>
```

699
guoyi.run
View File

@ -1,621 +1,164 @@
macro=;
log tnt.log;
macro=; taxname+1000; taxname=; mxram 10240; nstates 32; nstates NOGAPS;
log %7.tnt.log;
/*primary notification*/
if ( (argnumber == 0) || (argnumber >7) )
/*Arguments*/
if ( argnumber != 1 )
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: 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+jak+boot+sym=7.1 (default) |
| - prefix can be empty, or a string |
| default is empty |
\----------------------------------------------------/;
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; (Windows) |;
quote - \--------------------------------------------------/;
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;
/*Report what will be done*/
quote - /-----------------------------------------------\;
quote - | Implied weighting will be estimated. |;
quote - | TBR Mult and Xmult will be performed. |;
quote - | Strict consensus will be used. |;
quote - | Jackknifing, bootstrap and relative bremer |;
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. |;
quote - | TL, CI and RI will be calculated finally. |;
quote - \------------------------------------------------/;
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
/*Set K*/
piwe=12;
/*Reopen tnt*/
if ('istnt' || 'isnex')
procedure $input;
else
if ('isfas')
procedure & $input;
end end
procedure %1;
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
xpiwe(*;
piwe&;
/*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
mult=replic 1000 tbr hold 1000;
bbreak=tbr fill;
sect: slack 1000;
xmult=hit 1000 noupdate replications 20 drift 10 ratchet 10 fuse 10 hold 1 keepall;
/*Export trees*/
export= %7.trees.tre;
export= trees.tre;
taxname-;
export= %7.trees_no.tre;
tsave *= %7.trees.tnt.tre;
export= trees_no.tre;
taxname=;
tsave = %7.trees.ctf;
tsave = trees.ctf;
tsave *= trees.tnt.tre;
/*Get npars number*/
var: npars;
set npars ntrees;
/*Consensus tree*/
nelsen *;
/*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=;
/*Tree vault store*/
hold /+0;
tvault >/;
/*Export consensus tree*/
tchoose /;
export - %7.original.tre;
export - 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;
export - original_no.tre;
tsave = original.ctf;
tsave *= original.tnt.tre;
/*Caulculate TL/CI/RI score*/
report-;
var: themin themax CI RI TL ;
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=;
/*Apomorphic characters*/
export = winclada.tre;
taxname =;
ttags=;
apo >0;
quote - /----------------------------------------------\;
quote - apomorphy tags start ;
ttags/;
quote - apomorphy tags stop ;
quote - \----------------------------------------------/;
ttags & apo.svg thickness 7 italics fontsize 15;
export < apo.tre;
taxname-;
export - apo_no.tre;
ttags-;
/*Get jak/boot/relative-bremer support*/
tchoose/;
ttags=;
ttags]; /*in one line*/
resample jak replications 1000 from 0;
resample boot replications 1000 from 0;
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[;
/*Export consensus tree with supports*/
ttags & resample.svg thickness 7 italics fontsize 15;
quote - /----------------------------------------------\;
quote - resample tags start ;
ttags/;
quote - resample tags stop ;
quote - \----------------------------------------------/;
export < resample.tre;
taxname-;
export - resample_no.tre;
ttags-;
/*Report CI/RI/TL */
log %7.report.log;
macfloat 3;
quote Consistency Index (CI) is 'CI';
quote Retention Index (RI) is 'RI';
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 |
\----------------------------------------------/;
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 |;
quote - | The file `original*.tre` contain |;
quote - | strict consensus tree without label |;
quote - | The file `resample*.tre` contain |;
quote - | consensus tree with support |;
quote - | The file `apo*.tre` contain |;
quote - | tree with apomorphic character |;
quote - | The file `*_no.tre` contain |;
quote - | tree with `taxname-` |;
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 |;
quote - | strict consensus tree with |;
quote - | relative jak, boot and bremer |;
quote - | support on the tree |;
quote - | The file `apo.svg` contain the |;
quote - | tree with apomorphy mapping |;
quote - | The file `winclada.tre` can be |;
quote - | converted by tnt2winclada |;
quote - \----------------------------------------------/;
/*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/;

View File

@ -1,7 +0,0 @@
macro=;
taxname+5000;
p %1;
ttags=;
apo>0;
wincladtree %1.wincladtree.svg noalign shade rotate squaresize 15 taxangle 0;
zzz;

View File

@ -1,14 +0,0 @@
cmake_minimum_required(VERSION 3.0)
project(tnt2figtree)
SET( CMAKE_EXPORT_COMPILE_COMMANDS ON )
set(CMAKE_CXX_STANDARD 11)
add_executable(tnt2figtree tnt2figtree.cpp)
target_compile_options(tnt2figtree PRIVATE -Wall -Wextra -pedantic)
install(TARGETS tnt2figtree DESTINATION /usr/bin)
install(FILES ../LICENSE DESTINATION /usr/share/licenses/tnt2figtree)
install(FILES README.md DESTINATION /usr/share/doc/tnt2figtree)

View File

@ -1,55 +0,0 @@
# TNT2FigTree
```
~|~|\ |~|~~)|~o(~|~|~._ _ _
| | \| | /_|~| _| | | }_}_
MIT, Guoyi Zhang, 2024
```
## Function
Convert TNT output tree file with resample tags, e.g. `resample.tre` produced by TNT script `guoyi.run`, to complete nexus format tree.
## Compile
### Linux & Unix
```
mkdir -p build && cd build
cmake ..
make && make install
```
### Windows
```
cl /EHsc tnt2figtree.cpp
```
## Usage
```
tnt2figtree ${input_file} ${output_file}
```
Interactive commands are also available.
```
tnt2figtree
~|~|\ |~|~~)|~o(~|~|~._ _ _
| | \| | /_|~| _| | | }_}_
TNT2FigTree
MIT, Guoyi Zhang, 2024
please type help to see more commands
tnt2figtree> help
help show interactive commands help
import <filename> import a TNT output nexus format tree by TNT export command
export <filename> export a nexus format tree file
quit quit the program
exit exit the program
tnt2figree>
```

View File

@ -1,198 +0,0 @@
#include <fstream>
#include <iostream>
#include <regex>
#include <sstream>
std::string remove_useless(std::string input_str1)
{
std::string result_str1 =
std::regex_replace(input_str1, std::regex(" /*"), " ");
result_str1 = std::regex_replace(result_str1, std::regex("\\["), "{");
result_str1 = std::regex_replace(result_str1, std::regex("\\]"), "}");
return result_str1;
}
std::string add_support(std::string input_str2)
{
std::string result_str2 = "";
size_t i = 0;
while (i < input_str2.length()) {
if (input_str2[i] == ')') {
result_str2 += input_str2[i];
i++;
std::string support_str = "";
while (i < input_str2.length() &&
std::regex_match(std::string(1, input_str2[i]),
std::regex("[/0-9{}?]"))) {
support_str += input_str2[i];
i++;
}
result_str2 += "[&support=\"" + support_str + "\"]";
}
else {
result_str2 += input_str2[i];
i++;
}
}
return result_str2;
}
std::string add_blen(std::string input_str3)
{
std::string result_str3 = "";
int i = 0;
for (char c : input_str3) {
if (c == '(') {
i++;
result_str3 += c;
}
else if (c == ')') {
result_str3 += ":" + std::to_string(i) + c;
i--;
}
else if (c == ',') {
result_str3 += ":" + std::to_string(i) + c;
}
else {
result_str3 += c;
}
}
return result_str3;
}
std::string remove_slash(std::string input_str4)
{
std::string result_str4 = std::regex_replace(
input_str4, std::regex("\\[&support=\"[\\/\\s]*\"\\]"), "");
return result_str4;
}
std::vector<std::string> get_lines(std::string filename)
{
std::ifstream file(filename);
if (!file.is_open()) {
std::cout << "Failed to open the input file." << std::endl;
}
std::vector<std::string> lines;
std::string line;
while (std::getline(file, line)) {
lines.push_back(line);
}
file.close();
return lines;
}
std::vector<std::string> process_line(std::vector<std::string> lines,
size_t lineNum)
{
std::string line = remove_useless(lines[lineNum]);
line = add_blen(line);
line = add_support(line);
lines[lineNum] = remove_slash(line);
return lines;
}
void write_lines(const std::vector<std::string>& lines,
const std::string& filename)
{
std::ofstream outfile(filename);
if (!outfile.is_open()) {
std::cout << "Failed to open the output file." << std::endl;
}
for (const std::string& line : lines) {
outfile << line << std::endl;
}
outfile.close();
}
void interactive_commands(std::vector<std::string> lines)
{
std::string command, filename1, filename2;
std::cout
<< "~|~|\\ |~|~~)|~o(~|~|~._ _ _\n | | \\| | /_|~| _| | | }_}_"
<< std::endl;
std::cout << "TNT2FigTree\nMIT, Guoyi Zhang, 2024\nplease type help "
"to see more commands"
<< std::endl;
while (true) {
std::cout << "tnt2figtree> ";
getline(std::cin, command);
if (command == "help") {
std::cout << "help\t\t\tshow interactive commands "
"help\nimport <filename>\timport a TNT "
"output nexus format tree by TNT export "
"command\nexport <filename>\texport a "
"nexus format tree file\nquit\t\t\tquit "
"the program\nexit\t\t\texit the program"
<< std::endl;
}
else if (command.find("import ") == 0) {
std::stringstream ss(command.substr(7));
ss >> filename1;
if (filename1.empty()) {
std::cout << "tnt2figtree> please specify a "
"filename."
<< std::endl;
}
else {
lines = get_lines(filename1);
}
}
else if (command.find("export ") == 0) {
std::stringstream ss(command.substr(7));
ss >> filename2;
if (filename2.empty()) {
std::cout << "tnt2figtree> please specify a "
"filename."
<< std::endl;
}
else {
for (size_t i = 0; i < lines.size(); i++) {
if (lines[i][0] == '(') {
lines = process_line(lines, i);
}
}
write_lines(lines, filename2);
}
}
else if (command == "quit" || command == "exit") {
break;
}
else {
std::cout << "tnt2figtree> unrecognized command. Type "
"'help' for "
"a list of commands."
<< std::endl;
}
}
}
int main(int argc, char* argv[])
{
std::vector<std::string> lines;
if (argc == 1) {
interactive_commands(lines);
return 0;
}
else if (argc == 3) {
lines = get_lines(argv[1]);
for (size_t i = 0; i < lines.size(); i++) {
if (lines[i][0] == '(') {
lines = process_line(lines, i);
}
}
write_lines(lines, argv[2]);
}
else {
std::cout << "Usage: " << argv[0]
<< " <input_tnt_treefile> <output_nexus_treefile>"
<< std::endl;
}
return 0;
}

View File

@ -1,14 +0,0 @@
cmake_minimum_required(VERSION 3.0)
project(tnt2winclada)
SET( CMAKE_EXPORT_COMPILE_COMMANDS ON )
set(CMAKE_CXX_STANDARD 11)
add_executable(tnt2winclada tnt2winclada.cpp)
target_compile_options(tnt2winclada PRIVATE -Wall -Wextra -pedantic)
install(TARGETS tnt2winclada DESTINATION /usr/bin)
install(FILES ../LICENSE DESTINATION /usr/share/licenses/tnt2winclada)
install(FILES README.md DESTINATION /usr/share/doc/tnt2winclada)

View File

@ -1,55 +0,0 @@
# TNT2WinClada
```
~|~|\ |~|~ ~) | |o._ |~| _ _| _
| | \| | /_ \/\/ || ||_|(_|(_|(_|
MIT, Guoyi Zhang, 2023
```
## Function
Convert TNT output tree file without tags and taxname, e.g. `winclada.tre` produced by TNT script `guoyi.run`, to WinClada acceptable format tree.
## Compile
### Linux & Unix
```
mkdir -p build && cd build
cmake ..
make && make install
```
### Windows
```
cl /EHsc tnt2winclada.cpp
```
## Usage
```
tnt2winclada -i ${input_file} -o ${output_file}
```
Interactive commands are also available.
```
tnt2winclada
~|~|\ |~|~ ~) | |o._ |~| _ _| _
| | \| | /_ \/\/ || ||_|(_|(_|(_|
TNT2WinClada
MIT, Guoyi Zhang, 2023
please type help to see more commands
tnt2winclada> help
help show interactive commands help
input <filename> input a TNT output tree from the specified file
output <filename> output a winclada accessible tree file
quit quit the program
exit exit the program
tnt2winclada>
```