Entering edit mode
16 months ago
lacb
▴
120
Hello !
I'm trying to do something in Nextflow I thought would be simple but I can find how to do it: I need to filter the output of a channel by the output of another channel. An item in the second channel will be output only if the first channel contains this item.
I tried to convert the output of my first channel to a List and then to use the filter operator of Nextflow, but no item is emitted. Here is a toy example (I'm using Nextflow DLS2):
#!/usr/bin/env nextflow
nextflow.enable.dsl=2
workflow {
Channel.of(["a","c","e","g"]) \
| flatten \
| toList \
| set { to_keep }
Channel.of([['a', "file_a.bam"],
['b', "file_b.bam"],
['c', "file_c.bam"],
['d', "file_d.bam"],
['e', "file_e.bam"],
['f', "file_f.bam"],
['g', "file_g.bam"],
['h', "file_h.bam"]]) \
| filter { it -> to_keep.find { e -> it[0].toString().equalsIgnoreCase(e.toString()) } } \
| view
}