NextFlow:如何使用inputStream与DSL2



使用NextFlow (DSL=2),我想使用文件的每一行作为我的工作流的流输入。

nextflow.enable.dsl=2
process bar {
input: val data
output: val result
exec:
result = data.toUpperCase()
}
workflow {
myFile = file('input_test.txt')
myReader = myFile.newReader()
myFile.withInputStream {
String line
while( line = myReader.readLine() ) {
channel.from(line) | bar | view
}
}
}

我面临的问题是我只能使用"bar"过程:Process 'bar' has been already used -- If you need to reuse the same component include it with a different name or include in a different workflow context

我还尝试创建一个从线路和呼叫栏获取通道的子工作流。

是否有一种方法使用流数据作为输入使用Nextflow?

注意:我的最终目标不仅仅是应用一个大写函数。我想在数据流上链接几个复杂的进程。

谢谢!

您的示例代码看起来像一个反模式—它将尝试为输入文件中的每一行创建一个新通道。相反,看一下拆分操作符,特别是splitText操作符:

workflow {
Channel.fromPath('input_test.txt')
| splitText { it.trim() } 
| bar 
| view()
}

如果上面没有帮助,请准确描述你想对输入文件中的每一行做什么。

最新更新