diff --git a/public/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/SeqStat.scala b/public/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/SeqStat.scala index f29999270603fdf6ad900f3cc821c8a886f798a2..ac4afb7f99e2bbe545d068abc6c78495aea13cd6 100644 --- a/public/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/SeqStat.scala +++ b/public/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/SeqStat.scala @@ -130,7 +130,7 @@ object SeqStat extends ToolCommand { baseStats ++= mutable.ArrayBuffer.fill(record.length - baseStats.length)(BaseStat()) } - if (readStats.lengths.length < record.length) { + if (readStats.lengths.length <= record.length) { readStats.lengths ++= mutable.ArrayBuffer.fill(record.length - readStats.lengths.length + 1)(0) } diff --git a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/SeqStatTest.scala b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/SeqStatTest.scala index b60ef10126a30b4ccabb8d8b8595f44e7a3cd889..84c27306168ca6abe67a43b80458c033ade84964 100644 --- a/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/SeqStatTest.scala +++ b/public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/SeqStatTest.scala @@ -109,6 +109,21 @@ class SeqStatTest extends TestNGSuite with MockitoSugar with Matchers { } + @Test(dataProvider = "mockReaderProvider", groups = Array("check_readstats"), singleThreaded = true, dependsOnGroups = Array("report")) + def testReadStatsObject(fqMock: FastqReader) = { + when(fqMock.getFile) thenReturn new File("/tmp/test.fq") + when(fqMock.iterator) thenReturn recordsOver("1", "2", "3", "4", "5") + val seqstat = SeqStat + + // the histogram should store the lenght==0 value also, for example sequence length 5 is size 6. + // please note that we already loaded the dataset twice in seqstat. (seqstat.Seqstat is called 2 times in previous steps) + seqstat.readStats.lengths(5) shouldBe 10 + seqstat.readStats.lengths.length shouldBe 6 + + seqstat.readStats.nucs.sum shouldBe 50 + seqstat.readStats.withN shouldBe 10 + } + @Test def testArgsMinimum() = { val args = Array( "-i", resourcePath("/paired01a.fq"))