-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeast2newick
executable file
·60 lines (51 loc) · 1.09 KB
/
beast2newick
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
#!/bin/bash
## Convert beast mcmc-tree output to trees in newick format
##
## 04/15/2009 13:37:35 AM CEST
## Johan Nylander
##
## Usage: beast2newick infile
##
## Notes: Requires the Perl script beast2phy.pl
## Writes file <infile>.phy to cwd.
##
## Set globals
beast2phy="beast2phy.pl"
outputfileending='.phy'
## Check beast2phy.pl
beast2phy=`which $beast2phy`
if ! [ -x "$beast2phy" ]; then
echo "beast2phy.pl can not be found in the PATH. Quitting."
exit 1
fi
## Check arguments
if [ $# -gt 1 ] || [ ! $1 ] ; then
echo
echo "Usage: `basename $0` beast.tree.file"
echo
exit 1
fi
## Check input file
if [ -f "$1" ] ; then
infile=$1
else
echo
echo "File \"$1\" does not exist."
echo "Usage: `basename $0` beast.tree.file"
exit 1
fi
## Set output file
base=${infile%.*}
outfile=$base$outputfileending
if [ -e "$outfile" ] ; then
echo
echo "Outfile \"$outfile\" already exists. Quitting"
echo
exit 1
fi
## Try to convert
$beast2phy --decimals=6 --format=phy --outfile=$outfile $infile
## Finish
echo
echo "read $infile, wrote $outfile"
echo