Commit 7e0576ae authored by Sander Bollen's avatar Sander Bollen

tarmac testing

parent 020acbfe
...@@ -111,10 +111,11 @@ trait MultiSampleQScript extends SummaryQScript { qscript: QScript => ...@@ -111,10 +111,11 @@ trait MultiSampleQScript extends SummaryQScript { qscript: QScript =>
lazy val father = { lazy val father = {
val g: Option[String] = sampleTags.get("father").map(_.toString) val g: Option[String] = sampleTags.get("father").map(_.toString)
g.foreach { father => g.foreach { father =>
if (sampleId != father) Logging.addError(s"Father for $sampleId can not be itself") if (sampleId == father) Logging.addError(s"Father for $sampleId can not be itself")
if (samples.contains(father)) if (samples(father).gender != Gender.Male) if (samples.contains(father)) {
Logging.addError(s"Father of $sampleId is not a male") if (samples(father).gender != Gender.Male)
else logger.warn(s"For sample '$sampleId' is father '$father' not found in config") Logging.addError(s"Father of $sampleId is not a male")
} else logger.warn(s"For sample '$sampleId' is father '$father' not found in config")
} }
g g
} }
...@@ -122,10 +123,11 @@ trait MultiSampleQScript extends SummaryQScript { qscript: QScript => ...@@ -122,10 +123,11 @@ trait MultiSampleQScript extends SummaryQScript { qscript: QScript =>
lazy val mother = { lazy val mother = {
val g: Option[String] = sampleTags.get("mother").map(_.toString) val g: Option[String] = sampleTags.get("mother").map(_.toString)
g.foreach { mother => g.foreach { mother =>
if (sampleId != mother) Logging.addError(s"mother for $sampleId can not be itself") if (sampleId == mother) Logging.addError(s"mother for $sampleId can not be itself")
if (samples.contains(mother)) if (samples(mother).gender != Gender.Female) if (samples.contains(mother)) {
Logging.addError(s"Mother of $sampleId is not a female") if (samples(mother).gender != Gender.Female)
else logger.warn(s"For sample '$sampleId' is mother '$mother' not found in config") Logging.addError(s"Mother of $sampleId is not a female")
} else logger.warn(s"For sample '$sampleId' is mother '$mother' not found in config")
} }
g g
} }
......
...@@ -21,7 +21,7 @@ import scalaz.{ -\/, \/, \/- } ...@@ -21,7 +21,7 @@ import scalaz.{ -\/, \/, \/- }
class Tarmac(val parent: Configurable) extends QScript with PedigreeQscript with SummaryQScript with Reference { class Tarmac(val parent: Configurable) extends QScript with PedigreeQscript with SummaryQScript with Reference {
qscript => qscript =>
private val targets: File = config("targets") lazy val targets: File = config("targets")
def this() = this(null) def this() = this(null)
/* Fixed values for xhmm count file */ /* Fixed values for xhmm count file */
...@@ -233,6 +233,9 @@ class Tarmac(val parent: Configurable) extends QScript with PedigreeQscript with ...@@ -233,6 +233,9 @@ class Tarmac(val parent: Configurable) extends QScript with PedigreeQscript with
/** Must return files to store into summary */ /** Must return files to store into summary */
def summaryFiles: Map[String, File] = Map() def summaryFiles: Map[String, File] = Map()
/** Libs do not exist for this pipeline */
override def libIds: Set[String] = Set()
/** Must returns stats to store into summary */ /** Must returns stats to store into summary */
def summaryStats: Any = Map() def summaryStats: Any = Map()
} }
......
fam02 sample4 sample5 sample6 2 2
fam02 sample5 0 0 1 1
fam02 sample6 0 0 2 1
package nl.lumc.sasc.biopet.pipelines.tarmac
import java.nio.file.Paths
import nl.lumc.sasc.biopet.extensions.Ln
import nl.lumc.sasc.biopet.extensions.gatk.DepthOfCoverage
import nl.lumc.sasc.biopet.extensions.wisecondor.{WisecondorCount, WisecondorNewRef}
import nl.lumc.sasc.biopet.extensions.xhmm.XhmmMergeGatkDepths
import nl.lumc.sasc.biopet.utils.ConfigUtils
import nl.lumc.sasc.biopet.utils.config.Config
import org.broadinstitute.gatk.queue.QSettings
import org.scalatest.Matchers
import org.scalatest.testng.TestNGSuite
import org.testng.annotations.Test
/**
* Created by Sander Bollen on 13-4-17.
*/
class TarmacTest extends TestNGSuite with Matchers {
private def resourcePath(p: String): String = {
Paths.get(getClass.getResource(p).toURI).toString
}
val sample2 = Map("samples" ->
Map("sample2" ->
Map("tags" ->
Map("gender" -> "male",
"family" -> "fam01"
)
)
)
)
val samplesWithBam = Map(
"samples" -> Map(
"sample1" -> Map(
"tags" -> Map(
"gender" -> "female",
"father" -> "sample2",
"mother" -> "sample3",
"family" -> "fam01"
),
"bam" -> "sample1.bam"
),
"sample2" -> Map(
"tags" -> Map(
"gender" -> "male",
"family" -> "fam01"
),
"bam" -> "sample2.bam"
),
"sample3" -> Map(
"tags" -> Map(
"gender" -> "female",
"family" -> "fam01"
),
"bam" -> "sample3.bam"
),
"sample4" -> Map(
"tags" -> Map(
"gender" -> "female",
"family" -> "fam02"
),
"bam" -> "sample4.bam"
),
"sample5" -> Map(
"tags" -> Map(
"gender" -> "female",
"family" -> "fam02"
),
"bam" -> "sample5.bam"
),
"sample6" -> Map(
"tags" -> Map(
"gender" -> "male",
"family" -> "fam02"
),
"bam" -> "sample6.bam"
),
"sample7" -> Map(
"tags" -> Map(
"gender" -> "male",
"family" -> "fam02"
),
"bam" -> "sample7.bam"
)
)
)
val samplesWithCount = Map(
"samples" -> Map(
"sample1" -> Map(
"tags" -> Map(
"gender" -> "female",
"father" -> "sample2",
"mother" -> "sample3",
"family" -> "fam01"
),
"xhmm_count_file" -> "sample1.xhmm",
"wisecondor_count_file" -> "sample1.bed"
),
"sample2" -> Map(
"tags" -> Map(
"gender" -> "male",
"family" -> "fam01"
),
"xhmm_count_file" -> "sample2.xhmm",
"wisecondor_count_file" -> "sample2.bed"
),
"sample3" -> Map(
"tags" -> Map(
"gender" -> "female",
"family" -> "fam01"
),
"xhmm_count_file" -> "sample3.xhmm",
"wisecondor_count_file" -> "sample3.bed"
),
"sample4" -> Map(
"tags" -> Map(
"gender" -> "female",
"family" -> "fam02"
),
"xhmm_count_file" -> "sample4.xhmm",
"wisecondor_count_file" -> "sample4.bed"
),
"sample5" -> Map(
"tags" -> Map(
"gender" -> "female",
"family" -> "fam02"
),
"xhmm_count_file" -> "sample5.xhmm",
"wisecondor_count_file" -> "sample5.bed"
),
"sample6" -> Map(
"tags" -> Map(
"gender" -> "male",
"family" -> "fam02"
),
"xhmm_count_file" -> "sample6.xhmm",
"wisecondor_count_file" -> "sample6.bed"
),
"sample7" -> Map(
"tags" -> Map(
"gender" -> "male",
"family" -> "fam02"
),
"xhmm_count_file" -> "sample7.xhmm",
"wisecondor_count_file" -> "sample7.bed"
)
)
)
val settings = Map(
"gatk_jar" -> "gatk.jar",
"discover_params" -> "discover_params",
"tarmac" -> Map(
"targets" -> "targets.bed"
)
)
def initPipeline(map: Map[String, Any]): Tarmac = {
new Tarmac {
override def configNamespace = "tarmac"
override def globalConfig = new Config(map)
qSettings = new QSettings
qSettings.runName = "test"
}
}
@Test
def testSingleSampleLeft(): Unit = {
val script = initPipeline(sample2)
script.init()
script.samples.size shouldBe 1
script.samples.head._2.outputXhmmCountFile.isLeft shouldBe true
script.samples.head._2.outputWisecondorCountFile.isLeft shouldBe true
}
@Test
def testCountGeneration(): Unit = {
val script = initPipeline(ConfigUtils.mergeMaps(samplesWithBam, settings))
script.init()
script.addSamplesJobs()
script.samples.size shouldBe 7
script.functions.count(_.isInstanceOf[WisecondorCount]) shouldBe 7
script.functions.count(_.isInstanceOf[DepthOfCoverage]) shouldBe 7
val script2 = initPipeline(ConfigUtils.mergeMaps(samplesWithCount, settings))
script2.init()
script2.addSamplesJobs()
script2.functions.count(_.isInstanceOf[WisecondorCount]) shouldBe 0
script2.functions.count(_.isInstanceOf[DepthOfCoverage]) shouldBe 0
script2.functions.count(_.isInstanceOf[Ln]) shouldBe 14
}
@Test
def testReferenceSamples(): Unit = {
val script = initPipeline(ConfigUtils.mergeMaps(samplesWithBam, settings))
script.init()
script.biopetScript()
script.
getReferenceSamplesForSample("sample1").
getOrElse(Nil).toList.sorted shouldEqual List("sample4", "sample5").sorted
script.
getReferenceSamplesForSample("sample2").
getOrElse(Nil).toList.sorted shouldEqual List("sample6", "sample7").sorted
script.
getReferenceSamplesForSample("sample3").
getOrElse(Nil).toList.sorted shouldEqual List("sample1", "sample4", "sample5").sorted
script.
getReferenceSamplesForSample("sample4").
getOrElse(Nil).toList.sorted shouldEqual List("sample1", "sample3", "sample5").sorted
script.
getReferenceSamplesForSample("sample5").
getOrElse(Nil).toList.sorted shouldEqual List("sample1", "sample3", "sample4").sorted
script.
getReferenceSamplesForSample("sample6").
getOrElse(Nil).toList.sorted shouldEqual List("sample2", "sample7").sorted
script.
getReferenceSamplesForSample("sample7").
getOrElse(Nil).toList.sorted shouldEqual List("sample2", "sample6").sorted
}
@Test
def testReferenceJobs(): Unit = {
val script = initPipeline(ConfigUtils.mergeMaps(samplesWithBam, settings))
script.init()
script.biopetScript()
script.functions.count(_.isInstanceOf[XhmmMergeGatkDepths]) shouldBe 7
script.functions.count(_.isInstanceOf[WisecondorNewRef]) shouldBe 7
}
}
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