<commit_before><tool id="picrust_format_tree_and_trait_table" name="Format" version="@WRAPPER_VERSION@.0">
    <description>tree and trait tables</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements"/>
    <expand macro="version_command"/>
    <command detect_errors="aggressive"><![CDATA[
        format_tree_and_trait_table.py
            -i '$input_trait_table'
            -t '$input_tree'
            -o ./formatted/
            --input_table_delimiter $advanced.input_table_delimiter
            --output_table_delimiter $advanced.output_table_delimiter

            #if $advanced.input_tree_to_trait
                --tree_to_trait_mapping '$advanced.input_tree_to_trait'
            #end if

            #if $advanced.input_limit_otus
                --limit_tree_to_otus_fp '$advanced.input_limit_otus'
            #end if

            $advanced.suppress_bifurcating
            $advanced.convert_to_nexus
            $advanced.convert_values_to_ints
            $advanced.no_minimum_branch_length
            $advanced.supress_tree_filter
            $advanced.supress_table_filter
            $advanced.add_branch_length_to_root
    ]]></command>
    <inputs>
        <param name="input_trait_table" type="data" format="tabular,txt,csv" label="Input trait table"
               help="Input trait table in QIIME OTU table format"/>
        <param name="input_tree" type="data" format="nhx" label="Input tree" help="Input tree in Newick format"/>
        <section name="advanced" title="Advanced options" expanded="False">
            <param argument="--input_table_delimiter" type="select" label="Input table delimiter"
                   help="The character delimiting fields in the input trait table">
                <option value="tab" selected="true">Tab</option>
                <option value="space">Space</option>
                <option value="comma">Comma</option>
            </param>
            <param argument="--output_table_delimiter" type="select" label="Output table delimiter"
                   help="The character delimiting fields in the output trait table">
                <option value="tab" selected="true">Tab</option>
                <option value="space">Space</option>
                <option value="comma">Comma</option>
            </param>
            <param name="input_tree_to_trait" type="data" format="tabular" optional="true" label="Tree to trait mapping"
                   help="An optional two-column, tab-delimited text file mapping identifiers in the tree (column 1) to identifiers in the trait table (column 2). If supplied, the identifiers in the trait table will be converted to match the identifiers in the tree. (This mapping does not need to be supplied if the tree and trait table already use a common set of identifiers.)"/>
            <param name="input_limit_otus" type="data" format="tabular,txt,csv" optional="true" label="Limit trees"
                   help="Prune the reference tree to contain only those tips that are within the given OTU table"/>
            <param argument="--suppress_bifurcating" type="boolean" truevalue="--suppress_bifurcating" falsevalue="" checked="false"
                   label="Suppress bifurcating" help="If set, don’t ensure that tree is fully bifurcating"/>
            <param argument="--convert_to_nexus" type="boolean" truevalue="--convert_to_nexus" falsevalue="" checked="false"
                   label="Convert to NEXUS format" help="Convert tree to NEXUS format, including a translate block mapping tip names to numbers"/>
            <param argument="--convert_values_to_ints" type="boolean" truevalue="--convert_values_to_ints" falsevalue="" checked="false"
                   label="Convert character state to integers" help="Convert the values for each character state to integers"/>
            <param argument="--no_minimum_branch_length" type="boolean" truevalue="--no_minimum_branch_length" falsevalue="" checked="false"
                   label="No minimum branch length" help="If set, don’t ensure all branches have at least a small but non-zero branch length"/>
            <param argument="--supress_tree_filter" type="boolean" truevalue="--supress_tree_filter" falsevalue="" checked="false"
                   label="Supress tree filter" help="If set, don’t filter out tree tips that aren’t listed in the trait table"/>
            <param argument="--supress_table_filter" type="boolean" truevalue="--supress_table_filter" falsevalue="" checked="false"
                   label="Supress table filter" help="If set, don’t filter out trait table entries that aren’t listed in the tree"/>
            <param argument="--add_branch_length_to_root" type="boolean" truevalue="--add_branch_length_to_root" falsevalue="" checked="false"
                   label="Add branch to root" help="Add a short branch to the root node (this is required by some phylogeny programs). The length of the branch is determined by the min_branch_length option"/>
        </section>
    </inputs>
    <outputs>
        <data name="reference_tree" label="${tool.name} on ${on_string}: Reference tree" format="nhx"
              from_work_dir="formatted/reference_tree.newick"/>
        <data name="pruned_tree" label="${tool.name} on ${on_string}: Pruned tree" format="nhx"
              from_work_dir="formatted/pruned_tree.newick">
            <change_format>
                <when input="advanced.convert_to_nexus" value="--convert_to_nexus" format="nex"/>
            </change_format>
        </data>
        <data name="trait_table" label="${tool.name} on ${on_string}: Trait table" format="tabular"
              from_work_dir="formatted/trait_table.tab">
            <change_format>
                <when input="advanced.output_table_delimiter" value="space" format="txt"/>
                <when input="advanced.output_table_delimiter" value="comma" format="csv"/>
            </change_format>
        </data>
    </outputs>
    <tests>
        <test>
            <param name="input_trait_table" value="format_tree_and_trait_table/input_traits.tab"/>
            <param name="input_tree" value="format_tree_and_trait_table/input_tree.nwk"/>
            <output name="reference_tree" ftype="nhx" file="format_tree_and_trait_table/reference_tree.newick"/>
            <output name="pruned_tree" ftype="nhx" file="format_tree_and_trait_table/pruned_tree.newick"/>
            <output name="trait_table" ftype="tabluar" file="format_tree_and_trait_table/trait_table.tab"/>
        </test>
    </tests>
    <help>
