From 5f0512b57ae59c87fa07213f23cf135f54d0aee2 Mon Sep 17 00:00:00 2001
From: Sander Bollen <a.h.b.bollen@lumc.nl>
Date: Thu, 13 Aug 2015 17:44:36 +0200
Subject: [PATCH] VcfFilter tests. See #188.

---
 .../nl/lumc/sasc/biopet/tools/VcfFilter.scala |  2 +-
 .../sasc/biopet/tools/VepNormalizer.scala     |  2 +-
 .../sasc/biopet/tools/VcfFilterTest.scala     | 59 +++++++++++++++++++
 3 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/VcfFilter.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/VcfFilter.scala
index f5fb9f3a6..24cfab400 100644
--- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/VcfFilter.scala
+++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/VcfFilter.scala
@@ -56,7 +56,7 @@ class VcfFilter(val root: Configurable) extends ToolCommandFuntion {
 
 object VcfFilter extends ToolCommand {
   /** Container class for a trio */
-  protected case class Trio(child: String, father: String, mother: String) {
+  protected[tools] case class Trio(child: String, father: String, mother: String) {
     def this(arg: String) = {
       this(arg.split(":")(0), arg.split(":")(1), arg.split(":")(2))
     }
diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/VepNormalizer.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/VepNormalizer.scala
index 8543b7706..1b7af776e 100644
--- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/VepNormalizer.scala
+++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/VepNormalizer.scala
@@ -50,7 +50,7 @@ class VepNormalizer(val root: Configurable) extends ToolCommandFuntion {
   var mode: String = config("mode", default = "explode")
   var doNotRemove: Boolean = config("donotremove", default = false)
 
-  override def defaultCoreMemory = 1.0
+  override def defaultCoreMemory = 4.0
 
   override def commandLine = super.commandLine +
     required("-I", inputVCF) +
diff --git a/public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/VcfFilterTest.scala b/public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/VcfFilterTest.scala
index 840abf904..80fe1980e 100644
--- a/public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/VcfFilterTest.scala
+++ b/public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/VcfFilterTest.scala
@@ -147,4 +147,63 @@ class VcfFilterTest extends TestNGSuite with MockitoSugar with Matchers {
     mustHaveVariant(record, List("Child_7006504", "Father_7006506", "Mother_7006508")) shouldBe false
   }
 
+  @Test def testSameGenotype() = {
+    val reader = new VCFFileReader(vepped, false)
+    val record = reader.iterator().next()
+
+    notSameGenotype(record, "Child_7006504", "Father_7006506") shouldBe false
+    notSameGenotype(record, "Child_7006504", "Mother_7006508") shouldBe true
+    notSameGenotype(record, "Father_7006506", "Mother_7006508") shouldBe true
+  }
+
+  @Test def testfilterHetVarToHomVar() = {
+    val reader = new VCFFileReader(vepped, false)
+    val record = reader.iterator().next()
+
+    filterHetVarToHomVar(record, "Child_7006504", "Father_7006506") shouldBe true
+    filterHetVarToHomVar(record, "Child_7006504", "Mother_7006508") shouldBe true
+    filterHetVarToHomVar(record, "Father_7006506", "Mother_7006508") shouldBe true
+  }
+
+  @Test def testDeNovo() = {
+    val reader = new VCFFileReader(vepped, false)
+    val record = reader.iterator().next()
+
+    denovoInSample(record, "Child_7006504") shouldBe false
+    denovoInSample(record, "Father_7006506") shouldBe false
+    denovoInSample(record, "Mother_7006508") shouldBe false
+  }
+
+  @Test def testResToDom() = {
+    val reader = new VCFFileReader(vepped, false)
+    val record = reader.iterator().next()
+    val trio = new Trio("Child_7006504", "Father_7006506", "Mother_7006508")
+
+    resToDom(record, List(trio)) shouldBe false
+  }
+
+  @Test def testTrioCompound = {
+    val reader = new VCFFileReader(vepped, false)
+    val record = reader.iterator().next()
+    val trio = new Trio("Child_7006504", "Father_7006506", "Mother_7006508")
+
+    trioCompound(record, List(trio))
+  }
+
+  @Test def testDeNovoTrio = {
+    val reader = new VCFFileReader(vepped, false)
+    val record = reader.iterator().next()
+    val trio = new Trio("Child_7006504", "Father_7006506", "Mother_7006508")
+
+    denovoTrio(record, List(trio))
+  }
+
+  @Test def testInIDSet() = {
+    val reader = new VCFFileReader(vepped, false)
+    val record = reader.iterator().next()
+
+    inIdSet(record, Set("rs199537431")) shouldBe true
+    inIdSet(record, Set("dummy")) shouldBe false
+  }
+
 }
-- 
GitLab