From 4faa97b25e4a0d7a8c426a9d7748f25574faef24 Mon Sep 17 00:00:00 2001 From: Sander Bollen <a.h.b.bollen@lumc.nl> Date: Thu, 27 Aug 2015 15:43:04 +0200 Subject: [PATCH] FindRepeatsPacBioTest --- .../biopet/tools/FindRepeatsPacBioTest.scala | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/FindRepeatsPacBioTest.scala diff --git a/public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/FindRepeatsPacBioTest.scala b/public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/FindRepeatsPacBioTest.scala new file mode 100644 index 000000000..af0243cda --- /dev/null +++ b/public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/FindRepeatsPacBioTest.scala @@ -0,0 +1,64 @@ +package nl.lumc.sasc.biopet.tools + +import java.io.File +import java.nio.file.Paths + +import htsjdk.samtools.{SamReaderFactory, QueryInterval} +import nl.lumc.sasc.biopet.tools.FastqSplitter._ +import org.scalatest.Matchers +import org.scalatest.mock.MockitoSugar +import org.scalatest.testng.TestNGSuite +import org.testng.annotations.Test + +import scala.collection.immutable.Nil + +/** + * Created by ahbbollen on 27-8-15. + */ +class FindRepeatsPacBioTest extends TestNGSuite with MockitoSugar with Matchers { + + import FindRepeatsPacBio._ + private def resourcePath(p: String): String = { + Paths.get(getClass.getResource(p).toURI).toString + } + + val bed = resourcePath("/rrna01.bed") + val bam = resourcePath("/paired01.bam") + + @Test + def testMain() = { + + val args = Array("-I", bam, "-b", bed) + main(args) + } + + @Test + def testResult() = { + val samReader = SamReaderFactory.makeDefault().open(new File(bam)) + val header = samReader.getFileHeader + val record = samReader.iterator().next() + val interval = new QueryInterval(header.getSequenceIndex("chrQ"), 50, 55) + val result = procesSamrecord(record, interval) + + result.isEmpty shouldBe false + + result.get.samRecord shouldEqual record + result.get.beginDel should be >= 0 + result.get.endDel should be >= 0 + } + + @Test + def testResultObject = { + val record = SamReaderFactory.makeDefault().open(new File(bam)).iterator().next() + val result = new Result + result.samRecord = record + + result.samRecord shouldEqual record + result.beginDel shouldBe 0 + result.endDel shouldBe 0 + result.dels shouldEqual Nil + result.ins shouldEqual Nil + } + + +} -- GitLab