<![CDATA[
@PICRUST_OVERVIEW@

**Command Documenation**

This module does numerous formatting and checks to the reference tree and the trait tables. The following steps are done for both the marker gene copy number table and functional trait copy number table:

1. All internal nodes in the reference tree are checked for problematic characters and unlabelled internal nodes are given labels.
2. A pruned tree is created that contains only tips that have copy number predictions from sequenced genomes.
3. Any traits in the trait table that are not in the reference tree are removed.

Optional fixes include:

- Add short (epsilon) branch lengths in place of 0 length branches
- Filter out taxa that don't match between tree and trait table
- Output tree in NEXUS format
- Ensure tree is bifurcating (remove polytomies using very short branches)<commit_msg>Fix typo<commit_after><tool id="picrust_format_tree_and_trait_table" name="Format" version="@WRAPPER_VERSION@.0">
    <description>tree and trait tables</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements"/>
    <expand macro="version_command"/>
    <command detect_errors="aggressive"><![CDATA[
        format_tree_and_trait_table.py
            -i '$input_trait_table'
            -t '$input_tree'
            -o ./formatted/
            --input_table_delimiter $advanced.input_table_delimiter
            --output_table_delimiter $advanced.output_table_delimiter

            #if $advanced.input_tree_to_trait
                --tree_to_trait_mapping '$advanced.input_tree_to_trait'
            #end if

            #if $advanced.input_limit_otus
                --limit_tree_to_otus_fp '$advanced.input_limit_otus'
            #end if

            $advanced.suppress_bifurcating
            $advanced.convert_to_nexus
            $advanced.convert_values_to_ints
            $advanced.no_minimum_branch_length
            $advanced.supress_tree_filter
            $advanced.supress_table_filter
            $advanced.add_branch_length_to_root
    ]]></command>
    <inputs>
        <param name="input_trait_table" type="data" format="tabular,txt,csv" label="Input trait table"
               help="Input trait table in QIIME OTU table format"/>
        <param name="input_tree" type="data" format="nhx" label="Input tree" help="Input tree in Newick format"/>
        <section name="advanced" title="Advanced options" expanded="False">
            <param argument="--input_table_delimiter" type="select" label="Input table delimiter"
                   help="The character delimiting fields in the input trait table">
                <option value="tab" selected="true">Tab</option>
                <option value="space">Space</option>
                <option value="comma">Comma</option>
            </param>
            <param argument="--output_table_delimiter" type="select" label="Output table delimiter"
                   help="The character delimiting fields in the output trait table">
                <option value="tab" selected="true">Tab</option>
                <option value="space">Space</option>
                <option value="comma">Comma</option>
            </param>
            <param name="input_tree_to_trait" type="data" format="tabular" optional="true" label="Tree to trait mapping"
                   help="An optional two-column, tab-delimited text file mapping identifiers in the tree (column 1) to identifiers in the trait table (column 2). If supplied, the identifiers in the trait table will be converted to match the identifiers in the tree. (This mapping does not need to be supplied if the tree and trait table already use a common set of identifiers.)"/>
            <param name="input_limit_otus" type="data" format="tabular,txt,csv" optional="true" label="Limit trees"
                   help="Prune the reference tree to contain only those tips that are within the given OTU table"/>
            <param argument="--suppress_bifurcating" type="boolean" truevalue="--suppress_bifurcating" falsevalue="" checked="false"
                   label="Suppress bifurcating" help="If set, don’t ensure that tree is fully bifurcating"/>
            <param argument="--convert_to_nexus" type="boolean" truevalue="--convert_to_nexus" falsevalue="" checked="false"
                   label="Convert to NEXUS format" help="Convert tree to NEXUS format, including a translate block mapping tip names to numbers"/>
            <param argument="--convert_values_to_ints" type="boolean" truevalue="--convert_values_to_ints" falsevalue="" checked="false"
                   label="Convert character state to integers" help="Convert the values for each character state to integers"/>
            <param argument="--no_minimum_branch_length" type="boolean" truevalue="--no_minimum_branch_length" falsevalue="" checked="false"
                   label="No minimum branch length" help="If set, don’t ensure all branches have at least a small but non-zero branch length"/>
            <param argument="--supress_tree_filter" type="boolean" truevalue="--supress_tree_filter" falsevalue="" checked="false"
                   label="Supress tree filter" help="If set, don’t filter out tree tips that aren’t listed in the trait table"/>
            <param argument="--supress_table_filter" type="boolean" truevalue="--supress_table_filter" falsevalue="" checked="false"
                   label="Supress table filter" help="If set, don’t filter out trait table entries that aren’t listed in the tree"/>
            <param argument="--add_branch_length_to_root" type="boolean" truevalue="--add_branch_length_to_root" falsevalue="" checked="false"
                   label="Add branch to root" help="Add a short branch to the root node (this is required by some phylogeny programs). The length of the branch is determined by the min_branch_length option"/>
        </section>
    </inputs>
    <outputs>
        <data name="reference_tree" label="${tool.name} on ${on_string}: Reference tree" format="nhx"
              from_work_dir="formatted/reference_tree.newick"/>
        <data name="pruned_tree" label="${tool.name} on ${on_string}: Pruned tree" format="nhx"
              from_work_dir="formatted/pruned_tree.newick">
            <change_format>
                <when input="advanced.convert_to_nexus" value="--convert_to_nexus" format="nex"/>
            </change_format>
        </data>
        <data name="trait_table" label="${tool.name} on ${on_string}: Trait table" format="tabular"
              from_work_dir="formatted/trait_table.tab">
            <change_format>
                <when input="advanced.output_table_delimiter" value="space" format="txt"/>
                <when input="advanced.output_table_delimiter" value="comma" format="csv"/>
            </change_format>
        </data>
    </outputs>
    <tests>
        <test>
            <param name="input_trait_table" value="format_tree_and_trait_table/input_traits.tab"/>
            <param name="input_tree" value="format_tree_and_trait_table/input_tree.nwk"/>
            <output name="reference_tree" ftype="nhx" file="format_tree_and_trait_table/reference_tree.newick"/>
            <output name="pruned_tree" ftype="nhx" file="format_tree_and_trait_table/pruned_tree.newick"/>
            <output name="trait_table" ftype="tabular" file="format_tree_and_trait_table/trait_table.tab"/>
        </test>
    </tests>
    <help>
<![CDATA[
@PICRUST_OVERVIEW@

**Command Documenation**

This module does numerous formatting and checks to the reference tree and the trait tables. The following steps are done for both the marker gene copy number table and functional trait copy number table:

1. All internal nodes in the reference tree are checked for problematic characters and unlabelled internal nodes are given labels.
2. A pruned tree is created that contains only tips that have copy number predictions from sequenced genomes.
3. Any traits in the trait table that are not in the reference tree are removed.

Optional fixes include:

- Add short (epsilon) branch lengths in place of 0 length branches
- Filter out taxa that don't match between tree and trait table
- Output tree in NEXUS format
- Ensure tree is bifurcating (remove polytomies using very short branches)
{'fraction_non_alphanumeric': 0.10390135435617547, 'fraction_numerical': 0.0009433326595242908, 'mean_word_length': 3.1068068622025455, 'pattern_counts': {'":': 0, '<': 139, '<?xml version=': 0, '>': 137, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4323905', 'n_tokens_mistral': 4081, 'n_tokens_neox': 3940, 'n_words': 1180}