-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathNucleotideMap.cpp
84 lines (72 loc) · 1.59 KB
/
NucleotideMap.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
// NucleotideMap.cpp: maps characters to nucleotides
#include "NucleotideMap.h"
#include <iostream>
using namespace std;
// NucleotideMap(): default constructor
NucleotideMap::NucleotideMap()
{
}
// map(): maps characters to nucleotides
Nucleotide NucleotideMap::map(char Char) const
{
if (Char == 'A' || Char == 'a')
return A;
else if (Char == 'C' || Char == 'c')
return C;
else if (Char == 'G' || Char == 'g')
return G;
else if (Char == 'T' || Char == 't')
return T;
else
{
cerr << "WARNING:NucleotideMap::map():character not a nucleotide character" << endl;
return A;
}
}
// map(): maps integers to nucleotides
Nucleotide NucleotideMap::map(int Int) const
{
if (Int == 1)
return A;
else if (Int == 2)
return C;
else if (Int == 3)
return G;
else if (Int == 4)
return T;
else
{
cerr << "WARNING:NucleotideMap::map():integer not a nucleotide integer" << endl;
return A;
}
}
// mapC(): maps integers represented as characters to nucleotides
Nucleotide NucleotideMap::mapC(char IntC) const
{
if (IntC == '1')
return A;
else if (IntC == '2')
return C;
else if (IntC == '3')
return G;
else if (IntC == '4')
return T;
else
{
cerr << "WARNING:NucleotideMap::mapC(): character not a nucleotide integer" << endl;
return A;
}
}
// mapNC(): maps Nucleotide objects into characters
char NucleotideMap::mapNC(Nucleotide nt) const
{
if (nt == A)
return 'A';
else if (nt == C)
return 'C';
else if (nt == G)
return 'G';
else // (nt == T)
return 'T';
}
// end NucleotideMap.cpp