Debian Codegraph @

src/non_api/BamStats.h

raw symbols SCIP
1 #ifndef SEQLIB_BAMSTATS_H__
2 #define SEQLIB_BAMSTATS_H__
3
4 #include <unordered_map>
5 #include <cstdint>
6 #include <iostream>
7
8 #include "SeqLib/Histogram.h"
9 #include "SeqLib/BamRecord.h"
10
11 namespace SeqLib{
12
13 /** Store information pertaining to a given read group *
14 *
15 * This class will collect statistics on number of: read, supplementary reads, unmapped reads, qcfail reads, duplicate reads.
16 * It will also create Histogram objects to store counts of: mapq, nm, isize, clip, mean phred score, length
17 */
18 class BamReadGroup {
19
20 friend class BamStats;
21
22 public:
23
24 /** Construct an empty BamReadGroup */
25 BamReadGroup() {}
26
27 /** Construct an empty BamReadGroup for the specified read group
28 * @param name Name of the read group
29 */
30 BamReadGroup(const std::string& name);
31
32 /** Display basic information about this read group
33 */
34 friend std::ostream& operator<<(std::ostream& out, const BamReadGroup& rg);
35
36 /** Add a BamRecord to this read group */
37 void addRead(BamRecord &r);
38
39 private:
40
41 size_t reads;
42 size_t supp;
43 size_t unmap;
44 size_t qcfail;
45 size_t duplicate;
46 size_t mate_unmap;
47
48 Histogram mapq;
49 Histogram nm;
50 Histogram isize;
51 Histogram clip;
52 Histogram phred;
53 Histogram len;
54
55 std::string m_name;
56
57 };
58
59 /** Class to store statistics on a BAM file.
60 *
61 * BamStats currently stores a map of BamReadGroup objects. Bam statistics
62 * are collected then on a read-group basis, but can be output in aggregate. See
63 * BamReadGroup for description of relevant BAM statistics.
64 */
65 class BamStats
66 {
67
68 public:
69
70 /** Loop through the BamReadGroup objections and print them */
71 friend std::ostream& operator<<(std::ostream& out, const BamStats& qc);
72
73 /** Add a read by finding which read group it belongs to and calling the
74 * addRead function for that BamReadGroup.
75 */
76 void addRead(BamRecord &r);
77
78 private:
79
80 std::unordered_map<std::string, BamReadGroup> m_group_map;
81
82 };
83
84 }
85
86 #endif