我试图在执行管道期间访问nextflow.config
文件中的变量。我想在run.nf
中提供image_standard
作为字符串,并且我想接收eu.gcr.io/proj_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类和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)