nextflow icon indicating copy to clipboard operation
nextflow copied to clipboard

[New Feature] Group tuple size

Open Lehmann-Fabian opened this issue 2 years ago • 2 comments

Today I spent some time finding out how to group tuples when the group sizes vary. Currently, I have to do it this way.

Channel
     .from( [1,'A'], [1,'B'], [2,'C'], [3, 'B'], [1,'C'], [2, 'A'], [3, 'D'] )
     .map { key, value -> [ groupKey( key, key == 1 ? 3 : 2 ), value ] }
     .groupTuple()
     .view()

Doing it this way, requires an additional mapping, moreover it gets complex if more, and non-consecutive indexes are used. I propose to do it the following way. I implemented it as an alternative, keeping the other method valid.

Channel
     .from( [1,'A'], [1,'B'], [2,'C'], [3, 'B'], [1,'C'], [2, 'A'], [3, 'D'] )
     .groupTuple( size : { it == 1 ? 3 : 2} )
     .view()

Lehmann-Fabian avatar Dec 13 '21 16:12 Lehmann-Fabian

Hi @pditommaso, can you please review this PR.

Lehmann-Fabian avatar Apr 14 '22 11:04 Lehmann-Fabian

:warning: 7 God Classes were detected by Lift in this project. Visit the Lift web console for more details.

sonatype-lift[bot] avatar Sep 28 '22 09:09 sonatype-lift[bot]