Step 6 - Add a process parameter
What if we want to be able to configure the term in the sum? This would require a parameter to be sent with the process invocation. Let’s see how this can be done.
// Step - 6
process addTupleWithParameter {
input:
tuple val(id), val(input), val(term)
output:
tuple val("${id}"), val(output)
exec:
output = input + term
}
workflow step6 {
Channel.from( [ 1, 2, 3 ] ) \
| map{ el -> [ el.toString(), el, 10 ]} \
| addTupleWithParameter \
| view{ it }
}
The result is:
> nextflow -q run . -entry step6
WARN: DSL 2 IS AN EXPERIMENTAL FEATURE UNDER DEVELOPMENT -- SYNTAX MAY CHANGE IN FUTURE RELEASE
[2, 12]
[1, 11]
[3, 13]
This works, but is not very flexible. What if we want to configure the operator as well? What if we want to have branch-specific configuration? We can add a whole list of parameters, but that means that the process
signature may be different for every process
that we define. That is not a preferred solution.