changeset 19:30caca800c9b draft

Uploaded
author bgruening
date Thu, 14 Aug 2014 04:46:12 -0400
parents 862fb59a9a25
children 0895fe70075d
files bismark_bowtie2_wrapper.xml bismark_bowtie_wrapper.xml bismark_methylation_extractor.xml bismark_wrapper.py tool_dependencies.xml
diffstat 5 files changed, 86 insertions(+), 59 deletions(-) [+]
line wrap: on
line diff
--- a/bismark_bowtie2_wrapper.xml	Mon Apr 14 16:42:38 2014 -0400
+++ b/bismark_bowtie2_wrapper.xml	Thu Aug 14 04:46:12 2014 -0400
@@ -7,14 +7,19 @@
         <requirement type="package" version="0.1.19">samtools</requirement>
         <requirement type="package" version="2.1.0">bowtie2</requirement>
     </requirements>
-    <parallelism method="basic"></parallelism>
+    <stdio>
+        <exit_code range="1:" />
+        <exit_code range=":-1" />
+        <regex match="Error:" />
+        <regex match="Exception:" />
+    </stdio>
     <command interpreter="python">
         bismark_wrapper.py
         
         ## Change this to accommodate the number of threads you have available.
         --num-threads "\${GALAXY_SLOTS:-24}"
 
-        --bismark_path \$SCRIPT_PATH
+        ##--bismark_path \$SCRIPT_PATH
 
         --bowtie2
 
@@ -34,7 +39,6 @@
         ##  Input parameters
         ##
 
-
         #if $singlePaired.sPaired == "single":
             --single-paired $singlePaired.input_singles
 
@@ -58,14 +62,17 @@
             --mate1 #echo ','.join($mate1)
             --mate2 #echo ','.join($mate2)
 
-            #if $singlePaired.mate_list[0].input_mate1.ext == "fastqillumina":
-                --phred64-quals
-                --fastq
-            #elif $singlePaired.mate_list[0].input_mate1.ext == "fastqsanger":
-                --fastq
-            #elif $singlePaired.mate_list[0].input_mate1.ext == "fasta":
-                --fasta
-            #end if
+            #for $mate_pair in $singlePaired.mate_list:
+                #if $mate_pair.input_mate1.ext == "fastqillumina":
+                    --phred64-quals
+                    --fastq
+                #elif $mate_pair.input_mate1.ext == "fastqsanger":
+                    --fastq
+                #elif $mate_pair.input_mate1.ext == "fasta":
+                    --fasta
+                #end if
+                #break
+            #end for
 
             -I $singlePaired.minInsert
             -X $singlePaired.maxInsert
@@ -275,18 +282,22 @@
             </action>
           </when>
           <when value="paired">
-            <action type="format">
+            <!--action type="format">
               <option type="from_param" name="singlePaired.mate_list[0].input_mate1" param_attribute="ext" />
-            </action>
+            </action-->
           </when>
         </conditional>
       </actions>
     </data>
 
     <data format="fastq" name="output_suppressed_reads_r" label="${tool.name} on ${on_string}: suppressed reads (R)">
-      <filter>singlePaired['sPaired'] == "paired"</filter>
-      <filter>params['settingsType'] == "custom"</filter>
-      <filter>params['supressed_read_file'] is True</filter>
+      <filter>
+        ((
+            singlePaired['sPaired'] == "paired" and
+          params['settingsType'] == "custom" and
+          params['suppressed_read_file'] is True
+        ))
+      </filter>
       <actions>
         <conditional name="singlePaired.sPaired">
           <when value="single">
@@ -295,9 +306,9 @@
             </action>
           </when>
           <when value="paired">
-            <action type="format">
+            <!--action type="format">
               <option type="from_param" name="singlePaired.mate_list[0].input_mate1" param_attribute="ext" />
-            </action>
+            </action-->
           </when>
         </conditional>
       </actions>
@@ -319,18 +330,22 @@
             </action>
           </when>
           <when value="paired">
-            <action type="format">
+            <!--action type="format">
               <option type="from_param" name="singlePaired.mate_list[0].input_mate1" param_attribute="ext" />
