How to print count with text/message?

Hello there,

I’m interested in printing number of files in the channel.

ch_civic_mutation=channel.of([[batch:'SEMA-MM-001', timepoint:'MM-0486-T-01', tissue:'tumor', sequencing_type:'wes'],file('civic_mutation.csv')
  ],
  [[batch:'SEMA-MM-001', timepoint:'MM-0487-T-01', tissue:'tumor', sequencing_type:'wes'],file('civic_mutation.csv')
  ]
  )

I can get the count using following code:

ch_civic_mutation.count().view()

However, I’m interested to print as a string/text. I used following code but doesn’t work:

println "value is "+ch_civic_mutation.count()
println "value is "+{ch_civic_mutation}.count()
println "value is ch_civic_mutation.count()"


Please let me know how to get this in print with some texts.

You can use a closure in the view channel operator. Check the snippet below.

ch_civic_mutation = Channel.of([[batch:'SEMA-MM-001', timepoint:'MM-0486-T-01', tissue:'tumor', sequencing_type:'wes'],file('civic_mutation.csv')
  ],
  [[batch:'SEMA-MM-001', timepoint:'MM-0487-T-01', tissue:'tumor', sequencing_type:'wes'],file('civic_mutation.csv')
  ]
  )

ch_civic_mutation.count().view { "They are $it" }

Output:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.