Nextflow : Is it possible to tranform a queue channel to a value channel?

爱⌒轻易说出口 提交于 2021-01-29 07:20:22

问题


I have a process A which outputs a file into a channel outA. I want to use that file as input for 3 downstream processes B, C and D. As the channel outA created is a queue channel by default, I cannot directly use the file more than once (unlike value channels).

Currently, I use the into operator to duplicate the channel outA as described here (see the code below).

I also know that you can create a value channel from a file by doing Channel.value(file('/path/to/file.txt')).

My code currently :

// Upstream process creating a queue channel with one file
process A {
    output:
        file outA
    "echo 'Bonjour le monde !' > $outA"
}

// Queue channel triplication
outA.into {inB; inC; inD}

// Downstream processes all using the same file
process B {
    input:
        file inB
    "script of process B $inB"
}

process C {
    input:
        file inC
    "script of process C $inC"
}

process D {
    input:
        file inD
    "script of process D $inD"
}

I works fine as it is, but I wonder if it is possible to transform the queue channel outA into a value channel, so that I can use the same channel as input for processes B, C and D.


回答1:


You can use the first() operator to do that, e.g.:

inX = outA.first()

process B {
    input:
        file inX
    "script of process B $inX"
}

etc

Also note that when a process has no input (like process A) its outputs are implicitly value channels.



来源:https://stackoverflow.com/questions/53972302/nextflow-is-it-possible-to-tranform-a-queue-channel-to-a-value-channel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!