| •1 |
#!/bin/sh |
| 2 |
# |
| •3 |
|
| 4 |
PATH=/usr/lib/fastdnaml/bin:${PATH} |
| 5 |
|
| 6 |
comm=`echo "$0" | sed -e 's&^.*/&&'` |
| 7 |
cleanflag="-noclean" |
| 8 |
maxflag="-max" |
| 9 |
niceflag="-nice" |
| 10 |
stdopt="" |
| 11 |
|
| 12 |
jumbles=10 |
| 13 |
nice=10 |
| 14 |
cleanUp=1 |
| 15 |
|
| 16 |
# The spaces in the echo and grep are required because of a "feature" that |
| 17 |
# causes /bin/sh echo to consume ANY leading argument that begins with -n. |
| 18 |
|
| 19 |
while echo " $1" | grep "^ -" >/dev/null; do |
| 20 |
if test $# -lt 2; then break |
| 21 |
elif test $1 = $maxflag; then jumbles=$2; shift; shift |
| 22 |
elif test $1 = "-m"; then jumbles=$2; shift; shift |
| 23 |
elif test $1 = $cleanflag; then cleanUp=0; shift |
| 24 |
elif test $1 = "-c"; then cleanUp=0; shift |
| 25 |
elif test $1 = $niceflag; then nice=$2; shift; shift |
| 26 |
elif test $1 = "-n"; then nice=$2; shift; shift |
| 27 |
elif test $1 = "-"; then shift; break |
| 28 |
else echo "Bad flag: $*"; while test $# -gt 0; do shift; done; break |
| 29 |
fi |
| 30 |
done |
| 31 |
|
| 32 |
if test $# -eq 2; then |
| 33 |
opts="$stdopt" |
| 34 |
elif test $# -eq 3; then |
| 35 |
if test -n "$3"; then opts="$stdopt | $3" |
| 36 |
else opts="$stdopt" |
| 37 |
fi |
| 38 |
else |
| 39 |
cleanprm="[$cleanflag]" |
| 40 |
maxprm="[$maxflag maxjumble]" |
| 41 |
niceprm="[$niceflag nicevalue]" |
| 42 |
optprm="[ "'"'"dnaml_opt1 [ | dnaml_opt2 [...]]"'"'" ]" |
| 43 |
echo " |
| 44 |
Usage: $comm $maxprm $cleanprm $niceprm \\ |
| 45 |
in_file n_best $optprm |
| 46 |
|
| 47 |
For the given input file, the sequence input order is jumbled (up to maxjumble |
| 48 |
times) until the same best tree is found n_best times. The output files are |
| 49 |
then reduced to a summary of the scores produced by jumbling, and one example |
| 50 |
of the best tree. |
| 51 |
|
| 52 |
The jumble option is included by the script and should not be specified by the |
| 53 |
user or in the data file. Additional fastDNAml program options are enclosed in |
| 54 |
quotes, and separated by vertical bars (|). |
| 55 |
|
| 56 |
Flags and parameters: |
| 57 |
|
| 58 |
in_file -- name of the input data file |
| 59 |
n_best -- input order is jumbled (up to maxjumble times) until same tree |
| 60 |
is found n_best times |
| 61 |
$maxflag maxjumble -- maximum attempts at replicating inferred tree |
| 62 |
(Default=10) |
| 63 |
$niceflag nicevalue -- run fastDNAml with specified nice value (Default=10) |
| 64 |
$cleanflag -- inhibits cleanup of the output files |
| 65 |
" |
| 66 |
exit |
| 67 |
fi |
| 68 |
|
| 69 |
if test $cleanUp -ne 0; then cleanflag=""; fi |
| 70 |
|
| 71 |
if test -f "$1"; then |
| 72 |
root=`echo "$1" | sed -e 's/\.phylip$//' -e 's/\.phy$//'`; in="$1" |
| 73 |
elif test -f "$1.phy"; then |
| 74 |
root="$1"; in="$1.phy" |
| 75 |
elif test -f "$1.phylip"; then |
| 76 |
root="$1"; in="$1.phylip" |
| 77 |
else |
| 78 |
echo "$comm: Unable to find input file: $1"; exit |
| 79 |
fi |
| 80 |
|
| 81 |
out=`echo "$root" | sed -e 's&^.*/&&'` |
| 82 |
|
| 83 |
# Don't clobber an existing file |
| 84 |
|
| 85 |
if test $cleanUp -ne 0 -a \( -f "$out.tree" -o -f "$out.out" \); then |
| 86 |
echo "" |
| 87 |
echo "$comm: File(s) with the name(s) $out.out and/or $out.tree" |
| 88 |
echo "already exist and would be clobbered by 'cleaning' the jumble output" |
| 89 |
echo "files. Move them to a new name and try again." |
| 90 |
echo "" |
| 91 |
exit |
| 92 |
fi |
| 93 |
|
| 94 |
# Loop over jumble orders: |
| 95 |
|
| 96 |
while |
| 97 |
if test $cleanUp -ne 0 -a -f "$out.summary"; then |
| 98 |
echo "" |
| 99 |
echo "$comm: Jumbling stopped by existence of summary file:" |
| 100 |
echo "$out.summary" |
| 101 |
echo "" |
| 102 |
jumbles=0 |
| 103 |
nBest=0 |
| 104 |
nJumble=0 |
| 105 |
elif test `ls -d $out.[0-9]* 2>/dev/null | wc -l` -gt 0; then |
| 106 |
nJumble=`grep '^Ln Likelihood' $out.[0-9]* /dev/null | wc -l` |
| 107 |
nBest=`grep '^Ln Likelihood' $out.[0-9]* /dev/null | |
| 108 |
sed -e 's/^.*:Ln Likelihood =\(.*\)$/\1/g' | sort -nr +0 | |
| 109 |
awk 'BEGIN{c=0} NR==1{b=$1-0.001} $1>=b{c++} END{print c}'` |
| 110 |
else |
| 111 |
nBest=0 |
| 112 |
nJumble=0 |
| 113 |
fi |
| 114 |
|
| 115 |
test $nBest -lt $2 -a $nJumble -lt $jumbles |
| 116 |
do |
| 117 |
eval "jumble < $in $opts | |
| 118 |
nice -$nice out.PID fastDNAml $out" >/dev/null || exit |
| 119 |
done |
| 120 |
|
| 121 |
if test $cleanUp -ne 0; then clean_jumbles "$out"; fi |