Mercurial > repos > bgruening > text_processing
diff sort.xml @ 0:ec66f9d90ef0 draft
initial uploaded
author | bgruening |
---|---|
date | Thu, 05 Sep 2013 04:58:21 -0400 |
parents | |
children | a4ad586d1403 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sort.xml Thu Sep 05 04:58:21 2013 -0400 @@ -0,0 +1,137 @@ +<tool id="unixtools_sort_header_tool" name="Sort" version="0.1.1"> + <requirements> + <requirement type="package" version="8.21">gnu_coreutils</requirement> + <requirement type="package" version="4.2.2-sandbox">gnu_sed</requirement> + </requirements> + <command interpreter="sh"> + #if int($header) > 0: + (sed -u '${header}'q && sort $unique $ignore_case --stable -t ' ' + + #for $key in $sortkeys + '-k ${key.column}${key.order}${key.style},${key.column}' + #end for + + ) < '${infile}' > '${outfile}' + #else: + (sort $unique $ignore_case --stable -t ' ' + + #for $key in $sortkeys + '-k ${key.column}${key.order}${key.style},${key.column}' + #end for + + ) < '${infile}' > '${outfile}' + #end if + </command> + + <inputs> + <param format="txt" name="infile" type="data" label="Sort Query" /> + <param name="header" type="integer" size="5" value="1" 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> + + <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." /> + + <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." /> + + <repeat name="sortkeys" title="sort key"> + <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</option> + </param> + </repeat> + </inputs> + <tests> + </tests> + <outputs> + <data format="input" name="outfile" metadata_source="infile"/> + </outputs> + <help> + +**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. + +----- + +*sort-header* is was written by A. Gordon ( gordon at cshl dot edu ) + + </help> +</tool>