comparison sort.xml @ 0:5314e5d6f040 draft

Imported from capsule None
author bgruening
date Thu, 29 Jan 2015 07:53:17 -0500
parents
children 43b1f073b693
comparison
equal deleted inserted replaced
-1:000000000000 0:5314e5d6f040
1 <tool id="tp_sort_header_tool" name="Sort" version="@BASE_VERSION@.0">
2 <description>data in ascending or descending order</description>
3 <macros>
4 <import>macros.xml</import>
5 </macros>
6 <expand macro="requirements">
7 <requirement type="package" version="4.2.2-sandbox">gnu_sed</requirement>
8 </expand>
9 <version_command>sort --version | head -n 1</version_command>
10 <command>
11 <![CDATA[
12 (
13 LC_ALL=C
14 #if int($header) > 0:
15 sed -u '${header}'q &&
16 #end if
17
18 sort $unique $ignore_case --stable -t ' '
19
20 #for $key in $sortkeys:
21 -k '${key.column}${key.order}${key.style},${key.column}'
22 #end for
23
24 ) < '${infile}' > '${outfile}'
25 ]]>
26 </command>
27 <inputs>
28 <param format="tabular" name="infile" type="data" label="Sort Query" />
29 <param name="header" type="integer" size="5" value="0"
30 label="Number of header lines" help="These will be ignored during sort.">
31 <validator type="in_range" message="Negative values are not allowed." min="0"/>
32 </param>
33
34 <repeat name="sortkeys" title="Column selections" min="1">
35 <param name="column" label="on column" type="data_column" data_ref="infile" accept_default="true" />
36 <param name="order" type="select" display="radio" label="in">
37 <option value="">Ascending order</option>
38 <option value="r">Descending order</option>
39 </param>
40 <param name="style" type="select" display="radio" label="Flavor">
41 <option value="n">Fast numeric sort (-n)</option>
42 <option value="g">General numeric sort ( scientific notation -g)</option>
43 <option value="V">Natural/Version sort (-V) </option>
44 <option value="">Alphabetical sort</option>
45 <option value="h">Human-readable numbers (-h)</option>
46 <option value="R">Random order (-R)</option>
47 </param>
48 </repeat>
49
50 <param name="unique" type="boolean" checked="false" truevalue="--unique" falsevalue=""
51 label="Output unique values" help="Print only unique values, based on sorted key columns. See help section for details. (--unique)" />
52 <param name="ignore_case" type="boolean" checked="false" truevalue="-i" falsevalue=""
53 label="Ignore case" help="Sort and Join key column values regardless of upper/lower case letters. (-i)" />
54 </inputs>
55 <outputs>
56 <data name="outfile" format_source="infile" metadata_source="infile"/>
57 </outputs>
58 <tests>
59 <test>
60 <param name="infile" value="sort1.bed"/>
61 <param name="header" value="3"/>
62 <repeat name="sortkeys">
63 <param name="column" value="1"/>
64 <param name="style" value=""/>
65 <param name="order" value=""/>
66 </repeat>
67 <repeat name="sortkeys">
68 <param name="column" value="3"/>
69 <param name="style" value="n"/>
70 <param name="order" value="r"/>
71 </repeat>
72 <output name="outfile" file="sort_result1.bed"/>
73 </test>
74 <test>
75 <param name="infile" value="sort1.bed"/>
76 <param name="header" value="3"/>
77 <repeat name="sortkeys">
78 <param name="column" value="1"/>
79 <param name="style" value=""/>
80 <param name="order" value=""/>
81 </repeat>
82 <repeat name="sortkeys">
83 <param name="column" value="3"/>
84 <param name="style" value="n"/>
85 <param name="order" value=""/>
86 </repeat>
87 <output name="outfile" file="sort_result2.bed"/>
88 </test>
89 <test>
90 <param name="infile" value="sort2.bed"/>
91 <repeat name="sortkeys">
92 <param name="column" value="5"/>
93 <param name="style" value="g"/>
94 <param name="order" value=""/>
95 </repeat>
96 <output name="outfile" file="sort_result3.bed"/>
97 </test>
98 </tests>
99 <help>
100 <![CDATA[
101 **What it does**
102
103 This tool sorts an input file.
104
105 -----
106
107 **Sorting Styles**
108
109 * **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).
110 * **General Numeric**: sort by numeric values. Handles all numeric notations (including scientific notation). Slower than *fast numeric*, so use only when necessary.
111 * **Natural Sort**: Sort in 'natural' order (natural to humans, not to computers). See example below.
112 * **Alphabetical sort**: Sort in strict alphabetical order. See example below.
113 * **Human-readable numbers**: Sort human readble numbers (e.g. 1G > 2M > 3K > 400)
114 * **Random order**: return lines in random order.
115
116 ------
117
118 **Example - Header line**
119
120 **Input file** (note first line is a header line, should not be sorted)::
121
122 Fruit Color Price
123 Banana Yellow 4.1
124 Avocado Green 8.0
125 Apple Red 3.0
126 Melon Green 6.1
127
128 **Sorting** by **numeric order** on column **3**, with **header**, will return::
129
130 Fruit Color Price
131 Apple Red 3.0
132 Banana Yellow 4.1
133 Melon Green 6.1
134 Avocado Green 8.0
135
136
137 -----
138
139 **Example - Natural vs. Alphabetical sorting**
140
141 Given the following list::
142
143 chr4
144 chr13
145 chr1
146 chr10
147 chr20
148 chr2
149
150 **Alphabetical sort** would produce the following sorted list::
151
152 chr1
153 chr10
154 chr13
155 chr2
156 chr20
157 chr4
158
159 **Natural Sort** would produce the following sorted list::
160
161 chr1
162 chr2
163 chr4
164 chr10
165 chr13
166 chr20
167
168
169 .. class:: infomark
170
171 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.
172
173 @REFERENCES@
174 ]]>
175 </help>
176 </tool>