Mercurial > repos > bgruening > text_processing
annotate sort.xml @ 8:fa7f88da29d7 draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 369e40078146d00608d52205bb8cee66ae735b76-dirty
author | bgruening |
---|---|
date | Tue, 30 Jun 2015 16:20:05 -0400 |
parents | d64eace4f9f3 |
children | c78b1767db2b |
rev | line source |
---|---|
4 | 1 <tool id="tp_sort_header_tool" name="Sort" version="@BASE_VERSION@.0"> |
1 | 2 <description>data in ascending or descending order</description> |
4 | 3 <macros> |
4 <import>macros.xml</import> | |
5 </macros> | |
6 <expand macro="requirements"> | |
0 | 7 <requirement type="package" version="4.2.2-sandbox">gnu_sed</requirement> |
4 | 8 </expand> |
9 <version_command>sort --version | head -n 1</version_command> | |
10 <command> | |
11 <![CDATA[ | |
12 ( | |
6 | 13 LC_ALL=C |
4 | 14 #if int($header) > 0: |
7 | 15 sed -u '${header}'q && |
4 | 16 #end if |
0 | 17 |
4 | 18 sort $unique $ignore_case --stable -t ' ' |
0 | 19 |
4 | 20 #for $key in $sortkeys: |
21 -k '${key.column}${key.order}${key.style},${key.column}' | |
22 #end for | |
0 | 23 |
4 | 24 ) < '${infile}' > '${outfile}' |
25 ]]> | |
0 | 26 </command> |
27 <inputs> | |
4 | 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."> | |
0 | 31 <validator type="in_range" message="Negative values are not allowed." min="0"/> |
32 </param> | |
33 | |
1 | 34 <repeat name="sortkeys" title="Column selections" min="1"> |
0 | 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"> | |
4 | 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> | |
0 | 44 <option value="">Alphabetical sort</option> |
45 <option value="h">Human-readable numbers (-h)</option> | |
4 | 46 <option value="R">Random order (-R)</option> |
0 | 47 </param> |
48 </repeat> | |
1 | 49 |
50 <param name="unique" type="boolean" checked="false" truevalue="--unique" falsevalue="" | |
4 | 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)" /> | |
0 | 54 </inputs> |
55 <outputs> | |
6 | 56 <data name="outfile" format_source="infile" metadata_source="infile"/> |
0 | 57 </outputs> |
1 | 58 <tests> |
59 <test> | |
6 | 60 <param name="infile" value="sort1.bed"/> |
4 | 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"/> | |
1 | 73 </test> |
74 <test> | |
6 | 75 <param name="infile" value="sort1.bed"/> |
4 | 76 <param name="header" value="3"/> |
77 <repeat name="sortkeys"> | |
78 <param name="column" value="1"/> | |
79 <param name="style" value=""/> | |
8
fa7f88da29d7
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 369e40078146d00608d52205bb8cee66ae735b76-dirty
bgruening
parents:
7
diff
changeset
|
80 <param name="order" value=""/> |
4 | 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"/> | |
1 | 88 </test> |
89 <test> | |
6 | 90 <param name="infile" value="sort2.bed"/> |
4 | 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"/> | |
1 | 97 </test> |
98 </tests> | |
0 | 99 <help> |
4 | 100 <![CDATA[ |
0 | 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 | |
4 | 173 @REFERENCES@ |
174 ]]> | |
0 | 175 </help> |
176 </tool> |