comparison sort.xml @ 4:56e80527c482 draft

Uploaded
author bgruening
date Wed, 07 Jan 2015 11:10:52 -0500
parents 7068d1548234
children 8928e6d1e7ba
comparison
equal deleted inserted replaced
3:7068d1548234 4:56e80527c482
1 <tool id="tp_sort_header_tool" name="Sort" version="0.1.1"> 1 <tool id="tp_sort_header_tool" name="Sort" version="@BASE_VERSION@.0">
2 <description>data in ascending or descending order</description> 2 <description>data in ascending or descending order</description>
3 <requirements> 3 <macros>
4 <requirement type="package" version="8.21">gnu_coreutils</requirement> 4 <import>macros.xml</import>
5 </macros>
6 <expand macro="requirements">
5 <requirement type="package" version="4.2.2-sandbox">gnu_sed</requirement> 7 <requirement type="package" version="4.2.2-sandbox">gnu_sed</requirement>
6 </requirements> 8 </expand>
7 <command interpreter="sh"> 9 <version_command>sort --version | head -n 1</version_command>
8 #if int($header) > 0: 10 <command>
9 (sed -u '${header}'q &amp;&amp; sort $unique $ignore_case --stable -t ' ' 11 <![CDATA[
12 (
13 #if int($header) > 0:
14 sed -u '${header}'q &&
15 #end if
10 16
11 #for $key in $sortkeys 17 sort $unique $ignore_case --stable -t ' '
12 '-k ${key.column}${key.order}${key.style},${key.column}'
13 #end for
14 18
15 ) &lt; '${infile}' &gt; '${outfile}' 19 #for $key in $sortkeys:
16 #else: 20 -k '${key.column}${key.order}${key.style},${key.column}'
17 (sort $unique $ignore_case --stable -t ' ' 21 #end for
18 22
19 #for $key in $sortkeys 23 ) < '${infile}' > '${outfile}'
20 '-k ${key.column}${key.order}${key.style},${key.column}' 24 ]]>
21 #end for
22
23 ) &lt; '${infile}' &gt; '${outfile}'
24 #end if
25 </command> 25 </command>
26
27 <inputs> 26 <inputs>
28 <param format="txt" name="infile" type="data" label="Sort Query" /> 27 <param format="tabular" name="infile" type="data" label="Sort Query" />
29 <param name="header" type="integer" size="5" value="0" label="Number of header lines" help="These will be ignored during sort."> 28 <param name="header" type="integer" size="5" value="0"
29 label="Number of header lines" help="These will be ignored during sort.">
30 <validator type="in_range" message="Negative values are not allowed." min="0"/> 30 <validator type="in_range" message="Negative values are not allowed." min="0"/>
31 </param> 31 </param>
32 32
33 <repeat name="sortkeys" title="Column selections" min="1"> 33 <repeat name="sortkeys" title="Column selections" min="1">
34 <param name="column" label="on column" type="data_column" data_ref="infile" accept_default="true" /> 34 <param name="column" label="on column" type="data_column" data_ref="infile" accept_default="true" />
35 <param name="order" type="select" display="radio" label="in"> 35 <param name="order" type="select" display="radio" label="in">
36 <option value="">Ascending order</option> 36 <option value="">Ascending order</option>
37 <option value="r">Descending order</option> 37 <option value="r">Descending order</option>
38 </param> 38 </param>
39 <param name="style" type="select" display="radio" label="Flavor"> 39 <param name="style" type="select" display="radio" label="Flavor">
40 <option value="n">Fast numeric sort ([-n])</option> 40 <option value="n">Fast numeric sort (-n)</option>
41 <option value="g">General numeric sort ( scientific notation [-g])</option> 41 <option value="g">General numeric sort ( scientific notation -g)</option>
42 <option value="V">Natural/Version sort ([-V]) </option> 42 <option value="V">Natural/Version sort (-V) </option>
43 <option value="">Alphabetical sort</option> 43 <option value="">Alphabetical sort</option>
44 <option value="h">Human-readable numbers (-h)</option> 44 <option value="h">Human-readable numbers (-h)</option>
45 <option value="R">Random order</option> 45 <option value="R">Random order (-R)</option>
46 </param> 46 </param>
47 </repeat> 47 </repeat>
48 48
49 <param name="unique" type="boolean" checked="false" truevalue="--unique" falsevalue="" 49 <param name="unique" type="boolean" checked="false" truevalue="--unique" falsevalue=""
50 label="Output unique values" help="Print only unique values (based on sorted key columns. See help section for details." /> 50 label="Output unique values" help="Print only unique values, based on sorted key columns. See help section for details. (--unique)" />
51 51 <param name="ignore_case" type="boolean" checked="false" truevalue="-i" falsevalue=""
52 <param name="ignore_case" type="boolean" checked="false" truevalue="-i" falsevalue="" label="Ignore case" help="Sort and Join key column values regardless of upper/lower case letters." /> 52 label="Ignore case" help="Sort and Join key column values regardless of upper/lower case letters. (-i)" />
53 53
54 </inputs> 54 </inputs>
55 <outputs> 55 <outputs>
56 <data format="input" name="outfile" metadata_source="infile"/> 56 <data format="input" name="outfile" metadata_source="infile"/>
57 </outputs> 57 </outputs>
58 <tests> 58 <tests>
59 <!-- anyone knows how to write tests with repeat tags -->
60 <test> 59 <test>
61 <param name="infile" value="sort_in1.bed"/> 60 <param name="infile" value="sort_in1.bed"/>
62 <param name="column" value="1"/> 61 <param name="header" value="3"/>
63 <param name="style" value=""/> 62 <repeat name="sortkeys">
64 <param name="order" value="ASC"/> 63 <param name="column" value="1"/>
65 <param name="other_column" value="3"/> 64 <param name="style" value=""/>
66 <param name="other_style" value="n"/> 65 <param name="order" value=""/>
67 <param name="other_order" value="r"/> 66 </repeat>
68 <output name="out_file1" file="sort_out1.bed"/> 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"/>
69 </test> 73 </test>
70 <test> 74 <test>
71 <param name="infile" value="sort_in1.bed"/> 75 <param name="infile" value="sort_in1.bed"/>
72 <param name="column" value="1"/> 76 <param name="header" value="3"/>
73 <param name="style" value=""/> 77 <repeat name="sortkeys">
74 <param name="order" value="ASC"/> 78 <param name="column" value="1"/>
75 <param name="other_column" value="3"/> 79 <param name="style" value=""/>
76 <param name="other_style" value="n"/> 80 <param name="order" value=""/>
77 <param name="other_order" value=""/> 81 </repeat>
78 <output name="out_file1" file="sort_out2.bed"/> 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"/>
79 </test> 88 </test>
80 <test> 89 <test>
81 <param name="infile" value="sort_in2.bed"/> 90 <param name="infile" value="sort_in2.bed"/>
82 <param name="column" value="5"/> 91 <repeat name="sortkeys">
83 <param name="style" value="g"/> 92 <param name="column" value="5"/>
84 <param name="order" value=""/> 93 <param name="style" value="g"/>
85 <output name="out_file1" file="sort_out3.bed"/> 94 <param name="order" value=""/>
95 </repeat>
96 <output name="outfile" file="sort_result3.bed"/>
86 </test> 97 </test>
87 </tests> 98 </tests>
88 <help> 99 <help>
89 100 <![CDATA[
90 **What it does** 101 **What it does**
91 102
92 This tool sorts an input file. 103 This tool sorts an input file.
93 104
94 ----- 105 -----
157 168
158 .. class:: infomark 169 .. class:: infomark
159 170
160 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. 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.
161 172
162 ----- 173 @REFERENCES@
163 174 ]]>
164 *sort-header* is was written by A. Gordon ( gordon at cshl dot edu )
165
166 </help> 175 </help>
167 </tool> 176 </tool>