view awklike-mutate.xml @ 0:8e1a86b7fbc4 draft default tip

"planemo upload for repository https://github.com/shenwei356/csvtk commit 3a97e1b79bf0c6cdd37d5c8fb497b85531a563ab"
author nml
date Tue, 19 May 2020 17:15:08 -0400
parents
children
line wrap: on
line source

<tool id="csvtk_awklike_mutate" name="csvtk-advanced-mutate" version="@VERSION@+@GALAXY_VERSION@">
    <description> new column by awk-like artithmetic/string expressions</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements" />
    <expand macro="version_cmd" />
    <command detect_errors="exit_code"><![CDATA[

###################
## Start Command ##
###################
csvtk mutate2 --num-cpus "\${GALAXY_SLOTS:-1}"

    ## Add additional flags as specified ##
    #######################################
    $global_param.illegal_rows
    $global_param.empty_rows
    $global_param.header
    $global_param.lazy_quotes

    ## Set Tabular input/output flag if first input is tabular ##
    #############################################################
    #if $in_1.is_of_type("tabular"):
        -t -T
    #end if

    ## Set input files ##
    #####################
    $in_1

    ## Specific inputs ##
    #####################
    -e '$in_text'
    -n '$column_name'
    -L '$additional.digit_number'
    $additional.digit_strings
    
    ## To output ##
    ###############
    > mutated

    ]]></command>
    <inputs>
        <expand macro="singular_input"/>
        <param name="in_text" type="text" argument="-e" label="Awk-like artithmetic/string expression" >
            <help>
                <![CDATA[
        Examples:
        - '$age>12'
        - '$1 > $3'
        - '$name=="abc"'
        - '$1 % 2 == 0'
        More info is available in the help section below. The ' character is invalid and will be replaced, thus you must
        surround strings with double quotes ("string") instead.
        ]]>
            </help>
            <expand macro="text_sanitizer" />
        </param>
        <param name="column_name" type="text" argument="-n" value="New_Column"
            label="New column name"
            help="Specify what the new column should be called">
            <expand macro="text_sanitizer" />
        </param>
        <section name="additional" title="Additional Parameters" expanded="true">
            <param name="digit_number" type="integer" value="2" argument="-L"
                label="Number of digits after the decimal to keep"
                help="Keep input integer number of decimal places"
            />
            <param name="digit_strings" type="boolean" checked="false" argument="-s"
                truevalue="-s"
                falsevalue=""
                label="Input digits as strings"
                help="Treat digits as string to avoid converting big digits into scientific notation. No longer supports mathematical operations if set to yes"
            />
        </section>
        <expand macro="global_parameters" />
    </inputs>
    <outputs>
        <data format_source="in_1" from_work_dir="mutated" name="mutated" label="${in_1.name} mutated by ${in_text}" />
    </outputs>
    <tests>
        <test>
            <param name="in_1" value="awk_mutate_input.csv" />
            <param name="in_text" value="$2*$3" />
            <param name="column_name" value="CFU/ml" />
            <section name="additional">
                <param name="digit_number" value="0" />
            </section>
            <output name="mutated" file="awk_mutate_output.csv" ftype="csv" />
        </test>
    </tests>
    <help><![CDATA[
    
Csvtk - Mutate2 Help
--------------------

Info
####

Csvtk advanced mutate (also called mutate2) outputs a column that evaluates the input expression. Please see the
`documentation <https://github.com/Knetic/govaluate/blob/master/MANUAL.md>`_ for further details and examples on how to write expressions.

Also checkout the tools `website <https://bioinf.shenwei.me/csvtk/usage/#mutate2>`_ for additional ideas on how to structure expressions!

.. class:: warningmark

    Single quotes are not allowed in text inputs!

.. class:: note

    If your wanted column header has a space in it, use the column number. Example: Use $1 if column #1 is called "Colony Counts"

Supported operators and types:

    - Modifiers: + - / * & | ^ ** % >> <<
    - Comparators: > >= < <= == != =~ !~
    - Logical ops: || &&
    - Numeric constants, as 64-bit floating point (12345.678)
    - String constants (double quotes only: "foobar")
    - Date constants (double quotes)
    - Boolean constants: true false
    - Parenthesis to control order of evaluation ( )
    - Arrays (anything separated by , within parenthesis: (1, 2, "foo"))
    - Prefixes: ! - ~
    - Ternary conditional: ? :
    - Null coalescence: ??

----

@HELP_INPUT_DATA@


Usage
#####

Some quick and simple examples:

**Ex. Mutate2 with Numbers:**

Suppose we had the following table:

+---------------+------------+----------+
| Culture Label | Cell Count | Dilution |
+===============+============+==========+
| ECo-1         | 2523       | 1000     |
+---------------+------------+----------+
| LPn-1         | 100        | 1000000  |
+---------------+------------+----------+
| LPn-2         | 4          | 1000     |
+---------------+------------+----------+

If we wanted to evaluate the CFU/ml of these samples (supposing a 1ml volume plated) with this tool,
we could create give our new column a name like "CFU/ml" and then use the expression "$2*$3" to get:

+---------------+------------+----------+-----------+
| Culture Label | Cell Count | Dilution | CFU/ml    |
+===============+============+==========+===========+
| ECo-1         | 2523       | 1000     | 2523000   |
+---------------+------------+----------+-----------+
| LPn-1         | 100        | 1000000  | 100000000 |
+---------------+------------+----------+-----------+
| LPn-2         | 4          | 1000     | 4000      |
+---------------+------------+----------+-----------+

Note how $2 was used to get column 2 due to it containing a space in its name

----

@HELP_COLUMNS@


@HELP_END_STATEMENT@


    ]]></help>
    <expand macro="citations" />
</tool>