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