view fastq_dump.xml @ 32:fb723c531be5 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/sra-tools commit ac10fe34f1b2d5e8109dcaaf42b7870bee57827b
author iuc
date Wed, 25 Oct 2023 07:10:06 +0000
parents 734abc7ac21d
children 8848455c0270
line wrap: on
line source

<tool id="fastq_dump" name="Download and Extract Reads in FASTQ" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
    <description>format from NCBI SRA</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="edam_ontology"/>
    <expand macro="bio_tools"/>
    <expand macro="requirements"/>
    <version_command>fastq-dump --version | tr -d $'\n'</version_command>
    <command detect_errors="exit_code"><![CDATA[
    @COPY_CONFIGFILE@
    @SET_ACCESSIONS@

    #if $input.input_select == "sra_file":
        fastq-dump --log-level fatal --accession "\$acc"
    #else:
        ## Do not use prefetch if region is specified, to avoid downloading
        ## the complete sra file.
        #if ( str( $adv.region ) == "" ) and ( str( $adv.minID ) == "" ) and ( str( $adv.maxID ) == "" ):
            prefetch -X 200000000 "\$acc" &&
        #end if
        fastq-dump --accession "\$acc"
    #end if
    --split-files
    --defline-seq '$adv.defline_seq'
    --defline-qual '+'

    $adv.split
    #if str( $adv.alignments ) == "aligned":
        --aligned
    #end if
    #if str( $adv.alignments ) == "unaligned":
        --unaligned
    #end if
    #if str( $adv.minID ) != "":
        --minSpotId "$adv.minID"
    #end if
    #if str( $adv.maxID ) != "":
        --maxSpotId "$adv.maxID"
    #end if
    #if str( $adv.minlen ) != "":
        --minReadLen "$adv.minlen"
    #end if
    #if str( $adv.readfilter ) != "":
        --read-filter "$adv.readfilter"
    #end if
    #if str( $adv.region ) != "":
        --aligned-region "$adv.region"
    #end if
    #if str( $adv.spotgroups ) != "":
        --spot-groups "$adv.spotgroups"
    #end if
    #if str( $adv.matepairDist ) != "":
        --matepair-distance "$adv.matepairDist"
    #end if
    $adv.clip
    $adv.skip_technical

    #if str( $outputformat ) == "fastqsanger.gz":
        --gzip
    #elif str( $outputformat ) == "fastqsanger.bz2":   
        --bzip2
    #end if

    #if str($adv.table) != "":
        --table $adv.table
    #end if
    ;
    
    mkdir -p output &&
    data=(\$(ls ./*.fast*));
    if [ \${\#data[@]} -eq 2 ]; then
        mv "\${data[0]}" output/"\${data[0]}"_forward.$outputformat;
        mv "\${data[1]}" output/"\${data[1]}"_reverse.$outputformat;
    elif [ \${\#data[@]} -eq 1 ]; then
        mv "\${data[0]}" output/"\${data[0]}"__single.$outputformat;
    fi;
    
    #if $input.input_select != "sra_file":
        ); done;
    #end if
    echo "Done with all accessions."
    ]]>
    </command>
    <expand macro="configfile_hack"/>
    <inputs>
        <expand macro="input_conditional"/>
        <param name="outputformat" type="select" display="radio" label="Select output format" help="Compression will greatly reduce the amount of space occupied by downloaded data. Downstream applications such as a short-read mappers will accept compressed data as input. Consider this example: an uncoimpressed 400 Mb fastq datasets compresses to 100 Mb or 80 Mb by gzip or bzip2, respectively. " argument="--gzip --bzip2">
            <option value="fastqsanger.gz">gzip compressed fastq</option>
            <option value="fastqsanger">Uncompressed fastq</option>
            <option value="fastqsanger.bz2">bzip2 compressed fastq</option>
        </param>
        <section name="adv" title="Advanced Options" expanded="False">
            <expand macro="defline" defline_param="--defline-seq" defline_default="@$sn[_$rn]/$ri"/>
            <param name="minID" type="integer" label="Minimum spot ID" optional="true" help="Minimum spot id to be dumped." argument="--minSpotId"/>
            <param name="maxID" type="integer" label="Maximum spot ID" optional="true" help="Maximum spot id to be dumped." argument="--maxSpotId"/>
            <param name="minlen" type="integer" label="Minimum read length" optional="true" help="Filter by sequence length. Will dump only reads longer or equal to this value." argument="--minReadLen"/>
            <param name="split" type="boolean" checked="true" truevalue="--split-spot" falsevalue="" label="Split spot by read pairs" help="Split spots into individual reads." argument="--split-spot"/>
            <expand macro="alignments"/>
            <expand macro="region"/>
            <expand macro="matepairDist"/>
            <param name="readfilter" type="select" value="" label="filter by value" argument="--read-filter">
                <option value="">None</option>
                <option value="pass">pass</option>
                <option value="reject">reject</option>
                <option value="criteria">criteria</option>
                <option value="redacted">redacted</option>
            </param>
            <param name="spotgroups" type="text" label="Filter by spot-groups" optional="true" argument="--spot-groups"/>
            <param type="boolean" truevalue="--clip" falsevalue="" argument="--clip" label="Apply left and right clips" />
            <param type="boolean" truevalue="--skip-technical" falsevalue="" checked="False" label="Dump only biological reads" argument="--skip-technical"/>
            <param label="Table name within cSRA object" type="text" value="" optional="true" help="For SRA of noisy long-reads put SEQUENCE" argument="--table"/>
        </section>
    </inputs>
    <outputs>
        <collection name="list_paired" type="list:paired" label="Paired-end data (fastq-dump)">
        <!-- Use named regex group to grab pattern
             <identifier_0>_<identifier_1>.fq. Here identifier_0 is the list
             identifier in the nested collection and identifier_1 is either
             forward or reverse (for instance samp1_forward.fq).
        -->
            <discover_datasets pattern="(?P&lt;identifier_0&gt;[^_]+)_\d+.fastq_(?P&lt;identifier_1&gt;[^_]+)\.fastqsanger" ext="fastqsanger" directory="output"/>
            <discover_datasets pattern="(?P&lt;identifier_0&gt;[^_]+)_\d+.fastq.gz_(?P&lt;identifier_1&gt;[^_]+)\.fastqsanger.gz" ext="fastqsanger.gz" directory="output"/>
            <discover_datasets pattern="(?P&lt;identifier_0&gt;[^_]+)_\d+.fastq.bz2_(?P&lt;identifier_1&gt;[^_]+)\.fastqsanger.bz2" ext="fastqsanger.bz2" directory="output"/>
        </collection>
        <collection name="list_single" type='list' label="Single-end data (fastq-dump)">
            <discover_datasets pattern="(?P&lt;designation&gt;.+)_\d+.fastq__single\.fastqsanger" directory="output" ext='fastqsanger'/>
            <discover_datasets pattern="(?P&lt;designation&gt;.+)_\d+.fastq.gz__single\.fastqsanger.gz" directory="output" ext='fastqsanger.gz'/>
            <discover_datasets pattern="(?P&lt;designation&gt;.+)_\d+.fastq.bz2__single\.fastqsanger.bz2" directory="output" ext='fastqsanger.bz2'/>
        </collection>
    </outputs>
    <tests>
        <test expect_num_outputs="2">
            <param name="input_select" value="accession_number"/>
            <param name="outputformat" value="fastqsanger"/>
            <param name="accession" value="SRR044777"/>
            <param name="skip_technical" value="True"/>
            <output_collection name="list_single" type="list" count="1">
                <element name="SRR044777">
                    <assert_contents>
                        <not_has_text text="rRNA_primer"/>
                        <has_text text="F47USSH02GNP1D"/>
                    </assert_contents>
                </element>
            </output_collection>
        </test>
        <test expect_num_outputs="2">
            <param name="input_select" value="accession_number"/>
            <param name="outputformat" value="fastqsanger.gz"/>
            <param name="accession" value="SRR925743"/>
            <param name="maxID" value="5"/>
            <output_collection name="list_paired" type="list:paired" count="1">
                <element name="SRR925743">
                    <element name="forward" file="SRR925743_forward.fastqsanger" decompress="True"/>
                    <element name="reverse" file="SRR925743_reverse.fastqsanger" decompress="True"/>
                </element>
            </output_collection>
        </test>
        <test expect_num_outputs="2">
            <param name="input_select" value="accession_number"/>
            <param name="outputformat" value="fastqsanger"/>
            <param name="accession" value="SRR925743"/>
            <param name="maxID" value="5"/>
            <output_collection name="list_paired" type="list:paired" count="1">
                <element name="SRR925743">
                    <element name="forward" file="SRR925743_forward.fastqsanger"/>
                    <element name="reverse" file="SRR925743_reverse.fastqsanger"/>
                </element>
            </output_collection>
        </test>
        <test expect_num_outputs="2">
            <param name="input_select" value="file_list"/>
            <param name="outputformat" value="fastqsanger"/>
            <param name="file_list" value="list_pe"/>
            <param name="maxID" value="5"/>
            <output_collection name="list_paired" type="list:paired" count="1">
                <element name="DRR015708">
                    <element name="forward" file="DRR015708_forward.fastqsanger"/>
                    <element name="reverse" file="DRR015708_reverse.fastqsanger"/>
                </element>
            </output_collection>
        </test>
        <test expect_num_outputs="2">
            <param name="input_select" value="file_list"/>
            <param name="outputformat" value="fastqsanger"/>
            <param name="file_list" value="list_pe2"/>
            <param name="maxID" value="5"/>
            <output_collection name="list_paired" type="list:paired" count="1">
                <element name="ERR027433">
                    <element name="forward" file="ERR027433_forward.fastqsanger"/>
                    <element name="reverse" file="ERR027433_reverse.fastqsanger"/>
                </element>
            </output_collection>
        </test>      
        <test expect_num_outputs="2">
            <param name="input_select" value="file_list"/>
            <param name="outputformat" value="fastqsanger"/>
            <param name="file_list" value="list_se"/>
            <param name="maxID" value="5"/>
            <output_collection name="list_single" type="list" count="1">
                <element name="SRR1993644" file="SRR1993644.fastqsanger"/>
            </output_collection>
        </test>
        <test expect_num_outputs="2">
            <param name="input_select" value="accession_number"/>
            <param name="outputformat" value="fastqsanger.gz"/>
            <param name="accession" value="SRR6982805"/>
            <param name="maxID" value="2"/>
            <param name="table" value="SEQUENCE"/>
            <output_collection name="list_single" type="list" count="1">
                <element name="SRR6982805" file="SRR6982805.fastqsanger.gz" ftype="fastqsanger.gz" decompress="True"/>
            </output_collection>
        </test>
        <test expect_num_outputs="2">
            <param name="input_select" value="accession_number"/>
            <param name="outputformat" value="fastqsanger.gz"/>
            <param name="accession" value="ERR086330, SRR11953971"/>
            <output_collection name="list_paired" type="list:paired" count="2">
                <element name="ERR086330">
                    <element name="forward" file="ERR086330_1.fastq.gz" ftype="fastqsanger.gz" decompress="True"/>
                    <element name="reverse" file="ERR086330_2.fastq.gz" ftype="fastqsanger.gz" decompress="True"/>
                </element>
                <element name="SRR11953971">
                    <element name="forward" file="SRR11953971_1.fastq.gz" ftype="fastqsanger.gz" decompress="True"/>
                    <element name="reverse" file="SRR11953971_2.fastq.gz" ftype="fastqsanger.gz" decompress="True"/>
                </element>
            </output_collection>
        </test>
        <test expect_num_outputs="2">
            <param name="input_select" value="accession_number"/>
            <param name="outputformat" value="fastqsanger.gz"/>
            <param name="accession" value="ERR086330, SRR11953971"/>
            <section name="adv">
                <param name="defline_seq" value="@$ac.$si/$ri $sn length=$rl"/>
            </section>
            <output_collection name="list_paired" type="list:paired" count="2">
                <element name="ERR086330">
                    <element name="forward" ftype="fastqsanger.gz" decompress="True">
                        <assert_contents>
                            <!-- decompressed content assertions only work from 23.1
                                 therefore we test for size being at least one byte
                                 larger than the results of the previous test which
                                 uses the shorter default deflines
                                 TODO replace has_size by has_line-->
                            <has_size min="147"/>
                            <!-- <has_line line="@ERR086330.1/1 1 length=76"/> -->
                        </assert_contents>
                    </element>
                    <element name="reverse" ftype="fastqsanger.gz" decompress="True">
                        <assert_contents>
                            <has_size min="141"/>
                            <!-- <has_line line="@ERR086330.1/2 1 length=76"/> -->
                        </assert_contents>
                    </element>
                </element>
                <element name="SRR11953971">
                    <element name="forward" ftype="fastqsanger.gz" decompress="True">
                        <assert_contents>
                            <has_size min="56206"/>
                            <!-- <has_line line="@SRR11953971.1/1 1 length=101"/> -->
                        </assert_contents>
                    </element>
                    <element name="reverse" ftype="fastqsanger.gz" decompress="True">
                        <assert_contents>
                            <has_size min="59843"/>
                            <!-- <has_line line="@SRR11953971.1/2 1 length=101"/> -->
                        </assert_contents>
                    </element>
                </element>
            </output_collection>
        </test>
        <test expect_num_outputs="2">
            <param name="input_select" value="sra_file"/>
            <param name="sra_file" value="SRR522874.sra"/>
            <param name="split" value="True"/>
            <param name="skip_technical" value="True"/>
            <section name="adv">
                <param name="defline_seq" value="@$sn/$ri"/>
            </section>
            <output_collection name="list_paired" type="list:paired" count="1">
                <element name="SRR522874.sra">
                    <element name="forward" file="SRR522874.sra_2.fastq.gz" ftype="fastqsanger.gz" decompress="True"/>
                    <element name="reverse" file="SRR522874.sra_4.fastq.gz" ftype="fastqsanger.gz" decompress="True"/>
                </element>
            </output_collection>
        </test>
    </tests>
    <help><![CDATA[
**What it does?**

This tool extracts data (in fastq_ format) from the Short Read Archive (SRA) at the National Center for Biotechnology Information (NCBI). It is based on the fasterq-dump_ utility of the SRA Toolkit.  The following applies:

 - if data is paired-ended (or mate-pair) the tool will generate a collection of file pairs, in which each element will be a pair of fastq_ files containing forward and reverse mates.
 - if data is single ended, each element of the collection will be a single fastq_ dataset.


@HOW_TO_USE_IT@

-----

**Output**

In every case, fastq datasets produced will be saved in Galaxy's history as a collection_ - a single history element containing multiple datasets. In fact, regardless of the experimental design, three collections will be produced: one containing paired-end data, another containing single-end data, and a third one which contains reads which could not be classified.
Some collections may be empty if the accessions provided in the list do not contain one of the type of data.

.. class:: warningmark

When you decide to dump technical reads (in Advanced Options Dump only biological reads is set to No), you will probably find your PAIRED data in the other data collection as it is impossible to determine if it was 2 biological reads or one biological and one technical.

.. class:: warningmark

By default, only biological reads are dumped and in case of PAIRED dataset only the spots which have both reads will be in the paired-end collection. The remaining single reads will be in the other colletion.
To keep all reads, and potentially not have the same number of reads in forward and reverse use the --split-files option in Advanced Options, Select how to split the spots.

@ACCESSION_LIST_HOWTO@

-----


.. _fastq: https://en.wikipedia.org/wiki/FASTQ_format
.. _fasterq-dump: https://github.com/ncbi/sra-tools/wiki/HowTo:-fasterq-dump
.. _collection: https://galaxyproject.org/tutorials/collections/
.. _link: https://trace.ncbi.nlm.nih.gov/Traces/index.html?view=run_browser&display=reads

@SRATOOLS_ATTRRIBUTION@
]]>
    </help>
    <expand macro="citation"/>
</tool>