Mercurial > repos > iuc > table_compute
comparison table_compute.xml @ 2:02c3e335a695 draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/table_compute commit d00a518202228b990aeeea2ec3f842501fd2ec09"
author | iuc |
---|---|
date | Fri, 13 Sep 2019 14:54:41 -0400 |
parents | dddadbbac949 |
children | 60ff16842fcd |
comparison
equal
deleted
inserted
replaced
1:dddadbbac949 | 2:02c3e335a695 |
---|---|
1 <tool id="table_compute" name="Table Compute" version="@VERSION@"> | 1 <tool id="table_compute" name="Table Compute" version="@VERSION@"> |
2 <description>computes operations on table data</description> | 2 <description>computes operations on table data</description> |
3 <macros> | 3 <macros> |
4 <token name="@VERSION@">0.9.1</token> | 4 <token name="@VERSION@">0.9.2</token> |
5 <token name="@COPEN@"><![CDATA[<code>]]></token> | 5 <token name="@COPEN@"><![CDATA[<code>]]></token> |
6 <token name="@CCLOSE@"><![CDATA[</code>]]></token> | 6 <token name="@CCLOSE@"><![CDATA[</code>]]></token> |
7 <import>allowed_functions.xml</import> | 7 <import>allowed_functions.xml</import> |
8 <!-- text field validators --> | 8 <!-- text field validators --> |
9 <macro name="validator_text" > | 9 <macro name="validator_text" > |
21 <macro name="validator_index_ranges"> | 21 <macro name="validator_index_ranges"> |
22 <validator type="regex" message="Specify a comma-separated list index numbers or ranges">^(?:-?\d+(?::-?\d+)*(?:, *-?\d+(?::-?\d+)*)*)?$</validator> | 22 <validator type="regex" message="Specify a comma-separated list index numbers or ranges">^(?:-?\d+(?::-?\d+)*(?:, *-?\d+(?::-?\d+)*)*)?$</validator> |
23 <sanitizer sanitize="false" /> | 23 <sanitizer sanitize="false" /> |
24 </macro> | 24 </macro> |
25 <macro name="validator_functiondef"> | 25 <macro name="validator_functiondef"> |
26 <validator type="regex" message="An expression is required and is allowed to contain only letters, numbers and the characters '_ !-+=/*%.<>()'">^['"\w !\-+=/*%,.<>()]+$</validator> | 26 <validator type="regex" message="An expression is required and is allowed to contain only letters, numbers and the characters _ !-+=/*%.<>()">^[\w !\-+=/*%,.<>()]+$</validator> |
27 <sanitizer sanitize="false" /> | 27 <sanitizer sanitize="false" /> |
28 </macro> | 28 </macro> |
29 <!-- macro for main input tests --> | 29 <!-- macro for main input tests --> |
30 <macro name="test_inputs_single" > | 30 <macro name="test_inputs_single" > |
31 <conditional name="singtabop" > | 31 <conditional name="singtabop" > |
49 <!-- macro for umi to transcript tests --> | 49 <!-- macro for umi to transcript tests --> |
50 <macro name="umi2trans" > | 50 <macro name="umi2trans" > |
51 <yield /> | 51 <yield /> |
52 <conditional name="user" > | 52 <conditional name="user" > |
53 <param name="mode" value="element" /> | 53 <param name="mode" value="element" /> |
54 <param name="element_op" value="gt" /> | 54 <conditional name="elem_val"> |
55 <param name="element_value" value="0" /> | 55 <param name="element_op" value="None" /> |
56 </conditional> | |
56 <conditional name="element" > | 57 <conditional name="element" > |
57 <param name="mode" value="custom" /> | 58 <param name="mode" value="custom" /> |
58 <param name="custom_expr" value="-math.log(1 - elem/4096) * 4096 if elem != 4096 else elem - 0.5" /> | 59 <param name="custom_expr" value="-math.log(1 - elem/4096) * 4096 if elem != 4096 else elem - 0.5" /> |
59 </conditional> | 60 </conditional> |
60 </conditional> | 61 </conditional> |
131 "user_mode": '$singtabop.use_type', | 132 "user_mode": '$singtabop.use_type', |
132 "outtable": '$table' | 133 "outtable": '$table' |
133 } | 134 } |
134 | 135 |
135 #if str($singtabop.use_type) == "single": | 136 #if str($singtabop.use_type) == "single": |
137 #set $op_mode = str($singtabop.user.mode) | |
136 Data = { | 138 Data = { |
137 "tables": [ | 139 "tables": [ |
138 { | 140 { |
139 "file": '$singtabop.input', | 141 "file": '$singtabop.input', |
140 #if $singtabop.adv.header: | 142 #if $singtabop.adv.header: |
157 "nrows": None, | 159 "nrows": None, |
158 #end if | 160 #end if |
159 } | 161 } |
160 ], | 162 ], |
161 "params": { | 163 "params": { |
162 "user_mode_single": '$singtabop.user.mode.value', | 164 "user_mode_single": '$op_mode', |
163 #if $singtabop.user.mode.value == 'precision': | 165 #if $op_mode == 'precision': |
164 ## Literally do nothing, the user just sets the precision slider | 166 ## Literally do nothing, the user just sets the precision slider |
165 ## at the top default level | 167 ## at the top default level |
166 } | 168 } |
167 #elif $singtabop.user.mode.value == 'select': | 169 #elif $op_mode == 'select': |
168 "select_cols_unique": #echo 'select_cols_keepdupe' in str($singtabop.user.select_keepdupe)#, | 170 "select_cols_unique": #echo 'select_cols_keepdupe' in str($singtabop.user.select_keepdupe)#, |
169 "select_rows_unique": #echo 'select_rows_keepdupe' in str($singtabop.user.select_keepdupe)#, | 171 "select_rows_unique": #echo 'select_rows_keepdupe' in str($singtabop.user.select_keepdupe)#, |
170 #if $singtabop.user.select_cols_wanted: | 172 #if $singtabop.user.select_cols_wanted: |
171 "select_cols_wanted": '$singtabop.user.select_cols_wanted', | 173 "select_cols_wanted": '$singtabop.user.select_cols_wanted', |
172 #else | 174 #else |
176 "select_rows_wanted": '$singtabop.user.select_rows_wanted', | 178 "select_rows_wanted": '$singtabop.user.select_rows_wanted', |
177 #else | 179 #else |
178 "select_rows_wanted": None, | 180 "select_rows_wanted": None, |
179 #end if | 181 #end if |
180 } | 182 } |
181 #elif $singtabop.user.mode.value == 'filtersumval': | 183 #elif $op_mode == 'filtersumval': |
182 "filtersumval_mode": '$singtabop.user.filtersumval_mode.use.value', | 184 #set $filter_type = str($singtabop.user.filtersumval_mode.use) |
183 "filtersumval_axis": $singtabop.user.axis.value, | 185 "filtersumval_mode": '$filter_type', |
184 #if $singtabop.user.filtersumval_mode.use.value == 'operation': | 186 "filtersumval_axis": $singtabop.user.axis, |
185 "filtersumval_compare": '$singtabop.user.filtersumval_mode.compare_op.value', | 187 #if $filter_type == 'operation': |
186 "filtersumval_op": '$singtabop.user.filtersumval_mode.operation.value', | 188 "filtersumval_compare": '$singtabop.user.filtersumval_mode.compare_op', |
189 "filtersumval_op": '$singtabop.user.filtersumval_mode.operation', | |
187 "filtersumval_against": $singtabop.user.filtersumval_mode.against, | 190 "filtersumval_against": $singtabop.user.filtersumval_mode.against, |
188 "filtersumval_minmatch": None, | 191 "filtersumval_minmatch": None, |
189 #elif $singtabop.user.filtersumval_mode.use.value == 'element': | 192 #elif $filter_type == 'element': |
190 "filtersumval_compare": None, | 193 "filtersumval_compare": None, |
191 "filtersumval_op": '$singtabop.user.filtersumval_mode.operation.value', | 194 "filtersumval_op": '$singtabop.user.filtersumval_mode.operation', |
192 ## against could be string or float, so we parse this in the code | 195 ## against could be string or float, so we parse this in the code |
193 "filtersumval_against": '$singtabop.user.filtersumval_mode.against', | 196 "filtersumval_against": '$singtabop.user.filtersumval_mode.against', |
194 "filtersumval_minmatch": $singtabop.user.filtersumval_mode.minmatch, | 197 "filtersumval_minmatch": $singtabop.user.filtersumval_mode.minmatch, |
195 #end if | 198 #end if |
196 } | 199 } |
197 #elif $singtabop.user.mode.value == 'matrixapply': | 200 #elif $op_mode == 'matrixapply': |
198 "matrixapply_dimension": $singtabop.user.dimension.value, | 201 "matrixapply_dimension": $singtabop.user.dimension, |
199 #if str($singtabop.user.matrixapply_func.vector_op) == 'custom': | 202 #if str($singtabop.user.matrixapply_func.vector_op) == 'custom': |
200 #set $custom_func = str($singtabop.user.matrixapply_func.custom_func).strip() | 203 #set $custom_func = str($singtabop.user.matrixapply_func.custom_func).strip() |
201 "matrixapply_custom": True, | 204 "matrixapply_custom": True, |
202 "matrixapply_custom_func": '$custom_func', | 205 "matrixapply_custom_func": '$custom_func', |
203 "matrixapply_op": None, | 206 "matrixapply_op": None, |
205 "matrixapply_custom": False, | 208 "matrixapply_custom": False, |
206 "matrixapply_custom_func": None, | 209 "matrixapply_custom_func": None, |
207 "matrixapply_op": '$singtabop.user.matrixapply_func.vector_op', | 210 "matrixapply_op": '$singtabop.user.matrixapply_func.vector_op', |
208 #end if | 211 #end if |
209 } | 212 } |
210 #elif $singtabop.user.mode.value == 'element': | 213 #elif $op_mode == 'element': |
211 #if str($singtabop.user.elem_val.element_op) == "None": | 214 #set $filter_type = str($singtabop.user.elem_val.element_op) |
215 #set $element_mode = str($singtabop.user.element.mode) | |
216 #if $filter_type == "None": | |
212 "element_op": None, | 217 "element_op": None, |
213 #elif str($singtabop.user.elem_val.element_op) == "rowcol": | 218 #elif $filter_type == "rowcol": |
214 "element_op": "rowcol", | 219 "element_op": "rowcol", |
215 #if $singtabop.user.elem_val.select_rows_wanted | 220 #if $singtabop.user.elem_val.select_rows_wanted |
216 "element_rows": '$singtabop.user.elem_val.select_rows_wanted', | 221 "element_rows": '$singtabop.user.elem_val.select_rows_wanted', |
217 #end if | 222 #end if |
218 #if $singtabop.user.elem_val.select_cols_wanted | 223 #if $singtabop.user.elem_val.select_cols_wanted |
219 "element_cols": '$singtabop.user.elem_val.select_cols_wanted', | 224 "element_cols": '$singtabop.user.elem_val.select_cols_wanted', |
220 #end if | 225 #end if |
221 "element_inclusive": $singtabop.user.elem_val.inclusive_selection, | 226 "element_inclusive": $singtabop.user.elem_val.inclusive_selection, |
222 #else: | 227 #else: |
223 "element_op": '$singtabop.user.elem_val.element_op.value', | 228 "element_op": '$filter_type', |
224 ## Value is string or float, parsed in code later | 229 ## Value is string or float, parsed in code later |
225 "element_value" : '$singtabop.user.elem_val.element_value', | 230 "element_value" : '$singtabop.user.elem_val.element_value', |
226 #end if | 231 #end if |
227 "element_mode": '$singtabop.user.element.mode.value', | 232 "element_mode": '$element_mode', |
228 #if str($singtabop.user.element.mode) == "replace": | 233 #if $element_mode == "replace": |
229 "element_replace": '$singtabop.user.element.replace_value.value', | 234 "element_replace": '$singtabop.user.element.replace_value', |
230 #elif str($singtabop.user.element.mode) == "modify": | 235 #elif $element_mode == "modify": |
231 "element_modify_op": '$singtabop.user.element.modify_op.value', | 236 "element_modify_op": '$singtabop.user.element.modify_op', |
232 #elif str($singtabop.user.element.mode) == "scale": | 237 #elif $element_mode == "scale": |
233 "element_scale_op": '$singtabop.user.element.scale_op.value', | 238 "element_scale_op": '$singtabop.user.element.scale_op', |
234 "element_scale_value": $singtabop.user.element.scale_value, | 239 "element_scale_value": $singtabop.user.element.scale_value, |
235 #elif str($singtabop.user.element.mode) == "custom": | 240 #elif $element_mode == "custom": |
236 #set $custom_func = str($singtabop.user.element.custom_expr).strip() | 241 #set $custom_func = str($singtabop.user.element.custom_expr).strip() |
237 "element_customop": '$custom_func', | 242 "element_customop": '$custom_func', |
238 #end if | 243 #end if |
239 } | 244 } |
240 #elif $singtabop.user.mode.value == 'fulltable': | 245 #elif $op_mode == 'fulltable': |
241 "mode": '$singtabop.user.general.use', | 246 "mode": '$singtabop.user.general.use', |
242 #if str($singtabop.user.general.use) == 'melt': | 247 #if str($singtabop.user.general.use) == 'melt': |
243 #if str($singtabop.user.general.id_vars).strip(): | 248 #if str($singtabop.user.general.id_vars).strip(): |
244 #set $melt_ids = [i.strip() for i in str($singtabop.user.general.id_vars).split(',')] | 249 #set $melt_ids = [i.strip() for i in str($singtabop.user.general.id_vars).split(',')] |
245 #else | 250 #else |
271 "pivot_index": $pivot_index, | 276 "pivot_index": $pivot_index, |
272 "pivot_column": $pivot_column, | 277 "pivot_column": $pivot_column, |
273 "pivot_values": $pivot_values, | 278 "pivot_values": $pivot_values, |
274 }, | 279 }, |
275 #elif str($singtabop.user.general.use) == 'custom': | 280 #elif str($singtabop.user.general.use) == 'custom': |
276 #set $custom_func = str($singtabop.user.general.fulltable_custom_expr.value).strip() | 281 #set $custom_func = str($singtabop.user.general.fulltable_custom_expr).strip() |
277 "fulltable_customop": '$custom_func', | 282 "fulltable_customop": '$custom_func', |
278 | 283 |
279 #end if | 284 #end if |
280 }, | 285 }, |
281 #end if | 286 #end if |
282 } | 287 } |
283 | 288 |
284 #elif str($singtabop.use_type) == "multiple": | 289 #elif str($singtabop.use_type) == "multiple": |
285 #set $custom_func = str($singtabop.fulltable_custom_expr).strip() | 290 #set $custom_func = str($singtabop.fulltable_custom_expr).strip() |
286 Data = { | 291 Data = { |
287 "tables": [ | 292 "tables": [ |
288 #for $i, $s in enumerate($singtabop.tables) | 293 #for $i, $s in enumerate($singtabop.tables) |
289 { | 294 { |
290 "file": '${s.input}', | 295 "file": '${s.input}', |
422 </param> | 427 </param> |
423 </when> | 428 </when> |
424 <when value="fulltable"> | 429 <when value="fulltable"> |
425 <conditional name="general" > | 430 <conditional name="general" > |
426 <param name="use" type="select" label="Operation" help="See Examples 5, 7, and 8 for usage" > | 431 <param name="use" type="select" label="Operation" help="See Examples 5, 7, and 8 for usage" > |
427 <option value="melt" >Melt</option> | 432 <option value="transpose">Transpose</option> |
428 <option value="pivot" >Pivot</option> | 433 <option value="melt">Melt</option> |
429 <option value="custom" >Custom</option> | 434 <option value="pivot">Pivot</option> |
435 <option value="custom">Custom</option> | |
430 </param> | 436 </param> |
437 <when value="transpose" /> | |
431 <when value="melt" > | 438 <when value="melt" > |
432 <param name="id_vars" type="text" value="" label="Variable IDs" | 439 <param name="id_vars" type="text" value="" label="Variable IDs" |
433 help="Comma-delimited list of column names to use as identifiers" > | 440 help="Comma-delimited list of column names to use as identifiers" > |
434 <expand macro="validator_index_identifiers" /> | 441 <expand macro="validator_index_identifiers" /> |
435 </param> | 442 </param> |
472 <option value="modify">Transform</option> | 479 <option value="modify">Transform</option> |
473 <option value="scale">Arithmetic operation</option> | 480 <option value="scale">Arithmetic operation</option> |
474 <option value="custom">Custom</option> | 481 <option value="custom">Custom</option> |
475 </param> | 482 </param> |
476 <when value="replace" > | 483 <when value="replace" > |
477 <param name="replace_value" type="text" label="Replacement value" help="This value is converted to numeric if possible, otherwise it is treated as a string" /> | 484 <param name="replace_value" type="text" label="Replacement value" help="If you want to reuse the current value of each element as part of the replacement value, you can refer to it using the special @COPEN@{elem}@CCLOSE@ placeholder (see Example #9 in the Help section)."> |
485 <sanitizer> | |
486 <valid> | |
487 <add value="{" /> | |
488 <add value="}" /> | |
489 </valid> | |
490 </sanitizer> | |
491 </param> | |
478 </when> | 492 </when> |
479 <when value="modify" > | 493 <when value="modify" > |
480 <param name="modify_op" type="select" label="Transformation function" help="Example: to transform values to their square root, select @COPEN@Square Root@CCLOSE@ here."> | 494 <param name="modify_op" type="select" label="Transformation function" help="Example: to transform values to their square root, select @COPEN@Square Root@CCLOSE@ here."> |
481 <expand macro="select_onevalueoperator" /> | 495 <expand macro="select_onevalueoperator" /> |
482 </param> | 496 </param> |
818 <param name="fulltable_custom_expr" value="table + table[0,0]" /> | 832 <param name="fulltable_custom_expr" value="table + table[0,0]" /> |
819 </conditional> | 833 </conditional> |
820 </expand> | 834 </expand> |
821 </test> | 835 </test> |
822 <test expect_num_outputs="1"> | 836 <test expect_num_outputs="1"> |
823 <!-- Test 22: Melt --> | 837 <!-- Test 22: Transpose --> |
838 <expand macro="test_inputs_single" > | |
839 <param name="mode" value="fulltable" /> | |
840 <conditional name="general" > | |
841 <param name="use" value="transpose" /> | |
842 </conditional> | |
843 </expand> | |
844 <param name="out_opts" value="ignore_nas,output_headers_col" /> | |
845 <output name="table" > | |
846 <assert_contents> | |
847 <has_n_columns n="5" /> | |
848 </assert_contents> | |
849 </output> | |
850 </test> | |
851 <test expect_num_outputs="1"> | |
852 <!-- Test 23: Melt --> | |
824 <expand macro="test_inputs_single" > | 853 <expand macro="test_inputs_single" > |
825 <param name="mode" value="fulltable" /> | 854 <param name="mode" value="fulltable" /> |
826 <conditional name="general" > | 855 <conditional name="general" > |
827 <param name="use" value="melt" /> | 856 <param name="use" value="melt" /> |
828 <param name="id_vars" value="cell1,cell3" /> | 857 <param name="id_vars" value="cell1,cell3" /> |
837 <has_line_matching expression="^1\.0+\s0+\scell6\s6\.0+$" /> | 866 <has_line_matching expression="^1\.0+\s0+\scell6\s6\.0+$" /> |
838 </assert_contents> | 867 </assert_contents> |
839 </output> | 868 </output> |
840 </test> | 869 </test> |
841 <test expect_num_outputs="1"> | 870 <test expect_num_outputs="1"> |
842 <!-- Test 23: Pivot --> | 871 <!-- Test 24: Pivot --> |
843 <expand macro="test_inputs_single" > | 872 <expand macro="test_inputs_single" > |
844 <param name="mode" value="fulltable" /> | 873 <param name="mode" value="fulltable" /> |
845 <conditional name="general" > | 874 <conditional name="general" > |
846 <param name="use" value="pivot" /> | 875 <param name="use" value="pivot" /> |
847 <param name="index" value="cell1" /> | 876 <param name="index" value="cell1" /> |
858 </assert_contents> | 887 </assert_contents> |
859 </output> | 888 </output> |
860 </test> | 889 </test> |
861 <!-- Add Example Text Tests --> | 890 <!-- Add Example Text Tests --> |
862 <test expect_num_outputs="1" > | 891 <test expect_num_outputs="1" > |
863 <!-- Test 24: Ex 1 --> | 892 <!-- Test 25: Ex 1 --> |
864 <conditional name="singtabop" > | 893 <conditional name="singtabop" > |
865 <param name="use_type" value="single" /> | 894 <param name="use_type" value="single" /> |
866 <param name="input" value="examples.1.tsv" /> | 895 <param name="input" value="examples.1.tsv" /> |
867 <param name="col_row_names" value="has_col_names,has_row_names" /> | 896 <param name="col_row_names" value="has_col_names,has_row_names" /> |
868 <conditional name="user" > | 897 <conditional name="user" > |
879 <has_line_matching expression="^g2\s+3\s+3\s+9$" /> | 908 <has_line_matching expression="^g2\s+3\s+3\s+9$" /> |
880 </assert_contents> | 909 </assert_contents> |
881 </output> | 910 </output> |
882 </test> | 911 </test> |
883 <test expect_num_outputs="1" > | 912 <test expect_num_outputs="1" > |
884 <!-- Test 25: Ex 2 --> | 913 <!-- Test 26: Ex 2 --> |
885 <conditional name="singtabop" > | 914 <conditional name="singtabop" > |
886 <param name="use_type" value="single" /> | 915 <param name="use_type" value="single" /> |
887 <param name="input" value="examples.2.tsv" /> | 916 <param name="input" value="examples.2.tsv" /> |
888 <param name="col_row_names" value="has_col_names,has_row_names" /> | 917 <param name="col_row_names" value="has_col_names,has_row_names" /> |
889 <conditional name="user" > | 918 <conditional name="user" > |
904 <has_line_matching expression="^g3\s+4\s+8\s+12$" /> | 933 <has_line_matching expression="^g3\s+4\s+8\s+12$" /> |
905 </assert_contents> | 934 </assert_contents> |
906 </output> | 935 </output> |
907 </test> | 936 </test> |
908 <test expect_num_outputs="1" > | 937 <test expect_num_outputs="1" > |
909 <!-- Test 26: Ex 3_P1 --> | 938 <!-- Test 27: Ex 3_P1 --> |
910 <conditional name="singtabop" > | 939 <conditional name="singtabop" > |
911 <param name="use_type" value="single" /> | 940 <param name="use_type" value="single" /> |
912 <param name="input" value="examples.3p1.tsv" /> | 941 <param name="input" value="examples.3p1.tsv" /> |
913 <param name="col_row_names" value="has_col_names,has_row_names" /> | 942 <param name="col_row_names" value="has_col_names,has_row_names" /> |
914 <conditional name="user" > | 943 <conditional name="user" > |
929 <has_line_matching expression="^g4\s+False\s+True\s+True$" /> | 958 <has_line_matching expression="^g4\s+False\s+True\s+True$" /> |
930 </assert_contents> | 959 </assert_contents> |
931 </output> | 960 </output> |
932 </test> | 961 </test> |
933 <test expect_num_outputs="1" > | 962 <test expect_num_outputs="1" > |
934 <!-- Test 27: Ex 3_P2 --> | 963 <!-- Test 28: Ex 3_P2 --> |
935 <conditional name="singtabop" > | 964 <conditional name="singtabop" > |
936 <param name="use_type" value="single" /> | 965 <param name="use_type" value="single" /> |
937 <param name="input" value="examples.3p2.tsv" /> | 966 <param name="input" value="examples.3p2.tsv" /> |
938 <param name="col_row_names" value="has_col_names,has_row_names" /> | 967 <param name="col_row_names" value="has_col_names,has_row_names" /> |
939 <conditional name="user" > | 968 <conditional name="user" > |
951 <has_line_matching expression="^g4\s+2$" /> | 980 <has_line_matching expression="^g4\s+2$" /> |
952 </assert_contents> | 981 </assert_contents> |
953 </output> | 982 </output> |
954 </test> | 983 </test> |
955 <test expect_num_outputs="1" > | 984 <test expect_num_outputs="1" > |
956 <!-- Test 28: Ex 4 --> | 985 <!-- Test 29: Ex 4 --> |
957 <conditional name="singtabop" > | 986 <conditional name="singtabop" > |
958 <param name="use_type" value="single" /> | 987 <param name="use_type" value="single" /> |
959 <param name="input" value="examples.4.tsv" /> | 988 <param name="input" value="examples.4.tsv" /> |
960 <param name="col_row_names" value="has_col_names,has_row_names" /> | 989 <param name="col_row_names" value="has_col_names,has_row_names" /> |
961 <conditional name="user" > | 990 <conditional name="user" > |
976 <has_line_matching expression="^g4\s+0\.05\d+\s+1\.000\d+\s+1\.000\d+$" /> | 1005 <has_line_matching expression="^g4\s+0\.05\d+\s+1\.000\d+\s+1\.000\d+$" /> |
977 </assert_contents> | 1006 </assert_contents> |
978 </output> | 1007 </output> |
979 </test> | 1008 </test> |
980 <test expect_num_outputs="1" > | 1009 <test expect_num_outputs="1" > |
981 <!-- Test 29: Ex 5 --> | 1010 <!-- Test 30: Ex 5 --> |
982 <conditional name="singtabop" > | 1011 <conditional name="singtabop" > |
983 <param name="use_type" value="single" /> | 1012 <param name="use_type" value="single" /> |
984 <param name="input" value="examples.5.tsv" /> | 1013 <param name="input" value="examples.5.tsv" /> |
985 <param name="col_row_names" value="has_col_names,has_row_names" /> | 1014 <param name="col_row_names" value="has_col_names,has_row_names" /> |
986 <conditional name="user" > | 1015 <conditional name="user" > |
998 <has_line_matching expression="^g4\s+80\.\d+\s+7\.\d+\s+8\.\d+$" /> | 1027 <has_line_matching expression="^g4\s+80\.\d+\s+7\.\d+\s+8\.\d+$" /> |
999 </assert_contents> | 1028 </assert_contents> |
1000 </output> | 1029 </output> |
1001 </test> | 1030 </test> |
1002 <test expect_num_outputs="1" > | 1031 <test expect_num_outputs="1" > |
1003 <!-- Test 30: Ex 6 --> | 1032 <!-- Test 31: Ex 6 --> |
1004 <conditional name="singtabop" > | 1033 <conditional name="singtabop" > |
1005 <param name="use_type" value="multiple" /> | 1034 <param name="use_type" value="multiple" /> |
1006 <repeat name="tables" > | 1035 <repeat name="tables" > |
1007 <param name="input" value="examples.6p1.tsv" /> | 1036 <param name="input" value="examples.6p1.tsv" /> |
1008 <param name="col_row_names" value="has_col_names,has_row_names" /> | 1037 <param name="col_row_names" value="has_col_names,has_row_names" /> |
1024 <has_line_matching expression="^g3\s+1\.3\d+\s+2\.6\d+\s+3\.3\d+$" /> | 1053 <has_line_matching expression="^g3\s+1\.3\d+\s+2\.6\d+\s+3\.3\d+$" /> |
1025 </assert_contents> | 1054 </assert_contents> |
1026 </output> | 1055 </output> |
1027 </test> | 1056 </test> |
1028 <test expect_num_outputs="1" > | 1057 <test expect_num_outputs="1" > |
1029 <!-- Test 31: Ex 7 --> | 1058 <!-- Test 32: Ex 7 --> |
1030 <conditional name="singtabop" > | 1059 <conditional name="singtabop" > |
1031 <param name="use_type" value="single" /> | 1060 <param name="use_type" value="single" /> |
1032 <param name="input" value="examples.7.tsv" /> | 1061 <param name="input" value="examples.7.tsv" /> |
1033 <param name="col_row_names" value="has_col_names,has_row_names" /> | 1062 <param name="col_row_names" value="has_col_names,has_row_names" /> |
1034 <conditional name="user"> | 1063 <conditional name="user"> |
1047 <has_line_matching expression="^5\s+c\s+C\s+5\s*$" /> | 1076 <has_line_matching expression="^5\s+c\s+C\s+5\s*$" /> |
1048 </assert_contents> | 1077 </assert_contents> |
1049 </output> | 1078 </output> |
1050 </test> | 1079 </test> |
1051 <test expect_num_outputs="1" > | 1080 <test expect_num_outputs="1" > |
1052 <!-- Test 32: Ex 8 --> | 1081 <!-- Test 33: Ex 8 --> |
1053 <conditional name="singtabop" > | 1082 <conditional name="singtabop" > |
1054 <param name="use_type" value="single" /> | 1083 <param name="use_type" value="single" /> |
1055 <param name="input" value="examples.8.tsv" /> | 1084 <param name="input" value="examples.8.tsv" /> |
1056 <param name="col_row_names" value="has_col_names,has_row_names" /> | 1085 <param name="col_row_names" value="has_col_names,has_row_names" /> |
1057 <conditional name="user" > | 1086 <conditional name="user" > |
1071 <has_line_matching expression="^two\s+4\s+5\s+6$" /> | 1100 <has_line_matching expression="^two\s+4\s+5\s+6$" /> |
1072 </assert_contents> | 1101 </assert_contents> |
1073 </output> | 1102 </output> |
1074 </test> | 1103 </test> |
1075 <test expect_num_outputs="1" > | 1104 <test expect_num_outputs="1" > |
1076 <!-- Test 33: Subtracting table means #1 --> | 1105 <!-- Test 34: Negative range test #1 --> |
1077 <conditional name="singtabop" > | |
1078 <param name="use_type" value="single" /> | |
1079 <param name="input" value="examples.5.tsv" /> | |
1080 <param name="col_row_names" value="has_col_names,has_row_names" /> | |
1081 <conditional name="user" > | |
1082 <param name="mode" value="fulltable" /> | |
1083 <conditional name="general" > | |
1084 <param name="use" value="custom" /> | |
1085 <param name="fulltable_custom_expr" value="table - table.mean(1)/table.std(1)" /> | |
1086 </conditional> | |
1087 </conditional> | |
1088 </conditional> | |
1089 <output name="table" > | |
1090 <assert_contents> | |
1091 <has_n_columns n="8" /> | |
1092 <!-- should give nonsense empty output --> | |
1093 <has_line_matching expression="^\sc1\sc2\sc3\sg1\sg2\sg3\sg4$" /> | |
1094 <has_line_matching expression="^g4\s+$" /> | |
1095 </assert_contents> | |
1096 </output> | |
1097 </test> | |
1098 <test expect_num_outputs="1" > | |
1099 <!-- Test 34: Subtracting table means #2 --> | |
1100 <conditional name="singtabop" > | |
1101 <param name="use_type" value="single" /> | |
1102 <param name="input" value="examples.5.tsv" /> | |
1103 <param name="col_row_names" value="has_col_names,has_row_names" /> | |
1104 <conditional name="user" > | |
1105 <param name="mode" value="fulltable" /> | |
1106 <conditional name="general" > | |
1107 <param name="use" value="custom" /> | |
1108 <param name="fulltable_custom_expr" value="table.sub(table.mean(1), 0).div(table.std(1),0)" /> | |
1109 </conditional> | |
1110 </conditional> | |
1111 </conditional> | |
1112 <output name="table" > | |
1113 <assert_contents> | |
1114 <has_n_columns n="4" /> | |
1115 <has_line_matching expression="^g1\s+-1\.\d+\s+0\.\d+\s+1\.\d+\s*$" /> | |
1116 <has_line_matching expression="^g4\s+1\.1\d+\s+-0\.5\d+\s+-0\.5\d+\s*$" /> | |
1117 </assert_contents> | |
1118 </output> | |
1119 </test> | |
1120 <test expect_num_outputs="1" > | |
1121 <!-- Test 35: Subtracting table means #3 --> | |
1122 <conditional name="singtabop" > | |
1123 <param name="use_type" value="single" /> | |
1124 <param name="input" value="examples.5.tsv" /> | |
1125 <param name="col_row_names" value="has_col_names,has_row_names" /> | |
1126 <conditional name="user" > | |
1127 <param name="mode" value="fulltable" /> | |
1128 <conditional name="general" > | |
1129 <param name="use" value="custom" /> | |
1130 <param name="fulltable_custom_expr" value="(table.T - table.mean(1)).T" /> | |
1131 </conditional> | |
1132 </conditional> | |
1133 </conditional> | |
1134 <output name="table" > | |
1135 <assert_contents> | |
1136 <has_n_columns n="4" /> | |
1137 <has_line_matching expression="^g1\s+-10\.\d+\s+0\.\d+\s+10\.\d+\s*$" /> | |
1138 <has_line_matching expression="^g4\s+47\.3\d+\s+-23\.6\d+\s+-23\.6\d+\s*$" /> | |
1139 </assert_contents> | |
1140 </output> | |
1141 </test> | |
1142 <test expect_num_outputs="1" > | |
1143 <!-- Test 36: Negative range test #1 --> | |
1144 <expand macro="test_inputs_ranges" > | 1106 <expand macro="test_inputs_ranges" > |
1145 <param name="select_cols_wanted" value="-2:2,1,-1" /> | 1107 <param name="select_cols_wanted" value="-2:2,1,-1" /> |
1146 <param name="select_rows_wanted" value="1,3:-3,1" /> | 1108 <param name="select_rows_wanted" value="1,3:-3,1" /> |
1147 </expand> | 1109 </expand> |
1148 <output name="table" > | 1110 <output name="table" > |
1152 <has_line_matching expression="^g1\s+20\s+30\s+10\s+20\s+10\s+30$" /> | 1114 <has_line_matching expression="^g1\s+20\s+30\s+10\s+20\s+10\s+30$" /> |
1153 </assert_contents> | 1115 </assert_contents> |
1154 </output> | 1116 </output> |
1155 </test> | 1117 </test> |
1156 <test expect_num_outputs="1" > | 1118 <test expect_num_outputs="1" > |
1157 <!-- Test 37: Negative range test #2 --> | 1119 <!-- Test 35: Negative range test #2 --> |
1158 <expand macro="test_inputs_ranges" > | 1120 <expand macro="test_inputs_ranges" > |
1159 <param name="select_cols_wanted" value="-1,-3,3:-3,2" /> | 1121 <param name="select_cols_wanted" value="-1,-3,3:-3,2" /> |
1160 <param name="select_rows_wanted" value="3:-1" /> | 1122 <param name="select_rows_wanted" value="3:-1" /> |
1161 <param name="select_keepdupe" value="" /> | 1123 <param name="select_keepdupe" value="" /> |
1162 </expand> | 1124 </expand> |
1167 <has_line_matching expression="^g4\s+3\s+81\s+3\s+6\s+81\s+6$" /> | 1129 <has_line_matching expression="^g4\s+3\s+81\s+3\s+6\s+81\s+6$" /> |
1168 </assert_contents> | 1130 </assert_contents> |
1169 </output> | 1131 </output> |
1170 </test> | 1132 </test> |
1171 <test expect_num_outputs="1"> | 1133 <test expect_num_outputs="1"> |
1172 <!-- Test 38: Skip first 3 lines --> | 1134 <!-- Test 36: Skip first 3 lines --> |
1173 <conditional name="singtabop" > | 1135 <conditional name="singtabop" > |
1174 <param name="use_type" value="single" /> | 1136 <param name="use_type" value="single" /> |
1175 <param name="input" value="skiplines.tsv" /> | 1137 <param name="input" value="skiplines.tsv" /> |
1176 <section name="adv" > | 1138 <section name="adv" > |
1177 <param name="header" value="2" /> | 1139 <param name="header" value="2" /> |
1190 <has_line_matching expression="^g4\s+81\s+6\s+3$" /> | 1152 <has_line_matching expression="^g4\s+81\s+6\s+3$" /> |
1191 </assert_contents> | 1153 </assert_contents> |
1192 </output> | 1154 </output> |
1193 </test> | 1155 </test> |
1194 <test expect_num_outputs="1"> | 1156 <test expect_num_outputs="1"> |
1195 <!-- Test 39: Skip first 3 lines --> | 1157 <!-- Test 37: Skip first 3 lines --> |
1196 <conditional name="singtabop" > | 1158 <conditional name="singtabop" > |
1197 <param name="use_type" value="single" /> | 1159 <param name="use_type" value="single" /> |
1198 <param name="input" value="skiplines.tsv" /> | 1160 <param name="input" value="skiplines.tsv" /> |
1199 <section name="adv" > | 1161 <section name="adv" > |
1200 <param name="header" value="2" /> | 1162 <param name="header" value="2" /> |
1214 <has_line_matching expression="^\s+$" /> | 1176 <has_line_matching expression="^\s+$" /> |
1215 </assert_contents> | 1177 </assert_contents> |
1216 </output> | 1178 </output> |
1217 </test> | 1179 </test> |
1218 <test expect_num_outputs="1" > | 1180 <test expect_num_outputs="1" > |
1219 <!-- Test 40: Row Col custom op #1 --> | 1181 <!-- Test 38: Row Col replace with format spec #1 --> |
1220 <conditional name="singtabop" > | 1182 <conditional name="singtabop" > |
1221 <param name="use_type" value="single" /> | 1183 <param name="use_type" value="single" /> |
1222 <param name="input" value="examples.1.tsv" /> | 1184 <param name="input" value="examples.1.tsv" /> |
1223 <param name="col_row_names" value="has_col_names,has_row_names" /> | 1185 <param name="col_row_names" value="has_col_names,has_row_names" /> |
1224 <conditional name="user" > | 1186 <conditional name="user" > |
1225 <param name="mode" value="element" /> | 1187 <param name="mode" value="element" /> |
1226 <conditional name="element" > | 1188 <conditional name="element" > |
1227 <param name="mode" value="custom" /> | 1189 <param name="mode" value="replace" /> |
1228 <param name="custom_expr" value=""chr%.f" % elem" /> | 1190 <param name="replace_value" value="chr{elem:.0f}" /> |
1229 </conditional> | 1191 </conditional> |
1230 <conditional name="elem_val" > | 1192 <conditional name="elem_val" > |
1231 <param name="element_op" value="rowcol" /> | 1193 <param name="element_op" value="rowcol" /> |
1232 <param name="select_cols_wanted" value="2" /> | 1194 <param name="select_cols_wanted" value="2" /> |
1233 <param name="select_rows_wanted" value="2,4" /> | 1195 <param name="select_rows_wanted" value="2,4" /> |
1242 <has_line_matching expression="^g4\s+chr81\s+chr6\s+chr3$" /> | 1204 <has_line_matching expression="^g4\s+chr81\s+chr6\s+chr3$" /> |
1243 </assert_contents> | 1205 </assert_contents> |
1244 </output> | 1206 </output> |
1245 </test> | 1207 </test> |
1246 <test expect_num_outputs="1" > | 1208 <test expect_num_outputs="1" > |
1247 <!-- Test 41: Row Col custom op #2 --> | 1209 <!-- Test 39: Row Col replace with format spec #2 --> |
1248 <conditional name="singtabop" > | 1210 <conditional name="singtabop" > |
1249 <param name="use_type" value="single" /> | 1211 <param name="use_type" value="single" /> |
1250 <param name="input" value="examples.1.tsv" /> | 1212 <param name="input" value="examples.1.tsv" /> |
1251 <param name="col_row_names" value="has_col_names,has_row_names" /> | 1213 <param name="col_row_names" value="has_col_names,has_row_names" /> |
1252 <conditional name="user" > | 1214 <conditional name="user" > |
1253 <param name="mode" value="element" /> | 1215 <param name="mode" value="element" /> |
1254 <conditional name="element" > | 1216 <conditional name="element" > |
1255 <param name="mode" value="custom" /> | 1217 <param name="mode" value="replace" /> |
1256 <param name="custom_expr" value=""chr%.f" % elem" /> | 1218 <param name="replace_value" value="chr{elem:.0f}" /> |
1257 </conditional> | 1219 </conditional> |
1258 <conditional name="elem_val" > | 1220 <conditional name="elem_val" > |
1259 <param name="element_op" value="rowcol" /> | 1221 <param name="element_op" value="rowcol" /> |
1260 <param name="select_cols_wanted" value="2" /> | 1222 <param name="select_cols_wanted" value="2" /> |
1261 <param name="select_rows_wanted" value="2,4" /> | 1223 <param name="select_rows_wanted" value="2,4" /> |
1269 <has_line_matching expression="^g2\s+3\s+chr6\s+9$" /> | 1231 <has_line_matching expression="^g2\s+3\s+chr6\s+9$" /> |
1270 <has_line_matching expression="^g4\s+81\s+chr6\s+3$" /> | 1232 <has_line_matching expression="^g4\s+81\s+chr6\s+3$" /> |
1271 </assert_contents> | 1233 </assert_contents> |
1272 </output> | 1234 </output> |
1273 </test> | 1235 </test> |
1236 <test expect_num_outputs="1"> | |
1237 <!-- Test 40: Test safety of Replacement value free text | |
1238 Tries to escape/reenter config file quoting. | |
1239 If the test fails, this shows that Python has performed | |
1240 string concatenation upon importing the config file. --> | |
1241 <conditional name="singtabop" > | |
1242 <param name="use_type" value="single" /> | |
1243 <param name="input" value="examples.1.tsv" /> | |
1244 <param name="col_row_names" value="has_col_names,has_row_names" /> | |
1245 <conditional name="user" > | |
1246 <param name="mode" value="element" /> | |
1247 <conditional name="elem_val"> | |
1248 <param name="element_op" value="None" /> | |
1249 </conditional> | |
1250 <conditional name="element" > | |
1251 <param name="mode" value="replace" /> | |
1252 <param name="scale_op" value="mod" /> | |
1253 <param name="replace_value" value="a'+'b" /> | |
1254 </conditional> | |
1255 </conditional> | |
1256 </conditional> | |
1257 <output name="table" > | |
1258 <assert_contents> | |
1259 <has_n_columns n="4" /> | |
1260 <not_has_text text="g1	ab" /> | |
1261 <not_has_text text="g2	ab" /> | |
1262 <not_has_text text="g3	ab" /> | |
1263 <not_has_text text="g4	ab" /> | |
1264 </assert_contents> | |
1265 </output> | |
1266 </test> | |
1267 <test expect_num_outputs="1" expect_failure="true"> | |
1268 <!-- Test 41: Test safety of custom expression free text | |
1269 Tries to escape/reenter config file quoting. | |
1270 | |
1271 This test is expected to fail if either | |
1272 - a validator disallows the use of single quotes or | |
1273 - the single quotes get sanitized (which is unlikely to result in a | |
1274 valid expression); note that in this situation, it cannot be | |
1275 guaranteed that the single quote sanitization is safe with | |
1276 *every* input | |
1277 | |
1278 If the test succeeds unexpectedly, this shows that Python | |
1279 has performed string concatenation upon importing the config file | |
1280 resulting in each element of the test table being retained. | |
1281 --> | |
1282 <conditional name="singtabop" > | |
1283 <param name="use_type" value="single" /> | |
1284 <param name="input" value="examples.4.tsv" /> | |
1285 <param name="col_row_names" value="has_col_names,has_row_names" /> | |
1286 <conditional name="user" > | |
1287 <param name="mode" value="element" /> | |
1288 <conditional name="element" > | |
1289 <param name="mode" value="custom" /> | |
1290 <param name="custom_expr" value="el'+'em" /> | |
1291 </conditional> | |
1292 <conditional name="elem_val" > | |
1293 <param name="element_op" value="All" /> | |
1294 </conditional> | |
1295 </conditional> | |
1296 </conditional> | |
1297 </test> | |
1274 </tests> | 1298 </tests> |
1275 <help><![CDATA[ | 1299 <help><![CDATA[ |
1276 This tool computes table expressions on the element, row, and column basis. It can sub-select, | 1300 This tool computes table expressions on the element, row, and column basis. It can sub-select, |
1277 duplicate, as well as perform general and custom expressions on rows, columns or elements. | 1301 duplicate, as well as perform general and custom expressions on rows, columns or elements. |
1278 | 1302 |
1279 Only a single operation can be performed on the data. Multiple operations can be performed by | 1303 .. class:: infomark |
1280 chaining successive runs of this tool. This is to provide a more transparent workflow for complex operations. | 1304 |
1305 Only a single operation can be performed on the data. Multiple operations | |
1306 can be performed by chaining successive runs of this tool. This is to | |
1307 provide a more transparent workflow for complex operations. | |
1281 | 1308 |
1282 | 1309 |
1283 | 1310 |
1284 Examples | 1311 Examples |
1285 ======== | 1312 ======== |
1579 limitations of the tool. Nested attributes like `table2.values.max` are | 1606 limitations of the tool. Nested attributes like `table2.values.max` are |
1580 disallowed in expressions in the tool so the above would have to be replaced | 1607 disallowed in expressions in the tool so the above would have to be replaced |
1581 with the harder to read workaround:: | 1608 with the harder to read workaround:: |
1582 | 1609 |
1583 table1 / min(np.max(np.max(table2)), np.max(np.max(table3))) | 1610 table1 / min(np.max(np.max(table2)), np.max(np.max(table3))) |
1611 | |
1612 .. class:: infomark | |
1613 | |
1614 Complex operations (like ones that would benefit from specifying nested | |
1615 attributes) can often be broken into subsequent runs ot the tool, in | |
1616 which the first run generates an intermediate table representing the result | |
1617 of the "inner" operation that the second run can then use as input to | |
1618 perform the "outer" operation. | |
1584 | 1619 |
1585 Also note that, currently `min()`, `max()` and `sum()` are the only built-in | 1620 Also note that, currently `min()`, `max()` and `sum()` are the only built-in |
1586 Python functions that can be used inside expressions. If you want to use | 1621 Python functions that can be used inside expressions. If you want to use |
1587 additional functions, these have to be qualified functions from the `math`, | 1622 additional functions, these have to be qualified functions from the `math`, |
1588 `np` or `pd` libraries. | 1623 `np` or `pd` libraries. |
1700 * *Column names on first row?* → **Yes** | 1735 * *Column names on first row?* → **Yes** |
1701 * *Row names on first column?* → **Yes** | 1736 * *Row names on first column?* → **Yes** |
1702 | 1737 |
1703 * *Type of table operation* → **Manipulate selected table elements** | 1738 * *Type of table operation* → **Manipulate selected table elements** |
1704 | 1739 |
1705 * *Operation to perform* → **Custom** | 1740 * *Operation to perform* → **Replace values** |
1706 | 1741 |
1707 * *Custom Expression* → :: | 1742 * *Replacement value* → :: |
1708 | 1743 |
1709 "chr%.f" % elem | 1744 chr{elem:.0f} |
1745 | |
1746 Here, the placeholder ``{elem}`` lets us refer to each element's | |
1747 current value, while the ``:.0f`` part is a format specifier that makes | |
1748 sure numbers are printed without decimals (for a complete description of | |
1749 the available syntax see the | |
1750 `Python Format Specification Mini-Language <https://docs.python.org/3/library/string.html#formatspec>`_). | |
1710 | 1751 |
1711 * *Operate on elements* → **Specific Rows and/or Columns** | 1752 * *Operate on elements* → **Specific Rows and/or Columns** |
1712 * *List of columns to select* → "2" | 1753 * *List of columns to select* → "2" |
1713 * *List of rows to select* → "2,4" | 1754 * *List of rows to select* → "2,4" |
1714 * *Inclusive Selection* → "No" | 1755 * *Inclusive Selection* → "No" |