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