view sort.xml @ 5:20344ce0c811 draft

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit b9d202134c3c6d0e5c398c3ae75e410067fcfc52
author bgruening
date Wed, 23 Nov 2016 15:56:41 -0500
parents 37e1eb05b1b4
children 60edf2f8c28f
line wrap: on
line source

<tool id="tp_sort_header_tool" name="Sort" version="@BASE_VERSION@.0">
    <description>data in ascending or descending order</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements">
        <requirement type="package" version="4.2.3.dev0">sed</requirement>
    </expand>
    <version_command>sort --version | head -n 1</version_command>
    <command>
<![CDATA[
        (
            LC_ALL=C
            #if int($header) > 0:
                sed -u '${header}'q &&
            #end if

            sort $unique $ignore_case --stable -t '	'

            #for $key in $sortkeys:
                -k '${key.column}${key.order}${key.style},${key.column}'
            #end for

        ) < '${infile}' > '${outfile}'
]]>
    </command>
    <inputs>
        <param format="tabular" name="infile" type="data" label="Sort Query" />
        <param name="header" type="integer" value="0"
            label="Number of header lines" help="These will be ignored during sort.">
            <validator type="in_range" message="Negative values are not allowed." min="0"/>
        </param>

        <repeat name="sortkeys" title="Column selections" min="1">
            <param name="column" label="on column" type="data_column" data_ref="infile" accept_default="true" />
            <param name="order" type="select" display="radio" label="in">
                <option value="">Ascending order</option>
                <option value="r">Descending order</option>
            </param>
            <param name="style" type="select" display="radio" label="Flavor">
                <option value="n">Fast numeric sort (-n)</option>
                <option value="g">General numeric sort ( scientific notation -g)</option>
                <option value="V">Natural/Version sort (-V) </option>
                <option value="">Alphabetical sort</option>
                <option value="h">Human-readable numbers (-h)</option>
                <option value="R">Random order (-R)</option>
            </param>
        </repeat>

        <param name="unique" type="boolean" checked="false" truevalue="--unique" falsevalue=""
            label="Output unique values" help="Print only unique values, based on sorted key columns. See help section for details. (--unique)" />
        <param name="ignore_case" type="boolean" checked="false" truevalue="-i" falsevalue=""
            label="Ignore case" help="Sort and Join key column values regardless of upper/lower case letters. (-i)" />
    </inputs>
    <outputs>
        <data name="outfile" format_source="infile" metadata_source="infile"/>
    </outputs>
    <tests>
        <test>
            <param name="infile" value="sort1.bed"/>
            <param name="header" value="3"/>
            <repeat name="sortkeys">
                <param name="column" value="1"/>
                <param name="style" value=""/>
                <param name="order" value=""/>
            </repeat>
            <repeat name="sortkeys">
                <param name="column" value="3"/>
                <param name="style" value="n"/>
                <param name="order" value="r"/>
            </repeat>
            <output name="outfile" file="sort_result1.bed"/>
        </test>
        <test>
            <param name="infile" value="sort1.bed"/>
            <param name="header" value="3"/>
            <repeat name="sortkeys">
                <param name="column" value="1"/>
                <param name="style" value=""/>
                <param name="order" value=""/>
            </repeat>
            <repeat name="sortkeys">
                <param name="column" value="3"/>
                <param name="style" value="n"/>
                <param name="order" value=""/>
            </repeat>
            <output name="outfile" file="sort_result2.bed"/>
        </test>
        <test>
            <param name="infile" value="sort2.bed"/>
            <repeat name="sortkeys">
                <param name="column" value="5"/>
                <param name="style" value="g"/>
                <param name="order" value=""/>
            </repeat>
            <output name="outfile" file="sort_result3.bed"/>
        </test>
    </tests>
    <help>
<![CDATA[
**What it does**

This tool sorts an input file.

-----

**Sorting Styles**

* **Fast Numeric**: sort by numeric values. Handles integer values (e.g. 43, 134) and decimal-point values (e.g. 3.14). *Does not* handle scientific notation (e.g. -2.32e2).
* **General Numeric**: sort by numeric values. Handles all numeric notations (including scientific notation). Slower than *fast numeric*, so use only when necessary.
* **Natural Sort**: Sort in 'natural' order (natural to humans, not to computers). See example below.
* **Alphabetical sort**: Sort in strict alphabetical order. See example below.
* **Human-readable numbers**: Sort human readble numbers (e.g. 1G > 2M > 3K > 400)
* **Random order**: return lines in random order.

------

**Example - Header line**

**Input file** (note first line is a header line, should not be sorted)::

    Fruit   Color   Price
    Banana  Yellow  4.1
    Avocado Green   8.0
    Apple   Red     3.0
    Melon   Green   6.1

**Sorting** by **numeric order** on column **3**, with **header**, will return::

    Fruit   Color   Price
    Apple   Red     3.0
    Banana  Yellow  4.1
    Melon   Green   6.1
    Avocado Green   8.0


-----

**Example - Natural vs. Alphabetical sorting**

Given the following list::

    chr4
    chr13
    chr1
    chr10
    chr20
    chr2

**Alphabetical sort** would produce the following sorted list::

    chr1
    chr10
    chr13
    chr2
    chr20
    chr4

**Natural Sort** would produce the following sorted list::

    chr1
    chr2
    chr4
    chr10
    chr13
    chr20


.. class:: infomark

If you're planning to use the file with another tool that expected sorted files (such as *join*), you should use the **Alphabetical sort**,  not the **Natural Sort**. Natural sort order is easier for humans, but is unnatural for computer programs.

@REFERENCES@
]]>
  </help>
</tool>