From 8829cb1baa385d828e79f9abf82b12e34012cc39 Mon Sep 17 00:00:00 2001
From: Sander Bollen <a.h.b.bollen@lumc.nl>
Date: Wed, 12 Aug 2015 13:28:52 +0200
Subject: [PATCH] Added unit test for #186. Unit test passes.

---
 .../sasc/biopet/tools/VcfFilterTest.scala     | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)

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 150e3eea3..2f4709a9c 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
@@ -15,8 +15,10 @@
  */
 package nl.lumc.sasc.biopet.tools
 
+import java.io.File
 import java.nio.file.Paths
 
+import htsjdk.variant.vcf.VCFFileReader
 import org.scalatest.Matchers
 import org.scalatest.mock.MockitoSugar
 import org.scalatest.testng.TestNGSuite
@@ -37,6 +39,7 @@ class VcfFilterTest extends TestNGSuite with MockitoSugar with Matchers {
   }
 
   val vepped_path = resourcePath("/VEP_oneline.vcf")
+  val vepped = new File(vepped_path)
   val rand = new Random()
 
   @Test def testOutputTypeVcf() = {
@@ -57,4 +60,24 @@ class VcfFilterTest extends TestNGSuite with MockitoSugar with Matchers {
     main(arguments)
   }
 
+  @Test def testHasGenotype() = {
+    val reader = new VCFFileReader(vepped, false)
+    val record = reader.iterator().next()
+
+    hasGenotype(record, List("Child_7006504:HET")) shouldBe true
+    hasGenotype(record, List("Child_7006504:HOM_VAR")) shouldBe false
+    hasGenotype(record, List("Child_7006504:HOM_REF")) shouldBe false
+    hasGenotype(record, List("Child_7006504:NO_CALL")) shouldBe false
+    hasGenotype(record, List("Child_7006504:MIXED")) shouldBe false
+
+    hasGenotype(record, List("Mother_7006508:HET")) shouldBe false
+    hasGenotype(record, List("Mother_7006508:HOM_VAR")) shouldBe false
+    hasGenotype(record, List("Mother_7006508:HOM_REF")) shouldBe true
+    hasGenotype(record, List("Mother_7006508:NO_CALL")) shouldBe false
+    hasGenotype(record, List("Mother_7006508:MIXED")) shouldBe false
+
+    hasGenotype(record, List("Mother_7006508:HOM_REF", "Child_7006504:HET")) shouldBe true
+    hasGenotype(record, List("Mother_7006508:HET", "Child_7006504:HOM_HET")) shouldBe false
+  }
+
 }
-- 
GitLab