-
Notifications
You must be signed in to change notification settings - Fork 2
/
SNP.cpp
132 lines (111 loc) · 2.07 KB
/
SNP.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
// SNP.cpp: Stores a SNP's information
#include "SNP.h"
#include <iostream>
using namespace std;
// SNP(): default constructor
SNP::SNP()
{
chr = '0';
varSet = 0;
count[0] = count[1] = 0;
centimorgan = -1;
}
void SNP::setCentimorgan( float cm )
{
centimorgan = cm;
}
float SNP::getCentimorgan()
{
return centimorgan;
}
int SNP::mapNucleotide(char nt)
{
int ret = -1;
if (varSet == 2){
// BOTH variants are set
if (nt == getVariant(1))
ret = 1;
else if (nt == getVariant(0))
ret = 0;
else
{
cerr << endl << "WARNING:SNPs::setmapNucleotideToBinary():"
<< nt << " is not one of variant alleles for SNP "
<< SNPID
<< endl;
cerr << "Please ensure that your input data is bi-allelic and contains NO MISSING data" << endl;
cerr << "See the GERMLINE web-site (http://www.cs.columbia.edu/~itsik/Software.htm) for" << endl;
cerr << "additional information on imputing missing data." << endl;
}
} else if(varSet == 1){
// 1ST variant is set
if (nt == getVariant(0)){
ret = 0;
} else {
setVariant(1,nt);
ret = 1;
}
} else {
// NO variants are set
setVariant(0,nt);
ret = 0;
}
if(ret != -1) count[ret]++;
return ret;
}
// getSNPID(): accessor for SNPID
string SNP::getSNPID() const
{
return SNPID;
}
// getPhysPos(): accessor for physPos
long SNP::getPhysPos() const
{
return physPos;
}
string SNP::getChr() const
{
return chr;
}
// getVariant(): accessor for variants
char SNP::getVariant(int i) const
{
return variant[i];
}
void SNP::setChr(const string& c)
{
chr = c;
}
// setSNPID(): mutator for SNPID
void SNP::setSNPID(const string& sid)
{
SNPID = sid;
}
// setPhysPos(): mutator for physPos
void SNP::setPhysPos(long pp)
{
physPos = pp;
}
void SNP::setMarkerNumber( unsigned int i )
{
num = i;
}
unsigned int SNP::getMarkerNumber()
{
return num;
}
// setVariant(): mutator for variants
void SNP::setVariant(int i, char nt)
{
if (i == 1){
variant[1] = nt;
varSet = 2;
}
else if (i == 0){
variant[0] = nt;
varSet = 1;
}
else
cerr << "WARNING:SNP::setVariant():index out of bounds" << endl;
}
// end SNP.cpp