Mercurial > repos > jjohnson > mothur_toolsuite
view mothur/tools/mothur/TreeVector.py @ 32:ec8df51e841a
Fixes courtesy of Peter Briggs:
metagenomics.py:
- Groups class: Fix for when second column not present
- Axes class: make 'sniff' method more sensitive to try and restrict arbitrary tabular
data uploads being sniffed as this type
mothur_wrapper.py:
- update cmd_dict['chimera.perseus'], to use correct inputs
- add --beta option (needed for chimera.perseus tool)
- add function for converting input floats from scientific notation (e.g. 1e-6,
which mothur can't handle) to decimal format (e.g. 0.00001, which it can)
chimera.perseus.xml:
- add output data item for the "accnos" file (not previous captured in the
history)
trim.flows.xml:
- cosmetic change: base name for additional output data items is now "trim.flows",
rather than "logfile" (clarifies history items)
shhh.flows.xml:
- cosmetic change: update default value specified in help for mindiff to be
consistent with that given in the mothur documentation
author | Jim Johnson <jj@umn.edu> |
---|---|
date | Wed, 04 Sep 2013 10:51:34 -0500 |
parents | 3202a38e44d9 |
children |
line wrap: on
line source
#!/usr/bin/env python """ Runs TreeVector on a newick file; TODO: more documentation """ import optparse, os, shutil, subprocess, sys, tempfile, re, string def stop_err( msg ): sys.stderr.write( '%s\n' % msg ) sys.exit() def __main__(): #Parse Command Line parser = optparse.OptionParser() parser.add_option( '-i', '--input', dest='input', help='The sequence input file' ) parser.add_option( '-s', '--shape', dest='shape', help='Branch shape' ) parser.add_option( '-l', '--length', dest='length', help='Branch length' ) parser.add_option( '-g', '--svg', dest='svg', help='Graph in SVG format' ) parser.add_option( '-p', '--jarBin', dest='jarBin', default='', help='The path to where jars are stored' ) parser.add_option( '-j', '--jarFile', dest='jarFile', help='The file name of the jar file to use') parser.add_option( '-x', '--jvmArgs', dest='jvmArgs', help='Java JVM arguments, e.g -Xmx250m') (options, args) = parser.parse_args() if options.jarBin == None: stop_err("Misssing option --jarBin") elif options.jarFile == None: stop_err("Misssing option --jarFile") elif options.input == None: stop_err("Misssing option --input") params = [] props = [] if options.jvmArgs != None: props.append(options.jvmArgs) if options.shape != None and options.shape != 'None': params.append('-%s' % options.shape) if options.length != None and options.length != 'None': params.append('-%s' % options.length) if options.svg != None and options.svg != 'None': params.append('-out %s' % options.svg) # make temp directory buffsize = 1048576 tmp_dir = tempfile.mkdtemp() # print("tmp_dir %s" % tmp_dir) # generate commandline cmd = 'java %s -jar %s %s %s' % (' '.join(props), os.path.join( options.jarBin, options.jarFile ), options.input, ' '.join(params)) # print >> sys.stderr, cmd # need to nest try-except in try-finally to handle 2.4 try: try: proc = subprocess.Popen( args=cmd, shell=True, stderr=subprocess.PIPE ) returncode = proc.wait() stderr = proc.stderr.read() if returncode != 0: raise Exception, stderr except Exception, e: raise Exception, 'Error executing TeeVector. ' + str( e ) except Exception, e: stop_err( 'TreeVector failed.\n' + str( e ) ) if __name__=="__main__": __main__()