File: AlignerStats.cpp

package info (click to toggle)
snap-aligner 1.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,988 kB
  • sloc: cpp: 36,500; ansic: 5,239; python: 227; makefile: 85; sh: 28
file content (150 lines) | stat: -rw-r--r-- 3,617 bytes parent folder | download
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*++

Module Name:

    AlignerStats.cpp

Abstract:

    Common statistics for running single & paired alignment.

Authors:

    Ravi Pandya, May, 2012

Environment:

    User mode service.

Revision History:

    Integrated from SingleAligner.cpp & PairedAligner.cpp

--*/

#include "stdafx.h"
#include "options.h"
#include "AlignerStats.h"

AbstractStats::~AbstractStats()
{}

AlignerStats::AlignerStats(AbstractStats* i_extra)
:
    totalReads(0),
    uselessReads(0),
    singleHits(0), 
    multiHits(0),
    notFound(0),
    alignedAsPairs(0),
    extra(i_extra),
    lvCalls(0),
    millisReading(0),
    millisAligning(0),
    millisWriting(0),
    filtered(0),
    extraAlignments(0),
    sameComplement(0), 
    agForcedSingleEndAlignment(0),
    agUsedSingleEndAlignment(0)
{
    for (int i = 0; i <= AlignerStats::maxMapq; i++) {
        mapqHistogram[i] = 0;
     }

    for (int i = 0; i < maxMaxHits; i++) {
        countOfBestHitsByWeightDepth[i] = 0;
        countOfAllHitsByWeightDepth[i] = 0;
        probabilityMassByWeightDepth[i] = 0;
    }

#if     TIME_HISTOGRAM
    countOfUnaligned = 0;
    timeOfUnaligned = 0;
    backwardsTimeStamps = 0;
    totalBackwardsTimeStamps = 0;

    for (unsigned i = 0; i < 31; i++) {
        countByTimeBucket[i] = nanosByTimeBucket[i] = countByNM[i] = timeByNM[i] = 0;
    }

    for (unsigned i = 0; i <= 70; i++) {
        countByMAPQ[i] = timeByMAPQ[i] = 0;
    }
#endif  // TIME_HISTOGRAM

}

AlignerStats::~AlignerStats()
{
    if (extra != NULL) {
        delete extra;
    }
}

    void
AlignerStats::printHistograms(
    FILE* out)
{
    // nothing
    if (extra != NULL) {
        extra->printHistograms(out);
    }
}

    void
AlignerStats::add(
    const AbstractStats* i_other)
{
    AlignerStats* other = (AlignerStats*) i_other;
    totalReads += other->totalReads;
    uselessReads += other->uselessReads;
    singleHits += other->singleHits;
    multiHits += other->multiHits;
    notFound += other->notFound;
    alignedAsPairs += other->alignedAsPairs;
    lvCalls += other->lvCalls;
    millisReading += other->millisReading;
    millisAligning += other->millisAligning;
    millisWriting += other->millisWriting;
    filtered += other->filtered;
    extraAlignments += other->extraAlignments;
    sameComplement += other->sameComplement;
    agForcedSingleEndAlignment += other->agForcedSingleEndAlignment;
    agUsedSingleEndAlignment += other->agUsedSingleEndAlignment;


    if (extra != NULL && other->extra != NULL) {
        extra->add(other->extra);
    }

    for (int i = 0; i <= AlignerStats::maxMapq; i++) {
        mapqHistogram[i] += other->mapqHistogram[i];
    }

    for (int i = 0; i < maxMaxHits; i++) {
        countOfBestHitsByWeightDepth[i] += other->countOfBestHitsByWeightDepth[i];
        countOfAllHitsByWeightDepth[i] += other->countOfAllHitsByWeightDepth[i];
        probabilityMassByWeightDepth[i] = other->probabilityMassByWeightDepth[i];
    }

#if TIME_HISTOGRAM
    countOfUnaligned += other->countOfUnaligned;
    timeOfUnaligned += other->timeOfUnaligned;

    backwardsTimeStamps += other->backwardsTimeStamps;
    totalBackwardsTimeStamps += other->totalBackwardsTimeStamps;

    for (unsigned i = 0; i < 31; i++) {
        countByTimeBucket[i] += other->countByTimeBucket[i];
        nanosByTimeBucket[i] += other->nanosByTimeBucket[i];
        countByNM[i] += other->countByNM[i];
        timeByNM[i] += other->timeByNM[i];
    }

    for (unsigned i = 0; i < 71; i++) {
        countByMAPQ[i] += other->countByMAPQ[i];
        timeByMAPQ[i] += other->timeByMAPQ[i];
    }
#endif // TIME_HISTOGRAM
}