annotate sort.xml @ 4:56e80527c482 draft

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