Repository 'map_param_value'
hg clone https://toolshed.g2.bx.psu.edu/repos/iuc/map_param_value

Changeset 1:a01f088d0e5e (2022-10-19)
Previous changeset 0:43d7b3642a30 (2022-10-16) Next changeset 2:5ac8a4bf7a8d (2024-01-10)
Commit message:
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/map_param_value commit 49eab9a9d601cccd50401e5a0221264b5681b64d
modified:
map_param_value.xml
b
diff -r 43d7b3642a30 -r a01f088d0e5e map_param_value.xml
--- a/map_param_value.xml Sun Oct 16 08:05:37 2022 +0000
+++ b/map_param_value.xml Wed Oct 19 11:37:19 2022 +0000
[
b'@@ -1,10 +1,16 @@\n-<tool name="Map parameter value" id="map_param_value" version="0.1.0" tool_type="expression" profile="22.01">\n+<tool name="Map parameter value" id="map_param_value" version="0.1.1" tool_type="expression" profile="22.01">\n     <macros>\n         <xml name="when_element" tokens="type_selection">\n-            <param name="input_param" type="@TYPE_SELECTION@" optional="true" label="Map this parameter value to a different value"/>\n+            <param name="input_param" type="@TYPE_SELECTION@" optional="true" label="Value to map">\n+                <sanitizer sanitize="false"/>\n+            </param>\n             <repeat name="mappings" label="Add value mapping">\n-                <param name="from" type="@TYPE_SELECTION@" optional="true" label="Map from this value"></param>\n-                <param name="to" type="text" label="to this value" help="This value must be coercable to the selected output parameter type"></param>\n+                <param name="from" type="@TYPE_SELECTION@" optional="true" label="Map from this value">\n+                    <sanitizer sanitize="false"/>\n+                </param>\n+                <param name="to" type="text" optional="true" label="to this value" help="This value must be coercable to the selected output parameter type">\n+                    <sanitizer sanitize="false"/>\n+                </param>\n             </repeat>\n         </xml>\n     </macros>\n@@ -30,12 +36,12 @@\n }\n \n for ( var i = 0; i < mappings.length; i++ ) {\n-    if ( String(mappings[i].from) == source ) {\n+    if ( String(mappings[i].from) == String(source) ) {\n         return { output: coerceToOutput(mappings[i].to) };\n     }\n }\n if ( $job.unmapped.on_unmapped == "fail" ) {\n-    return { __error_message: `text_param ${source} not found in mapping values.` };\n+    return { __error_message: `input_param ${source} not found in mapping values.` };\n } else if ( $job.unmapped.on_unmapped == "default" ) {\n     return { output: coerceToOutput($job.unmapped.default_value) };\n }\n@@ -63,14 +69,8 @@\n                 <expand macro="when_element" type_selection="boolean"/>\n             </when>\n         </conditional>\n-        <param name="output_param_type" type="select" label="Select type of parameter to output">\n-            <option value="text">Text</option>\n-            <option value="integer">Integer</option>\n-            <option value="float">Float</option>\n-            <option value="boolean">Boolean</option>\n-        </param>\n         <conditional name="unmapped">\n-            <param name="on_unmapped" type="select" label="Select how">\n+            <param name="on_unmapped" type="select" label="Select how to handle unmapped values">\n                 <option value="input">Use unmodified input parameter value if input parameter value not found in mappings</option>\n                 <option value="fail">Fail if input parameter value not found in mappings</option>\n                 <option value="default">Provide a default value to use if input parameter value not found in mappings</option>\n@@ -81,6 +81,12 @@\n                 <param name="default_value" type="text" label="Use this value if the input parameter value was not found in mappings"/>\n             </when>\n         </conditional>\n+        <param name="output_param_type" type="select" label="Select type of parameter to output">\n+            <option value="text">Text</option>\n+            <option value="integer">Integer</option>\n+            <option value="float">Float</option>\n+            <option value="boolean">Boolean</option>\n+        </param>\n     </inputs>\n     <outputs>\n         <output type="text" name="output_param_text" from="output">\n@@ -98,6 +104,7 @@\n     </outputs>\n     <tests>\n         <test expect_num_outputs="1">\n+            <!-- map string A to string B -->\n             <conditional name="input_param_type">\n                 <param name="type" value="text"/>\n                 <param name="input_param" value="A" />\n@@ -109,6 +116,19 @@\n             <output'..b'fail"/>\n+            </conditional>\n+            <param name="output_param_type" value="boolean"/>\n+            <output name="output_param_boolean" value_json="false" />\n+        </test>\n+        <test expect_num_outputs="1">\n+            <!-- map boolean false to boolean true -->\n+            <conditional name="input_param_type">\n+                <param name="type" value="boolean" />\n+                <param name="input_param" value="false" />\n+                <repeat name="mappings">\n+                    <param name="from" value="false" />\n+                    <param name="to" value="true" />\n+                </repeat>\n+            </conditional>\n+            <conditional name="unmapped">\n+                <param name="on_unmapped" value="fail"/>\n+            </conditional>\n+            <param name="output_param_type" value="boolean"/>\n+            <output name="output_param_boolean" value_json="true" />\n+        </test>\n+        <test expect_num_outputs="1">\n+            <!-- map integer 0 to boolean false via default value coercion -->\n+            <conditional name="input_param_type">\n+                <param name="type" value="integer" />\n+                <param name="input_param" value="0" />\n+            </conditional>\n+            <param name="output_param_type" value="boolean"/>\n+            <output name="output_param_boolean" value_json="false" />\n         </test>\n+        <test expect_num_outputs="1">\n+            <!-- map null text value to boolean true -->\n+            <conditional name="input_param_type">\n+                <param name="type" value="text" />\n+                <param name="input_param" value_json="null" />\n+                <repeat name="mappings">\n+                    <param name="from" value_json="null" />\n+                    <param name="to" value="true" />\n+                </repeat>\n+            </conditional>\n+            <param name="output_param_type" value="boolean"/>\n+            <output name="output_param_boolean" value_json="true" />\n+        </test>\n+        <test expect_num_outputs="1" doc="map null integer value to boolean true">\n+            <!-- map null integer value to boolean true -->\n+            <conditional name="input_param_type">\n+                <param name="type" value="integer" />\n+                <param name="input_param" value_json="null" />\n+                <repeat name="mappings">\n+                    <param name="from" value_json="null" />\n+                    <param name="to" value="true" />\n+                </repeat>\n+            </conditional>\n+            <param name="output_param_type" value="boolean"/>\n+            <output name="output_param_boolean" value_json="true" />\n+        </test>\n+        <test expect_num_outputs="1">\n+            <!-- map integer value to null text -->\n+            <conditional name="input_param_type">\n+                <param name="type" value="integer" />\n+                <param name="input_param" value="1" />\n+                <repeat name="mappings">\n+                    <param name="from" value="1" />\n+                    <param name="to" value_json="null" />\n+                </repeat>\n+            </conditional>\n+            <param name="output_param_type" value="text"/>\n+            <output name="output_param_text" value_json="null" />\n+        </test>\n+        <!-- Old Galaxy issue, optional unset text input still recorded as ""\n+             We could work around this with a conditional, but no usecase yet\n+             and we should better fix this in Galaxy\n+            <test expect_num_outputs="1">\n+                <conditional name="input_param_type">\n+                    <param name="input_param" value="A" />\n+                    <repeat name="mappings">\n+                        <param name="from" value="A" />\n+                    </repeat>\n+                </conditional>\n+                <output name="output_param_text" value_json="null" />\n+            </test>\n+        -->\n     </tests>\n     <help><![CDATA[\n **What it does**\n'