diff --git a/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/bamstats/BamStats.scala b/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/bamstats/BamStats.scala index 62f7060fcfcbcf6dffad0da0f2fab59660b85d95..e40f3614a80e560bf9e1561460ad55d3ea2c7875 100644 --- a/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/bamstats/BamStats.scala +++ b/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/bamstats/BamStats.scala @@ -94,8 +94,6 @@ object BamStats extends ToolCommand { val stats = waitOnFutures(unmappedFuture :: contigsFutures.toList) - logger.info(s"total: ${stats.totalReads}, unmapped: ${stats.unmapped}, secondary: ${stats.secondary}") - stats.writeStatsToFiles(outputDir) } @@ -167,10 +165,7 @@ object BamStats extends ToolCommand { // Read based stats if (samRecord.getAlignmentStart > threadStart && samRecord.getAlignmentStart <= threadEnd) { totalStats.flagstat.loadRecord(samRecord) - totalStats.totalReads += 1 - if (samRecord.isSecondaryOrSupplementary) totalStats.secondary += 1 - if (samRecord.getReadUnmappedFlag) totalStats.unmapped += 1 - else { // Mapped read + if (!samRecord.getReadUnmappedFlag) { // Mapped read totalStats.mappingQualityHistogram.add(samRecord.getMappingQuality) } if (samRecord.getProperPairFlag && samRecord.getFirstOfPairFlag && !samRecord.getSecondOfPairFlag) @@ -212,8 +207,6 @@ object BamStats extends ToolCommand { val samReader = SamReaderFactory.makeDefault().open(bamFile) for (samRecord <- samReader.queryUnmapped()) { stats.flagstat.loadRecord(samRecord) - stats.totalReads += 1 - stats.unmapped += 1 } samReader.close() stats diff --git a/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/bamstats/Stats.scala b/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/bamstats/Stats.scala index 1bab56ec2abe029f964b63e222b21c981052d798..394ccb8dd389ec08cd83809f88763f4bbd7dd457 100644 --- a/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/bamstats/Stats.scala +++ b/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/bamstats/Stats.scala @@ -7,10 +7,7 @@ import nl.lumc.sasc.biopet.tools.flagstat.FlagstatCollector /** * Created by pjvanthof on 05/07/16. */ -case class Stats(var totalReads: Long = 0L, - var unmapped: Long = 0L, - var secondary: Long = 0L, - flagstat: FlagstatCollector = new FlagstatCollector(), +case class Stats(flagstat: FlagstatCollector = new FlagstatCollector(), mappingQualityHistogram: Histogram[Int] = new Histogram[Int](), insertSizeHistogram: Histogram[Int] = new Histogram[Int](), clippingHistogram: Histogram[Int] = new Histogram[Int](), @@ -24,8 +21,6 @@ case class Stats(var totalReads: Long = 0L, /** This will add an other [[Stats]] inside `this` */ def +=(other: Stats): Stats = { - this.totalReads += other.totalReads - this.unmapped += other.unmapped this.flagstat += other.flagstat this.mappingQualityHistogram += other.mappingQualityHistogram this.insertSizeHistogram += other.insertSizeHistogram