view vsnp_build_tables.xml @ 11:6b3b0f5858e6 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit c38fd63f7980c70390d104a73ba4c72b266444c3
author iuc
date Fri, 10 Jun 2022 06:11:08 +0000
parents 25714108bb22
children
line wrap: on
line source

<tool id="vsnp_build_tables" name="vSNP: build tables" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
    <description></description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <requirements>
        <expand macro="biopython_requirement"/>
        <requirement type="package" version="0.25.3">pandas</requirement>
        <expand macro="xlsxwriter_requirement"/>
    </requirements>
    <command detect_errors="exit_code"><![CDATA[
#import re
#set output_excel_dir = 'output_excel_dir'
#set input_type = $input_type_cond.input_type
mkdir $output_excel_dir &&
#if $input_type == "collection":
    #set input_newick_dir = 'input_newick_dir'
    mkdir $input_newick_dir &&
    #set input_json_avg_mq_dir = 'input_json_avg_mq_dir'
    mkdir $input_json_avg_mq_dir &&
    #set input_json_dir = 'input_json_dir'
    mkdir $input_json_dir &&
    #for $i in $input_type_cond.input_avg_mq_json_collection:
        #set file_name = $i.file_name
        #set identifier = re.sub('[^\s\w\-\\.]', '_', str($i.element_identifier))
        ln -s '$file_name' '$input_json_avg_mq_dir/$identifier' &&
    #end for
    #for $i in $input_type_cond.input_snps_json_collection:
        #set file_name = $i.file_name
        #set identifier = re.sub('[^\s\w\-\\.]', '_', str($i.element_identifier))
        ln -s '$file_name' '$input_json_dir/$identifier' &&
    #end for
    #for $i in $input_type_cond.input_newick_collection:
        #set file_name = $i.file_name
        #set identifier = re.sub('[^\s\w\-\\.]', '_', str($i.element_identifier))
        ln -s '$file_name' '$input_newick_dir/$identifier' &&
    #end for
#end if
python '$__tool_directory__/vsnp_build_tables.py'
#if $input_type == "single":
    --input_avg_mq_json '$input_avg_mq_json'
    --input_snps_json '$input_snps_json'
    --input_newick '$input_newick'
#end if:
#if str($gbk_cond.gbk_param) == "yes":
    #set gbk_source_cond = $gbk_cond.gbk_source_cond
    #set gbk_source = $gbk_source_cond.gbk_source
    #if str($gbk_source) == "cached":
        --gbk_file '$gbk_source_cond.gbk_file.fields.path'
    #else:
        --gbk_file '$gbk_source_cond.gbk_file'
    #end if
#end if
--processes \${GALAXY_SLOTS:-8}
]]></command>
    <inputs>
        <conditional name="input_type_cond">
            <param name="input_type" type="select" label="Choose the category for the files to be analyzed">
                <option value="single" selected="true">Single files</option>
                <option value="collection">Collection of files</option>
            </param>
            <when value="single">
                <param name="input_snps_json" type="data" format="json" label="SNPs json file"/>
                <param name="input_avg_mq_json" type="data" format="json" label="Average MQ json file"/>
                <param name="input_newick" type="data" format="newick" label="Best-scoring ML tree file"/>
            </when>
            <when value="collection">
                <param name="input_snps_json_collection" format="json" type="data_collection" collection_type="list" label="Collection of SNPs json files"/>
                <param name="input_avg_mq_json_collection" format="json" type="data_collection" collection_type="list" label="Collection of average MQ json files"/>
                <param name="input_newick_collection" format="newick" type="data_collection" collection_type="list" label="Collection of best-scoring ML tree files"/>
            </when>
        </conditional>
        <conditional name="gbk_cond">
            <param name="gbk_param" type="select" label="Use Genbank file?">
                <option value="yes" selected="true">yes</option>
                <option value="no">No</option>
            </param>
            <when value="yes">
                <conditional name="gbk_source_cond">
                    <param name="gbk_source" type="select" label="Choose the source for the Genbank file">
                        <option value="cached" selected="true">locally cached</option>
                        <option value="history">from history</option>
                    </param>
                    <when value="cached">
                        <param name="gbk_file" type="select" label="Genbank file">
                            <options from_data_table="vsnp_genbank">
                                <validator type="no_options" message="A cached Genbank file is not available for the build associated with the selected average MQ json file"/>
                            </options>
                        </param>
                    </when>
                    <when value="history">
                        <param name="gbk_file" type="data" format="genbank" label="Genbank file"/>
                    </when>
                </conditional>
            </when>
            <when value="no"/>
        </conditional>
    </inputs>
    <outputs>
        <collection name="excel" type="list" format="xlsx" label="${tool.name} on ${on_string}">
            <discover_datasets pattern="(?P&lt;designation&gt;.+)\.(?P&lt;ext&gt;xlsx)" directory="output_excel_dir"/>
        </collection>
    </outputs>
    <tests>
        <test>
            <param name="input_snps_json" value="input_snps_json.json" ftype="json" dbkey="89"/>
            <param name="input_newick" value="input_newick.newick" ftype="newick" dbkey="89"/>
            <param name="input_avg_mq_json" value="input_avg_mq_json.json" ftype="json" dbkey="89"/>
            <param name="gbk_param" value="no"/>
            <output_collection name="excel" type="list" count="2">
                <element name="cascade_table" ftype="xlsx">
                    <assert_contents>
                        <has_size value="6766" delta="100"/>
                    </assert_contents>
                </element>
                <element name="sort_table" ftype="xlsx">
                    <assert_contents>
                        <has_size value="6760" delta="100"/>
                    </assert_contents>
                </element>
            </output_collection>
        </test>
        <test>
            <param name="input_type" value="collection"/>
            <param name="input_snps_json_collection">
                <collection type="list">
                    <element name="Mbovis-01_snps.json" value="Mbovis-01_snps.json" dbkey="89"/>
                    <element name="Mbovis-01D_snps.json" value="Mbovis-01D_snps.json" dbkey="89"/>
                    <element name="Mbovis-01D6_snps.json" value="Mbovis-01D6_snps.json" dbkey="89"/>
                </collection>
            </param>
            <param name="input_newick_collection">
                <collection type="list">
                    <element name="Mbovis-01_snps.newick" value="Mbovis-01_snps.newick" dbkey="89"/>
                    <element name="Mbovis-01D_snps.newick" value="Mbovis-01D_snps.newick" dbkey="89"/>
                    <element name="Mbovis-01D6_snps.newick" value="Mbovis-01D6_snps.newick" dbkey="89"/>
                </collection>
            </param>
            <param name="input_avg_mq_json_collection">
                <collection type="list">
                    <element name="Mbovis-01_avg_mq.json" value="Mbovis-01_avg_mq.json" dbkey="89"/>
                    <element name="Mbovis-01D_avg_mq.json" value="Mbovis-01D_avg_mq.json" dbkey="89"/>
                    <element name="Mbovis-01D6_avg_mq.json" value="Mbovis-01D6_avg_mq.json" dbkey="89"/>
                </collection>
            </param>
            <param name="gbk_param" value="no"/>
            <output_collection name="excel" type="list" count="6">
                <element name="Mbovis-01D6_snps_cascade_table" ftype="xlsx">
                    <assert_contents>
                        <has_size value="6767" delta="100"/>
                    </assert_contents>
                </element>
                <element name="Mbovis-01D6_snps_sort_table" ftype="xlsx">
                    <assert_contents>
                        <has_size value="6761" delta="100"/>
                    </assert_contents>
                </element>
                <element name="Mbovis-01D_snps_cascade_table" ftype="xlsx">
                    <assert_contents>
                        <has_size value="6767" delta="100"/>
                    </assert_contents>
                </element>
                <element name="Mbovis-01D_snps_sort_table" ftype="xlsx">
                    <assert_contents>
                        <has_size value="6761" delta="100"/>
                    </assert_contents>
                </element>
                <element name="Mbovis-01_snps_cascade_table" ftype="xlsx">
                    <assert_contents>
                        <has_size value="6767" delta="100"/>
                    </assert_contents>
                </element>
                <element name="Mbovis-01_snps_sort_table" ftype="xlsx">
                    <assert_contents>
                        <has_size value="6761" delta="100"/>
                    </assert_contents>
                </element>
            </output_collection>
        </test>
    </tests>
    <help>
