From 5a4df7151678303548bfb3b0d063ba51ab3edbb6 Mon Sep 17 00:00:00 2001
From: Peter van 't Hof <p.j.van_t_hof@lumc.nl>
Date: Fri, 6 Jun 2014 11:36:59 +0200
Subject: [PATCH] Added merge config

---
 .../src/main/java/nl/lumc/sasc/biopet/wrappers/Ln.scala  | 9 ++++++---
 .../main/java/nl/lumc/sasc/biopet/wrappers/Sha1sum.scala | 2 +-
 .../main/java/nl/lumc/sasc/biopet/wrappers/Zcat.scala    | 2 +-
 .../biopet/pipelines/flexiprep/scripts/FastqSync.scala   | 2 +-
 .../pipelines/flexiprep/scripts/FastqcToContams.scala    | 2 +-
 .../pipelines/flexiprep/scripts/FastqcToQualtype.scala   | 2 +-
 .../biopet/pipelines/flexiprep/scripts/Seqstat.scala     | 2 +-
 .../biopet/pipelines/flexiprep/scripts/Summarize.scala   | 2 +-
 .../nl/lumc/sasc/biopet/wrappers/fastq/Cutadapt.scala    | 2 +-
 .../java/nl/lumc/sasc/biopet/wrappers/fastq/Fastqc.scala | 2 +-
 .../java/nl/lumc/sasc/biopet/wrappers/fastq/Sickle.scala | 2 +-
 .../java/nl/lumc/sasc/biopet/wrappers/aligners/Bwa.scala | 2 +-
 .../nl/lumc/sasc/biopet/wrappers/aligners/Star.scala     | 4 ++--
 13 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/biopet-framework/src/main/java/nl/lumc/sasc/biopet/wrappers/Ln.scala b/biopet-framework/src/main/java/nl/lumc/sasc/biopet/wrappers/Ln.scala
index f09971730..2764aebf0 100644
--- a/biopet-framework/src/main/java/nl/lumc/sasc/biopet/wrappers/Ln.scala
+++ b/biopet-framework/src/main/java/nl/lumc/sasc/biopet/wrappers/Ln.scala
@@ -5,17 +5,20 @@ import org.broadinstitute.sting.queue.function.CommandLineFunction
 //import org.broadinstitute.sting.queue.function.QFunction
 import org.broadinstitute.sting.commandline._
 import java.io.File
