Mercurial > repos > jjohnson > mothur_toolsuite
comparison mothur/tools/mothur/mothur_wrapper.py @ 2:e990ac8a0f58
Migrated tool version 1.19.0 from old tool shed archive to new tool shed repository
author | jjohnson |
---|---|
date | Tue, 07 Jun 2011 17:39:06 -0400 |
parents | fcc0778f6987 |
children | e2e2071d2c62 |
comparison
equal
deleted
inserted
replaced
1:fcc0778f6987 | 2:e990ac8a0f58 |
---|---|
2 | 2 |
3 """ | 3 """ |
4 http://www.mothur.org/ | 4 http://www.mothur.org/ |
5 | 5 |
6 Supports mothur version | 6 Supports mothur version |
7 mothur v.1.15.0 | 7 mothur v.1.17.0 |
8 | 8 |
9 Class encapsulating Mothur galaxy tool. | 9 Class encapsulating Mothur galaxy tool. |
10 Expect each invocation to include: | 10 Expect each invocation to include: |
11 Here is an example call to this script with an explanation before each param : | 11 Here is an example call to this script with an explanation before each param : |
12 mothur_wrapper.py | 12 mothur_wrapper.py |
44 | 44 |
45 assert sys.version_info[:2] >= ( 2, 4 ) | 45 assert sys.version_info[:2] >= ( 2, 4 ) |
46 | 46 |
47 debug = False | 47 debug = False |
48 #debug = True | 48 #debug = True |
49 max_processors = 1 | 49 max_processors = 2 |
50 | 50 |
51 def stop_err( msg ): | 51 def stop_err( msg ): |
52 sys.stderr.write( "%s\n" % msg ) | 52 sys.stderr.write( "%s\n" % msg ) |
53 sys.exit() | 53 sys.exit() |
54 | 54 |
55 def __main__(): | 55 def __main__(): |
56 # tranform the logfile into html | 56 # tranform the logfile into html |
57 # add extra file ouput | |
58 # add object tags for svg files | |
57 def logfile_to_html(logfile_path,htmlfile_path,tmp_input_dir_name,tmp_output_dir_name,title="Mothur Logfile"): | 59 def logfile_to_html(logfile_path,htmlfile_path,tmp_input_dir_name,tmp_output_dir_name,title="Mothur Logfile"): |
58 if debug: print >> sys.stdout, 'logfile_to_html %s -> %s' % (logfile_path, htmlfile_path) | 60 if debug: print >> sys.stdout, 'logfile_to_html %s -> %s' % (logfile_path, htmlfile_path) |
59 if debug: print >> sys.stdout, 'logfile_to_html input_dir: %s' % tmp_input_dir_name | 61 if debug: print >> sys.stdout, 'logfile_to_html input_dir: %s' % tmp_input_dir_name |
60 if debug: print >> sys.stdout, 'logfile_to_html output_dir: %s' % tmp_output_dir_name | 62 if debug: print >> sys.stdout, 'logfile_to_html output_dir: %s' % tmp_output_dir_name |
61 txt = open(logfile_path,'r') | 63 txt = open(logfile_path,'r') |
67 for line in txt: | 69 for line in txt: |
68 if line.find('set.dir') >= 0: | 70 if line.find('set.dir') >= 0: |
69 continue | 71 continue |
70 elif line.find('put directory to ') >= 0: | 72 elif line.find('put directory to ') >= 0: |
71 continue | 73 continue |
74 elif line.startswith('Mothur\'s directories:') : | |
75 continue | |
76 elif line.startswith('outputDir=') : | |
77 continue | |
72 elif line.startswith('Type ') : | 78 elif line.startswith('Type ') : |
73 continue | 79 continue |
74 elif line.find(tmp_output_dir_name) >= 0: | 80 elif line.find(tmp_output_dir_name) >= 0: |
75 line = re.sub(out_pat,'<a href="\\1">\\1</a>',line) | 81 # if debug: print >> sys.stdout, 'logfile_to_html #%s#' % line |
82 if line.strip().endswith('.svg'): | |
83 line = re.sub(out_pat,' <object id="object" type="image/svg+xml" data="\\1">\\1</object> <br><a href="\\1">\\1</a> <hr/>',line) | |
84 else: | |
85 line = re.sub(out_pat,'<a href="\\1">\\1</a>',line) | |
76 elif line.find(tmp_input_dir_name) >= 0: | 86 elif line.find(tmp_input_dir_name) >= 0: |
77 line = re.sub(in_pat,'\\1',line) | 87 line = re.sub(in_pat,'\\1',line) |
78 html.write(line) | 88 html.write(line) |
79 except Exception, e: | 89 except Exception, e: |
80 print(str(e)) | 90 print(str(e)) |
163 This covers many, but not all of the argument dependency requirements. | 173 This covers many, but not all of the argument dependency requirements. |
164 For example - read.dist required a phylip or (column and name) argument. | 174 For example - read.dist required a phylip or (column and name) argument. |
165 The complexity of inputs should be handled by the glaxy tool xml file. | 175 The complexity of inputs should be handled by the glaxy tool xml file. |
166 """ | 176 """ |
167 cmd_dict = dict() | 177 cmd_dict = dict() |
178 cmd_dict['align.check'] = dict({'required' : ['fasta','map']}) | |
179 #cmd_dict['align.seqs'] = dict({'required' : ['candidate','template'], 'optional' : ['search','ksize','align','match','mismatch','gapopen','gapextend','flip','threshold','processors']}) | |
180 cmd_dict['align.seqs'] = dict({'required' : ['fasta','reference',], 'optional' : ['search','ksize','align','match','mismatch','gapopen','gapextend','flip','threshold','processors']}) | |
181 cmd_dict['amova'] = dict({'required' : ['phylip','design'] , 'optional' : ['alpha','iters']}) | |
182 cmd_dict['anosim'] = dict({'required' : ['phylip','design'] , 'optional' : ['alpha','iters']}) | |
183 #cmd_dict['bin.seqs'] = dict({'required' : ['fasta'], 'optional' : ['name','label','group']}) | |
184 cmd_dict['bin.seqs'] = dict({'required' : ['list','fasta'], 'optional' : ['name','label','group']}) | |
185 #cmd_dict['bootstrap.shared'] = dict({'required' : [], 'optional' : ['calc','groups','iters','label']}) | |
186 cmd_dict['bootstrap.shared'] = dict({'required' : ['shared'], 'optional' : ['calc','groups','iters','label']}) | |
187 #catchall | |
188 cmd_dict['chimera.bellerophon'] = dict({'required' : ['fasta'], 'optional' : ['filter','correction','window','increment','processors']}) | |
189 #cmd_dict['chimera.ccode'] = dict({'required' : ['fasta','template'], 'optional' : ['filter','mask','window','numwanted','processors']}) | |
190 cmd_dict['chimera.ccode'] = dict({'required' : ['fasta','reference'], 'optional' : ['filter','mask','window','numwanted','processors']}) | |
191 #cmd_dict['chimera.check'] = dict({'required' : ['fasta','template'], 'optional' : ['ksize','svg','name','increment','processors']}) | |
192 cmd_dict['chimera.check'] = dict({'required' : ['fasta','reference'], 'optional' : ['ksize','svg','name','increment','processors']}) | |
193 #cmd_dict['chimera.pintail'] = dict({'required' : ['fasta','template'], 'optional' : ['conservation','quantile','filter','mask','window','increment','processors']}) | |
194 cmd_dict['chimera.pintail'] = dict({'required' : ['fasta','reference'], 'optional' : ['conservation','quantile','filter','mask','window','increment','processors']}) | |
195 #cmd_dict['chimera.slayer'] = dict({'required' : ['fasta','template'], 'optional' : ['name','search','window','increment','match','mismatch','numwanted','parents','minsim','mincov','iters','minbs','minsnp','divergence','realign','split','processors']}) | |
196 cmd_dict['chimera.slayer'] = dict({'required' : ['fasta','reference'], 'optional' : ['name','search','window','increment','match','mismatch','numwanted','parents','minsim','mincov','iters','minbs','minsnp','divergence','realign','split','processors']}) | |
197 #cmd_dict['chop.seqs'] = dict({'required' : ['fasta','numbases'], 'optional' : ['keep','short']}) | |
198 cmd_dict['chop.seqs'] = dict({'required' : ['fasta','numbases'], 'optional' : ['countgaps','keep','short']}) | |
199 cmd_dict['classify.otu'] = dict({'required' : ['list','taxonomy'],'optional' : ['name','cutoff','label','group','probs','basis','reftaxonomy']}) | |
200 #cmd_dict['classify.seqs'] = dict({'required' : ['fasta','template','taxonomy'],'optional' : ['name','search','ksize','method','match','mismatch','gapopen','gapextend','numwanted','probs','processors']}) | |
201 cmd_dict['classify.seqs'] = dict({'required' : ['fasta','reference','taxonomy'],'optional' : ['name','search','ksize','method','match','mismatch','gapopen','gapextend','numwanted','probs','processors']}) | |
202 cmd_dict['clearcut'] = dict({'required' : [['phylip','fasta']],'optional' : ['seed','norandom','shuffle','neighbor','expblen','expdist','ntrees','matrixout','kimura','jukes','protein','DNA']}) | |
203 #cmd_dict['cluster'] = dict({'required' : [] , 'optional' : ['method','cutoff','hard','precision']}) | |
204 cmd_dict['cluster'] = dict({'required' : [['phylip','column']] , 'optional' : ['name','method','cutoff','hard','precision','sim','showabund','timing']}) | |
205 #cmd_dict['cluster.classic'] = dict({'required' : ['phylip'] , 'optional' : ['method','cutoff','hard','precision']}) | |
206 cmd_dict['cluster.classic'] = dict({'required' : ['phylip'] , 'optional' : ['name','method','cutoff','hard','sim','precision']}) | |
207 cmd_dict['cluster.fragments'] = dict({'required' : ['fasta'] , 'optional' : ['name','diffs','percent']}) | |
208 cmd_dict['cluster.split'] = dict({'required' : [['fasta','phylip','column']] , 'optional' : ['name','method','splitmethod','taxonomy','taxlevel','showabund','cutoff','hard','large','precision','timing','processors']}) | |
209 #cmd_dict['collect.shared'] = dict({'required' : [], 'optional' : ['calc','label','freq','groups','all']}) | |
210 cmd_dict['collect.shared'] = dict({'required' : ['shared'], 'optional' : ['calc','label','freq','groups','all']}) | |
211 #cmd_dict['collect.single'] = dict({'required' : [], 'optional' : ['calc','abund','size','label','freq']}) | |
212 cmd_dict['collect.single'] = dict({'required' : [['list', 'sabund', 'rabund', 'shared']], 'optional' : ['calc','abund','size','label','freq']}) | |
213 cmd_dict['consensus.seqs'] = dict({'required' : ['fasta'], 'optional' : ['list','name','label']}) | |
214 cmd_dict['corr.axes'] = dict({'required' : [['shared','relabund','metadata'],'axes'], 'optional' : ['label','groups','method','numaxes']}) | |
215 cmd_dict['degap.seqs'] = dict({'required' : ['fasta']}) | |
216 cmd_dict['deunique.seqs'] = dict({'required' : ['fasta','name'], 'optional' : []}) | |
217 #cmd_dict['dist.seqs'] = dict({'required' : ['fasta'], 'optional' : ['calc','countends','output','cutoff','processors']}) | |
218 cmd_dict['dist.seqs'] = dict({'required' : ['fasta'], 'optional' : ['calc','countends','output','cutoff','oldfasta','column','processors']}) | |
219 #cmd_dict['dist.shared'] = dict({'required' : [], 'optional' : ['calc','label','groups','output']}) | |
220 cmd_dict['dist.shared'] = dict({'required' : ['shared'], 'optional' : ['calc','label','groups','output']}) | |
221 cmd_dict['fastq.info'] = dict({'required' : ['fastq'], 'optional' : []}) | |
222 cmd_dict['filter.seqs'] = dict({'required' : ['fasta'], 'optional' : ['vertical','trump','soft','hard','processors']}) | |
223 #cmd_dict['get.group'] = dict({'required' : [], 'optional' : []}) | |
224 cmd_dict['get.group'] = dict({'required' : ['shared'], 'optional' : []}) | |
225 cmd_dict['get.groups'] = dict({'required' : ['group'], 'optional' : ['groups','accnos','fasta','name','list','taxonomy']}) | |
226 cmd_dict['get.lineage'] = dict({'required' : ['taxonomy','taxon'],'optional' : ['fasta','name','group','list','alignreport','dups']}) | |
227 ##cmd_dict['get.otulist'] = dict({'required' : [], 'optional' : []}) | |
228 cmd_dict['get.otulist'] = dict({'required' : ['list'], 'optional' : ['label','sort']}) | |
229 #cmd_dict['get.oturep'] = dict({'required' : ['fasta','list'], 'optional' : ['phylip','column','name','label','group','groups','sorted','precision','cutoff','large','weighted']}) | |
230 cmd_dict['get.oturep'] = dict({'required' : ['fasta','list',['phylip','column']], 'optional' : ['name','label','group','groups','sorted','precision','cutoff','large','weighted']}) | |
231 cmd_dict['get.otus'] = dict({'required' : ['group','list','label'], 'optional' : ['groups','accnos']}) | |
232 ##cmd_dict['get.rabund'] = dict({'required' : [],'optional' : []}) | |
233 cmd_dict['get.rabund'] = dict({'required' : [['list','sabund']],'optional' : ['sorted','label']}) | |
234 #cmd_dict['get.relabund'] = dict({'required' : [],'optional' : ['scale','label','groups']}) | |
235 cmd_dict['get.relabund'] = dict({'required' : ['shared'],'optional' : ['scale','label','groups']}) | |
236 ##cmd_dict['get.sabund'] = dict({'required' : [],'optional' : []}) | |
237 cmd_dict['get.sabund'] = dict({'required' : [['list','rabund']],'optional' : ['label']}) | |
238 cmd_dict['get.seqs'] = dict({'required' : ['accnos',['fasta','qfile','name','group','list','alignreport','taxonomy']], 'optional' : ['dups']}) | |
239 ##cmd_dict['get.sharedseqs'] = dict({'required' : [], 'optional' : []}) | |
240 cmd_dict['get.sharedseqs'] = dict({'required' : ['list','group'], 'optional' : ['label', 'unique', 'shared', 'output', 'fasta']}) | |
241 cmd_dict['hcluster'] = dict({'required' : [['column','phylip']] , 'optional' : ['name','method','cutoff','hard','precision','sorted','showabund','timing']}) | |
242 #cmd_dict['heatmap.bin'] = dict({'required' : [], 'optional' : ['label','groups','scale','sorted','numotu','fontsize']}) | |
243 cmd_dict['heatmap.bin'] = dict({'required' : [['list', 'sabund', 'rabund', 'shared']], 'optional' : ['label','groups','scale','sorted','numotu','fontsize']}) | |
244 #cmd_dict['heatmap.sim'] = dict({'required' : [], 'optional' : ['calc','phylip','column','name','label','groups']}) | |
245 cmd_dict['heatmap.sim'] = dict({'required' : [['shared','phylip','column']], 'optional' : ['calc','name','label','groups']}) | |
246 cmd_dict['homova'] = dict({'required' : ['phylip','design'] , 'optional' : ['alpha','iters']}) | |
247 cmd_dict['indicator'] = dict({'required' : ['tree',['shared','relabund']], 'optional' : ['groups','label','design']}) | |
248 #cmd_dict['libshuff'] = dict({'required' : [],'optional' : ['iters','form','step','cutoff']}) | |
249 cmd_dict['libshuff'] = dict({'required' : ['phylip','group'],'optional' : ['groups','iters','form','sim','step','cutoff']}) | |
250 cmd_dict['list.seqs'] = dict({'required' : [['fasta','name','group','list','alignreport','taxonomy']]}) | |
251 cmd_dict['make,fastq'] = dict({'required' : ['fasta','qfile'] , 'optional' : []}) | |
252 #cmd_dict['make.group'] = dict({'required' : ['fasta','groups'], 'optional' : ['output']}) | |
253 cmd_dict['make.group'] = dict({'required' : ['fasta','groups'], 'optional' : []}) | |
254 cmd_dict['make.shared'] = dict({'required' : ['list','group'], 'optional' : ['label','groups','ordergroup']}) | |
255 cmd_dict['mantel'] = dict({'required' : ['phylip','phylip2'] , 'optional' : ['method','iters']}) | |
256 cmd_dict['merge.files'] = dict({'required' : ['input','output']}) | |
257 cmd_dict['merge.groups'] = dict({'required' : ['shared','design'], 'optional' : ['groups', 'label']}) | |
258 #cmd_dict['metastats'] = dict({'required' : ['design'], 'optional' : ['groups', 'label','iters','threshold','sets','processors']}) | |
259 cmd_dict['metastats'] = dict({'required' : ['shared','design'], 'optional' : ['groups', 'label','iters','threshold','sets','processors']}) | |
260 cmd_dict['nmds'] = dict({'required' : ['phylip'], 'optional' : ['axes','mindim','maxdim','iters','maxiters','epsilon']}) | |
261 #cmd_dict['normalize.shared'] = dict({'required' : [], 'optional' : ['label','method','norm','groups']}) | |
262 cmd_dict['normalize.shared'] = dict({'required' : [['shared','relabund']], 'optional' : ['label','method','norm','groups','makerelabund']}) | |
263 ##cmd_dict['otu.hierarchy'] = dict({'required' : [], 'optional' : []}) | |
264 cmd_dict['otu.hierarchy'] = dict({'required' : ['list','label'], 'optional' : ['output']}) | |
265 cmd_dict['pairwise.seqs'] = dict({'required' : ['fasta'], 'optional' : ['align','calc','countends','output','cutoff','match','mismatch','gapopen','gapextend','processors']}) | |
266 cmd_dict['parse.list'] = dict({'required' : ['list','group'], 'optional' : ['label']}) | |
267 #cmd_dict['parsimony'] = dict({'required' : [], 'optional' : ['groups','iters','random','processors']}) | |
268 cmd_dict['parsimony'] = dict({'required' : ['tree'], 'optional' : ['group','groups','name','iters','random','processors']}) | |
269 #cmd_dict['pca'] = dict({'required' : [], 'optional' : ['label','groups','metric']}) | |
270 cmd_dict['pca'] = dict({'required' : [['shared','relabund']], 'optional' : ['label','groups','metric']}) | |
271 #cmd_dict['pcoa'] = dict({'required' : ['phylip'], 'optional' : []}) | |
272 cmd_dict['pcoa'] = dict({'required' : ['phylip'], 'optional' : ['metric']}) | |
273 #cmd_dict['phylo.diversity'] = dict({'required' : [],'optional' : ['groups','iters','freq','scale','rarefy','collect','summary','processors']}) | |
274 cmd_dict['phylo.diversity'] = dict({'required' : ['tree','group'],'optional' : ['name','groups','iters','freq','scale','rarefy','collect','summary','processors']}) | |
275 cmd_dict['phylotype'] = dict({'required' : ['taxonomy'],'optional' : ['name','cutoff','label']}) | |
276 #cmd_dict['pre.cluster'] = dict({'required' : ['fasta'], 'optional' : ['names','diffs']}) | |
277 cmd_dict['pre.cluster'] = dict({'required' : ['fasta'], 'optional' : ['name','diffs']}) | |
278 #cmd_dict['rarefaction.shared'] = dict({'required' : [], 'optional' : ['label','iters','groups','jumble']}) | |
279 cmd_dict['rarefaction.shared'] = dict({'required' : ['shared'], 'optional' : ['calc','label','iters','groups','jumble']}) | |
280 #cmd_dict['rarefaction.single'] = dict({'required' : [], 'optional' : ['calc','abund','iters','label','freq','processors']}) | |
281 cmd_dict['rarefaction.single'] = dict({'required' : [['list', 'sabund', 'rabund', 'shared']], 'optional' : ['calc','abund','iters','label','freq','processors']}) | |
282 #cmd_dict['read.dist'] = dict({'required' : [['phylip','column']], 'optional' : ['name','cutoff','hard','precision','sim','group']}) | |
283 #cmd_dict['read.otu'] = dict({'required' : [['rabund','sabund','list','shared','relabund']], 'optional' : ['label','group','groups','ordergroup']}) | |
284 #cmd_dict['read.tree'] = dict({'required' : ['tree'], 'optional' : ['name','group']}) | |
285 cmd_dict['remove.groups'] = dict({'required' : ['group'], 'optional' : ['groups','accnos','fasta','name','list','taxonomy']}) | |
286 cmd_dict['remove.lineage'] = dict({'required' : ['taxonomy','taxon'],'optional' : ['fasta','name','group','list','alignreport','dups']}) | |
287 cmd_dict['remove.otus'] = dict({'required' : ['group','list','label'], 'optional' : ['groups','accnos']}) | |
288 #cmd_dict['remove.rare'] = dict({'required' : [['list','sabund','rabund','shared'],'nseqs'], 'optional' : ['group','groups','label','bygroup']}) | |
289 cmd_dict['remove.rare'] = dict({'required' : [['list','sabund','rabund','shared'],'nseqs'], 'optional' : ['group','groups','label','bygroup']}) | |
290 cmd_dict['remove.seqs'] = dict({'required' : ['accnos',['fasta','qfile','name','group','list','alignreport','taxonomy']], 'optional' : ['dups']}) | |
291 cmd_dict['reverse.seqs'] = dict({'required' : ['fasta']}) | |
292 cmd_dict['screen.seqs'] = dict({'required' : ['fasta'], 'optional' : ['start','end','maxambig','maxhomop','minlength','maxlength','criteria','optimize','name','group','alignreport','processors']}) | |
293 cmd_dict['sens.spec'] = dict({'required' : ['list',['column','phylip']] , 'optional' : ['label','cutoff','hard','precision']}) | |
294 cmd_dict['sffinfo'] = dict({'required' : [['sff','sfftxt']], 'optional' : ['fasta','qfile','trim','sfftxt','flow','accnos']}) | |
295 cmd_dict['split.abund'] = dict({'required' : ['fasta',['name','list']], 'optional' : ['cutoff','group','groups','label','accnos']}) | |
296 #cmd_dict['split.groups'] = dict({'required' : ['fasta','group'], 'optional' : []}) | |
297 cmd_dict['split.groups'] = dict({'required' : ['fasta','group'], 'optional' : ['name','groups']}) | |
298 cmd_dict['sub.sample'] = dict({'required' : [['fasta','list','sabund','rabund','shared']], 'optional' : ['name','group','groups','label','size','persample']}) | |
299 #cmd_dict['summary.seqs'] = dict({'required' : ['fasta'],'outputs' : ['names']}) | |
300 cmd_dict['summary.seqs'] = dict({'required' : ['fasta'], 'optional' : ['name','processors']}) | |
301 #cmd_dict['summary.shared'] = dict({'required' : [], 'optional' : ['calc','label','groups','all','distance']}) | |
302 cmd_dict['summary.shared'] = dict({'required' : ['shared'], 'optional' : ['calc','label','groups','all','distance','processors']}) | |
303 #cmd_dict['summary.single'] = dict({'required' : [], 'optional' : ['calc','abund','size','label','groupmode']}) | |
304 cmd_dict['summary.single'] = dict({'required' : [['list','sabund','rabund','shared']], 'optional' : ['calc','abund','size','label','groupmode']}) | |
305 #cmd_dict['tree.shared'] = dict({'required' : [], 'optional' : ['groups','calc','cutoff','precision','label']}) | |
306 cmd_dict['tree.shared'] = dict({'required' : [['shared','phylip','column']], 'optional' : ['name','groups','calc','cutoff','precision','label']}) | |
307 cmd_dict['trim.seqs'] = dict({'required' : ['fasta'], 'optional' : ['group','oligos','qfile','qaverage','qthreshold','qtrim','flip','maxambig','maxhomop','minlength','maxlength','bdiffs','pdiffs','tdiffs','allfiles','keepfirst','removelast']}) | |
308 #cmd_dict['unifrac.unweighted'] = dict({'required' : [], 'optional' : ['groups','iters','distance','random','root','processors']}) | |
309 cmd_dict['unifrac.unweighted'] = dict({'required' : ['tree'], 'optional' : ['name','group','groups','iters','distance','random','root','processors']}) | |
310 #cmd_dict['unifrac.weighted'] = dict({'required' : [], 'optional' : ['groups','iters','distance','random','root','processors']}) | |
311 cmd_dict['unifrac.weighted'] = dict({'required' : ['tree'], 'optional' : ['name','group','groups','iters','distance','random','root','processors']}) | |
312 #cmd_dict['unique.seqs'] = dict({'required' : ['fasta'], 'optional' : ['names']}) | |
313 cmd_dict['unique.seqs'] = dict({'required' : ['fasta'], 'optional' : ['name']}) | |
314 #cmd_dict['venn'] = dict({'required' : [], 'optional' : ['calc','label','groups','abund','nseqs','permute']}) | |
315 cmd_dict['venn'] = dict({'required' : [['list','shared']], 'optional' : ['calc','label','groups','abund','nseqs','permute']}) | |
316 ## | |
317 """ | |
168 cmd_dict['merge.files'] = dict({'required' : ['input','output']}) | 318 cmd_dict['merge.files'] = dict({'required' : ['input','output']}) |
169 cmd_dict['make.group'] = dict({'required' : ['fasta','groups'], 'optional' : ['output']}) | 319 cmd_dict['make.group'] = dict({'required' : ['fasta','groups'], 'optional' : ['output']}) |
170 cmd_dict['merge.groups'] = dict({'required' : ['shared','design'], 'optional' : ['groups', 'label']}) | 320 cmd_dict['merge.groups'] = dict({'required' : ['shared','design'], 'optional' : ['groups', 'label']}) |
171 cmd_dict['summary.seqs'] = dict({'required' : ['fasta'], | 321 cmd_dict['summary.seqs'] = dict({'required' : ['fasta'], |
172 'outputs' : ['.names']}) | 322 'outputs' : ['.names']}) |
190 # label=0.01-0.02-0.03 from 0.01,0.02,0.03 string.replace(options.label,',','-') | 340 # label=0.01-0.02-0.03 from 0.01,0.02,0.03 string.replace(options.label,',','-') |
191 cmd_dict['chimera.bellerophon'] = dict({'required' : ['fasta'], 'optional' : ['filter','correction','window','increment','processors']}) | 341 cmd_dict['chimera.bellerophon'] = dict({'required' : ['fasta'], 'optional' : ['filter','correction','window','increment','processors']}) |
192 cmd_dict['chimera.ccode'] = dict({'required' : ['fasta','template'], 'optional' : ['filter','mask','window','numwanted','processors']}) | 342 cmd_dict['chimera.ccode'] = dict({'required' : ['fasta','template'], 'optional' : ['filter','mask','window','numwanted','processors']}) |
193 cmd_dict['chimera.check'] = dict({'required' : ['fasta','template'], 'optional' : ['ksize','svg','name','increment','processors']}) | 343 cmd_dict['chimera.check'] = dict({'required' : ['fasta','template'], 'optional' : ['ksize','svg','name','increment','processors']}) |
194 cmd_dict['chimera.pintail'] = dict({'required' : ['fasta','template'], 'optional' : ['conservation','quantile','filter','mask','window','increment','processors']}) | 344 cmd_dict['chimera.pintail'] = dict({'required' : ['fasta','template'], 'optional' : ['conservation','quantile','filter','mask','window','increment','processors']}) |
195 cmd_dict['chimera.slayer'] = dict({'required' : ['fasta','template'], 'optional' : ['name','search','window','increment','match','mismatch','numwanted','parents','minsim','mincov','iters','minbs','minsnp','divergence','realign','processors']}) | 345 cmd_dict['chimera.slayer'] = dict({'required' : ['fasta','template'], 'optional' : ['name','search','window','increment','match','mismatch','numwanted','parents','minsim','mincov','iters','minbs','minsnp','divergence','realign','split','processors']}) |
196 cmd_dict['dist.seqs'] = dict({'required' : ['fasta'], 'optional' : ['calc','countends','output','cutoff','processors']}) | 346 cmd_dict['dist.seqs'] = dict({'required' : ['fasta'], 'optional' : ['calc','countends','output','cutoff','processors']}) |
197 cmd_dict['pairwise.seqs'] = dict({'required' : ['fasta'], 'optional' : ['align','calc','countends','output','cutoff','match','mismatch','gapopen','gapextend','processors']}) | 347 cmd_dict['pairwise.seqs'] = dict({'required' : ['fasta'], 'optional' : ['align','calc','countends','output','cutoff','match','mismatch','gapopen','gapextend','processors']}) |
198 cmd_dict['read.dist'] = dict({'required' : [['phylip','column']], 'optional' : ['name','cutoff','hard','precision','sim','group']}) | 348 cmd_dict['read.dist'] = dict({'required' : [['phylip','column']], 'optional' : ['name','cutoff','hard','precision','sim','group']}) |
199 cmd_dict['read.otu'] = dict({'required' : [['rabund','sabund','list','shared','relabund']], 'optional' : ['label','group','groups','ordergroup']}) | 349 cmd_dict['read.otu'] = dict({'required' : [['rabund','sabund','list','shared','relabund']], 'optional' : ['label','group','groups','ordergroup']}) |
200 cmd_dict['read.tree'] = dict({'required' : ['tree'], 'optional' : ['name','group']}) | 350 cmd_dict['read.tree'] = dict({'required' : ['tree'], 'optional' : ['name','group']}) |
201 cmd_dict['cluster'] = dict({'required' : [] , 'optional' : ['method','cutoff','hard','precision']}) | 351 cmd_dict['cluster'] = dict({'required' : [] , 'optional' : ['method','cutoff','hard','precision']}) |
202 cmd_dict['hcluster'] = dict({'required' : [['column','phylip']] , 'optional' : ['name','method','cutoff','hard','precision','sorted','showabund']}) | 352 cmd_dict['hcluster'] = dict({'required' : [['column','phylip']] , 'optional' : ['name','method','cutoff','hard','precision','sorted','showabund']}) |
203 cmd_dict['cluster.fragments'] = dict({'required' : ['fasta'] , 'optional' : ['name','diffs','percent']}) | 353 cmd_dict['cluster.fragments'] = dict({'required' : ['fasta'] , 'optional' : ['name','diffs','percent']}) |
204 cmd_dict['cluster.split'] = dict({'required' : [['fasta','phylip','column']] , 'optional' : ['name','method','splitmethod','taxonomy','taxlevel','showabund','cutoff','hard','large','precision','timing','processors']}) | 354 cmd_dict['cluster.split'] = dict({'required' : [['fasta','phylip','column']] , 'optional' : ['name','method','splitmethod','taxonomy','taxlevel','showabund','cutoff','hard','large','precision','timing','processors']}) |
205 cmd_dict['metastats'] = dict({'required' : ['design'], 'optional' : ['groups', 'label','iters','threshold','sets','processors']}) | 355 cmd_dict['metastats'] = dict({'required' : ['design'], 'optional' : ['groups', 'label','iters','threshold','sets','processors']}) |
206 cmd_dict['summary.single'] = dict({'required' : [], 'optional' : ['calc','abund','size','label','groupmode','processors']}) | 356 cmd_dict['summary.single'] = dict({'required' : [], 'optional' : ['calc','abund','size','label','groupmode']}) |
207 cmd_dict['summary.shared'] = dict({'required' : [], 'optional' : ['calc','label','groups','all','distance']}) | 357 cmd_dict['summary.shared'] = dict({'required' : [], 'optional' : ['calc','label','groups','all','distance']}) |
208 cmd_dict['collect.single'] = dict({'required' : [], 'optional' : ['calc','abund','size','label','freq']}) | 358 cmd_dict['collect.single'] = dict({'required' : [], 'optional' : ['calc','abund','size','label','freq']}) |
209 cmd_dict['collect.shared'] = dict({'required' : [], 'optional' : ['calc','label','freq','groups','all']}) | 359 cmd_dict['collect.shared'] = dict({'required' : [], 'optional' : ['calc','label','freq','groups','all']}) |
210 cmd_dict['rarefaction.single'] = dict({'required' : [], 'optional' : ['calc','abund','iters','label','freq','processors']}) | 360 cmd_dict['rarefaction.single'] = dict({'required' : [], 'optional' : ['calc','abund','iters','label','freq','processors']}) |
211 cmd_dict['rarefaction.shared'] = dict({'required' : [], 'optional' : ['label','iters','groups','jumble']}) | 361 cmd_dict['rarefaction.shared'] = dict({'required' : [], 'optional' : ['label','iters','groups','jumble']}) |
212 cmd_dict['normalize.shared'] = dict({'required' : [], 'optional' : ['label','method','norm','groups']}) | 362 cmd_dict['normalize.shared'] = dict({'required' : [], 'optional' : ['label','method','norm','groups']}) |
213 cmd_dict['dist.shared'] = dict({'required' : [], 'optional' : ['calc','label','groups','output']}) | 363 cmd_dict['dist.shared'] = dict({'required' : [], 'optional' : ['calc','label','groups','output']}) |
214 cmd_dict['split.abund'] = dict({'required' : ['fasta',['name','list']], 'optional' : ['cutoff','group','groups','label','accnos']}) | 364 cmd_dict['split.abund'] = dict({'required' : ['fasta',['name','list']], 'optional' : ['cutoff','group','groups','label','accnos']}) |
215 cmd_dict['split.groups'] = dict({'required' : ['fasta','group'], 'optional' : []}) | 365 cmd_dict['split.groups'] = dict({'required' : ['fasta','group'], 'optional' : []}) |
216 cmd_dict['tree.shared'] = dict({'required' : [], 'optional' : ['groups','calc','cutoff','precision','label']}) | 366 cmd_dict['tree.shared'] = dict({'required' : [], 'optional' : ['groups','calc','cutoff','precision','label']}) |
217 cmd_dict['unifrac.unweighted'] = dict({'required' : [], 'optional' : ['groups','iters','distance','random','processors']}) | 367 cmd_dict['unifrac.unweighted'] = dict({'required' : [], 'optional' : ['groups','iters','distance','random','root','processors']}) |
218 cmd_dict['unifrac.weighted'] = dict({'required' : [], 'optional' : ['groups','iters','distance','random','processors']}) | 368 cmd_dict['unifrac.weighted'] = dict({'required' : [], 'optional' : ['groups','iters','distance','random','root','processors']}) |
219 cmd_dict['parsimony'] = dict({'required' : [], 'optional' : ['groups','iters','random','processors']}) | 369 cmd_dict['parsimony'] = dict({'required' : [], 'optional' : ['groups','iters','random','processors']}) |
220 cmd_dict['sffinfo'] = dict({'required' : ['sff'], 'optional' : ['fasta','qfile','trim','sfftxt','flow','accnos']}) | 370 cmd_dict['sffinfo'] = dict({'required' : ['sff'], 'optional' : ['fasta','qfile','trim','sfftxt','flow','accnos']}) |
221 cmd_dict['fastq.info'] = dict({'required' : ['fastq'], 'optional' : []}) | 371 cmd_dict['fastq.info'] = dict({'required' : ['fastq'], 'optional' : []}) |
222 cmd_dict['heatmap.bin'] = dict({'required' : [], 'optional' : ['label','groups','scale','sorted','numotu','fontsize']}) | 372 cmd_dict['heatmap.bin'] = dict({'required' : [], 'optional' : ['label','groups','scale','sorted','numotu','fontsize']}) |
223 cmd_dict['heatmap.sim'] = dict({'required' : [], 'optional' : ['calc','phylip','column','name','label','groups']}) | 373 cmd_dict['heatmap.sim'] = dict({'required' : [], 'optional' : ['calc','phylip','column','name','label','groups']}) |
224 cmd_dict['venn'] = dict({'required' : [], 'optional' : ['calc','label','groups','nseqs','permute']}) | 374 cmd_dict['venn'] = dict({'required' : [], 'optional' : ['calc','label','groups','abund','nseqs','permute']}) |
225 cmd_dict['pcoa'] = dict({'required' : ['phylip'], 'optional' : []}) | 375 cmd_dict['pcoa'] = dict({'required' : ['phylip'], 'optional' : []}) |
226 cmd_dict['pca'] = dict({'required' : [], 'optional' : ['label','groups','metric']}) | 376 cmd_dict['pca'] = dict({'required' : [], 'optional' : ['label','groups','metric']}) |
227 cmd_dict['nmds'] = dict({'required' : ['phylip'], 'optional' : ['axes','mindim','maxdim','iters','maxiters','epsilon']}) | 377 cmd_dict['nmds'] = dict({'required' : ['phylip'], 'optional' : ['axes','mindim','maxdim','iters','maxiters','epsilon']}) |
228 cmd_dict['corr.axes'] = dict({'required' : [['shared','relabund','metadata'],'axes'], 'optional' : ['label','groups','method','numaxes']}) | 378 cmd_dict['corr.axes'] = dict({'required' : [['shared','relabund','metadata'],'axes'], 'optional' : ['label','groups','method','numaxes']}) |
229 cmd_dict['get.group'] = dict({'required' : [], 'optional' : []}) | 379 cmd_dict['get.group'] = dict({'required' : [], 'optional' : []}) |
230 cmd_dict['phylotype'] = dict({'required' : ['taxonomy'],'optional' : ['name','cutoff','label']}) | 380 cmd_dict['phylotype'] = dict({'required' : ['taxonomy'],'optional' : ['name','cutoff','label']}) |
231 cmd_dict['phylo.diversity'] = dict({'required' : [],'optional' : ['groups','iters','freq','processors','scale','rarefy','collect','summary','processors']}) | 381 cmd_dict['phylo.diversity'] = dict({'required' : [],'optional' : ['groups','iters','freq','scale','rarefy','collect','summary','processors']}) |
232 cmd_dict['get.oturep'] = dict({'required' : ['fasta','list'], 'optional' : ['phylip','column','name','label','group','groups','sorted','precision','cutoff','large','weighted']}) | 382 cmd_dict['get.oturep'] = dict({'required' : ['fasta','list'], 'optional' : ['phylip','column','name','label','group','groups','sorted','precision','cutoff','large','weighted']}) |
233 cmd_dict['get.relabund'] = dict({'required' : [],'optional' : ['scale','label','groups']}) | 383 cmd_dict['get.relabund'] = dict({'required' : [],'optional' : ['scale','label','groups']}) |
234 cmd_dict['libshuff'] = dict({'required' : [],'optional' : ['iters','form','step','cutoff']}) | 384 cmd_dict['libshuff'] = dict({'required' : [],'optional' : ['iters','form','step','cutoff']}) |
235 # clearcut options not needed in galaxy: 'version','verbose','quiet','stdout' | 385 # clearcut options not needed in galaxy: 'version','verbose','quiet','stdout' |
236 cmd_dict['clearcut'] = dict({'required' : [['list','fasta']],'optional' : ['seed','norandom','shuffle','neighbor','expblen','expdist','ntrees','matrixout','kimura','jukes','protein','DNA']}) | 386 cmd_dict['clearcut'] = dict({'required' : [['list','fasta']],'optional' : ['seed','norandom','shuffle','neighbor','expblen','expdist','ntrees','matrixout','kimura','jukes','protein','DNA']}) |
237 cmd_dict['get.lineage'] = dict({'required' : ['taxonomy','taxon'],'optional' : ['fasta','name','group','list','alignreport','dups']}) | 387 cmd_dict['get.lineage'] = dict({'required' : ['taxonomy','taxon'],'optional' : ['fasta','name','group','list','alignreport','dups']}) |
238 cmd_dict['remove.lineage'] = dict({'required' : ['taxonomy','taxon'],'optional' : ['fasta','name','group','list','alignreport','dups']}) | 388 cmd_dict['remove.lineage'] = dict({'required' : ['taxonomy','taxon'],'optional' : ['fasta','name','group','list','alignreport','dups']}) |
239 cmd_dict['bootstrap.shared'] = dict({'required' : [], 'optional' : ['calc','groups','iters','label']}) | 389 cmd_dict['bootstrap.shared'] = dict({'required' : [], 'optional' : ['calc','groups','iters','label']}) |
240 """ | 390 cmd_dict['cluster.classic'] = dict({'required' : ['phylip'] , 'optional' : ['method','cutoff','hard','precision']}) |
241 Mothur 1.15 | |
242 """ | |
243 cmd_dict['cluster.classic'] = dict({'required' : [] , 'optional' : ['method','cutoff','hard','precision']}) | |
244 cmd_dict['get.groups'] = dict({'required' : ['group'], 'optional' : ['groups','accnos','fasta','name','list','taxonomy']}) | 391 cmd_dict['get.groups'] = dict({'required' : ['group'], 'optional' : ['groups','accnos','fasta','name','list','taxonomy']}) |
245 cmd_dict['remove.groups'] = dict({'required' : ['group'], 'optional' : ['groups','accnos','fasta','name','list','taxonomy']}) | 392 cmd_dict['remove.groups'] = dict({'required' : ['group'], 'optional' : ['groups','accnos','fasta','name','list','taxonomy']}) |
246 cmd_dict['get.otus'] = dict({'required' : ['group','list','label'], 'optional' : ['groups','accnos']}) | 393 cmd_dict['get.otus'] = dict({'required' : ['group','list','label'], 'optional' : ['groups','accnos']}) |
247 cmd_dict['remove.otus'] = dict({'required' : ['group','list','label'], 'optional' : ['groups','accnos']}) | 394 cmd_dict['remove.otus'] = dict({'required' : ['group','list','label'], 'optional' : ['groups','accnos']}) |
248 cmd_dict['remove.rare'] = dict({'required' : [['list','sabund','rabund','shared'],'nseqs'], 'optional' : ['group','groups','label','bygroup']}) | 395 cmd_dict['remove.rare'] = dict({'required' : [['list','sabund','rabund','shared'],'nseqs'], 'optional' : ['group','groups','label','bygroup']}) |
249 cmd_dict['parse.list'] = dict({'required' : ['list','group'], 'optional' : ['label']}) | 396 cmd_dict['parse.list'] = dict({'required' : ['list','group'], 'optional' : ['label']}) |
250 | 397 |
251 cmd_dict['sub.sample'] = dict({'required' : [['fasta','list','sabund','rabund','shared']], 'optional' : ['name','group','groups','label','size','persample']}) | 398 cmd_dict['sub.sample'] = dict({'required' : [['fasta','list','sabund','rabund','shared']], 'optional' : ['name','group','groups','label','size','persample']}) |
252 cmd_dict['consensus.seqs'] = dict({'required' : ['fasta'], 'optional' : ['list','name','label']}) | 399 cmd_dict['consensus.seqs'] = dict({'required' : ['fasta'], 'optional' : ['list','name','label']}) |
253 cmd_dict['indicator'] = dict({'required' : ['tree',['shared','relabund']], 'optional' : ['groups','label','design']}) | 400 cmd_dict['indicator'] = dict({'required' : ['tree',['shared','relabund']], 'optional' : ['groups','label','design']}) |
401 | |
402 cmd_dict['amova'] = dict({'required' : ['phylip','design'] , 'optional' : ['alpha','iters']}) | |
403 cmd_dict['homova'] = dict({'required' : ['phylip','design'] , 'optional' : ['alpha','iters']}) | |
404 cmd_dict['anosim'] = dict({'required' : ['phylip','design'] , 'optional' : ['alpha','iters']}) | |
405 cmd_dict['mantel'] = dict({'required' : ['phylip','phylip2'] , 'optional' : ['method','iters']}) | |
406 cmd_dict['make,fastq'] = dict({'required' : ['fasta','qfile'] , 'optional' : []}) | |
407 """ | |
408 | |
254 parser = optparse.OptionParser() | 409 parser = optparse.OptionParser() |
255 # Options for managing galaxy interaction | 410 # Options for managing galaxy interaction |
256 parser.add_option( '--debug', dest='debug', action='store_true', default=False, help='Turn on wrapper debugging to stdout' ) | 411 parser.add_option( '--debug', dest='debug', action='store_true', default=False, help='Turn on wrapper debugging to stdout' ) |
257 parser.add_option( '--cmd', dest='cmd', help='The mothur command' ) | 412 parser.add_option( '--cmd', dest='cmd', help='The mothur command' ) |
258 parser.add_option( '--inputdir', dest='inputdir', help='The directory in which to work' ) | 413 parser.add_option( '--inputdir', dest='inputdir', help='The directory in which to work' ) |
316 parser.add_option( '--taxon', dest='taxon', help='A Taxon' ) | 471 parser.add_option( '--taxon', dest='taxon', help='A Taxon' ) |
317 parser.add_option( '--taxlevel', dest='taxlevel', type="int", help='A Taxonomy level' ) | 472 parser.add_option( '--taxlevel', dest='taxlevel', type="int", help='A Taxonomy level' ) |
318 # parser.add_option( '--taxon', dest='taxon', action="callback", callback=remove_confidence_callback, help='A Taxon' ) | 473 # parser.add_option( '--taxon', dest='taxon', action="callback", callback=remove_confidence_callback, help='A Taxon' ) |
319 parser.add_option( '--candidate', dest='candidate', help=' file ' ) | 474 parser.add_option( '--candidate', dest='candidate', help=' file ' ) |
320 parser.add_option( '--template', dest='template', help=' file ' ) | 475 parser.add_option( '--template', dest='template', help=' file ' ) |
476 parser.add_option( '--reference', dest='reference', help=' file ' ) | |
321 parser.add_option( '--dups', dest='dups', help='if True also apply to the aliases from the names files' ) | 477 parser.add_option( '--dups', dest='dups', help='if True also apply to the aliases from the names files' ) |
322 parser.add_option( '--keep', dest='keep', help='Either front or back to specify the which end of the sequence to keep' ) | 478 parser.add_option( '--keep', dest='keep', help='Either front or back to specify the which end of the sequence to keep' ) |
323 parser.add_option( '--search', dest='search', help='Method for finding the template sequence: kmer, blast, suffix' ) | 479 parser.add_option( '--search', dest='search', help='Method for finding the template sequence: kmer, blast, suffix' ) |
324 parser.add_option( '--ksize', dest='ksize', type="int", help='Size of kmers (5 - 12)' ) | 480 parser.add_option( '--ksize', dest='ksize', type="int", help='Size of kmers (5 - 12)' ) |
325 parser.add_option( '--align', dest='align', help='Alignment method: needleman, blastn, gotoh' ) | 481 parser.add_option( '--align', dest='align', help='Alignment method: needleman, blastn, gotoh' ) |
351 parser.add_option( '--cutoff', dest='cutoff', help='Distance Cutoff threshold, discard larger distances' ) | 507 parser.add_option( '--cutoff', dest='cutoff', help='Distance Cutoff threshold, discard larger distances' ) |
352 parser.add_option( '--countgaps', dest='countgaps', help='count gaps as bases' ) | 508 parser.add_option( '--countgaps', dest='countgaps', help='count gaps as bases' ) |
353 parser.add_option( '--output', dest='output', help='Format for output' ) | 509 parser.add_option( '--output', dest='output', help='Format for output' ) |
354 parser.add_option( '--method', dest='method', help='Method to use for analysis - cluster' ) | 510 parser.add_option( '--method', dest='method', help='Method to use for analysis - cluster' ) |
355 parser.add_option( '--splitmethod', dest='splitmethod', help='Method to split a distance file - cluster.split' ) | 511 parser.add_option( '--splitmethod', dest='splitmethod', help='Method to split a distance file - cluster.split' ) |
512 parser.add_option( '--split', dest='split', help='Chimera split parameter, whether to detect trimeras and quadmeras' ) | |
356 parser.add_option( '--abund', dest='abund', type='int', help='Threshold for rare to Abundant OTU classification' ) | 513 parser.add_option( '--abund', dest='abund', type='int', help='Threshold for rare to Abundant OTU classification' ) |
357 parser.add_option( '--size', dest='size', type='int', help='Size - sample size' ) | 514 parser.add_option( '--size', dest='size', type='int', help='Size - sample size' ) |
358 parser.add_option( '--groupmode', dest='groupmode', help='Collate groups into one result table' ) | 515 parser.add_option( '--groupmode', dest='groupmode', help='Collate groups into one result table' ) |
359 parser.add_option( '--all', dest='all', help='Calculate for all' ) | 516 parser.add_option( '--all', dest='all', help='Calculate for all' ) |
360 parser.add_option( '--freq', dest='freq', type="float", help='Frequency of sequences to choose, as fraction is 0.0 - 1.0 or iteration if int > 1' ) | 517 parser.add_option( '--freq', dest='freq', type="float", help='Frequency of sequences to choose, as fraction is 0.0 - 1.0 or iteration if int > 1' ) |
371 parser.add_option( '--mindim', dest='mindim', type='int', help='Minimum dimensions' ) | 528 parser.add_option( '--mindim', dest='mindim', type='int', help='Minimum dimensions' ) |
372 parser.add_option( '--maxdim', dest='maxdim', type='int', help='Maximum dimensions' ) | 529 parser.add_option( '--maxdim', dest='maxdim', type='int', help='Maximum dimensions' ) |
373 parser.add_option( '--percent', dest='percent', type='int', help='(0-100 percent)' ) | 530 parser.add_option( '--percent', dest='percent', type='int', help='(0-100 percent)' ) |
374 parser.add_option( '--divergence', dest='divergence', type='float', help='Divergence cutoff for chimera determination' ) | 531 parser.add_option( '--divergence', dest='divergence', type='float', help='Divergence cutoff for chimera determination' ) |
375 parser.add_option( '--sff', dest='sff', help='Sff file' ) | 532 parser.add_option( '--sff', dest='sff', help='Sff file' ) |
533 parser.add_option( '--svg', dest='svg', help='SVG' ) | |
376 parser.add_option( '--sfftxt', dest='sfftxt', help='Generate a sff.txt file' ) | 534 parser.add_option( '--sfftxt', dest='sfftxt', help='Generate a sff.txt file' ) |
377 parser.add_option( '--flow', dest='flow', help='Generate a flowgram file' ) | 535 parser.add_option( '--flow', dest='flow', help='Generate a flowgram file' ) |
378 parser.add_option( '--trim', dest='trim', help='Whether sequences and quality scores are trimmed to the clipQualLeft and clipQualRight values' ) | 536 parser.add_option( '--trim', dest='trim', help='Whether sequences and quality scores are trimmed to the clipQualLeft and clipQualRight values' ) |
379 parser.add_option( '--input', dest='input', help='' ) | 537 parser.add_option( '--input', dest='input', help='' ) |
380 parser.add_option( '--phylip', dest='phylip', help='' ) | 538 parser.add_option( '--phylip', dest='phylip', help='' ) |
539 parser.add_option( '--phylip2', dest='phylip2', help='' ) | |
381 parser.add_option( '--column', dest='column', help='' ) | 540 parser.add_option( '--column', dest='column', help='' ) |
541 parser.add_option( '--sort', dest='sort', help='specify sort order' ) | |
382 parser.add_option( '--sorted', dest='sorted', help='Input is presorted' ) | 542 parser.add_option( '--sorted', dest='sorted', help='Input is presorted' ) |
383 parser.add_option( '--showabund', dest='showabund', help='' ) | 543 parser.add_option( '--showabund', dest='showabund', help='' ) |
384 parser.add_option( '--short', dest='short', help='Keep sequences that are too short to chop' ) | 544 parser.add_option( '--short', dest='short', help='Keep sequences that are too short to chop' ) |
385 parser.add_option( '--distance', dest='distance', help='' ) | 545 parser.add_option( '--distance', dest='distance', help='' ) |
386 parser.add_option( '--scale', dest='scale', help='' ) | 546 parser.add_option( '--scale', dest='scale', help='' ) |
387 parser.add_option( '--numotu', dest='numotu', help='' ) | 547 parser.add_option( '--numotu', dest='numotu', help='' ) |
388 parser.add_option( '--fontsize', dest='fontsize', help='' ) | 548 parser.add_option( '--fontsize', dest='fontsize', help='' ) |
389 parser.add_option( '--neqs', dest='neqs', help='' ) | 549 parser.add_option( '--neqs', dest='neqs', help='' ) |
550 parser.add_option( '--random', dest='random', help='' ) | |
390 parser.add_option( '--permute', dest='permute', help='' ) | 551 parser.add_option( '--permute', dest='permute', help='' ) |
391 parser.add_option( '--rarefy', dest='rarefy', help='' ) | 552 parser.add_option( '--rarefy', dest='rarefy', help='' ) |
392 parser.add_option( '--collect', dest='collect', help='' ) | 553 parser.add_option( '--collect', dest='collect', help='' ) |
393 parser.add_option( '--summary', dest='summary', help='' ) | 554 parser.add_option( '--summary', dest='summary', help='' ) |
394 parser.add_option( '--large', dest='large', help='' ) | 555 parser.add_option( '--large', dest='large', help='' ) |
406 parser.add_option( '--bygroup', dest='bygroup', help='' ) | 567 parser.add_option( '--bygroup', dest='bygroup', help='' ) |
407 parser.add_option( '--design', dest='design', help='' ) | 568 parser.add_option( '--design', dest='design', help='' ) |
408 parser.add_option( '--sets', dest='sets', help='' ) | 569 parser.add_option( '--sets', dest='sets', help='' ) |
409 parser.add_option( '--metric', dest='metric', help='' ) | 570 parser.add_option( '--metric', dest='metric', help='' ) |
410 parser.add_option( '--epsilon', dest='epsilon', help='' ) | 571 parser.add_option( '--epsilon', dest='epsilon', help='' ) |
572 parser.add_option( '--alpha', dest='alpha', help='' ) | |
573 parser.add_option( '--root', dest='root', help='' ) | |
411 parser.add_option( '--axes', dest='axes', help='table of name column followed by columns of axis values' ) | 574 parser.add_option( '--axes', dest='axes', help='table of name column followed by columns of axis values' ) |
412 parser.add_option( '--numaxes', dest='numaxes', help='the number of axes' ) | 575 parser.add_option( '--numaxes', dest='numaxes', help='the number of axes' ) |
413 parser.add_option( '--metadata', dest='metadata', help='data table with columns of floating-point values' ) | 576 parser.add_option( '--metadata', dest='metadata', help='data table with columns of floating-point values' ) |
414 parser.add_option( '--basis', dest='basis', help='what the summary file represents' ) | 577 parser.add_option( '--basis', dest='basis', help='what the summary file represents' ) |
415 parser.add_option( '--keepfirst', dest='keepfirst', help='trimming' ) | 578 parser.add_option( '--keepfirst', dest='keepfirst', help='trimming' ) |
444 if options.tmpdir != None: | 607 if options.tmpdir != None: |
445 if not os.path.isdir(options.tmpdir): | 608 if not os.path.isdir(options.tmpdir): |
446 os.makedirs(options.tmpdir) | 609 os.makedirs(options.tmpdir) |
447 tmp_dir = options.tmpdir | 610 tmp_dir = options.tmpdir |
448 else: | 611 else: |
449 tmp_dir = tempfile.mkdtemp() | 612 if options.outputdir != None: |
613 if not os.path.isdir(options.outputdir): | |
614 os.makedirs(options.outputdir) | |
615 tmp_dir = os.path.join(options.outputdir,'tmp') | |
616 if not os.path.isdir(tmp_dir): | |
617 os.makedirs(tmp_dir) | |
618 else: | |
619 tmp_dir = tempfile.mkdtemp() | |
450 if options.inputdir != None: | 620 if options.inputdir != None: |
451 if not os.path.isdir(options.inputdir): | 621 if not os.path.isdir(options.inputdir): |
452 os.makedirs(options.inputdir) | 622 os.makedirs(options.inputdir) |
453 inputdir = options.inputdir | 623 inputdir = options.inputdir |
454 if options.outputdir != None: | 624 if options.outputdir != None: |
476 # Check for command options | 646 # Check for command options |
477 cmd_opts = ','.join(get_params(options.cmd,options,inputdir)) | 647 cmd_opts = ','.join(get_params(options.cmd,options,inputdir)) |
478 # print >> sys.stderr, cmd_opts | 648 # print >> sys.stderr, cmd_opts |
479 # print >> sys.stderr, params # so will appear as blurb for file | 649 # print >> sys.stderr, params # so will appear as blurb for file |
480 params.append('%s(%s)' % (options.cmd,cmd_opts)) | 650 params.append('%s(%s)' % (options.cmd,cmd_opts)) |
651 if debug: params.append('get.current()') | |
481 try: | 652 try: |
482 # Generate the mothur commandline | 653 # Generate the mothur commandline |
483 # http://www.mothur.org/wiki/Command_line_mode | 654 # http://www.mothur.org/wiki/Command_line_mode |
484 cmdline = 'mothur "#' + '; '.join(params) + '"' | 655 cmdline = 'mothur "#' + '; '.join(params) + '"' |
485 # print >> sys.stdout, '%s' % cmdline | 656 if debug: print >> sys.stdout, '%s' % cmdline |
486 if tmp_dir == None or not os.path.isdir(tmp_dir): | 657 if tmp_dir == None or not os.path.isdir(tmp_dir): |
487 tmp_dir = tempfile.mkdtemp() | 658 tmp_dir = tempfile.mkdtemp() |
488 tmp_stderr_name = tempfile.NamedTemporaryFile( dir=tmp_dir,suffix='.err' ).name | 659 tmp_stderr_name = tempfile.NamedTemporaryFile( dir=tmp_dir,suffix='.err' ).name |
489 tmp_stderr = open( tmp_stderr_name, 'wb' ) | 660 tmp_stderr = open( tmp_stderr_name, 'wb' ) |
490 tmp_stdout_name = tempfile.NamedTemporaryFile( dir=tmp_dir,suffix='.out' ).name | 661 tmp_stdout_name = tempfile.NamedTemporaryFile( dir=tmp_dir,suffix='.out' ).name |
491 tmp_stdout = open( tmp_stdout_name, 'wb' ) | 662 tmp_stdout = open( tmp_stdout_name, 'wb' ) |
492 proc = subprocess.Popen( args=cmdline, shell=True, cwd=tmp_dir, stderr=tmp_stderr.fileno(), stdout=tmp_stdout.fileno() ) | 663 proc = subprocess.Popen( args=cmdline, shell=True, cwd=tmp_dir, stderr=tmp_stderr.fileno(), stdout=tmp_stdout.fileno() ) |
493 # proc = subprocess.Popen( args=cmdline, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE ) | 664 # proc = subprocess.Popen( args=cmdline, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE ) |
494 returncode = proc.wait() | 665 returncode = proc.wait() |
666 if debug: print >> sys.stdout, 'returncode %d' % returncode | |
495 tmp_stderr.close() | 667 tmp_stderr.close() |
496 # get stderr, allowing for case where it's very large | 668 # get stderr, allowing for case where it's very large |
497 tmp_stderr = open( tmp_stderr_name, 'rb' ) | 669 tmp_stderr = open( tmp_stderr_name, 'rb' ) |
498 stderr = '' | 670 stderr = '' |
499 buffsize = 1048576 | 671 buffsize = 1048576 |
503 if not stderr or len( stderr ) % buffsize != 0: | 675 if not stderr or len( stderr ) % buffsize != 0: |
504 break | 676 break |
505 except OverflowError: | 677 except OverflowError: |
506 pass | 678 pass |
507 tmp_stderr.close() | 679 tmp_stderr.close() |
680 tmp_stdout.close() | |
681 if debug: print >> sys.stdout, 'parse %s' % tmp_stdout_name | |
508 if returncode != 0: | 682 if returncode != 0: |
683 try: | |
684 # try to copy stdout to the logfile | |
685 for output in options.result.split(','): | |
686 # Each item has a regex pattern and a file path to a galaxy dataset | |
687 (pattern,path) = output.split(':') | |
688 if debug: print >> sys.stdout, '%s -> %s' % (pattern,path) | |
689 if pattern.find('\.logfile') > 0: | |
690 if path != None and os.path.exists(path): | |
691 logfile_to_html(tmp_stdout_name,path,inputdir,outputdir,title="Mothur %s Error Logfile" % options.cmd) | |
692 break | |
693 except: | |
694 pass | |
509 raise Exception, stderr | 695 raise Exception, stderr |
510 stdout = '' | 696 stdout = '' |
511 # Parse stdout to provide info | 697 # Parse stdout to provide info |
512 tmp_stdout.close() | |
513 tmp_stdout = open( tmp_stdout_name, 'rb' ) | 698 tmp_stdout = open( tmp_stdout_name, 'rb' ) |
699 # try to find a "little" something interesting to print as info for the galaxy interface | |
514 info = '' | 700 info = '' |
515 if options.cmd.startswith('chimera') and not options.cmd.endswith('check'): | 701 if options.cmd.startswith('chimera') and not options.cmd.endswith('check'): |
516 pattern = '^.*$' | 702 pattern = '^.*$' |
517 if options.cmd == 'chimera.slayer': | 703 if options.cmd == 'chimera.slayer': |
518 # gi|11093931|MNE12|AF293003 yes | 704 # gi|11093931|MNE12|AF293003 yes |
531 if re.match(pattern,line): | 717 if re.match(pattern,line): |
532 chimera_count += 1 | 718 chimera_count += 1 |
533 info += "Chimeras: %d" % chimera_count | 719 info += "Chimeras: %d" % chimera_count |
534 else: | 720 else: |
535 found_begin = False | 721 found_begin = False |
722 info_chars = 0 | |
536 for line in tmp_stdout: | 723 for line in tmp_stdout: |
537 if line.find(outputdir) >= 0: | 724 if line.find(outputdir) >= 0: |
538 continue | 725 continue |
726 if line.startswith('**************'): | |
727 continue | |
539 if re.match('^Processing.*',line): | 728 if re.match('^Processing.*',line): |
540 continue | 729 continue |
730 if re.match('^Reading .*',line): | |
731 continue | |
732 if re.match('^Merging .*',line): | |
733 continue | |
734 if re.match('^DONE.*',line): | |
735 continue | |
541 if re.match('.*\.\.\.\s*$',line): | 736 if re.match('.*\.\.\.\s*$',line): |
542 continue | 737 continue |
543 if re.match('^\d*\s*$',line): | 738 if re.match('^\d*\s*$',line): |
739 continue | |
740 # if re.match('^(unique|[0-9.]*)(\t\d+)+',line): # abundance from cluster commands | |
741 if not options.cmd.startswith('unifrac') and re.match('^([0-9.]+)(\t\d+)*',line): # abundance from cluster commands, allow unique line into info | |
544 continue | 742 continue |
545 if re.match('Output .*',line): | 743 if re.match('Output .*',line): |
546 break | 744 break |
547 if found_begin: | 745 if found_begin and info_chars < 200: |
548 info += "%s" % line | 746 info += "%s" % line |
747 info_chars += len(line) | |
549 if re.match('mothur > ' + options.cmd + '\(.*\)', line): | 748 if re.match('mothur > ' + options.cmd + '\(.*\)', line): |
550 found_begin = True | 749 found_begin = True |
551 tmp_stdout.close() | 750 tmp_stdout.close() |
552 print >> sys.stdout, info | 751 print >> sys.stdout, info |
553 # Collect output files | 752 # Collect output files |
554 flist = os.listdir(outputdir) | 753 flist = os.listdir(outputdir) |
555 if debug: print >> sys.stdout, '%s' % flist | 754 if debug: print >> sys.stdout, '%s' % flist |
755 # chimera.check can generate svg files, but they are not listed in the mothur.*.logfile, so we'll added them in here | |
756 if options.cmd == 'chimera.check': | |
757 svgs = [] | |
758 mothurlog = None | |
759 for fname in flist: | |
760 if fname.endswith('.svg'): | |
761 svgs.append(fname) | |
762 elif fname.endswith('.logfile'): | |
763 mothurlog = fname | |
556 # process option result first | 764 # process option result first |
557 # These are the known galaxy datasets listed in the --result= param | 765 # These are the known galaxy datasets listed in the --result= param |
558 if len(flist) > 0 and options.result: | 766 if len(flist) > 0 and options.result: |
559 # items in list are separated by commas | 767 # items in list are separated by commas |
560 for output in options.result.split(','): | 768 for output in options.result.split(','): |
571 flist.remove(fname) | 779 flist.remove(fname) |
572 fpath = os.path.join(outputdir,fname) | 780 fpath = os.path.join(outputdir,fname) |
573 if fname.endswith('.logfile'): | 781 if fname.endswith('.logfile'): |
574 # Make the logfile into html | 782 # Make the logfile into html |
575 logfile_to_html(fpath,path,inputdir,outputdir,title="Mothur %s Logfile" % options.cmd) | 783 logfile_to_html(fpath,path,inputdir,outputdir,title="Mothur %s Logfile" % options.cmd) |
576 elif False and outputdir == options.outputdir: | 784 elif outputdir == options.outputdir: |
577 # Use a hard link if outputdir is the extra_files_path | 785 # Use a hard link if outputdir is the extra_files_path, allows link from mothur logfile without copying data. |
578 try: | 786 try: |
787 if debug: print >> sys.stdout, 'link %s %s' % (fpath, path) | |
579 os.link(fpath, path) | 788 os.link(fpath, path) |
580 except: | 789 except: |
790 if debug: print >> sys.stdout, 'copy %s %s' % (fpath, path) | |
581 shutil.copy2(fpath, path) | 791 shutil.copy2(fpath, path) |
582 else: | 792 else: |
793 if debug: print >> sys.stdout, 'copy2 %s %s' % (fpath, path) | |
583 shutil.copy2(fpath, path) | 794 shutil.copy2(fpath, path) |
584 break | 795 break |
796 # mothur.*.logfile may be in tmp_dir | |
585 # chimera.pintail e.g. generates files in the working dir that we might want to save | 797 # chimera.pintail e.g. generates files in the working dir that we might want to save |
586 if not found: | 798 if not found: |
587 for fname in os.listdir(tmp_dir): | 799 for fname in os.listdir(tmp_dir): |
588 if debug: print >> sys.stdout, 'tmpdir %s match: %s' % (fname,re.match(pattern,fname)) | 800 if debug: print >> sys.stdout, 'tmpdir %s match: %s' % (fname,re.match(pattern,fname)) |
589 if re.match(pattern,fname): | 801 if re.match(pattern,fname): |
590 fpath = os.path.join(tmp_dir,fname) | 802 fpath = os.path.join(tmp_dir,fname) |
591 shutil.copy2(fpath, path) | 803 if fname.endswith('.logfile'): |
592 break | 804 # Make the logfile into html |
805 logfile_to_html(fpath,path,inputdir,outputdir,title="Mothur %s Logfile" % options.cmd) | |
806 else: | |
807 shutil.copy2(fpath, path) | |
808 break | |
593 # Handle the dynamically generated galaxy datasets | 809 # Handle the dynamically generated galaxy datasets |
594 # http://bitbucket.org/galaxy/galaxy-central/wiki/ToolsMultipleOutput | 810 # http://bitbucket.org/galaxy/galaxy-central/wiki/ToolsMultipleOutput |
595 # --new_datasets= specifies files to copy to the new_file_path | 811 # --new_datasets= specifies files to copy to the new_file_path |
596 # The list items are separated by commas | 812 # The list items are separated by commas |
597 # Each item conatins: a regex pattern for matching filenames and a galaxy datatype (separated by :) | 813 # Each item conatins: a regex pattern for matching filenames and a galaxy datatype (separated by :) |
603 for fname in flist: | 819 for fname in flist: |
604 m = re.match(pattern,fname) | 820 m = re.match(pattern,fname) |
605 if m: | 821 if m: |
606 fpath = os.path.join(outputdir,fname) | 822 fpath = os.path.join(outputdir,fname) |
607 if len(m.groups()) > 0: | 823 if len(m.groups()) > 0: |
608 root = m.groups()[0] | 824 # remove underscores since galaxy uses that as a field separator for dynamic datasets |
825 root = m.groups()[0].replace('_','') | |
609 else: | 826 else: |
610 # remove the ext from the name if it exists, galaxy will add back later | 827 # remove the ext from the name if it exists, galaxy will add back later |
611 # remove underscores since galaxy uses that as a field separator for dynamic datasets | 828 # remove underscores since galaxy uses that as a field separator for dynamic datasets |
612 root = re.sub('\.?'+ext+'$','',fname).replace('_','').replace('.','') | 829 root = re.sub('\.?'+ext+'$','',fname).replace('_','').replace('.','') |
613 # filename pattern required by galaxy | 830 # filename pattern required by galaxy |
630 # Only remove temporary directories | 847 # Only remove temporary directories |
631 # Enclose in try block, so we don't report error on stale nfs handles | 848 # Enclose in try block, so we don't report error on stale nfs handles |
632 try: | 849 try: |
633 if outputdir != options.outputdir and os.path.exists(outputdir): | 850 if outputdir != options.outputdir and os.path.exists(outputdir): |
634 if os.path.islink(outputdir): | 851 if os.path.islink(outputdir): |
852 if debug: print >> sys.stdout, 'rm outputdir %s' % outputdir | |
635 os.remove(outputdir) | 853 os.remove(outputdir) |
854 if debug: print >> sys.stdout, 'rmtree outputdir %s' % outputdir | |
636 shutil.rmtree(os.path.dirname(outputdir)) | 855 shutil.rmtree(os.path.dirname(outputdir)) |
637 else: | 856 else: |
857 if debug: print >> sys.stdout, 'rmtree %s' % outputdir | |
638 shutil.rmtree(outputdir) | 858 shutil.rmtree(outputdir) |
639 if inputdir != options.inputdir and os.path.exists(inputdir): | 859 if inputdir != options.inputdir and os.path.exists(inputdir): |
860 if debug: print >> sys.stdout, 'rmtree %s' % inputdir | |
640 shutil.rmtree(inputdir) | 861 shutil.rmtree(inputdir) |
641 except: | 862 except: |
863 if debug: print >> sys.stdout, 'rmtree failed' | |
642 pass | 864 pass |
643 | 865 |
644 | 866 |
645 if __name__ == "__main__": __main__() | 867 if __name__ == "__main__": __main__() |