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