How do I create a cartesian product of 2 channels where each channel is a tuple of (meta,value)? #3977
-
I need to create the cartesian product of 2 channels where each channel has the nf-core structure of a tuple(meta,value).
//def t(v){ tuple([:],v) } //it does not work with the tuple
def t(v){ v }
ch_a = Channel.fromList([t(1),t(2),t(3)])
ch_b = Channel.fromList([t("A"),t("B"),t("C")])
ch_a.combine(ch_b)
.multiMap{ :x b ->
a: a
b: b
}
.set{ comb }
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Yes, I'm not sure what's going on with your |
Beta Was this translation helpful? Give feedback.
-
Dear Ben, thank you very much for the answer, but
I need an operator that creates the cartesian product of two channels that each produces tuples, ignoring any possible common "keys" and the result should preserve the input structure.
Result
Result
Desired result
|
Beta Was this translation helpful? Give feedback.
You're right,
cross
can't do a simple cross product without matching, which seems odd since it's literally namedcross
😅While we could change
cross
to do a simple cross product whenby
is not given, Paolo probably won't accept it because it could break existing pipelines. Maybe we can do it if you explicitly sayby: null
?Anyway, for now I recommend you use
combine
and thenmap
to un-flatten the combos: