# HG changeset patch # User devteam # Date 1385574159 18000 # Node ID 5b175699dd41286175353e8339a6a07f51ef77b4 # Parent 8ee90c5631c7bcb9dca4ae57a88a7297898133f4 Uploaded diff -r 8ee90c5631c7 -r 5b175699dd41 samtools_filter2.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samtools_filter2.xml Wed Nov 27 12:42:39 2013 -0500 @@ -0,0 +1,229 @@ + + files on FLAG MAPQ RG LN or by region + + samtools + + + +##set up input files, regions requires input.bam and input.bai +#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 + #end if + + #if $outputtype.__str__ == "bam": + -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 SAM or BAM (depending on the chosen option), 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 + + +