VcfUtilsTest.scala 1.84 KB
Newer Older
Peter van 't Hof's avatar
Peter van 't Hof committed
1
2
3
package nl.lumc.sasc.biopet.utils

import htsjdk.variant.variantcontext.{ Allele, GenotypeBuilder }
4
5
6
7
8
9
10
import org.scalatest.Matchers
import org.scalatest.testng.TestNGSuite
import org.testng.annotations.Test

import scala.collection.JavaConversions._

/**
Sander Bollen's avatar
Sander Bollen committed
11
12
 * Created by Sander Bollen on 4-10-16.
 */
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class VcfUtilsTest extends TestNGSuite with Matchers {

  @Test
  def testCompoundNoCall(): Unit = {
    val noAllele = Allele.NO_CALL
    val refAllele = Allele.create("A", true)
    val compoundNoCall = GenotypeBuilder.create("sample_01", List(noAllele, refAllele))
    VcfUtils.isCompoundNoCall(compoundNoCall) shouldBe true

    val altAllele = Allele.create("G", false)
    val normalGenotype = GenotypeBuilder.create("sample_01", List(refAllele, altAllele))
    VcfUtils.isCompoundNoCall(normalGenotype) shouldBe false

    val completeNoCall = GenotypeBuilder.create("sample_01", List(noAllele, noAllele))
    VcfUtils.isCompoundNoCall(completeNoCall) shouldBe false
  }

Peter van 't Hof's avatar
Peter van 't Hof committed
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  @Test
  def testAlleleOverlap(): Unit = {

    val a1 = Allele.create("G")
    val a2 = Allele.create("A")

    VcfUtils.alleleOverlap(List(a1, a1), List(a1, a1)) shouldBe 2
    VcfUtils.alleleOverlap(List(a2, a2), List(a2, a2)) shouldBe 2
    VcfUtils.alleleOverlap(List(a1, a2), List(a1, a2)) shouldBe 2
    VcfUtils.alleleOverlap(List(a1, a2), List(a2, a1)) shouldBe 2
    VcfUtils.alleleOverlap(List(a2, a1), List(a1, a2)) shouldBe 2
    VcfUtils.alleleOverlap(List(a2, a1), List(a2, a1)) shouldBe 2

    VcfUtils.alleleOverlap(List(a1, a2), List(a1, a1)) shouldBe 1
    VcfUtils.alleleOverlap(List(a2, a1), List(a1, a1)) shouldBe 1
    VcfUtils.alleleOverlap(List(a1, a1), List(a1, a2)) shouldBe 1
    VcfUtils.alleleOverlap(List(a1, a1), List(a2, a1)) shouldBe 1

    VcfUtils.alleleOverlap(List(a1, a1), List(a2, a2)) shouldBe 0
    VcfUtils.alleleOverlap(List(a2, a2), List(a1, a1)) shouldBe 0
  }

52
}