view snpEff_create_db.xml @ 16:c9ecd2a96ecf draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tool_collections/snpeff commit 33017565e3dd788161910bd856aff43fbb57a58f
author iuc
date Tue, 28 Aug 2018 03:03:45 -0400
parents 479c4f2f4826
children 65ae79bddc69
line wrap: on
line source

<tool id="snpEff_build_gb" name="SnpEff build:" version="@wrapper_version@.galaxy3">
    <description> database from Genbank or GFF record</description>
    <macros>
        <import>snpEff_macros.xml</import>
    </macros>
    <requirements>
        <expand macro="requirement" />
        <requirement type="package" version="3.6">python</requirement>
        <requirement type="package" version="1.70">biopython</requirement>
        <requirement type="package" version="0.4.15">python-magic</requirement>
        <requirement type="package" version="5.32">libmagic</requirement>
    </requirements>
    <expand macro="stdio" />
    <expand macro="version_command" />
    <command><![CDATA[

        #if str( $input_type.input_type_selector ) == "gb":
            #if str( $input_type.fasta ) == "yes":
                python3 '$__tool_directory__/gbk2fa.py' '${input_type.input_gbk}' '${output_fasta}'
                #if $input_type.remove_version:
                    '${input_type.remove_version}'
                #end if
                &&
            #end if
        #end if

        mkdir -p '${snpeff_output.files_path}'/'${genome_version}' &&

        #if str( $input_type.input_type_selector ) == "gb":
            #if $input_type.input_gbk.is_of_type("genbank"):
                ln -s '${input_type.input_gbk}' '${snpeff_output.files_path}'/'${genome_version}'/genes.gbk &&
            #elif $input_type.input_gbk.is_of_type("genbank.gz"):
                ln -s '${input_type.input_gbk}' '${snpeff_output.files_path}'/'${genome_version}'/genes.gbk.gz &&
            #end if
        #elif str( $input_type.input_type_selector ) == "gff":
            #if $input_type.input_fasta.is_of_type("fasta"):
                ln -s '${input_type.input_fasta}' '${snpeff_output.files_path}'/'${genome_version}'/sequences.fa &&
            #elif $input_type.input_fasta.is_of_type("fasta.gz"):
                ln -s '${input_type.input_fasta}' '${snpeff_output.files_path}'/'${genome_version}'/sequences.fa.gz &&
            #end if
            ln -s '${input_type.input_gff}' '${snpeff_output.files_path}'/'${genome_version}'/genes.gff &&
        #end if

        snpEff @java_options@ build -v
        -configOption '${genome_version}'.genome='${genome_version}'
        -configOption '${genome_version}'.codonTable='${codon_table}'
        #if str( $input_type.input_type_selector ) == "gb":
            -genbank
        #elif str( $input_type.input_type_selector ) == "gff":
            -gff3
        #end if
        -dataDir '${snpeff_output.files_path}' '${genome_version}' &&
        echo "${genome_version}.genome : ${genome_version}" >> '${snpeff_output.files_path}'/snpEff.config &&
        echo "${genome_version}.codonTable : ${codon_table}" >> '${snpeff_output.files_path}'/snpEff.config

    ]]></command>
    <inputs>
        <param name="genome_version" type="text" value="" label="Name for the database" help="for E. coli K12 you may want to use 'EcK12' etc.">
            <validator type="regex" message="A genome version name is required">\S+</validator>
        </param>
        <conditional name="input_type">
            <param name="input_type_selector" type="select" display="radio" label="Input annotations are in" help="Specify format for annotations you are using to create SnpEff database">
                <option value="gb" selected="true">GenBank</option>
                <option value="gff">GFF</option>
            </param>
            <when value="gb">
                <param name="input_gbk" type="data" format="genbank,genbank.gz" label="Genbank dataset to build database from" help="This Genbank file will be used to generate snpEff database"/>
                <param name="fasta" type="select" display="radio" label="Parse Genbank into Fasta" help="This will generate an additional dataset containing all sequences from Genbank file in FASTA format">
                        <option value="yes" selected="true">Yes</option>
                        <option value="no">No</option>
                </param>
                <param type="boolean" name="remove_version" truevalue="--remove_version" falsevalue="" checked="true" label="Remove sequence version label?" help="Genbank sequences have vesion numbers such as B000564.2. This option removes them leaving only B000564" argument="--remove_version"/>
            </when>
            <when value="gff"> 
                <param name="input_gff" type="data" format="gff3" label="GFF dataset to build database from" help="This GFF file will be used to generate snpEff database"/>
                <param name="input_fasta" type="data" format="fasta,fasta.gz" label="Genome in FASTA format" help="This dataset is required for generating SnpEff database. See help section below."/>
            </when>
        </conditional>
        <param name="codon_table" type="select" label="Select genetic code for this sequence" help="If this sequence uses non-standard genetic code, select one from these options">
            <option selected="true" value="Standard">Standard</option>
            <option value="Vertebrate_Mitochondrial">Vertebrate_Mitochondrial</option>
            <option value="Yeast_Mitochondrial">Yeast_Mitochondrial</option>
            <option value="Mold_Mitochondrial">Mold_Mitochondrial</option>
            <option value="Protozoan_Mitochondrial">Protozoan_Mitochondrial</option>
            <option value="Coelenterate">Coelenterate</option>
            <option value="Mitochondrial">Mitochondrial</option>
            <option value="Mycoplasma">Mycoplasma</option>
            <option value="Spiroplasma">Spiroplasma</option>
            <option value="Invertebrate_Mitochondrial">Invertebrate_Mitochondrial</option>
            <option value="Ciliate_Nuclear">Ciliate_Nuclear</option>
            <option value="Dasycladacean_Nuclear">Dasycladacean_Nuclear</option>
            <option value="Hexamita_Nuclear">Hexamita_Nuclear</option>
            <option value="Echinoderm_Mitochondrial">Echinoderm_Mitochondrial</option>
            <option value="Flatworm_Mitochondrial">Flatworm_Mitochondrial</option>
            <option value="Euplotid_Nuclear">Euplotid_Nuclear</option>
            <option value="Bacterial_and_Plant_Plastid">Bacterial_and_Plant_Plastid</option>
            <option value="Alternative_Yeast_Nuclear">Alternative_Yeast_Nuclear</option>
            <option value="Ascidian_Mitochondrial">Ascidian_Mitochondrial</option>
            <option value="Alternative_Flatworm_Mitochondrial">Alternative_Flatworm_Mitochondrial</option>
            <option value="Blepharisma_Macronuclear">Blepharisma_Macronuclear</option>
            <option value="Chlorophycean_Mitochondrial">Chlorophycean_Mitochondrial</option>
            <option value="Trematode_Mitochondrial">Trematode_Mitochondrial</option>
            <option value="Scenedesmus_obliquus_Mitochondrial">Scenedesmus_obliquus_Mitochondrial</option>
            <option value="Thraustochytrium_Mitochondrial">Thraustochytrium_Mitochondrial</option>
        </param>
    </inputs>
    <outputs>
        <data name="snpeff_output" format="snpeffdb" label="@snpeff_version@ database for ${genome_version}"/>
        <data name="output_fasta" format="fasta" label="Fasta sequences for ${genome_version}">
            <filter>input_type['input_type_selector'] == 'gb'</filter>
            <filter>input_type['fasta'] == 'yes'</filter>
        </data>
    </outputs>
    <tests>
        <test>
            <param name="genome_version" value="pBR322"/>
            <param name="input_type_selector" value="gb"/>
            <param name="input_gbk" value="pBR322.gbk" />
            <output name="snpeff_output">
                <assert_contents>
                    <has_text text="pBR322" />
                </assert_contents>
            </output>
            <output name="output_fasta" value="pBR322_test1.fna"/>
        </test>
        <test>
            <param name="genome_version" value="pBR322"/>
            <param name="input_type_selector" value="gb"/>
            <param name="input_gbk" value="pBR322.gbk.gz" />
            <output name="snpeff_output">
                <assert_contents>
                    <has_text text="pBR322" />
                </assert_contents>
            </output>
            <output name="output_fasta" value="pBR322_test1.fna"/>
        </test>
        <test>
            <param name="genome_version" value="pBR322"/>
            <param name="input_type_selector" value="gff"/>
            <param name="input_fasta" value="pBR322_test2.fna" />
            <param name="input_gff" value="pBR322.gff3" />
            <output name="snpeff_output">
                <assert_contents>
                    <has_text text="pBR322" />
                </assert_contents>
            </output>
        </test>
        <test>
            <param name="genome_version" value="pBR322"/>
            <param name="input_type_selector" value="gff"/>
            <param name="input_fasta" value="pBR322_test2.fna.gz" />
            <param name="input_gff" value="pBR322.gff3" />
            <output name="snpeff_output">
                <assert_contents>
                    <has_text text="pBR322" />
                </assert_contents>
            </output>
        </test>
    </tests>
    <help><![CDATA[
**What it does**

This tool uses `"snpEff build -genbank"` or `"snpEff build -gff3"` commands to create a snpEff database. 

------

.. class:: infomark

**Working with Genbank files**

Using Genbank data for creating databases has several advantages:

 #. Genbank files contain annotations (such as locations of genes) together with sequences. This ensures that these two are in sync with each other. 
 #. When you are analyzing small genomes (or not so small) it is much more convenient to create a database on the fly and use it.

 .. class:: warningmark

 SnpEff errors out on highly fragmented genomes containing multiple scaffolds. This is because a single gene may be split between multiple scaffolds causing SnpEff to crash. If this is happening use GFF route described below. 

-------

**Genbank usage scenario**

Suppose you have a series of Illumina reads from an experiment involving *E. coli* K-12 MG1655. You want to map these reads to the reference genome of K-12 MG1655, call variants, and annotate them using snpEff. This tool enables you to follow the following analysis steps:

 #. Go to `NCBI <http://www.ncbi.nlm.nih.gov>`_ page for K-12 MG1655 genome (note that all NCBI genomes have similar list of files associated with them).
 #. Copy URL for file with extension `gbff.gz` 
 #. Paste the URL into upload tool and set datatype to `genbank.gz`.
 #. Use this tool to generate a snpEff database and FASTA sequences from the dataset you've uploaded during the previous step.
 #. Use your Illumina reads to map against FASTA dataset generated in the previous step using BWA-MEM.
 #. Call variants using **Freebayes**.
 #. Annotate vcf output of Freebayes with **SnpEff eff** using database generated at step 2 (using *Custom* option for **Genome source** parameter).

In this scenario Genbank dataset is used twice. First, it is used to produce FASTA sequences that are using by BWA to map against. Second, it is used to create snpEff database. This guarantees that you will not have any issues related to reference sequence naming.

-------

.. class:: infomark

**Working with GFF files**

Alternatively you can create a SnpEff database from `GFF3 <https://en.wikipedia.org/wiki/General_feature_format>`_ files downloaded from NCBI or any other source. Using GFF dataset for building SnpEff database requires two inputs:

 #. The GFF file itself
 #. A genome in FASTA format

The GFF file contains coordinates of various features, but does not contain underlying sequences. This is why a FASTA file needs to be provided as well.

------

**GFF usage scenario**   

The following example also uses *E. coli* K-12 MG1655:

#. Go to `NCBI <http://www.ncbi.nlm.nih.gov>`_ page for K-12 MG1655 genome.
#. Copy URLs for files with `gff.gz` and `fna.gz` extensions. The first file contains annotations in GFF3 format. The second file contains entire genome as a FASTA record.
#. Paste URLs into upload tool and set datatypes to `gff3` and `fasta.gz` for annotations and genome, respectively.
#. Use this tool to generate a snpEff database from the GFF dataset.
#. Map your reads against the FASTA dataset and continue as described in the above example.


@snpeff_in_galaxy_info@
@external_documentation@
]]>
    </help>
    <expand macro="citations" />
</tool>