<tool id="funannotate_compare" name="Funannotate compare" profile="20.01" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@">
    <description>annotations</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <requirements>
        <expand macro="requirements" />
    </requirements>
    <version_command>funannotate check --show-versions</version_command>
    <command><![CDATA[
#set $inputs = ""
#for i, f in enumerate($input):
    #set $inputs = $inputs + " input" + str($i) + ".gbk"
    ln -s '$f' input${i}.gbk &&
#end for

funannotate compare
--input

$inputs

--out output

--database '$database.fields.path'

#if $run_dnds in ['estimate', 'full']:
    --run_dnds ${run_dnds}
#end if

## TODO add --outgroup option some day (hard to get an up to date/customizable list)

--go_fdr ${go_fdr}

--heatmap_stdev ${heatmap_stdev}

--num_orthos ${num_orthos}

#if $proteinortho:
    --proteinortho '${proteinortho}'
#end if

--ml_method ${ml.ml_method}

#if $ml.ml_method == 'raxml':
    --bootstrap '${ml.bootstrap}'
#end if

--cpus \${GALAXY_SLOTS:-2}

&&

mkdir -p '$output.files_path' &&
cp -R output/* '$output.files_path' &&
cp output/index.html '$output'
    ]]></command>
    <inputs>
        <param argument="--input" type="data" format="genbank" multiple="true" label="Genome annotations in genbank format" help="Outputs from 'Funannotate predict annotation' tool" />

        <param name="database" label="Funannotate database" type="select">
            <options from_data_table="funannotate">
                <column name="value" index="0" />
                <column name="name" index="1" />
                <column name="path" index="3" />
                <filter type="sort_by" column="0" />
                <filter type="static_value" column="2" value="1.0" />
            </options>
        </param>

        <param argument="--run_dnds" type="select" label="Calculate dN/dS ratio on all orthologs">
            <option value="no" selected="True">No</option>
            <option value="estimate">estimate</option>
            <option value="full">full</option>
        </param>

        <param argument="--go_fdr" type="float" value="0.05" label="P-value for FDR GO-enrichment" />
        <param argument="--heatmap_stdev" type="float" value="1.0" label="Cut-off for heatmap" />
        <param argument="--num_orthos" type="integer" value="500" label="Number of Single-copy orthologs to use for ML" />
        <param argument="--proteinortho" type="data" format="tabular" optional="true" label="Proteinortho POFF results" help="TSV format, if available"/>

        <conditional name="ml">
            <param argument="--ml_method" type="select" label="Maximum Likelihood method">
                <option value="iqtree" selected="True">iqtree</option>
                <option value="raxml">raxml</option>
            </param>
            <when value="iqtree" />
            <when value="raxml">
                <param argument="--bootstrap" type="integer" value="100" label="Number of boostrap replicates to run with RAxML" />
            </when>
        </conditional>
    </inputs>
    <outputs>
        <data name='output' format='html' label="${tool.name} on ${on_string}: report" />
    </outputs>
    <tests>
        <test>
            <param name="input" value="compare/Genus_species.gbk,compare/Other_species.gbk,compare/Other_beast.gbk,compare/Yet_another.gbk" />
            <param name="database" value="2021-07-20-120000" />
            <conditional name="ml">
                <param name="ml_method" value="raxml" />
            </conditional>
            <output name="output">
                <assert_contents>
                    <has_text text="Report generated on:" />
                </assert_contents>
            </output>
        </test>
        <test>
            <param name="input" value="compare/Genus_species.gbk,compare/Other_species.gbk,compare/Other_beast.gbk,compare/Yet_another.gbk" />
            <param name="database" value="2021-07-20-120000" />
            <param name="run_dnds" value="estimate" />
            <conditional name="ml">
                <param name="ml_method" value="raxml" />
            </conditional>
            <output name="output">
                <assert_contents>
                    <has_text text="Report generated on:" />
                </assert_contents>
            </output>
        </test>
        <test>
            <param name="input" value="compare/Genus_species.gbk,compare/Other_species.gbk,compare/Other_beast.gbk,compare/Yet_another.gbk" />
            <param name="database" value="2021-07-20-120000" />
            <param name="run_dnds" value="full" />
            <conditional name="ml">
                <param name="ml_method" value="raxml" />
            </conditional>
            <output name="output">
                <assert_contents>
                    <has_text text="Report generated on:" />
                </assert_contents>
            </output>
        </test>
    </tests>
    <help><![CDATA[
Funannotate_ compare
--------------------

Funannotate_ is a pipeline for genome annotation (built specifically for fungi, but will also work with higher eukaryotes).

This script does light-weight comparative genomics between funannotated genomes.  Output
is graphs, phylogeny, CSV files, etc --> visualized in web-browser.

.. _Funannotate: http://funannotate.readthedocs.io
    ]]></help>
    <expand macro="citations" />
</tool>
