<?xml version="1.0"?>
<macros>
    <token name="@DESEQ2_ASV_VISUALISATION_CMD_LINE@">
        deseq2_visualisation.py
            --analysis-type 'ASV'
            --phyloseq-rdata '$phyloseq_rdata' 
            --deseq-rdata '$deseq_rdata'
            --var-exp '$var_exp'
            #if $varType.vartType_selected == "qualitative":
                --mod1 '$varType.mod1' 
                --mod2 '$varType.mod2'
            #end if
            --padj $padj
            --html '$html'
    </token>

    <xml name="deseq2_asv_visualisation_inputs">
        <!-- Files -->
        <param argument="--phyloseq-rdata" type="data" format="rdata" label="Phyloseq object (.Rdata)" help="Rdata file generated by the FROGS Stat Phyloseq import for ASV data."/>
        <param argument="--deseq-rdata" type="data" format="rdata" label="DESeq2 object (.Rdata)" help="Rdata file generated by the FROGS Stat DESeq2 Preprocess tool for ASV data."/>
        <!-- Parameters -->
        <param argument="--var-exp" type="text" label="Experimental variable" help="Sample metadata variable expected to influence ASV abundances (e.g., Treatment, Site, Environment, etc.).">
            <expand macro="restricted_sanitizer_validator"/>
        </param>
        <conditional name="varType">
            <param name="vartType_selected" type="select" label="Is the experimental variable quantitative or qualitative?" help="Select whether the experimental variable is qualitative (categorical) or quantitative (numerical). If qualitative, specify two conditions to compare.">
                <option value="qualitative">Qualitative</option>
                <option value="quantitative">Quantitative</option>
            </param>
            <when value="qualitative">
                <param argument="--mod2" type="text"  label="Condition 1 considered as reference" help="Condition used as reference in the comparison (e.g., Control, Untreated, With).">
                   <expand macro="restricted_sanitizer_validator"/>
                </param>
                <param argument="--mod1" type="text"  label="Condition 2 to be compared to the reference" help="Condition to compare against the reference (e.g., Treated, Without).">
                   <expand macro="restricted_sanitizer_validator"/>
                </param>
            </when>
            <when value="quantitative"/>
        </conditional>
        <param argument="--padj" type="float" value="0.05" label="Adjusted p-value threshold" help="Adjusted p-value cutoff used to determine significantly differentially abundant ASVs (default: 0.05)."/>
    </xml>

    <!-- Test -->
    <xml name="deseq2_asv_visualisation_test_input">
        <param name="phyloseq_rdata" value="references/16-phylo_import.Rdata" />
        <param name="deseq_rdata" value="references/23-deseq2_preprocess_asv.Rdata"/>
        <param name="var_exp" value="EnvType" />
        <conditional name="varType">
            <param name="vartType_selected" value="qualitative"/>
            <param name="mod1" value="BoeufHache"/>
            <param name="mod2" value="SaumonFume"/>
        </conditional>
        <param name="padj" value="0.05" />
    </xml>

    <xml name="deseq2_asv_visualisation_test_output">
        <output name="html" count="1">
            <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, intermediate results and output of last R command -->
				<!-- Deseq2 is influenced by other intermediate libraries or packages and results are hard to compare -->
                <has_text text="Stat: DESeq2 Visualisation" />
                <has_text text="(deseq2_visualisation.py" />
				<has_text text="v5.1.0)" />
                <has_text text='["otu_01582",' />
                <!-- baseMean value of otu_01582 -->
                <has_text text='[52.4455' />
                <!-- Log2 FC of otu_01582 -->
                <has_text text='[21.6623' />
                <!-- lfcSE of otu_01582 -->
                <has_text text='[2.2089' />
                <has_text text='─ Session info ───────────────────────────────────────────────────────────────' />
            </assert_contents>
        </output>
    </xml>

    <token name="@DESEQ2_FUN_VISUALISATION_CMD_LINE@">
        deseq2_visualisation.py
            --analysis 'FUNCTION'
            --phyloseq-rdata '$phyloseq_rdata' 
            --deseq-rdata '$deseq_rdata'
            --var-exp '$var_exp'
            #if $varType.vartType_selected == "qualitative":
                --mod1 '$varType.mod1' 
                --mod2 '$varType.mod2'
            #end if
            --padj $padj
            --html '$html'
            --output-ipath-over '$Function_over_abund'
            --output-ipath-under '$Function_under_abund'
    </token>

    <xml name="deseq2_fun_visualisation_inputs">
        <!-- Files -->
        <param argument="--phyloseq-rdata" type="data" format="rdata" label="Phyloseq object (.Rdata)" help="Rdata file generated by the FROGS Stat DESeq2 Preprocess analysis for FUNCTION data."/>
        <param argument="--deseq-rdata" type="data" format="rdata" label="DESeq2 object (.Rdata)" help="Rdata file generated by the FROGS Stat DESeq2 Preprocess analysis for FUNCTION data."/>
        <!-- Parameters -->
        <param argument="--var-exp" type="text" label="Experimental variable" help="Sample metadata variable expected to influence functional abundances (e.g., Treatment, Site, Environment, etc.).">
            <expand macro="restricted_sanitizer_validator"/>
        </param>
        <conditional name="varType">
            <param name="vartType_selected" type="select" label="Is the experimental variable quantitative or qualitative?" help="Select whether the experimental variable is qualitative (categorical) or quantitative (numerical). If qualitative, specify two conditions to compare.">
                <option value="qualitative">Qualitative</option>
                <option value="quantitative">Quantitative</option>
            </param>
            <when value="qualitative">
                <param argument="--mod2" type="text"  label="Condition 1 considered as reference" help="Condition used as reference in the comparison (e.g., Control, Untreated, With).">
                   <expand macro="restricted_sanitizer_validator"/>
                </param>
                <param argument="--mod1" type="text"  label="Condition 2 to be compared to the reference" help="Condition to compare against the reference (e.g., Treated, Without).">
                   <expand macro="restricted_sanitizer_validator"/>
                </param>
            </when>
            <when value="quantitative"/>
        </conditional>
        <param argument="--padj" type="float" value="0.05" label="Adjusted p-value threshold" help="Adjusted p-value cutoff used to determine significantly differentially abundant functions (default: 0.05)."/>
    </xml>

    <!-- Test -->
    <xml name="deseq2_fun_visualisation_test_input">
        <param name="phyloseq_rdata" value="references/23-phyloseq_functions.Rdata" />
        <param name="deseq_rdata" value="references/23-deseq2_preprocess_func.Rdata"/>
        <param name="var_exp" value="EnvType" />
        <conditional name="varType">
            <param name="vartType_selected" value="qualitative"/>
            <param name="mod1" value="BoeufHache"/>
            <param name="mod2" value="SaumonFume"/>
        </conditional>
        <param name="padj" value="0.05" />
    </xml>

    <xml name="deseq2_fun_visualisation_test_output">
        <output name="html" count="1">
            <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, intermediate results and output of last R command -->
                <has_text text="Stat: DESeq2 Visualisation" />
                <has_text text="(deseq2_visualisation.py v5.1.0)" />
                <has_text text='["EC:1.3.1.76",' />
                <!-- baseMean value of EC:1.3.1.76 -->
                <has_text text='[753.1103444315089' />
                <!-- Log2 FC of EC:1.3.1.76 -->
                <has_text text='[-8.386170731613163' />
                <!-- lfcSE of EC:1.3.1.76 -->
                <has_text text='[1.005359955086068' />
                <!-- pvalue EC:1.3.1.76 -->
                <has_text text='[7.337830601151377e-17' />
                <has_text text='─ Session info ───────────────────────────────────────────────────────────────' />
            </assert_contents>
        </output>
    </xml>
</macros>
