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 0000000000000000000000000000000000000000..74eabb4125ad9351ff4691a7e5cf0fa68282249c --- /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 0000000000000000000000000000000000000000..dd05aed41c50b81790742957b210b21840918826 --- /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 0000000000000000000000000000000000000000..acbe332a82a9d7c04c71e5c9ae74275b3c75b0cc --- /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 0000000000000000000000000000000000000000..e7984915cab425c8bd94dd0a22eae60e0407f518 --- /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 0000000000000000000000000000000000000000..9eeb9fa3cb6ac4b2c1c826054682c7a21fa85d26 --- /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)) + } + +}