【问题标题】:NextFlow: how to use inputStream with DSL2NextFlow:如何在 DSL2 中使用 inputStream
【发布时间】:2021-03-03 10:38:42
【问题描述】:

使用 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 将流数据用作输入?

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

谢谢!

【问题讨论】:

    标签: java-stream workflow nextflow


    【解决方案1】:

    您的示例代码看起来像一个反模式 - 它会尝试为您输入文件中的每一行创建一个新通道。相反,看看splitting operators,尤其是splitText operator

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

    如果上述方法没有帮助,请准确描述您想要对输入文件中的每一行执行的操作。

    【讨论】:

    • 感谢您的帮助!是的,到目前为止我生成的代码不会产生预期的行为。我想使用一组非有限元素作为输入,并通过通道将其流式传输到工作流,而不必为每个新行“启动”新的工作流运行。我正在考虑“提供”一个频道,但如果没有 DSL2 已弃用的 bind 或“
    • 对不起@Nine,我不确定我是否在关注。据我了解, splitText 操作应该满足这些要求。例如,流程“栏”可以是(命名的)工作流程。此外,通道 create 方法已被 DSL2 弃用。
    猜你喜欢
    • 2022-11-11
    • 2021-10-13
    • 1970-01-01
    • 1970-01-01
    • 2021-11-02
    • 1970-01-01
    • 2013-04-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多