-
Notifications
You must be signed in to change notification settings - Fork 736
Open
Description
New feature
Enhancing the pipe operator to allow processes and workflows with multiple inputs to be piped together.
Usage scenario
Given the following processes:
process toUpper {
input: val x
output: stdout
script: "echo -n $x | tr a-z A-Z"
}
process strConcat {
input: val x; val y
output: stdout
script: "echo -n $x; echo -n $y"
}
If we want to run out data through toUpper
and into strConcat
, the best we can do with piping is the following:
workflow {
append = channel.value('!')
strConcat(
channel.of('foo', 'bar') | toUpper,
append) |
view()
}
which gives output:
N E X T F L O W ~ version 22.04.5
Launching `works.nf` [zen_mclean] DSL2 - revision: 2f1ccf68d9
executor > local (4)
[68/eb8b8d] process > toUpper (2) [100%] 2 of 2 ✔
[e9/7fb402] process > strConcat (2) [100%] 2 of 2 ✔
FOO!
BAR!
Suggest implementation
The following would be more intuitive and readable:
workflow {
append = channel.value('!')
channel.of('foo', 'bar') |
toUpper() |
strConcat(append) |
view()
}
Attempting to run the above currently gives the following error:
Process `toUpper` declares 1 input channel but 0 were specified
-- Check script 'main.nf' at line: 17 or see '.nextflow.log' file for more details
if we replace toUpper() |
with toUpper |
, the error becomes:
Process `strConcat` declares 2 input channels but 1 were specified
This could be achieved by making the first argument or a process be the piped value (regardless of whether parenthesis are present). This already seems to be the case for operators that accept multiple arguments, e.g.:
channel.of('foo', 'bar') |
mix(channel.of('baz')) |
view
Gullumluvl