changeset 0:97bb72be07f9 draft default tip

Uploaded first version
author brenninc
date Tue, 10 May 2016 03:59:17 -0400
parents
children
files samtools_flag_filter.xml samtools_macros.xml tool_dependencies.xml
diffstat 3 files changed, 182 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/samtools_flag_filter.xml	Tue May 10 03:59:17 2016 -0400
@@ -0,0 +1,104 @@
+<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>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/samtools_macros.xml	Tue May 10 03:59:17 2016 -0400
@@ -0,0 +1,72 @@
+<?xml version="1.0"?>
+<!-- Copied from https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/samtools/samtools_slice_bam -->
+<macros>
+    <xml name="requirements">
+        <requirements>
+            <requirement type="package" version="1.2">samtools</requirement>
+            <yield/>
+        </requirements>
+    </xml>
+    <xml name="citations">
+        <citations>
+            <citation type="bibtex">
+                @misc{SAM_def,
+                title={Definition of SAM/BAM format},
+                url = {https://samtools.github.io/hts-specs/SAMv1.pdf},}
+            </citation>
+            <citation type="doi">10.1093/bioinformatics/btp352</citation>
+            <citation type="doi">10.1093/bioinformatics/btr076</citation>
+            <citation type="doi">10.1093/bioinformatics/btr509</citation>
+            <citation type="bibtex">
+                @misc{Danecek_et_al,
+                Author={Danecek, P., Schiffels, S., Durbin, R.},
+                title={Multiallelic calling model in bcftools (-m)},
+                url = {http://samtools.github.io/bcftools/call-m.pdf},}
+            </citation>
+            <citation type="bibtex">
+                @misc{Durbin_VCQC,
+                Author={Durbin, R.},
+                title={Segregation based metric for variant call QC},
+                url = {http://samtools.github.io/bcftools/rd-SegBias.pdf},}
+            </citation>
+            <citation type="bibtex">
+                @misc{Li_SamMath,
+                Author={Li, H.},
+                title={Mathematical Notes on SAMtools Algorithms},
+                url = {http://www.broadinstitute.org/gatk/media/docs/Samtools.pdf},}
+            </citation>
+            <citation type="bibtex">
+                @misc{SamTools_github,
+                title={SAMTools GitHub page},
+                url = {https://github.com/samtools/samtools},}
+            </citation>
+        </citations>
+    </xml>
+    <xml name="version_command">
+        <version_command>samtools --version | head -n 1 | awk '{ print $2 }'</version_command>
+    </xml>
+    <xml name="stdio">
+        <stdio>
+            <exit_code range="1:" level="fatal" description="Error" />
+        </stdio>
+    </xml>
+    <token name="@no-chrom-options@">
+-----
+
+.. class:: warningmark
+
+**No options available? How to re-detect metadata**
+
+If you see a &quot;No options available&quot; within the &quot;**Select references (chromosomes and contigs) you would like to restrict bam to**&quot; drop down, you need to re-detect metadata for the dataset you are trying to process. To do this follow these steps:
+
+1. Click on the **pencil** icon adjacent to the dataset in the history
+2. A new menu will appear in the center pane of the interface
+3. Click **Datatype** tab
+4. Set **New Type** to **BAM**
+5. Click **Save**
+
+The medatada will be re-detected and you will be able to see the list of reference sequences in the &quot;**Select references (chromosomes and contigs) you would like to restrict bam to**&quot; drop-down.
+
+    </token>
+
+</macros>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_dependencies.xml	Tue May 10 03:59:17 2016 -0400
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<tool_dependency>
+    <package name="samtools" version="1.2">
+        <repository changeset_revision="f6ae3ba3f3c1" name="package_samtools_1_2" owner="iuc" prior_installation_required="True" toolshed="https://toolshed.g2.bx.psu.edu" />
+    </package>
+</tool_dependency>