-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathUCE_divergence.sh
71 lines (56 loc) · 1.66 KB
/
UCE_divergence.sh
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
filetype=`tail -n+1 UCE_divergence.settings | head -n1`
method=`tail -n+2 UCE_divergence.settings | head -n1`
methodoptions=`tail -n+3 UCE_divergence.settings | head -n1`
if [ "$method" = "paup" ]; then
if [ "$filetype" = "fasta" ]; then
for f in `ls *.fasta`; do
newname=`echo $f | sed "1s/.fasta//"`
seqmagick convert --alphabet dna-ambiguous $newname.fasta $newname.nex
done
fi
if [ "$filetype" = "nexus" ]; then
for f in `ls *.nexus`; do
newname=`echo $f | sed "1s/.nexus//"`
mv $newname.nexus $newname.nex
done
fi
ls *.nex | tail -n+1 | head -n1 > renamefile
Rscript shortennames.R
bash shortnames.sh
NEXUSFILES=*.nex
for f in $NEXUSFILES; do
basename=`echo $f | sed "1s/.nex//"`
printf "begin paup; execute $f; Dset $methodoptions; SaveDist FORMAT=PHYLIP FILE=$basename.out TRIANGLE=BOTH UNDEFINED=ASTERISK REPLACE=YES APPEND=NO; end;" > paup_file
paup -n paup_file
done
else
if [ "$filetype" = "nexus" ]; then
for f in `ls *.nexus`; do
newname=`echo $f | sed "1s/.nexus//"`
mv $newname.nexus $newname.nex
done
fi
if [ "$filetype" != "fasta" ]; then
for f in `ls *.nex*`; do
newname=`echo $f | sed "1s/.nex//"`
seqmagick convert --alphabet dna-ambiguous $newname.nex $newname.fasta
done
fi
FASTAFILES=*.fasta
for f in $FASTAFILES; do
basename=`echo $f | sed "1s/.fasta//"`
sed -i 's/?/-/g' $f
~/bin/fastphylo-1.0.1-Linux/bin/fastdist $f -o $basename.out -O phylip $methodoptions
done
fi
rm -rf combined.outfile
OUTFILES=*.out
for f in $OUTFILES; do
basename=`echo $f | sed "1s/.out//"`
awk '{print chrname" "$0}' chrname="$basename" $f | tail -n +2 >> combined.outfile
done
rm -rf *.out
if [ "$method" = "paup" ]; then
bash lengthennames.sh
fi
Rscript UCE_divergence.R