1
2
3
4
5 """Command-line wrapper for the tree inference program RAxML.
6
7 Derived from the help page for RAxML version 7.3 by Alexandros Stamatakis, but
8 should work for any version 7.X (and probably earlier for most options).
9 """
10 from __future__ import print_function
11 from Bio._py3k import basestring
12
13 from Bio.Application import _Option, _Switch, AbstractCommandline
14
15
17 """Command-line wrapper for the tree inference program RAxML.
18
19 The required parameters are 'sequences' (-s), 'model' (-m) and 'name' (-n).
20 The parameter 'parsimony_seed' (-p) must also be set for RAxML, but if you
21 do not specify it, this wrapper will set the seed to 10000 for you.
22
23 Example:
24
25 >>> from Bio.Phylo.Applications import RaxmlCommandline
26 >>> raxml_cline = RaxmlCommandline(sequences="Tests/Phylip/interlaced2.phy",
27 ... model="PROTCATWAG", name="interlaced2")
28 >>> print(raxml_cline)
29 raxmlHPC -m PROTCATWAG -n interlaced2 -p 10000 -s Tests/Phylip/interlaced2.phy
30
31 You would typically run the command line with raxml_cline() or via
32 the Python subprocess module, as described in the Biopython tutorial.
33
34 Citation:
35
36 Stamatakis A.
37 RAxML-VI-HPC: Maximum Likelihood-based Phylogenetic Analyses with
38 Thousands of Taxa and Mixed Models.
39 Bioinformatics 2006, 22(21):2688-2690.
40
41 Homepage: http://sco.h-its.org/exelixis/software.html
42 """
43
44 - def __init__(self, cmd='raxmlHPC', **kwargs):
45 self.parameters = [
46 _Option(['-a', 'weight_filename'],
47 "Name of a column weight file to assign individual weights "
48 "to each column of the alignment. Those weights must be "
49 "integers separated by any type and number of whitespaces "
50 "within a separate file.",
51 filename=True,
52 equate=False,
53 ),
54
55 _Option(['-b', 'bootstrap_seed'],
56 "Random seed for bootstrapping.",
57 equate=False,
58 ),
59
60 _Option(['-c', 'num_categories'],
61 "Number of distinct rate categories for RAxML when "
62 "evolution model is set to GTRCAT or GTRMIX."
63 "Individual per-site rates are categorized into this "
64 "many rate categories to accelerate computations. "
65 "Default: 25.",
66 equate=False,
67 ),
68
69 _Switch(['-d', 'random_starting_tree'],
70 "Start ML optimization from random starting tree."
71 ),
72
73 _Option(['-e', 'epsilon'],
74 "Set model optimization precision in log likelihood units "
75 "for final optimization of tree topology under MIX/MIXI "
76 "or GAMMA/GAMMAI."
77 "Default: 0.1 for models not using proportion of "
78 "invariant sites estimate; 0.001 for models using "
79 "proportion of invariant sites estimate.",
80 equate=False,
81 ),
82
83 _Option(['-E', 'exclude_filename'],
84 "An exclude file name, containing a specification of "
85 "alignment positions you wish to exclude. Format is "
86 "similar to Nexus, the file shall contain entries like "
87 "'100-200 300-400'; to exclude a single column write, "
88 "e.g., '100-100'. If you use a mixed model, an "
89 "appropriately adapted model file will be written.",
90 filename=True,
91 equate=False,
92 ),
93
94 _Option(['-f', 'algorithm'],
95 """Select algorithm:
96 a: Rapid Bootstrap analysis and search for best-scoring ML
97 tree in one program run.
98 b: Draw bipartition information on a tree provided with '-t'
99 based on multiple trees (e.g. form a bootstrap) in a file
100 specifed by '-z'.
101 c: Check if the alignment can be properly read by RAxML.
102 d: New rapid hill-climbing (DEFAULT).
103 e: Optimize model+branch lengths for given input tree under
104 GAMMA/GAMMAI only.
105 g: Compute per site log Likelihoods for one ore more trees
106 passed via '-z' and write them to a file that can be read
107 by CONSEL.
108 h: Compute log likelihood test (SH-test) between best tree
109 passed via '-t' and a bunch of other trees passed via '-z'.
110 i: Perform a really thorough bootstrap, refinement of final
111 bootstrap tree under GAMMA and a more exhaustive algorithm.
112 j: Generate a bunch of bootstrapped alignment files from an
113 original alignemnt file.
114 m: Compare bipartitions between two bunches of trees passed
115 via '-t' and '-z' respectively. This will return the
116 Pearson correlation between all bipartitions found in the
117 two tree files. A file called
118 RAxML_bipartitionFrequencies.outputFileName will be
119 printed that contains the pair-wise bipartition
120 frequencies of the two sets.
121 n: Compute the log likelihood score of all trees contained
122 in a tree file provided by '-z' under GAMMA or
123 GAMMA+P-Invar.
124 o: Old and slower rapid hill-climbing.
125 p: Perform pure stepwise MP addition of new sequences to an
126 incomplete starting tree.
127 s: Split up a multi-gene partitioned alignment into the
128 respective subalignments.
129 t: Do randomized tree searches on one fixed starting tree.
130 w: Compute ELW test on a bunch of trees passed via '-z'.
131 x: Compute pair-wise ML distances, ML model parameters will
132 be estimated on an MP starting tree or a user-defined
133 tree passed via '-t', only allowed for GAMMA-based models
134 of rate heterogeneity.""",
135 checker_function=(lambda x:
136 isinstance(x, basestring) and len(x) == 1),
137 equate=False,
138 ),
139
140 _Option(['-g', 'grouping_constraint'],
141 "File name of a multifurcating constraint tree. "
142 "this tree does not need to be comprehensive, i.e. "
143 "contain all taxa.",
144 filename=True,
145 equate=False,
146 ),
147
148 _Option(['-i', 'rearrangements'],
149 "Initial rearrangement setting for the subsequent "
150 "application of topological changes phase.",
151 equate=False,
152 ),
153
154 _Switch(['-j', 'checkpoints'],
155 "Write checkpoints (intermediate tree topologies)."
156 ),
157
158 _Switch(['-k', 'bootstrap_branch_lengths'],
159 "Print bootstrapped trees with branch lengths. "
160 "The bootstraps will run a bit longer, because model "
161 "parameters will be optimized at the end of each run. "
162 "Use with CATMIX/PROTMIX or GAMMA/GAMMAI."
163 ),
164
165 _Option(['-l', 'cluster_threshold'],
166 "Threshold for sequence similarity clustering. "
167 "RAxML will then print out an alignment to a file "
168 "called sequenceFileName.reducedBy.threshold that "
169 "only contains sequences <= the specified threshold "
170 "that must be between 0.0 and 1.0. RAxML uses the "
171 "QT-clustering algorithm to perform this task. "
172 "In addition, a file called "
173 "RAxML_reducedList.outputFileName will be written "
174 "that contains clustering information.",
175 equate=False,
176 ),
177
178 _Option(['-L', 'cluster_threshold_fast'],
179 "Same functionality as '-l', but uses a less "
180 "exhaustive and thus faster clustering algorithm. "
181 "This is intended for very large datasets with more "
182 "than 20,000-30,000 sequences.",
183 equate=False,
184 ),
185
186 _Option(['-m', 'model'],
187 """Model of Nucleotide or Amino Acid Substitution:
188
189 NUCLEOTIDES:
190
191 GTRCAT : GTR + Optimization of substitution rates + Optimization of site-specific
192 evolutionary rates which are categorized into numberOfCategories distinct
193 rate categories for greater computational efficiency
194 if you do a multiple analysis with '-#' or '-N' but without bootstrapping the program
195 will use GTRMIX instead
196 GTRGAMMA : GTR + Optimization of substitution rates + GAMMA model of rate
197 heterogeneity (alpha parameter will be estimated)
198 GTRMIX : Inference of the tree under GTRCAT
199 and thereafter evaluation of the final tree topology under GTRGAMMA
200 GTRCAT_GAMMA : Inference of the tree with site-specific evolutionary rates.
201 However, here rates are categorized using the 4 discrete GAMMA rates.
202 Evaluation of the final tree topology under GTRGAMMA
203 GTRGAMMAI : Same as GTRGAMMA, but with estimate of proportion of invariable sites
204 GTRMIXI : Same as GTRMIX, but with estimate of proportion of invariable sites
205 GTRCAT_GAMMAI : Same as GTRCAT_GAMMA, but with estimate of proportion of invariable sites
206
207 AMINO ACIDS:
208
209 PROTCATmatrixName[F] : specified AA matrix + Optimization of substitution rates + Optimization of site-specific
210 evolutionary rates which are categorized into numberOfCategories distinct
211 rate categories for greater computational efficiency
212 if you do a multiple analysis with '-#' or '-N' but without bootstrapping the program
213 will use PROTMIX... instead
214 PROTGAMMAmatrixName[F] : specified AA matrix + Optimization of substitution rates + GAMMA model of rate
215 heterogeneity (alpha parameter will be estimated)
216 PROTMIXmatrixName[F] : Inference of the tree under specified AA matrix + CAT
217 and thereafter evaluation of the final tree topology under specified AA matrix + GAMMA
218 PROTCAT_GAMMAmatrixName[F] : Inference of the tree under specified AA matrix and site-specific evolutionary rates.
219 However, here rates are categorized using the 4 discrete GAMMA rates.
220 Evaluation of the final tree topology under specified AA matrix + GAMMA
221 PROTGAMMAImatrixName[F] : Same as PROTGAMMAmatrixName[F], but with estimate of proportion of invariable sites
222 PROTMIXImatrixName[F] : Same as PROTMIXmatrixName[F], but with estimate of proportion of invariable sites
223 PROTCAT_GAMMAImatrixName[F] : Same as PROTCAT_GAMMAmatrixName[F], but with estimate of proportion of invariable sites
224
225 Available AA substitution models: DAYHOFF, DCMUT, JTT, MTREV, WAG, RTREV, CPREV, VT, BLOSUM62, MTMAM, GTR
226 With the optional 'F' appendix you can specify if you want to use empirical base frequencies
227 Please not that for mixed models you can in addition specify the per-gene AA model in
228 the mixed model file (see manual for details)
229 """,
230 equate=False,
231 ),
232
233 _Switch(['-M', 'partition_branch_lengths'],
234 "Switch on estimation of individual per-partition "
235 "branch lengths. Only has effect when used in "
236 "combination with 'partition_filename' ('-q'). "
237 "Branch lengths for individual partitions will be "
238 "printed to separate files. A weighted average of the "
239 "branch lengths is computed by using the respective "
240 "partition lengths. "
241 ),
242
243 _Option(['-n', 'name'],
244 "Name used in the output files.",
245 filename=True,
246 equate=False,
247 ),
248
249 _Option(['-o', 'outgroup'],
250 "Name of a single outgroup or a comma-separated list "
251 "of outgroups, eg '-o Rat' or '-o Rat,Mouse'. In case "
252 "that multiple outgroups are not monophyletic the "
253 "first name in the list will be selected as outgroup. "
254 "Don't leave spaces between taxon names!",
255 checker_function=lambda x: len(x.split()) == 1,
256 equate=False,
257 ),
258
259 _Option(['-q', 'partition_filename'],
260 "File name containing the assignment of models to "
261 "alignment partitions for multiple models of "
262 "substitution. For the syntax of this file please "
263 "consult the RAxML manual.",
264 filename=True,
265 equate=False,
266 ),
267
268 _Option(['-p', 'parsimony_seed'],
269 "Random number seed for the parsimony inferences. "
270 "This allows you to reproduce your results and will "
271 "help developers debug the program. This option HAS "
272 "NO EFFECT in the parallel MPI version.",
273 equate=False,
274 ),
275
276 _Option(['-P', 'protein_model'],
277 "File name of a user-defined AA (Protein) substitution "
278 "model. This file must contain 420 entries, the first "
279 "400 being the AA substitution rates (this must be a "
280 "symmetric matrix) and the last 20 are the empirical "
281 "base frequencies.",
282 filename=True,
283 equate=False,
284 ),
285
286 _Option(['-r', 'binary_constraint'],
287 "File name of a binary constraint tree. "
288 "This tree does not need to be comprehensive, i.e. "
289 "contain all taxa.",
290 filename=True,
291 equate=False,
292 ),
293
294 _Option(['-s', 'sequences'],
295 "Name of the alignment data file, in PHYLIP format.",
296 filename=True,
297 equate=False,
298 ),
299
300 _Option(['-t', 'starting_tree'],
301 "File name of a user starting tree, in Newick format.",
302 filename=True,
303 equate=False,
304 ),
305
306 _Option(['-T', 'threads'],
307 "Number of threads to run. "
308 "PTHREADS VERSION ONLY! "
309 "Make sure to set this at most the number of CPUs "
310 "you have on your machine, otherwise, there will be "
311 "a huge performance decrease!",
312 equate=False,
313 ),
314
315 _Option(['-u', 'num_bootstrap_searches'],
316 "Number of multiple bootstrap searches per replicate. "
317 "Use this to obtain better ML trees for each "
318 "replicate. Default: 1 ML search per bootstrap "
319 "replicate.",
320 equate=False,
321 ),
322
323 _Switch(['-v', 'version'],
324 "Display version information."
325 ),
326
327 _Option(['-w', 'working_dir'],
328 "Name of the working directory where RAxML will "
329 "write its output files. Default: current directory.",
330 filename=True,
331 equate=False,
332 ),
333
334 _Option(['-x', 'rapid_bootstrap_seed'],
335 "Random seed for rapid bootstrapping.",
336 equate=False,
337 ),
338
339 _Switch(['-y', 'parsimony'],
340 "Only compute a parsimony starting tree, then exit."
341 ),
342
343 _Option(['-z', 'bipartition_filename'],
344 "Name of a file containing multiple trees, e.g. from "
345 "a bootstrap run, that shall be used to draw "
346 "bipartition values onto a tree provided with '-t'. "
347 "It can also be used to compute per-site log "
348 "likelihoods in combination with '-f g', and to read "
349 "a bunch of trees for a couple of other options "
350 "('-f h', '-f m', '-f n').",
351 filename=True,
352 equate=False,
353 ),
354
355 _Option(['-N', '-#', 'num_replicates'],
356 "Number of alternative runs on distinct starting trees. "
357 "In combination with the '-b' option, this will invoke a "
358 "multiple bootstrap analysis. "
359 "DEFAULT: 1 single analysis."
360 "Note that '-N' has been added as an alternative since "
361 "'-#' sometimes caused problems with certain MPI job "
362 "submission systems, since '-#' is often used to start "
363 "comments. ",
364 equate=False,
365 ),
366 ]
367 AbstractCommandline.__init__(self, cmd, **kwargs)
368
369 if not self.parsimony_seed:
370 self.parsimony_seed = 10000
371
372
373 if __name__ == "__main__":
374 from Bio._utils import run_doctest
375 run_doctest()
376