changeset 4:117cce3296af

Uploaded wrapper v0.0.3, which is for MIRA v3.4.x which includes support for Ion Torrent. The Galaxy wrapper will no longer work with MIRA v3.2.x - if you are still using the old version of MIRA, please continue to use v0.0.2 of the wrapper.
author peterjc
date Wed, 21 Dec 2011 11:33:19 -0500
parents 298f5c1d9521
children 216bf640baaf
files tools/sr_assembly/mira.py tools/sr_assembly/mira.txt tools/sr_assembly/mira.xml
diffstat 3 files changed, 60 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/tools/sr_assembly/mira.py	Tue Jun 21 09:50:32 2011 -0400
+++ b/tools/sr_assembly/mira.py	Wed Dec 21 11:33:19 2011 -0500
@@ -11,24 +11,6 @@
     sys.stderr.write(msg+"\n")
     sys.exit(err)
 
-def tcs_to_tabular(old, new):
-    in_handle = open(old, "rU")
-    out_handle = open(new, "w")
-    assert in_handle.readline() == "#TCS V1.0\n"
-    assert in_handle.readline() == "#\n"
-    assert in_handle.readline() == "# contig name          padPos  upadPos | B  Q | tcov covA covC covG covT cov* | qA qC qG qT q* |  S | Tags\n"
-    assert in_handle.readline() == "#\n"
-    out_handle.write("#%s\n" % "\t".join(["contig", "pasPos", "upadPos", "B", "Q",
-                                         "tcov", "covA", "covC", "covG", "covT", "cov*",
-                                         "qA", "qC", "qG", "qT", "q*", "S", "Tags"]))
-    for line in in_handle:
-        parts = line.rstrip("\n").split(None,22)
-        assert parts[3] == parts[6] == parts[13] == parts[19] == parts[21] == "|"
-        wanted = parts[:3] + parts[4:6]+parts[7:13]+parts[14:19]+parts[20:21]+parts[22:]
-        out_handle.write("%s\n" % "\t".join(wanted))
-    out_handle.close()
-    in_handle.close()
-
 def collect_output(temp, name):
     n3 = (temp, name, name, name)
     f = "%s/%s_assembly/%s_d_results" % (temp, name, name)
@@ -36,16 +18,18 @@
         stop_err("Missing output folder")
     if not os.listdir(f):
         stop_err("Empty output folder")
+    missing = []
     for old, new in [("%s/%s_out.unpadded.fasta" % (f, name), out_fasta),
                      ("%s/%s_out.unpadded.fasta.qual" % (f, name), out_qual),
                      ("%s/%s_out.wig" % (f, name), out_wig),
                      ("%s/%s_out.caf" % (f, name), out_caf),
                      ("%s/%s_out.ace" % (f, name), out_ace)]:
         if not os.path.isfile(old):
-            stop_err("Missing %s output file" % os.path.splitext(old)[-1])
+            missing.append(os.path.splitext(old)[-1])
         else:
             shutil.move(old, new)
-    tcs_to_tabular("%s/%s_assembly/%s_d_results/%s_out.tcs" % n3, out_tcs)
+    if missing:
+        stop_err("Missing output files: %s" % ", ".join(missing))
 
 def clean_up(temp, name):
     folder = "%s/%s_assembly" % (temp, name)
@@ -56,14 +40,15 @@
 #Currently Galaxy puts us somewhere safe like:
 #/opt/galaxy-dist/database/job_working_directory/846/
 temp = "."
-name, out_fasta, out_qual, out_tcs, out_ace, out_caf, out_wig, out_log = sys.argv[1:9]
+name, out_fasta, out_qual, out_ace, out_caf, out_wig, out_log = sys.argv[1:8]
 
 start_time = time.time()
-cmd = " ".join(sys.argv[9:])
+cmd_list =sys.argv[8:]
+cmd = " ".join(cmd_list)
 
 assert os.path.isdir(temp)
 d = "%s_assembly" % name
-assert not os.path.isdir(d)
+assert not os.path.isdir(d), "Path %s already exists" % d
 try:
     #Check path access
     os.mkdir(d)
@@ -77,7 +62,7 @@
 handle = open(out_log, "w")
 try:
     #Run MIRA
