These are chat archives for nextflow-io/nextflow

30th
May 2016
Szilveszter Juhos
@szilvajuhos
May 30 2016 13:53
what is the easy way to monitor the content of a channel without exhausting its items?
what I am doing now i to duplicate a channel with .separate and report one into logs
Paolo Di Tommaso
@pditommaso
May 30 2016 13:54
Yes, use the view operator
Szilveszter Juhos
@szilvajuhos
May 30 2016 14:13
Hm, when doing something like
Channel.from fastqs.view()
I will get the content printed out, indeed, but the channel is empty
if I say foo=Channel.from fastqs.view() , and trying to use it
seems they are not exactly what I expected to be copies
Paolo Di Tommaso
@pditommaso
May 30 2016 14:18
um, let say that we have this snippet
Channel.from(1,2,3)
    .view { "item: $it" }
    .map { it * it }
    .println { "the square is: $it" }
it prints
item: 1
item: 2
item: 3
the square is: 1
the square is: 4
the square is: 9
so view dump the content of the source channel and return the same
than map get the items creating a channel with the square
then print them
to summarise, yes view allows you only yo print the content but without consuming the content of the channel
Szilveszter Juhos
@szilvajuhos
May 30 2016 14:23
and if I want to only view the items before passing to an other process?
ch = Channel.from(1,2,3)
Channel.from ch.view { "item: $it" }
Channel.from ch.view { "item: $it" }
stops after the first one
Paolo Di Tommaso
@pditommaso
May 30 2016 14:25
this is an invalid syntax Channel.from ch.view { "item: $it" }
you can do
Szilveszter Juhos
@szilvajuhos
May 30 2016 14:26
:) can be, but does something
Paolo Di Tommaso
@pditommaso
May 30 2016 14:26
ch = Channel.from(1,2,3).view()
process foo {
  input: 
  val x from ch 
 : 
}
in other word you need to use the result of view
to be precise, view like all other other operators consume the source channel but implicitly create a new channel that emits the same content
thus, you cannot do
ch = Channel.from(1,2,3)
ch.view { "item: $it" }
ch.view { "item: $it" }
but you can do
ch = Channel.from(1,2,3)
ch.view { "item: $it" }
   .view { "item: $it" }
   .somethingElse ..
i.e. you need always to chain operators
Szilveszter Juhos
@szilvajuhos
May 30 2016 14:35
cheers, this part is more or less OK, I guess I am screwing up something somewhere else