annotate sort.xml @ 0:5314e5d6f040 draft

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