<?xml version="1.0"?>
<macros>
    <token name="@PHYLOSEQ_BETA_DIVERSITY_CMD_LINE@">
        phyloseq_beta_diversity.py
            --phyloseq-rdata '$phyloseq_rdata'
            --var-exp '$var_exp'
            --beta-distance-methods ${" ".join(str($beta_distance_methods).split(","))} ${" ".join(str($other_beta_method).split(","))}
            --matrix-outdir 'BetaMatrix'
            --html '$html'
    </token>

    <xml name="phyloseq_beta_diversity_inputs">
        <!-- Files -->
        <param argument="--phyloseq-rdata" type="data" format="rdata" label="Phyloseq object (.Rdata)" help="Rdata file generated by the FROGS Stat 'Phyloseq Import data' tool."/>
        <!-- Parameters -->
        <param argument="--var-exp" type="text" label="Grouping variable" help="Experimental variable used to group samples (e.g., Treatment, Environment type, Host species, etc.).">
            <expand macro="restricted_sanitizer_validator"/>
        </param>
        <param argument="--beta-distance-methods" type="select" multiple="true" display="checkboxes" optional="true" label="Beta diversity distance methods" help="Select one or more distance metrics to compute. Note: if the phylogenetic tree is not available in your Rdata file, Unifrac and Weighted Unifrac cannot be used.">
            <option value="unifrac">Unifrac</option>
            <option value="wunifrac">Weighted Unifrac</option>
            <option value="bray">Bray-Curtis</option>
            <option value="cc">Jaccard (corresponds to the ‘cc’ method in the betadiver vegan function)</option>
        </param>
        <param name="other_beta_method" type="text" optional="true" label="Other distance metrics" help="Specify additional beta diversity methods to use (comma-separated).">
            <expand macro="restricted_sanitizer_validator"/>
        </param>
    </xml>      
    
    <!-- Test -->
    <xml name="phyloseq_beta_diversity_test_input">
        <param name="phyloseq_rdata" value="references/16-phylo_import.Rdata" />
        <param name="var_exp" value="EnvType" />
        <param name="beta_distance_methods" value="cc,unifrac"/>
    </xml>

    <xml name="phyloseq_beta_diversity_test_output">
        <output name="html" count="3">
            <assert_contents>
                <!-- HTML size or line diff can't be used as many information about path, os, date are present. -->
                <!-- Here we test only title and output of last R command -->
                <has_text text='Stat: Beta Diversity Visualisation' />
                <has_text text='(phyloseq_beta_diversity.py' />
				<has_text text='v5.1.0)' />
                <has_text text='─ Session info ───────────────────────────────────────────────────────────────' />
            </assert_contents>
        </output>
        <output name="html">
            <discovered_dataset designation="unifrac.tsv" ftype="tsv" file="references/unifrac.tsv" compare="diff" lines_diff="0"/>
        </output>
    </xml>
</macros>
