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

Adde more test for BedRecord

parent cd041e3f
......@@ -48,7 +48,7 @@ case class BedRecord(chr: String,
case Some(false) => blockCount.get - i
case _ => i + 1
}
BedRecord(chr, start + blockStarts(i) + blockSizes(i) + 1, start + blockStarts(i + 1) - 1,
BedRecord(chr, start + blockStarts(i) + blockSizes(i), start + blockStarts(i + 1),
Some(s"intron-$intronNumber"), _originals = List(this))
})
} else None
......@@ -63,9 +63,9 @@ case class BedRecord(chr: String,
lazy val utr3 = (strand, thickStart, thickEnd) match {
case (Some(false), Some(tStart), Some(tEnd)) if (tStart > start && tEnd < end) =>
Some(BedRecord(chr, start, tStart - 1, name.map(_ + "_utr3")))
Some(BedRecord(chr, start, tStart, name.map(_ + "_utr3")))
case (Some(true), Some(tStart), Some(tEnd)) if (tStart > start && tEnd < end) =>
Some(BedRecord(chr, tEnd + 1, end, name.map(_ + "_utr3")))
Some(BedRecord(chr, tEnd, end, name.map(_ + "_utr3")))
case _ => None
}
......
......@@ -24,6 +24,7 @@ class BedRecordTest extends TestNGSuite with Matchers {
@Test def testLineOutput: Unit = {
BedRecord("chrQ", 0, 4).toString shouldBe "chrQ\t0\t4"
BedRecord.fromLine("chrQ\t0\t4").toString shouldBe "chrQ\t0\t4"
BedRecord.fromLine("chrQ\t0\t100\tname\t3\t+\t1\t3\t255,0,0\t2\t10,20\t20,50").toString shouldBe "chrQ\t0\t100\tname\t3.0\t+\t1\t3\t255,0,0\t2\t10,20\t20,50"
}
@Test def testOverlap: Unit = {
......@@ -40,8 +41,64 @@ class BedRecordTest extends TestNGSuite with Matchers {
BedRecord("chrQ", 0, 4).length shouldBe 4
BedRecord("chrQ", 0, 1).length shouldBe 1
BedRecord("chrQ", 3, 4).length shouldBe 1
BedRecord.fromLine("chrQ\t0\t100\tname\t3\t+\t1\t3\t255,0,0\t2\t10,20\t20,50").exons.get.foldLeft(0)(_ + _.length) shouldBe 30
BedRecord.fromLine("chrQ\t0\t100\tname\t3\t+\t1\t3\t255,0,0\t2\t10,20\t20,50").introns.get.foldLeft(0)(_ + _.length) shouldBe 20
}
@Test def testExons: Unit = {
BedRecord.fromLine("chrQ\t0\t100\tname\t3\t+\t1\t3\t255,0,0").exons shouldBe None
val record = BedRecord.fromLine("chrQ\t0\t100\tname\t3\t+\t1\t3\t255,0,0\t2\t10,20\t0,80")
val exons = record.exons
exons should not be None
exons.get(0).originals()(0) shouldBe record
exons.get(0).originals().size shouldBe 1
exons.get(1).originals()(0) shouldBe record
exons.get(1).originals().size shouldBe 1
exons.get(0).start shouldBe 0
exons.get(0).end shouldBe 10
exons.get(1).start shouldBe 80
exons.get(1).end shouldBe 100
exons.get.foldLeft(0)(_ + _.length) shouldBe 30
}
@Test def testIntrons: Unit = {
BedRecord.fromLine("chrQ\t0\t100\tname\t3\t+\t1\t3\t255,0,0").introns shouldBe None
val record = BedRecord.fromLine("chrQ\t0\t100\tname\t3\t+\t1\t3\t255,0,0\t2\t10,20\t0,80")
val introns = record.introns
introns should not be None
introns.get(0).originals()(0) shouldBe record
introns.get(0).originals().size shouldBe 1
introns.get(0).start shouldBe 10
introns.get(0).end shouldBe 80
introns.get.foldLeft(0)(_ + _.length) shouldBe 70
}
@Test def testUtrsPositive: Unit = {
BedRecord.fromLine("chrQ\t0\t100\tname\t3\t+").utr3 shouldBe None
BedRecord.fromLine("chrQ\t0\t100\tname\t3\t+").utr5 shouldBe None
val record = BedRecord.fromLine("chrQ\t0\t100\tname\t3\t+\t3\t93\t255,0,0\t2\t10,20\t0,80")
val utr5 = record.utr5
val utr3 = record.utr3
utr5 should not be None
utr3 should not be None
utr5.get.length shouldBe 3
utr3.get.length shouldBe 7
}
@Test def testUtrsNegative: Unit = {
BedRecord.fromLine("chrQ\t0\t100\tname\t3\t-").utr3 shouldBe None
BedRecord.fromLine("chrQ\t0\t100\tname\t3\t-").utr5 shouldBe None
val record = BedRecord.fromLine("chrQ\t0\t100\tname\t3\t-\t3\t93\t255,0,0\t2\t10,20\t0,80")
val utr5 = record.utr5
val utr3 = record.utr3
utr5 should not be None
utr3 should not be None
utr5.get.length shouldBe 7
utr3.get.length shouldBe 3
}
@Test def testErrors: Unit = {
......
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