Step 21 - Is the triplet really necessary?
A process can take multiple input Channels. But then why are struggling with triplets above? Why do we make our life harder than it could be? Let us illustrate this with a little example. We define a process that takes two input Channels, one containing integers and the other with strings. We simply concatenate both in the process definition:
// Step - 21
process process_step21 {
input:
val(in1)
val(in2)
output:
val(out)
exec:
out = in1 + in2
}
workflow step21 {
ch1_ = Channel.from( [1, 2, 3, 4, 5 ] )
ch2_ = Channel.from( ["a", "b", "c", "d" ] )
process_step21(ch1_, ch2_) | toSortedList | view
}
If we run this, we get the following result:
> nextflow -q run . -entry step21 -with-docker
WARN: DSL 2 IS AN EXPERIMENTAL FEATURE UNDER DEVELOPMENT -- SYNTAX MAY CHANGE IN FUTURE RELEASE
[1a, 2b, 3c, 4d]
This seems fine, it is probably what was expected to happen. If we slightly change the workflow and add a process step we defined earlier (add):
// Step - 21a
workflow step21a {
ch1_ = Channel.from( [1, 2, 3, 4, 5 ] ) | add
ch2_ = Channel.from( ["a", "b", "c", "d" ] )
process_step21(ch1_, ch2_) | toSortedList | view
}
Running this two times should reveal the caveat we want to point out;
> nextflow -q run . -entry step21a -with-docker
WARN: DSL 2 IS AN EXPERIMENTAL FEATURE UNDER DEVELOPMENT -- SYNTAX MAY CHANGE IN FUTURE RELEASE
[2d, 3a, 4c, 5b]
> nextflow -q run . -entry step21a -with-docker
WARN: DSL 2 IS AN EXPERIMENTAL FEATURE UNDER DEVELOPMENT -- SYNTAX MAY CHANGE IN FUTURE RELEASE
[2d, 3a, 4c, 6b]
The result is not deterministic. Imagine you want to combine two input Channels like this, but one of the Channels requires some additional processing first (creating an index or a qc report) then relying on the order of operations not consistent.
In other words, we need to stick to adding an explicit ID and add it with the config to the triplet.