1 | #!/bin/bash |
---|
2 | # renames output to 'treefile' |
---|
3 | |
---|
4 | usage() { |
---|
5 | arb_message "arb_raxml called with wrong parameters (look @ console for errors)" |
---|
6 | echo "Usage:" |
---|
7 | echo " arb_raxml 'DNA' SEQFILE WEIGHTS TREE CONSTRAINT RANDOMSTART OPTIMIZEPARAMETERS SEARCH INITIALREARRANGEMENT SEED NUMBEROFRUNS TAKETREES [import|consense] \"COMMENT\" RATEMODELNUC NUMCATEGORIES" |
---|
8 | echo " arb_raxml 'PROTEIN' SEQFILE WEIGHTS TREE CONSTRAINT RANDOMSTART OPTIMIZEPARAMETERS SEARCH INITIALREARRANGEMENT SEED NUMBEROFRUNS TAKETREES [import|consense] \"COMMENT\" RATEMODELPROT MATRIXNAME" |
---|
9 | exit 1 |
---|
10 | } |
---|
11 | |
---|
12 | if [ -z "${13}" ]; then |
---|
13 | usage |
---|
14 | else |
---|
15 | # parameters common for DNA and PROTEIN |
---|
16 | DATA=$1 ; shift |
---|
17 | SEQFILE=$1 ; shift |
---|
18 | WEIGHTS=$1 ; shift |
---|
19 | TREE=$1 ; shift |
---|
20 | CONSTRAINT=$1 ; shift |
---|
21 | |
---|
22 | RANDOMSTART=$1 ; shift |
---|
23 | OPTIMIZEPARAMETERS=$1 ; shift |
---|
24 | SEARCH=$1 ; shift |
---|
25 | INITIALREARRANGEMENT=$1 ; shift |
---|
26 | SEED=$1 ; shift |
---|
27 | |
---|
28 | NUMBEROFRUNS=$1 ; shift |
---|
29 | TAKETREES=$1 ; shift |
---|
30 | CONSENSE=$1 ; shift |
---|
31 | COMMENT=$1 ; shift |
---|
32 | |
---|
33 | if [ -z "$CONSENSE" ]; then |
---|
34 | usage |
---|
35 | fi |
---|
36 | |
---|
37 | if [ $(($NUMBEROFRUNS)) -lt 1 ]; then |
---|
38 | arb_message "Invalid number of runs specified (NUMBEROFRUNS=$NUMBEROFRUNS)" |
---|
39 | exit 1 |
---|
40 | fi |
---|
41 | |
---|
42 | DIST=unknown |
---|
43 | if [ "$DATA" == "DNA" ]; then |
---|
44 | if [ -z "$1" ]; then |
---|
45 | usage |
---|
46 | fi |
---|
47 | RATEMODELNUC=$1 |
---|
48 | NUMCATEGORIES=$2 |
---|
49 | DIST=${RATEMODELNUC}-${NUMCATEGORIES} |
---|
50 | else |
---|
51 | if [ "$DATA" == "PROTEIN" ]; then |
---|
52 | # if [ -z "$2" ]; then |
---|
53 | # usage |
---|
54 | # fi |
---|
55 | RATEMODELPROT=$1 |
---|
56 | MATRIXNAME=$2 |
---|
57 | DIST=${RATEMODELPROT}-${MATRIXNAME} |
---|
58 | else |
---|
59 | arb_message "Unknown datatype '$DATA'" |
---|
60 | exit 1 |
---|
61 | fi |
---|
62 | fi |
---|
63 | |
---|
64 | COMMENT=${COMMENT/ALGO=/DIST=$DIST ALGO=} |
---|
65 | |
---|
66 | if [ -z "$SEED" ]; then |
---|
67 | # seconds since 1970 |
---|
68 | SEED=`date +%s` |
---|
69 | fi |
---|
70 | |
---|
71 | # check inputfiles |
---|
72 | if [ \! -s $SEQFILE ]; then |
---|
73 | arb_message "Missing or empty sequence file '$SEQFILE'" |
---|
74 | exit 1 |
---|
75 | fi |
---|
76 | if [ \! -s $WEIGHTS ]; then |
---|
77 | arb_message "Missing or empty weights file '$WEIGHTS'" |
---|
78 | exit 1 |
---|
79 | fi |
---|
80 | |
---|
81 | # generate tree file |
---|
82 | TREEPARAMS= |
---|
83 | HAVEINPUTTREE=0 |
---|
84 | if [ "$TREE" != "tree_?????" -a ! -z "$TREE" ]; then # has to match ../TEMPLATES/arb_global_defs.h@NO_TREE_SELECTED |
---|
85 | CMD="arb_export_tree $TREE" |
---|
86 | echo "$CMD" |
---|
87 | echo `$CMD > treefile.in` |
---|
88 | if [ \! -s treefile.in ]; then |
---|
89 | arb_message "Couldn't export tree '$TREE'" |
---|
90 | exit 1 |
---|
91 | fi |
---|
92 | if [ "$CONSTRAINT" == "1" ]; then |
---|
93 | TREEPARAMS="-r treefile.in" |
---|
94 | else |
---|
95 | TREEPARAMS="-t treefile.in" |
---|
96 | fi |
---|
97 | HAVEINPUTTREE=1 |
---|
98 | else |
---|
99 | if [ "$RANDOMSTART" == "1" ]; then |
---|
100 | TREEPARAMS=-d |
---|
101 | fi |
---|
102 | # otherwise use default parsimony tree |
---|
103 | fi |
---|
104 | |
---|
105 | # model dependent parameters |
---|
106 | DEPENDENT_PARAMS= |
---|
107 | if [ "$OPTIMIZEPARAMETERS" == "1" ]; then |
---|
108 | if [ "$DATA" == "DNA" ]; then |
---|
109 | case "$RATEMODELNUC" in |
---|
110 | "GTRGAMMA" | "GTRGAMMAI" ) |
---|
111 | DEPENDENT_PARAMS="$DEPENDENT_PARAMS -k" |
---|
112 | ;; |
---|
113 | * ) |
---|
114 | arb_message "Ignored 'Optimize branches/parameters'\n(only usable with GTRGAMMA)" |
---|
115 | ;; |
---|
116 | esac |
---|
117 | else |
---|
118 | case "$RATEMODELPROT" in |
---|
119 | "PROTGAMMA" | "PROTGAMMAI" ) |
---|
120 | DEPENDENT_PARAMS="$DEPENDENT_PARAMS -k" |
---|
121 | ;; |
---|
122 | * ) |
---|
123 | arb_message "Ignored 'Optimize branches/parameters'\n(only usable with PROTGAMMA)" |
---|
124 | ;; |
---|
125 | esac |
---|
126 | fi |
---|
127 | fi |
---|
128 | |
---|
129 | if [ "$DATA" == "DNA" ]; then |
---|
130 | if [ "$RATEMODELNUC" == "GTRCAT" ]; then |
---|
131 | DEPENDENT_PARAMS="$DEPENDENT_PARAMS -c $NUMCATEGORIES" |
---|
132 | fi |
---|
133 | fi |
---|
134 | |
---|
135 | # search algorithm |
---|
136 | NEEDINPUTTREE=0 |
---|
137 | USESINPUTTREE=0 |
---|
138 | NEEDGAMMA=0 |
---|
139 | GENERATEDTREES=$NUMBEROFRUNS |
---|
140 | MODE=normal |
---|
141 | |
---|
142 | case "$SEARCH" in |
---|
143 | "e" ) # optimize input tree |
---|
144 | NEEDINPUTTREE=1 |
---|
145 | NEEDGAMMA=1 |
---|
146 | MODE=optimized |
---|
147 | ;; |
---|
148 | |
---|
149 | "t" ) # randomized tree searches |
---|
150 | NEEDINPUTTREE=1 |
---|
151 | ;; |
---|
152 | |
---|
153 | "d" ) # new rapid hill climbing |
---|
154 | # modes that use (but don't expect) an inputtree |
---|
155 | USESINPUTTREE=1 |
---|
156 | ;; |
---|
157 | |
---|
158 | "a" ) # rapid bootstrap analysis |
---|
159 | DEPENDENT_PARAMS="$DEPENDENT_PARAMS -k -x $SEED" |
---|
160 | if [ $(($NUMBEROFRUNS)) -lt 2 ]; then |
---|
161 | arb_message "You need to specify at least 2 runs (NUMBEROFRUNS=$NUMBEROFRUNS)" |
---|
162 | exit 1 |
---|
163 | fi |
---|
164 | MODE=bootstrapped |
---|
165 | ;; |
---|
166 | |
---|
167 | "p" ) # add new sequences (MP) |
---|
168 | NEEDINPUTTREE=1 |
---|
169 | GENERATEDTREES=1 |
---|
170 | if [ "$NUMBEROFRUNS" != "1" ]; then |
---|
171 | arb_message "Ignoring number of runs (only performing 1 run)" |
---|
172 | NUMBEROFRUNS=1 |
---|
173 | fi |
---|
174 | TAKETREES=1 |
---|
175 | ;; |
---|
176 | |
---|
177 | esac |
---|
178 | |
---|
179 | if [ $(($GENERATEDTREES)) -lt $((TAKETREES)) ]; then |
---|
180 | arb_message "Can't take $TAKETREES of $GENERATEDTREES tree (using all)" |
---|
181 | $TAKETREES = $GENERATEDTREES |
---|
182 | fi |
---|
183 | |
---|
184 | if [ "$NEEDINPUTTREE" != "$HAVEINPUTTREE" ]; then |
---|
185 | if [ "$NEEDINPUTTREE" == "1" ]; then |
---|
186 | arb_message "Please select an input tree" |
---|
187 | exit 1; |
---|
188 | else |
---|
189 | if [ "$USESINPUTTREE" == "0" ]; then |
---|
190 | arb_message "Given input tree ignored" |
---|
191 | # don't use tree: |
---|
192 | TREEPARAMS= |
---|
193 | fi |
---|
194 | fi |
---|
195 | fi |
---|
196 | |
---|
197 | if [ "$NEEDGAMMA" == "1" ]; then |
---|
198 | if [ "$DATA" == "DNA" ]; then |
---|
199 | case "$RATEMODELNUC" in |
---|
200 | "GTRGAMMA" | "GTRGAMMAI" ) |
---|
201 | ;; |
---|
202 | * ) |
---|
203 | arb_message "Please choose GAMMA substitution model" |
---|
204 | exit 1 |
---|
205 | ;; |
---|
206 | esac |
---|
207 | else |
---|
208 | case "$RATEMODELPROT" in |
---|
209 | "PROTGAMMA" | "PROTGAMMAI" ) |
---|
210 | ;; |
---|
211 | * ) |
---|
212 | arb_message "Please choose GAMMA rate model" |
---|
213 | exit 1 |
---|
214 | ;; |
---|
215 | esac |
---|
216 | fi |
---|
217 | fi |
---|
218 | |
---|
219 | MODELPARAMS= |
---|
220 | if [ "$DATA" == "DNA" ]; then |
---|
221 | MODELPARAMS="-m $RATEMODELNUC" |
---|
222 | else |
---|
223 | MODELPARAMS="-m $RATEMODELPROT$MATRIXNAME" |
---|
224 | fi |
---|
225 | |
---|
226 | # build parameters for raxml |
---|
227 | RAXMLPARAMS="$MODELPARAMS -f $SEARCH" |
---|
228 | if [ ! -z "$INITIALREARRANGEMENT" ]; then |
---|
229 | RAXMLPARAMS="$RAXMLPARAMS -i $INITIALREARRANGEMENT" |
---|
230 | # otherwise autodetect by RAxML |
---|
231 | fi |
---|
232 | if [ "$NUMBEROFRUNS" != "1" ]; then |
---|
233 | RAXMLPARAMS="$RAXMLPARAMS -N $NUMBEROFRUNS" |
---|
234 | fi |
---|
235 | |
---|
236 | RUNNAME=viaARB |
---|
237 | RAXMLPARAMS="$RAXMLPARAMS -p $SEED -s $SEQFILE -a $WEIGHTS $TREEPARAMS $DEPENDENT_PARAMS -n $RUNNAME" |
---|
238 | |
---|
239 | echo "------------------------------------------" |
---|
240 | echo "Calling raxmlHPC $RAXMLPARAMS" |
---|
241 | time raxmlHPC $RAXMLPARAMS |
---|
242 | echo "------------------------------------------" |
---|
243 | |
---|
244 | # ../PERL_SCRIPTS/ARBTOOLS/raxml2arb.pl |
---|
245 | raxml2arb.pl "$RUNNAME" "$GENERATEDTREES" "$MODE" "$TAKETREES" "$CONSENSE" "$COMMENT" |
---|
246 | fi |
---|