<?xml version="1.0"?>
<macros>
    <token name="@PHYLOSEQ_IMPORT_CMD_LINE@">
        phyloseq_import_data.py
            --input-biom '$input_biom'
            --sample-metadata-tsv '$sample_metadata_tsv'
            #if $tree_nwk
                --tree-nwk '$tree_nwk'
            #end if
            --ranks $ranks
            #if $normalisation == "true"
                --normalisation
            #end if
            --output-phyloseq-rdata '$ASV_phyloseq_rdata'
            --html '$html'
    </token>

    <xml name="phyloseq_import_inputs">
        <!-- Files -->
        <param argument="--input-biom" type="data" format="biom1" label="Abundance BIOM file with taxonomic affiliations (.biom)" help="BIOM file containing ASV abundances and their associated taxonomic annotations."/>
        <param argument="--sample-metadata-tsv" type="data" format="tabular,tsv" label="Sample metadata file (.tsv)" help="TSV file containing metadata describing each sample (e.g., condition, batch, environment)."/>
        <param argument="--tree-nwk" type="data" format="nhx" optional="true" label="Phylogenetic tree file (.nwk)" help="Optional Newick file containing the phylogenetic tree generated by the FROGS Core Tree tool."/>
        <!-- Parameters -->
        <param argument="--ranks" type="text" value="Kingdom Phylum Class Order Family Genus Species" 
            label="Names of taxonomic levels" help="The ordered taxonomic levels stored in BIOM. Each level is separated by one space">
            <expand macro="restricted_sanitizer_validator"/>
        </param>
        <param argument="--normalisation" type="select" label="Do you want to normalize your data ?" help="Choose whether to normalize read abundances before performing statistical analyses (default: No)." display="radio">
            <option value="false">No, keep original abundances.</option>
            <option value="true">Yes, subsample abundances to match the smallest sample size.</option>            
        </param>
    </xml>

    <!-- Test -->
    <xml name="phyloseq_import_test_input">
        <param name="input_biom" value="input/chaillou.biom"/>
        <param name="sample_metadata_tsv" value="input/sample_metadata.tsv"/>
        <param name="tree_nwk" value="input/tree.nwk"/>
    </xml>
    
    <xml name="phyloseq_import_test_output">
        <output name="ASV_phyloseq_rdata" value="references/16-phylo_import.Rdata" compare="sim_size" delta="10"/>
        <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: Import data' />
                <has_text text='(phyloseq_import_data.py' />
				<has_text text='v5.1.0)' />
                <!-- check phyloseq object summary-->
                <has_text text='otu_table()   OTU Table:         [ 507 taxa and 64 samples ]'/>
                <has_text text='sample_data() Sample Data:       [ 64 samples by 4 sample variables ]' />
                <has_text text='tax_table()   Taxonomy Table:    [ 507 taxa by 7 taxonomic ranks ]' />
                <has_text text='phy_tree()    Phylogenetic Tree: [ 507 tips and 506 internal nodes ]' />
                <!-- check phyloseq object rank names-->
                <has_text text='Rank names :  Kingdom, Phylum, Class, Order, Family, Genus, Species'/>
                <!-- check phyloseq object Sample variables-->
                <has_text text='Sample variables:  EnvType, Description, FoodType, SampleID'/>
                <!-- check phyloseq object Variables details-->
                <has_text text='EnvType :  BoeufHache, VeauHache, DesLardons, MerguezVolaille, SaumonFume, FiletSaumon, FiletCabillaud, Crevette'/>
                <has_text text='Description :  LOT1, LOT3, LOT4, LOT5, LOT6, LOT7, LOT8, LOT10, LOT2, LOT9'/>
                <has_text text='FoodType :  Meat, Seafood'/>
                <has_text text='SampleID :  BHT0.LOT01, BHT0.LOT03, BHT0.LOT04, BHT0.LOT05, BHT0.LOT06, BHT0.LOT07, BHT0.LOT08, BHT0.LOT10, VHT0.LOT01, VHT0.LOT02, VHT0.LOT03, VHT0.LOT04, VHT0.LOT06, VHT0.LOT07, VHT0.LOT08, VHT0.LOT10, DLT0.LOT01, DLT0.LOT03, DLT0.LOT04, DLT0.LOT05, DLT0.LOT06, DLT0.LOT07, DLT0.LOT08, DLT0.LOT10, MVT0.LOT01, MVT0.LOT03, MVT0.LOT05, MVT0.LOT06, MVT0.LOT07, MVT0.LOT08, MVT0.LOT09, MVT0.LOT10, SFT0.LOT01, SFT0.LOT02, SFT0.LOT03, SFT0.LOT04, SFT0.LOT05, SFT0.LOT06, SFT0.LOT07, SFT0.LOT08, FST0.LOT01, FST0.LOT02, FST0.LOT03, FST0.LOT05, FST0.LOT06, FST0.LOT07, FST0.LOT08, FST0.LOT10, FCT0.LOT01, FCT0.LOT02, FCT0.LOT03, FCT0.LOT05, FCT0.LOT06, FCT0.LOT07, FCT0.LOT08, FCT0.LOT10, CDT0.LOT02, CDT0.LOT04, CDT0.LOT05, CDT0.LOT06, CDT0.LOT07, CDT0.LOT08, CDT0.LOT09, CDT0.LOT10'/>
                <has_text text='─ Session info ───────────────────────────────────────────────────────────────' />
            </assert_contents>
        </output>
    </xml>
</macros>
