2.9. Expression Tool#
An expression tool is a type of Process that can be run by itself or as a Workflow step. It executes a pure JavaScript expression. It is meant to be used as a way to isolate complex JavaScript expressions that need to operate on input data and produce some result as output.
Similar to the command-line tool it requires inputs
and outputs
.
But instead of baseCommand
, it requires an expression
attribute.
cwlVersion: v1.2
class: ExpressionTool
requirements:
InlineJavascriptRequirement: {}
inputs:
message: string
outputs:
uppercase_message: string
expression: |
${ return {"uppercase_message": inputs.message.toUpperCase()}; }
Note
We had to use an InlineJavascriptRequirement
as our expression
contains a JavaScript call in .toUpperCase()
. This means to tools
using the expression tool that JavaScript is a requirement.