2

我试图在nextflow.config管道执行期间访问文件中的变量。我想image_standard作为字符串提供run.nf,我想eu.gcr.io/proj_name/image1:latest作为输出接收。我想出了一种.config在 nextflow 脚本中获取文件内容的方法,但我不知道如何访问这个特定的属性。

这是我的nextflow.config文件:

process {
    withLabel: image_standard {
        container = "eu.gcr.io/proj_name/image1:latest"
    }
    withLabel: image_deluxe {
        container = "eu.gcr.io/proj_name/image2:latest"
    }
}

run.nf

  x =  workflow.configFiles[0]
  Properties properties = new Properties()
  File propertiesFile = new File("${x}")
        propertiesFile.withInputStream {
        properties.load(it)
    }
    log.info "${properties.process}"

仅打印该行:

{

4

1 回答 1

1

您可以尝试使用 ProcessConfig 类和applyConfigSelector()方法来替代配置文件并选择所需的进程:

import nextflow.config.ConfigParser
import nextflow.script.ProcessConfig

def config_file = file("${baseDir}/nextflow.config")
def config = new ConfigParser().setIgnoreIncludes(true).parse(config_file.text)

def process = new ProcessConfig([:])
process.applyConfigSelector(config.process, 'withLabel:', 'image_standard')

println(process.container)
于 2020-11-23T23:30:16.300 回答