Mercurial > repos > gordon > unix_tools
diff sort-header.xml @ 0:631dfde45073 draft default tip
First tool-shed public version
| author | gordon |
|---|---|
| date | Tue, 09 Oct 2012 18:48:06 -0400 |
| parents | |
| children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sort-header.xml Tue Oct 09 18:48:06 2012 -0400 @@ -0,0 +1,129 @@ +<tool id="cshl_sort_header" name="Sort" version="0.1.1"> + <command interpreter="perl">sort-header + --header $header + $unique + $ignore_case + --stable + -t ' ' + #for $key in $sortkeys + '-k ${key.column}${key.order}${key.style},${key.column}' + #end for + --output '$out_file1' + '$input1' + </command> + + <inputs> + <param format="txt" name="input1" type="data" label="Sort Query" /> + + <!-- header line is boolean for now, but the values are 1 or 0. + in the future, we can use Galaxy's number-of-comment-lines variable --> + <param name="header" type="boolean" checked="false" truevalue="1" falsevalue="0" + label="First line is a header line" help="Use if first line contains column headers. It will not be sorted." /> + + <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="input1" 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="out_file1" metadata_source="input1" + /> + </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>
