Groovy 访问配置文件中的复杂密钥

Groovy 访问配置文件中的复杂密钥,groovy,nextflow,Groovy,Nextflow,在执行管道期间,我试图访问nextflow.config文件中的变量。我想在run.nf中以字符串形式提供image\u standard,我想接收eu.gcr.io/proj\u name/image1:latest作为输出。我找到了在nextflow脚本中获取.config文件内容的方法,但我不知道如何访问此特定属性 这是我的nextflow.config文件: process { withLabel: image_standard { container = &qu

在执行管道期间,我试图访问
nextflow.config
文件中的变量。我想在
run.nf
中以字符串形式提供
image\u standard
,我想接收
eu.gcr.io/proj\u name/image1:latest
作为输出。我找到了在nextflow脚本中获取
.config
文件内容的方法,但我不知道如何访问此特定属性

这是我的
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}"
它只打印行:


{

您可以尝试使用ProcessConfig类和以下方法来读取配置文件并选择所需的进程:

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)