-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodonsTable.cpp
More file actions
68 lines (60 loc) · 1.79 KB
/
CodonsTable.cpp
File metadata and controls
68 lines (60 loc) · 1.79 KB
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
#include "CodonsTable.h"
CodonsTable::CodonsTable()
{
string fileName;
/*cout << "Enter File Name" << endl;
cin >> fileName;*/ ///found no use in taking the name every time we use the constructor so hard coded
/// the name since it doesnt change
fileName = "RNA_codon_table.txt";
LoadCodonsFromFile(fileName);
}
CodonsTable::~CodonsTable()
{
delete[] codons;
}
void CodonsTable::LoadCodonsFromFile(string codonsFileName){
ifstream theFile(codonsFileName.c_str());
string item;
char acid;
for(int i=0; i<64; i++){
if(i==56 || i== 50 || i== 48){
theFile >> item;
for(int j=0; j<3; j++){
codons[i].value[j] = item[j];
}
codons[i].value[3] = '\0';
codons[i].AminoAcid = '\0';
}else{
theFile >> item;
theFile >> acid;
for(int j=0; j<3; j++){
codons[i].value[j] = item[j];
}
codons[i].value[3] = '\0';
codons[i].AminoAcid = acid;
}
}
}
Codon CodonsTable::getAminoAcid(char* value){
for(int i=0; i<64; i++){
if((value[0] == codons[i].value[0]) && (value[1] == codons[i].value[1]) && (value[2] == codons[i].value[2])){
return codons[i];
}
}
cout << "Not Found" << endl;
}
void CodonsTable::setCodon(char * value, char AminoAcid, int index){
for(int i=0; i<3; i++){
codons[index].value[i] = value[i];
}
codons[index].value[3] = '\0';
codons[index].AminoAcid = AminoAcid;
}
bool CodonsTable::isAminoAcidValid(char a){
for(int j=0; j<64; j++){
if(a == codons[j].AminoAcid){
return true;
}
}
return false;
}