# HG changeset patch # User jjohnson # Date 1333139814 14400 # Node ID 5dcbce4f597165df0642c439646e7bcc5246bce5 Uploaded diff -r 000000000000 -r 5dcbce4f5971 samtools_filter.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samtools_filter.xml Fri Mar 30 16:36:54 2012 -0400 @@ -0,0 +1,216 @@ + + files on FLAG MAPQ RG LN or by region + + samtools + + + +##set up input files, regions requires input.bam and input.bai +#set $input = None +#if isinstance($input1.datatype, $__app__.datatypes_registry.get_datatype_by_extension('bam').__class__): + #set $input = 'input.bam' + ln -s $input1 $input && + ln -s $input1.metadata.bam_index input.bai && +#elif isinstance($input1.datatype, $__app__.datatypes_registry.get_datatype_by_extension('sam').__class__): + #set $input = 'input.sam' + ln -s $input1 $input && +#end if +samtools view -o "$output1" $header + #if $input1.datatype.file_ext == 'sam': + -S + #else + -b + #end if + #if $mapq.__str__ != '': + -q $mapq + #end if + #if $flag.filter.__str__ == 'yes': + #if $flag.reqBits.__str__ != 'None': + #set $reqs = $flag.reqBits.__str__.split(',') + #set $reqFlag = 0 + #for $xn in $reqs: + #set $reqFlag += int(xn,16) + #end for + -f $hex($reqFlag) + #end if + #if $flag.skipBits.__str__ != 'None': + #set $skips = $flag.skipBits.__str__.split(',') + #set $skipFlag = 0 + #for $xn in $skips: + #set $skipFlag += int(xn,16) + #end for + -F $hex($skipFlag) + #end if + #end if + #if $read_group.__str__.strip() != '': + -r $read_group + #end if + #if $library.__str__.strip() != '': + -l $library + #end if + #if $bed_file.__str__ != "None" and len($bed_file.__str__) > 0: + -L $bed_file + #end if + $input + #if $regions.__str__.strip() != '' and $input1.datatype.file_ext == 'bam': + $regions.__str__.strip() + #end if + ## need to redirect stderr message so galaxy does not think this failed + 2>&1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +**What it does** + +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. + +**Input** + +Input is either a SAM or BAM file. + +**Output** + +The output file will be of the same format a the Input file, filtered by the selected options. + +**Options** + +Filtering by read group or library requires headers in the input SAM or BAM file. + +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. +A region can be presented, for example, in the following format:: + + chr2 (the whole chr2) + chr2:1000000 (region starting from 1,000,000bp) + chr2:1,000,000-2,000,000 (region between 1,000,000 and 2,000,000bp including the end points). + +Note: The coordinate is 1-based. + +Multiple regions may be specified, separated by a space character:: + + chr2:1000000-2000000 chr2:1,000,000-2,000,000 chrX + + + +.. _SAMTools: http://samtools.sourceforge.net/samtools.shtml + + +