-            </action>
+            </action-->
           </when>
         </conditional>
       </actions>
     </data>
 
     <data format="fastq" name="output_unmapped_reads_r" label="${tool.name} on ${on_string}: unmapped reads (R)">
-      <filter>singlePaired['sPaired'] == "paired"</filter>
-      <filter>params['settingsType'] == "custom"</filter>
-      <filter>params['unmapped_read_file'] is True</filter>
+      <filter>
+        ((
+            singlePaired['sPaired'] == "paired" and
+          params['settingsType'] == "custom" and
+          params['unmapped_read_file'] is True
+        ))
+      </filter>
       <actions>
         <conditional name="singlePaired.sPaired">
           <when value="single">
@@ -339,9 +354,9 @@
             </action>
           </when>
           <when value="paired">
-            <action type="format">
+            <!--action type="format">
               <option type="from_param" name="singlePaired.mate_list[0].input_mate1" param_attribute="ext" />
-            </action>
+            </action-->
           </when>
         </conditional>
       </actions>
@@ -641,4 +656,7 @@
                          always used and its default value is set to 10.
 
   </help>
+  <citations>
+      <citation type="doi">10.1093/bioinformatics/btr167</citation>
+  </citations>
 </tool>
--- a/bismark_bowtie_wrapper.xml	Mon Apr 14 16:42:38 2014 -0400
+++ b/bismark_bowtie_wrapper.xml	Thu Aug 14 04:46:12 2014 -0400
@@ -7,11 +7,16 @@
         <requirement type="package" version="0.1.19">samtools</requirement>
         <requirement type="package" version="0.12.8">bowtie</requirement>
     </requirements>
-    <parallelism method="basic"></parallelism>
+    <stdio>
+        <exit_code range="1:" />
+        <exit_code range=":-1" />
+        <regex match="Error:" />
+        <regex match="Exception:" />
+    </stdio>
     <command interpreter="python">
         bismark_wrapper.py
 
-        --bismark_path \$SCRIPT_PATH
+        ##--bismark_path \$SCRIPT_PATH
 
         ##
         ## Bismark Genome Preparation, if desired.
@@ -53,14 +58,17 @@
             --mate1 #echo ','.join($mate1)
             --mate2 #echo ','.join($mate2)
 
-            #if $singlePaired.mate_list[0].input_mate1.ext == "fastqillumina":
-                --phred64-quals
-                --fastq
-            #elif $singlePaired.mate_list[0].input_mate1.ext == "fastqsanger":
-                --fastq
-            #elif $singlePaired.mate_list[0].input_mate1.ext == "fasta":
-                --fasta
-            #end if
+            #for $mate_pair in $singlePaired.mate_list:
+                #if $mate_pair.input_mate1.ext == "fastqillumina":
+                    --phred64-quals
+                    --fastq
+                #elif $mate_pair.input_mate1.ext == "fastqsanger":
+                    --fastq
+                #elif $mate_pair.input_mate1.ext == "fasta":
+                    --fasta
+                #end if
+                #break
+            #end for
 
             -I $singlePaired.minInsert
             -X $singlePaired.maxInsert
@@ -251,9 +259,9 @@
             </action>
           </when>
           <when value="paired">
-            <action type="format">
+            <!--action type="format">
               <option type="from_param" name="singlePaired.mate_list[0].input_mate1" param_attribute="ext" />
-            </action>
+            </action-->
           </when>
         </conditional>
       </actions>
@@ -271,9 +279,9 @@
             </action>
           </when>
           <when value="paired">
-            <action type="format">
+            <!--action type="format">
               <option type="from_param" name="singlePaired.mate_list[0].input_mate1" param_attribute="ext" />
-            </action>
+            </action-->
           </when>
         </conditional>
       </actions>
@@ -295,9 +303,9 @@
             </action>
           </when>
           <when value="paired">
-            <action type="format">
+            <!--action type="format">
               <option type="from_param" name="singlePaired.mate_list[0].input_mate1" param_attribute="ext" />
-            </action>
+            </action-->
           </when>
         </conditional>
       </actions>
@@ -314,15 +322,13 @@
             </action>
           </when>
           <when value="paired">
-            <action type="format">
+            <!--action type="format">
               <option type="from_param" name="singlePaired.mate_list[0].input_mate1" param_attribute="ext" />
