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