-
Notifications
You must be signed in to change notification settings - Fork 2
/
ComputeDist_core.cpp
95 lines (72 loc) · 2.34 KB
/
ComputeDist_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
/*
* ComputeDist_core
* Date: Jan-24-2013
* Author : Gabriel Renaud gabriel.reno [at sign here ] gmail.com
*
*/
#include "ComputeDist_core.h"
// #define DEBUG3
// damage (<-)
// transition (<->)
// A --------- G
// | |
// | |
// | |
// | |
// C --------- T
// transition (<->)
// damage ( ->)
inline bool isTransition(char allel_1,char allel_2){
return (
(allel_1 == 'C' && allel_2 == 'T' ) ||
(allel_1 == 'T' && allel_2 == 'C' ) ||
(allel_1 == 'A' && allel_2 == 'G' ) ||
(allel_1 == 'G' && allel_2 == 'A' )
);
}
inline bool isDamage(char allel_anc,char allel){
//return isTransition(allel_1,allel_2);//we have no way of polarizing the direction of the mutation
return (
(allel_anc == 'C' && allel == 'T' ) ||
(allel_anc == 'G' && allel == 'A' )
);
}
void computeDist(const char allel_anc,const char allel_1,const char allel_2,bool isCpG,DistResult * divr){
int allePairIndex=allelePair2Int(allel_1,allel_2);
//cerr<<allel_1<<" "<<allel_2<<" "<<allePairIndex<<endl;
divr->all.addAllelePair(allePairIndex);
if(isCpG)
divr->onlyCpg.addAllelePair(allePairIndex);
else
divr->noCpg.addAllelePair(allePairIndex);
if(isTransition(allel_1,allel_2)){
divr->transitions.addAllelePair(allePairIndex);
}else{
divr->transversions.addAllelePair(allePairIndex);
}
if( (allel_anc != 'N') &&
!isDamage( allel_anc,allel_1) &&
!isDamage( allel_anc,allel_2) ){
divr->noDamage.addAllelePair(allePairIndex);
}else{
}
}
void addIdenticalSite(const char allel_anc,const char allel_1,bool isCpG,DistResult * divr,int allePairIndex){
divr->all.addAllelePair(allePairIndex);
if(isCpG)
divr->onlyCpg.addAllelePair(allePairIndex);
else
divr->noCpg.addAllelePair(allePairIndex);
// if(isTransition(allel_1,allel_2)){
// divr->transitions.addAllelePair(allePairIndex);
// }else{
divr->transversions.addAllelePair(allePairIndex);
// }
if( (allel_anc != 'N') &&
!isDamage( allel_anc,allel_1)// &&
//!isDamage( allel_anc,allel_2)
){
divr->noDamage.addAllelePair(allePairIndex);
}else{
}
}