diff samtools_stats.xml @ 1:cc56fc603e53 draft

planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
author devteam
date Tue, 13 Oct 2015 12:56:27 -0400
parents cd6eb75c9819
children 45c568e7f1f9
line wrap: on
line diff
--- a/samtools_stats.xml	Mon Oct 20 14:56:49 2014 -0400
+++ b/samtools_stats.xml	Tue Oct 13 12:56:27 2015 -0400
@@ -1,9 +1,11 @@
-<tool id="samtools_stats" name="Generate statistics" version="1.0.0">
-    <description>for a BAM or SAM file</description>
-    <requirements>
-        <requirement type="package" version="1.1">samtools</requirement>
-    </requirements>
-    <version_command>samtools --version | head -n 1 | awk '{ print $2 }'</version_command>
+<tool id="samtools_stats" name="Stats" version="2.0">
+    <description>generate statistics for BAM dataset</description>
+    <macros>
+    <import>macros.xml</import>
+  </macros>
+    <expand macro="requirements"></expand>
+    <expand macro="stdio"></expand>
+    <expand macro="version_command"></expand>
     <command><![CDATA[
         #if $use_reference.use_ref_selector == "yes":
             #if $use_reference.reference_source.reference_source_selector == "history":
@@ -27,6 +29,14 @@
         #end if
         --GC-depth ${gc_depth}
         --insert-size ${insert_size}
+
+        ## The code below is commented out because using -I/--id options causes the following exception
+        ## Samtools-htslib: init_group_id() header parsing not yet implemented
+
+        ##if str($read_group) != "":
+        ##    -I "${read_group}"
+        ##end if
+
         #if str($read_length) != "0":
             --read-length "${read_length}"
         #end if
@@ -43,60 +53,88 @@
         #if $split_output.split_output_selector == "yes":
             #set outputs_to_split = str($split_output.generate_tables).split(',')
             && mkdir split && echo ${split_output.generate_tables} &&
+
             #if 'sn' in $outputs_to_split:
-                grep -q ^SN  "${output}" ; if [ $? = 0 ] ; then grep ^SN  "${output}" | cut -f 2- > "split/Summary numbers.tab"  ; fi &&
+                echo "# Summary Numbers\n"  > "split/Summary numbers.tab" &&
+                grep -q ^SN  "${output}" ; if [ $? = 0 ] ; then grep ^SN  "${output}" | cut -f 2- >> "split/Summary numbers.tab"  ; fi &&
             #end if
+
             #if 'ffq' in $outputs_to_split:
-                grep -q ^FFQ "${output}" ; if [ $? = 0 ] ; then grep ^FFQ "${output}" | cut -f 2- > "split/First Fragment Qualities.tab" ; fi &&
+                echo "# Columns correspond to qualities and rows to cycles. First column is the cycle number\n" > "split/First Fragment Qualities.tab" &&
+                grep -q ^FFQ "${output}" ; if [ $? = 0 ] ; then grep ^FFQ "${output}" | cut -f 2- >> "split/First Fragment Qualities.tab" ; fi &&
             #end if
+
             #if 'lfq' in $outputs_to_split:
-                grep -q ^LFQ "${output}" ; if [ $? = 0 ] ; then grep ^LFQ "${output}" | cut -f 2- > "split/Last Fragment Qualities.tab" ; fi &&
+                echo "# Columns correspond to qualities and rows to cycles. First column is the cycle number" > "split/Last Fragment Qualities.tab" &&
+                grep -q ^LFQ "${output}" ; if [ $? = 0 ] ; then grep ^LFQ "${output}" | cut -f 2- >> "split/Last Fragment Qualities.tab" ; fi &&
             #end if
+
             #if 'mpc' in $outputs_to_split:
-                grep -q ^MPC "${output}" ; if [ $? = 0 ] ; then grep ^MPC "${output}" | cut -f 2- > "split/Mismatches per cycle.tab" ; fi &&
+                echo "# Columns correspond to qualities, rows to cycles. First column is the cycle number, second is the number of N's and the rest is the number of mismatches" > "split/Mismatches per cycle.tab" &&
+                grep -q ^MPC "${output}" ; if [ $? = 0 ] ; then grep ^MPC "${output}" | cut -f 2- >> "split/Mismatches per cycle.tab" ; fi &&
             #end if
+
             #if 'gcf' in $outputs_to_split:
-                grep -q ^GCF "${output}" ; if [ $? = 0 ] ; then grep ^GCF "${output}" | cut -f 2- > "split/GC Content of first fragments.tab" ; fi &&
+                echo "# GC Content of first fragments" > "split/GC Content of first fragments.tab" &&
+                grep -q ^GCF "${output}" ; if [ $? = 0 ] ; then grep ^GCF "${output}" | cut -f 2- >> "split/GC Content of first fragments.tab" ; fi &&
             #end if
+
             #if 'gcl' in $outputs_to_split:
-                grep -q ^GCL "${output}" ; if [ $? = 0 ] ; then grep ^GCL "${output}" | cut -f 2- > "split/GC Content of last fragments.tab" ; fi &&
+                echo "# GC Content of last fragments" > "split/GC Content of last fragments.tab" &&
+                grep -q ^GCL "${output}" ; if [ $? = 0 ] ; then grep ^GCL "${output}" | cut -f 2- >> "split/GC Content of last fragments.tab" ; fi &&
             #end if
+
             #if 'gcc' in $outputs_to_split:
-                grep -q ^GCC "${output}" ; if [ $? = 0 ] ; then grep ^GCC "${output}" | cut -f 2- > "split/ACGT content per cycle.tab" ; fi &&
+                echo "# ACGT content per cycle. The columns are: cycle, and A,C,G,T counts (percent)" > "split/ACGT content per cycle.tab" &&
+                grep -q ^GCC "${output}" ; if [ $? = 0 ] ; then grep ^GCC "${output}" | cut -f 2- >> "split/ACGT content per cycle.tab" ; fi &&
             #end if
+
             #if 'is' in $outputs_to_split:
-                grep -q ^IS  "${output}" ; if [ $? = 0 ] ; then grep ^IS  "${output}" | cut -f 2- > "split/Insert sizes.tab"  ; fi &&
+                echo "# Insert sizes. The columns are: insert size, pairs total, inward oriented pairs, outward oriented pairs, other pairs" > "split/Insert sizes.tab" &&
+                grep -q ^IS  "${output}" ; if [ $? = 0 ] ; then grep ^IS  "${output}" | cut -f 2- >> "split/Insert sizes.tab"  ; fi &&
             #end if
+
             #if 'rl' in $outputs_to_split:
-                grep -q ^RL  "${output}" ; if [ $? = 0 ] ; then grep ^RL  "${output}" | cut -f 2- > "split/Read lengths.tab"  ; fi &&
+                echo "# Read lengths. The columns are: read length, count" > "split/Read lengths.tab" &&
+                grep -q ^RL  "${output}" ; if [ $? = 0 ] ; then grep ^RL  "${output}" | cut -f 2- >> "split/Read lengths.tab"  ; fi &&
             #end if
+
             #if 'id' in $outputs_to_split:
-                grep -q ^ID  "${output}" ; if [ $? = 0 ] ; then grep ^ID  "${output}" | cut -f 2- > "split/Indel distribution.tab"  ; fi &&
+                echo "# Indel distribution. The columns are: length, number of insertions, number of deletions" > "split/Indel distribution.tab" &&
+                grep -q ^ID  "${output}" ; if [ $? = 0 ] ; then grep ^ID  "${output}" | cut -f 2- >> "split/Indel distribution.tab"  ; fi &&
             #end if
+
             #if 'ic' in $outputs_to_split:
-                grep -q ^IC  "${output}" ; if [ $? = 0 ] ; then grep ^IC  "${output}" | cut -f 2- > "split/Indels per cycle.tab"  ; fi &&
+                echo "# Indels per cycle. The columns are: cycle, number of insertions (fwd), .. (rev) , number of deletions (fwd), .. (rev)" >  "split/Indels per cycle.tab"  &&
+                grep -q ^IC  "${output}" ; if [ $? = 0 ] ; then grep ^IC  "${output}" | cut -f 2- >> "split/Indels per cycle.tab"  ; fi &&
             #end if
+
             #if 'cov' in $outputs_to_split:
-                grep -q ^COV "${output}" ; if [ $? = 0 ] ; then grep ^COV "${output}" | cut -f 2- > "split/Coverage distribution.tab" ; fi &&
+                echo "# Coverage distribution" > "split/Coverage distribution.tab" &&
+                grep -q ^COV "${output}" ; if [ $? = 0 ] ; then grep ^COV "${output}" | cut -f 2- >> "split/Coverage distribution.tab" ; fi &&
             #end if
+
             #if 'gcd' in $outputs_to_split:
-                grep -q ^GCD "${output}" ; if [ $? = 0 ] ; then grep ^GCD "${output}" | cut -f 2- > "split/GC depth.tab" ; fi
+                echo "# GC-depth. The columns are: GC%, unique sequence percentiles, 10th, 25th, 50th, 75th and 90th depth percentile" > "split/GC depth.tab" &&
+                grep -q ^GCD "${output}" ; if [ $? = 0 ] ; then grep ^GCD "${output}" | cut -f 2- >> "split/GC depth.tab" ; fi &&
             #end if
+
+            ## Unix true command below
+
+            true
+
         #end if
         ]]></command>
