从两个通道中的任何一个获取过程输入

Take process input from either of two channels

如何允许进程从两个通道之一获取输入,这两个通道是具有互斥条件 运行 的进程的输出?例如,类似于:

params.condition = false

process a {
    output:
    path "a.out" into a_into_c

    when:
    params.condition == true

    """
    touch a.out
    """
}

process b {
    output:
    path "b.out" into b_into_c

    when:
    params.condition == false

    """
    touch b.out
    """
}

process c {
    publishDir baseDir, mode: 'copy'

    input:
    path foo from a_into_c or b_into_c

    output:
    path "final.out"

    """
    echo $foo > final.out
    """
}

如果 params.condition 为真(例如 --condition 在命令行上给出),final.out 将包含 a.out,如果为真,则 b.out假的。

您可以为此使用 mix operator

process c {
    publishDir baseDir, mode: 'copy'

    input:
    path foo from a_into_c.mix(b_into_c)

    output:
    path "final.out"

    """
    echo $foo > final.out
    """
}