view macros.xml @ 1:07164270ec13 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/DIMet commit 7568e92bfc4560d6e0287e7444455f55c86d135d
author iuc
date Tue, 23 Jan 2024 14:57:41 +0000
parents c9040bdb918c
children 1df18470e3d0
line wrap: on
line source

<macros>
    <token name="@TOOL_VERSION@">0.1.4</token>
    <token name="@VERSION_SUFFIX@">1</token>
    <token name="@EXECUTABLE@">pca</token>
    <xml name="factor_repeat">
        <repeat name="rep_factorName" title="Factor" min="1">
            <param name="factorName" type="text" value="FactorName" label="Specify a factor name, e.g. effects_drug_x or cancer_markers"
                help="Only letters, numbers and underscores will be retained in this field">
                <sanitizer>
                    <valid initial="string.letters,string.digits"><add value="_" /></valid>
                </sanitizer>
            </param>
            <repeat name="rep_factorLevel" title="Factor level" min="2" default="2">
                <param name="factorLevel" type="text" value="FactorLevel" label="Specify a factor level, typical values could be 'tumor', 'normal', 'treated' or 'control'"
                    help="Only letters, numbers and underscores will be retained in this field">
                    <sanitizer>
                        <valid initial="string.letters,string.digits"><add value="_" /></valid>
                    </sanitizer>
                </param>
                <yield/>
            </repeat>
        </repeat>
    </xml>
    <xml name="requirements">
        <requirements>
            <requirement type="package" version="@TOOL_VERSION@">dimet</requirement>
        </requirements>
    </xml>
    <xml name="statistical_test">
        <param name="stat_test" type="select" value="Tt"  display="radio" label="Select statistical to apply" help="Please enter at max 1 statistical test by file">
            <option value="Tt">t-test</option>
            <option value="MW">Mann Whitney</option>
            <option value="KW">Kruskall Wallis</option>
            <option value="ranksum">Wilcoxon's rank sum test</option>
            <option value="Wcox">Wilcoxon signed-rank test</option>
            <option value="BrMu">Brunner-Munzel test</option>
            <option value="prm-scipy">permutations test</option>
            <option value="disfit">distribution fitting (of the z-score of the ratios), disfit needs several hundreds of metabolites to be trustful.</option>
        </param>
    </xml>
    <xml name="citations">
        <citations>
            <citation type="bibtex">
                @software{Galvis_Rodriguez_DIMet,
                    author = {Galvis Rodriguez, Johanna  and Guyon, Joris and Dartigues, Benjamin and Specque, Florian and Daubon, Thomas and Karkar, Slim and Nikolski, Macha},
                    license = {MIT},
                    title = {{DIMet}},
                    url = {https://github.com/cbib/DIMet}
                    }

            </citation>
        </citations>

    </xml>
    <xml name="metadata_file_macros">
        <param name="metadata_path" type="data" format="tabular" label="metadata file" help="The metadata, a unique file with the description of the samples in your measures' files. This is compulsory, see section Metadata File Information."/>
    </xml>
    <xml name="abundance_file_macros">
        <param name="abundance_file" type="data" format="tabular" label="Metabolite abundance file" help="The total abundances file must be organized as a matrix: - The first column must contain Metabolite IDs that are unique (not repeated) within the file. - The rest of the columns correspond to the samples - The rows correspond to the metabolites - The values must be tab separated, with the first row containing the sample/column labels. (see help below for more details)"/>
    </xml>
    <xml name="enrichment_file_macros">
        <param name="me_or_frac_contrib_file" type="data" format="tabular" label="Metabolite enrichment file" help="The mean enrichment file must be organized as a matrix: - The first column must contain Metabolite IDs that are unique (not repeated) within the file. - The rest of the columns correspond to the samples. - The rows correspond to the metabolites. - The values must be tab separated, with the first row containing the sample/column labels. (see help below for more details)"/>
    </xml>
    <xml name="isotopologue_prop_file_macros">
        <param name="isotop_prop_file" type="data" format="tabular" label="Isotopologues proportion abundance file" help="    The isotopologue proportions file must be organized as a matrix: - The first column must contain isotopologues IDs that are unique (not repeated) within the file. - The rest of the columns correspond to the samples. - The rows correspond to the isotopologues. - The values must be tab separated, with the first row containing the sample/column labels  (see help below for more details)."/>
    </xml>
    <xml name="isotopologue_abs_file_macros">
        <param name="isotop_abs_file" type="data" format="tabular" label="Isotopologues absolute abundance file" help="The isotopologue absolute values file must be organized as a matrix: - The first column must contain isotopologues IDs that are unique (not repeated) within the file. - The rest of the columns correspond to the samples. - The rows correspond to the isotopologues. - The values must be tab separated, with the first row containing the sample/column labels  (see help below for more details)."/>
    </xml>
    <xml name="input_parameters_pca">
        <expand macro="abundance_file_macros"/>
        <param name="me_or_frac_contrib_file" type="data" optional="true" format="tabular" label="Mean enrichment or fraction contribution file"/>
        <expand macro="metadata_file_macros"/>
    </xml>
    <xml name="input_parameters_abundance">
        <expand macro="abundance_file_macros"/>
        <expand macro="metadata_file_macros"/>
    </xml>
    <xml name="input_parameters_enrichment">
        <expand macro="enrichment_file_macros"/>
        <expand macro="metadata_file_macros"/>
    </xml>
    <xml name="input_parameters_isotopologue">
        <expand macro="isotopologue_prop_file_macros"/>
        <expand macro="metadata_file_macros"/>
    </xml>
    <xml name="input_parameters_metabologram">
        <conditional name="data_input">
            <param name="data_input_selector" type="select" label="Abundance, Enrichment or Isotopologues count files" help="Select between raw abundance, mean enrichment or isotopologue files">
                <option value="abundance" selected="True">abundance</option>
                <option value="mean_enrichment">mean_enrichment</option>
            </param>
            <when value="abundance">
                <expand macro="abundance_file_macros"/>
                <param name="metabolites_list" type="select" optional="false" multiple="true"
                       label="Select Metabolite(s) for factor 1 to plot (1 Min.). You have to load a abundance file prior to have access to metabolite list">
                    <validator type="length" min="1" message="Please enter at max 2 compartments"/>
                    <options from_dataset="abundance_file">
                        <column name="metabolite_or_isotopologue" index="0"/>
                        <column name="value" index="0"/>
                        <filter type="unique_value" name="metabolite_or_isotopologue" column="0"/>
                        <filter type="remove_value" value="metabolite_or_isotopologue"/>
                    </options>
                    <sanitizer>
                        <valid initial="default">
                            <add preset="string.printable"/>
                            <add value="\t"/>
                            <remove value="&quot;"/>
                            <remove value="&apos;"/>
                        </valid>
                    </sanitizer>
                </param>
                <expand macro="statistical_test"/>
            </when>
            <when value="mean_enrichment">
                <expand macro="enrichment_file_macros"/>
                <param name="metabolites_list" type="select" optional="false" multiple="true"
                       label="Select Metabolite(s) for factor 1 to plot (1 Min.). You have to load a abundance file prior to have access to metabolite list">
                    <validator type="length" min="1" message="Please enter at max 2 compartments"/>
                    <options from_dataset="me_or_frac_contrib_file">
                        <column name="metabolite_or_isotopologue" index="0"/>
                        <column name="value" index="0"/>
                        <filter type="unique_value" name="metabolite_or_isotopologue" column="0"/>
                        <filter type="remove_value" value="metabolite_or_isotopologue"/>
                    </options>
                    <sanitizer>
                        <valid initial="default">
                            <add preset="string.printable"/>
                            <add value="\t"/>
                            <remove value="&quot;"/>
                            <remove value="&apos;"/>
                        </valid>
                    </sanitizer>
                </param>
                <expand macro="statistical_test"/>
            </when>
        </conditional>
        <param name="path_kegg_metabolites" type="data" format="tabular" label="Pathways kegg metabolites file" help="A file with the pathways and respective metabolites ID, that must match with those in your metabolomics data. The names of the columns must be the pathways' names, see the minimal data example downloaded from zenodo as explained above. (see help below for more details)"/>
        <param name="path_kegg_transcripts" type="data" format="tabular" label="Pathways kegg transcripts file" help="A file with the pathways and respective gene symbols, which must match with those present in the transcriptomics data. The names of the columns must be the pathways' names, see the minimal data example downloaded from zenodo as explained above. (see help below for more details)"/>
        <expand macro="metadata_file_macros"/>
    </xml>
    <xml name="input_parameters_diff_analysis">
        <conditional name="data_input">
            <param name="data_input_selector" type="select" label="Abundance, Enrichment or Isotopologues count files" help="Select between raw abundance and mean enrichment files">
                <option value="abundance" selected="True">abundance</option>
                <option value="mean_enrichment">mean_enrichment</option>
                <option value="isotop_prop">isotop_prop</option>
                <option value="isotop_abs">isotop_abs</option>
            </param>
            <when value="abundance">
                <expand macro="abundance_file_macros"/>
                <expand macro="statistical_test"/>

            </when>
            <when value="mean_enrichment">
                <expand macro="enrichment_file_macros"/>
                <expand macro="statistical_test"/>
            </when>
            <when value="isotop_prop">
                <expand macro="isotopologue_prop_file_macros"/>
                <expand macro="statistical_test"/>
            </when>
            <when value="isotop_abs">
                <expand macro="isotopologue_abs_file_macros"/>
                <expand macro="statistical_test"/>
            </when>
        </conditional>
        <expand macro="metadata_file_macros"/>
    </xml>
    <xml name="suffix">
        <param name="suffix" type="text" optional="false" label="suffix to add to output files" >
            <sanitizer invalid_char="">
                <valid initial="string.ascii_letters,string.digits">
                    <add value="_" />
                </valid>
            </sanitizer>
        </param>      
    </xml>
    <xml name="conditions">
        <param name="conditions" type="select" optional="false" multiple="true" label="Browse conditions from metadata file (1 min. only if two timepoints are set. 2 max.). You have to load a metadata file prior to have access to metabolite list">
            <options from_dataset="metadata_path">
                <column name="condition" index="1"/>
                <column name="value" index="1"/>
                <filter type="unique_value" name="condition" column="condition"/>
                <filter type="remove_value" value="condition"/>
            </options>
            <sanitizer>
                <valid initial="default">
                    <add preset="string.printable"/>
                    <add value="\t"/>
                    <remove value="&quot;"/>
                    <remove value="&apos;"/>
                </valid>
            </sanitizer>
        </param>
    </xml>
    <xml name="conditions_multigroup">
        <param name="conditions" type="select" optional="false" multiple="true" label="Browse conditions from metadata file. (1 min. only if three timepoints are set). You have to load a metadata file prior to have access to conditions">
            <options from_dataset="metadata_path">
                <column name="condition" index="1"/>
                <column name="value" index="1"/>
                <filter type="unique_value" name="condition" column="condition"/>
                <filter type="remove_value" value="condition"/>
            </options>
            <sanitizer>
                <valid initial="default">
                    <add preset="string.printable"/>
                    <add value="\t"/>
                    <remove value="&quot;"/>
                    <remove value="&apos;"/>
                </valid>
            </sanitizer>
        </param>
    </xml>
    <xml name="timepoint_multigroup">
        <param name="timepoint" type="select" optional="true" multiple="true" label="Browse timepoint from metadata file (1 min. only if three conditions are set). You have to load a metadata file prior to have access to conditions">
            <options from_dataset="metadata_path">
                <column name="timepoint" index="2"/>
                <column name="value" index="2"/>
                <filter type="unique_value" name="timepoint" column="2"/>
                <filter type="remove_value" value="timepoint"/>
                <filter type="sort_by" name="timepoint" column="1"/>
            </options>
            <sanitizer>
                <valid initial="default">
                    <add preset="string.printable"/>
                    <add value="\t"/>
                    <remove value="&quot;"/>
                    <remove value="&apos;"/>
                </valid>
            </sanitizer>
        </param>
    </xml>
    <xml name="timepoint">
        <param name="timepoint" type="select" optional="true" multiple="true" label="Browse timepoint from metadata file (1 min. only if two conditions are set.)">
            <options from_dataset="metadata_path">
                <column name="timepoint" index="2"/>
                <column name="value" index="2"/>
                <filter type="unique_value" name="timepoint" column="2"/>
                <filter type="remove_value" value="timepoint"/>
                <filter type="sort_by" name="timepoint" column="1"/>
            </options>
            <sanitizer>
                <valid initial="default">
                    <add preset="string.printable"/>
                    <add value="\t"/>
                    <remove value="&quot;"/>
                    <remove value="&apos;"/>
                </valid>
            </sanitizer>
        </param>
    </xml>
    <xml name="grouping">
        <param name="grouping" type="select"  optional="false" multiple="true" label="Browse group to compare">
            <option value="condition" selected="true">condition</option>
            <option value="timepoint" selected="true">timepoint</option>
        </param>
    </xml>
    <xml name="correction_method">
        <param name="correction_method" type="select" value="bonferroni" display="radio" label="Select multiple test correction to apply" help="Please enter at max 1 method">
                    <option value="bonferroni">bonferroni</option>
                    <option value="holm-sidak">holm-sidak</option>
                    <option value="holm">holm</option>
                    <option value="simes-hochberg">simes-hochberg</option>
                    <option value="hommel">hommel</option>
                    <option value="fdr_bh">fdr_bh</option>
                    <option value="fdr_by">fdr_by</option>
                    <option value="fdr_tsbh">fdr_tsbh</option>
                    <option value="fdr_tsbky">fdr_tsbky</option>
        </param>
    </xml>
    <xml name="compartments_enrichment">
        <param name="compartments" type="select" optional="false" multiple="true"
               label="Browse compartments from metadata file (All needed). You have to load a metadata file prior to have access to compartments">
            <options from_dataset="metadata_path">
                <column name="compartment" index="4"/>
                <column name="value" index="4"/>
                <filter type="unique_value" name="compartment" column="4"/>
                <filter type="remove_value" value="compartment"/>
            </options>
            <sanitizer>
                <valid initial="default">
                    <add preset="string.printable"/>
                    <add value="\t"/>
                    <remove value="&quot;"/>
                    <remove value="&apos;"/>
                </valid>
            </sanitizer>
        </param>
    </xml>
    <xml name="compartments_abundance">
        <param name="compartments" type="select" optional="false" multiple="true"
               label="Browse compartments from metadata file (All needed). You have to load a metadata file prior to have access to compartments">
            <options from_dataset="metadata_path">
                <column name="compartment" index="4"/>
                <column name="value" index="4"/>
                <filter type="unique_value" name="compartment" column="4"/>
                <filter type="remove_value" value="compartment"/>
            </options>
            <sanitizer>
                <valid initial="default">
                    <add preset="string.printable"/>
                    <add value="\t"/>
                    <remove value="&quot;"/>
                    <remove value="&apos;"/>
                </valid>
            </sanitizer>
        </param>
    </xml>
    <xml name="compartments">
        <param name="compartments" type="select" optional="false" multiple="true"
               label="Browse compartments from metadata file (1 min.). You have to load a metadata file prior to have access to compartments">
            <options from_dataset="metadata_path">
                <column name="compartment" index="4"/>
                <column name="value" index="4"/>
                <filter type="unique_value" name="compartment" column="4"/>
                <filter type="remove_value" value="compartment"/>
            </options>
            <sanitizer>
                <valid initial="default">
                    <add preset="string.printable"/>
                    <add value="\t"/>
                    <remove value="&quot;"/>
                    <remove value="&apos;"/>
                </valid>
            </sanitizer>
        </param>
    </xml>
    <xml name="abundance_metabolites_list">
        <param name="metabolites_list" type="select" optional="false" multiple="true"
               label="Select Metabolite(s) for factor 1 to plot (1 min). You have to load a abundance file prior to have access to metabolite list">
            <validator type="length" min="1" message="Please enter at max 2 compartments"/>
            <options from_dataset="abundance_file">
                <column name="metabolite_or_isotopologue" index="0"/>
                <column name="value" index="0"/>
                <filter type="unique_value" name="metabolite_or_isotopologue" column="0"/>
                <filter type="remove_value" value="metabolite_or_isotopologue"/>
            </options>
            <sanitizer>
                <valid initial="default">
                    <add preset="string.printable"/>
                    <add value="\t"/>
                    <remove value="&quot;"/>
                    <remove value="&apos;"/>
                </valid>
            </sanitizer>
        </param>
    </xml>
    <xml name="enrichment_metabolites_list">
        <param name="metabolites_list" type="select" optional="false" multiple="true"
               label="Select Metabolite(s) for factor 1 to plot (1 Min.). You have to load a abundance file prior to have access to metabolite list">
            <validator type="length" min="1" message="Please enter at max 2 compartments"/>
            <options from_dataset="me_or_frac_contrib_file">
                <column name="ID" index="0"/>
                <column name="value" index="0"/>
                <filter type="unique_value" name="ID" column="0"/>
                <filter type="remove_value" value="ID"/>
            </options>
            <sanitizer>
                <valid initial="default">
                    <add preset="string.printable"/>
                    <add value="\t"/>
                    <remove value="&quot;"/>
                    <remove value="&apos;"/>
                </valid>
            </sanitizer>
        </param>
    </xml>
    <xml name="isotopologue_metabolites_list">
        <param name="metabolites_list" type="select" optional="false" multiple="true"
               label="Select Metabolite(s) to plot (1 Min.). You have to load a abundance file prior to have access to metabolite list">
            <validator type="length" min="1" message="Please enter at max 2 compartments"/>
            <options from_dataset="isotop_prop_file">
                <column name="ID" index="0"/>
                <column name="value" index="0"/>
                <filter type="unique_value" name="ID" column="0"/>
                <filter type="remove_value" value="ID"/>
            </options>
            <sanitizer>
                <valid initial="default">
                    <add preset="string.printable"/>
                    <add value="\t"/>
                    <remove value="&quot;"/>
                    <remove value="&apos;"/>
                </valid>
            </sanitizer>
        </param>
    </xml>
    <xml name="deg_list">
        <repeat name="deg_list" title="Deregulated gene set">
            <param name="input" type="data" format="tabular" label="Deregulated genes set"/>
            <param name="idcol" type="data_column" data_ref="input" label="Column for id" use_header_names="true"/>
            <param name="valuecol" type="data_column" data_ref="input" label="Column for values" use_header_names="true"/>
        </repeat>
    </xml>
    <token name="@INIT_PCA@"><![CDATA[
    #import json
    #import re

    mkdir -p data/raw &&
    mkdir -p data/processed &&

    #if $metadata_path:
        ln -s '$metadata_path' data/raw/metadata.csv &&
    #end if
    #if $abundance_file:
        ln -s '$abundance_file' data/raw/abundance.csv &&
    #end if
    #if $me_or_frac_contrib_file:
        ln -s '$me_or_frac_contrib_file' data/raw/me_or_frac_contrib.csv &&
    #end if

    ]]></token>
    <token name="@INIT_CONFIG@"><![CDATA[
    mkdir -p '$__new_file_path__/config' &&
    touch '$__new_file_path__/config/config.yaml' &&
    ]]></token>
    <token name="@REMOVE_CONFIG@"><![CDATA[
    && rm -r '$__new_file_path__/config'
    ]]></token>
    <token name="@INIT_ABUNDANCE_PLOT@"><![CDATA[

    mkdir -p data/raw &&
    mkdir -p data/processed &&

    #if $metadata_path:
        ln -s '$metadata_path' data/raw/metadata.csv &&
    #end if
    #if $abundance_file:
        ln -s '$abundance_file' data/raw/abundance.csv &&
    #end if
    ]]></token>
    <token name="@INIT_ENRICHMENT_PLOT@"><![CDATA[

    mkdir -p data/raw &&
    mkdir -p data/processed &&

    #if $metadata_path:
        ln -s '$metadata_path' data/raw/metadata.csv &&
    #end if
    #if $me_or_frac_contrib_file:
        ln -s '$me_or_frac_contrib_file' data/raw/me_or_frac_contrib.csv &&
    #end if
    ]]></token>
    <token name="@INIT_ISOTOPOLOGUE_PLOT@"><![CDATA[

    mkdir -p data/raw &&
    mkdir -p data/processed &&

    #if $metadata_path:
        ln -s '$metadata_path' data/raw/metadata.csv &&
    #end if
    #if $isotop_prop_file:
        ln -s '$isotop_prop_file' data/raw/isotop_prop.csv &&
    #end if
    ]]></token>
    <token name="@INIT_DIFF_ANALYSIS@"><![CDATA[

    mkdir -p data/raw &&
    mkdir -p data/processed &&

    #if $metadata_path:
        ln -s '$metadata_path' data/raw/metadata.csv &&
    #end if

    #set $impute_values  = {}
    #if str( $data_input.data_input_selector ) == "abundance":
        #if $data_input.abundance_file:
            ln -s '$data_input.abundance_file' data/raw/abundance.csv &&
            #silent $impute_values['abundances']='min'
        #end if
    #elif str( $data_input.data_input_selector ) == "mean_enrichment":
        #if $data_input.me_or_frac_contrib_file:
            ln -s '$data_input.me_or_frac_contrib_file' data/raw/me_or_frac_contrib.csv &&
            #silent $impute_values['mean_enrichment']='min'
        #end if
    #elif str( $data_input.data_input_selector ) == "isotop_prop":
        #if $data_input.isotop_prop_file:
            ln -s '$data_input.isotop_prop_file' data/raw/isotop_prop.csv &&
            #silent $impute_values['isotopologue_proportions']='min'
        #end if
    #else
        #if $data_input.isotop_abs_file:
            ln -s '$data_input.isotop_abs_file' data/raw/isotop_abs.csv &&
            #silent $impute_values['isotopologues']='min'
        #end if
    #end if
    ]]></token>
    <token name="@INIT_METABOLOGRAM@"><![CDATA[
    #import json
    #import re
    #import os
    #import csv
    #import subprocess

    mkdir -p data/raw &&
    mkdir -p data/processed &&
    mkdir -p data/integration_files &&

    #if $path_kegg_metabolites:
        ln -s '$path_kegg_metabolites' data/integration_files/pathways_kegg_metabolites.csv &&
    #end if
    #if $path_kegg_transcripts:
        ln -s '$path_kegg_transcripts' data/integration_files/pathways_kegg_transcripts.csv &&
    #end if

    #if $metadata_path:
        ln -s '$metadata_path' data/raw/metadata.csv &&
    #end if

    #set $impute_values  = {}
    #if str( $data_input.data_input_selector ) == "abundance":
        #if $data_input.abundance_file:
            ln -s '$data_input.abundance_file' data/raw/abundance.csv &&
            #silent $impute_values['abundances']='min'
        #end if
    #else:
        #if $data_input.me_or_frac_contrib_file:
            ln -s '$data_input.me_or_frac_contrib_file' data/raw/me_or_frac_contrib.csv &&
            #silent $impute_values['mean_enrichment']='min'
        #end if
    #end if

    #for $i, $s in enumerate($deg_list)
        #set $cpt = str($i+1)
        ln -s '${s.input}' data/integration_files/DEG_comparison'${cpt}'.csv &&
    #end for


    ]]></token>
    <token name="@INIT_DIFF_MULTIGROUP_ANALYSIS@"><![CDATA[

    mkdir -p data/raw &&
    mkdir -p data/processed &&

    #if $metadata_path:
        ln -s '$metadata_path' data/raw/metadata.csv &&
    #end if

    #set $impute_values  = {}
    #if str( $data_input.data_input_selector ) == "abundance":
        #if $data_input.abundance_file:
            ln -s '$data_input.abundance_file' data/raw/abundance.csv &&
            #silent $impute_values['abundances']='min'
        #end if
    #elif str( $data_input.data_input_selector ) == "mean_enrichment":
        #if $data_input.me_or_frac_contrib_file:
            ln -s '$data_input.me_or_frac_contrib_file' data/raw/me_or_frac_contrib.csv &&
            #silent $impute_values['mean_enrichment']='min'
        #end if
    #elif str( $data_input.data_input_selector ) == "isotop_prop":
        #if $data_input.isotop_prop_file:
            ln -s '$data_input.isotop_prop_file' data/raw/isotop_prop.csv &&
            #silent $impute_values['isotopologue_proportions']='min'
        #end if
    #else
        #if $data_input.isotop_abs_file:
            ln -s '$data_input.isotop_abs_file' data/raw/isotop_abs.csv &&
            #silent $impute_values['isotopologues']='min'
        #end if
    #end if
    ]]></token>
    <token name="@INIT_IMPUTE_VALUES@"><![CDATA[
    #import re
    #set $impute_values  = {}
    #if $abundance_file:
        #silent $impute_values['abundances']='min'
    #end if
    #if $me_or_frac_contrib_file:
        #silent $impute_values['mean_enrichment']='min'
    #end if
    ]]></token>
    <token name="@INIT_DATATYPES@"><![CDATA[
    #import re
    #set $datatypes_avail = list()
    #if str( $data_input.data_input_selector ) == "abundance":
        #if $data_input.abundance_file:
            $datatypes_avail.append(re.sub('"', '', "abundances"))
        #end if
    #elif str( $data_input.data_input_selector ) == "mean_enrichment":
        #if $data_input.me_or_frac_contrib_file:
            $datatypes_avail.append(re.sub('"', '', "mean_enrichment"))
        #end if
    #elif str( $data_input.data_input_selector ) == "isotop_prop":
        #if $data_input.isotop_prop_file:
            $datatypes_avail.append(re.sub('"', '', "isotopologue_proportions"))
        #end if
    #else
        #if $data_input.isotop_abs_file:
            $datatypes_avail.append(re.sub('"', '', "isotopologues"))
        #end if
    #end if
    ]]></token>
    <token name="@INIT_STAT_TEST@"><![CDATA[
    #import re
    #set $statistical_test  = {}
    #if str( $data_input.data_input_selector ) == "abundance":
        #if $data_input.abundance_file:
            #silent $statistical_test['abundances']=str($data_input.stat_test)
        #end if
    #elif str( $data_input.data_input_selector ) == "mean_enrichment":
        #if $data_input.me_or_frac_contrib_file:
            #silent $statistical_test['mean_enrichment']=str($data_input.stat_test)
        #end if
    #elif str( $data_input.data_input_selector ) == "isotop_prop":
        #if $data_input.isotop_prop_file:
            #silent $statistical_test['isotopologue_proportions']=str($data_input.stat_test)
        #end if
    #else
        #if $data_input.isotop_abs_file:
            #silent $statistical_test['isotopologues']=str($data_input.stat_test)
        #end if
    #end if
    ]]></token>
    <token name="@INIT_CONDITIONS@"><![CDATA[
    #import re
    #set $conds = list()
    #for $co in $conditions:
        $conds.append(re.sub('"', '', str($co)))
    #end for
    ]]></token>
    <token name="@INIT_TIMEPOINTS@"><![CDATA[

    #import re
    #set $timepoints = list()
    #for $tp in $timepoint:
        $timepoints.append(re.sub('"', '', str($tp)))
    #end for
    ]]></token>
    <token name="@INIT_GROUPS@"><![CDATA[
    #import re
    #set $groups = list()
    $groups.append(re.sub('"', '', str("condition")))
    $groups.append(re.sub('"', '', str("timepoint")))

    ]]></token>
    <token name="@INIT_ENRICHMENT_METABOLITES@"><![CDATA[
    #import json
    #import re
    #set $metabolites = {}
    #for $cp in $compartments:
        #silent $metabolites[re.sub('"', '', str($cp))]=list()
        #for $met in $metabolites_list:
            $metabolites[re.sub('"', '', str($cp))].append(re.sub('"', '\'', str($met)))
        #end for
    #end for
    ]]></token>
    <token name="@INIT_ISOTOPOLOGUE_METABOLITES@"><![CDATA[
    #set $metabolites = {}
    #for $cp in $compartments:
        #silent $metabolites[re.sub('"', '', str($cp))]=list()
        #for $met in $metabolites_list:
            #set tmp_met=re.sub('\,', '--',str($met))
            #set tmp_met_bis=str(re.split('_m', str($tmp_met))[0])
            #set tmp_met_ter=re.sub('--', '\,',str($tmp_met_bis))
            $metabolites[re.sub('"', '', str($cp))].append(re.sub('"', '\'', str(tmp_met_ter)))
        #end for
    #end for
    ]]></token>
    <token name="@INIT_MULTIGROUP_COMPARISONS@"><![CDATA[
    #set $comparisons = list()
    #for $tp in $timepoint:
        #set $ctrl_found=False
        #set $ctrl=""

        #for $co in $conditions:
            #set $sub_comparisons = list()
            #if str($co) in ["Control", "control","ctrl"]:
                 #set $ctrl_found=True
                 #set $ctrl=str($co)
                 $sub_comparisons.append(re.sub('"', '', str($co)))
                 $sub_comparisons.append(re.sub('"', '', str($tp)))
            #else:
                $sub_comparisons.append(re.sub('"', '', str($co)))
                $sub_comparisons.append(re.sub('"', '', str($tp)))

            #end if
            $comparisons.append($sub_comparisons)
        #end for
    #end for
    ]]></token>
    <token name="@INIT_CONDITIONS_TIMECOURSE@"><![CDATA[
    #import re
    #set $conds = list()
    #for $co in $conditions:
        $conds.append(re.sub('"', '', str($co)))
    #end for

    ]]></token>
    <token name="@INIT_COMPARISONS@"><![CDATA[
    #import re
    #set $conds = list()
    #for $co in $conditions:
        $conds.append(re.sub('"', '', str($co)))
    #end for
    #set $timepoints = list()
    #for $tp in $timepoint:
        $timepoints.append(re.sub('"', '', str($tp)))
    #end for

    #set $comparisons = list()
    #if len($conds) > 1:
        #if len($timepoints) > 0:
            #for $tp in $timepoint:
                #set $ctrl_found=False
                #set $ctrl=""
                #set $comparisons_bis = list()
                #for $co in $conditions:
                    #set $sub_comparisons = list()
                    #if str($co) in ["'Control'", "'control'", "'ctrl'"]:
                        #set $ctrl_found=True
                        #set $ctrl=str($co)
                    #else:
                        $sub_comparisons.append(re.sub('"', '', str($co)))
                        $sub_comparisons.append(re.sub('"', '', str($tp)))

                    #end if
                    $comparisons_bis.append($sub_comparisons)
                #end for

                #if $ctrl_found:
                    $sub_comparisons.append(str($ctrl))
                    $sub_comparisons.append(str($tp))
                    $comparisons_bis.append($sub_comparisons)
                #end if

                $comparisons.append($comparisons_bis)
            #end for
         #else
            #for $co in $conditions:
                $comparisons.append(re.sub('"', '', str($co)))
            #end for
        #end if

    #else
        #if len($conds) > 0:
            #if len($timepoints) > 1:
                #for $co in $conditions:
                    #set $comparisons_bis = list()
                    #for $tp in $timepoint:
                        #set $sub_comparisons = list()
                        $sub_comparisons.append(re.sub('"', '', str($co)))
                        $sub_comparisons.append(re.sub('"', '', str($tp)))
                        $comparisons_bis.append($sub_comparisons)
                    #end for
                    $comparisons.append($comparisons_bis)
                #end for
            #end if
        #else
            #for $tp in $timepoint:
                $comparisons.append(re.sub('"', '', str($tp)))
            #end for
        #end if
    #end if
    ]]></token>
    <token name="@INIT_TRANSCRIPTS@"><![CDATA[
    #import re
    #import os
    #import subprocess
    #set $transcripts  = list()

    #for $i, $s in enumerate($deg_list)
        #set $cpt = str($i+1)
        $transcripts.append(re.sub('"', '', "DEG_comparison"+str($i+1)))
        #set $deg_one_values = os.fsdecode(subprocess.check_output('head -n1 ' + str($s.input) + '| cut -f' + str($s.valuecol), shell=True))
        #set $deg_one_id = os.fsdecode(subprocess.check_output('head -n1 ' + str($s.input) + '| cut -f' + str($s.idcol), shell=True))
    #end for
    ]]></token>
    <token name="@INIT_PATHWAYS@"><![CDATA[
    #set $pathways  = {}
    #if $path_kegg_metabolites:
        #silent $pathways['metabolites']='pathways_kegg_metabolites'
    #end if
    #if $path_kegg_transcripts:
        #silent $pathways['transcripts']='pathways_kegg_transcripts'
    #end if
    ]]></token>
</macros>