-    <stdio>
-        <exit_code range="1:" level="fatal" description="Error" />
-    </stdio>
     <inputs>
         <param name="input_file" type="data" format="sam,bam" label="BAM file" />
-        <param name="coverage_min" type="integer" value="1" label="Minimum coverage" />
-        <param name="coverage_max" type="integer" value="1000" label="Maximum coverage" />
-        <param name="coverage_step" type="integer" value="1" label="Coverage step" />
-        <param name="remove_dups" type="boolean" truevalue="--remove-dups" falsevalue="" checked="False" label="Exclude reads marked as duplicates" />
+        <param name="coverage_min" type="integer" value="1" label="Minimum coverage" help="minimum coverage value for --coverage option"/>
+        <param name="coverage_max" type="integer" value="1000" label="Maximum coverage" help="maximum coverage value for --coverage option"/>
+        <param name="coverage_step" type="integer" value="1" label="Coverage step" help="step value for --coverage option"/>
+        <param name="remove_dups" type="boolean" truevalue="--remove-dups" falsevalue="" checked="False" label="Exclude reads marked as duplicates" help="--remove-dups; default = False"/>
         <conditional name="split_output">
-            <param name="split_output_selector" type="select" label="Output">
-                <option value="no" selected="True">Output to a summary file</option>
-                <option value="yes">Extract separate statistics</option>
+            <param name="split_output_selector" type="select" label="Output" help="Select between a single output or separate outputs for each statistics">
+                <option value="no" selected="True">a single summary file</option>
+                <option value="yes">separate datasets for each statistics</option>
             </param>
             <when value="no" />
             <when value="yes">