**What it does**

Accepts a combination of single SNPs json, average MQ json and newick files (or associated collections of
each) to produce annotated SNPs tables in the form of Excel spreadsheets.  The SNPs json and average MQ json
files are typically produced by the **vSNP: get SNPs** tool and the newick files are typically produced by
the **Phyogenetic reconstruction with RaXML** tool.

The SNPs tables display closely related isolates and enables identification of mixed SNPs when multiple
bacterial strains are infecting an organism.  The table structure is shown below.  The columns identify the
genome location of the SNP calls and the isolates are contained within the rows.  The reference (or ancestral
strain if the reference is an outgroup) is listed across the top, identified as the "reference call".  SNPs
that are not highlighted will match the reference.  The map-quality row values are the average of the map
quality scores of each isolate  in that position.  These scores measure the confidence that the read has been
mapped to the correct location on the genome.  The maximum score possible is 60, and lower scores lessen the
confidence that the SNP was correctly identified.  The annotation of the position is provided at the bottom
of the table.

.. image:: table_description.png

SNPs are sorted according to their evolutionary age within the table.  The oldest SNPs (encompassing the most
isolates) are furthest to the left.  This sorting is somewhat crude - the intent is to improve readibility or
more easily match a related tree.

For a more detailed discussion, see the **Validating and correcting SNP calls** section of
the `vSNP documentation`_.

.. _vSNP documentation: https://github.com/USDA-VS/vSNP/blob/master/docs/detailed_usage.md

**Required Options**

 * **Choose the category for the files to be analyzed** -  select "Single files" or "Collections of files", then select the appropriate history items (single SNPs json, average MQ json and newick files, or collections of each) based on the selected option.
 * **Use Genbank file** - Select "yes" to annotate the tables using the information in the Genbank file.  Locally cached files, if available, provide the most widely used annotations, but more custom Genbank files can be chosen from the current history.
    </help>
    <expand macro="citations"/>
</tool>