-    child = subprocess.Popen(sys.argv[9:],
+    child = subprocess.Popen(cmd_list,
                              stdout=handle,
                              stderr=subprocess.STDOUT)
 except Exception, err:
@@ -102,6 +87,10 @@
              return_code)
 handle.close()
 
+#print "Collecting output..."
 collect_output(temp, name)
+
+#print "Cleaning up..."
 clean_up(temp, name)
+
 print "Done"
--- a/tools/sr_assembly/mira.txt	Tue Jun 21 09:50:32 2011 -0400
+++ b/tools/sr_assembly/mira.txt	Wed Dec 21 11:33:19 2011 -0500
@@ -7,7 +7,7 @@
 
 This tool is a short Python script (to collect the MIRA output and move it
 to where Galaxy expects the files, and convert MIRA's TCS file into a tab
-separate file for use in Galaxy). There are just two files to install:
+separated file for use in Galaxy). There are just two files to install:
 
 * mira.py (the Python script)
 * mira.xml (the Galaxy tool definition)
@@ -16,9 +16,9 @@
 modify the tools_conf.xml file to tell Galaxy to offer the tool and also do
 this to tools_conf.xml.sample in order to run any tests:
 
-<tool file="sr_assembly/seq_primer_clip.xml" />
+<tool file="sr_assembly/mira.xml" />
 
-You will also need to install MIRA, we used version 3.2.1. See:
+You will also need to install MIRA, we used version 3.4.0. See:
 
 http://chevreux.org/projects_mira.html
 http://sourceforge.net/projects/mira-assembler/
@@ -33,8 +33,13 @@
 History
 =======
 
-v0.0.1 - Initial version (working prototype)
+v0.0.1 - Initial version (working prototype, using MIRA 3.2.1)
 v0.0.2 - Improve capture of stdout/stderr (should see it as it runs)
+v0.0.3 - Support Ion Torrent reads, now requires MIRA 3.4.0 or later
+         (some other switched changed, e.g. -OUT rrol to rrot, which
+         means the wrapper no longer works with MIRA 3.2.x)
+       - The contig summary file (TCS file) was removed in MIRA 3.4
+       - Report all missing output files (not just first missing one)
 
 
 Developers
--- a/tools/sr_assembly/mira.xml	Tue Jun 21 09:50:32 2011 -0400
+++ b/tools/sr_assembly/mira.xml	Wed Dec 21 11:33:19 2011 -0500
@@ -1,40 +1,46 @@
-<tool id="mira_assembler" name="Assemble with MIRA" version="0.0.2">
-    <description>Takes Sanger, Roche, and Illumina data</description>
-	<command interpreter="python">mira.py mira $out_fasta $out_qual $out_tcs $out_ace $out_caf $out_wig $out_log
+<tool id="mira_assembler" name="Assemble with MIRA" version="0.0.3">
+    <description>Takes Sanger, Roche, Illumina, and Ion Torrent data</description>
+	<command interpreter="python">mira.py mira $out_fasta $out_qual $out_ace $out_caf $out_wig $out_log
 ##Give the wrapper script list of output filenames, then the mira command...
 mira --job=$job_method,$job_type,$job_quality
 
 ##Input files
 #if $condBackbone.use == "true":
     ## Can this be linked to job_method as well? If mapping we need the backbone...
-    -SB:lb=yes -SB:bft=fasta -FN:bbin=${condBackbone.filename}
+    -SB:lb=1:bft=1 -FN:bbin=${condBackbone.filename}
 #end if
 #if $condSanger.use == "true":
-    Sanger_SETTINGS
-    ## Not easy to add sanger to --job, so use load_sequence_data(lsd) instead
-    -LR:lsd=yes
+    SANGER_SETTINGS
+    ## Not easy in Galaxy to add sanger to --job, so use load_sequence_data(lsd) instead
     ## I expect hard trimmed FASTQ files with no NCBI traceinfo XML file
-    -LR:mxti=no -LR:ft=fastq -FN:fqi=${condSanger.filename}
+    -LR:lsd=1:mxti=0:ft=fastq -FN:fqi=${condSanger.filename}
 #end if
 #if $condRoche.use == "true":
     454_SETTINGS
-    ## Not easy to add 454 to --job, so use load_sequence_data(lsd) instead
-    -LR:lsd=yes
+    ## Not easy in Galaxy to add 454 to --job, so use load_sequence_data(lsd) instead
     ## I expect hard trimmed FASTQ files with no NCBI traceinfo XML file
