Hello Alexander

I've made some changes to our local copy of the bowtie tool files (bowtie_wrapper.xml and bowtie_wrapper.py) to give the option of capturing bowtie's stderr output and adding it as an additional history item (here the statistics in this output is used as input to a local tool).


I've attached patches to the tool in case they're any use to you.

(As an aside and more generally: I'm not sure how to manage these local customisations in the longer term - what do other people on this list do?)

HTH, best wishes, Peter

On 25/02/13 11:29, Alexander Kurze wrote:
Hello,

I am using the bowtie-wrapper on my locally installed galaxy server to
align reads. However I missing the stats read-out. Is there any
possibility to include statistics about unaligned reads?

If I use bowtie vi comman line I get following output:


bowtie ~/dm3 -v 2 -k 5 --best --strata -S -t reads.fastq reads.sam
End-to-end 2/3-mismatch full-index search: 01:00:21
# reads processed: 12084153
# reads with at least one reported alignment: 9391748 (77.72%)
# reads that failed to align: 2692405 (22.28%)
Reported 30293838 alignments to 1 output stream(s)


The output should be normally saved in the stderr but unfortunatly the
stderr is somehow deleted after the alignment job is done in bowtie
under galaxy.

Any idea how I can still access the stats?

Thanks,

Alex

--
Alexander Kurze, DPhil
University of Oxford
Department of Biochemistry
South Parks Road
Oxford, OX1 3QU
United Kingdom

Tel: +44 1865 613 230
Fax:+44 1865 613 341


___________________________________________________________
Please keep all replies on the list by using "reply all"
in your mail client.  To manage your subscriptions to this
and other Galaxy lists, please use the interface at:

   http://lists.bx.psu.edu/


--
Peter Briggs peter.bri...@manchester.ac.uk
Bioinformatics Core Facility University of Manchester
B.1083 Michael Smith Bldg Tel: (0161) 2751482


--- bowtie_wrapper.xml	2013-02-19 16:34:58.172013341 +0000
+++ bowtie_wrapper_fls.xml	2013-02-19 16:39:27.530434562 +0000
@@ -128,6 +128,9 @@
           --seed=$singlePaired.pParams.pSeed
         #end if
       #end if
+      #if $save_mapping_stats
+        --output_mapping_stats=$mapping_stats
+      #end if
   </command>
   <inputs>
     <conditional name="refGenomeSource">
@@ -329,6 +332,7 @@
         </conditional> <!-- pParams -->
       </when> <!-- paired -->
     </conditional> <!-- singlePaired -->
+    <param name="save_mapping_stats" type="boolean" truevalue="True" falsevalue="False" checked="False" label="Save the bowtie mapping statistics to the history" />
     <param name="suppressHeader" type="boolean" truevalue="true" falsevalue="false" checked="False" label="Suppress the header in the output SAM file" help="Bowtie produces SAM with several lines of header information by default" />
   </inputs>
   <outputs>
@@ -351,6 +355,9 @@
         </conditional>
       </actions>
     </data>
+    <data format="txt" name="mapping_stats" label="${tool.name} on ${on_string}: mapping stats">
+      <filter>save_mapping_stats is True</filter>
+    </data>
     <data format="fastq" name="output_suppressed_reads_l" label="${tool.name} on ${on_string}: suppressed reads (L)">
       <filter>((
           singlePaired['sPaired'] == "single" and
@@ -662,6 +669,8 @@
 
   <help>
 
+**This version of the Bowtie for Illumina tool has been customised from the official Galaxy version**
+
 **What it does**
 
 Bowtie_ is a short read aligner designed to be ultrafast and memory-efficient. It is developed by Ben Langmead and Cole Trapnell. Please cite: Langmead B, Trapnell C, Pop M, Salzberg SL. Ultrafast and memory-efficient alignment of short DNA sequences to the human genome. Genome Biology 10:R25.
--- bowtie_wrapper.py	2013-02-19 16:34:53.106967735 +0000
+++ bowtie_wrapper_fls.py	2013-02-19 14:21:17.839938788 +0000
@@ -13,6 +13,7 @@
     --output_suppressed_reads=: File name for suppressed reads because of max setting (single-end)
     --output_suppressed_reads_l=: File name for suppressed reads because of max setting (left, paired-end)
     --output_suppressed_reads_r=: File name for suppressed reads because of max setting (right, paired-end)
+    --output_mapping_stats=: File name for mapping statistics (output on stderr by bowtie)
     -i, --input1=i: The (forward or single-end) reads file in Sanger FASTQ format
     -I, --input2=I: The reverse reads file in Sanger FASTQ format
     -4, --dataType=4: The type of data (SOLiD or Solexa)
@@ -87,6 +88,7 @@
     parser.add_option( '', '--output_suppressed_reads', dest='output_suppressed_reads', help='File name for suppressed reads because of max setting (single-end)' )
     parser.add_option( '', '--output_suppressed_reads_l', dest='output_suppressed_reads_l', help='File name for suppressed reads because of max setting (left, paired-end)' )
     parser.add_option( '', '--output_suppressed_reads_r', dest='output_suppressed_reads_r', help='File name for suppressed reads because of max setting (right, paired-end)' )
+    parser.add_option( '', '--output_mapping_stats', dest='output_mapping_stats', help='File for mapping statistics (i.e. stderr from bowtie)' )
     parser.add_option( '-4', '--dataType', dest='dataType', help='The type of data (SOLiD or Solexa)' )
     parser.add_option( '-i', '--input1', dest='input1', help='The (forward or single-end) reads file in Sanger FASTQ format' )
     parser.add_option( '-I', '--input2', dest='input2', help='The reverse reads file in Sanger FASTQ format' )
@@ -418,7 +420,7 @@
             # align
             tmp = tempfile.NamedTemporaryFile( dir=tmp_index_dir ).name
             tmp_stderr = open( tmp, 'wb' )
-            proc = subprocess.Popen( args=cmd2, shell=True, cwd=tmp_index_dir, stderr=tmp_stderr.fileno() )
+            proc = subprocess.Popen( args=cmd2, shell=True, cwd=tmp_index_dir, stdout=sys.stdout, stderr=tmp_stderr.fileno() )
             returncode = proc.wait()
             tmp_stderr.close()
             # get stderr, allowing for case where it's very large
@@ -435,6 +437,11 @@
             tmp_stderr.close()
             if returncode != 0:
                 raise Exception, stderr
+            elif options.output_mapping_stats is not None:
+                # Write stderr (containing the mapping statistics) to a named file
+                mapping_stats = open( options.output_mapping_stats, 'w')
+                mapping_stats.write( stderr )
+                mapping_stats.close()
             # get suppressed and unmapped reads output files in place if appropriate
             if options.paired == 'paired' and tmp_suppressed_file_name and \
                                options.output_suppressed_reads_l and options.output_suppressed_reads_r:
@@ -463,6 +470,7 @@
         # clean up temp dir
         if os.path.exists( tmp_index_dir ):
             shutil.rmtree( tmp_index_dir )
+    stdout += "Ran %s\n" % cmd2
     stdout += 'Sequence file aligned.\n'
     sys.stdout.write( stdout )
 
___________________________________________________________
Please keep all replies on the list by using "reply all"
in your mail client.  To manage your subscriptions to this
and other Galaxy lists, please use the interface at:

  http://lists.bx.psu.edu/

Reply via email to