<?xml version="1.0"?>
<macros>
    <token name="@PHYLOSEQ_COMPOSITION_CMD_LINE@">
        phyloseq_composition.py
            --phyloseq-rdata '$phyloseq_rdata'
            --var-exp '$var_exp'
            --taxa-rank-1 '$taxa_rank_1'
            --taxa-set-1 '$taxa_set_1'
            --taxa-rank-2 '$taxa_rank_2'
            --number-of-taxa $number_of_taxa
            --html '$html'
    </token>

    <xml name="phyloseq_composition_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."/>
        <!-- Params -->
        <param argument="--var-exp" type="text" label="Grouping variable" help="Experimental variable used to group samples (e.g., Treatment, Host type, Site, etc.).">
            <expand macro="restricted_sanitizer_validator"/>
        </param>
        <param argument="--taxa-rank-1" type="text" value="Kingdom" label="Taxonomic level for filtering" help="Taxonomic rank used to filter the dataset (e.g., Kingdom, Phylum, Class, Order, Family, Genus, Species).">
            <expand macro="restricted_sanitizer_validator"/>
        </param>
        <param argument="--taxa-set-1" type="text"  value="Bacteria" label="Taxa to retain" help="Taxa to keep at the selected filtering level (e.g., Bacteria at Kingdom level, or Firmicutes at Phylum level). Multiple taxa can be specified, separated by spaces (e.g., Firmicutes Proteobacteria).">
            <expand macro="restricted_sanitizer_validator"/>
        </param>
        <param argument="--taxa-rank-2" type="text" value="Family" label="Taxonomic level for aggregation" help="Taxonomic rank used to aggregate data. It must be lower than the filtering level (e.g., Family when filtering at the Phylum level).">
            <expand macro="restricted_sanitizer_validator"/>
        </param>
        <param argument="--number-of-taxa" type="integer" value="9" min="1" label="Number of most abundant taxa to retain" help="Number of the most abundant taxa to keep (e.g., 9). All remaining taxa are grouped under 'Other'."/>
    </xml>

    <!-- Test -->
    <xml name="phyloseq_composition_test_input">
        <param name="phyloseq_rdata" value="references/16-phylo_import.Rdata"/>
        <param name="var_exp" value="EnvType"/>
        <param name="taxa_rank_1" value="Kingdom"/>
        <param name="taxa_set_1" value="Bacteria"/>
        <param name="taxa_rank_2" value="Phylum"/>
        <param name="number_of_taxa" value="9" />
    </xml>

    <xml name="phyloseq_composition_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: Visualise Data Composition' />
                <has_text text='(phyloseq_composition.py' />
				<has_text text='v5.1.0)' />
                <!-- check html report contents -->
                <has_text_matching expression="Phylum: Actinobacteria.*Sample: BHT0.LOT07.*Abundance: 0.3806484555" />
                <has_text_matching expression="Phylum: Bacteroidetes.*Sample: BHT0.LOT07.*Abundance: 0.0026380734" />
                <has_text_matching expression="Phylum: Cyanobacteria.*Sample: BHT0.LOT07.*Abundance: 0.0000000000" />
                <has_text_matching expression="Phylum: Firmicutes.*Sample: BHT0.LOT07.*Abundance: 0.6024168156" />
                <has_text_matching expression="Phylum: Fusobacteria.*Sample: BHT0.LOT07.*Abundance: 0.0002552974" />
                <has_text_matching expression="Phylum: Proteobacteria.*Sample: BHT0.LOT07.*Abundance: 0.0137860608" />
                <has_text_matching expression="Phylum: Spirochaetes.*Sample: BHT0.LOT07.*Abundance: 0.0000000000" />
                <has_text_matching expression="Phylum: Tenericutes.*Sample: BHT0.LOT07.*Abundance: 0.0002552974" />
                <has_text_matching expression="Phylum: Other.*Sample: BHT0.LOT07.*Abundance: 0.0000000000" />
                <has_text text='─ Session info ───────────────────────────────────────────────────────────────' />
            </assert_contents>
        </output>
    </xml>
                
</macros>
