These are chat archives for nextflow-io/nextflow

21st
Apr 2016
Robert Syme
@robsyme
Apr 21 2016 02:55
Bi @JoseEspinosa. What does the channel look like before the groupBy operation?
Robert Syme
@robsyme
Apr 21 2016 03:05
Is it possible to use groupTuple? Something like:
names = Channel.from 'Amy', 'Chloe', 'James', 'Sam'
counts = Channel.from 1, 2, 3, 4

process makeFiles {
  input:
  val count from counts

  output:
  set 'out.txt', count into foo

  """
#!/usr/bin/env ruby
File.open('out.txt', 'w') do |out|
    out.puts 'This value is: ${count}'
end
  """
}

foo.spread(names)
.map { file, count, name -> [name, file, count] }
.groupTuple()
.set { jose }

process combineFiles {
  input:
  set name, 'files.*.txt', counts from jose

  output:
  set name, 'output.txt', counts into finished

  """
cat files.*.txt > output.txt
  """
}

finished.println()
Jose Espinosa-Carrasco
@JoseEspinosa
Apr 21 2016 09:04
Thanks a lot!
channel_in = Channel.from(['file.name.backward.csv', 'file.head.txt'],
                      ['file.name.backward.csv', 'file.tail.txt'],
                      ['file.name.backward.csv', 'file.tail.txt'],
                      ['file.name.forward.csv', 'file.head.txt'],
                      ['file.name.forward.csv', 'file.tail.txt']
                     )


process makeFiles {
  input:
  set val (name_A), val (name_B) from channel_in      

  output:
  set 'out.txt', name_A, name_B into foo

  """
  echo "$name_A $name_B" > out.txt
  """
}

channel_hash = foo.groupBy { it ->
      it[1].tokenize(".")[2] + "_" + it[2].tokenize(".")[1] }.subscribe {println it}
My example will be more like that
Jose Espinosa-Carrasco
@JoseEspinosa
Apr 21 2016 09:25
This leads to a hash of channels. From this hash I would like to concatenate for each key the content of the files (position 0 of the channels)
Paolo Di Tommaso
@pditommaso
Apr 21 2016 11:21
This leads to a hash of channels
what do you mean by that?
Jose Espinosa-Carrasco
@JoseEspinosa
Apr 21 2016 13:22
Hi Paolo mixing my example with the code of Robert I manage to solve it
thanks!
Paolo Di Tommaso
@pditommaso
Apr 21 2016 13:23
Great