-            </action>
+            </action-->
           </when>
         </conditional>
       </actions>
     </data>
-        
-        
     </outputs>
 
     <tests>
@@ -547,4 +553,7 @@
                          temporary folder can be either relative or absolute.
 
   </help>
+  <citations>
+      <citation type="doi">10.1093/bioinformatics/btr167</citation>
+  </citations>
 </tool>
--- a/bismark_methylation_extractor.xml	Mon Apr 14 16:42:38 2014 -0400
+++ b/bismark_methylation_extractor.xml	Thu Aug 14 04:46:12 2014 -0400
@@ -13,7 +13,7 @@
 
         --infile $input
 
-        --bismark_path \$SCRIPT_PATH
+        #--bismark_path \$SCRIPT_PATH
 
         #if $singlePaired.sPaired == "single":
             --single-end
--- a/bismark_wrapper.py	Mon Apr 14 16:42:38 2014 -0400
+++ b/bismark_wrapper.py	Thu Aug 14 04:46:12 2014 -0400
@@ -17,7 +17,6 @@
 
 def __main__():
 
-    print 'tempfile_location',tempfile.gettempdir()
     #Parse Command Line
     parser = argparse.ArgumentParser(description='Wrapper for the bismark bisulfite mapper.')
     parser.add_argument( '-p', '--num-threads', dest='num_threads',
@@ -258,9 +257,6 @@
 
     # Final bismark command:
     cmd = cmd % arguments
-    print 'bismark_cmd:', cmd
-    #sys.stderr.write( cmd )
-    #sys.exit(1)
     # Run
     try:
         tmp_out = tempfile.NamedTemporaryFile().name
@@ -321,8 +317,8 @@
         """
         #tmp_out = tempfile.NamedTemporaryFile( dir=output_dir ).name
         tmp_stdout = open( tmp_out, 'wab' )
-        tmp_err = tempfile.NamedTemporaryFile( dir=output_dir ).name
-        tmp_stderr = open( tmp_err, 'wb' )
+        #tmp_err = tempfile.NamedTemporaryFile( dir=output_dir ).name
+        tmp_stderr = open( tmp_err, 'wab' )
 
         tmp_res = tempfile.NamedTemporaryFile( dir= output_dir).name
 
@@ -338,18 +334,22 @@
             if returncode != 0:
                 raise Exception, open( tmp_stderr.name ).read()
         else:
-	    tmp_res = bam_files[0]
+            tmp_res = bam_files[0]
 
         bam_path = "%s" % tmp_res
 
         if os.path.exists( bam_path ):
-	    if args.sort_bam:
-                cmd = 'samtools sort -@ %s %s %s' % (args.num_threads, bam_path, args.output) 
-	    else:
-                shutil.copy( bam_path, args.output )
+            if args.sort_bam:
+                cmd = 'samtools sort -@ %s %s sorted_bam' % (args.num_threads, bam_path)
+                proc = subprocess.Popen( args=shlex.split( cmd ) )
+                returncode = proc.wait()
+                if returncode != 0:
+                    raise Exception("Error during '%s'" % cmd)
+                shutil.move( 'sorted_bam.bam', args.output )
+            else:
+                shutil.move( bam_path, args.output )
         else:
             stop_err( 'BAM file no found:\n' + str( bam_path ) )
-		
 
 
     # TODO: look for errors in program output.
--- a/tool_dependencies.xml	Mon Apr 14 16:42:38 2014 -0400
+++ b/tool_dependencies.xml	Thu Aug 14 04:46:12 2014 -0400
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
 <tool_dependency>
     <package name="samtools" version="0.1.19">
-        <repository changeset_revision="36aa94676939" name="package_samtools_0_1_19" owner="iuc" toolshed="http://testtoolshed.g2.bx.psu.edu" />
+        <repository changeset_revision="632f1a03db92" name="package_samtools_0_1_19" owner="iuc" toolshed="https://testtoolshed.g2.bx.psu.edu" />
     </package>
     <set_environment version="1.0">
         <environment_variable action="set_to" name="SCRIPT_PATH">$REPOSITORY_INSTALL_DIR</environment_variable>