0
|
1 <tool id="samtools_flag_filter" name="Samtools flag_filter" version="0.1">
|
|
2 <description>Use Samtools' view tool to filter alignments based on the flag field.</description>
|
|
3 <macros>
|
|
4 <import>samtools_macros.xml</import>
|
|
5 </macros>
|
|
6 <expand macro="requirements"></expand>
|
|
7 <expand macro="stdio"></expand>
|
|
8 <expand macro="version_command"></expand>
|
|
9
|
|
10 <command>
|
|
11 <![CDATA[
|
|
12 samtools sort -@ \${GALAXY_SLOTS:-1} -o temp_bam -O bam -T dataset "${input}" &&
|
|
13 samtools view -@ \${GALAXY_SLOTS:-1}
|
|
14 #for $bit in $bits
|
|
15 -${bit.state} ${bit.flag}
|
|
16 #end for
|
|
17 -b -o "${output}" temp_bam
|
|
18 ]]>
|
|
19 </command>
|
|
20 <inputs>
|
|
21 <param name="input" format="bam,sam" label="BAM/SAM dataset to filter by flag" type="data" />
|
|
22 <repeat name="bits" title="Flag">
|
|
23 <param name="flag" type="select" label="Type">
|
|
24 <option value="0x0001">Read is paired 0x0001</option>
|
|
25 <option value="0x0002">Read is mapped in a proper pair 0x0002</option>
|
|
26 <option value="0x0004">The read is unmapped 0x0004</option>
|
|
27 <option value="0x0008">The mate is unmapped 0x0008</option>
|
|
28 <option value="0x0010">Read strand 0x0010</option>
|
|
29 <option value="0x0020">Mate strand 0x0020</option>
|
|
30 <option value="0x0040">Read is the first in a pair 0x0040</option>
|
|
31 <option value="0x0080">Read is the second in a pair 0x0080</option>
|
|
32 <option value="0x0100">The alignment or this read is not primary 0x0100</option>
|
|
33 <option value="0x0200">The read fails platform/vendor quality checks 0x0200</option>
|
|
34 <option value="0x0400">The read is a PCR or optical duplicate 0x0400</option>
|
|
35 </param>
|
|
36 <param name="state" type="select" display="radio" label="Set the states for this flag">
|
|
37 <option value="f">Keep only alignments with this flag set --f</option>
|
|
38 <option value="F">Remove all alignments with this flag set --F</option>
|
|
39 </param>
|
|
40 </repeat>
|
|
41
|
|
42 </inputs>
|
|
43 <outputs>
|
|
44 <data format="bam" name="output" label="Filtered by flag from ${on_string}" />
|
|
45 </outputs>
|
|
46 <tests>
|
|
47 <test>
|
|
48 <param ftype="bam" name="input" value="unfiltered.bam" />
|
|
49 <param name="bits_0|flag" value="The read is unmapped 0x0004"/>
|
|
50 <param name="bits_0|state" value="f"/>
|
|
51 <output file="f0X0004.bam" ftype="bam" name="output" />
|
|
52 </test>
|
|
53 <test>
|
|
54 <param ftype="bam" name="input" value="unfiltered.bam" />
|
|
55 <param name="bits_0|flag" value="The read is unmapped 0x0004"/>
|
|
56 <param name="bits_0|state" value="f"/>
|
|
57 <param name="bits_1|flag" value="The mate is unmapped 0x0008"/>
|
|
58 <param name="bits_1|state" value="f"/>
|
|
59 <output file="f0X0004_plus8.bam" ftype="bam" name="output" />
|
|
60 </test>
|
|
61 <test>
|
|
62 <param ftype="bam" name="input" value="unfiltered.bam" />
|
|
63 <param name="bits_0|flag" value="The read is unmapped 0x0004"/>
|
|
64 <param name="bits_0|state" value="f"/>
|
|
65 <param name="bits_1|flag" value="The mate is unmapped 0x0008"/>
|
|
66 <param name="bits_1|state" value="F"/>
|
|
67 <output file="f0X0004_less8.bam" ftype="bam" name="output" />
|
|
68 </test>
|
|
69 </tests>
|
|
70 <help>
|
|
71 <![CDATA[
|
|
72 This tool uses Samtools view method and specifically the -f and -F parameters to filter a sam file to remove alignments based on their flag field.
|
|
73
|
|
74 Alignments can be excluded based on either the presence or absence of that bit in their flag file.
|
|
75
|
|
76 Multiple check can be carried out in the same pass.
|
|
77
|
|
78 The flag values used are:
|
|
79
|
|
80 0x0001: Read is paired
|
|
81
|
|
82 0x0002: Read is mapped in a proper pair
|
|
83
|
|
84 0x0004: The read is unmapped
|
|
85
|
|
86 0x0008: The mate is unmapped
|
|
87
|
|
88 0x0010: Read strand
|
|
89
|
|
90 0x0020: Mate strand
|
|
91
|
|
92 0x0040: Read is the first in a pair
|
|
93
|
|
94 0x0080: Read is the second in a pair
|
|
95
|
|
96 0x0100: The alignment or this read is not primary
|
|
97
|
|
98 0x0200: The read fails platform/vendor quality checks
|
|
99
|
|
100 0x0400: The read is a PCR or optical duplicate
|
|
101 ]]>
|
|
102 </help>
|
|
103 <expand macro="citations"></expand>
|
|
104 </tool>
|