view samtools_slice_bam.xml @ 6:b8beef827165 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tool_collections/samtools/samtools_slice_bam commit 9c5a35ce695c3d134e41d8695487edd5f71ea33c
author iuc
date Sun, 08 Sep 2024 03:26:35 +0000
parents b5c88b7b153e
children
line wrap: on
line source

<tool id="samtools_slice_bam" name="Slice" version="2.0.3" profile="@PROFILE@">
    <description>BAM by genomic regions</description>
    <macros>
        <import>macros.xml</import>
    </macros>

    <expand macro="requirements"/>
    <expand macro="stdio"/>
    <expand macro="version_command"/>

    <command><![CDATA[
    ln -s '${input_bam}' temp_input.bam &&
    ln -s '${input_bam.metadata.bam_index}' temp_input.bam.bai &&

    #if str($slice_method.slice_method_selector) == "bed":
        samtools view -@ \${GALAXY_SLOTS:-1} -b -L "${input_interval}" -o unsorted_output.bam temp_input.bam &&
    #elif str($slice_method.slice_method_selector) == "chr":
        samtools view -@ \${GALAXY_SLOTS:-1} -b -o unsorted_output.bam temp_input.bam
        ${ ' '.join( map( lambda x:'"%s"' % ( x ), str( $slice_method.refs ).split(",") ) ) } &&
    #elif str($slice_method.slice_method_selector) == "man":
        samtools view -@ \${GALAXY_SLOTS:-1} -b -o unsorted_output.bam temp_input.bam

        #for $region in $slice_method.regions:
            "${region.chrom}:${region.start}-${region.end}"
        #end for
        &&
    #end if

    samtools sort
        -O bam
        -T "\${TMPDIR:-.}"
        -@ \${GALAXY_SLOTS:-1}
        -o '${output_bam}'
        unsorted_output.bam
    ]]></command>
    <inputs>
        <param name="input_bam" type="data" format="bam" label="Select BAM dataset to slice" />
        <conditional name="slice_method">
            <param name="slice_method_selector" type="select" label="How do you want to slice your dataset?">
                <option value="bed">using a list of intervals from a BED dataset</option>
                <option value="chr">by chromosomes/contigs present in the BAM dataset</option>
                <option value="man">by chromosomes/contigs and coordinates</option>
            </param>
            <when value="bed">
                <param name="input_interval" type="data" format="bed" label="BED file" help="BED datasets can be obtained using &quot;Get Data -> UCSC Main&quot; datasource" />
            </when>
            <when value="chr">
                <param name="refs" type="select" optional="False" multiple="True" label="Select references (chromosomes and contigs) you would like to restrict bam to" help="Click and type in the box above to see options. You can select multiple entries. If &quot;No options available&quot; is displayed, you need to re-detect metadata on the input dataset. See help section below.">

                    <!-- The options tagset below extracts reference names from bam file metadata -->
                    <!-- This will not work with bed files with old style metadata. However this  -->
                    <!-- Can be easily fixed by re-deceting metadata on a bam dataset by clicking -->
                    <!-- The pencil icon and settind datatype to "bam"                            -->
                    <!-- This change has been commited in the following pull request:             -->
                    <!-- https://github.com/galaxyproject/galaxy/pull/107                         -->

                    <options>
                        <filter type="data_meta" ref="input_bam" key="reference_names" />
                    </options>
                </param>
            </when>
            <when value="man">
                <repeat name="regions" title="Regions" min="1">
                    <param name="chrom" type="select" optional="False" label="Select references (chromosomes and contigs) you would like to restrict bam to" help="Select chromosome/contig from the list. If &quot;No options available&quot; is displayed, you need to re-detect metadata on the input dataset. See help section below.">

                        <!-- See comments above -->

                        <options>
                            <filter type="data_meta" ref="input_bam" key="reference_names" />
                        </options>
                    </param>
                    <param name="start" type="integer" min="1" value="0" label="Enter START coordinate (1-based)"/>
                    <param name="end" type="integer" min="1" value="100" label="Enter END coordinate"/>
                </repeat>
            </when>
        </conditional>
    </inputs>
    <outputs>
        <data name="output_bam" format="bam" />
    </outputs>
    <tests>
        <test>
            <param name="input_bam" ftype="bam" value="bam-slice-input.bam" />
            <param name="slice_method_selector" value="bed"/>
            <param name="input_interval" ftype="bed" value="bam-slice.bed" />
            <output name="output_bam" file="bam-slice-test1.bam" ftype="bam" lines_diff="4" />
        </test>
        <test>
            <param name="input_bam" ftype="bam" value="bam-slice-input.bam" />
            <param name="slice_method_selector" value="chr"/>
            <param name="refs" value="chrM" />
            <output name="output_bam" file="bam-slice-test2.bam" ftype="bam" lines_diff="4" />
        </test>
        <test>
            <param name="input_bam" ftype="bam" value="bam-slice-input.bam" />
            <param name="slice_method_selector" value="man"/>
            <param name="chrom" value="chrM" />
            <param name="start" value="1" />
            <param name="end" value="1000" />
            <output name="output_bam" file="bam-slice-test3.bam" ftype="bam" lines_diff="4"/>
        </test>
    </tests>
    <help><![CDATA[
**What it does**

Allows to restrict (slice) input BAM dataset to a list of intervals defined in a BED file, individual chromosomes, or manually set list of coordinates.
BED datasets can be obtained from **Get Data -> UCSC Main**.

This tool is based on ``samtools view`` command.

@no-chrom-options@
    ]]></help>
    <expand macro="citations"/>
</tool>