RNA-seq示例工作流中的nextflow.collect()方法



我知道,当我们运行一个以两个通道作为输入的进程时,我们必须使用collect(),其中第一个通道有一个元素,然后第二个通道有>1个元素:


#! /usr/bin/env nextflow
nextflow.enable.dsl=2
process A {
input:
val(input1)
output:
path 'index.txt', emit: foo
script:
"""
echo 'This is an index' > index.txt
"""
}
process B {
input:
val(input1)
path(input2)
output:
path("${input1}.txt")
script:
"""
cat <(echo ${input1}) ${input2} > "${input1}.txt"
"""
}
workflow {
A( Channel.from( 'A' ) )
// This would only run for one element of the first channel:
B( Channel.from( 1, 2, 3 ), A.out.foo )
// and this for all of them as intended:
B( Channel.from( 1, 2, 3 ), A.out.foo.collect() )
}

现在的问题是:为什么示例工作流中的这一行可以从nextflow io(https://github.com/nextflow-io/rnaseq-nf/blob/master/modules/rnaseq.nf#L15)在不使用collect()toList()的情况下工作?

具有一个元素(索引(的通道和具有>1(fastq对(应由同一进程(quant(使用,并且它在所有fastq文件上运行。与我的伪示例相比,我缺少了什么?

您需要创建第一个具有值工厂的通道,该值工厂永远不会耗尽通道。

您的链接示例隐含地创建了一个价值通道,这就是它工作的原因。当您在A.out.foo上调用.collect()时,也会发生同样的情况。

Channel.from(或更现代的Channel.of(创建了一个可以耗尽的序列信道,这就是为什么AB都只运行一次的原因。

所以

A( Channel.value('A') )

就是你所需要的。

最新更新