Commit fe65dd17 authored by Peter van 't Hof's avatar Peter van 't Hof

Added sanity checks for outputDir

parent 531c04b7
......@@ -38,6 +38,8 @@ trait BiopetQScript extends Configurable with GatkLogging { qscript: QScript =>
if (config.contains("output_dir", path = Nil)) config("output_dir", path = Nil).asFile
else new File(".")
}
require(outputDir.canRead, s"No premision to read outputdir: $outputDir")
require(outputDir.canWrite, s"No premision to read outputdir: $outputDir")
@Argument(doc = "Disable all scatters", shortName = "DSC", required = false)
var disableScatter: Boolean = false
......@@ -67,6 +69,9 @@ trait BiopetQScript extends Configurable with GatkLogging { qscript: QScript =>
final def script() {
outputDir = config("output_dir")
outputDir = outputDir.getAbsoluteFile
BiopetQScript.checkOutputDir(outputDir)
init()
biopetScript()
logger.info("Biopet script done")
......@@ -153,4 +158,13 @@ trait BiopetQScript extends Configurable with GatkLogging { qscript: QScript =>
object BiopetQScript {
case class InputFile(file: File, md5: Option[String] = None)
def checkOutputDir(outputDir: File): Unit = {
// Sanity checks
require(outputDir.getParentFile.canRead, s"No premision to read parent of outputdir: ${outputDir.getParentFile}")
require(outputDir.getParentFile.canWrite, s"No premision to write parent of outputdir: ${outputDir.getParentFile}")
outputDir.mkdir()
require(outputDir.canRead, s"No premision to read outputdir: $outputDir")
require(outputDir.canWrite, s"No premision to write outputdir: $outputDir")
}
}
......@@ -77,6 +77,7 @@ trait PipelineCommand extends MainCommand with GatkLogging with ImplicitConversi
val pipelineName = this.getClass.getSimpleName.toLowerCase.split("""\$""").head
val pipelineConfig = globalConfig.map.getOrElse(pipelineName, Map()).asInstanceOf[Map[String, Any]]
val pipelineOutputDir = new File(globalConfig.map.getOrElse("output_dir", pipelineConfig.getOrElse("output_dir", "./")).toString)
BiopetQScript.checkOutputDir(pipelineOutputDir)
val logDir: File = new File(pipelineOutputDir, ".log")
logDir.mkdirs()
new File(logDir, "biopet." + BiopetQCommandLine.timestamp + ".log")
......
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