-    -LR:mxti=no -LR:ft=fastq -FN:fqi=${condRoche.filename}
+    -LR:lsd=1:mxti=0:ft=fastq -FN:fqi=${condRoche.filename}
 #end if
 #if $condIllumina.use == "true":
     SOLEXA_SETTINGS
-    ## Not easy to add solexa to --job, so use load_sequence_data(lsd) instead
-    -LR:lsd=yes -LR:ft=fastq -FN:fgi=${condIllumina.filename}
+    ## Not easy in Galaxy to add solexa to --job, so use load_sequence_data(lsd) instead
+    -LR:lsd=1:ft=fastq -FN:fqi=${condIllumina.filename}
     ##TODO - Look at -LR FASTQ qual offset (fqqo)
 #end if
-
+#if $condIonTorrent.use == "true":
+    IONTOR_SETTINGS
+    ## Not easy in Galaxy to add iontor to --job, so use load_sequence_data(lsd) instead
+    ## I expect hard trimmed FASTQ files with no NCBI traceinfo XML file
+    -LR:lsd=1:mxti=0:ft=fastq -FN:fqi=${condIonTorrent.filename}
+#end if
 
 ##Output files
 COMMON_SETTINGS
-##remove_rollover_logs, remove_log_directory
--OUT:rrol=yes -OUT:rld=yes
+##Explicitly request the FASTA (+QUAL), CAF, ACE, WIG output
+##Explicitly disable formats we won't use like MAF (reduce IO)
+-OUT:orf=1:orc=1:ora=1:orw=1:orm=0:org=0:ors=0
+##remove_rollover_tmps, remove_tmp_directory
+-OUT:rrot=1:rtd=1
 
     </command>
 	<inputs>
@@ -47,9 +53,9 @@
             <option value="est">EST (transcriptome)</option>
         </param>
         <param name="job_quality" type="select" label="Assembly quality grade">
-            <option value="normal">Normal</option>
+            <option value="accurate">Accurate</option>
+            <option value="normal">Normal (deprecated)</option>
             <option value="draft">Draft</option>
-            <option value="accurate">Accurate</option>
         </param>
         <!-- Backbone -->
         <conditional name="condBackbone">
@@ -82,7 +88,8 @@
            </param>
            <when value="false" />
            <when value="true">
-              <param name="filename" type="data" format="fastq,sff" label="Roche 454 reads file" help="FASTQ format" />
+              <!-- TODO? Support SFF files directly, e.g. with sff_extract, but will need linker sequences -->
+              <param name="filename" type="data" format="fastq" label="Roche 454 reads file" help="FASTQ format" />
            </when>
         </conditional>
         <!-- Illumina -->
@@ -96,11 +103,22 @@
               <param name="filename" type="data" format="fastq" label="Solexa/Illumina reads file" help="FASTQ format" />
            </when>
         </conditional>
+        <!-- Ion Torrent -->
+        <conditional name="condIonTorrent">
+           <param name="use" type="select" label="Ion Torrent reads?">
+               <option value="false">No</option>
+               <option value="true">Yes</option>
+           </param>
+           <when value="false" />
+           <when value="true">
+              <!-- TODO? Support SFF files directly, e.g. with sff_extract -->
+              <param name="filename" type="data" format="fastq" label="Ion Torrent reads file" help="FASTQ format" />
+           </when>
+        </conditional>
 	</inputs>
 	<outputs>
 	    <data name="out_fasta" format="fasta" label="MIRA contigs (FASTA)" />
 	    <data name="out_qual" format="qual454" label="MIRA contigs (QUAL)" />
-	    <data name="out_tcs" format="tabular" label="MIRA contigs summary" />
 	    <data name="out_caf" format="txt" label="MIRA contigs (CAF)" />
 	    <data name="out_ace" format="txt" label="MIRA contigs (ACE)" />
 	    <data name="out_wig" format="wig" label="MIRA coverage (Wiggle)" />
@@ -117,9 +135,6 @@
 
 Runs MIRA v3, collects the output, and throws away all the temporary files.
 
-The MIRA transposed contig summary (TCS) file is converted into a tabular file for use within Galaxy.
-This records one line per base per contig, and including things like the base, quality, coverage and any tags.
-
 **Citation**
 
 This tool uses MIRA. If you use this tool in scientific work leading to a