Commit ed129189 authored by Peter van 't Hof's avatar Peter van 't Hof

Remove duplicated stats

parent 99f13260
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment