view samtools_flag_filter.xml @ 0:97bb72be07f9 draft default tip

Uploaded first version
author brenninc
date Tue, 10 May 2016 03:59:17 -0400
parents
children
line wrap: on
line source

<tool id="samtools_flag_filter" name="Samtools flag_filter" version="0.1">
  <description>Use Samtools' view tool to filter alignments based on the flag field.</description>
  <macros>
    <import>samtools_macros.xml</import>
  </macros>
  <expand macro="requirements"></expand>
  <expand macro="stdio"></expand>
  <expand macro="version_command"></expand>

    <command>
    <![CDATA[
        samtools sort -@ \${GALAXY_SLOTS:-1} -o temp_bam -O bam -T dataset "${input}" &&
        samtools view -@ \${GALAXY_SLOTS:-1}
        #for $bit in $bits
            -${bit.state} ${bit.flag}
        #end for
        -b -o "${output}"  temp_bam
    ]]>
    </command>
    <inputs>
        <param name="input" format="bam,sam" label="BAM/SAM dataset to filter by flag" type="data" />
        <repeat name="bits" title="Flag">
            <param name="flag" type="select" label="Type">
                <option value="0x0001">Read is paired  0x0001</option>
                <option value="0x0002">Read is mapped in a proper pair  0x0002</option>
                <option value="0x0004">The read is unmapped  0x0004</option>
                <option value="0x0008">The mate is unmapped  0x0008</option>
                <option value="0x0010">Read strand  0x0010</option>
                <option value="0x0020">Mate strand  0x0020</option>
                <option value="0x0040">Read is the first in a pair  0x0040</option>
                <option value="0x0080">Read is the second in a pair  0x0080</option>
                <option value="0x0100">The alignment or this read is not primary  0x0100</option>
                <option value="0x0200">The read fails platform/vendor quality checks  0x0200</option>
                <option value="0x0400">The read is a PCR or optical duplicate  0x0400</option>
            </param>
            <param name="state" type="select" display="radio" label="Set the states for this flag">
                <option value="f">Keep only alignments with this flag set  --f</option>
                <option value="F">Remove all alignments with this flag set  --F</option>
            </param>
    </repeat>

    </inputs>
    <outputs>
        <data format="bam" name="output" label="Filtered by flag from ${on_string}" />
    </outputs>
    <tests>
        <test>
            <param ftype="bam" name="input" value="unfiltered.bam" />
            <param name="bits_0|flag" value="The read is unmapped  0x0004"/>
            <param name="bits_0|state" value="f"/>
            <output file="f0X0004.bam" ftype="bam" name="output" />
        </test>
        <test>
            <param ftype="bam" name="input" value="unfiltered.bam" />
            <param name="bits_0|flag" value="The read is unmapped  0x0004"/>
            <param name="bits_0|state" value="f"/>
            <param name="bits_1|flag" value="The mate is unmapped  0x0008"/>
            <param name="bits_1|state" value="f"/>
            <output file="f0X0004_plus8.bam" ftype="bam" name="output" />
        </test>
        <test>
            <param ftype="bam" name="input" value="unfiltered.bam" />
            <param name="bits_0|flag" value="The read is unmapped  0x0004"/>
            <param name="bits_0|state" value="f"/>
            <param name="bits_1|flag" value="The mate is unmapped  0x0008"/>
            <param name="bits_1|state" value="F"/>
            <output file="f0X0004_less8.bam" ftype="bam" name="output" />
        </test>
    </tests>
    <help>
<![CDATA[
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.

Alignments can be excluded based on either the presence or absence of that bit in their flag file.

Multiple check can be carried out in the same pass.

The flag values used are:

0x0001: Read is paired

0x0002: Read is mapped in a proper pair

0x0004: The read is unmapped

0x0008: The mate is unmapped

0x0010: Read strand

0x0020: Mate strand

0x0040: Read is the first in a pair

0x0080: Read is the second in a pair

0x0100: The alignment or this read is not primary

0x0200: The read fails platform/vendor quality checks

0x0400: The read is a PCR or optical duplicate
]]>
  </help>
    <expand macro="citations"></expand>
</tool>