Commit 9b522749 authored by Peter van 't Hof's avatar Peter van 't Hof

Change to option types

parent 89846ab2
......@@ -177,51 +177,51 @@ object BiopetQScript {
require(outputDir.getAbsoluteFile.canWrite, s"No premision to write outputdir: $outputDir")
}
def safeInputs(function: QFunction): Seq[File] = {
def safeInputs(function: QFunction): Option[Seq[File]] = {
try {
function.inputs
Some(function.inputs)
} catch {
case e: NullPointerException => Seq()
case e: NullPointerException => None
}
}
def safeOutputs(function: QFunction): Seq[File] = {
def safeOutputs(function: QFunction): Option[Seq[File]] = {
try {
function.outputs
Some(function.outputs)
} catch {
case e: NullPointerException => Seq()
case e: NullPointerException => None
}
}
def safeDoneFiles(function: QFunction): Seq[File] = {
def safeDoneFiles(function: QFunction): Option[Seq[File]] = {
try {
function.doneOutputs
Some(function.doneOutputs)
} catch {
case e: NullPointerException => Seq()
case e: NullPointerException => None
}
}
def safeFailFiles(function: QFunction): Seq[File] = {
def safeFailFiles(function: QFunction): Option[Seq[File]] = {
try {
function.failOutputs
Some(function.failOutputs)
} catch {
case e: NullPointerException => Seq()
case e: NullPointerException => None
}
}
def safeIsDone(function: QFunction): Boolean = {
def safeIsDone(function: QFunction): Option[Boolean] = {
try {
function.isDone
Some(function.isDone)
} catch {
case e: NullPointerException => false
case e: NullPointerException => None
}
}
def safeIsFail(function: QFunction): Boolean = {
def safeIsFail(function: QFunction): Option[Boolean] = {
try {
function.isFail
Some(function.isFail)
} catch {
case e: NullPointerException => false
case e: NullPointerException => None
}
}
......
......@@ -91,12 +91,12 @@ object WriteDependencies extends Logging with Configurable {
val files: mutable.Map[File, QueueFile] = mutable.Map()
for (function <- functions) {
for (input <- BiopetQScript.safeInputs(function)) {
for (input <- BiopetQScript.safeInputs(function).getOrElse(Seq())) {
val file = files.getOrElse(input, QueueFile(input))
file.addInputJob(function)
files += input -> file
}
for (output <- BiopetQScript.safeOutputs(function)) {
for (output <- BiopetQScript.safeOutputs(function).getOrElse(Seq())) {
val file = files.getOrElse(output, QueueFile(output))
file.addOutputJob(function)
files += output -> file
......@@ -113,13 +113,13 @@ object WriteDependencies extends Logging with Configurable {
case s: WriteSummary if s.qscript.root == null => true
case _ => false
}), "intermediate" -> f.isIntermediate,
"depends_on_intermediate" -> BiopetQScript.safeOutputs(f).exists(files(_).isIntermediate),
"depends_on_jobs" -> BiopetQScript.safeOutputs(f).toList.flatMap(files(_).outputJobNames).distinct,
"output_used_by_jobs" -> BiopetQScript.safeOutputs(f).toList.flatMap(files(_).inputJobNames).distinct,
"outputs" -> BiopetQScript.safeOutputs(f).toList,
"inputs" -> BiopetQScript.safeOutputs(f).toList,
"done_files" -> BiopetQScript.safeDoneFiles(f).toList,
"fail_files" -> BiopetQScript.safeFailFiles(f).toList,
"depends_on_intermediate" -> BiopetQScript.safeOutputs(f).getOrElse(Seq()).exists(files(_).isIntermediate),
"depends_on_jobs" -> BiopetQScript.safeOutputs(f).getOrElse(Seq()).toList.flatMap(files(_).outputJobNames).distinct,
"output_used_by_jobs" -> BiopetQScript.safeOutputs(f).getOrElse(Seq()).toList.flatMap(files(_).inputJobNames).distinct,
"outputs" -> BiopetQScript.safeOutputs(f).getOrElse(Seq()).toList,
"inputs" -> BiopetQScript.safeOutputs(f).getOrElse(Seq()).toList,
"done_files" -> BiopetQScript.safeDoneFiles(f).getOrElse(Seq()).toList,
"fail_files" -> BiopetQScript.safeFailFiles(f).getOrElse(Seq()).toList,
"stdout_file" -> f.jobOutputFile,
"done_at_start" -> BiopetQScript.safeIsDone(f),
"fail_at_start" -> BiopetQScript.safeIsFail(f))
......
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