PageRenderTime 39ms CodeModel.GetById 25ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/tools/filters/sorter.xml

https://bitbucket.org/cistrome/cistrome-harvard/
XML | 188 lines | 160 code | 28 blank | 0 comment | 0 complexity | ac85880aac664e6a7a2a50b9e4479db7 MD5 | raw file
  1<tool id="sort1" name="Sort" version="1.0.3">
  2    <description>data in ascending or descending order</description>
  3    <command interpreter="python">
  4        sorter.py
  5        
  6        --input=${input}
  7        --output=${out_file1}
  8        
  9        #if (str($style) == 'num'):
 10            #set $style = 'n'
 11        #elif (str($style) == 'gennum'):
 12            #set $style = 'g'
 13        #else:
 14            #set $style = ''
 15        #end if
 16
 17        #set $order = '' if (str($order) == 'ASC') else 'r'
 18        
 19        --key=${column},${column}${style}${order}
 20        
 21        
 22        #for $col in $column_set:
 23            #set $other_column = str($col.other_column)
 24            
 25            #if (str($col.other_style) == 'num'):
 26                #set $other_style = 'n'
 27            #elif (str($col.other_style) == 'gennum'):
 28                #set $other_style = 'g'
 29            #else:
 30                #set $other_style = ''
 31            #end if
 32            
 33            #set $other_order = '' if (str($col.other_order) == "ASC") else 'r'
 34            --key=${other_column},${other_column}${other_style}${other_order}
 35        #end for
 36    </command>
 37    <inputs>
 38        <param format="tabular" name="input" type="data" label="Sort Dataset" />
 39        <param name="column" label="on column" type="data_column" data_ref="input" accept_default="true"/>
 40        <param name="style" type="select" label="with flavor">
 41            <option value="num">Numerical sort</option>
 42            <option value="gennum">General numeric sort</option>
 43            <option value="alpha">Alphabetical sort</option>
 44        </param>
 45        <param name="order" type="select" label="everything in">
 46            <option value="DESC">Descending order</option>
 47            <option value="ASC">Ascending order</option>
 48        </param>
 49        <repeat name="column_set" title="Column selection">
 50            <param name="other_column" label="on column" type="data_column" data_ref="input" accept_default="true" />
 51            <param name="other_style" type="select" label="with flavor">
 52                <option value="num">Numerical sort</option>
 53                <option value="gennum">General numeric sort</option>
 54                <option value="alpha">Alphabetical sort</option>
 55            </param>
 56            <param name="other_order" type="select" label="everything in">
 57                <option value="DESC">Descending order</option>
 58                <option value="ASC">Ascending order</option>
 59            </param>
 60        </repeat>
 61    </inputs>
 62    <outputs>
 63        <data format="input" name="out_file1" metadata_source="input"/>
 64    </outputs>
 65    <tests>
 66        <test>
 67            <param name="input" value="sort_in1.bed"/>
 68            <param name="column" value="1"/>
 69            <param name="style" value="alpha"/>
 70            <param name="order" value="ASC"/>
 71            <param name="other_column" value="3"/>
 72            <param name="other_style" value="num"/>
 73            <param name="other_order" value="DESC"/>
 74            <output name="out_file1" file="sort_out1.bed"/>
 75        </test>
 76        <test>
 77            <param name="input" value="sort_in1.bed"/>
 78            <param name="column" value="1"/>
 79            <param name="style" value="alpha"/>
 80            <param name="order" value="ASC"/>
 81            <param name="other_column" value="3"/>
 82            <param name="other_style" value="num"/>
 83            <param name="other_order" value="ASC"/>
 84            <output name="out_file1" file="sort_out2.bed"/>
 85        </test>
 86        <test>
 87            <param name="input" value="sort_in2.bed"/>
 88            <param name="column" value="5"/>
 89            <param name="style" value="gennum"/>
 90            <param name="order" value="ASC"/>
 91            <output name="out_file1" file="sort_out3.bed"/>
 92        </test>
 93    </tests>
 94    <help>
 95.. class:: infomark
 96        
 97**TIP:** If your data is not TAB delimited, use *Text Manipulation-&gt;Convert*
 98        
 99-----
