changeset 0:8c17ddca0eee draft

Uploaded
author jjohnson
date Mon, 15 May 2017 16:27:18 -0400
parents
children 59f09c61031c
files ._bamtools-split-ref.xml ._bamtools-split-tag.xml bamtools-split-mapped.xml bamtools-split-paired.xml bamtools-split-ref.xml bamtools-split-tag.xml bamtools-split.xml bamtools-split.xml.save test-data/bamtools-input-paired.bam test-data/bamtools-input-tags.bam test-data/bamtools-input1.bam test-data/bamtools-input2.bam test-data/bamtools-split-test1.bam test-data/bamtools_input2.chr1 test-data/bamtools_input_tags.TAG_XG_N.bam test-data/bamtools_input_tags.TAG_XG_V.bam test-data/split_bam.MAPPED.bam test-data/split_bam.PAIRED_END.bam test-data/split_bam.SINGLE_END.bam test-data/split_bam.UNMAPPED.bam
diffstat 20 files changed, 523 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
Binary file ._bamtools-split-ref.xml has changed
Binary file ._bamtools-split-tag.xml has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bamtools-split-mapped.xml	Mon May 15 16:27:18 2017 -0400
@@ -0,0 +1,55 @@
+<tool id="bamSplitMapped" name="Split BAM by Mapped" version="2.4.0">
+    <description></description>
+    <requirements>
+        <requirement type="package" version="2.4.0">bamtools</requirement>
+    </requirements>
+    <command>
+        <![CDATA[
+            ln -s '${input_bam}' 'localbam.bam' &&
+            ln -s '${input_bam.metadata.bam_index}' 'localbam.bam.bai' &&
+            bamtools split -mapped
+            -in localbam.bam 
+            -stub split_bam 
+        ]]>
+    </command>
+    <inputs>
+        <param name="input_bam" type="data" format="bam" label="BAM dataset to split by mapped/unmapped"/>
+    </inputs>
+    <outputs>
+        <data format="bam" name="mapped" label="${input_bam.name} mapped" from_work_dir="split_bam.MAPPED.bam" />
+        <data format="bam" name="unmapped" label="${input_bam.name} unmapped" from_work_dir="split_bam.UNMAPPED.bam" />
+    </outputs>
+    <tests>
+        <test>
+            <param name="input_bam" ftype="bam" value="bamtools-input1.bam"/>
+            <output name="mapped" file="split_bam.MAPPED.bam"  compare="sim_size" delta="200" />
+            <output name="unmapped" file="split_bam.UNMAPPED.bam"  compare="sim_size" delta="200" />
+        </test>
+    </tests>
+    <help>
+**What is does**
+
+BAMTools split is a utility for splitting BAM files. It is based on BAMtools suite of tools by Derek Barnett (https://github.com/pezmaster31/bamtools).
+
+-----
+
+.. class:: warningmark
+
+
+**How it works**
+
+Splits the input BAM file into 2 output files named (MAPPED) and (UNMAPPED) containing mapped and unmapped reads, respectively.
+
+-----
+
+.. class:: infomark
+
+**More information**
+
+Additional information about BAMtools can be found at https://github.com/pezmaster31/bamtools/wiki
+
+    </help>
+    <citations>
+        <citation type="doi">10.1093/bioinformatics/btr174</citation>
+    </citations>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bamtools-split-paired.xml	Mon May 15 16:27:18 2017 -0400
@@ -0,0 +1,56 @@
+<tool id="bamSplitPaired" name="Split BAM by Paired/Single End" version="2.4.0">
+    <description></description>
+    <requirements>
+        <requirement type="package" version="2.4.0">bamtools</requirement>
+    </requirements>
+    <command>
+        <![CDATA[
+            ln -s '${input_bam}' 'localbam.bam' &&
+            ln -s '${input_bam.metadata.bam_index}' 'localbam.bam.bai' &&
+            bamtools split -paired
+            -in localbam.bam 
+            -stub split_bam 
+        ]]>
+    </command>
+    <inputs>
+        <param name="input_bam" type="data" format="bam" label="BAM dataset to split by single_end/paired_end"/>
+    </inputs>
+    <outputs>
+        <data format="bam" name="single" label="${input_bam.name} mapped" from_work_dir="split_bam.SINGLE_END.bam" />
+        <data format="bam" name="paired" label="${input_bam.name} unmapped" from_work_dir="split_bam.PAIRED_END.bam" />
+    </outputs>
+    <tests>
+        <test>
+            <param name="input_bam" ftype="bam" value="bamtools-input-paired.bam"/>
+            <output name="single" file="split_bam.SINGLE_END.bam"  compare="sim_size" delta="200" />
+            <output name="paired" file="split_bam.PAIRED_END.bam"  compare="sim_size" delta="200" />
+        </test>
+    </tests>
+    <help>
+**What is does**
+
+BAMTools split is a utility for splitting BAM files. It is based on BAMtools suite of tools by Derek Barnett (https://github.com/pezmaster31/bamtools).
+
+-----
+
+.. class:: warningmark
+
+
+**How it works**
+
+
+Splits the input BAM file into 2 output files named (SINGLE_END) and (PAIRED_END) containing single_end and paired_end reads, respectively.
+
+-----
+
+.. class:: infomark
+
+**More information**
+
+Additional information about BAMtools can be found at https://github.com/pezmaster31/bamtools/wiki
+
+    </help>
+    <citations>
+        <citation type="doi">10.1093/bioinformatics/btr174</citation>
+    </citations>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bamtools-split-ref.xml	Mon May 15 16:27:18 2017 -0400
@@ -0,0 +1,88 @@
+<tool id="bamSplitRef" name="Split BAM by Reference" version="2.4.0">
+    <description>into dataset list collection</description>
+    <requirements>
+        <requirement type="package" version="2.4.0">bamtools</requirement>
+    </requirements>
+    <command>
+        <![CDATA[
+            ln -s '${input_bam}' 'localbam.bam' &&
+            ln -s '${input_bam.metadata.bam_index}' 'localbam.bam.bai' &&
+            bamtools split -reference
+            -in localbam.bam 
+            -stub split_bam 
+            ## Preserve order from metadata in the output collection
+            #import re
+            #set $name = $re.sub('\W','_',$re.sub('\.bam$','',$input_bam.name))
+            #if str($refs) != 'None':
+                #set $ref_list = ' '.join(str($refs).split(","))
+            #else 
+                #set $ref_list = ' '.join([$re.sub('^.*__sq__(.+)__sq__.*$','\\1',n) if n.find('__sq__') >= 0 else n for n in str($input_bam.metadata.reference_names).split(',')])
+            #end if
+            && mkdir -p outputs
+            && (export I=0; 
+              for i in $ref_list; 
+                do I=\$((++I)); SN=`printf "split_bam.REF_%s.bam" "\$i"`; 
+                  if [ -e \$SN ]; then FN=`printf "outputs/split_bam%05d%s.%s.bam" \$((I)) '$name' "\$i"`; mv \$SN \$FN; fi;
+                done)
+        ]]>
+    </command>
+    <inputs>
+        <param name="input_bam" type="data" format="bam" label="BAM dataset to split by reference"/>
+        <param name="refs" type="select" optional="True" multiple="True" label="Select references (chromosomes and contigs) you would like to restrict bam to" >
+            <help><![CDATA[Click and type in the box above to see options. You can select multiple entries. 
+                  If "No options available" is displayed, you need to re-detect metadata on the input dataset.
+            ]]></help>
+            <options>
+                <filter type="data_meta" ref="input_bam" key="reference_names" />
+            </options>
+        </param>
+    </inputs>
+    <outputs>
+        <collection name="output_bams" type="list" label="${input_bam.name} Split List">
+            <discover_datasets pattern="split_bam\d*(?P&lt;designation&gt;.+)\.bam" ext="bam" directory="outputs" visible="false"/>
+        </collection>
+    </outputs>
+    <tests>
+        <test>
+            <param name="input_bam" ftype="bam" value="bamtools-input2.bam"/>
+            <output_collection name="output_bams"  type="list">
+                <element name="bamtools_input2.chr1"  file="bamtools_input2.chr1" compare="sim_size" delta="500" />
+            </output_collection>
+        </test>
+    </tests>
+    <help>
+**What is does**
+
+BAMTools split is a utility for splitting BAM files. It is based on BAMtools suite of tools by Derek Barnett (https://github.com/pezmaster31/bamtools).
+
+-----
+
+.. class:: warningmark
+
+**DANGER: Multiple Outputs**
+
+As described below, splitting a BAM dataset(s) on reference name or a tag value can produce very large numbers of outputs. Read below and know what you are doing.
+
+-----
+
+**How it works**
+
+Split alignments by reference name into a dataset list collection.  The collection will be in the same order as the input BAM references.
+
+In cases of unfinished genomes with very large number of reference sequences (scaffolds) 
+it can generate thousands (if not millions) of output datasets.
+
+
+-----
+
+.. class:: infomark
+
+**More information**
+
+Additional information about BAMtools can be found at https://github.com/pezmaster31/bamtools/wiki
+
+    </help>
+    <citations>
+        <citation type="doi">10.1093/bioinformatics/btr174</citation>
+    </citations>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bamtools-split-tag.xml	Mon May 15 16:27:18 2017 -0400
@@ -0,0 +1,70 @@
+<tool id="bamSplitTag" name="Split BAM by Tag" version="2.4.0">
+    <description>into dataset list collection</description>
+    <requirements>
+        <requirement type="package" version="2.4.0">bamtools</requirement>
+    </requirements>
+    <command>
+        <![CDATA[
+            #import re
+            #set $name = 'split_bam' + $re.sub('\W','_',$re.sub('\.bam$','',$input_bam.name))
+            ln -s '${input_bam}' 'localbam.bam' &&
+            ln -s '${input_bam.metadata.bam_index}' 'localbam.bam.bai' &&
+            bamtools split -tag $tag_name
+            -in 'localbam.bam' 
+            -stub '$name'
+        ]]>
+    </command>
+    <inputs>
+        <param name="input_bam" type="data" format="bam" label="BAM dataset to split by tag value"/>
+        <param name="tag_name" type="text" value="NM" label="Enter tag name here" help="For example, to split on NM tag enter &quot;NM&quot;"/>
+    </inputs>
+    <outputs>
+        <collection name="output_bams" type="list" label="${input_bam.name} Split List">
+            <discover_datasets pattern="split_bam(?P&lt;designation&gt;.+)\.bam" ext="bam" visible="false"/>
+        </collection>
+    </outputs>
+    <tests>
+        <test>
+            <param name="input_bam" ftype="bam" value="bamtools-input-tags.bam"/>
+            <param name="tag_name" value="XG"/>
+            <output_collection name="output_bams"  type="list">
+                <element name="bamtools_input_tags.TAG_XG_V.bam"  file="bamtools_input_tags.TAG_XG_V.bam" compare="sim_size" delta="500" />
+            </output_collection>
+        </test>
+
+    </tests>
+    <help>
+**What is does**
+
+BAMTools split is a utility for splitting BAM files. It is based on BAMtools suite of tools by Derek Barnett (https://github.com/pezmaster31/bamtools).
+
+-----
+
+.. class:: warningmark
+
+**DANGER: Multiple Outputs**
+
+As described below, splitting a BAM dataset(s) on tag value can produce very large numbers of outputs. Read below and know what you are doing.
+
+-----
+
+**How it works**
+
+Split alignments by tag name into a dataset list collection.
+
+This can generate a huge number of output datasets depending on the number of distinct values of the TAG.
+
+
+-----
+
+.. class:: infomark
+
+**More information**
+
+Additional information about BAMtools can be found at https://github.com/pezmaster31/bamtools/wiki
+
+    </help>
+    <citations>
+        <citation type="doi">10.1093/bioinformatics/btr174</citation>
+    </citations>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bamtools-split.xml	Mon May 15 16:27:18 2017 -0400
@@ -0,0 +1,108 @@
+<tool id="bamSplit" name="Split" version="2.4.0">
+    <description>BAM datasets on variety of attributes</description>
+    <requirements>
+        <requirement type="package" version="2.4.0">bamtools</requirement>
+    </requirements>
+    <command>
+        <![CDATA[
+            echo "BAM" > $report &&
+            #for $bam_count, $input_bam in enumerate( $input_bams ):
+                ln -s "${input_bam}" "localbam_${bam_count}.bam" &&
+                ln -s "${input_bam.metadata.bam_index}" "localbam_${bam_count}.bam.bai" &&
+            #end for
+            bamtools
+            split
+            #if str ( $analysis_type.analysis_type_selector ) == "-tag" :
+                ${analysis_type.analysis_type_selector} "${analysis_type.tag_name}"
+            #else
+                ${analysis_type.analysis_type_selector}
+            #end if
+            -stub split_bam
+            #for $bam_count, $input_bam in enumerate( $input_bams ):
+                -in "localbam_${bam_count}.bam"
+            #end for
+        ]]>
+    </command>
+    <inputs>
+        <param name="input_bams" type="data" format="bam" label="BAM dataset(s) to filter" min="1" multiple="True"/>
+        <conditional name="analysis_type">
+            <param name="analysis_type_selector" type="select" label="Split BAM dataset(s) by" help="See help below for explanation of each option">
+                <option value="-mapped">Mapping status (-mapped)</option>
+                <option value="-paired">Pairing status (-paired)</option>
+                <option value="-reference">Reference name (-reference)</option>
+                <option value="-tag">Specific tag (-tag)</option>
+            </param>
+            <when value="-mapped" />
+            <when value="-paired" />
+            <when value="-reference" />
+            <when value="-tag">
+                <param name="tag_name" type="text" value="NM" label="Enter tag name here" help="For example, to split on NM tag enter &quot;NM&quot;"/>
+            </when>
+        </conditional>
+    </inputs>
+    <outputs>
+        <data format="txt" name="report" label="BAMSplitter Run" hidden="true">
+            <discover_datasets pattern="split_bam\.(?P&lt;designation&gt;.+)\.bam" ext="bam" visible="true"/>
+        </data>
+    </outputs>
+    <tests>
+        <test>
+            <param name="input_bams" ftype="bam" value="bamtools-input1.bam"/>
+            <param name="analysis_type_selector" value="-mapped"/>
+            <output name="report">
+                <assert_contents>
+                    <has_line line="BAM" />
+                </assert_contents>
+                <discovered_dataset designation="MAPPED" file="bamtools-split-test1.bam" ftype="bam"/>
+            </output>
+        </test>
+    </tests>
+    <help>
+**What is does**
+
+BAMTools split is a utility for splitting BAM files. It is based on BAMtools suite of tools by Derek Barnett (https://github.com/pezmaster31/bamtools).
+
+-----
+
+.. class:: warningmark
+
+**DANGER: Multiple Outputs**
+
+As described below, splitting a BAM dataset(s) on reference name or a tag value can produce very large numbers of outputs. Read below and know what you are doing.
+
+-----
+
+**How it works**
+
+The following options can be specified via "**Split BAM dataset(s) by**" dropdown::
+
+  Mapping status (-mapped)          split mapped/unmapped and generate two output files
+                                    named (MAPPED) and (UNMAPPED) containing mapped and unmapped
+                                    reads, respectively.
+
+  Pairing status (-paired)          split single-end/paired-end alignments and generate two output files
+                                    named (SINGLE_END) and (PAIRED_END) containing paired and unpaired
+                                    reads, respectively.
+
+  Reference name (-reference)       split alignments by reference name. In cases of unfinished genomes with
+                                    very large number of reference sequences (scaffolds) it can generate
+                                    thousands (if not millions) of output datasets.
+
+  Specific tag (-tag)               split alignments based on all values of TAG encountered. Choosing this
+                                    option from the menu will allow you to enter the tag name. As was the
+                                    case with the reference splitting above, this option can produce very
+                                    large number of outputs if a tag has a large number of unique values.
+
+-----
+
+.. class:: infomark
+
+**More information**
+
+Additional information about BAMtools can be found at https://github.com/pezmaster31/bamtools/wiki
+
+    </help>
+    <citations>
+        <citation type="doi">10.1093/bioinformatics/btr174</citation>
+    </citations>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bamtools-split.xml.save	Mon May 15 16:27:18 2017 -0400
@@ -0,0 +1,146 @@
+<tool id="bamSplit" name="Split" version="2.4.1">
+    <description>BAM datasets on variety of attributes</description>
+    <macros>
+        <xml name="macro_output_type">
+            <param name="output_type" type="select" label="output as">
+                <option value="history_items">history items</option>
+                <option value="dataset_collection">dataset_collection</option>
+            </param>
+        </xml>
+    </macros>
+    <requirements>
+        <requirement type="package" version="2.4.0">bamtools</requirement>
+    </requirements>
+    <command>
+        <![CDATA[
+            echo "BAM" > $report &&
+            #for $bam_count, $input_bam in enumerate( $input_bams ):
+                ln -s "${input_bam}" "localbam_${bam_count}.bam" &&
+                ln -s "${input_bam.metadata.bam_index}" "localbam_${bam_count}.bam.bai" &&
+            #end for
+            bamtools
+            split
+            #if str ( $analysis_type.analysis_type_selector ) == "-tag" :
+                ${analysis_type.analysis_type_selector} "${analysis_type.tag_name}"
+            #else
+                ${analysis_type.analysis_type_selector}
+            #end if
+            -stub split_bam
+            #for $bam_count, $input_bam in enumerate( $input_bams ):
+                -in "localbam_${bam_count}.bam"
+            #end for
+            #if str ( $analysis_type.analysis_type_selector ) == "-reference"  and $analysis_type.output_type == "dataset_collection": 
+                #import re
+                #set $name = $re.sub('\W','_',$re.sub('\.bam$','',$input_bams[0].name))
+                #set $ref_list = ' '.join([$re.sub('^.*__sq__(.+)__sq__.*$','\\1',n) if n.find('__sq__') >= 0 else n for n in str($input_bam.metadata.reference_names).split(',')])
+                    && (export I=0; 
+                      for i in $ref_list; 
+                        do I=\$((++I)); SN=`printf "split_bam.REF_%s.bam" "\$i"`; 
+                           if [ -e \$SN ]; 
+                             then FN=`printf "split_bam%05d%s.%s.bam" \$((I)) "$name" "\$i"`; 
+                             mv \$SN \$FN;
+                           fi;
+                        done)
+            #end if
+        ]]>
+    </command>
+    <inputs>
+        <param name="input_bams" type="data" format="bam" label="BAM dataset(s) to filter" min="1" multiple="True"/>
+        <conditional name="analysis_type">
+            <param name="analysis_type_selector" type="select" label="Split BAM dataset(s) by" help="See help below for explanation of each option">
+                <option value="-mapped">Mapping status (-mapped)</option>
+                <option value="-paired">Pairing status (-paired)</option>
+                <option value="-reference">Reference name (-reference)</option>
+                <option value="-tag">Specific tag (-tag)</option>
+            </param>
+            <when value="-mapped" />
+            <when value="-paired" />
+            <when value="-reference" >
+                <expand macro="macro_output_type" />
+            </when>
+            <when value="-tag">
+                <param name="tag_name" type="text" value="NM" label="Enter tag name here" help="For example, to split on NM tag enter &quot;NM&quot;"/>
+                <expand macro="macro_output_type" />
+            </when>
+        </conditional>
+    </inputs>
+    <outputs>
+        <data format="txt" name="report" label="BAMSplitter Run" hidden="true">
+            <discover_datasets pattern="split_bam\.(?P&lt;designation&gt;.+)\.bam" ext="bam" visible="true"/>
+            <filter>analysis_type['analysis_type_selector'] in ('-mapped','-paired') or analysis_type['output_type'] != 'dataset_collection'</filter>
+        </data>
+        <collection name="output_bams" type="list" label="${input_bams[0].name} by ${analysis_type.analysis_type_selector.replace('-','')}">
+            <discover_datasets pattern="split_bam\d*(?P&lt;designation&gt;.+)\.bam" ext="bam" visible="false"/>
+            <filter>analysis_type['analysis_type_selector'] in ('-reference','-tag') and analysis_type['output_type'] == 'dataset_collection'</filter>
+        </collection>
+    </outputs>
+    <tests>
+        <test>
+            <param name="input_bams" ftype="bam" value="bamtools-input1.bam"/>
+            <param name="analysis_type_selector" value="-mapped"/>
+            <output name="report">
+                <assert_contents>
+                    <has_line line="BAM" />
+                </assert_contents>
+                <discovered_dataset designation="MAPPED" file="bamtools-split-test1.bam" ftype="bam"/>
+            </output>
+        </test>
+        <test>
+            <param name="input_bams" ftype="bam" value="bamtools-input2.bam"/>
+            <param name="analysis_type_selector" value="-reference"/>
+            <param name="output_type" value="dataset_collection"/>
+            <output_collection name="output_bams"  type="list">
+                <element name="bamtools_input2.chr1"  file="bamtools_input2.chr1" compare="sim_size" delta="500" />
+            </output_collection>
+        </test>
+
+    </tests>
+    <help>
+**What is does**
+
+BAMTools split is a utility for splitting BAM files. It is based on BAMtools suite of tools by Derek Barnett (https://github.com/pezmaster31/bamtools).
+
+-----
+
+.. class:: warningmark
+
+**DANGER: Multiple Outputs**
+
+As described below, splitting a BAM dataset(s) on reference name or a tag value can produce very large numbers of outputs. Read below and know what you are doing.
+
+-----
+
+**How it works**
+
+The following options can be specified via "**Split BAM dataset(s) by**" dropdown::
+
+  Mapping status (-mapped)          split mapped/unmapped and generate two output files
+                                    named (MAPPED) and (UNMAPPED) containing mapped and unmapped
+                                    reads, respectively.
+
+  Pairing status (-paired)          split single-end/paired-end alignments and generate two output files
+                                    named (SINGLE_END) and (PAIRED_END) containing paired and unpaired
+                                    reads, respectively.
+
+  Reference name (-reference)       split alignments by reference name. In cases of unfinished genomes with
+                                    very large number of reference sequences (scaffolds) it can generate
+                                    thousands (if not millions) of output datasets.
+
+  Specific tag (-tag)               split alignments based on all values of TAG encountered. Choosing this
+                                    option from the menu will allow you to enter the tag name. As was the
+                                    case with the reference splitting above, this option can produce very
+                                    large number of outputs if a tag has a large number of unique values.
+
+-----
+
+.. class:: infomark
+
+**More information**
+
+Additional information about BAMtools can be found at https://github.com/pezmaster31/bamtools/wiki
+
+    </help>
+    <citations>
+        <citation type="doi">10.1093/bioinformatics/btr174</citation>
+    </citations>
+</tool>
Binary file test-data/bamtools-input-paired.bam has changed
Binary file test-data/bamtools-input-tags.bam has changed
Binary file test-data/bamtools-input1.bam has changed
Binary file test-data/bamtools-input2.bam has changed
Binary file test-data/bamtools-split-test1.bam has changed
Binary file test-data/bamtools_input2.chr1 has changed
Binary file test-data/bamtools_input_tags.TAG_XG_N.bam has changed
Binary file test-data/bamtools_input_tags.TAG_XG_V.bam has changed
Binary file test-data/split_bam.MAPPED.bam has changed
Binary file test-data/split_bam.PAIRED_END.bam has changed
Binary file test-data/split_bam.SINGLE_END.bam has changed
Binary file test-data/split_bam.UNMAPPED.bam has changed