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
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 {}
//TODO: function need rename to beforeGraph
......@@ -123,7 +124,10 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab
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)
}
......@@ -166,6 +170,8 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab
/** Get version from cache otherwise execute the version command */
def getVersion: String = {
if (!BiopetCommandLineFunctionTrait.executableCache.contains(executable))
checkExecutable
if (!BiopetCommandLineFunctionTrait.versionCache.contains(executable))
BiopetCommandLineFunctionTrait.versionCache += executable -> getVersionInternal
return BiopetCommandLineFunctionTrait.versionCache(executable)
......
......@@ -73,12 +73,14 @@ trait BiopetQScript extends Configurable with GatkLogging {
case f: BiopetCommandLineFunctionTrait => {
f.checkExecutable
f.afterGraph
f.commandLine
}
case _ =>
}
if (outputDir.canWrite) globalConfig.writeReport(qSettings.runName, outputDir + ".log/" + qSettings.runName)
else BiopetQScript.addError("Output dir: '" + outputDir + "' is not writeable")
if (outputDir.getParentFile.canWrite || (outputDir.exists && outputDir.canWrite))
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
}
......
......@@ -140,7 +140,8 @@ class Config(var map: Map[String, Any]) extends Logging {
} 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] = {
input.foldLeft(Map[String, Any]())(
......@@ -155,8 +156,7 @@ class Config(var map: Map[String, Any]) extends Logging {
}
def writeMapToJsonFile(map: Map[String, Any], name: String): Unit = {
val file = new File(directory + "/" + id + "." + name + ".json")
file.getParentFile.mkdirs()
val file = new File(directory, id + "." + name + ".json")
val writer = new PrintWriter(file)
writer.write(ConfigUtils.mapToJson(map).spaces2)
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