why I got Cannot invoke method view() on null object

huangapple go评论62阅读模式
英文:

why I got Cannot invoke method view() on null object

问题

I got "Cannot invoke method view() on null object" 错误,我的代码如下:

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()      //在这里出错
}
英文:

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
}

答案1

得分: 1

因为set操作符只会返回null,所以你会收到上述错误。它的主要目的是为通道分配一个变量名。通常,我们在一系列通道操作的最后使用set操作符。如果我们不需要对输出应用任何转换,可以使用=赋值操作符来分配通道名称:

workflow {
    ch_input = file(params.input)
    ch_fq = parsefq(ch_input)

    ch_fq.view()
}
英文:

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()
}

huangapple
  • 本文由 发表于 2023年4月13日 17:19:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/76003764.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定