Is channel output from multiMap guaranteed to be in the same order it comes in? #2682
-
Is output from multiMap guaranteed to be in the same order it comes in? #! /usr/bin/env nextflow
nextflow.enable.dsl = 2
workflow {
input_ch = Channel.of (
[ id: 'test1', prop1: 'test1_od', prop2: 'test1_pad' ],
[ id: 'test2', prop1: 'test2_od', prop2: 'test2_pad' ]
)
def mmc = multiMapCriteria {
sample: it.id
attributeone: it.prop1
attributetwo: it.prop2
}
FOO ( input_ch.multiMap( mmc ) ) // Does this guarantee test1 and test2 won't be mixed?
}
process FOO {
echo true
input:
val samp
val x
val y
script:
"""
printf "%s\\t%s\\t%s\\n" $samp $x $y
"""
} I want to apply it to a more complex scenario to keep the code more readable rather than having a very large tuple with optional inputs. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
I wouldn't be surprised if multiMap preserves the order, but I don't recommend structuring the channels this way. Values that should be tied together, like As for optional inputs, there are some efforts to improve Nextflow support for optionals (#1694, #2893). I think that would be a better direction to pursue. |
Beta Was this translation helpful? Give feedback.
I wouldn't be surprised if multiMap preserves the order, but I don't recommend structuring the channels this way. Values that should be tied together, like
(samp, x, y)
in this example, should be managed as a tuple, even if that means that you have long tuples. Even if multiMap happens to preserve order, who knows what other channel logic might come into play and break that ordering.As for optional inputs, there are some efforts to improve Nextflow support for optionals (#1694, #2893). I think that would be a better direction to pursue.