0
|
1 <tool id="cshl_sort_tool" name="Sort">
|
|
2 <!--
|
|
3 note 1:
|
|
4 the 'version' sort (or natual order sort)
|
|
5 requires GNU Coreutils 7.1 or later
|
|
6
|
|
7 note 2:
|
|
8 for greater efficiency, sort buffer size is very large.
|
|
9 If your Galaxy server doesn't have so much memory (or the
|
|
10 sorts you use don't require it) - you can decrease the memory size.
|
|
11 (argument is "-S 2G")
|
|
12 -->
|
|
13 <command>sort -S 2G $unique
|
|
14 #for $key in $sortkeys
|
|
15 '-k ${key.column},${key.column}${key.order}${key.style}'
|
|
16 #end for
|
|
17 $input > $out_file1
|
|
18 </command>
|
|
19
|
|
20 <inputs>
|
|
21 <param format="txt" name="input" type="data" label="Sort Query" />
|
|
22
|
|
23 <param name="unique" type="select" label="Output only unique values?">
|
|
24 <option value="">No</option>
|
|
25 <option value="-u">Yes</option>
|
|
26 </param>
|
|
27
|
|
28 <repeat name="sortkeys" title="sort key">
|
|
29 <param name="column" label="on column" type="data_column" data_ref="input" accept_default="true" />
|
|
30 <param name="order" type="select" display="radio" label="in">
|
|
31 <option value="r">Descending order</option>
|
|
32 <option value="">Ascending order</option>
|
|
33 </param>
|
|
34 <param name="style" type="select" display="radio" label="Flavor">
|
|
35 <option value="n">Fast numeric sort ([-n])</option>
|
|
36 <option value="g">General numeric sort ( scientific notation [-g])</option>
|
|
37 <option value="V">Natural/Version sort ([-V]) </option>
|
|
38 <option value="">Alphabetical sort</option>
|
|
39 </param>
|
|
40 </repeat>
|
|
41 </inputs>
|
|
42 <tests>
|
|
43 <test>
|
|
44 <!-- Sort Descending numerical order,
|
|
45 with scientific notation -->
|
|
46 <param name="input" value="unix_sort_input1.txt" />
|
|
47 <output name="output" file="unix_sort_output1.txt" />
|
|
48 <param name="unique" value="No" />
|
|
49 <param name="column" value="2" />
|
|
50 <param name="order" value="r" />
|
|
51 <param name="style" value="g" />
|
|
52 </test>
|
|
53 <test>
|
|
54 <!-- Sort Ascending numerical order,
|
|
55 with scientific notation - outputing unique values only
|
|
56
|
|
57 The catch:
|
|
58 chr15 appears twice, with the same value (0.0314 and 3.14e-2).
|
|
59 In the output, it should appear only once because of the unique flag
|
|
60 -->
|
|
61 <param name="input" value="unix_sort_input1.txt" />
|
|
62 <output name="output" file="unix_sort_output2.txt" />
|
|
63 <param name="unique" value="Yes" />
|
|
64 <param name="column" value="2" />
|
|
65 <param name="order" value="" />
|
|
66 <param name="style" value="g" />
|
|
67 </test>
|
|
68 <test>
|
|
69 <!-- Sort Ascending 'natural' order -->
|
|
70 <param name="input" value="unix_sort_input1.txt" />
|
|
71 <output name="output" file="unix_sort_output3.txt" />
|
|
72 <param name="unique" value="No" />
|
|
73 <param name="column" value="1" />
|
|
74 <param name="order" value="" />
|
|
75 <param name="style" value="V" />
|
|
76 </test>
|
|
77 </tests>
|
|
78 <outputs>
|
|
79 <data format="input" name="out_file1" metadata_source="input"/>
|
|
80 </outputs>
|
|
81 <help>
|
|
82
|
|
83 **What it does**
|
|
84
|
|
85 This tool runs the unix **sort** command on the selected data file.
|
|
86
|
|
87 -----
|
|
88
|
|
89 **Sorting Styles**
|
|
90
|
|
91 * **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).
|
|
92 * **General Numeric**: sort by numeric values. Handles all numeric notations (including scientific notation). Slower than *fast numeric*, so use only when necessary.
|
|
93 * **Natural Sort**: Sort in 'natural' order (natural to humans, not to computers). See example below.
|
|
94 * **Alphabetical sort**: Sort in strict alphabetical order. See example below.
|
|
95
|
|
96
|
|
97
|
|
98
|
|
99 **Sorting Examples**
|
|
100
|
|
101 Given the following list::
|
|
102
|
|
103 chr4
|
|
104 chr13
|
|
105 chr1
|
|
106 chr10
|
|
107 chr20
|
|
108 chr2
|
|
109
|
|
110 **Alphabetical sort** would produce the following sorted list::
|
|
111
|
|
112 chr1
|
|
113 chr10
|
|
114 chr13
|
|
115 chr2
|
|
116 chr20
|
|
117 chr4
|
|
118
|
|
119 **Natural Sort** would produce the following sorted list::
|
|
120
|
|
121 chr1
|
|
122 chr2
|
|
123 chr4
|
|
124 chr10
|
|
125 chr13
|
|
126 chr20
|
|
127
|
|
128
|
|
129 .. class:: infomark
|
|
130
|
|
131 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.
|
|
132
|
|
133 </help>
|
|
134 </tool>
|