File: MappingMetrics.hpp

package info (click to toggle)
pbseqlib 0~20161219-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,924 kB
  • ctags: 5,123
  • sloc: cpp: 82,727; makefile: 305; python: 239; sh: 8
file content (133 lines) | stat: -rw-r--r-- 2,785 bytes parent folder | download | duplicates (4)
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
#ifndef _BLASR_MAPPING_METRICS_HPP_
#define _BLASR_MAPPING_METRICS_HPP_

#include <iostream>
#include <time.h>
#include <map>
#include <vector>
//In order to use clock_gettime in LINUX, add -lrt 
#ifdef __APPLE__
#include <mach/mach.h>
#include <mach/clock.h>
#include <mach/mach_time.h>
#include <errno.h>

typedef enum {
    CLOCK_REALTIME,
    CLOCK_MONOTONIC,
    CLOCK_PROCESS_CPUTIME_ID,
    CLOCK_THREAD_CPUTIME_ID
} clockid_t;
static mach_timebase_info_data_t __clock_gettime_inf;

int clock_gettime(clockid_t clk_id, struct timespec *tp); 
#endif // __APPLE__

class Timer {
public:
    bool keepHistogram, keepList;
    timespec cpuclock[2];
    int elapsedClockMsec;
    float   elapsedTime;
    std::map<int,int> histogram;
    std::vector<int> msecList;
    long long totalElapsedClock;
    std::string header;


    Timer(std::string _header=""); 

    int ListSize(); 

    void PrintHeader(std::ostream &out); 

    void PrintListValue(std::ostream &out, int index); 

    void Tick(); 

    void SetStoreElapsedTime(bool value); 

    void SetStoreHistgram(bool value); 

    void Tock(); 

    void Add(const Timer &rhs); 

    void SetHeader(std::string _header); 

};


class MappingClocks {
public:
    Timer total;
    Timer findAnchors;
    Timer mapToGenome;
    Timer sortMatchPosList;
    Timer findMaxIncreasingInterval;
    Timer alignIntervals;           
    std::vector<int> nCellsPerSample;
    std::vector<int> nBasesPerSample;

    void AddCells(int nCells); 

    void AddBases(int nBases); 

    int  GetSize(); 

    MappingClocks(); 

    void PrintHeader(std::ostream &out); 

    void PrintList(std::ostream &out, int index); 

    void SetStoreList(bool value=true); 

    void AddClockTime(const MappingClocks &rhs); 
};


class MappingMetrics {
public:
    MappingClocks clocks;
    int numReads;
    int numMappedReads;
    int numMappedBases;
    std::vector<int> mappedBases;
    std::vector<int> cellsPerAlignment;
    std::vector<int> anchorsPerAlignment;
    std::vector<int> sdpAnchors, sdpBases, sdpClock;
    long totalAnchors;
    int anchorsPerRead;
    long totalAnchorsForMappedReads;

    MappingMetrics(); 

    void StoreSDPPoint(int nBases, int nSDPAnchors, int nClock); 

    void SetStoreList(bool value=true); 

    void PrintSeconds(std::ostream &out, long sec);

    void PrintFraction(std::ostream &out, float frac); 

    void RecordNumAlignedBases(int nBases); 

    void RecordNumCells(int nCells); 

    void Collect(MappingMetrics &rhs); 

    void CollectSDPMetrics(MappingMetrics &rhs); 

    void PrintSDPMetrics(std::ostream &out); 

    void PrintFullList(std::ostream &out); 

    void PrintSummary(std::ostream &out); 

    void AddClock(MappingClocks &clocks); 
};



#endif // _BLASR_MAPPING_METRICS_HPP_