Skip to content

Instantly share code, notes, and snippets.

@kelly-sovacool
Created September 26, 2019 18:14
Show Gist options
  • Save kelly-sovacool/883342d825ff17f2271cd240c26f2cd2 to your computer and use it in GitHub Desktop.
Save kelly-sovacool/883342d825ff17f2271cd240c26f2cd2 to your computer and use it in GitHub Desktop.
The first program I ever wrote! In 10th grade I was inspired by my biomedical science class. Saved here for posterity.
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main ()
{
while (true) { //This repeats the program. You close console window manually by clicking "x".
system ("CLS");//this will clear previous text
cin.clear(); //this will clear any values remain in cin from prior run
int ques1;
string code;
string ques2;
cout<<"Welcome to Kelly's Genetic Code converter!"<< endl;
cout<<"for DNA codon to amino acid converting, Press 1"<<endl;
cout<<"for mRNA codon to amino acid converting, Press 2."<<endl;
cout<<"for amino acid to DNA-codon converting, Press 3"<<endl;
cout<<"for amino acid to mRNA-codon converting, Press 4"<<endl;
cout<<"To exit the program, Press 5"<< endl;
cin>>ques1;
//below is DNA to Amino Acid converting
if (ques1==1)
{cout<<"Type the 3-letter codon in all caps."<<endl;
cin>>code;
if (code=="TAC")
{cout << "Methionine - M"<< endl;getchar();
}
else if (code=="CGA"||code=="CGG"||code=="CGT"||code=="CGC")
{cout << "Alanine - A"<< endl;getchar();
}
else if (code=="GCA"||code=="GCG"||code=="GCT"||code=="GCC"||code=="TCC"||code=="TCT"||code=="TCG"||code=="TCA")
{cout << "Arginine - R"<< endl;getchar();
}
else if (code=="TTG"||code=="TTA")
{cout << "Asparagine - N"<< endl;getchar();
}
else if (code=="CTA"||code=="CTG")
{cout << "Aspartic Acid - D"<< endl;getchar();
}
else if (code=="ACA"||code=="ACG")
{cout << "Cysteine - C"<< endl;getchar();
}
else if (code=="GTC"||code=="GTT")
{cout << "Glutamine - Q"<< endl;getchar();
}
else if (code=="CTT"||code=="CTC")
{cout << "Glutamic Acid - E"<< endl;getchar();
}
else if (code=="CCA"||code=="CCG"||code=="CCT"||code=="CCC")
{cout << "Glycine - G"<< endl;getchar();
}
else if (code=="GTA"||code=="GTG")
{cout << "Histidine - H"<< endl;getchar();
}
else if (code=="TAT"||code=="TAG"||code=="TAA")
{cout << "Isoleucine - I"<< endl;getchar();
}
else if (code=="GAA"||code=="GAG"||code=="GAT"||code=="GAC")
{cout << "Leucine - L"<< endl;getchar();
}
else if (code=="TTT"||code=="TTC")
{cout << "Lysine - K"<< endl;getchar();
}
else if (code=="AAA"||code=="AAG")
{cout << "Phenylalanine - F"<< endl;getchar();
}
else if (code=="GGA"||code=="GGG"||code=="GGT"||code=="GGC")
{cout << "Proline - P"<< endl;getchar();
}
else if (code=="AGA"||code=="AGG"||code=="AGT"||code=="AGC"||code=="TCG"||code=="TCA")
{cout << "Serine - S"<< endl;getchar();
}
else if (code=="TGC"||code=="TGT"||code=="TGA"||code=="TGG")
{cout << "Threonine - T"<< endl;getchar();
}
else if (code=="ACC")
{cout << "Tryptophan - W"<< endl;getchar();
}
else if (code=="ATA"||code=="ATG")
{cout << "Tyrosine - Y"<< endl;getchar();
}
else if (code=="CAA"||code=="CAG"||code=="CAT"||code=="CAC")
{cout << "Valine - V"<< endl;getchar();
}
else
{cout << "That's not a valid codon."<<endl;
}
}
//below is mRNA to amino acid converting
else if (ques1==2)
{cout<<"Type the 3-letter codon in all caps."<<endl;
cin>>code;
if (code=="ATG")
{cout<<"Methionine - M"<< endl;getchar();
}
else if (code=="GCT"||code=="GCC"||code=="GCA")
{cout<<"Alanine - A"<<endl;getchar();
}
else if (code=="CGT"||code=="CGC"||code=="CGA"||code=="CGG"||code=="AGG"||code=="AGA"||code=="AGC"||code=="AGT")
{cout<<"Arginine - R"<<endl;getchar();
}
else if (code=="AAC"||code=="AAT")
{cout<<"Asparagine - N"<<endl;getchar();
}
else if (code=="GAT"||code=="GAC")
{cout<<"Aspartic Acid - D"<<endl;getchar();
}
else if (code=="TGT"||code=="TGC")
{cout<<"Cysteine - C"<<endl;getchar();
}
else if (code=="CAG"||code=="CAA")
{cout<<"Glutamine - Q"<<endl;getchar();
}
else if (code=="GAA"||code=="GAG")
{cout<<"Glutamic Acid - E"<<endl;getchar();
}
else if (code=="GGT"||code=="GGC"||code=="GGA"||code=="GGG")
{cout<<"Glycine - G"<<endl;getchar();
}
else if (code=="CAT"||code=="CAC")
{cout<<"Histidine - H"<<endl;getchar();
}
else if (code=="ATA"||code=="ATC"||code=="ATT")
{cout<<"Isoleucine - I"<<endl;getchar();
}
else if (code=="CTT"||code=="CTC"||code=="CTA"||code=="CTG")
{cout<<"Leucine - L"<<endl;getchar();
}
else if (code=="AAA"||code=="AAG")
{cout<<"Lysine - K"<<endl;getchar();
}
else if (code=="TTT"||code=="TTC")
{cout<<"Phenylalanine - F"<<endl;getchar();
}
else if (code=="CCT"||code=="CCC"||code=="CCA"||code=="CCG")
{cout<<"Proline - P"<<endl;getchar();
}
else if (code=="TCT"||code=="TCC"||code=="TCA"||code=="TCG"||code=="AGC"||code=="AGT")
{cout<<"Serine - S"<<endl;getchar();
}
else if (code=="ACG"||code=="ACA"||code=="ACT"||code=="ACC")
{cout<<"Threonine - T"<<endl;getchar();
}
else if (code=="TGG")
{cout<<"Tryptophan - W"<<endl;getchar();
}
else if (code=="TAT"||code=="TAC")
{cout<<"Tyrosine - Y"<<endl;getchar();
}
else if (code=="GTT"||code=="GTC"||code=="GTA"||code=="GTG")
{cout<<"Valine - V"<<endl;getchar();
}
else
{cout<<"That's not a valid codon."<<endl;
}
}
//below is amino acid to DNA
else if (ques1==3)
{cout<<"Type the single-letter abbreviation of the amino acid."<<endl;
cin>>code;
if (code=="A"||code=="a")
{cout<<"Alanine - CGA,CGG,CGT,CGC"<<endl;getchar();
}
else if (code=="R"||code=="r")
{cout<<"Arginine - GCA,GCG,GCT,GCC,TCC,TCT,TCG,TCA"<<endl;getchar();
}
else if (code=="N"||code=="n")
{cout<<"Asparagine - TTG,TTA"<<endl;getchar();
}
else if (code=="D"||code=="d")
{cout<<"Aspartic Acid - CTA,CTG"<<endl;getchar();
}
else if (code=="C"||code=="c")
{cout<<"Cysteine - ACA,ACG"<<endl;getchar();
}
else if (code=="Q"||code=="q")
{cout<<"Glutamine - GTC,GTT"<<endl;getchar();
}
else if (code=="E"||code=="e")
{cout<<"Glutamic Acid - CTT,CTC"<<endl;getchar();
}
else if (code=="G"||code=="g")
{cout<<"Glycine - CCA,CCG,CCT,CCC"<<endl;getchar();
}
else if (code=="H"||code=="h")
{cout<<"Histidine - GTA, GTG"<<endl;getchar();
}
else if (code=="I"||code=="i")
{cout<<"Isoleucine - TAT,TAG,TAA"<<endl;getchar();
}
else if (code=="L"||code=="l")
{cout<<"Leucine - GAA,GAG,GAT,GAC"<<endl;getchar();
}
else if (code=="K"||code=="k")
{cout<<"Lysine - TTT,TTC"<<endl;getchar();
}
else if (code=="M"||code=="m")
{cout<<"Methionine - TAC"<<endl;getchar();
}
else if (code=="F"||code=="f")
{cout<<"Phenylalanine - AAA,AAG"<<endl;getchar();
}
else if (code=="P"||code=="p")
{cout<<"Proline - GGA,GGG,GGT,GGC"<<endl;getchar();
}
else if (code=="S"||code=="s")
{cout<<"Serine - AGA,AGG,AGT,AGC,TCG,TCA"<<endl;getchar();
}
else if (code=="T"||code=="t")
{cout<<"Threonine - TGC,TGT,TGA,TGG"<<endl;getchar();
}
else if (code=="W"||code=="w")
{cout<<"Tryptophan - ACC"<<endl;getchar();
}
else if (code=="Y"||code=="y")
{cout<<"Tyrosine - ATA,ATG"<<endl;getchar();
}
else if (code=="V"||code=="v")
{cout<<"Valine - CAA,CAG,CAT,CAC"<<endl;getchar();
}
else
{cout<<"That's not a valid amino acid."<<endl;
}
}
//below is amino acid to mRNA
else if (ques1==4)
{cout<<"Type the single-letter abbreviation of the amino acid in caps."<<endl;
cin>>code;
if (code=="A"||code=="a")
{cout<<"Alanine - GCT,GCC,GCA,GCG"<<endl;getchar();
}
else if (code=="R"||code=="r")
{cout<<"Arginine - CGT,CGC,CGA,CGG,AGG,AGA,AGC,AGT"<<endl;getchar();
}
else if (code=="N"||code=="n")
{cout<<"Asparagine - AAC,AAT"<<endl;getchar();
}
else if (code=="D"||code=="d")
{cout<<"Aspartic Acid - GAT,GAC"<<endl;getchar();
}
else if (code=="C"||code=="c")
{cout<<"Cysteine - TGT,TGC"<<endl;getchar();
}
else if (code=="Q"||code=="q")
{cout<<"Glutamine - CAG,CAA"<<endl;getchar();
}
else if (code=="E"||code=="e")
{cout<<"Glutamic Acid - GAA,GAG"<<endl;getchar();
}
else if (code=="G"||code=="g")
{cout<<"Glycine - GGT,GGC,GGA,GGG"<<endl;getchar();
}
else if (code=="H"||code=="h")
{cout<<"Histidine - CAT,CAC"<<endl;getchar();
}
else if (code=="I"||code=="i")
{cout<<"Isoleucine - ATA,ATC,ATT"<<endl;getchar();
}
else if (code=="L"||code=="l")
{cout<<"Leucine - CTT,CTC,CTA,CTG"<<endl;getchar();
}
else if (code=="K"||code=="k")
{cout<<"Lysine - AAA,AAG"<<endl;getchar();
}
else if (code=="M"||code=="m")
{cout<<"Methionine - ATG"<<endl;getchar();
}
else if (code=="F"||code=="f")
{cout<<"Phenylalanine - TTT,TTC"<<endl;getchar();
}
else if (code=="P"||code=="p")
{cout<<"Proline - CCT,CCC,CCA,CCG"<<endl;getchar();
}
else if (code=="S"||code=="s")
{cout<<"Serine - TCT,TCC,TCA,TCG,AGC,AGT"<<endl;getchar();
}
else if (code=="T"||code=="t")
{cout<<"Threonine - ACG,ACA,ACT,ACC"<<endl;getchar();
}
else if (code=="W"||code=="w")
{cout<<"Tryptophan - TGG"<<endl;getchar();
}
else if (code=="Y"||code=="y")
{cout<<"Tyrosine - TAT,TAC"<<endl;getchar();
}
else if (code=="V"||code=="v")
{cout<<"Valine - GTT,GTC,GTA,GTG"<<endl;getchar();
}
else
{cout<<"That's not a valid amino acid."<<endl;getchar();
}
}
//below is if the user wants to exit
else if (ques1==5)
{cout<<"Are you sure you want to exit? Type 'YES' or 'NO'."<<endl;
cin>>ques2;
if (ques2=="YES"||ques2=="Yes"||ques2=="yes"||ques2=="yea"||ques2=="yep"||ques2=="yup"||ques2=="ya")
{return 0;
}
else if (ques2=="NO"||ques2=="no"||ques2=="No"||ques2=="nope")
{cout<<"Okay."<<endl;
}
else
{cout<<"That's not a valid command."<<endl;
}
}
//below is if the user doesn't type a valid input for ques1
if (ques1<1||ques1>5)
{cout<<"That's not a valid command."<<endl;
}
}
system ("PAUSE");
} // this ends while loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment