# HG changeset patch # User peterjc # Date 1402409518 14400 # Node ID aeb3e35f823676c6cdaf34b04e8273b22b6d83df # Parent 8487d70e82aaf0b73c0bb99b16fb6c8ff558dd32 Uploaded v0.0.4 preview, made MAF and BAM output optional diff -r 8487d70e82aa -r aeb3e35f8236 tools/mira4/README.rst --- a/tools/mira4/README.rst Wed May 21 06:56:06 2014 -0400 +++ b/tools/mira4/README.rst Tue Jun 10 10:11:58 2014 -0400 @@ -91,6 +91,8 @@ (``$TMPDIR``, ``$TEMP``, or ``$TMP`` in that order). This was previously hard coded as ``/tmp``. v0.0.3 - Updated to target MIRA 4.0.2 +v0.0.4 - Using optparse for the Python wrapper script API + - Made MAF and BAM outputs optional ======= ====================================================================== diff -r 8487d70e82aa -r aeb3e35f8236 tools/mira4/mira4.py --- a/tools/mira4/mira4.py Wed May 21 06:56:06 2014 -0400 +++ b/tools/mira4/mira4.py Tue Jun 10 10:11:58 2014 -0400 @@ -7,11 +7,12 @@ import shutil import time import tempfile +from optparse import OptionParser #Do we need any PYTHONPATH magic? from mira4_make_bam import make_bam -WRAPPER_VER = "0.0.1" #Keep in sync with the XML file +WRAPPER_VER = "0.0.4" #Keep in sync with the XML file def stop_err(msg, err=1): sys.stderr.write(msg+"\n") @@ -34,6 +35,35 @@ del child return ver.split("\n", 1)[0].strip() +#Parse Command Line +usage = """Galaxy MIRA4 wrapper script v%s - use as follows: + +$ python mira4.py ... + +This will run the MIRA binary and collect its output files as directed. +""" % WRAPPER_VER +parser = OptionParser(usage=usage) +parser.add_option("-m", "--manifest", dest="manifest", + default=None, metavar="FILE", + help="MIRA manifest filename") +parser.add_option("--maf", dest="maf", + default="-", metavar="FILE", + help="MIRA MAF output filename") +parser.add_option("--bam", dest="bam", + default="-", metavar="FILE", + help="Unpadded BAM output filename") +parser.add_option("--fasta", dest="fasta", + default="-", metavar="FILE", + help="Unpadded FASTA output filename") +parser.add_option("--log", dest="log", + default="-", metavar="FILE", + help="MIRA logging output filename") +options, args = parser.parse_args() +manifest = options.manifest +out_maf = options.maf +out_bam = options.bam +out_fasta = options.fasta +out_log = options.log try: mira_path = os.environ["MIRA4"] @@ -60,6 +90,11 @@ print "WARNING: miraconvert %s" % mira_convert_ver sys.exit(0) +if not manifest: + stop_err("Manifest is required") +elif not os.path.isfile(manifest): + stop_err("Missing input MIRA manifest file: %r" % manifest) + try: threads = int(os.environ.get("GALAXY_SLOTS", "1")) @@ -143,6 +178,8 @@ (old_fasta, out_fasta)]: if not os.path.isfile(old): missing = True + elif not new or new == "-": + handle.write("Ignoring %s\n" % old) else: handle.write("Capturing %s\n" % old) shutil.move(old, new) @@ -154,9 +191,10 @@ #For mapping mode, probably most people would expect a BAM file #using the reference FASTA file... - msg = make_bam(mira_convert, out_maf, ref_fasta, out_bam, handle) - if msg: - stop_err(msg) + if out_bam and out_bam != "-": + msg = make_bam(mira_convert, out_maf, ref_fasta, out_bam, handle) + if msg: + stop_err(msg) def clean_up(temp, name): folder = "%s/%s_assembly" % (temp, name) @@ -167,14 +205,12 @@ #Currently Galaxy puts us somewhere safe like: #/opt/galaxy-dist/database/job_working_directory/846/ temp = "." -#name, out_fasta, out_qual, out_ace, out_caf, out_wig, out_log = sys.argv[1:8] + name = "MIRA" -manifest, out_maf, out_bam, out_fasta, out_log = sys.argv[1:] override_temp(manifest) start_time = time.time() -#cmd_list =sys.argv[8:] cmd_list = [mira_binary, "-t", str(threads), manifest] cmd = " ".join(cmd_list) @@ -192,7 +228,10 @@ #print os.path.abspath(".") #print cmd -handle = open(out_log, "w") +if out_log and out_log != "-": + handle = open(out_log, "w") +else: + handle = open(os.devnull, "w") handle.write("======================== MIRA manifest (instructions) ========================\n") m = open(manifest, "rU") for line in m: diff -r 8487d70e82aa -r aeb3e35f8236 tools/mira4/mira4_de_novo.xml --- a/tools/mira4/mira4_de_novo.xml Wed May 21 06:56:06 2014 -0400 +++ b/tools/mira4/mira4_de_novo.xml Tue Jun 10 10:11:58 2014 -0400 @@ -1,4 +1,4 @@ - + Takes Sanger, Roche 454, Solexa/Illumina, Ion Torrent and PacBio reads mira @@ -8,8 +8,16 @@ samtools mira4.py --version - -mira4.py "$manifest" "$out_maf" "$out_bam" "$out_fasta" "$out_log" + mira4.py +--manifest "$manifest" +#if str($maf_wanted)=="true": +--maf "$out_maf" +#end if +#if str($bam_wanted)=="true": +--bam "$out_bam" +#end if +--fasta "$out_fasta" +--log "$out_log" @@ -67,12 +75,18 @@ + + - - + + bam_wanted is True + + + maf_wanted is True + @@ -162,6 +176,8 @@ + + @@ -176,6 +192,8 @@ + + diff -r 8487d70e82aa -r aeb3e35f8236 tools/mira4/mira4_mapping.xml --- a/tools/mira4/mira4_mapping.xml Wed May 21 06:56:06 2014 -0400 +++ b/tools/mira4/mira4_mapping.xml Tue Jun 10 10:11:58 2014 -0400 @@ -1,4 +1,4 @@ - + Maps Sanger, Roche 454, Solexa/Illumina, Ion Torrent and PacBio reads mira @@ -8,8 +8,16 @@ samtools mira4.py --version - -mira4.py "$manifest" "$out_maf" "$out_bam" "$out_fasta" "$out_log" + mira4.py +--manifest "$manifest" +#if str($maf_wanted) == "true": +--maf "$out_maf" +#end if +#if str($bam_wanted) == "true": +--bam "$out_bam" +#end if +--fasta "$out_fasta" +--log "$out_log" @@ -69,11 +77,17 @@ + + - - + + bam_wanted is True + + + maf_wanted is True + @@ -168,6 +182,8 @@ + + @@ -180,6 +196,8 @@ + + diff -r 8487d70e82aa -r aeb3e35f8236 tools/mira4/repository_dependencies.xml --- a/tools/mira4/repository_dependencies.xml Wed May 21 06:56:06 2014 -0400 +++ b/tools/mira4/repository_dependencies.xml Tue Jun 10 10:11:58 2014 -0400 @@ -1,4 +1,4 @@ - + diff -r 8487d70e82aa -r aeb3e35f8236 tools/mira4/tool_dependencies.xml --- a/tools/mira4/tool_dependencies.xml Wed May 21 06:56:06 2014 -0400 +++ b/tools/mira4/tool_dependencies.xml Tue Jun 10 10:11:58 2014 -0400 @@ -1,7 +1,7 @@ - +