Hi, I have this bit of code generated by AI this morning and I am trying to double check if it is correct. Also looking for some sort of documentation I can link here when my future self tries to blame this on me.
I know that channels are somewhat asynchronous in nextflow, right? meaning the the order of the channel is not guaranteed. So that’s why I am a bit worried about this implementation. I am assuming that map is however synchronous and will maintain the order considering the input of the two maps is the same channel. Is this true?
Note that this particular “hack” is needed because I can’t (or rather I don’t want to) change the implementation of the nf-core module itself. I would normally declare an input channel with multiple inputs to maintain the order.
The long term solution is to combine the UCSC_BIGWIGAVERAGEOVERBED input to a single input which could support any combination of inputs. This is the direction the language is going with features such as record types.
As Adam said we normally use multiMap, mostly to keep the code together. map does work too, but the source channels need to be the same. This is because channels are also queues ( first-in, first-out ). The asynchronicity comes from when objects are put into channels, so when map receives something from an upstream channel, it should process it in the same order as that upstream channel.
Awesome! Thanks for the quick reply! I ll add multimap for now, indeed looks a cleaner result. Record types looks interesting indeed! I have to get another look at it. Thanks again for sharing.