-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dstat_core.cpp
168 lines (124 loc) · 3.74 KB
/
Dstat_core.cpp
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
* Dstat_core
* Date: Mar-15-2013
* Author : Gabriel Renaud gabriel.reno [at sign here ] gmail.com
*
*/
#include "Dstat_core.h"
#include "ComputeAvgCoa_core.h"
bool computeDstat(const char allel_chimpHumanAncestor,const char allel_condition,const char allel_ind1,const char allel_ind2,const bool isCpG,DstatResult * dSres){
//must be different
if(allel_chimpHumanAncestor == allel_condition){
return false;
}
//require the reference allele to be either derived or ancestral
if( ( allel_ind1 == allel_chimpHumanAncestor) ||
( allel_ind1 == allel_condition) ){
//fine
}else{
return false;
}
//require the sample allele to be either derived or ancestral
if( ( allel_ind2 == allel_chimpHumanAncestor) ||
( allel_ind2 == allel_condition) ){
//fine
}else{
return false;
}
//AA
if( ( allel_ind1 == allel_chimpHumanAncestor) &&
( allel_ind2 == allel_chimpHumanAncestor) ){
dSres->all.counterAncAnc++;
if(isCpG)
dSres->onlyCpg.counterAncAnc++;
else
dSres->noCpg.counterAncAnc++;
if(isPotentialTransition(allel_condition,allel_chimpHumanAncestor))
dSres->transitions.counterAncAnc++;
else
dSres->transversions.counterAncAnc++;
if( (toupper(allel_chimpHumanAncestor) == 'C' &&
toupper(allel_condition) == 'T' )
||
(toupper(allel_chimpHumanAncestor) == 'G' &&
toupper(allel_condition) == 'A' ) ){
dSres->noDamage.counterAncAnc++;
}
//cout<<"AA"<<endl;
return false;
}else{
//AD
if( ( allel_ind1 == allel_chimpHumanAncestor) &&
( allel_ind2 == allel_condition) ){
// cout<<"AD"<<endl;
dSres->all.counterAncDer++;
if(isCpG)
dSres->onlyCpg.counterAncDer++;
else
dSres->noCpg.counterAncDer++;
if(isPotentialTransition(allel_condition,allel_chimpHumanAncestor))
dSres->transitions.counterAncDer++;
else
dSres->transversions.counterAncDer++;
if( (toupper(allel_chimpHumanAncestor) == 'C' &&
toupper(allel_condition) == 'T' )
||
(toupper(allel_chimpHumanAncestor) == 'G' &&
toupper(allel_condition) == 'A' ) ){
dSres->noDamage.counterAncDer++;
}
//cout<<"AD"<<endl;
return true;
}else{
//DA
if( ( allel_ind1 == allel_condition) &&
( allel_ind2 == allel_chimpHumanAncestor) ){
// cout<<"DA"<<endl;
dSres->all.counterDerAnc++;
if(isCpG)
dSres->onlyCpg.counterDerAnc++;
else
dSres->noCpg.counterDerAnc++;
if(isPotentialTransition(allel_condition,allel_chimpHumanAncestor))
dSres->transitions.counterDerAnc++;
else
dSres->transversions.counterDerAnc++;
if( (toupper(allel_chimpHumanAncestor) == 'C' &&
toupper(allel_condition) == 'T' )
||
(toupper(allel_chimpHumanAncestor) == 'G' &&
toupper(allel_condition) == 'A' ) ){
dSres->noDamage.counterDerAnc++;
}
//cout<<"DA"<<endl;
return true;
}else{
//DD
if( ( allel_ind1 == allel_condition) &&
( allel_ind2 == allel_condition) ){
dSres->all.counterDerDer++;
if(isCpG)
dSres->onlyCpg.counterDerDer++;
else
dSres->noCpg.counterDerDer++;
if(isPotentialTransition(allel_condition,allel_chimpHumanAncestor))
dSres->transitions.counterDerDer++;
else
dSres->transversions.counterDerDer++;
if( (toupper(allel_chimpHumanAncestor) == 'C' &&
toupper(allel_condition) == 'T' )
||
(toupper(allel_chimpHumanAncestor) == 'G' &&
toupper(allel_condition) == 'A' ) ){
dSres->noDamage.counterDerDer++;
}
//cout<<"DD"<<endl;
return false;
}else{
cerr<<"Dstat_core: Invalid state"<<endl;
exit(1);
}
}
}
}
}