view filter_contigs.xml @ 2:1442e77ee8e9 draft default tip

Uploaded
author greg
date Tue, 25 Apr 2023 12:59:47 +0000
parents 2c61adbbdbdb
children
line wrap: on
line source

<tool id="filter_contigs" name="Filter contigs" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
  <description>from an assembled FASTA file</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements"/>
    <command detect_errors="exit_code"><![CDATA[
#if $input.is_of_type('fasta.gz'):
    gunzip -c '$input' > 'input.fasta' &&
#else:
    ln -s '$input' 'input.fasta' &&
#end if
#if str($max_min_cond.max_min) == 'max':
    faidx -i chromsizes 'input.fasta' | awk '($2 <= $max_min_cond.max_len) {print $1}' | parallel -n1 -n1 \$(which faidx) 'input.fasta' > '$output'
#else:
    faidx -i chromsizes 'input.fasta' | awk '($2 > $max_min_cond.min_len) {print $1}' | parallel -n1 -n1 \$(which faidx) 'input.fasta' > '$output'
#end if

    ]]></command>
    <inputs>
        <param name="input" type="data" format="fasta,fasta.gz" label="Assembled FASTA file"/>
        <conditional name="max_min_cond">
            <param name="max_min" type="select" label="Use minimum or maximum contig length when filtering?">
                <option value="max" selected="true">Maximum - contigs shorter than or equal to this length will be filtered</option>
                <option value="min">Minimum - contigs longer than this length will be filtered</option>
            </param>
            <when value="max">
                <param name="max_len" type="integer" value="1500000" min="0" label="Maximum contig length"/>
            </when>
            <when value="min">
                <param name="min_len" type="integer" value="1000" min="0" label="Maximum contig length"/>
            </when>
        </conditional>
    </inputs>
    <outputs>
        <data name="output" format="fasta"/>
    </outputs>
    <tests>
        <test>
            <param name="input" value="input.fasta.gz" ftype="fasta.gz"/>
            <param name="max_len" value="30000"/>
            <output name="output" ftype="fasta">
                <assert_contents>
                    <has_size value="51690"/>
                    <has_text text=">contig_10"/>
                    <has_text text=">contig_7"/>
                </assert_contents>
            </output>
        </test>
        <test>
            <param name="input" value="input2.fasta" ftype="fasta"/>
            <param name="max_len" value="30000"/>
            <output name="output" ftype="fasta">
                <assert_contents>
                    <has_size value="28492"/>
                    <has_text text=">contig_7"/>
                </assert_contents>
            </output>
        </test>
    </tests>
    <help>
**What it does**

Filters contigs from an assembled fasta file that are longer than the specified length.
    </help>
    <expand macro="citations"/>
</tool>