<tool id="cb_div" name="Diversity" version="@VERSION@" profile = "20.01">
    <description>indicators</description>
    <macros>
        <import>macro.xml</import>
    </macros>
    <requirements>
        <requirement type="package" version="2.2">r-adiv</requirement>
        <requirement type="package" version="1.0.10">r-dplyr</requirement>
        <requirement type="package" version="1.2.1">r-tidyr</requirement>
        <requirement type="package" version="3.1.8">r-tibble</requirement>
        <requirement type="package" version="1.0.1">r-rgl</requirement>
    </requirements>
    <required_files>
        <include type="literal" path="div_index.r"/>
    </required_files>
    <command detect_errors="exit_code"><![CDATA[
        Rscript
            '$__tool_directory__/div_index.r'
            '$input_data'
            '$output_div'
            '$output_rdata'
            '$plots'
        ]]>
    </command>
    <inputs>
        <param name="input_data" type="data" format="rdata" label="Input clean data"/>
    </inputs>
    <outputs>
        <data name="output_div" from_work_dir="Valeurs_stat.tabular" format="tabular" label="Diversity index"/>
        <data name="output_rdata" from_work_dir="div_df.RDS" format="rdata" label="Diversity Rdata"/>
        <collection type="list" name="plots" label="Diversity plot">
            <discover_datasets pattern="(?P&lt;designation&gt;.+)\.png" visible="false" format="png"/>
        </collection>
    </outputs>
    <tests>
        <test expect_num_outputs="3">
            <param name="input_data" value="Clean_Rdata.rdata"/>
            <output name="output_div">
                <assert_contents>
                    <has_n_columns n="20"/>
                </assert_contents>
            </output>
            <output name="output_rdata">
                <assert_contents>
                    <has_text text="no"/>
                </assert_contents>
            </output>
            <output_collection name="plots" type="list" count="14"/>
        </test>
    </tests>
    <help><![CDATA[
====================
Diversity indicators
====================


**What it does**

Calculates the diversity indicators (Shannon, Simpson, ...). 

**Input description**

Clean Rdata file from the previous tool Dissimilarity.

+----------------+
|      Rdata     |
+================+
|   Clean data   |
+----------------+
|       ...      |
+----------------+


**Output**

- 1 .RDS file
- 1 tabular file for all the diversity indices
- Multiple png plots one for each indices



    ]]>    </help>
        <expand macro="cb_bibref"/>
</tool>