@@ -118,12 +156,12 @@
             </when>
         </conditional>
         <conditional name="filter_by_flags">
-            <param name="filter_flags" type="select" label="Set filter by flags">
+            <param name="filter_flags" type="select" label="Set filter by flags" help="-f and -F options">
                 <option value="nofilter" selected="True">Do not filter</option>
                 <option value="filter">Filter by flags to exclude or require</option>
             </param>
             <when value="filter">
-                <param name="require_flags" type="select" display="checkboxes" multiple="True" label="Require">
+                <param name="require_flags" type="select" display="checkboxes" multiple="True" label="Require" help="-f">
                     <option value="1">Read is paired</option>
                     <option value="2">Read is mapped in a proper pair</option>
                     <option value="4">The read is unmapped</option>
@@ -136,7 +174,7 @@
                     <option value="512">The read fails platform/vendor quality checks</option>
                     <option value="1024">The read is a PCR or optical duplicate</option>
                 </param>
-                <param name="exclude_flags" type="select" display="checkboxes" multiple="True" label="Exclude">
+                <param name="exclude_flags" type="select" display="checkboxes" multiple="True" label="Exclude" help="-F">
                     <option value="1">Read is paired</option>
                     <option value="2">Read is mapped in a proper pair</option>
                     <option value="4">The read is unmapped</option>
