These are chat archives for nextflow-io/nextflow

29th
Aug 2017
jeslipp
@jeslipp
Aug 29 2017 10:30
Hi all - I have a question about operators in Nextflow. Is there an easy way to get from [ [ key1, [value1, value2] ] , [ key2, [value3, value4] ] ] to the unnested version [ [ [ key1, value1 ], [ key1, value2 ] ] , [ [ key2, value3 ], [ key2, value3 ] ] ]? Maybe I am missing something obvious in the documentation? Thanks for your help!
Evan Floden
@evanfloden
Aug 29 2017 11:28
Try this, I think it works it the console anyway.
inputCh = Channel.from ([ [ 'key1', ['value1', 'value2'] ] , [ 'key2', ['value3', 'value4'] ] ])

def transform = { 
          def result = []
          def name = it[0]
          it[1].each { result << [name, it] }
          return result
 }

inputCh
  .flatMap { it -> transform(it) }
  .view()
jeslipp
@jeslipp
Aug 29 2017 11:44
Just what I needed. Thanks!!
Paolo Di Tommaso
@pditommaso
Aug 29 2017 12:09
I've noticed that's a recurrent use case, I think we could add an operator to manage it in a smoother way
any suggestion for the name ?
jeslipp
@jeslipp
Aug 29 2017 12:14
unnest?
or something with ungroup as it is kind of the reverse operation of groupTuple
Paolo Di Tommaso
@pditommaso
Aug 29 2017 12:52
um, ungroupTuple could work