why I got Cannot invoke method view() on null object,,, my code is like:
workflow parsefq {
take: samplesheet
main:
Channel.fromPath( samplesheet )
.splitCsv ( header:true, sep:'\t' ) // dict: [sample:test1, fqdir:xxx, barcode: 10, 11]
.map { create_fastq_channel(it) } //[test1, [fq1, fq2]]
.set {reads}
emit: reads
}
def create_fastq_channel(LinkedHashMap row) {...return [row.sample, fq1s, fq2s]}
workflow {
ch_input = file(params.input)
parsefq (ch_input)
.set {ch_fq}
.view() //got error on this
}
You get the error above because the set
operator just returns null
. It is intended only to assign a variable name to a channel. Usually we use the set
operator at the end of a chain of channel operations. If we don't need to apply any transformations to the output, we can just assign a channel name using the =
assignment operator:
workflow {
ch_input = file(params.input)
ch_fq = parsefq(ch_input)
ch_fq.view()
}