SamStatistics Class Reference

## Public Member Functions

void | reset ()
bool | updateStatistics (SamRecord &samRecord)
void | print ()

## Detailed Description

Definition at line 24 of file SamStatistics.h.

## Constructor & Destructor Documentation

## SamStatistics()

SamStatistics::SamStatistics | ( |  | ) |

Definition at line 22 of file SamStatistics.cpp.

{
reset();
}

## ~SamStatistics()

SamStatistics::~SamStatistics | ( |  | ) |

Definition at line 27 of file SamStatistics.cpp.

{
reset();
}

## Member Function Documentation

## print()

void SamStatistics::print | ( |  | ) |

Definition at line 86 of file SamStatistics.cpp.

{
double DIVIDE_UNITS = 1000000;
std::string units = "(e6)";
std::cerr << std::fixed << std::setprecision(2);
// If total reads is less than DIVIDE_UNITS, just show the straight number.
if(myReadCount < DIVIDE_UNITS)
{
DIVIDE_UNITS = 1;
units.clear();
}
// Read Counts
std::cerr << "TotalReads" << units << "\t"
<< myReadCount/DIVIDE_UNITS << std::endl;
std::cerr << "MappedReads" << units << "\t"
<< myMappedReadCount/DIVIDE_UNITS << std::endl;
std::cerr << "PairedReads" << units << "\t"
<< myPairedReadCount/DIVIDE_UNITS << std::endl;
std::cerr << "ProperPair" << units << "\t"
<< myProperPairedReadCount/DIVIDE_UNITS << std::endl;
std::cerr << "DuplicateReads" << units << "\t"
<< myDupReadCount/DIVIDE_UNITS << std::endl;
std::cerr << "QCFailureReads" << units << "\t"
<< myQCFailureReadCount/DIVIDE_UNITS << std::endl;
std::cerr << std::endl;
// Read Percentages
std::cerr << "MappingRate(%)\t"
<< 100 * myMappedReadCount/(double)myReadCount << std::endl;
std::cerr << "PairedReads(%)\t"
<< 100 * myPairedReadCount/(double)myReadCount << std::endl;
std::cerr << "ProperPair(%)\t"
<< 100 * myProperPairedReadCount/(double)myReadCount << std::endl;
std::cerr << "DupRate(%)\t"
<< 100 * myDupReadCount/(double)myReadCount << std::endl;
std::cerr << "QCFailRate(%)\t"
<< 100 * myQCFailureReadCount/(double)myReadCount << std::endl;
std::cerr << std::endl;
// Base Counts
std::cerr << "TotalBases" << units << "\t"
<< myBaseCount/DIVIDE_UNITS << std::endl;
std::cerr << "BasesInMappedReads" << units << "\t"
<< myMappedReadBases/DIVIDE_UNITS << std::endl;
}

## reset()

void SamStatistics::reset | ( |  | ) |

Definition at line 32 of file SamStatistics.cpp.

{
myReadCount = 0;
myMappedReadCount = 0;
myPairedReadCount = 0;
myProperPairedReadCount = 0;
myBaseCount = 0;
myMappedReadBases = 0;
myDupReadCount = 0;
myQCFailureReadCount = 0;
}

## updateStatistics()

bool SamStatistics::updateStatistics | ( | SamRecord & | samRecord | ) |

Definition at line 45 of file SamStatistics.cpp.

{
// Each record has one read, so update the read count.
++myReadCount;
int32_t readLen = samRecord.getReadLength();
// Get the flag to determine the type or
// read (mapped, paired, proper paired).
uint16_t flag = samRecord.getFlag();
// If the read is mapped, update the mapped c
if(SamFlag::isMapped(flag))
{
++myMappedReadCount;
myMappedReadBases += readLen;
}
if(SamFlag::isPaired(flag))
{
++myPairedReadCount;
if(SamFlag::isProperPair(flag))
{
++myProperPairedReadCount;
}
}
if(SamFlag::isDuplicate(flag))
{
++myDupReadCount;
}
if(SamFlag::isQCFailure(flag))
{
++myQCFailureReadCount;
}
// Increment the total number of bases.
myBaseCount += readLen;
return(true);
}
SamRecord::getFlag
uint16_t getFlag()
Get the flag (FLAG).
Definition: SamRecord.cpp:1384
SamRecord::getReadLength
int32_t getReadLength()
Get the length of the read.
Definition: SamRecord.cpp:1391

The documentation for this class was generated from the following files:

- bam/SamStatistics.h
- bam/SamStatistics.cpp