0
|
1 <tool id="samtools_stats" name="Stats" version="2.0">
|
|
2 <description>generate statistics for BAM dataset</description>
|
|
3 <macros>
|
|
4 <import>macros.xml</import>
|
|
5 </macros>
|
|
6 <expand macro="requirements"></expand>
|
|
7 <expand macro="stdio"></expand>
|
|
8 <expand macro="version_command"></expand>
|
|
9 <command><![CDATA[
|
|
10 #if $use_reference.use_ref_selector == "yes":
|
|
11 #if $use_reference.reference_source.reference_source_selector == "history":
|
|
12 ln -s "${use_reference.reference_source.ref_file}" && samtools faidx `basename "${use_reference.reference_source.ref_file}"` && samtools stats
|
|
13 #else:
|
|
14 samtools stats
|
|
15 #end if
|
|
16 #else:
|
|
17 samtools stats
|
|
18 #end if
|
|
19 "${input_file}"
|
|
20 --coverage ${coverage_min},${coverage_max},${coverage_step}
|
|
21 ${remove_dups}
|
|
22 #if str( $filter_by_flags.filter_flags ) == "filter":
|
|
23 #if $filter_by_flags.require_flags:
|
|
24 --required-flag ${sum([int(flag) for flag in str($filter_by_flags.require_flags).split(',')])}
|
|
25 #end if
|
|
26 #if $filter_by_flags.exclude_flags:
|
|
27 --filtering-flag ${sum([int(flag) for flag in str($filter_by_flags.exclude_flags).split(',')])}
|
|
28 #end if
|
|
29 #end if
|
|
30 --GC-depth ${gc_depth}
|
|
31 --insert-size ${insert_size}
|
|
32
|
|
33 ## The code below is commented out because using -I/--id options causes the following exception
|
|
34 ## Samtools-htslib: init_group_id() header parsing not yet implemented
|
|
35
|
|
36 ##if str($read_group) != "":
|
|
37 ## -I "${read_group}"
|
|
38 ##end if
|
|
39
|
|
40 #if str($read_length) != "0":
|
|
41 --read-length "${read_length}"
|
|
42 #end if
|
|
43 --most-inserts ${most_inserts}
|
|
44 --trim-quality ${trim_quality}
|
|
45 #if $use_reference.use_ref_selector == "yes":
|
|
46 #if $use_reference.reference_source.reference_source_selector != "history":
|
|
47 --ref-seq "${use_reference.reference_source.ref_file.fields.path}"
|
|
48 #else:
|
|
49 --ref-seq "${use_reference.reference_source.ref_file}"
|
|
50 #end if
|
|
51 #end if
|
|
52 > "${output}"
|
|
53 #if $split_output.split_output_selector == "yes":
|
|
54 #set outputs_to_split = str($split_output.generate_tables).split(',')
|
|
55 && mkdir split && echo ${split_output.generate_tables} &&
|
|
56
|
|
57 #if 'sn' in $outputs_to_split:
|
|
58 echo "# Summary Numbers\n" > "split/Summary numbers.tab" &&
|
|
59 grep -q ^SN "${output}" ; if [ $? = 0 ] ; then grep ^SN "${output}" | cut -f 2- >> "split/Summary numbers.tab" ; fi &&
|
|
60 #end if
|
|
61
|
|
62 #if 'ffq' in $outputs_to_split:
|
|
63 echo "# Columns correspond to qualities and rows to cycles. First column is the cycle number\n" > "split/First Fragment Qualities.tab" &&
|
|
64 grep -q ^FFQ "${output}" ; if [ $? = 0 ] ; then grep ^FFQ "${output}" | cut -f 2- >> "split/First Fragment Qualities.tab" ; fi &&
|
|
65 #end if
|
|
66
|
|
67 #if 'lfq' in $outputs_to_split:
|
|
68 echo "# Columns correspond to qualities and rows to cycles. First column is the cycle number" > "split/Last Fragment Qualities.tab" &&
|
|
69 grep -q ^LFQ "${output}" ; if [ $? = 0 ] ; then grep ^LFQ "${output}" | cut -f 2- >> "split/Last Fragment Qualities.tab" ; fi &&
|
|
70 #end if
|
|
71
|
|
72 #if 'mpc' in $outputs_to_split:
|
|
73 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" &&
|
|
74 grep -q ^MPC "${output}" ; if [ $? = 0 ] ; then grep ^MPC "${output}" | cut -f 2- >> "split/Mismatches per cycle.tab" ; fi &&
|
|
75 #end if
|
|
76
|
|
77 #if 'gcf' in $outputs_to_split:
|
|
78 echo "# GC Content of first fragments" > "split/GC Content of first fragments.tab" &&
|
|
79 grep -q ^GCF "${output}" ; if [ $? = 0 ] ; then grep ^GCF "${output}" | cut -f 2- >> "split/GC Content of first fragments.tab" ; fi &&
|
|
80 #end if
|
|
81
|
|
82 #if 'gcl' in $outputs_to_split:
|
|
83 echo "# GC Content of last fragments" > "split/GC Content of last fragments.tab" &&
|
|
84 grep -q ^GCL "${output}" ; if [ $? = 0 ] ; then grep ^GCL "${output}" | cut -f 2- >> "split/GC Content of last fragments.tab" ; fi &&
|
|
85 #end if
|
|
86
|
|
87 #if 'gcc' in $outputs_to_split:
|
|
88 echo "# ACGT content per cycle. The columns are: cycle, and A,C,G,T counts (percent)" > "split/ACGT content per cycle.tab" &&
|
|
89 grep -q ^GCC "${output}" ; if [ $? = 0 ] ; then grep ^GCC "${output}" | cut -f 2- >> "split/ACGT content per cycle.tab" ; fi &&
|
|
90 #end if
|
|
91
|
|
92 #if 'is' in $outputs_to_split:
|
|
93 echo "# Insert sizes. The columns are: insert size, pairs total, inward oriented pairs, outward oriented pairs, other pairs" > "split/Insert sizes.tab" &&
|
|
94 grep -q ^IS "${output}" ; if [ $? = 0 ] ; then grep ^IS "${output}" | cut -f 2- >> "split/Insert sizes.tab" ; fi &&
|
|
95 #end if
|
|
96
|
|
97 #if 'rl' in $outputs_to_split:
|
|
98 echo "# Read lengths. The columns are: read length, count" > "split/Read lengths.tab" &&
|
|
99 grep -q ^RL "${output}" ; if [ $? = 0 ] ; then grep ^RL "${output}" | cut -f 2- >> "split/Read lengths.tab" ; fi &&
|
|
100 #end if
|
|
101
|
|
102 #if 'id' in $outputs_to_split:
|
|
103 echo "# Indel distribution. The columns are: length, number of insertions, number of deletions" > "split/Indel distribution.tab" &&
|
|
104 grep -q ^ID "${output}" ; if [ $? = 0 ] ; then grep ^ID "${output}" | cut -f 2- >> "split/Indel distribution.tab" ; fi &&
|
|
105 #end if
|
|
106
|
|
107 #if 'ic' in $outputs_to_split:
|
|
108 echo "# Indels per cycle. The columns are: cycle, number of insertions (fwd), .. (rev) , number of deletions (fwd), .. (rev)" > "split/Indels per cycle.tab" &&
|
|
109 grep -q ^IC "${output}" ; if [ $? = 0 ] ; then grep ^IC "${output}" | cut -f 2- >> "split/Indels per cycle.tab" ; fi &&
|
|
110 #end if
|
|
111
|
|
112 #if 'cov' in $outputs_to_split:
|
|
113 echo "# Coverage distribution" > "split/Coverage distribution.tab" &&
|
|
114 grep -q ^COV "${output}" ; if [ $? = 0 ] ; then grep ^COV "${output}" | cut -f 2- >> "split/Coverage distribution.tab" ; fi &&
|
|
115 #end if
|
|
116
|
|
117 #if 'gcd' in $outputs_to_split:
|
|
118 echo "# GC-depth. The columns are: GC%, unique sequence percentiles, 10th, 25th, 50th, 75th and 90th depth percentile" > "split/GC depth.tab" &&
|
|
119 grep -q ^GCD "${output}" ; if [ $? = 0 ] ; then grep ^GCD "${output}" | cut -f 2- >> "split/GC depth.tab" ; fi &&
|
|
120 #end if
|
|
121
|
|
122 ## Unix true command below
|
|
123
|
|
124 true
|
|
125
|
|
126 #end if
|
|
127 ]]></command>
|
|
128 <inputs>
|
|
129 <param name="input_file" type="data" format="sam,bam" label="BAM file" />
|
|
130 <param name="coverage_min" type="integer" value="1" label="Minimum coverage" help="minimum coverage value for --coverage option"/>
|
|
131 <param name="coverage_max" type="integer" value="1000" label="Maximum coverage" help="maximum coverage value for --coverage option"/>
|
|
132 <param name="coverage_step" type="integer" value="1" label="Coverage step" help="step value for --coverage option"/>
|
|
133 <param name="remove_dups" type="boolean" truevalue="--remove-dups" falsevalue="" checked="False" label="Exclude reads marked as duplicates" help="--remove-dups; default = False"/>
|
|
134 <conditional name="split_output">
|
|
135 <param name="split_output_selector" type="select" label="Output" help="Select between a single output or separate outputs for each statistics">
|
|
136 <option value="no" selected="True">a single summary file</option>
|
|
137 <option value="yes">separate datasets for each statistics</option>
|
|
138 </param>
|
|
139 <when value="no" />
|
|
140 <when value="yes">
|
|
141 <param name="generate_tables" type="select" display="checkboxes" multiple="True" label="Statistics to extract">
|
|
142 <option value="sn">Summary numbers</option>
|
|
143 <option value="ffq">First Fragment Qualities</option>
|
|
144 <option value="lfq">Last Fragment Qualities</option>
|
|
145 <option value="mpc">Mismatches per cycle</option>
|
|
146 <option value="gcf">GC Content of first fragments</option>
|
|
147 <option value="gcl">GC Content of last fragments</option>
|
|
148 <option value="gcc">ACGT content per cycle</option>
|
|
149 <option value="is">Insert sizes</option>
|
|
150 <option value="rl">Read lengths</option>
|
|
151 <option value="id">Indel distribution</option>
|
|
152 <option value="ic">Indels per cycle</option>
|
|
153 <option value="cov">Coverage distribution</option>
|
|
154 <option value="gcd">GC depth</option>
|
|
155 </param>
|
|
156 </when>
|
|
157 </conditional>
|
|
158 <conditional name="filter_by_flags">
|
|
159 <param name="filter_flags" type="select" label="Set filter by flags" help="-f and -F options">
|
|
160 <option value="nofilter" selected="True">Do not filter</option>
|
|
161 <option value="filter">Filter by flags to exclude or require</option>
|
|
162 </param>
|
|
163 <when value="filter">
|
|
164 <param name="require_flags" type="select" display="checkboxes" multiple="True" label="Require" help="-f">
|
|
165 <option value="1">Read is paired</option>
|
|
166 <option value="2">Read is mapped in a proper pair</option>
|
|
167 <option value="4">The read is unmapped</option>
|
|
168 <option value="8">The mate is unmapped</option>
|
|
169 <option value="16">Read strand</option>
|
|
170 <option value="32">Mate strand</option>
|
|
171 <option value="64">Read is the first in a pair</option>
|
|
172 <option value="128">Read is the second in a pair</option>
|
|
173 <option value="256">The alignment or this read is not primary</option>
|
|
174 <option value="512">The read fails platform/vendor quality checks</option>
|
|
175 <option value="1024">The read is a PCR or optical duplicate</option>
|
|
176 </param>
|
|
177 <param name="exclude_flags" type="select" display="checkboxes" multiple="True" label="Exclude" help="-F">
|
|
178 <option value="1">Read is paired</option>
|
|
179 <option value="2">Read is mapped in a proper pair</option>
|
|
180 <option value="4">The read is unmapped</option>
|
|
181 <option value="8">The mate is unmapped</option>
|
|
182 <option value="16">Read strand</option>
|
|
183 <option value="32">Mate strand</option>
|
|
184 <option value="64">Read is the first in a pair</option>
|
|
185 <option value="128">Read is the second in a pair</option>
|
|
186 <option value="256">The alignment or this read is not primary</option>
|
|
187 <option value="512">The read fails platform/vendor quality checks</option>
|
|
188 <option value="1024">The read is a PCR or optical duplicate</option>
|
|
189 </param>
|
|
190 </when>
|
|
191 <when value="nofilter" />
|
|
192
|
|
193 </conditional>
|
|
194 <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"/>
|
|
195 <param name="insert_size" type="integer" value="8000" label="Maximum insert size" help="--insert-size; default = 8000"/>
|
|
196
|
|
197 <!--
|
|
198
|
|
199 The -I option of samtools stats returns the following message in version 1.2:
|
|
200
|
|
201 Samtools-htslib: init_group_id() header parsing not yet implemented
|
|
202 Abort trap: 6
|
|
203
|
|
204 Because of this the section below is commented out until this stats bug is fixed
|
|
205
|
|
206 <param name="read_group" type="select" optional="true" label="Limit to a specific read group name" >
|
|
207 <options>
|
|
208 <filter type="data_meta" ref="input_file" key="read_groups" />
|
|
209 </options>
|
|
210 </param>
|
|
211
|
|
212 -->
|
|
213
|
|
214 <param name="read_length" type="integer" value="0" label="Minimum read length to generate statistics for" help="--read-length; default = no cutoff"/>
|
|
215 <param name="most_inserts" type="float" value="0.99" label="Report only the main part of inserts" help="--most-inserts; default = 0.99"/>
|
|
216 <param name="trim_quality" type="integer" value="0" label="BWA trim parameter" help="--trim-quality; default = 0"/>
|
|
217
|
|
218 <conditional name="use_reference">
|
|
219 <param name="use_ref_selector" type="select" label="Use reference sequence" help="--ref-seq; required for GC-depth and mismatches-per-cycle calculation">
|
|
220 <option value="yes">Use reference</option>
|
|
221 <option selected="True" value="no">Do not use reference</option>
|
|
222 </param>
|
|
223 <when value="yes">
|
|
224 <conditional name="reference_source">
|
|
225 <param name="reference_source_selector" type="select" label="Choose a reference sequence for GC depth">
|
|
226 <option value="cached">Locally cached</option>
|
|
227 <option value="history">History</option>
|
|
228 </param>
|
|
229 <when value="cached">
|
|
230 <param name="ref_file" type="select" label="Using genome">
|
|
231 <options from_data_table="fasta_indexes" />
|
|
232 <filter type="data_meta" ref="input_file" key="dbkey" column="1" />
|
|
233 </param>
|
|
234 </when>
|
|
235 <when value="history">
|
|
236 <param name="ref_file" type="data" format="fasta" label="Using file" />
|
|
237 </when>
|
|
238 </conditional>
|
|
239 </when>
|
|
240 <when value="no" />
|
|
241 </conditional>
|
|
242
|
|
243 </inputs>
|
|
244
|
|
245 <outputs>
|
|
246 <data format="tabular" name="output" label="${tool.name} on ${on_string}">
|
|
247 <discover_datasets pattern="(?P<designation>.+)\.tab" ext="tabular" visible="true" directory="split" />
|
|
248 </data>
|
|
249 </outputs>
|
|
250 <tests>
|
|
251 <test>
|
|
252 <param name="input_file" value="samtools_stats_input.bam" ftype="bam" />
|
|
253 <param name="use_ref_selector" value="yes" />
|
|
254 <param name="reference_source_selector" value="history" />
|
|
255 <param name="ref_file" value="samtools_stats_ref.fa" ftype="fasta" />
|
|
256 <output name="output" file="samtools_stats_out1.tab" ftype="tabular" lines_diff="4" />
|
|
257 </test>
|
|
258 <test>
|
|
259 <param name="input_file" value="samtools_stats_input.bam" ftype="bam" />
|
|
260 <param name="use_ref_selector" value="yes" />
|
|
261 <param name="reference_source_selector" value="history" />
|
|
262 <param name="ref_file" value="samtools_stats_ref.fa" ftype="fasta" />
|
|
263 <param name="split_output_selector" value="yes" />
|
|
264 <param name="generate_tables" value="sn,mpc,gcc" />
|
|
265 <output name="output" file="samtools_stats_out2.tab" lines_diff="4">
|
|
266 <discovered_dataset designation="Summary numbers" ftype="tabular" file="samtools_stats_out2/sn.tab" />
|
|
267 <discovered_dataset designation="ACGT content per cycle" ftype="tabular" file="samtools_stats_out2/gcc.tab" />
|
|
268 <discovered_dataset designation="Mismatches per cycle" ftype="tabular" file="samtools_stats_out2/mpc.tab" />
|
|
269 </output>
|
|
270 </test>
|
|
271 </tests>
|
|
272 <help><![CDATA[
|
|
273 **What it does**
|
|
274
|
|
275 This tool runs the ``samtools stats`` command. It has the following options::
|
|
276
|
|
277 -c, --coverage <int>,<int>,<int> Coverage distribution min,max,step [1,1000,1]
|
|
278 -d, --remove-dups Exclude from statistics reads marked as duplicates
|
|
279 -f, --required-flag <str|int> Required flag, 0 for unset. See also `samtools flags` [0]
|
|
280 -F, --filtering-flag <str|int> Filtering flag, 0 for unset. See also `samtools flags` [0]
|
|
281 --GC-depth <float> the size of GC-depth bins (decreasing bin size increases memory requirement) [2e4]
|
|
282 -h, --help This help message
|
|
283 -i, --insert-size <int> Maximum insert size [8000]
|
|
284 -I, --id <string> Include only listed read group or sample name
|
|
285 -l, --read-length <int> Include in the statistics only reads with the given read length []
|
|
286 -m, --most-inserts <float> Report only the main part of inserts [0.99]
|
|
287 -q, --trim-quality <int> The BWA trimming parameter [0]
|
|
288 -r, --ref-seq <file> Reference sequence (required for GC-depth and mismatches-per-cycle calculation). Galaxy
|
|
289 will provide options for selecting a reference cached as this Galaxy instance or choosing
|
|
290 one from history.
|
|
291
|
|
292
|
|
293 ]]></help>
|
|
294 <expand macro="citations"></expand>
|
|
295 </tool>
|
|
296
|