00001 #include <iostream>
00002 #include <string.h>
00003 #include "GeneticCode.h"
00004
00005 const int GeneticCode::NUM_ANTICODONS = 33;
00006
00007 const int GeneticCode::NUM_CODONS = 64;
00008
00009
00010 GeneticCode::~GeneticCode()
00011 {
00012 delete [] code;
00013 }
00014
00015
00016 GeneticCode::GeneticCode()
00017 {
00018 code = new int[NUM_CODONS];
00019
00020 code[int(AAA)] = int(uuu);
00021 code[int(AAG)] = int(uuu);
00022 code[int(AAU)] = int(quu);
00023 code[int(AAC)] = int(quu);
00024 code[int(AUU)] = int(gau);
00025 code[int(AUC)] = int(gau);
00026 code[int(AUA)] = int(nau);
00027 code[int(AUG)] = int(cau);
00028 code[int(CGU)] = int(icg);
00029 code[int(CGC)] = int(icg);
00030 code[int(CGA)] = int(icg);
00031 code[int(CGG)] = int(ccg);
00032 code[int(AGA)] = int(ucu);
00033 code[int(AGG)] = int(ucu);
00034 code[int(UCU)] = int(gga);
00035 code[int(UCC)] = int(gga);
00036 code[int(UCA)] = int(gga);
00037 code[int(UCG)] = int(gga);
00038 code[int(AGU)] = int(gcu);
00039 code[int(AGC)] = int(gcu);
00040 code[int(ACU)] = int(ggu);
00041 code[int(ACC)] = int(ggu);
00042 code[int(ACA)] = int(ugu);
00043 code[int(ACG)] = int(ugu);
00044 code[int(UGG)] = int(cca);
00045 code[int(UAU)] = int(qua);
00046 code[int(UAC)] = int(qua);
00047 code[int(CUU)] = int(gag);
00048 code[int(CUC)] = int(gag);
00049 code[int(CUA)] = int(uag);
00050 code[int(CUG)] = int(cag);
00051 code[int(UUA)] = int(aaa);
00052 code[int(UUG)] = int(aaa);
00053 code[int(UUU)] = int(gaa);
00054 code[int(UUC)] = int(gaa);
00055 code[int(UGU)] = int(gca);
00056 code[int(UGC)] = int(gca);
00057 code[int(GAA)] = int(uuc);
00058 code[int(GAG)] = int(uuc);
00059 code[int(GAU)] = int(quc);
00060 code[int(GAC)] = int(quc);
00061 code[int(GUU)] = int(gac);
00062 code[int(GUC)] = int(gac);
00063 code[int(GUA)] = int(gac);
00064 code[int(GUG)] = int(gac);
00065 code[int(GGU)] = int(gcc);
00066 code[int(GGC)] = int(gcc);
00067 code[int(GGA)] = int(ucc);
00068 code[int(GGG)] = int(ccc);
00069 code[int(GCU)] = int(ggc);
00070 code[int(GCC)] = int(ggc);
00071 code[int(GCA)] = int(ggc);
00072 code[int(GCG)] = int(ggc);
00073 code[int(CAA)] = int(uug);
00074 code[int(CAG)] = int(cug);
00075 code[int(CAU)] = int(qug);
00076 code[int(CAC)] = int(qug);
00077 code[int(CCU)] = int(qgg);
00078 code[int(CCC)] = int(qgg);
00079 code[int(CCA)] = int(ugg);
00080 code[int(CCG)] = int(ugg);
00081
00082 code[int(UAA)] = int(stop);
00083 code[int(UAG)] = int(stop);
00084 code[int(UGA)] = int(stop);
00085 }
00086
00087 Anticodon GeneticCode::get_anticodon(Codon x)
00088 {
00089 return Anticodon(code[int(x)]);
00090 }
00091
00092 Codon GeneticCode::read_seq(char* seq)
00093 {
00094 if (strncmp(seq, "AAA", 3) == 0)
00095 return AAA;
00096 else if (strncmp(seq, "AAU", 3) == 0)
00097 return AAU;
00098 else if (strncmp(seq, "AAG", 3) == 0)
00099 return AAG;
00100 else if (strncmp(seq, "AAC", 3) == 0)
00101 return AAC;
00102 else if (strncmp(seq, "AUA", 3) == 0)
00103 return AUA;
00104 else if (strncmp(seq, "AUU", 3) == 0)
00105 return AUU;
00106 else if (strncmp(seq, "AUG", 3) == 0)
00107 return AUG;
00108 else if (strncmp(seq, "AUC", 3) == 0)
00109 return AUC;
00110 else if (strncmp(seq, "AGA", 3) == 0)
00111 return AGA;
00112 else if (strncmp(seq, "AGU", 3) == 0)
00113 return AGU;
00114 else if (strncmp(seq, "AGG", 3) == 0)
00115 return AGG;
00116 else if (strncmp(seq, "AGC", 3) == 0)
00117 return AGC;
00118 else if (strncmp(seq, "ACA", 3) == 0)
00119 return ACA;
00120 else if (strncmp(seq, "ACU", 3) == 0)
00121 return ACU;
00122 else if (strncmp(seq, "ACG", 3) == 0)
00123 return ACG;
00124 else if (strncmp(seq, "ACC", 3) == 0)
00125 return ACC;
00126 else if (strncmp(seq, "UAA", 3) == 0)
00127 return UAA;
00128 else if (strncmp(seq, "UAU", 3) == 0)
00129 return UAU;
00130 else if (strncmp(seq, "UAG", 3) == 0)
00131 return UAG;
00132 else if (strncmp(seq, "UAC", 3) == 0)
00133 return UAC;
00134 else if (strncmp(seq, "UUA", 3) == 0)
00135 return UUA;
00136 else if (strncmp(seq, "UUU", 3) == 0)
00137 return UUU;
00138 else if (strncmp(seq, "UUG", 3) == 0)
00139 return UUG;
00140 else if (strncmp(seq, "UUC", 3) == 0)
00141 return UUC;
00142 else if (strncmp(seq, "UGA", 3) == 0)
00143 return UGA;
00144 else if (strncmp(seq, "UGU", 3) == 0)
00145 return UGU;
00146 else if (strncmp(seq, "UGG", 3) == 0)
00147 return UGG;
00148 else if (strncmp(seq, "UGC", 3) == 0)
00149 return UGC;
00150 else if (strncmp(seq, "UCA", 3) == 0)
00151 return UCA;
00152 else if (strncmp(seq, "UCU", 3) == 0)
00153 return UCU;
00154 else if (strncmp(seq, "UCG", 3) == 0)
00155 return UCG;
00156 else if (strncmp(seq, "UCC", 3) == 0)
00157 return UCC;
00158 else if (strncmp(seq, "GAA", 3) == 0)
00159 return GAA;
00160 else if (strncmp(seq, "GAU", 3) == 0)
00161 return GAU;
00162 else if (strncmp(seq, "GAG", 3) == 0)
00163 return GAG;
00164 else if (strncmp(seq, "GAC", 3) == 0)
00165 return GAC;
00166 else if (strncmp(seq, "GUA", 3) == 0)
00167 return GUA;
00168 else if (strncmp(seq, "GUU", 3) == 0)
00169 return GUU;
00170 else if (strncmp(seq, "GUG", 3) == 0)
00171 return GUG;
00172 else if (strncmp(seq, "GUC", 3) == 0)
00173 return GUC;
00174 else if (strncmp(seq, "GGA", 3) == 0)
00175 return GGA;
00176 else if (strncmp(seq, "GGU", 3) == 0)
00177 return GGU;
00178 else if (strncmp(seq, "GGG", 3) == 0)
00179 return GGG;
00180 else if (strncmp(seq, "GGC", 3) == 0)
00181 return GGC;
00182 else if (strncmp(seq, "GCA", 3) == 0)
00183 return GCA;
00184 else if (strncmp(seq, "GCU", 3) == 0)
00185 return GCU;
00186 else if (strncmp(seq, "GCG", 3) == 0)
00187 return GCG;
00188 else if (strncmp(seq, "GCC", 3) == 0)
00189 return GCC;
00190 else if (strncmp(seq, "CAA", 3) == 0)
00191 return CAA;
00192 else if (strncmp(seq, "CAU", 3) == 0)
00193 return CAU;
00194 else if (strncmp(seq, "CAG", 3) == 0)
00195 return CAG;
00196 else if (strncmp(seq, "CAC", 3) == 0)
00197 return CAC;
00198 else if (strncmp(seq, "CUA", 3) == 0)
00199 return CUA;
00200 else if (strncmp(seq, "CUU", 3) == 0)
00201 return CUU;
00202 else if (strncmp(seq, "CUG", 3) == 0)
00203 return CUG;
00204 else if (strncmp(seq, "CUC", 3) == 0)
00205 return CUC;
00206 else if (strncmp(seq, "CGA", 3) == 0)
00207 return CGA;
00208 else if (strncmp(seq, "CGU", 3) == 0)
00209 return CGU;
00210 else if (strncmp(seq, "CGG", 3) == 0)
00211 return CGG;
00212 else if (strncmp(seq, "CGC", 3) == 0)
00213 return CGC;
00214 else if (strncmp(seq, "CCA", 3) == 0)
00215 return CCA;
00216 else if (strncmp(seq, "CCU", 3) == 0)
00217 return CCU;
00218 else if (strncmp(seq, "CCG", 3) == 0)
00219 return CCG;
00220 else if (strncmp(seq, "CCC", 3) == 0)
00221 return CCC;
00222 else
00223 {
00224 std::cout << seq << " is not a valid codon." << std::endl;
00225 return UGA;
00226 }
00227 }
00228
00229 void GeneticCode::write_seq(Codon c, char* str)
00230 {
00231 if (c==AAA)
00232 strcpy(str, "AAA");
00233 else if (c==AAU)
00234 strcpy(str, "AAU");
00235 else if (c==AAG)
00236 strcpy(str, "AAG");
00237 else if (c==AAC)
00238 strcpy(str, "AAC");
00239 else if (c==AUA)
00240 strcpy(str, "AUA");
00241 else if (c==AUU)
00242 strcpy(str, "AUU");
00243 else if (c==AUG)
00244 strcpy(str, "AUG");
00245 else if (c==AUC)
00246 strcpy(str, "AUC");
00247 else if (c==AGA)
00248 strcpy(str, "AGA");
00249 else if (c==AGU)
00250 strcpy(str, "AGU");
00251 else if (c==AGG)
00252 strcpy(str, "AGG");
00253 else if (c==AGC)
00254 strcpy(str, "AGC");
00255 else if (c==ACA)
00256 strcpy(str, "ACA");
00257 else if (c==ACU)
00258 strcpy(str, "ACU");
00259 else if (c==ACG)
00260 strcpy(str, "ACG");
00261 else if (c==ACC)
00262 strcpy(str, "ACC");
00263 else if (c==UAA)
00264 strcpy(str, "UAA");
00265 else if (c==UAU)
00266 strcpy(str, "UAU");
00267 else if (c==UAG)
00268 strcpy(str, "UAG");
00269 else if (c==UAC)
00270 strcpy(str, "UAC");
00271 else if (c==UUA)
00272 strcpy(str, "UUA");
00273 else if (c==UUU)
00274 strcpy(str, "UUU");
00275 else if (c==UUG)
00276 strcpy(str, "UUG");
00277 else if (c==UUC)
00278 strcpy(str, "UUC");
00279 else if (c==UGA)
00280 strcpy(str, "UGA");
00281 else if (c==UGU)
00282 strcpy(str, "UGU");
00283 else if (c==UGG)
00284 strcpy(str, "UGG");
00285 else if (c==UGC)
00286 strcpy(str, "UGC");
00287 else if (c==UCA)
00288 strcpy(str, "UCA");
00289 else if (c==UCU)
00290 strcpy(str, "UCU");
00291 else if (c==UCG)
00292 strcpy(str, "UCG");
00293 else if (c==UCC)
00294 strcpy(str, "UCC");
00295 else if (c==GAA)
00296 strcpy(str, "GAA");
00297 else if (c==GAU)
00298 strcpy(str, "GAU");
00299 else if (c==GAG)
00300 strcpy(str, "GAG");
00301 else if (c==GAC)
00302 strcpy(str, "GAC");
00303 else if (c==GUA)
00304 strcpy(str, "GUA");
00305 else if (c==GUU)
00306 strcpy(str, "GUU");
00307 else if (c==GUG)
00308 strcpy(str, "GUG");
00309 else if (c==GUC)
00310 strcpy(str, "GUC");
00311 else if (c==GGA)
00312 strcpy(str, "GGA");
00313 else if (c==GGU)
00314 strcpy(str, "GGU");
00315 else if (c==GGG)
00316 strcpy(str, "GGG");
00317 else if (c==GGC)
00318 strcpy(str, "GGC");
00319 else if (c==GCA)
00320 strcpy(str, "GCA");
00321 else if (c==GCU)
00322 strcpy(str, "GCU");
00323 else if (c==GCG)
00324 strcpy(str, "GCG");
00325 else if (c==GCC)
00326 strcpy(str, "GCC");
00327 else if (c==CAA)
00328 strcpy(str, "CAA");
00329 else if (c==CAU)
00330 strcpy(str, "CAU");
00331 else if (c==CAG)
00332 strcpy(str, "CAG");
00333 else if (c==CAC)
00334 strcpy(str, "CAC");
00335 else if (c==CUA)
00336 strcpy(str, "CUA");
00337 else if (c==CUU)
00338 strcpy(str, "CUU");
00339 else if (c==CUG)
00340 strcpy(str, "CUG");
00341 else if (c==CUC)
00342 strcpy(str, "CUC");
00343 else if (c==CGA)
00344 strcpy(str, "CGA");
00345 else if (c==CGU)
00346 strcpy(str, "CGU");
00347 else if (c==CGG)
00348 strcpy(str, "CGG");
00349 else if (c==CGC)
00350 strcpy(str, "CGC");
00351 else if (c==CCA)
00352 strcpy(str, "CCA");
00353 else if (c==CCU)
00354 strcpy(str, "CCU");
00355 else if (c==CCG)
00356 strcpy(str, "CCG");
00357 else if (c==CCC)
00358 strcpy(str, "CCC");
00359 else
00360 std::cout << "Not a valid codon." << std::endl;
00361 }