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
|
int main(){
map<char, set<string>> encs;
string protein;
const string RNA;
const set<string>& codes = {};
set<string>::const_iterator itr;
int counter = 0;
// Amino Acid (char) ... is encoded by RNA sequences (set<string>)
encs['I'] = set<string>{ "AUU", "AUC", "AUA" }; // Isoleucine
encs['L'] = set<string>{ "CUU", "CUC", "CUA", "CUG", "UUA", "UUG" }; // Leucine
encs['V'] = set<string>{ "GUU", "GUC", "GUA", "GUG" }; // Valine
encs['F'] = set<string>{ "UUU", "UUC" }; // Phenylalanine
encs['M'] = set<string>{ "AUG" }; // Methionine
encs['C'] = set<string>{ "UGU", "UGC" }; // Cysteine
encs['A'] = set<string>{ "GCU", "GCC", "GCA", "GCG" }; // Alanine
encs['G'] = set<string>{ "GGU", "GGC", "GGA", "GGG" }; // Glycine
encs['P'] = set<string>{ "CCU", "CCC", "CCA", "CCG" }; // Proline
encs['U'] = set<string>{ "ACU", "ACC", "ACA", "ACG" }; // Threonine
encs['S'] = set<string>{ "UCU", "UCC", "UCA", "UCG", "AGU", "AGC" }; // Serine
encs['Y'] = set<string>{ "UAU", "UAC" }; // Tyrosine
encs['W'] = set<string>{ "UGG" }; // Tryptophan
encs['Q'] = set<string>{ "CAA", "CAG" }; // Glutamine
encs['N'] = set<string>{ "AAU", "AAC" }; // Asparagine
encs['H'] = set<string>{ "CAU", "CAC" }; // Histidine
encs['E'] = set<string>{ "GAA", "GAG" }; // Glutamic acid
encs['D'] = set<string>{ "GAU", "GAC" }; // Aspartic acid
encs['K'] = set<string>{ "AAA", "AAG" }; // Lysine
encs['R'] = set<string>{ "CGU", "CGC", "CGA", "CGG", "AGA", "AGG" }; // Arginine
encs['-'] = set<string>{ "UAA", "UAG", "UGA" }; // Stop codons
cout << setw(15) << " " << "The amino acids are LVFMCAGPUSYWQNHEDKER-.\n";
cout << setw(15) << " " << "Enter a protein terminating with the \"-\" stop codon: ";
while (cin >> protein) {
listAllRNAStrandsFor(protein, encs, RNA,codes,itr);
cout << setw(15) << " " << "The amino acids are LVFMCAGPUSYWQNHEDKER-.\n";
cout << setw(15) << " " << "Enter a protein terminating with the \"-\" stop codon: ";
}
}
void listAllRNAStrandsFor(const string protein, map<char, set<string>>& encodings,
const string RNA, const set<string>& codes, set<string>::const_iterator itr)
{
if (itr != codes.end())// a problem
listAllRNAStrandsFor(protein.substr(1), encodings, RNA + *itr, codes, itr);
listAllRNAStrandsFor(protein, encodings, RNA, codes, ++itr);
}
void listAllRNAStrandsFor(const string protein, map<char, set<string>> &encodings,
const string RNA)
{
if (protein.empty())
{
cout << RNA;
}
else
listAllRNAStrandsFor(protein, encodings, RNA, encodings[protein[0]], encodings[protein[0]].cbegin());
}
| |