From d1f28ea8825e93dace333cf5c51a35b0963398e6 Mon Sep 17 00:00:00 2001 From: Peter van 't Hof Date: Tue, 18 Nov 2014 13:29:50 +0100 Subject: [PATCH] Alow for multiple configs in BIOPET_CONFIG and BIO_CONFIG_SCATTER --- .../lumc/sasc/biopet/core/BiopetQScript.scala | 4 ++++ .../lumc/sasc/biopet/core/config/Config.scala | 19 ++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala b/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala index cf4ee286b..47c7279f5 100644 --- a/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala +++ b/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala @@ -15,6 +15,9 @@ trait BiopetQScript extends Configurable { @Argument(doc = "Output directory", fullName = "output_directory", shortName = "outDir", required = true) var outputDir: String = _ + @Argument(doc = "Use scatter defaults, env vale BIOPET_CONFIG_SCATTER", shortName = "SC", required = false) + var useScatterDefault: Boolean = false + var outputFiles: Map[String, File] = Map() var qSettings: QSettings @@ -25,6 +28,7 @@ trait BiopetQScript extends Configurable { var functions: Seq[QFunction] final def script() { + if (useScatterDefault) Config.global.loadDefaultScatterConfig if (!outputDir.endsWith("/")) outputDir += "/" init biopetScript diff --git a/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/config/Config.scala b/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/config/Config.scala index f6f8e0cf7..c110ea774 100644 --- a/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/config/Config.scala +++ b/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/config/Config.scala @@ -12,15 +12,24 @@ class Config(var map: Map[String, Any]) extends Logging { loadDefaultConfig() } - def loadDefaultConfig() { - var globalFile: String = System.getenv("BIOPET_CONFIG") - if (globalFile != null) { + def loadConfigEnv(valueName: String) { + var globalFiles = System.getenv(valueName).split(":") + for (globalFile <- globalFiles) { var file: File = new File(globalFile) if (file.exists()) { logger.info("Loading config file: " + file) loadConfigFile(file) - } else logger.warn("BIOPET_CONFIG value found but file does not exist, no global config is loaded") - } else logger.info("BIOPET_CONFIG value not found, no global config is loaded") + } else logger.warn(valueName + " value found but file does not exist, no global config is loaded") + } + if (globalFiles.isEmpty) logger.info(valueName + " value not found, no global config is loaded") + } + + def loadDefaultConfig() { + loadConfigEnv("BIOPET_CONFIG") + } + + def loadDefaultScatterConfig() { + loadConfigEnv("BIOPET_CONFIG_SCATTER") } def loadConfigFile(configFile: File) { -- GitLab