Mercurial > repos > iuc > calculate_numeric_param
comparison calculate_numeric_param.xml @ 0:0e586762f97b draft default tip
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_numeric_param commit b8635afd6cef6704f21f08caf4ffa89e672a96f8"
| author | iuc |
|---|---|
| date | Wed, 05 May 2021 15:03:08 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:0e586762f97b |
|---|---|
| 1 <tool name="Calculate numeric parameter value" id="calculate_numeric_param" version="0.1.0" profile="19.05" tool_type="expression"> | |
| 2 <description>from parameters</description> | |
| 3 <expression type="ecma5.1"> | |
| 4 { | |
| 5 let s = ""; | |
| 6 for (const repeat of $job.components) { | |
| 7 s += repeat.param_type.component_value | |
| 8 s += repeat.arith | |
| 9 if (repeat.arith == "") { | |
| 10 break; | |
| 11 } | |
| 12 }; | |
| 13 let e; | |
| 14 if ($job.output_type == "integer") { | |
| 15 e = parseInt(eval(s)); | |
| 16 } else { | |
| 17 e = eval(s); | |
| 18 } | |
| 19 return {'output': e}; | |
| 20 } | |
| 21 </expression> | |
| 22 <inputs> | |
| 23 <repeat name="components" min="2"> | |
| 24 <conditional name="param_type"> | |
| 25 <param name="select_param_type" type="select" label="Choose the type of parameter for this field"> | |
| 26 <option value="integer">Integer Parameter</option> | |
| 27 <option value="float">Float Parameter</option> | |
| 28 </param> | |
| 29 <when value="integer"> | |
| 30 <param name="component_value" value="" type="integer" label="Enter integer for calculating the parameter"/> | |
| 31 </when> | |
| 32 <when value="float"> | |
| 33 <param name="component_value" value="" type="float" label="Enter float for calculating the parameter"/> | |
| 34 </when> | |
| 35 </conditional> | |
| 36 <param name='arith' type='select' label='Choose the arithmetic operator to apply'> | |
| 37 <option value="+">Addition (+)</option> | |
| 38 <option value="-">Subtraction (-)</option> | |
| 39 <option value="*">Multiplication (*)</option> | |
| 40 <option value="/">Division (/)</option> | |
| 41 <option value="**">Exponentiation (**)</option> | |
| 42 <option value="%">Modulus (%)</option> | |
| 43 <option value="">None (expression should end here)</option> | |
| 44 </param> | |
| 45 </repeat> | |
| 46 <param name='output_type' type='select' label='Choose whether the output should be an integer or a float.'> | |
| 47 <option value="integer">Integer</option> | |
| 48 <option value="float">Float</option> | |
| 49 </param> | |
| 50 </inputs> | |
| 51 <outputs> | |
| 52 <output type="float" name="float_param" from="output"> | |
| 53 <filter>output_type == 'float'</filter> | |
| 54 </output> | |
| 55 <output type="integer" name="integer_param" from="output"> | |
| 56 <filter>output_type == 'integer'</filter> | |
| 57 </output> | |
| 58 </outputs> | |
| 59 <tests> | |
| 60 <test> | |
| 61 <repeat name="components"> | |
| 62 <conditional name="param_type"> | |
| 63 <param name="select_param_type" value="integer"/> | |
| 64 <param name="component_value" value="1"/> | |
| 65 </conditional> | |
| 66 <param name="arith" value="+"/> | |
| 67 </repeat> | |
| 68 <repeat name="components"> | |
| 69 <conditional name="param_type"> | |
| 70 <param name="select_param_type" value="integer"/> | |
| 71 <param name="component_value" value="1"/> | |
| 72 </conditional> | |
| 73 <param name="arith" value=""/> | |
| 74 </repeat> | |
| 75 <param name="output_type" value="integer"/> | |
| 76 <output name="output"> | |
| 77 <assert_contents> | |
| 78 <has_line line="2"/> | |
| 79 </assert_contents> | |
| 80 </output> | |
| 81 </test> | |
| 82 <test> | |
| 83 <repeat name="components"> | |
| 84 <conditional name="param_type"> | |
| 85 <param name="select_param_type" value="float"/> | |
| 86 <param name="component_value" value="1.5"/> | |
| 87 </conditional> | |
| 88 <param name="arith" value="*"/> | |
| 89 </repeat> | |
| 90 <repeat name="components"> | |
| 91 <conditional name="param_type"> | |
| 92 <param name="select_param_type" value="float"/> | |
| 93 <param name="component_value" value="1.5"/> | |
| 94 </conditional> | |
| 95 <param name="arith" value=""/> | |
| 96 </repeat> | |
| 97 <param name="output_type" value="float"/> | |
| 98 <output name="output"> | |
| 99 <assert_contents> | |
| 100 <has_line line="2.25"/> | |
| 101 </assert_contents> | |
| 102 </output> | |
| 103 </test> | |
| 104 <test> | |
| 105 <repeat name="components"> | |
| 106 <conditional name="param_type"> | |
| 107 <param name="select_param_type" value="float"/> | |
| 108 <param name="component_value" value="1.5"/> | |
| 109 </conditional> | |
| 110 <param name="arith" value="*"/> | |
| 111 </repeat> | |
| 112 <repeat name="components"> | |
| 113 <conditional name="param_type"> | |
| 114 <param name="select_param_type" value="float"/> | |
| 115 <param name="component_value" value="1.5"/> | |
| 116 </conditional> | |
| 117 <param name="arith" value=""/> | |
| 118 </repeat> | |
| 119 <param name="output_type" value="integer"/> | |
| 120 <output name="output"> | |
| 121 <assert_contents> | |
| 122 <not_has_text text="2.25"/> | |
| 123 <has_line line="2"/> | |
| 124 </assert_contents> | |
| 125 </output> | |
| 126 </test> | |
| 127 </tests> | |
| 128 <help><![CDATA[ | |
| 129 This tool calculates an output (integer or float) parameter | |
| 130 from integer and float input parameters and specified simple | |
| 131 arithmetic operations (addition, subtraction, multiplication, | |
| 132 division, exponentiation, and modulus). | |
| 133 ]]></help> | |
| 134 </tool> |
