annotate raxml.py @ 0:d95d87f40f47 draft default tip

Uploaded the first beta.
author malex
date Tue, 02 Oct 2012 17:35:46 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
1 #!/usr/bin/env python
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
2 """
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
3 Runs RAxML on a sequence file.
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
4 For use with RAxML version 7.3.0
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
5
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
6 usage:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
7 <!-- raxmlHPC-PTHREADS-SSE3 -T 2 -f c -m GTRGAMMA -F -s "/Users/om/Downloads/rana.phy" -n rana_red -w "/Users/om/Downloads/" 0
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
8 ## raxmlHPC-PTHREADS-SSE3 -T 2 -m GTRGAMMA -n test -p 323483 -s reduced.phy
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
9 command>raxmlHPC-HYBRID-SSE3 -T 4 -f ${search_algorithm} -m ${smodel} -N ${repeats} -o "${html_outfile.files_path}" -s "$input1"
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
10 """
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
11 import os, shutil, subprocess, sys, optparse, fnmatch, glob
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
12
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
13 def stop_err(msg):
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
14 sys.stderr.write("%s\n" % msg)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
15 sys.exit()
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
16
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
17 def getint(name):
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
18 basename = name.partition('RUN.')
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
19 if basename[2] != '':
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
20 num = basename[2]
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
21 return int(num)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
22
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
23 def __main__():
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
24 usage = "usage: %prog -T <threads> -s <input> -n <output> -m <model> [optional arguments]"
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
25
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
26 # Parse the primary wrapper's command line options
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
27 parser = optparse.OptionParser(usage = usage)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
28 # raxml binary name, hardcoded in the xml file
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
29 parser.add_option("--binary", action="store", type="string", dest="binary", help="Command to run")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
30 # (-a)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
31 parser.add_option("--weightfile", action="store", type="string", dest="weightfile", help="Column weight file")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
32 # (-A)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
33 parser.add_option("--secondary_structure_model", action="store", type="string", dest="secondary_structure_model", help="Secondary structure model")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
34 # (-b)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
35 parser.add_option("--bootseed", action="store", type="int", dest="bootseed", help="Bootstrap random number seed")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
36 # (-c)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
37 parser.add_option("--numofcats", action="store", type="int", dest="numofcats", help="Number of distinct rate categories")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
38 # (-d)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
39 parser.add_option("--search_complete_random_tree", action="store_true", dest="search_complete_random_tree", help="Search with a complete random starting tree")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
40 # (-D)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
41 parser.add_option("--ml_search_convergence", action="store_true", dest="ml_search_convergence", help="ML search onvergence criterion")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
42 # (-e)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
43 parser.add_option("--model_opt_precision", action="store", type="float", dest="model_opt_precision", help="Model Optimization Precision (-e)")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
44 # (-E)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
45 parser.add_option("--excludefile", action="store", type="string", dest="excludefile", help="Exclude File Name")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
46 # (-f)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
47 parser.add_option("--search_algorithm", action="store", type="string", dest="search_algorithm", help="Search Algorithm")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
48 # (-F)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
49 parser.add_option("--save_memory_cat_model", action="store_true", dest="save_memory_cat_model", help="Save memory under CAT and GTRGAMMA models")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
50 # (-g)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
51 parser.add_option("--groupingfile", action="store", type="string", dest="groupingfile", help="Grouping File Name")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
52 # (-G)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
53 parser.add_option("--enable_evol_heuristics", action="store_true", dest="enable_evol_heuristics", help="Enable evol algo heuristics")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
54 # (-i)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
55 parser.add_option("--initial_rearrangement_setting", action="store", type="int", dest="initial_rearrangement_setting", help="Initial Rearrangement Setting")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
56 # (-I)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
57 parser.add_option("--posterior_bootstopping_analysis", action="store", type="string", dest="posterior_bootstopping_analysis", help="Posterior bootstopping analysis")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
58 # (-J)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
59 parser.add_option("--majority_rule_consensus", action="store", type="string", dest="majority_rule_consensus", help="Majority rule consensus")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
60 # (-k)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
61 parser.add_option("--print_branch_lengths", action="store_true", dest="print_branch_lengths", help="Print branch lengths")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
62 # (-K)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
63 parser.add_option("--multistate_sub_model", action="store", type="string", dest="multistate_sub_model", help="Multistate substitution model")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
64 # (-m)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
65 parser.add_option("--model_type", action="store", type="string", dest="model_type", help="Model Type")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
66 parser.add_option("--base_model", action="store", type="string", dest="base_model", help="Base Model")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
67 parser.add_option("--aa_empirical_freq", action="store_true", dest="aa_empirical_freq", help="Use AA Empirical base frequences")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
68 parser.add_option("--aa_search_matrix", action="store", type="string", dest="aa_search_matrix", help="AA Search Matrix")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
69 # (-n)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
70 parser.add_option("--name", action="store", type="string", dest="name", help="Run Name")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
71 # (-N/#)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
72 parser.add_option("--number_of_runs", action="store", type="int", dest="number_of_runs", help="Number of alternative runs")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
73 parser.add_option("--number_of_runs_bootstop", action="store", type="string", dest="number_of_runs_bootstop", help="Number of alternative runs based on the bootstop criteria")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
74 # (-M)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
75 parser.add_option("--estimate_individual_branch_lengths", action="store_true", dest="estimate_individual_branch_lengths", help="Estimate individual branch lengths")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
76 # (-o)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
77 parser.add_option("--outgroup_name", action="store", type="string", dest="outgroup_name", help="Outgroup Name")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
78 # (-O)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
79 parser.add_option("--disable_undetermined_seq_check", action="store_true", dest="disable_undetermined_seq_check", help="Disable undetermined sequence check")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
80 # (-p)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
81 parser.add_option("--random_seed", action="store", type="int", dest="random_seed", help="Random Number Seed")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
82 # (-P)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
83 parser.add_option("--external_protein_model", action="store", type="string", dest="external_protein_model", help="External Protein Model")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
84 # (-q)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
85 parser.add_option("--multiple_model", action="store", type="string", dest="multiple_model", help="Multiple Model File")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
86 # (-r)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
87 parser.add_option("--constraint_file", action="store", type="string", dest="constraint_file", help="Constraint File")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
88 # (-R)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
89 parser.add_option("--bin_model_parameter_file", action="store", type="string", dest="bin_model_parameter_file", help="Constraint File")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
90 # (-s)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
91 parser.add_option("--source", action="store", type="string", dest="source", help="Input file")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
92 # (-S)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
93 parser.add_option("--secondary_structure_file", action="store", type="string", dest="secondary_structure_file", help="Secondary structure file")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
94 # (-t)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
95 parser.add_option("--starting_tree", action="store", type="string", dest="starting_tree", help="Starting Tree")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
96 # (-T)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
97 parser.add_option("--threads", action="store", type="int", dest="threads", help="Number of threads to use")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
98 # (-u)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
99 parser.add_option("--use_median_approximation", action="store_true", dest="use_median_approximation", help="Use median approximation")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
100 # (-U)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
101 parser.add_option("--save_memory_gappy_alignments", action="store_true", dest="save_memory_gappy_alignments", help="Save memory in large gapped alignments")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
102 # (-V)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
103 parser.add_option("--disable_rate_heterogeneity", action="store_true", dest="disable_rate_heterogeneity", help="Disable rate heterogeneity")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
104 # (-W)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
105 parser.add_option("--sliding_window_size", action="store", type="string", dest="sliding_window_size", help="Sliding window size")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
106 # (-x)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
107 parser.add_option("--rapid_bootstrap_random_seed", action="store", type="int", dest="rapid_bootstrap_random_seed", help="Rapid Boostrap Random Seed")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
108 # (-y)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
109 parser.add_option("--parsimony_starting_tree_only", action="store_true", dest="parsimony_starting_tree_only", help="Generate a parsimony starting tree only")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
110 # (-z)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
111 parser.add_option("--file_multiple_trees", action="store", type="string", dest="file_multiple_trees", help="Multiple Trees File")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
112
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
113 (options, args) = parser.parse_args()
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
114 cmd = []
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
115
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
116 # Required parameters
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
117 binary = options.binary
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
118 cmd.append(binary)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
119 # Threads
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
120 threads = "-T %d" % options.threads
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
121 cmd.append(threads)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
122 # Source
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
123 source = "-s %s" % options.source
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
124 cmd.append(source)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
125 #Hardcode to "galaxy" first to simplify the output part of the wrapper
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
126 #name = "-n %s" % options.name
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
127 name = "-n galaxy"
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
128 cmd.append(name)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
129 ## Model
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
130 model_type = options.model_type
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
131 base_model = options.base_model
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
132 aa_search_matrix = options.aa_search_matrix
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
133 aa_empirical_freq = options.aa_empirical_freq
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
134 if model_type == 'aminoacid':
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
135 model = "-m %s%s" % (base_model, aa_search_matrix)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
136 if aa_empirical_freq:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
137 model = "-m %s%s%s" % (base_model, aa_search_matrix, 'F')
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
138 # (-P)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
139 if options.external_protein_model:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
140 external_protein_model = "-P %s" % options.external_protein_model
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
141 cmd.append(external_protein_model)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
142 else:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
143 model = "-m %s" % base_model
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
144 cmd.append(model)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
145 if model == "GTRCAT":
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
146 # (-c)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
147 if options.numofcats:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
148 numofcats = "-c %d" % options.numofcats
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
149 cmd.append(numofcats)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
150 # Optional parameters
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
151 if options.number_of_runs_bootstop:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
152 number_of_runs_bootstop = "-N %s" % options.number_of_runs_bootstop
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
153 cmd.append(number_of_runs_bootstop)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
154 else:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
155 number_of_runs_bootstop = ''
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
156 if options.number_of_runs:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
157 number_of_runs_opt = "-N %d" % options.number_of_runs
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
158 cmd.append(number_of_runs_opt)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
159 else:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
160 number_of_runs_opt = 0
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
161 # (-a)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
162 if options.weightfile:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
163 weightfile = "-a %s" % options.weightfile
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
164 cmd.append(weightfile)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
165 # (-A)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
166 if options.secondary_structure_model:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
167 secondary_structure_model = "-A %s" % options.secondary_structure_model
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
168 cmd.append(secondary_structure_model )
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
169 # (-b)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
170 if options.bootseed:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
171 bootseed = "-b %d" % options.bootseed
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
172 cmd.append(bootseed)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
173 else:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
174 bootseed = 0
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
175 # -C - doesn't work in pthreads version, skipped
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
176 if options.search_complete_random_tree:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
177 cmd.append("-d")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
178 if options.ml_search_convergence:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
179 cmd.append("-D" )
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
180 if options.model_opt_precision:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
181 model_opt_precision = "-e %f" % options.model_opt_precision
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
182 cmd.append(model_opt_precision)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
183 if options.excludefile:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
184 excludefile = "-E %s" % options.excludefile
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
185 cmd.append(excludefile)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
186 if options.search_algorithm:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
187 search_algorithm = "-f %s" % options.search_algorithm
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
188 cmd.append(search_algorithm)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
189 if options.save_memory_cat_model:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
190 cmd.append("-F")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
191 if options.groupingfile:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
192 groupingfile = "-g %s" % options.groupingfile
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
193 cmd.append(groupingfile)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
194 if options.enable_evol_heuristics:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
195 enable_evol_heuristics = "-G %f" % options.enable_evol_heuristics
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
196 cmd.append(enable_evol_heuristics )
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
197 if options.initial_rearrangement_setting:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
198 initial_rearrangement_setting = "-i %s" % options.initial_rearrangement_setting
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
199 cmd.append(initial_rearrangement_setting)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
200 if options.posterior_bootstopping_analysis:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
201 posterior_bootstopping_analysis = "-I %s" % options.posterior_bootstopping_analysis
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
202 cmd.append(posterior_bootstopping_analysis)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
203 if options.majority_rule_consensus:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
204 majority_rule_consensus = "-J %s" % options.majority_rule_consensus
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
205 cmd.append(majority_rule_consensus)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
206 if options.print_branch_lengths:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
207 cmd.append("-k")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
208 if options.multistate_sub_model:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
209 multistate_sub_model = "-K %s" % options.multistate_sub_model
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
210 cmd.append(multistate_sub_model)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
211 if options.estimate_individual_branch_lengths:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
212 cmd.append("-M")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
213 if options.outgroup_name:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
214 outgroup_name = "-o %s" % options.outgroup_name
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
215 cmd.append(outgroup_name)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
216 if options.disable_undetermined_seq_check:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
217 cmd.append("-O")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
218 if options.random_seed:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
219 random_seed = "-p %d" % options.random_seed
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
220 cmd.append(random_seed)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
221 multiple_model = None
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
222 if options.multiple_model:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
223 multiple_model = "-q %s" % options.multiple_model
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
224 cmd.append(multiple_model)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
225 if options.constraint_file:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
226 constraint_file = "-r %s" % options.constraint_file
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
227 cmd.append(constraint_file)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
228 if options.bin_model_parameter_file:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
229 bin_model_parameter_file_name = "RAxML_binaryModelParameters.galaxy"
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
230 os.symlink(options.bin_model_parameter_file, bin_model_parameter_file_name )
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
231 bin_model_parameter_file = "-R %s" % options.bin_model_parameter_file
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
232 #Needs testing. Is the hardcoded name or the real path needed?
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
233 cmd.append(bin_model_parameter_file)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
234 if options.secondary_structure_file:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
235 secondary_structure_file = "-S %s" % options.secondary_structure_file
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
236 cmd.append(secondary_structure_file)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
237 if options.starting_tree:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
238 starting_tree = "-t %s" % options.starting_tree
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
239 cmd.append(starting_tree)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
240 if options.use_median_approximation:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
241 cmd.append("-u")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
242 if options.save_memory_gappy_alignments:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
243 cmd.append("-U")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
244 if options.disable_rate_heterogeneity:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
245 cmd.append("-V")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
246 if options.sliding_window_size:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
247 sliding_window_size = "-W %d" % options.sliding_window_size
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
248 cmd.append(sliding_window_size)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
249 if options.rapid_bootstrap_random_seed:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
250 rapid_bootstrap_random_seed = "-x %d" % options.rapid_bootstrap_random_seed
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
251 cmd.append(rapid_bootstrap_random_seed)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
252 else:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
253 rapid_bootstrap_random_seed = 0
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
254 if options.parsimony_starting_tree_only:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
255 cmd.append("-y")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
256 if options.file_multiple_trees:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
257 file_multiple_trees = "-z %s" % options.file_multiple_trees
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
258 cmd.append(file_multiple_trees)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
259
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
260 print "cmd list: ", cmd, "\n"
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
261
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
262 full_cmd = " ".join(cmd)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
263 print "Command string: %s" % full_cmd
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
264
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
265 try:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
266 proc = subprocess.Popen(args=full_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
267 except Exception, err:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
268 sys.stderr.write("Error invoking command: \n%s\n\n%s\n" % (cmd, err))
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
269 sys.exit(1)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
270 stdout, stderr = proc.communicate()
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
271 return_code = proc.returncode
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
272 if return_code:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
273 sys.stdout.write(stdout)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
274 sys.stderr.write(stderr)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
275 sys.stderr.write("Return error code %i from command:\n" % return_code)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
276 sys.stderr.write("%s\n" % cmd)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
277 else:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
278 sys.stdout.write(stdout)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
279 sys.stdout.write(stderr)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
280
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
281 #Multiple runs - concatenate
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
282 if number_of_runs_opt > 0:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
283 if (bootseed == 0) and (rapid_bootstrap_random_seed == 0 ):
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
284 runfiles = glob.glob('RAxML*RUN*')
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
285 runfiles.sort(key=getint)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
286 # Logs
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
287 outfile = open('RAxML_log.galaxy','w')
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
288 for filename in runfiles:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
289 if fnmatch.fnmatch(filename, 'RAxML_log.galaxy.RUN.*'):
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
290 infile = open(filename, 'r')
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
291 filename_line = "%s\n" % filename
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
292 outfile.write(filename_line)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
293 for line in infile:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
294 outfile.write(line)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
295 infile.close()
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
296 outfile.close()
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
297 # Parsimony Trees
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
298 outfile = open('RAxML_parsimonyTree.galaxy','w')
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
299 for filename in runfiles:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
300 if fnmatch.fnmatch(filename, 'RAxML_parsimonyTree.galaxy.RUN.*'):
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
301 infile = open(filename, 'r')
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
302 filename_line = "%s\n" % filename
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
303 outfile.write(filename_line)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
304 for line in infile:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
305 outfile.write(line)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
306 infile.close()
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
307 outfile.close()
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
308 # Results
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
309 outfile = open('RAxML_result.galaxy','w')
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
310 for filename in runfiles:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
311 if fnmatch.fnmatch(filename, 'RAxML_result.galaxy.RUN.*'):
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
312 infile = open(filename, 'r')
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
313 filename_line = "%s\n" % filename
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
314 outfile.write(filename_line)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
315 for line in infile:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
316 outfile.write(line)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
317 infile.close()
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
318 outfile.close()
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
319 # Multiple Model Partition Files
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
320 if multiple_model:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
321 files = glob.glob('RAxML_bestTree.galaxy.PARTITION.*')
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
322 if len(files) > 0:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
323 files.sort(key=getint)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
324 outfile = open('RAxML_bestTreePartitions.galaxy','w')
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
325 # Best Tree Partitions
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
326 for filename in files:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
327 if fnmatch.fnmatch(filename, 'RAxML_bestTree.galaxy.PARTITION.*'):
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
328 infile = open(filename, 'r')
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
329 filename_line = "%s\n" % filename
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
330 outfile.write(filename_line)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
331 for line in infile:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
332 outfile.write(line)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
333 infile.close()
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
334 outfile.close()
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
335 else:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
336 outfile = open('RAxML_bestTreePartitions.galaxy','w')
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
337 outfile.write("No partition files were produced.\n")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
338 outfile.close()
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
339
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
340 # Result Partitions
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
341 files = glob.glob('RAxML_result.galaxy.PARTITION.*')
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
342 if len(files) > 0:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
343 files.sort(key=getint)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
344 outfile = open('RAxML_resultPartitions.galaxy','w')
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
345 for filename in files:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
346 if fnmatch.fnmatch(filename, 'RAxML_result.galaxy.PARTITION.*'):
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
347 infile = open(filename, 'r')
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
348 filename_line = "%s\n" % filename
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
349 outfile.write(filename_line)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
350 for line in infile:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
351 outfile.write(line)
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
352 infile.close()
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
353 outfile.close()
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
354 else:
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
355 outfile = open('RAxML_resultPartitions.galaxy','w')
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
356 outfile.write("No partition files were produced.\n")
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
357 outfile.close()
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
358
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
359 # DEBUG options
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
360 infof = open('RAxML_info.galaxy','a')
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
361 infof.write('\nOM: CLI options DEBUG START:\n')
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
362 infof.write(options.__repr__())
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
363 infof.write('\nOM: CLI options DEBUG END\n')
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
364
d95d87f40f47 Uploaded the first beta.
malex
parents:
diff changeset
365 if __name__=="__main__": __main__()