Commit 325ed2b1 authored by Peter van 't Hof's avatar Peter van 't Hof

Fixing failing test

parent f4ab0677
......@@ -177,4 +177,52 @@ object BiopetQScript {
require(outputDir.getAbsoluteFile.canWrite, s"No premision to write outputdir: $outputDir")
}
def safeInputs(function: QFunction): Seq[File] = {
try {
function.inputs
} catch {
case e: NullPointerException => Seq()
}
}
def safeOutputs(function: QFunction): Seq[File] = {
try {
function.outputs
} catch {
case e: NullPointerException => Seq()
}
}
def safeDoneFiles(function: QFunction): Seq[File] = {
try {
function.doneOutputs
} catch {
case e: NullPointerException => Seq()
}
}
def safeFailFiles(function: QFunction): Seq[File] = {
try {
function.failOutputs
} catch {
case e: NullPointerException => Seq()
}
}
def safeIsDone(function: QFunction): Boolean = {
try {
function.isDone
} catch {
case e: NullPointerException => false
}
}
def safeIsFail(function: QFunction): Boolean = {
try {
function.isFail
} catch {
case e: NullPointerException => false
}
}
}
......@@ -146,12 +146,12 @@ trait MultiSampleQScript extends SummaryQScript { qscript: QScript =>
} catch {
case e: IllegalStateException if e.getMessage == "Value is not a map: library" =>
Logging.addError("libraries is not a map")
Set("placeholder")
Set()
}
if (ids.isEmpty) {
Logging.addError(s"No libraries found in config for sample $sampleId")
}
ids
Set("placeholder")
} else ids
}
/** Name overules the one from qscript */
......
......@@ -90,18 +90,13 @@ object WriteDependencies extends Logging with Configurable {
val files: mutable.Map[File, QueueFile] = mutable.Map()
def outputFiles(function: QFunction) = {
if (function.jobErrorFile == null) function.outputs :+ function.jobOutputFile
else function.outputs :+ function.jobOutputFile :+ function.jobErrorFile
}
for (function <- functions) {
for (input <- function.inputs) {
for (input <- BiopetQScript.safeInputs(function)) {
val file = files.getOrElse(input, QueueFile(input))
file.addInputJob(function)
files += input -> file
}
for (output <- outputFiles(function)) {
for (output <- BiopetQScript.safeOutputs(function)) {
val file = files.getOrElse(output, QueueFile(output))
file.addOutputJob(function)
files += output -> file
......@@ -118,16 +113,16 @@ object WriteDependencies extends Logging with Configurable {
case s: WriteSummary if s.qscript.root == null => true
case _ => false
}), "intermediate" -> f.isIntermediate,
"depends_on_intermediate" -> f.inputs.exists(files(_).isIntermediate),
"depends_on_jobs" -> f.inputs.toList.flatMap(files(_).outputJobNames).distinct,
"output_used_by_jobs" -> outputFiles(f).toList.flatMap(files(_).inputJobNames).distinct,
"outputs" -> outputFiles(f).toList,
"inputs" -> f.inputs.toList,
"done_files" -> f.doneOutputs.toList,
"fail_files" -> f.failOutputs.toList,
"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,
"stdout_file" -> f.jobOutputFile,
"done_at_start" -> f.isDone,
"fail_at_start" -> f.isFail)
"done_at_start" -> BiopetQScript.safeIsDone(f),
"fail_at_start" -> BiopetQScript.safeIsFail(f))
}.toIterator.toMap
val outputFile = new File(outputDir, s"deps.json")
......
......@@ -15,11 +15,12 @@
package nl.lumc.sasc.biopet.core
import java.io.File
import nl.lumc.sasc.biopet.core.MultiSampleQScript.Gender
import nl.lumc.sasc.biopet.core.extensions.Md5sum
import nl.lumc.sasc.biopet.utils.{ ConfigUtils, Logging }
import nl.lumc.sasc.biopet.utils.{ConfigUtils, Logging}
import nl.lumc.sasc.biopet.utils.config.Config
import org.broadinstitute.gatk.queue.QScript
import org.broadinstitute.gatk.queue.{QScript, QSettings}
import org.scalatest.Matchers
import org.scalatest.testng.TestNGSuite
import org.testng.annotations.Test
......@@ -121,7 +122,7 @@ class MultiSampleQScriptTest extends TestNGSuite with Matchers {
@Test
def testNoLibSample(): Unit = {
an[IllegalStateException] shouldBe thrownBy(MultiSampleQScriptTest(noLibSample :: Nil))
an[IllegalStateException] shouldBe thrownBy(MultiSampleQScriptTest(Map("output_dir" -> ".") :: noLibSample :: Nil).script())
}
}
......@@ -203,6 +204,9 @@ object MultiSampleQScriptTest {
def apply(configs: List[Map[String, Any]], only: List[String] = Nil) = {
new QScript with MultiSampleQScript { qscript =>
qSettings = new QSettings()
qSettings.runName = "test"
override val onlySamples = only
var buffer = new ListBuffer[String]()
......@@ -272,7 +276,7 @@ object MultiSampleQScriptTest {
def summaryFiles: Map[String, File] = Map()
/** Name of summary output file */
def summaryFile: File = null
def summaryFile: File = new File("./summary.json")
/** Init for pipeline */
def init(): Unit = {
......
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