1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
#include "stdafx.h"
#include "ReadsMappingStats.h"
CReadsMappingStats::CReadsMappingStats(void)
{
this->initialization();
}
CReadsMappingStats::~CReadsMappingStats(void)
{
}
void CReadsMappingStats::initialization(void)
{
this->iReadsFileCount = 0;
this->iMultiMappedLocationThreshold = 2000;
// this->iMultiMappedLocationThreshold = 1000000;
this->initializeStatsCounter(); // Counters
}
void CReadsMappingStats::initializeStatsCounter(void)
{
this->iBadReadCounter = 0;
this->iMapCount = 0;
this->iReadCounter = 0;
this->iMissReadCounter = 0;
this->iMultiMappedReads = 0;
this->iReadsFileCount = 0;
this->iReadsMapped2tooManyLocations = 0;
for (unsigned int i = 0; i <= MAXTOLERATSUBMIS; i++) {
// Temporarily assume there have same # of record
this->iMapDiffCount[i] = 0;
}
}
void CReadsMappingStats::printCommand(ostream& out, string command)
{
out << command << endl;
}
int CReadsMappingStats::printMappingStats(ostream& out, const char* readSetName,\
unsigned int uiSubThreshold) const
{
unsigned int i;
out << endl;
out << readSetName << ", Reads:, ";
out << "Filtered#, " << iBadReadCounter << ", ";
out << "Kept#, " << iReadCounter << ", ";
out << "Mapped#, " << iMapCount << ", ";
out << "Multimapped#, " << iMultiMappedReads << ", ";
out << "Multimapped>" << iMultiMappedLocationThreshold << "#, ";
out << iReadsMapped2tooManyLocations << BLANK_LINE << endl;
out << readSetName << ",_ ";
for (i = 0; i <= uiSubThreshold; i++) {
out << "Sub" << i << ", " << iMapDiffCount[i] << ", " ;
}
out << endl;
return(0);
}
// return true if print the alignments
void CReadsMappingStats::bookKeepMapping(CAlignmentsQ& que)
{
this->iMapCount++;
this->iMapDiffCount[que.MinDiff]++;
if (que.AmbiguousFlag) {
this->iMultiMappedReads++;
}
}
bool CReadsMappingStats::printAlignmentOrNot(CAlignmentsQ& que, bool bExcludeAmbiguous, bool ambiguousOnly) const
{
bool ambiguousFlag = false;
if (que.qAllInThreshold()) {
// if bExcludeAmbiguous and qAllInThreshold (-E -A), print only if there are single record.
if (que.load > 1) {
ambiguousFlag = true;
}
} else {
if (que.AmbiguousFlag) {
ambiguousFlag = true;
}
}
if (ambiguousFlag) {
if (ambiguousOnly) {
return(true);
} else if (bExcludeAmbiguous) {
return(false);
} else {
return(true);
}
} else {
if (ambiguousOnly) {
return(false); // If the mapping is not ambiguous but only ambiguous mapping are meant to be printed.
} else {
return(true);
}
}
}
|