Commit 21fba762 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Fix some small bugs

parent 2a906887
...@@ -48,7 +48,8 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab ...@@ -48,7 +48,8 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab
protected[core] def beforeCmd {} protected[core] def beforeCmd {}
/** /**
* Can override this method. This is executed after the script is done en queue starts to generate the graph * Can overr
* ide this method. This is executed after the script is done en queue starts to generate the graph
*/ */
protected[core] def afterGraph {} protected[core] def afterGraph {}
//TODO: function need rename to beforeGraph //TODO: function need rename to beforeGraph
...@@ -123,7 +124,10 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab ...@@ -123,7 +124,10 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab
beforeCmd beforeCmd
addJobReportBinding("cores", if (nCoresRequest.get.toInt > 0) nCoresRequest.get.toInt else 1) addJobReportBinding("cores", nCoresRequest match {
case Some(n) if n > 0 => n
case _ => 1
})
addJobReportBinding("version", getVersion) addJobReportBinding("version", getVersion)
} }
...@@ -166,6 +170,8 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab ...@@ -166,6 +170,8 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab
/** Get version from cache otherwise execute the version command */ /** Get version from cache otherwise execute the version command */
def getVersion: String = { def getVersion: String = {
if (!BiopetCommandLineFunctionTrait.executableCache.contains(executable))
checkExecutable
if (!BiopetCommandLineFunctionTrait.versionCache.contains(executable)) if (!BiopetCommandLineFunctionTrait.versionCache.contains(executable))
BiopetCommandLineFunctionTrait.versionCache += executable -> getVersionInternal BiopetCommandLineFunctionTrait.versionCache += executable -> getVersionInternal
return BiopetCommandLineFunctionTrait.versionCache(executable) return BiopetCommandLineFunctionTrait.versionCache(executable)
......
...@@ -73,12 +73,14 @@ trait BiopetQScript extends Configurable with GatkLogging { ...@@ -73,12 +73,14 @@ trait BiopetQScript extends Configurable with GatkLogging {
case f: BiopetCommandLineFunctionTrait => { case f: BiopetCommandLineFunctionTrait => {
f.checkExecutable f.checkExecutable
f.afterGraph f.afterGraph
f.commandLine
} }
case _ => case _ =>
} }
if (outputDir.canWrite) globalConfig.writeReport(qSettings.runName, outputDir + ".log/" + qSettings.runName) if (outputDir.getParentFile.canWrite || (outputDir.exists && outputDir.canWrite))
else BiopetQScript.addError("Output dir: '" + outputDir + "' is not writeable") globalConfig.writeReport(qSettings.runName, new File(outputDir, ".log/" + qSettings.runName))
else BiopetQScript.addError("Parent of output dir: '" + outputDir.getParent + "' is not writeable, outputdir can not be created")
BiopetQScript.checkErrors BiopetQScript.checkErrors
} }
......
...@@ -140,7 +140,8 @@ class Config(var map: Map[String, Any]) extends Logging { ...@@ -140,7 +140,8 @@ class Config(var map: Map[String, Any]) extends Logging {
} else ConfigValue(requestedIndex, null, null, freeVar) } else ConfigValue(requestedIndex, null, null, freeVar)
} }
def writeReport(id: String, directory: String): Unit = { def writeReport(id: String, directory: File): Unit = {
directory.mkdirs()
def convertIndexValuesToMap(input: List[(ConfigValueIndex, Any)], forceFreeVar: Option[Boolean] = None): Map[String, Any] = { def convertIndexValuesToMap(input: List[(ConfigValueIndex, Any)], forceFreeVar: Option[Boolean] = None): Map[String, Any] = {
input.foldLeft(Map[String, Any]())( input.foldLeft(Map[String, Any]())(
...@@ -155,8 +156,7 @@ class Config(var map: Map[String, Any]) extends Logging { ...@@ -155,8 +156,7 @@ class Config(var map: Map[String, Any]) extends Logging {
} }
def writeMapToJsonFile(map: Map[String, Any], name: String): Unit = { def writeMapToJsonFile(map: Map[String, Any], name: String): Unit = {
val file = new File(directory + "/" + id + "." + name + ".json") val file = new File(directory, id + "." + name + ".json")
file.getParentFile.mkdirs()
val writer = new PrintWriter(file) val writer = new PrintWriter(file)
writer.write(ConfigUtils.mapToJson(map).spaces2) writer.write(ConfigUtils.mapToJson(map).spaces2)
writer.close() writer.close()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment