annotate samtools_filter.xml @ 1:ca962d4ac268

Uploaded
author devteam
date Tue, 26 Nov 2013 13:42:20 -0500
parents 141116b4e966
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
141116b4e966 Uploaded
devteam
parents:
diff changeset
1 <tool id="samtools_filter" name="Filter SAM or BAM" version="1.1.1">
141116b4e966 Uploaded
devteam
parents:
diff changeset
2 <description>files on FLAG MAPQ RG LN or by region</description>
141116b4e966 Uploaded
devteam
parents:
diff changeset
3 <requirements>
141116b4e966 Uploaded
devteam
parents:
diff changeset
4 <requirement type="package" version="0.1.18">samtools</requirement>
141116b4e966 Uploaded
devteam
parents:
diff changeset
5 </requirements>
141116b4e966 Uploaded
devteam
parents:
diff changeset
6 <!--
141116b4e966 Uploaded
devteam
parents:
diff changeset
7 samtools view [-bchuHS] [-t in.refList] [-o output] [-f reqFlag] [-F skipFlag] [-q minMapQ] [-l library] [-r readGroup] [-R rgFile] <in.bam>|<in.sam> [region1 [...]]
141116b4e966 Uploaded
devteam
parents:
diff changeset
8 Usage: samtools view [options] <in.bam>|<in.sam> [region1 [...]]
141116b4e966 Uploaded
devteam
parents:
diff changeset
9
141116b4e966 Uploaded
devteam
parents:
diff changeset
10 Options: -b output BAM
141116b4e966 Uploaded
devteam
parents:
diff changeset
11 -h print header for the SAM output
141116b4e966 Uploaded
devteam
parents:
diff changeset
12 -H print header only (no alignments)
141116b4e966 Uploaded
devteam
parents:
diff changeset
13 -S input is SAM
141116b4e966 Uploaded
devteam
parents:
diff changeset
14 -u uncompressed BAM output (force -b)
141116b4e966 Uploaded
devteam
parents:
diff changeset
15 -1 fast compression (force -b)
141116b4e966 Uploaded
devteam
parents:
diff changeset
16 -x output FLAG in HEX (samtools-C specific)
141116b4e966 Uploaded
devteam
parents:
diff changeset
17 -X output FLAG in string (samtools-C specific)
141116b4e966 Uploaded
devteam
parents:
diff changeset
18 -c print only the count of matching records
141116b4e966 Uploaded
devteam
parents:
diff changeset
19 -L FILE output alignments overlapping the input BED FILE [null]
141116b4e966 Uploaded
devteam
parents:
diff changeset
20 -t FILE list of reference names and lengths (force -S) [null]
141116b4e966 Uploaded
devteam
parents:
diff changeset
21 -T FILE reference sequence file (force -S) [null]
141116b4e966 Uploaded
devteam
parents:
diff changeset
22 -o FILE output file name [stdout]
141116b4e966 Uploaded
devteam
parents:
diff changeset
23 -R FILE list of read groups to be outputted [null]
141116b4e966 Uploaded
devteam
parents:
diff changeset
24 -f INT required flag, 0 for unset [0]
141116b4e966 Uploaded
devteam
parents:
diff changeset
25 -F INT filtering flag, 0 for unset [0]
141116b4e966 Uploaded
devteam
parents:
diff changeset
26 -q INT minimum mapping quality [0]
141116b4e966 Uploaded
devteam
parents:
diff changeset
27 -l STR only output reads in library STR [null]
141116b4e966 Uploaded
devteam
parents:
diff changeset
28 -r STR only output reads in read group STR [null]
141116b4e966 Uploaded
devteam
parents:
diff changeset
29 -? longer help
141116b4e966 Uploaded
devteam
parents:
diff changeset
30 -->
141116b4e966 Uploaded
devteam
parents:
diff changeset
31 <command>
141116b4e966 Uploaded
devteam
parents:
diff changeset
32 ##set up input files, regions requires input.bam and input.bai
141116b4e966 Uploaded
devteam
parents:
diff changeset
33 #if isinstance($input1.datatype, $__app__.datatypes_registry.get_datatype_by_extension('bam').__class__):
141116b4e966 Uploaded
devteam
parents:
diff changeset
34 #set $input = 'input.bam'
141116b4e966 Uploaded
devteam
parents:
diff changeset
35 ln -s $input1 $input &amp;&amp;
141116b4e966 Uploaded
devteam
parents:
diff changeset
36 ln -s $input1.metadata.bam_index input.bai &amp;&amp;
141116b4e966 Uploaded
devteam
parents:
diff changeset
37 #elif isinstance($input1.datatype, $__app__.datatypes_registry.get_datatype_by_extension('sam').__class__):
141116b4e966 Uploaded
devteam
parents:
diff changeset
38 #set $input = 'input.sam'
141116b4e966 Uploaded
devteam
parents:
diff changeset
39 ln -s $input1 $input &amp;&amp;
141116b4e966 Uploaded
devteam
parents:
diff changeset
40 #end if
141116b4e966 Uploaded
devteam
parents:
diff changeset
41 samtools view -o "$output1" $header
141116b4e966 Uploaded
devteam
parents:
diff changeset
42
141116b4e966 Uploaded
devteam
parents:
diff changeset
43 #if $input1.datatype.file_ext == 'sam':
141116b4e966 Uploaded
devteam
parents:
diff changeset
44 -S
141116b4e966 Uploaded
devteam
parents:
diff changeset
45 #end if
141116b4e966 Uploaded
devteam
parents:
diff changeset
46
141116b4e966 Uploaded
devteam
parents:
diff changeset
47 #if $outputtype.__str__ == "bam":
141116b4e966 Uploaded
devteam
parents:
diff changeset
48 -b
141116b4e966 Uploaded
devteam
parents:
diff changeset
49 #end if
141116b4e966 Uploaded
devteam
parents:
diff changeset
50
141116b4e966 Uploaded
devteam
parents:
diff changeset
51
141116b4e966 Uploaded
devteam
parents:
diff changeset
52 #if $mapq.__str__ != '':
141116b4e966 Uploaded
devteam
parents:
diff changeset
53 -q $mapq
141116b4e966 Uploaded
devteam
parents:
diff changeset
54 #end if
141116b4e966 Uploaded
devteam
parents:
diff changeset
55 #if $flag.filter.__str__ == 'yes':
141116b4e966 Uploaded
devteam
parents:
diff changeset
56 #if $flag.reqBits.__str__ != 'None':
141116b4e966 Uploaded
devteam
parents:
diff changeset
57 #set $reqs = $flag.reqBits.__str__.split(',')
141116b4e966 Uploaded
devteam
parents:
diff changeset
58 #set $reqFlag = 0
141116b4e966 Uploaded
devteam
parents:
diff changeset
59 #for $xn in $reqs:
141116b4e966 Uploaded
devteam
parents:
diff changeset
60 #set $reqFlag += int(xn,16)
141116b4e966 Uploaded
devteam
parents:
diff changeset
61 #end for
141116b4e966 Uploaded
devteam
parents:
diff changeset
62 -f $hex($reqFlag)
141116b4e966 Uploaded
devteam
parents:
diff changeset
63 #end if
141116b4e966 Uploaded
devteam
parents:
diff changeset
64 #if $flag.skipBits.__str__ != 'None':
141116b4e966 Uploaded
devteam
parents:
diff changeset
65 #set $skips = $flag.skipBits.__str__.split(',')
141116b4e966 Uploaded
devteam
parents:
diff changeset
66 #set $skipFlag = 0
141116b4e966 Uploaded
devteam
parents:
diff changeset
67 #for $xn in $skips:
141116b4e966 Uploaded
devteam
parents:
diff changeset
68 #set $skipFlag += int(xn,16)
141116b4e966 Uploaded
devteam
parents:
diff changeset
69 #end for
141116b4e966 Uploaded
devteam
parents:
diff changeset
70 -F $hex($skipFlag)
141116b4e966 Uploaded
devteam
parents:
diff changeset
71 #end if
141116b4e966 Uploaded
devteam
parents:
diff changeset
72 #end if
141116b4e966 Uploaded
devteam
parents:
diff changeset
73 #if $read_group.__str__.strip() != '':
141116b4e966 Uploaded
devteam
parents:
diff changeset
74 -r $read_group
141116b4e966 Uploaded
devteam
parents:
diff changeset
75 #end if
141116b4e966 Uploaded
devteam
parents:
diff changeset
76 #if $library.__str__.strip() != '':
141116b4e966 Uploaded
devteam
parents:
diff changeset
77 -l $library
141116b4e966 Uploaded
devteam
parents:
diff changeset
78 #end if
141116b4e966 Uploaded
devteam
parents:
diff changeset
79 #if $bed_file.__str__ != "None" and len($bed_file.__str__) > 0:
141116b4e966 Uploaded
devteam
parents:
diff changeset
80 -L $bed_file
141116b4e966 Uploaded
devteam
parents:
diff changeset
81 #end if
141116b4e966 Uploaded
devteam
parents:
diff changeset
82 $input
141116b4e966 Uploaded
devteam
parents:
diff changeset
83 #if $regions.__str__.strip() != '' and $input1.datatype.file_ext == 'bam':
141116b4e966 Uploaded
devteam
parents:
diff changeset
84 $regions.__str__.strip()
141116b4e966 Uploaded
devteam
parents:
diff changeset
85 #end if
141116b4e966 Uploaded
devteam
parents:
diff changeset
86 ## need to redirect stderr message so galaxy does not think this failed
141116b4e966 Uploaded
devteam
parents:
diff changeset
87 2>&amp;1
141116b4e966 Uploaded
devteam
parents:
diff changeset
88 </command>
141116b4e966 Uploaded
devteam
parents:
diff changeset
89 <inputs>
141116b4e966 Uploaded
devteam
parents:
diff changeset
90 <param name="input1" type="data" format="sam,bam" label="SAM or BAM File to Filter" />
141116b4e966 Uploaded
devteam
parents:
diff changeset
91 <param name="header" type="select" label="Header in output">
141116b4e966 Uploaded
devteam
parents:
diff changeset
92 <option value="-h">Include Header</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
93 <option value="">Exclude Header</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
94 <option value="-H">Only the Header</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
95 </param>
141116b4e966 Uploaded
devteam
parents:
diff changeset
96 <param name="mapq" type="integer" value="" optional="true" label="Minimum MAPQ quality score">
141116b4e966 Uploaded
devteam
parents:
diff changeset
97 <validator type="in_range" message="The MAPQ quality score can't be negative" min="0"/>
141116b4e966 Uploaded
devteam
parents:
diff changeset
98 </param>
141116b4e966 Uploaded
devteam
parents:
diff changeset
99 <conditional name="flag">
141116b4e966 Uploaded
devteam
parents:
diff changeset
100 <param name="filter" type="select" label="Filter on bitwise flag">
141116b4e966 Uploaded
devteam
parents:
diff changeset
101 <option value="no">no</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
102 <option value="yes">yes</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
103 </param>
141116b4e966 Uploaded
devteam
parents:
diff changeset
104 <when value="no"/>
141116b4e966 Uploaded
devteam
parents:
diff changeset
105 <when value="yes">
141116b4e966 Uploaded
devteam
parents:
diff changeset
106 <param name="reqBits" type="select" multiple="true" display="checkboxes" label="Only output alignments with all of these flag bits set" >
141116b4e966 Uploaded
devteam
parents:
diff changeset
107 <option value="0x0001">Read is paired</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
108 <option value="0x0002">Read is mapped in a proper pair</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
109 <option value="0x0004">The read is unmapped</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
110 <option value="0x0008">The mate is unmapped</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
111 <option value="0x0010">Read strand</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
112 <option value="0x0020">Mate strand</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
113 <option value="0x0040">Read is the first in a pair</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
114 <option value="0x0080">Read is the second in a pair</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
115 <option value="0x0100">The alignment or this read is not primary</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
116 <option value="0x0200">The read fails platform/vendor quality checks</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
117 <option value="0x0400">The read is a PCR or optical duplicate</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
118 </param>
141116b4e966 Uploaded
devteam
parents:
diff changeset
119 <param name="skipBits" type="select" multiple="true" display="checkboxes" label="Skip alignments with any of these flag bits set" >
141116b4e966 Uploaded
devteam
parents:
diff changeset
120 <option value="0x0001">Read is paired</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
121 <option value="0x0002">Read is mapped in a proper pair</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
122 <option value="0x0004">The read is unmapped</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
123 <option value="0x0008">The mate is unmapped</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
124 <option value="0x0010">Read strand</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
125 <option value="0x0020">Mate strand</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
126 <option value="0x0040">Read is the first in a pair</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
127 <option value="0x0080">Read is the second in a pair</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
128 <option value="0x0100">The alignment or this read is not primary</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
129 <option value="0x0200">The read fails platform/vendor quality checks</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
130 <option value="0x0400">The read is a PCR or optical duplicate</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
131 </param>
141116b4e966 Uploaded
devteam
parents:
diff changeset
132 </when>
141116b4e966 Uploaded
devteam
parents:
diff changeset
133 </conditional>
141116b4e966 Uploaded
devteam
parents:
diff changeset
134 <param name="library" type="text" value="" size="20" label="Select alignments from Library"
141116b4e966 Uploaded
devteam
parents:
diff changeset
135 help="Requires headers in the input SAM or BAM, otherwise no alignments will be output."/>
141116b4e966 Uploaded
devteam
parents:
diff changeset
136 <param name="read_group" type="text" value="" size="20" label="Select alignments from Read Group"
141116b4e966 Uploaded
devteam
parents:
diff changeset
137 help="Requires headers in the input SAM or BAM, otherwise no alignments will be output."/>
141116b4e966 Uploaded
devteam
parents:
diff changeset
138 <param name="bed_file" type="data" format="bed" optional="true" label="Output alignments overlapping the regions in the BED FILE"/>
141116b4e966 Uploaded
devteam
parents:
diff changeset
139 <param name="regions" type="text" value="" size="180" label="Select regions (only used when the input is in BAM format)"
141116b4e966 Uploaded
devteam
parents:
diff changeset
140 help="region should be presented in one of the following formats: `chr1', `chr2:1,000' and `chr3:1000-2,000'"/>
141116b4e966 Uploaded
devteam
parents:
diff changeset
141 <param name="outputtype" type="select" label="Select the output format">
141116b4e966 Uploaded
devteam
parents:
diff changeset
142 <option value="bam">bam</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
143 <option value="sam">sam</option>
141116b4e966 Uploaded
devteam
parents:
diff changeset
144 </param>
141116b4e966 Uploaded
devteam
parents:
diff changeset
145 </inputs>
141116b4e966 Uploaded
devteam
parents:
diff changeset
146 <outputs>
141116b4e966 Uploaded
devteam
parents:
diff changeset
147 <data name="output1" format_source="input1" label="${tool.name} on ${on_string}: ${input1.datatype.file_ext}">
141116b4e966 Uploaded
devteam
parents:
diff changeset
148 <change_format>
141116b4e966 Uploaded
devteam
parents:
diff changeset
149 <when input="outputtype" value="bam" format="bam" />
141116b4e966 Uploaded
devteam
parents:
diff changeset
150 </change_format>
141116b4e966 Uploaded
devteam
parents:
diff changeset
151 </data>
141116b4e966 Uploaded
devteam
parents:
diff changeset
152 </outputs>
141116b4e966 Uploaded
devteam
parents:
diff changeset
153 <tests>
141116b4e966 Uploaded
devteam
parents:
diff changeset
154 <test>
141116b4e966 Uploaded
devteam
parents:
diff changeset
155 <param name="input1" value="bam_to_sam_in2.sam" ftype="sam" />
141116b4e966 Uploaded
devteam
parents:
diff changeset
156 <param name="header" value=""/>
141116b4e966 Uploaded
devteam
parents:
diff changeset
157 <param name="filter" value="yes"/>
141116b4e966 Uploaded
devteam
parents:
diff changeset
158 <param name="reqBits" value="0x0080"/>
141116b4e966 Uploaded
devteam
parents:
diff changeset
159 <output name="output1" >
141116b4e966 Uploaded
devteam
parents:
diff changeset
160 <assert_contents>
141116b4e966 Uploaded
devteam
parents:
diff changeset
161 <has_text text="141" />
141116b4e966 Uploaded
devteam
parents:
diff changeset
162 <not_has_text text="77" />
141116b4e966 Uploaded
devteam
parents:
diff changeset
163 </assert_contents>
141116b4e966 Uploaded
devteam
parents:
diff changeset
164 </output>
141116b4e966 Uploaded
devteam
parents:
diff changeset
165 </test>
141116b4e966 Uploaded
devteam
parents:
diff changeset
166 <test>
141116b4e966 Uploaded
devteam
parents:
diff changeset
167 <param name="input1" value="bam_to_sam_in2.sam" ftype="sam" />
141116b4e966 Uploaded
devteam
parents:
diff changeset
168 <param name="header" value=""/>
141116b4e966 Uploaded
devteam
parents:
diff changeset
169 <param name="filter" value="no"/>
141116b4e966 Uploaded
devteam
parents:
diff changeset
170 <param name="read_group" value="rg1"/>
141116b4e966 Uploaded
devteam
parents:
diff changeset
171 <output name="output1" >
141116b4e966 Uploaded
devteam
parents:
diff changeset
172 <assert_contents>
141116b4e966 Uploaded
devteam
parents:
diff changeset
173 <has_text text="rg1" />
141116b4e966 Uploaded
devteam
parents:
diff changeset
174 <not_has_text text="rg2" />
141116b4e966 Uploaded
devteam
parents:
diff changeset
175 </assert_contents>
141116b4e966 Uploaded
devteam
parents:
diff changeset
176 </output>
141116b4e966 Uploaded
devteam
parents:
diff changeset
177 </test>
141116b4e966 Uploaded
devteam
parents:
diff changeset
178 <test>
141116b4e966 Uploaded
devteam
parents:
diff changeset
179 <param name="input1" value="bam_to_sam_in1.sam" ftype="sam" />
141116b4e966 Uploaded
devteam
parents:
diff changeset
180 <param name="header" value=""/>
141116b4e966 Uploaded
devteam
parents:
diff changeset
181 <param name="filter" value="yes"/>
141116b4e966 Uploaded
devteam
parents:
diff changeset
182 <param name="skipBits" value="0x0008"/>
141116b4e966 Uploaded
devteam
parents:
diff changeset
183 <param name="mapq" value="250"/>
141116b4e966 Uploaded
devteam
parents:
diff changeset
184 <output name="output1" >
141116b4e966 Uploaded
devteam
parents:
diff changeset
185 <assert_contents>
141116b4e966 Uploaded
devteam
parents:
diff changeset
186 <has_text text="both_reads_align_clip_marked" />
141116b4e966 Uploaded
devteam
parents:
diff changeset
187 <not_has_text text="both_reads_present_only_first_aligns" />
141116b4e966 Uploaded
devteam
parents:
diff changeset
188 </assert_contents>
141116b4e966 Uploaded
devteam
parents:
diff changeset
189 </output>
141116b4e966 Uploaded
devteam
parents:
diff changeset
190 </test>
141116b4e966 Uploaded
devteam
parents:
diff changeset
191 </tests>
141116b4e966 Uploaded
devteam
parents:
diff changeset
192 <help>
141116b4e966 Uploaded
devteam
parents:
diff changeset
193
141116b4e966 Uploaded
devteam
parents:
diff changeset
194
141116b4e966 Uploaded
devteam
parents:
diff changeset
195 **What it does**
141116b4e966 Uploaded
devteam
parents:
diff changeset
196
141116b4e966 Uploaded
devteam
parents:
diff changeset
197 This tool uses the samtools view command in SAMTools_ toolkit to filter a SAM or BAM file on the MAPQ (mapping quality), FLAG bits, Read Group, Library, or region.
141116b4e966 Uploaded
devteam
parents:
diff changeset
198
141116b4e966 Uploaded
devteam
parents:
diff changeset
199 **Input**
141116b4e966 Uploaded
devteam
parents:
diff changeset
200
141116b4e966 Uploaded
devteam
parents:
diff changeset
201 Input is either a SAM or BAM file.
141116b4e966 Uploaded
devteam
parents:
diff changeset
202
141116b4e966 Uploaded
devteam
parents:
diff changeset
203 **Output**
141116b4e966 Uploaded
devteam
parents:
diff changeset
204
141116b4e966 Uploaded
devteam
parents:
diff changeset
205 The output file will be SAM or BAM (depending on the chosen option), filtered by the selected options.
141116b4e966 Uploaded
devteam
parents:
diff changeset
206
141116b4e966 Uploaded
devteam
parents:
diff changeset
207 **Options**
141116b4e966 Uploaded
devteam
parents:
diff changeset
208
141116b4e966 Uploaded
devteam
parents:
diff changeset
209 Filtering by read group or library requires headers in the input SAM or BAM file.
141116b4e966 Uploaded
devteam
parents:
diff changeset
210
141116b4e966 Uploaded
devteam
parents:
diff changeset
211 If regions are specified, only alignments overlapping the specified regions will be output. An alignment may be given multiple times if it is overlapping several regions.
141116b4e966 Uploaded
devteam
parents:
diff changeset
212 A region can be presented, for example, in the following format::
141116b4e966 Uploaded
devteam
parents:
diff changeset
213
141116b4e966 Uploaded
devteam
parents:
diff changeset
214 chr2 (the whole chr2)
141116b4e966 Uploaded
devteam
parents:
diff changeset
215 chr2:1000000 (region starting from 1,000,000bp)
141116b4e966 Uploaded
devteam
parents:
diff changeset
216 chr2:1,000,000-2,000,000 (region between 1,000,000 and 2,000,000bp including the end points).
141116b4e966 Uploaded
devteam
parents:
diff changeset
217
141116b4e966 Uploaded
devteam
parents:
diff changeset
218 Note: The coordinate is 1-based.
141116b4e966 Uploaded
devteam
parents:
diff changeset
219
141116b4e966 Uploaded
devteam
parents:
diff changeset
220 Multiple regions may be specified, separated by a space character::
141116b4e966 Uploaded
devteam
parents:
diff changeset
221
141116b4e966 Uploaded
devteam
parents:
diff changeset
222 chr2:1000000-2000000 chr2:1,000,000-2,000,000 chrX
141116b4e966 Uploaded
devteam
parents:
diff changeset
223
141116b4e966 Uploaded
devteam
parents:
diff changeset
224
141116b4e966 Uploaded
devteam
parents:
diff changeset
225
141116b4e966 Uploaded
devteam
parents:
diff changeset
226 .. _SAMTools: http://samtools.sourceforge.net/samtools.shtml
141116b4e966 Uploaded
devteam
parents:
diff changeset
227
141116b4e966 Uploaded
devteam
parents:
diff changeset
228 </help>
141116b4e966 Uploaded
devteam
parents:
diff changeset
229 </tool>