@@ -151,17 +189,36 @@
                 </param>
             </when>
             <when value="nofilter" />
+
         </conditional>
-        <param name="gc_depth" type="float" value="2000" label="GC-depth bin size" />
-        <param name="insert_size" type="integer" value="8000" label="Maximum insert size" />
-        <param name="read_group" type="text" optional="true" label="Limit to a specific read group name" />
-        <param name="read_length" type="integer" value="0" optional="true" label="Minimum read length to generate statistics for" />
-        <param name="most_inserts" type="float" value="0.99" label="Report only the main part of inserts" />
-        <param name="trim_quality" type="integer" value="0" label="BWA trim parameter" />
+        <param name="gc_depth" type="float" value="20000" label="GC-depth bin size" help="--GC-depth; decreasing bin size increases memory requirement; default = 20000.0"/>
+        <param name="insert_size" type="integer" value="8000" label="Maximum insert size" help="--insert-size; default = 8000"/>
+
+        <!--
+            
+            The -I option of samtools stats returns the following message in version 1.2:
+
+            Samtools-htslib: init_group_id() header parsing not yet implemented
+            Abort trap: 6
+    
+            Because of this the section below is commented out until this stats bug is fixed
+
+            <param name="read_group" type="select" optional="true" label="Limit to a specific read group name" > 
+                <options>
+                    <filter type="data_meta" ref="input_file" key="read_groups" />
+                </options>
+            </param>
+
+        -->
+
+        <param name="read_length" type="integer" value="0" label="Minimum read length to generate statistics for" help="--read-length; default = no cutoff"/>
+        <param name="most_inserts" type="float" value="0.99" label="Report only the main part of inserts" help="--most-inserts; default = 0.99"/>
+        <param name="trim_quality" type="integer" value="0" label="BWA trim parameter" help="--trim-quality; default = 0"/>
+        
         <conditional name="use_reference">
-            <param name="use_ref_selector" type="select" label="Use reference sequence">
+            <param name="use_ref_selector" type="select" label="Use reference sequence" help="--ref-seq; required for GC-depth and mismatches-per-cycle calculation">
                 <option value="yes">Use reference</option>
-                <option value="no">Do not use reference</option>
+                <option selected="True" value="no">Do not use reference</option>
             </param>
             <when value="yes">
                 <conditional name="reference_source">
@@ -182,7 +239,9 @@
             </when>
             <when value="no" />
         </conditional>
+
     </inputs>
+
     <outputs>
         <data format="tabular" name="output" label="${tool.name} on ${on_string}">
             <discover_datasets pattern="(?P&lt;designation&gt;.+)\.tab" ext="tabular" visible="true" directory="split" />
@@ -190,38 +249,48 @@
     </outputs>
     <tests>
         <test>
-            <param name="input_file" value="phiX.bam" ftype="bam" />
-            <param name="use_ref_selector" value="no" />
-            <output name="output" file="samtools_stats_out1.tab" ftype="tabular" lines_diff="2" />
+            <param name="input_file" value="samtools_stats_input.bam" ftype="bam" />
+            <param name="use_ref_selector" value="yes" />
+            <param name="reference_source_selector" value="history" />
+            <param name="ref_file" value="samtools_stats_ref.fa" ftype="fasta" />
+            <output name="output" file="samtools_stats_out1.tab" ftype="tabular" lines_diff="4" />
         </test>
         <test>
