1
|
1 <tool id="sambamba_filter" name="Filter BAM or SAM" version="0.2.4">
|
0
|
2 <requirements>
|
|
3 <requirement type="binary">sambamba</requirement>
|
|
4 </requirements>
|
|
5 <description>
|
1
|
6 on flags, fields, and tags
|
0
|
7 </description>
|
|
8 <command>
|
|
9 #if $query != None:
|
1
|
10 #set $query = $query.replace('__sq__', '\'')
|
|
11 #set $query = $query.replace('__ob__', '[')
|
|
12 #set $query = $query.replace('__cb__', ']')
|
|
13 #set $query = $query.replace('__dq__', '"')
|
|
14 #set $query = $query.replace('__oc__', '{')
|
|
15 #set $query = $query.replace('__cc__', '}')
|
|
16 #set $query = $query.replace('__gt__', chr(62))
|
|
17 #set $query = $query.replace('__lt__', chr(60))
|
|
18 #end if
|
0
|
19 #if isinstance($input.datatype, $__app__.datatypes_registry.get_datatype_by_extension('bam').__class__):
|
|
20 #set $input1 = 'input.bam'
|
|
21 ln -s $input $input1 &&
|
|
22 ln -s $input.metadata.bam_index input.bai &&
|
1
|
23 sambamba view -h --filter="$query" -f $outputformat.format -o $outfile $input1 $region
|
|
24 #else
|
|
25 sambamba view -S -h --filter="$query" -f $outputformat.format -o $outfile $input
|
0
|
26 #end if
|
|
27 </command>
|
|
28 <inputs>
|
|
29 <param name="input" type="data" format="bam,sam" label="BAM or SAM file to filter"/>
|
|
30 <param name="query" type="text" size="80">
|
|
31 <label>Filter expression</label>
|
|
32 <help>
|
|
33 The syntax is described at sambamba wiki: https://github.com/lomereiter/sambamba/wiki/%5Bsambamba-view%5D-Filter-expression-syntax
|
|
34 </help>
|
|
35 </param>
|
|
36
|
|
37 <conditional name="outputformat">
|
1
|
38 <param name="format" type="select">
|
|
39 <label>Output format</label>
|
|
40 <option value="sam">SAM</option>
|
|
41 <option value="bam">BAM</option>
|
|
42 </param>
|
|
43 <when value="sam">
|
|
44 <!-- TODO
|
|
45 <param name="header" type="select">
|
|
46 <label>Include SAM header in output</label>
|
|
47 <option value="yes">Yes</option>
|
|
48 <option value="no">No</option>
|
|
49 </param>-->
|
|
50 </when>
|
|
51 <when value="bam"/>
|
0
|
52 </conditional>
|
|
53 <param name="region" type="text" size="40" label="Region in format chr:beg-end, works for BAM input only">
|
1
|
54 <help>
|
|
55 The syntax is the same as in samtools, start and end coordinates are 1-based.
|
|
56 </help>
|
0
|
57 </param>
|
|
58 </inputs>
|
|
59 <outputs>
|
1
|
60 <data name="outfile" format="bam">
|
|
61 <change_format>
|
|
62 <when input="outputformat.format" value="sam" format="sam"/>
|
|
63 </change_format>
|
|
64 </data>
|
0
|
65 </outputs>
|
1
|
66 <tests>
|
|
67 <test>
|
|
68 <param name="input" value="ex1_header.sam" ftype="sam" />
|
|
69 <param name="query" value="[H0] == 1 and read_name =~ /^EAS51_62/" />
|
|
70 <param name="format" value="bam" />
|
|
71 <param name="region" value="" />
|
|
72 <output name="outfile" file="ex1_header_filtered.bam" ftype="bam" />
|
|
73 </test>
|
|
74 <test>
|
|
75 <param name="input" value="c1215_fixmate.bam" ftype="bam" />
|
|
76 <param name="query" value="[MD] =~ /^\d+T\d+A\d+/ and first_of_pair" />
|
|
77 <param name="format" value="sam" />
|
|
78 <!--<param name="header" value="yes" />-->
|
|
79 <param name="region" value="AL096846:1000-5000" />
|
|
80 <output name="outfile" file="c1215_fixmate_filtered.sam" ftype="sam" />
|
|
81 </test>
|
|
82 </tests>
|
0
|
83 <help>
|
|
84 **What it does**
|
|
85
|
|
86 This tool uses sambamba view to filter BAM/SAM on flags, fields, tags, and region.
|
|
87 In order to install sambamba, visit its website_ and either download
|
|
88 a Debian package for your architecture, or build the tool from source.
|
|
89
|
|
90 Input is SAM or BAM file, output is chosen by user.
|
|
91
|
|
92 **Note**
|
|
93
|
1
|
94 Filtering by region works only for coordinate-sorted BAM files. For SAM files this parameter is ignored.
|
0
|
95
|
|
96 -----
|
|
97
|
|
98 .. _website: http://github.com/lomereiter/sambamba
|
|
99
|
|
100
|
|
101 </help>
|
|
102 </tool>
|