<commit_before><tool id="plot_grouped_barplot" name="Plot grouped barplot" version="0.1.0">
    <description>with R</description>

    <requirements>
        <requirement type="package" version="3.2.1">R</requirement>
        <requirement type="package" version="1.20.0">r-getopt</requirement>
    </requirements>

    <stdio>
        <exit_code range="1:" />
        <exit_code range=":-1" />
    </stdio>

    <version_command></version_command>

    <command><![CDATA[
        Rscript $__tool_directory__/plot_grouped_barplot.R
            --input_file $input_file
            --header $header

            #if str($output_format)=="pdf"
                --output_pdf_file $output_pdf_file
            #else
                --output_svg_file $output_svg_file
            #end if

            #set $column_with_data=""
            #set $colors=""
            #set $names=""
            #set $sep=""
            #for sample in $samples:
                #set $column_with_data = $column_with_data + $sep + str($sample.column_id)
                #set $colors = $colors + $sep + str($sample.color)
                #set $names = $names + $sep +str($sample.name)
                #set $sep=","
            #end for
            #set $column_with_data = $column_with_data
            #set $colors = $colors
            #set $names = $names

            --data_column $column_with_data
            --col "$colors"
            --names "$names"
            --replace_null $replace_null
            --order $order
            --names_column $names_column
            --xlab "$xlab"
            --log $log
            --bottom_margin $bottom_margin
            --left_margin $left_margin
            --top_margin $top_margin
            --right_margin $right_margin
            --legend_pos $legend_pos
    ]]></command>

    <inputs>
        <param name="input_file" type="data" format="tabular,tsv,csv" label="Input file" help="File in tabular format with tab-separated columns and header in first line (--input_file)"/>

        <param name="header" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="false" label="Header in first line?" help="(--header)"/>

        <param name="output_format" label="Format for output image" type="select" help="">
            <option value="pdf" selected="True">PDF</option>
            <option value="svg">SVG</option>
        </param>

        <repeat name="samples" title="Add sample information (column id, name, color)" >
            <param name="name" type="text" label="Name of the data" help="(--sample_name)"/>
            <param name="column_id" type="data_column" data_ref="input_file" label="Column containing corresponding data" multiple="false" numerical="true" help="(after normalization, --charact_input_file)"/>
            <param name="color" label="Bar color" type="text" value= "blue" help="R color (--col)"/>
        </repeat>
        <param name="replace_null" type="boolean" truevalue="TRUE" falsevalue="FALSE" label="Replace null values by NA?" help="(--replace_null)"/>
        <param name="order" type="boolean" truevalue="TRUE" falsevalue="FALSE" label="Order given the first chosen data?" help="(--order)"/>

        <param name="names_column" type="data_column" data_ref="input_file" multiple="false" numerical="false" label="Column containing data names?" help="(--names_column)" />

        <param name="xlab" type="text" value="" label="Label for x axis" help="(--xlab)"/>

        <param name="log" type="boolean" truevalue="TRUE" falsevalue="FALSE" label="Log scale?" help="(--log)"/>

        <param name="bottom_margin" type="integer" value="5" label="Bottom margin" help="(--bottom_margin)"/>
        <param name="left_margin" type="integer" value="19" label="Left margin" help="(--left_margin)"/>
        <param name="top_margin" type="integer" value="1" label="Top margin" help="(--top_margin)"/>
        <param name="right_margin" type="integer" value="1" label="Right margin" help="(--right_margin)"/>
        <param name="legend_pos" label="Position of the legend" type="select" help="">
            <option value="topright" selected="True">Top right</option>
            <option value="topleft">Top left</option>
            <option value="bottomright">Bottom right</option>
            <option value="bottomleft">Bottom left</option>
        </param>
    </inputs>

    <outputs>
        <data name="output_pdf_file" format="pdf"
            label="${tool.name} on ${on_string}: PDF barplot">
            <filter>output_format=="pdf"</filter>
        </data>
        <data name="output_png_file" format="png"
            label="${tool.name} on ${on_string}: PNG barplot">
            <filter>output_format=="png"</filter>
        </data>
        <data name="output_svg_file" format="svg"
            label="${tool.name} on ${on_string}: SVG barplot">
            <filter>output_format=="svg"</filter>
        </data>
    </outputs>

    <tests>
    </tests>

    <help><![CDATA[
        **What it does**

        This tool plot a grouped barplot from a tabular file into different format files given different customizable parameters:

        .. image:: $PATH_TO_IMAGES/output.png
           :scale: 50 %

        This tool relies on R's barplot function.

    ]]></help><commit_msg>Create test<commit_after><tool id="plot_grouped_barplot" name="Plot grouped barplot" version="0.1.0">
    <description>with R</description>

    <requirements>
        <requirement type="package" version="3.2.1">R</requirement>
        <requirement type="package" version="1.20.0">r-getopt</requirement>
    </requirements>

    <stdio>
        <exit_code range="1:" />
        <exit_code range=":-1" />
    </stdio>

    <version_command></version_command>

    <command><![CDATA[
        Rscript $__tool_directory__/plot_grouped_barplot.R
            --input_file $input_file
            --header $header

            #if str($output_format)=="pdf"
                --output_pdf_file $output_pdf_file
            #else
                --output_svg_file $output_svg_file
            #end if

            #set $column_with_data=""
            #set $colors=""
            #set $names=""
            #set $sep=""
            #for sample in $samples:
                #set $column_with_data = $column_with_data + $sep + str($sample.column_id)
                #set $colors = $colors + $sep + str($sample.color)
                #set $names = $names + $sep +str($sample.name)
                #set $sep=","
            #end for
            #set $column_with_data = $column_with_data
            #set $colors = $colors
            #set $names = $names

            --data_column $column_with_data
            --col "$colors"
            --names "$names"
            --replace_null $replace_null
            --order $order
            --names_column $names_column
            --xlab "$xlab"
            --log $log
            --bottom_margin $bottom_margin
            --left_margin $left_margin
            --top_margin $top_margin
            --right_margin $right_margin
            --legend_pos $legend_pos
    ]]></command>

    <inputs>
        <param name="input_file" type="data" format="tabular,tsv,csv" label="Input file" help="File in tabular format with tab-separated columns and header in first line (--input_file)"/>

        <param name="header" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="false" label="Header in first line?" help="(--header)"/>

        <param name="output_format" label="Format for output image" type="select" help="">
            <option value="pdf" selected="True">PDF</option>
            <option value="svg">SVG</option>
        </param>

        <repeat name="samples" title="Add sample information (column id, name, color)" >
            <param name="name" type="text" label="Name of the data" help="(--sample_name)"/>
            <param name="column_id" type="data_column" data_ref="input_file" label="Column containing corresponding data" multiple="false" numerical="true" help="(after normalization, --charact_input_file)"/>
            <param name="color" label="Bar color" type="text" value= "blue" help="R color (--col)"/>
        </repeat>
        <param name="replace_null" type="boolean" truevalue="TRUE" falsevalue="FALSE" label="Replace null values by NA?" help="(--replace_null)"/>
        <param name="order" type="boolean" truevalue="TRUE" falsevalue="FALSE" label="Order given the first chosen data?" help="(--order)"/>

        <param name="names_column" type="data_column" data_ref="input_file" multiple="false" numerical="false" label="Column containing data names?" help="(--names_column)" />

        <param name="xlab" type="text" value="" label="Label for x axis" help="(--xlab)"/>

        <param name="log" type="boolean" truevalue="TRUE" falsevalue="FALSE" label="Log scale?" help="(--log)"/>

        <param name="bottom_margin" type="integer" value="5" label="Bottom margin" help="(--bottom_margin)"/>
        <param name="left_margin" type="integer" value="19" label="Left margin" help="(--left_margin)"/>
        <param name="top_margin" type="integer" value="1" label="Top margin" help="(--top_margin)"/>
        <param name="right_margin" type="integer" value="1" label="Right margin" help="(--right_margin)"/>
        <param name="legend_pos" label="Position of the legend" type="select" help="">
            <option value="topright" selected="True">Top right</option>
            <option value="topleft">Top left</option>
            <option value="bottomright">Bottom right</option>
            <option value="bottomleft">Bottom left</option>
        </param>
    </inputs>

    <outputs>
        <data name="output_pdf_file" format="pdf"
            label="${tool.name} on ${on_string}: PDF barplot">
            <filter>output_format=="pdf"</filter>
        </data>
        <data name="output_png_file" format="png"
            label="${tool.name} on ${on_string}: PNG barplot">
            <filter>output_format=="png"</filter>
        </data>
        <data name="output_svg_file" format="svg"
            label="${tool.name} on ${on_string}: SVG barplot">
            <filter>output_format=="svg"</filter>
        </data>
    </outputs>

    <tests>
        <test>
            <param name="input_file" value="input_file_test.txt"/>
            <param name='header' value="FALSE"/>
            <param name="output_format" value="pdf"/>
            <param name="samples_0|name" value="A"/>
            <param name="samples_0|column_id" value="2"/>
            <param name="samples_0|color" value="blue"/>
            <param name="samples_1|name" value="B"/>
            <param name="samples_1|column_id" value="3"/>
            <param name="samples_1|color" value="red"/>
            <param name="replace_null" value="FALSE"/>
            <param name="order" value="FALSE"/>
            <param name="names_column" value="1"/>
            <param name='xlab' value=""/>
            <param name='log' value="FALSE"/>
            <param name='bottom_margin' value="5"/>
            <param name="left_margin" value="19"/>
            <param name='top_margin' value="1"/>
            <param name='right_margin' value="1"/>
            <param name="legend_pos" value="topright"/>
            <output name="output_pdf_file" file="output_test.pdf"/>
        </test>
    </tests>

    <help><![CDATA[
        **What it does**

        This tool plot a grouped barplot from a tabular file into different format files given different customizable parameters:

        .. image:: $PATH_TO_IMAGES/output.png
           :scale: 50 %

        This tool relies on R's barplot function.

    ]]></help>
{'fraction_non_alphanumeric': 0.15693524808667986, 'fraction_numerical': 0.004471579671510878, 'mean_word_length': 2.5707706478354315, 'pattern_counts': {'":': 2, '<': 167, '<?xml version=': 0, '>': 167, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '5623306', 'n_tokens_mistral': 3398, 'n_tokens_neox': 3289, 'n_words': 786}