From a1605bf28997aeaea178ef51042cd157b03b4bd5 Mon Sep 17 00:00:00 2001 From: Sander Bollen <a.h.b.bollen@lumc.nl> Date: Wed, 26 Aug 2015 17:40:28 +0200 Subject: [PATCH] BiopetFlagStat testing --- .../test/resources/flagstat_crossreport.txt | 15 +++++ .../src/test/resources/flagstat_crosstrue.txt | 15 +++++ .../src/test/resources/flagstat_report.txt | 48 +++++++++++++++ .../src/test/resources/flagstat_summary.txt | 16 +++++ .../biopet/tools/BiopetFlagstatTest.scala | 60 +++++++++++++++++++ 5 files changed, 154 insertions(+) create mode 100644 public/biopet-framework/src/test/resources/flagstat_crossreport.txt create mode 100644 public/biopet-framework/src/test/resources/flagstat_crosstrue.txt create mode 100644 public/biopet-framework/src/test/resources/flagstat_report.txt create mode 100644 public/biopet-framework/src/test/resources/flagstat_summary.txt create mode 100644 public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/BiopetFlagstatTest.scala diff --git a/public/biopet-framework/src/test/resources/flagstat_crossreport.txt b/public/biopet-framework/src/test/resources/flagstat_crossreport.txt new file mode 100644 index 000000000..74eabb412 --- /dev/null +++ b/public/biopet-framework/src/test/resources/flagstat_crossreport.txt @@ -0,0 +1,15 @@ + #1 #2 #3 #4 #5 #6 #7 #8 #9 #10 #11 #12 #13 #14 +#1 1 1 0 1 0 0 0 1 1 1 0 0 0 0 +#2 1 1 0 1 0 0 0 1 1 1 0 0 0 0 +#3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +#4 1 1 0 1 0 0 0 1 1 1 0 0 0 0 +#5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +#6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +#7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +#8 1 1 0 1 0 0 0 1 1 1 0 0 0 0 +#9 1 1 0 1 0 0 0 1 1 1 0 0 0 0 +#10 1 1 0 1 0 0 0 1 1 1 0 0 0 0 +#11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +#12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +#13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +#14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 diff --git a/public/biopet-framework/src/test/resources/flagstat_crosstrue.txt b/public/biopet-framework/src/test/resources/flagstat_crosstrue.txt new file mode 100644 index 000000000..dd05aed41 --- /dev/null +++ b/public/biopet-framework/src/test/resources/flagstat_crosstrue.txt @@ -0,0 +1,15 @@ + #1 #2 #3 #4 #5 #6 #7 #8 #9 #10 #11 #12 #13 #14 +#1 100.0000% 100.0000% 0.0000% 100.0000% 0.0000% 0.0000% 0.0000% 100.0000% 100.0000% 100.0000% 0.0000% 0.0000% 0.0000% 0.0000% +#2 100.0000% 100.0000% 0.0000% 100.0000% 0.0000% 0.0000% 0.0000% 100.0000% 100.0000% 100.0000% 0.0000% 0.0000% 0.0000% 0.0000% +#3 NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% +#4 100.0000% 100.0000% 0.0000% 100.0000% 0.0000% 0.0000% 0.0000% 100.0000% 100.0000% 100.0000% 0.0000% 0.0000% 0.0000% 0.0000% +#5 NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% +#6 NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% +#7 NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% +#8 100.0000% 100.0000% 0.0000% 100.0000% 0.0000% 0.0000% 0.0000% 100.0000% 100.0000% 100.0000% 0.0000% 0.0000% 0.0000% 0.0000% +#9 100.0000% 100.0000% 0.0000% 100.0000% 0.0000% 0.0000% 0.0000% 100.0000% 100.0000% 100.0000% 0.0000% 0.0000% 0.0000% 0.0000% +#10 100.0000% 100.0000% 0.0000% 100.0000% 0.0000% 0.0000% 0.0000% 100.0000% 100.0000% 100.0000% 0.0000% 0.0000% 0.0000% 0.0000% +#11 NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% +#12 NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% +#13 NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% +#14 NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% diff --git a/public/biopet-framework/src/test/resources/flagstat_report.txt b/public/biopet-framework/src/test/resources/flagstat_report.txt new file mode 100644 index 000000000..acbe332a8 --- /dev/null +++ b/public/biopet-framework/src/test/resources/flagstat_report.txt @@ -0,0 +1,48 @@ +Number Total Flags Fraction Name +#1 1 100.0000% All +#2 1 100.0000% Mapped +#3 0 0.0000% Duplicates +#4 1 100.0000% FirstOfPair +#5 0 0.0000% SecondOfPair +#6 0 0.0000% ReadNegativeStrand +#7 0 0.0000% NotPrimaryAlignment +#8 1 100.0000% ReadPaired +#9 1 100.0000% ProperPair +#10 1 100.0000% MateNegativeStrand +#11 0 0.0000% MateUnmapped +#12 0 0.0000% ReadFailsVendorQualityCheck +#13 0 0.0000% SupplementaryAlignment +#14 0 0.0000% SecondaryOrSupplementary + + #1 #2 #3 #4 #5 #6 #7 #8 #9 #10 #11 #12 #13 #14 +#1 1 1 0 1 0 0 0 1 1 1 0 0 0 0 +#2 1 1 0 1 0 0 0 1 1 1 0 0 0 0 +#3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +#4 1 1 0 1 0 0 0 1 1 1 0 0 0 0 +#5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +#6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +#7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +#8 1 1 0 1 0 0 0 1 1 1 0 0 0 0 +#9 1 1 0 1 0 0 0 1 1 1 0 0 0 0 +#10 1 1 0 1 0 0 0 1 1 1 0 0 0 0 +#11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +#12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +#13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +#14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + + #1 #2 #3 #4 #5 #6 #7 #8 #9 #10 #11 #12 #13 #14 +#1 100.0000% 100.0000% 0.0000% 100.0000% 0.0000% 0.0000% 0.0000% 100.0000% 100.0000% 100.0000% 0.0000% 0.0000% 0.0000% 0.0000% +#2 100.0000% 100.0000% 0.0000% 100.0000% 0.0000% 0.0000% 0.0000% 100.0000% 100.0000% 100.0000% 0.0000% 0.0000% 0.0000% 0.0000% +#3 NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% +#4 100.0000% 100.0000% 0.0000% 100.0000% 0.0000% 0.0000% 0.0000% 100.0000% 100.0000% 100.0000% 0.0000% 0.0000% 0.0000% 0.0000% +#5 NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% +#6 NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% +#7 NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% +#8 100.0000% 100.0000% 0.0000% 100.0000% 0.0000% 0.0000% 0.0000% 100.0000% 100.0000% 100.0000% 0.0000% 0.0000% 0.0000% 0.0000% +#9 100.0000% 100.0000% 0.0000% 100.0000% 0.0000% 0.0000% 0.0000% 100.0000% 100.0000% 100.0000% 0.0000% 0.0000% 0.0000% 0.0000% +#10 100.0000% 100.0000% 0.0000% 100.0000% 0.0000% 0.0000% 0.0000% 100.0000% 100.0000% 100.0000% 0.0000% 0.0000% 0.0000% 0.0000% +#11 NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% +#12 NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% +#13 NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% +#14 NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% NaN% + diff --git a/public/biopet-framework/src/test/resources/flagstat_summary.txt b/public/biopet-framework/src/test/resources/flagstat_summary.txt new file mode 100644 index 000000000..e7984915c --- /dev/null +++ b/public/biopet-framework/src/test/resources/flagstat_summary.txt @@ -0,0 +1,16 @@ +{ + "Duplicates" : 0, + "NotPrimaryAlignment" : 0, + "All" : 1, + "ReadNegativeStrand" : 0, + "ProperPair" : 1, + "MateUnmapped" : 0, + "ReadFailsVendorQualityCheck" : 0, + "Mapped" : 1, + "SupplementaryAlignment" : 0, + "MateNegativeStrand" : 1, + "FirstOfPair" : 1, + "ReadPaired" : 1, + "SecondaryOrSupplementary" : 0, + "SecondOfPair" : 0 +} \ No newline at end of file diff --git a/public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/BiopetFlagstatTest.scala b/public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/BiopetFlagstatTest.scala new file mode 100644 index 000000000..9eeb9fa3c --- /dev/null +++ b/public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/BiopetFlagstatTest.scala @@ -0,0 +1,60 @@ +package nl.lumc.sasc.biopet.tools + +import java.io.File +import java.nio.file.Paths + +import htsjdk.samtools.SamReaderFactory +import org.scalatest.Matchers +import org.scalatest.mock.MockitoSugar +import org.scalatest.testng.TestNGSuite +import org.testng.annotations.Test + +import scala.io.Source + +/** + * Created by ahbbollen on 26-8-15. + */ +class BiopetFlagstatTest extends TestNGSuite with MockitoSugar with Matchers { + + import BiopetFlagstat._ + private def resourcePath(p: String): String = { + Paths.get(getClass.getResource(p).toURI).toString + } + + val bam = new File(resourcePath("/paired01.bam")) + val report = new File(resourcePath("/flagstat_report.txt")) + val summary = new File(resourcePath("/flagstat_summary.txt")) + val crossReport = new File(resourcePath("/flagstat_crossreport.txt")) + val crossTrue = new File(resourcePath("/flagstat_crosstrue.txt")) + + val record = SamReaderFactory.makeDefault().open(bam).iterator().next() + val processor = new FlagstatCollector + processor.loadDefaultFunctions() + processor.loadRecord(record) + + @Test + def testReport()= { + processor.report shouldBe Source.fromFile(report).mkString + } + + @Test + def testSummary() = { + processor.summary shouldBe Source.fromFile(summary).mkString + } + + @Test + def testCrossReport() = { + processor.crossReport() shouldBe Source.fromFile(crossReport).mkString + } + + @Test + def testCrossReportTrue() = { + processor.crossReport(true) shouldBe Source.fromFile(crossTrue).mkString + } + + @Test + def testMain() = { + main(Array("-I", bam.getAbsolutePath)) + } + +} -- GitLab