view samtools_faidx.xml @ 1:76c27c4861bd draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tool_collections/samtools/samtools_faidx commit 7ba11a2aa8901b555a95e284e4fb83c8dca2833e
author iuc
date Tue, 04 Nov 2025 22:34:23 +0000
parents baa79754a17e
children
line wrap: on
line source

<tool id="samtools_faidx" name="Samtools faidx" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
    <description>Index a FASTA file</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements"/>
    <expand macro="stdio"/>
    <expand macro="version_command"/>
    <command><![CDATA[
        #set is_fastq = ("fastq" in $input.ext)
        #if $input.ext.endswith(".gz") or $input.ext.endswith(".bgz") or $input.ext == "bgzip"
            ln -s '$input' input.gz &&
            samtools faidx
            #if $is_fastq
                --fastq
            #end if
                input.gz
                --fai-idx '$output'
                --gzi-idx input.gz.gzi
            || (
                echo "Failed to index compressed reference. Trying decompressed ..." 1>&2 &&
                gzip -dc input.gz > input.plain &&
                samtools faidx
                #if $is_fastq
                    --fastq
                #end if
                    input.plain
                    --fai-idx '$output'
            )
        #else
            ln -s '$input' input &&
            samtools faidx
            #if $is_fastq
                --fastq
            #end if
                input
                --fai-idx '$output'
        #end if
    ]]></command>
    <inputs>
        <param name="input"
        type="data"
        format="fasta,fasta.gz,fastqsanger,fastqsanger.gz,fastqillumina,fastqillumina.gz"
        label="Dataset with sequences (FASTA or FASTQ; auto-detected)" />
    </inputs>
    <outputs>
        <data name="output" format="tabular"/>
    </outputs>
    <tests>
        <test expect_num_outputs="1">
            <param name="input" value="samtools_fastx-out1-2.fasta" />
            <output name="output" file="out_fasta.tabular" />
        </test>
        <test expect_num_outputs="1">
            <param name="input" value="samtools_fastx-out1-2.fasta.gz" />
            <output name="output" file="out_fasta.tabular" />
            <assert_stderr>
                <has_line line="Failed to index compressed reference. Trying decompressed ..." />
                <has_line line="[E::fai_build3_core] Cannot index files compressed with gzip, please use bgzip"/>
            </assert_stderr>
        </test>
        <test expect_num_outputs="1">
            <param name="input" value="samtools_fastx-out1-2.fasta.bgz" />
            <output name="output" file="out_fasta.tabular" />
            <assert_stderr>
                <has_line line="Failed to index compressed reference. Trying decompressed ..." negate="true" />
                <has_line line="[E::fai_build3_core] Cannot index files compressed with gzip, please use bgzip" negate="true"/>
            </assert_stderr>
        </test>
        <test expect_num_outputs="1">
            <param name="input" value="samtools_fastx-out1-2.fastq" />
            <output name="output" file="out_fastq.tabular" />
        </test>
        <test expect_num_outputs="1">
            <param name="input" value="samtools_fastx-out1-2.fastq.gz" />
            <output name="output" file="out_fastq.tabular" />
            <assert_stderr>
                <has_line line="Failed to index compressed reference. Trying decompressed ..."/>
                <has_line line="[E::fai_build3_core] Cannot index files compressed with gzip, please use bgzip"/>
            </assert_stderr>
        </test>
        <test expect_num_outputs="1">
            <param name="input" value="samtools_fastx-out1-2.fastq.bgz" />
            <output name="output" file="out_fastq.tabular" />
            <assert_stderr>
                <has_line line="Failed to index compressed reference. Trying decompressed ..." negate="true"/>
                <has_line line="[E::fai_build3_core] Cannot index files compressed with gzip, please use bgzip" negate="true"/>
            </assert_stderr>
        </test>
        <test expect_num_outputs="1">
            <param name="input" value="samtools_fastx-out1-2.fastq" ftype="fastqsanger" />
            <output name="output" file="out_fastq.tabular" />
        </test>
        <test expect_num_outputs="1">
            <param name="input" value="samtools_fastx-out1-2.fastq.gz" ftype="fastqsanger.gz" />
            <output name="output" file="out_fastq.tabular" />
            <assert_stderr>
                <has_line line="Failed to index compressed reference. Trying decompressed ..." />
                <has_line line="[E::fai_build3_core] Cannot index files compressed with gzip, please use bgzip" />
            </assert_stderr>
        </test>
        <test expect_num_outputs="1">
            <param name="input" value="samtools_fastx-out1-2.fastq.bgz" ftype="fastqsanger.gz" />
            <output name="output" file="out_fastq.tabular" />
            <assert_stderr>
                <has_line line="Failed to index compressed reference. Trying decompressed ..." negate="true" />
                <has_line line="[E::fai_build3_core] Cannot index files compressed with gzip, please use bgzip" negate="true" />
            </assert_stderr>
        </test>
        <test expect_num_outputs="1">
            <param name="input" value="samtools_fastx-out1-2.fastq" ftype="fastqillumina" />
            <output name="output" file="out_fastq.tabular" />
        </test>
        <test expect_num_outputs="1">
            <param name="input" value="samtools_fastx-out1-2.fastq.gz" ftype="fastqillumina.gz" />
            <output name="output" file="out_fastq.tabular" />
            <assert_stderr>
                <has_line line="Failed to index compressed reference. Trying decompressed ..." />
                <has_line line="[E::fai_build3_core] Cannot index files compressed with gzip, please use bgzip" />
            </assert_stderr>
        </test>
        <test>  
            <param name="input" value="samtools_fastx-out1-2.fastq.bgz" ftype="fastqillumina.gz" />
            <output name="output" file="out_fastq.tabular" />
            <assert_stderr>
                <has_line line="Failed to index compressed reference. Trying decompressed ..." negate="true" />
                <has_line line="[E::fai_build3_core] Cannot index files compressed with gzip, please use bgzip" negate="true" />
            </assert_stderr>
        </test>
    </tests>
    <help><![CDATA[
        **What it does**

        Runs the ``samtools faidx`` command to index reference sequence in the FASTA format reference sequence.

        If the input file is of ``fastq`` type, passes the --fastq flag to accomodate the ``samtools faidx`` command line tool.

        **Notes on compression**
        - ``samtools faidx`` supports **BGZF-compressed** FASTA files (e.g. ``.fa.bgz`` / ``.fasta.bgz``).
        - Plain ``.fasta.gz`` may need to be decompressed first, depending on how it was created.

        Full `documentation <https://www.htslib.org/doc/samtools-faidx.html>`_ for the faidx command.
    ]]></help>
    <expand macro="citations"/>
</tool>