diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetCommandLineFunctionTrait.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetCommandLineFunctionTrait.scala index 4a5b25f7a5b816fe32ad39897a334a6e13fe1eda..a9cb89d93e36333d91e0d030a95328ac31802435 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetCommandLineFunctionTrait.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetCommandLineFunctionTrait.scala @@ -66,7 +66,7 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab super.freezeFieldValues() } - protected def checkExecutable { + protected[core] def checkExecutable { if (!BiopetCommandLineFunctionTrait.executableMd5Cache.contains(executable)) { try if (executable != null) { if (!BiopetCommandLineFunctionTrait.executableCache.contains(executable)) { @@ -79,8 +79,7 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab val file = new File(executable) executable = file.getCanonicalPath } else { - logger.error("executable: '" + executable + "' not found, please check config") - throw new QException("executable: '" + executable + "' not found, please check config") + BiopetQScript.addError("executable: '" + executable + "' not found, please check config") } BiopetCommandLineFunctionTrait.executableCache += oldExecutable -> executable BiopetCommandLineFunctionTrait.executableCache += executable -> executable @@ -101,9 +100,8 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab case ioe: java.io.IOException => logger.warn("Could not use 'which', check on executable skipped: " + ioe) } } - val md5 = BiopetCommandLineFunctionTrait.executableMd5Cache(executable) - if (md5 == null) addJobReportBinding("md5sum_exe", md5) - else addJobReportBinding("md5sum_exe", "None") + val md5 = BiopetCommandLineFunctionTrait.executableMd5Cache.get(executable) + addJobReportBinding("md5sum_exe", md5.getOrElse("None")) } final protected def preCmdInternal { @@ -120,6 +118,11 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab protected val versionExitcode = List(0) // Can select multiple private def getVersionInternal: String = { if (versionCommand == null || versionRegex == null) return "N/A" + val exe = new File(versionCommand.trim.split(" ")(0)) + if (!exe.exists()) { + //BiopetQScript.addError("executable '" + exe + "' does not exist") + return "N/A" + } val stdout = new StringBuffer() val stderr = new StringBuffer() def outputLog = "Version command: \n" + versionCommand + diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala index 93cf7ebb16e397db26ad8912a92c74b40cd5c80e..ba0dc2c6d956e4db78189afa3542ebbc7911266b 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala @@ -33,7 +33,7 @@ trait BiopetQScript extends Configurable with GatkLogging { var outputDir: String = { val temp = Config.getValueFromMap(Config.global.map, ConfigValueIndex(this.configName, configPath, "output_dir")) - if (temp.isEmpty) throw new IllegalArgumentException("No output_dir defined in config") + if (temp.isEmpty) "" else { val t = temp.get.value.toString if (!t.endsWith("/")) t + "/" else t @@ -54,7 +54,8 @@ trait BiopetQScript extends Configurable with GatkLogging { final def script() { outputDir = config("output_dir") - if (!outputDir.endsWith("/")) outputDir += "/" + if (outputDir.isEmpty) outputDir = new File(".").getAbsolutePath() + else if (!outputDir.endsWith("/")) outputDir += "/" init biopetScript @@ -63,11 +64,15 @@ trait BiopetQScript extends Configurable with GatkLogging { case _ => } for (function <- functions) function match { - case f: BiopetCommandLineFunctionTrait => f.afterGraph + case f: BiopetCommandLineFunctionTrait => { + f.checkExecutable + f.afterGraph + } case _ => } - Config.global.writeReport(qSettings.runName, outputDir + ".log/" + qSettings.runName) + if (new File(outputDir).canWrite) Config.global.writeReport(qSettings.runName, outputDir + ".log/" + qSettings.runName) + else BiopetQScript.addError("Output dir: '" + outputDir + "' is not writeable") BiopetQScript.checkErrors } @@ -82,15 +87,23 @@ trait BiopetQScript extends Configurable with GatkLogging { object BiopetQScript extends Logging { private val errors: ListBuffer[Exception] = ListBuffer() - def addError(msg: String): Unit = { + def addError(error: String, debug: String = null): Unit = { + val msg = error + (if (debug != null && logger.isDebugEnabled) "; " + debug else "") errors.append(new Exception(msg)) } protected def checkErrors: Unit = { if (!errors.isEmpty) { - for (e <- errors) { - logger.error(e.getMessage) - logger.debug(e.getStackTrace.mkString("Stack trace:\n", "\n", "\n")) + logger.error("*************************") + logger.error("Biopet found some errors:") + if (logger.isDebugEnabled) { + for (e <- errors) { + logger.error(e.getMessage) + logger.debug(e.getStackTrace.mkString("Stack trace:\n", "\n", "\n")) + } + } else { + val set = errors.map(_.getMessage).toSet + set.toList.sorted.foreach(logger.error(_)) } throw new IllegalStateException("Biopet found errors") } diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/Fastqc.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/Fastqc.scala index fed5e514be34618f41d2e8348eba6d15e67fab29..7bda8792544eea2d863ab06192b51b55ae900077 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/Fastqc.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/Fastqc.scala @@ -51,7 +51,7 @@ class Fastqc(val root: Configurable) extends BiopetCommandLineFunction { override def afterGraph { this.checkExecutable - val fastqcDir = executable.substring(0, executable.lastIndexOf("/")) + val fastqcDir = new File(executable).getParent contaminants = contaminants match { // user-defined contaminants file take precedence diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/ConfigUtils.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/ConfigUtils.scala index 47e7d1af8d21add7744613806ea7520d82cbf04d..2c9165036824f135f9552b69fa3b4085be25fc93 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/ConfigUtils.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/ConfigUtils.scala @@ -335,8 +335,8 @@ object ConfigUtils extends Logging { val exist = valueExists(value) if (!exist) BiopetQScript.addError("Value does not exist but is required, key: " + value.requestIndex.key + - " module: " + value.requestIndex.module + - (if (value.requestIndex.path != Nil) " path: " + value.requestIndex.path.mkString("->") else "")) + " module: " + value.requestIndex.module, + (if (value.requestIndex.path != Nil) " path: " + value.requestIndex.path.mkString("->") else null)) exist }