diff sambamba_filter.xml @ 1:806b3253c996

add test data
author lomereiter
date Tue, 14 Aug 2012 21:25:40 +0400
parents 668e187566d5
children
line wrap: on
line diff
--- a/sambamba_filter.xml	Mon Aug 13 02:13:09 2012 -0400
+++ b/sambamba_filter.xml	Tue Aug 14 21:25:40 2012 +0400
@@ -1,33 +1,28 @@
-<tool id="sambamba_filter" name="Filter BAM or SAM" version="0.2.3">
+<tool id="sambamba_filter" name="Filter BAM or SAM" version="0.2.4">
     <requirements>
         <requirement type="binary">sambamba</requirement>
     </requirements>
     <description>
-		on flags, fields, and tags
+        on flags, fields, and tags
     </description>
     <command>
         #if $query != None:
-			#set $query = $query.replace('__sq__', '\'')
-			#set $query = $query.replace('__ob__', '[')
-			#set $query = $query.replace('__cb__', ']')
-			#set $query = $query.replace('__dq__', '"')
-			#set $query = $query.replace('__oc__', '{')
-			#set $query = $query.replace('__cc__', '}')
-			#set $query = $query.replace('__gt__', chr(62))
-			#set $query = $query.replace('__lt__', chr(60))
-		#end if
-		#if $outputformat.format == 'bam':
-			#set $header = ''
-		#else
-			#set $header = $outputformat.header
-		#end if
+            #set $query = $query.replace('__sq__', '\'')
+            #set $query = $query.replace('__ob__', '[')
+            #set $query = $query.replace('__cb__', ']')
+            #set $query = $query.replace('__dq__', '"')
+            #set $query = $query.replace('__oc__', '{')
+            #set $query = $query.replace('__cc__', '}')
+            #set $query = $query.replace('__gt__', chr(62))
+            #set $query = $query.replace('__lt__', chr(60))
+        #end if
         #if isinstance($input.datatype, $__app__.datatypes_registry.get_datatype_by_extension('bam').__class__):
             #set $input1 = 'input.bam'
             ln -s $input $input1 &amp;&amp;
             ln -s $input.metadata.bam_index input.bai &amp;&amp;
-			sambamba view --filter="$query" -f $outputformat.format -o $outfile $input1 $header $region
-		#else
-            sambamba view -S --filter="$query" -f $outputformat.format -o $outfile $input $header
+            sambamba view -h --filter="$query" -f $outputformat.format -o $outfile $input1 $region
+        #else
+            sambamba view -S -h --filter="$query" -f $outputformat.format -o $outfile $input
         #end if
     </command>
     <inputs>
@@ -40,33 +35,51 @@
         </param>
      
         <conditional name="outputformat">
-			<param name="format" type="select">
-				<label>Output format</label>
-				<option value="sam">SAM</option>
-				<option value="bam">BAM</option>
-			</param>
-			<when value="sam">
-				<param name="header" type="select">
-					<label>Include SAM header in output</label>
-					<option value="-h">Yes</option>
-					<option value="">No</option>
-				</param>
-			</when>
-			<when value="bam"/>
+            <param name="format" type="select">
+                <label>Output format</label>
+                <option value="sam">SAM</option>
+                <option value="bam">BAM</option>
+            </param>
+            <when value="sam">
+            <!-- TODO
+                <param name="header" type="select">
+                    <label>Include SAM header in output</label>
+                    <option value="yes">Yes</option>
+                    <option value="no">No</option>
+                </param>-->
+            </when>
+            <when value="bam"/>
         </conditional>
         <param name="region" type="text" size="40" label="Region in format chr:beg-end, works for BAM input only">
-			<help>
-				The syntax is the same as in samtools, start and end coordinates are 1-based.
-			</help>
+            <help>
+                The syntax is the same as in samtools, start and end coordinates are 1-based.
+            </help>
         </param>
     </inputs>
     <outputs>
-		<data name="outfile" format="bam">
-			<change_format>
-				<when input="outputformat.format" value="sam" format="sam"/>
-			</change_format>	
-		</data>
+        <data name="outfile" format="bam">
+            <change_format>
+                <when input="outputformat.format" value="sam" format="sam"/>
+            </change_format>    
+        </data>
     </outputs>
+    <tests>
+        <test>
+            <param name="input" value="ex1_header.sam" ftype="sam" />
+            <param name="query" value="[H0] == 1 and read_name =~ /^EAS51_62/" />
+            <param name="format" value="bam" />
+            <param name="region" value="" />
+            <output name="outfile" file="ex1_header_filtered.bam" ftype="bam" />
+        </test>
+        <test>
+            <param name="input" value="c1215_fixmate.bam" ftype="bam" />
+            <param name="query" value="[MD] =~ /^\d+T\d+A\d+/ and first_of_pair" />
+            <param name="format" value="sam" />
+            <!--<param name="header" value="yes" />-->
+            <param name="region" value="AL096846:1000-5000" />
+            <output name="outfile" file="c1215_fixmate_filtered.sam" ftype="sam" />     
+        </test>
+    </tests>
     <help>
 **What it does**
 
@@ -78,7 +91,7 @@
 
 **Note**
 
-Filtering by region works only for coordinate-sorted BAM files. For SAM files this parameter is just ignored.
+Filtering by region works only for coordinate-sorted BAM files. For SAM files this parameter is ignored.
 
 -----
 
@@ -86,5 +99,4 @@
 
 
     </help>
-    <!-- TODO: tests -->
 </tool>