+import scala.sys.process._
 
 class Ln(val globalConfig: Config) extends CommandLineFunction {
   def this() = this(new Config(Map()))
   this.analysisName = "ln"
-  val config: Config = globalConfig.getAsConfig(this.analysisName)
+  val config: Config = Config.mergeConfigs(globalConfig.getAsConfig(analysisName), globalConfig)
   logger.debug("Config for " + this.analysisName + ": " + config)
   
   @Input(doc="Input file") var in: File = _
   @Output(doc="Link destination") var out: File = _
-
-  def commandLine = "ln -sf %s %s".format(in, out)
+    
+  def commandLine = {
+    "ln -sf " + required(in) + required(out)
+  }
 }
 
 object Ln {
diff --git a/biopet-framework/src/main/java/nl/lumc/sasc/biopet/wrappers/Sha1sum.scala b/biopet-framework/src/main/java/nl/lumc/sasc/biopet/wrappers/Sha1sum.scala
index d89e3d9ef..2dded92c2 100644
--- a/biopet-framework/src/main/java/nl/lumc/sasc/biopet/wrappers/Sha1sum.scala
+++ b/biopet-framework/src/main/java/nl/lumc/sasc/biopet/wrappers/Sha1sum.scala
@@ -8,7 +8,7 @@ import java.io.File
 class Sha1sum(val globalConfig: Config) extends CommandLineFunction {
   def this() = this(new Config(Map()))
   this.analysisName = "sha1sum"
-  val config: Config = globalConfig.getAsConfig("sha1sum")
+  val config: Config = Config.mergeConfigs(globalConfig.getAsConfig(analysisName), globalConfig)
   logger.debug("Config for " + this.analysisName + ": " + config)
   
   @Input(doc="Zipped file") var in: File = _
diff --git a/biopet-framework/src/main/java/nl/lumc/sasc/biopet/wrappers/Zcat.scala b/biopet-framework/src/main/java/nl/lumc/sasc/biopet/wrappers/Zcat.scala
index de8b4efdc..206d4bd0d 100644
--- a/biopet-framework/src/main/java/nl/lumc/sasc/biopet/wrappers/Zcat.scala
+++ b/biopet-framework/src/main/java/nl/lumc/sasc/biopet/wrappers/Zcat.scala
@@ -8,7 +8,7 @@ import java.io.File
 class Zcat(val globalConfig: Config) extends CommandLineFunction {
   def this() = this(new Config(Map()))
   this.analysisName = "zcat"
-  val config: Config = globalConfig.getAsConfig("zcat")
+  val config: Config = Config.mergeConfigs(globalConfig.getAsConfig(analysisName), globalConfig)
   logger.debug("Config for " + this.analysisName + ": " + config)
   
   @Input(doc="Zipped file") var in: File = _
diff --git a/flexiprep/src/main/java/nl/lumc/sasc/biopet/pipelines/flexiprep/scripts/FastqSync.scala b/flexiprep/src/main/java/nl/lumc/sasc/biopet/pipelines/flexiprep/scripts/FastqSync.scala
index 131327f65..4b5f179c7 100644
--- a/flexiprep/src/main/java/nl/lumc/sasc/biopet/pipelines/flexiprep/scripts/FastqSync.scala
+++ b/flexiprep/src/main/java/nl/lumc/sasc/biopet/pipelines/flexiprep/scripts/FastqSync.scala
@@ -10,7 +10,7 @@ import java.io.File
 class FastqSync(val globalConfig: Config) extends CommandLineFunction with Python {
   def this() = this(new Config(Map()))
   analysisName = "fastqsync"
-  val config: Config = globalConfig.getAsConfig(analysisName)
+  val config: Config = Config.mergeConfigs(globalConfig.getAsConfig(analysisName), globalConfig)
   logger.debug("Config for " + analysisName + ": " + config)
   
   setPythonScript("__init__.py", "scripts/pyfastqc/")
diff --git a/flexiprep/src/main/java/nl/lumc/sasc/biopet/pipelines/flexiprep/scripts/FastqcToContams.scala b/flexiprep/src/main/java/nl/lumc/sasc/biopet/pipelines/flexiprep/scripts/FastqcToContams.scala
index f72c91277..a0c4e9ff2 100644
--- a/flexiprep/src/main/java/nl/lumc/sasc/biopet/pipelines/flexiprep/scripts/FastqcToContams.scala
+++ b/flexiprep/src/main/java/nl/lumc/sasc/biopet/pipelines/flexiprep/scripts/FastqcToContams.scala
@@ -9,7 +9,7 @@ import java.io.File
 class FastqcToContams(val globalConfig: Config) extends CommandLineFunction with Python {
   def this() = this(new Config(Map()))
   analysisName = "getcontams"
-  val config: Config = globalConfig.getAsConfig(analysisName)
+  val config: Config = Config.mergeConfigs(globalConfig.getAsConfig(analysisName), globalConfig)
   logger.debug("Config for " + analysisName + ": " + config)
   
   setPythonScript("__init__.py", "scripts/pyfastqc/")
diff --git a/flexiprep/src/main/java/nl/lumc/sasc/biopet/pipelines/flexiprep/scripts/FastqcToQualtype.scala b/flexiprep/src/main/java/nl/lumc/sasc/biopet/pipelines/flexiprep/scripts/FastqcToQualtype.scala
index bbdaefa1f..346d88d90 100644
--- a/flexiprep/src/main/java/nl/lumc/sasc/biopet/pipelines/flexiprep/scripts/FastqcToQualtype.scala
+++ b/flexiprep/src/main/java/nl/lumc/sasc/biopet/pipelines/flexiprep/scripts/FastqcToQualtype.scala
@@ -9,7 +9,7 @@ import java.io.File
 class FastqcToQualtype(val globalConfig: Config) extends CommandLineFunction with Python {
   def this() = this(new Config(Map()))
   analysisName = "getqualtype"
-  val config: Config = globalConfig.getAsConfig(analysisName)
+  val config: Config = Config.mergeConfigs(globalConfig.getAsConfig(analysisName), globalConfig)
   logger.debug("Config for " + analysisName + ": " + config)
   
   setPythonScript("__init__.py", "scripts/pyfastqc/")
diff --git a/flexiprep/src/main/java/nl/lumc/sasc/biopet/pipelines/flexiprep/scripts/Seqstat.scala b/flexiprep/src/main/java/nl/lumc/sasc/biopet/pipelines/flexiprep/scripts/Seqstat.scala
index 003b07535..b046872d2 100644
--- a/flexiprep/src/main/java/nl/lumc/sasc/biopet/pipelines/flexiprep/scripts/Seqstat.scala
+++ b/flexiprep/src/main/java/nl/lumc/sasc/biopet/pipelines/flexiprep/scripts/Seqstat.scala
@@ -9,7 +9,7 @@ import java.io.File
 class Seqstat(val globalConfig: Config) extends CommandLineFunction with Python {
   def this() = this(new Config(Map()))
   analysisName = "seqstat"
-  val config: Config = globalConfig.getAsConfig(analysisName)
+  val config: Config = Config.mergeConfigs(globalConfig.getAsConfig(analysisName), globalConfig)
   logger.debug("Config for " + analysisName + ": " + config)
   
   setPythonScript("__init__.py", "scripts/pyfastqc/")
diff --git a/flexiprep/src/main/java/nl/lumc/sasc/biopet/pipelines/flexiprep/scripts/Summarize.scala b/flexiprep/src/main/java/nl/lumc/sasc/biopet/pipelines/flexiprep/scripts/Summarize.scala
index fec2feccc..2375ffaff 100644
--- a/flexiprep/src/main/java/nl/lumc/sasc/biopet/pipelines/flexiprep/scripts/Summarize.scala
+++ b/flexiprep/src/main/java/nl/lumc/sasc/biopet/pipelines/flexiprep/scripts/Summarize.scala
@@ -9,7 +9,7 @@ import java.io.File
 class Summarize(val globalConfig: Config) extends CommandLineFunction with Python {
   def this() = this(new Config(Map()))
   analysisName = "flexiprep_sumarize"
-  val config: Config = globalConfig.getAsConfig(analysisName)
+  val config: Config = Config.mergeConfigs(globalConfig.getAsConfig(analysisName), globalConfig)
   logger.debug("Config for " + analysisName + ": " + config)
   
   setPythonScript("__init__.py", "scripts/pyfastqc/")
diff --git a/flexiprep/src/main/java/nl/lumc/sasc/biopet/wrappers/fastq/Cutadapt.scala b/flexiprep/src/main/java/nl/lumc/sasc/biopet/wrappers/fastq/Cutadapt.scala
index b9bfbaff2..c4c407ec3 100644
--- a/flexiprep/src/main/java/nl/lumc/sasc/biopet/wrappers/fastq/Cutadapt.scala
+++ b/flexiprep/src/main/java/nl/lumc/sasc/biopet/wrappers/fastq/Cutadapt.scala
@@ -10,7 +10,7 @@ import scala.sys.process._
 class Cutadapt(val globalConfig: Config) extends CommandLineFunction {
   def this() = this(new Config(Map()))
   analysisName = "cutadapt"
-  val config: Config = Config.mergeConfigs(globalConfig.getAsConfig("cutadapt"), globalConfig)
+  val config: Config = Config.mergeConfigs(globalConfig.getAsConfig(analysisName), globalConfig)
   logger.debug("Config for " + this.analysisName + ": " + config)
   
   @Input(doc="Cutadapt exe", required=false)
diff --git a/flexiprep/src/main/java/nl/lumc/sasc/biopet/wrappers/fastq/Fastqc.scala b/flexiprep/src/main/java/nl/lumc/sasc/biopet/wrappers/fastq/Fastqc.scala
index 333581a52..36e2e16d7 100644
--- a/flexiprep/src/main/java/nl/lumc/sasc/biopet/wrappers/fastq/Fastqc.scala
+++ b/flexiprep/src/main/java/nl/lumc/sasc/biopet/wrappers/fastq/Fastqc.scala
@@ -9,7 +9,7 @@ import scala.sys.process._
 class Fastqc(val globalConfig: Config) extends CommandLineFunction {
   def this() = this(new Config(Map()))
   this.analysisName = "fastqc"
-  val config: Config = globalConfig.getAsConfig("fastqc")
+  val config: Config = Config.mergeConfigs(globalConfig.getAsConfig(analysisName), globalConfig)
   logger.debug("Config for " + this.analysisName + ": " + config)
   
   @Input(doc="fastqc executeble", shortName="Fastqc_Exe")
diff --git a/flexiprep/src/main/java/nl/lumc/sasc/biopet/wrappers/fastq/Sickle.scala b/flexiprep/src/main/java/nl/lumc/sasc/biopet/wrappers/fastq/Sickle.scala
index bb9b3ac56..156c2cefa 100644
--- a/flexiprep/src/main/java/nl/lumc/sasc/biopet/wrappers/fastq/Sickle.scala
+++ b/flexiprep/src/main/java/nl/lumc/sasc/biopet/wrappers/fastq/Sickle.scala
@@ -10,7 +10,7 @@ import scala.sys.process._
 class Sickle(val globalConfig: Config) extends CommandLineFunction {
   def this() = this(new Config(Map()))
   this.analysisName = "sickle"
-  val config: Config = globalConfig.getAsConfig("sickle")
+  val config: Config = Config.mergeConfigs(globalConfig.getAsConfig(analysisName), globalConfig)
   logger.debug("Config for " + this.analysisName + ": " + config)
   
   @Input(doc="Sickle exe", required=false) var sickle_exe: File = new File(config.getAsString("exe", "/usr/local/bin/sickle"))
diff --git a/mapping/src/main/java/nl/lumc/sasc/biopet/wrappers/aligners/Bwa.scala b/mapping/src/main/java/nl/lumc/sasc/biopet/wrappers/aligners/Bwa.scala
index 905b56f32..f6a5e70f1 100644
--- a/mapping/src/main/java/nl/lumc/sasc/biopet/wrappers/aligners/Bwa.scala
+++ b/mapping/src/main/java/nl/lumc/sasc/biopet/wrappers/aligners/Bwa.scala
@@ -9,7 +9,7 @@ import scala.sys.process._
 class Bwa(val globalConfig: Config) extends CommandLineFunction {
   def this() = this(new Config(Map()))
   this.analysisName = "bwa"
-  val config: Config = Config.mergeConfigs(globalConfig.getAsConfig("bwa"), globalConfig)
+  val config: Config = Config.mergeConfigs(globalConfig.getAsConfig(analysisName), globalConfig)
   logger.debug("Config for " + this.analysisName + ": " + config)
 
   @Argument(doc="Bwa executeble", shortName="bwa_exe", required=false) var bwa_exe: String = config.getAsString("exe", "/usr/local/bin/bwa")
diff --git a/mapping/src/main/java/nl/lumc/sasc/biopet/wrappers/aligners/Star.scala b/mapping/src/main/java/nl/lumc/sasc/biopet/wrappers/aligners/Star.scala
index 0cca136cb..663344054 100644
--- a/mapping/src/main/java/nl/lumc/sasc/biopet/wrappers/aligners/Star.scala
+++ b/mapping/src/main/java/nl/lumc/sasc/biopet/wrappers/aligners/Star.scala
@@ -8,8 +8,8 @@ import scala.sys.process._
 
 class Star(val globalConfig: Config) extends CommandLineFunction {
   def this() = this(new Config(Map()))
-  this.analysisName = "STAR"
-  val config: Config = globalConfig.getAsConfig("star")
+  this.analysisName = "star"
+  val config: Config = Config.mergeConfigs(globalConfig.getAsConfig(analysisName), globalConfig)
   logger.debug("Config for " + this.analysisName + ": " + config)
   
   @Argument(doc="STAR executeble", shortName="star_exe", required=false)
-- 
GitLab