Commit ecd3dd97 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Added testing

parent 22201b39
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
import nl.lumc.sasc.biopet.utils.config.Config
import org.broadinstitute.gatk.queue.QScript
......@@ -7,9 +11,7 @@ import org.scalatest.Matchers
import org.scalatest.testng.TestNGSuite
import org.testng.annotations.Test
import scala.collection.mutable.{ListBuffer, StringBuilder}
import scalaz._
import Scalaz._
import scala.collection.mutable.ListBuffer
/**
* Created by pjvan_thof on 12/29/15.
......@@ -18,27 +20,91 @@ class MultiSampleQScriptTest extends TestNGSuite with Matchers {
import MultiSampleQScriptTest._
@Test
def test: Unit = {
def testDefault: Unit = {
val script = MultiSampleQScriptTest(sample1 :: sample2 :: sample3 :: Nil)
script.outputDir = new File("./").getAbsoluteFile
script.init()
script.biopetScript()
script.functions.size shouldBe 4
script.samples.foreach { case (sampleId, sample) =>
sample.gender shouldBe Gender.Unknown
sample.father shouldBe None
sample.mother shouldBe None
sample.summaryFiles shouldBe Map()
sample.summaryStats shouldBe Map()
sample.summarySettings shouldBe Map()
sample.sampleDir shouldBe new File(script.outputDir, "samples" + File.separator + sampleId)
sample.createFile("bla.txt") shouldBe new File(sample.sampleDir, s"$sampleId.bla.txt")
sample.libraries.foreach { case (libId, library) =>
library.libDir shouldBe new File(sample.sampleDir, s"lib_$libId")
library.createFile("bla.txt") shouldBe new File(library.libDir, s"$sampleId-$libId.bla.txt")
library.summaryFiles shouldBe Map()
library.summaryStats shouldBe Map()
library.summarySettings shouldBe Map()
}
}
}
@Test
def testTrio: Unit = {
val script = MultiSampleQScriptTest(child :: father :: mother :: Nil)
script.init()
script.biopetScript()
script.functions.size shouldBe 4
script.samples("child").gender shouldBe Gender.Male
script.samples("father").gender shouldBe Gender.Male
script.samples("mother").gender shouldBe Gender.Female
script.samples("child").father shouldBe Some("father")
script.samples("child").mother shouldBe Some("mother")
}
@Test
def testGroups: Unit = {
val script = MultiSampleQScriptTest(sample1 :: sample2 :: sample3 :: Nil)
script.init()
script.biopetScript()
val bla = MultiSampleQScriptTest(sample1 :: sample2 :: sample3 :: child :: father :: mother :: Nil)
bla.init()
bla.biopetScript()
script.functions.size shouldBe 4
bla.samples.foreach(_._2.gender)
script.samples("sample1").sampleGroups shouldBe List("1")
script.samples("sample1").libraries("lib1").libGroups shouldBe List("1")
script.samples("sample2").sampleGroups shouldBe List("2")
script.samples("sample2").libraries("lib1").libGroups shouldBe List("3")
//println(bla.buffer.toString())
script.samples("sample3").sampleGroups shouldBe Nil
}
@Test
def testOnlySamples: Unit = {
val script = MultiSampleQScriptTest(sample1 :: sample2 :: sample3 :: Nil, List("sample1"))
script.init()
script.biopetScript()
script.functions.size shouldBe 1
}
}
object MultiSampleQScriptTest {
val sample1 = Map("samples" -> Map("sample1" -> Map("libraries" -> Map(
"lib1" -> Map("test" -> "1-1")
))))
val sample2 = Map("samples" -> Map("sample2" -> Map("libraries" -> Map(
"lib1" -> Map("test" -> "2-1"),
"lib2" -> Map("test" -> "2-2")
))))
val sample1 = Map("samples" -> Map("sample1" -> Map(
"gender" -> "blablablablabla",
"groups" -> List("1"),
"libraries" -> Map(
"lib1" -> Map("test" -> "1-1")
)))
)
val sample2 = Map("samples" -> Map("sample2" -> Map(
"groups" -> List("2"),
"libraries" -> Map(
"lib1" -> Map("test" -> "2-1", "groups" -> List("3")),
"lib2" -> Map("test" -> "2-2")
))))
val sample3 = Map("samples" -> Map("sample3" -> Map("libraries" -> Map(
"lib1" -> Map("test" -> "3-1"),
......@@ -50,8 +116,10 @@ object MultiSampleQScriptTest {
val father = Map("samples" -> Map("father" -> Map("gender" -> "male")))
val mother = Map("samples" -> Map("mother" -> Map("gender" -> "female")))
def apply(configs: List[Map[String, Any]]) = {
new QScript with MultiSampleQScript {
def apply(configs: List[Map[String, Any]], only: List[String] = Nil) = {
new QScript with MultiSampleQScript { qscript =>
override val onlySamples = only
var buffer = new ListBuffer[String]()
......@@ -84,6 +152,7 @@ object MultiSampleQScriptTest {
protected def addJobs(): Unit = {
buffer += s"$sampleId"
addPerLibJobs()
add(new Md5sum(qscript))
}
/** Must return files to store into summary */
......@@ -97,6 +166,7 @@ object MultiSampleQScriptTest {
* Method where the multisample jobs should be added, this will be executed only when running the -sample argument is not given.
*/
def addMultiSampleJobs(): Unit = {
add(new Md5sum(qscript))
}
/**
......
Supports Markdown
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