100
101**Syntax**
102
103This tool sorts the dataset on any number of columns in either ascending or descending order.
104
105* **Numerical sort** orders numbers by their magnitude, ignores all characters besides numbers, and evaluates a string of numbers to the value they signify.
106* **General numeric sort** orders numbers by their general numerical value. Unlike the numerical sort option, it can handle numbers in scientific notation too.
107* **Alphabetical sort** is a phonebook type sort based on the conventional order of letters in an alphabet. Each nth letter is compared with the nth letter of other words in the list, starting at the first letter of each word and advancing to the second, third, fourth, and so on, until the order is established. Therefore, in an alphabetical sort, 2 comes after 100 (1 &lt; 2).
108        
109-----
110
111**Examples**
112
113The list of numbers 4,17,3,5 collates to 3,4,5,17 by numerical sorting, while it collates to 17,3,4,5 by alphabetical sorting.
114
115Sorting the following::
116
117    Q     d    7   II    jhu  45
118    A     kk   4   I     h    111
119    Pd    p    1   ktY   WS   113
120    A     g    10  H     ZZ   856
121    A     edf  4   tw    b    234
122    BBB   rt   10  H     ZZ   100
123    A     rew  10  d     b    1111
124    C     sd   19  YH    aa   10
125    Hah   c    23  ver   bb   467
126    MN    gtr  1   a     X    32
127    N     j    9   a     T    205
128    BBB   rrf  10  b     Z    134
129    odfr  ws   6   Weg   dew  201
130    C     f    3   WW    SW   34
131    A     jhg  4   I     b    345
132    Pd    gf   7   Gthe  de   567
133    rS    hty  90  YY    LOp  89
134    A     g    10  H     h    43
135    A     g    4   I     h    500
136
137on columns 1 (alphabetical), 3 (numerical), and 6 (numerical) in ascending order will yield::
138
139    A     kk   4   I     h    111
140    A     edf  4   tw    b    234
141    A     jhg  4   I     b    345
142    A     g    4   I     h    500
143    A     g    10  H     h    43
144    A     g    10  H     ZZ   856
145    A     rew  10  d     b    1111
146    BBB   rt   10  H     ZZ   100
147    BBB   rrf  10  b     Z    134
148    C     f    3   WW    SW   34
149    C     sd   19  YH    aa   10
150    Hah   c    23  ver   bb   467
151    MN    gtr  1   a     X    32
152    N     j    9   a     T    205
153    odfr  ws   6   Weg   dew  201
154    Pd    p    1   ktY   WS   113
155    Pd    gf   7   Gthe  de   567
156    Q     d    7   II    jhu  45
157    rS    hty  90  YY    LOp  89
158
159
160Sorting the following::
161
162    chr10  100  200  feature1  100.01   +
163    chr20  800  900  feature2  1.1      +
164    chr2   500  600  feature3  1000.1   +
165    chr1   300  400  feature4  1.1e-05  +
166    chr21  300  500  feature5  1.1e2    +
167    chr15  700  800  feature6  1.1e4    +
168
169on column 5 (numerical) in ascending order will yield::
170
171    chr1   300  400  feature4  1.1e-05  +
172    chr15  700  800  feature6  1.1e4    +
173    chr20  800  900  feature2  1.1      +
174    chr21  300  500  feature5  1.1e2    +
175    chr10  100  200  feature1  100.01   +
176    chr2   500  600  feature3  1000.1   +
177
178on column 5 (general numeric) in ascending order will yield::
179
180    chr1   300  400  feature4  1.1e-05  +
181    chr20  800  900  feature2  1.1      +
182    chr10  100  200  feature1  100.01   +
183    chr21  300  500  feature5  1.1e2    +
184    chr2   500  600  feature3  1000.1   +
185    chr15  700  800  feature6  1.1e4    +
186
187    </help>
188</tool>