forked from freebayes/freebayes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSample.h
135 lines (100 loc) · 4.02 KB
/
Sample.h
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
#ifndef __SAMPLE_H
#define __SAMPLE_H
#include <string>
#include <vector>
#include <map>
#include <utility>
#include "Utility.h"
#include "Allele.h"
using namespace std;
class StrandBaseCounts {
public:
int forwardRef;
int forwardAlt;
int reverseRef;
int reverseAlt;
StrandBaseCounts(void)
: forwardRef(0), forwardAlt(0), reverseRef(0), reverseAlt(0)
{ }
StrandBaseCounts(int fr,
int fa,
int rr,
int ra)
: forwardRef(fr)
, forwardAlt(fa)
, reverseRef(rr)
, reverseAlt(ra) { }
};
// sample tracking and allele sorting
class Sample : public map<string, vector<Allele*> > {
friend ostream& operator<<(ostream& out, Sample& sample);
public:
// includes both fully and partially-supported observations after adding partial obs
set<string> supportedAlleles;
void setSupportedAlleles(void);
// partial support for alleles, such as for observations that partially overlap the calling window
map<string, vector<Allele*> > partialSupport;
// for fast scaling of qualities for partial supports
map<Allele*, set<Allele*> > reversePartials;
// clear the above
void clearPartialObservations(void);
// set of partial observations (keys of the above map) cached for faster GL calculation
//vector<Allele*> partialObservations;
// if the observation (partial or otherwise) supports the allele
bool observationSupports(Allele* obs, Allele* allele);
// the number of observations for this allele
int observationCount(Allele& allele);
double observationCountInclPartials(Allele& allele);
double partialObservationCount(Allele& allele);
// the number of observations for this base
int observationCount(const string& base);
double observationCountInclPartials(const string& base);
double partialObservationCount(const string& base);
int partialObservationCount(void);
// the total number of observations
int observationCount(void);
int observationCountInclPartials(void);
// sum of quality for the given allele
// (includes partial support)
int qualSum(Allele& allele);
int qualSum(const string& base);
double partialQualSum(Allele& allele);
double partialQualSum(const string& base);
// puts alleles into the right bins if they have changed their base (as
// occurs in the case of reference alleles)
void sortReferenceAlleles(void);
StrandBaseCounts strandBaseCount(string refbase, string altbase);
int baseCount(string base, AlleleStrand strand);
string tojson(void);
};
class Samples : public map<string, Sample> {
public:
map<string, double> estimatedAlleleFrequencies(void);
void assignPartialSupport(vector<Allele>& alleles,
vector<Allele*>& partialObservations,
map<string, vector<Allele*> >& partialObservationGroups,
map<Allele*, set<Allele*> >& partialObservationSupport,
unsigned long haplotypeStart,
int haplotypeLength);
int observationCount(void);
double observationCountInclPartials(void);
int observationCount(Allele& allele);
double observationCountInclPartials(Allele& allele);
double partialObservationCount(Allele& allele);
int observationCount(const string& base);
double observationCountInclPartials(const string& base);
double partialObservationCount(const string& base);
int qualSum(Allele& allele);
int qualSum(const string& base);
double partialQualSum(Allele& allele);
double partialQualSum(const string& base);
void clearFullObservations(void);
void clearPartialObservations(void);
void setSupportedAlleles(void);
};
int countAlleles(Samples& samples);
// using this one...
void groupAlleles(Samples& samples, map<string, vector<Allele*> >& alleleGroups);
// filters... maybe move to its own file?
bool sufficientAlternateObservations(Samples& observations, int mincount, float minfraction);
#endif