-            <param name="input_file" value="phiX.bam" ftype="bam" />
-            <param name="use_ref_selector" value="no" />
+            <param name="input_file" value="samtools_stats_input.bam" ftype="bam" />
+            <param name="use_ref_selector" value="yes" />
+            <param name="reference_source_selector" value="history" />
+            <param name="ref_file" value="samtools_stats_ref.fa" ftype="fasta" />
             <param name="split_output_selector" value="yes" />
-            <param name="generate_tables" value="sn,gcf,gcl,gcc,cov,gcd" />
-            <output name="output" file="samtools_stats_out2.tab" lines_diff="2">
+            <param name="generate_tables" value="sn,mpc,gcc" />
+            <output name="output" file="samtools_stats_out2.tab" lines_diff="4">
                 <discovered_dataset designation="Summary numbers" ftype="tabular" file="samtools_stats_out2/sn.tab" />
-                <discovered_dataset designation="GC Content of first fragments" ftype="tabular" file="samtools_stats_out2/gcf.tab" />
-                <discovered_dataset designation="GC Content of last fragments" ftype="tabular" file="samtools_stats_out2/gcl.tab" />
                 <discovered_dataset designation="ACGT content per cycle" ftype="tabular" file="samtools_stats_out2/gcc.tab" />
-                <discovered_dataset designation="Coverage distribution" ftype="tabular" file="samtools_stats_out2/cov.tab" />
-                <discovered_dataset designation="GC depth" ftype="tabular" file="samtools_stats_out2/gcd.tab" />
+                <discovered_dataset designation="Mismatches per cycle" ftype="tabular" file="samtools_stats_out2/mpc.tab" />
             </output>
         </test>
     </tests>
-    <help>
+    <help><![CDATA[
 **What it does**
 
-This tool runs the ``samtools stats`` command in the SAMtools toolkit.
-
-Collects statistics from BAM files. The output can be visualized using plot-bamstats.
-
-**Citation**
+This tool runs the ``samtools stats`` command. It has the following options::
 
-For the underlying tool, please cite `Li H, Handsaker B, Wysoker A, Fennell T, Ruan J, Homer N, Marth G, Abecasis G, Durbin R; 1000 Genome Project Data Processing Subgroup. The Sequence Alignment/Map format and SAMtools. Bioinformatics. 2009 Aug 15;25(16):2078-9. &lt;http://www.ncbi.nlm.nih.gov/pubmed/19505943&gt;`_
-
+    -c, --coverage <int>,<int>,<int>    Coverage distribution min,max,step [1,1000,1]
+    -d, --remove-dups                   Exclude from statistics reads marked as duplicates
+    -f, --required-flag  <str|int>      Required flag, 0 for unset. See also `samtools flags` [0]
+    -F, --filtering-flag <str|int>      Filtering flag, 0 for unset. See also `samtools flags` [0]
+        --GC-depth <float>              the size of GC-depth bins (decreasing bin size increases memory requirement) [2e4]
+    -h, --help                          This help message
+    -i, --insert-size <int>             Maximum insert size [8000]
+    -I, --id <string>                   Include only listed read group or sample name
+    -l, --read-length <int>             Include in the statistics only reads with the given read length []
+    -m, --most-inserts <float>          Report only the main part of inserts [0.99]
+    -q, --trim-quality <int>            The BWA trimming parameter [0]
+    -r, --ref-seq <file>                Reference sequence (required for GC-depth and mismatches-per-cycle calculation). Galaxy
+                                        will provide options for selecting a reference cached as this Galaxy instance or choosing
+                                        one from history.
+   
 
-If you use this tool in Galaxy, please cite Blankenberg D, et al. *In preparation.*
-    </help>
+    ]]></help>
+    <expand macro="citations"></expand>
 </tool>