Debian Codegraph @

src/Sample.h

raw
1 #ifndef FREEBAYES_SAMPLE_H
2 #define FREEBAYES_SAMPLE_H
3
4 #include <string>
5 #include <vector>
6 #include <map>
7 #include <utility>
8 #include "Utility.h"
9 #include "Allele.h"
10
11 using namespace std;
12
13 class StrandBaseCounts {
14
15 public:
16 int forwardRef;
17 int forwardAlt;
18 int reverseRef;
19 int reverseAlt;
20
21 StrandBaseCounts(void)
22 : forwardRef(0), forwardAlt(0), reverseRef(0), reverseAlt(0)
23 { }
24
25 StrandBaseCounts(int fr,
26 int fa,
27 int rr,
28 int ra)
29 : forwardRef(fr)
30 , forwardAlt(fa)
31 , reverseRef(rr)
32 , reverseAlt(ra) { }
33
34 };
35
36 // sample tracking and allele sorting
37 class Sample : public map<string, vector<Allele*> > {
38
39 friend ostream& operator<<(ostream& out, Sample& sample);
40
41 public:
42
43 // includes both fully and partially-supported observations after adding partial obs
44 set<string> supportedAlleles;
45 void setSupportedAlleles(void);
46
47 // partial support for alleles, such as for observations that partially overlap the calling window
48 map<string, vector<Allele*> > partialSupport;
49
50 // for fast scaling of qualities for partial supports
51 map<Allele*, set<Allele*> > reversePartials;
52
53 // clear the above
54 void clearPartialObservations(void);
55
56 // set of partial observations (keys of the above map) cached for faster GL calculation
57 //vector<Allele*> partialObservations;
58
59 // if the observation (partial or otherwise) supports the allele
60 bool observationSupports(Allele* obs, Allele* allele);
61
62 // the number of observations for this allele
63 int observationCount(Allele& allele);
64 double observationCountInclPartials(Allele& allele);
65 double partialObservationCount(Allele& allele);
66
67 // the number of observations for this base
68 int observationCount(const string& base);
69 double observationCountInclPartials(const string& base);
70 double partialObservationCount(const string& base);
71 int partialObservationCount(void);
72
73 // the total number of observations
74 int observationCount(void);
75 int observationCountInclPartials(void);
76
77 // sum of quality for the given allele
78 // (includes partial support)
79 int qualSum(Allele& allele);
80 int qualSum(const string& base);
81 double partialQualSum(Allele& allele);
82 double partialQualSum(const string& base);
83
84 // puts alleles into the right bins if they have changed their base (as
85 // occurs in the case of reference alleles)
86 void sortReferenceAlleles(void);
87
88 StrandBaseCounts strandBaseCount(string refbase, string altbase);
89
90 int baseCount(string base, AlleleStrand strand);
91
92 string tojson(void);
93
94 };
95
96 class Samples : public map<string, Sample> {
97 public:
98 map<string, double> estimatedAlleleFrequencies(void);
99 void assignPartialSupport(vector<Allele>& alleles,
100 vector<Allele*>& partialObservations,
101 map<string, vector<Allele*> >& partialObservationGroups,
102 map<Allele*, set<Allele*> >& partialObservationSupport,
103 unsigned long haplotypeStart,
104 int haplotypeLength);
105
106 int observationCount(void);
107 double observationCountInclPartials(void);
108
109 int observationCount(Allele& allele);
110 double observationCountInclPartials(Allele& allele);
111 double partialObservationCount(Allele& allele);
112
113 int observationCount(const string& base);
114 double observationCountInclPartials(const string& base);
115 double partialObservationCount(const string& base);
116
117 int qualSum(Allele& allele);
118 int qualSum(const string& base);
119 double partialQualSum(Allele& allele);
120 double partialQualSum(const string& base);
121
122 void clearFullObservations(void);
123 void clearPartialObservations(void);
124 void setSupportedAlleles(void);
125 };
126
127 int countAlleles(Samples& samples);
128 // using this one...
129 void groupAlleles(Samples& samples, map<string, vector<Allele*> >& alleleGroups);
130
131 // filters... maybe move to its own file?
132 bool sufficientAlternateObservations(Samples& observations, int mincount, float minfraction);
133
134
135 #endif