我试图创建一个条件管道NextFlow。例如,
进程A向通道输出值。如果值为1,则运行X,否则运行Y.
这就是我要做的事情:
initialData = 2
receiver1 = "EMPTY"
receiver2 = "EMPTY"
receiver3 = ""
process A {
input:
val initialData
output:
val initialData into trigger
'''
echo 10
'''
}
process foo {
input:
val trigger
output:
val "I ran from FOO" into receiver2
when:
trigger == 2
'''
echo I ran from FOO
'''
}
process bar {
input:
val trigger
output:
val "I ran from BAR" into receiver1
when:
trigger == 1
'''
echo I ran from BAR
'''
}
假设foo和bar是等效但不同的实现(例如,一个将电影从AVI转换为h.264,另一个从MOV转换为h.264)。我想要另一个过程,比如说C,可以从Bar或Foo读取,而不知道触发器的任何信息。但是,如果我在Foo和Bar中使用相同的输出通道名称,则nextflow会抱怨。
答案 0 :(得分:0)
您可以在流程中使用conditional scripts并仅使用一个渠道。
process action {
input:
val t from trigger
file in from input_channel
output:
file out into unique_receiver
script:
if (t == 1)
"""
foo ${in} > ${out}
"""
else if (t == 2)
"""
bar ${in} > ${out}
"""
}