-
Notifications
You must be signed in to change notification settings - Fork 2
/
FstAlleleCounter.h
79 lines (63 loc) · 2.24 KB
/
FstAlleleCounter.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
/*
* FstAlleleCounter
* Date: Aug-15-2012
* Author : Gabriel Renaud [email protected]
*
*/
#ifndef FstAlleleCounter_h
#define FstAlleleCounter_h
#include <iostream>
#include <ostream>
#include <math.h>
#include <limits>
//#include <iostream>
//#include <fstream>
using namespace std;
class FstAlleleCounter{
private:
public:
void reinitializedCounters();
//counter of mutations
unsigned int counterSame;
unsigned int counterCommon;
unsigned int counterReference;
unsigned int counterSample;
FstAlleleCounter(); //constructor
double lowerConf (const unsigned int shortBranch,const unsigned int commonBranch) const;
double highConf (const unsigned int shortBranch,const unsigned int commonBranch) const;
/* friend ostream & operator<<(ostream & os, const FstAlleleCounter & ct); */
string getHeader(string prefixToAdd="");
double fstRefSam () const ;
double fstSamRef () const ;
FstAlleleCounter & operator+= (const FstAlleleCounter & other){
counterSame += other.counterSame;
counterCommon += other.counterCommon;
counterReference += other.counterReference;
counterSample += other.counterSample;
return *this;
}
FstAlleleCounter & operator-= (const FstAlleleCounter & other){
counterSame -= other.counterSame;
counterCommon -= other.counterCommon;
counterReference -= other.counterReference;
counterSample -= other.counterSample;
return *this;
}
friend ostream& operator<<(ostream& os, const FstAlleleCounter & ct){
os<<ct.counterSame<<"\t"
<<ct.counterCommon<<"\t"
<<ct.counterReference<<"\t"
<<ct.counterSample<<"\t";
if( (ct.counterReference+ct.counterCommon) != 0)
os<<float(ct.counterReference)/float(ct.counterReference+ct.counterCommon)<<"\t"<<ct.lowerConf(ct.counterReference,ct.counterCommon)<<"\t"<<ct.highConf(ct.counterReference,ct.counterCommon);
else
os<<"nan"<<"\t"<<"nan"<<"\t"<<"nan";
os<<"\t";
if( (ct.counterSample+ct.counterCommon) != 0)
os<<float(ct.counterSample)/float(ct.counterSample+ct.counterCommon)<<"\t"<<ct.lowerConf(ct.counterSample,ct.counterCommon)<<"\t"<<ct.highConf(ct.counterSample,ct.counterCommon);
else
os<<"nan"<<"\t"<<"nan"<<"\t"<<"nan";
return os;
}
};
#endif