130,243 views
37 votes
37 votes
Write a program that repeatedly accepts as input a string of ACGT triples and produces a list of the triples and the corresponding amino acids, one set per line. The program will continue to accept input until the user just presses ENTER without entering any DNA codes.

User Sehafoc
by
2.7k points

1 Answer

19 votes
19 votes

Answer:

Step-by-step explanation:

The following code is written in Python. I created a dictionary with all the possible gene combinations and their corresponding amino acids. The user then enters a string. The string is split into triples and checked against the dictionary. If a value exists the gene and amino acid is printed, otherwise an "Invalid Sequence" error is printed for that triple. The program has been tested and the output can be seen in the attached image below.

def printAminoAcids():

data = {

'TTT': 'Phe', 'TCT': 'Ser', 'TGT': 'Cys', 'TAT': 'Tyr',

'TTC': 'Phe', 'TCC': 'Ser', 'TGC': 'Cys', 'TAC': 'Tyr',

'TTG': 'Leu', 'TCG': 'Ser', 'TGG': 'Trp', 'TAG': '***',

'TTA': 'Leu', 'TCA': 'Ser', 'TGA': '***', 'TAA': '***',

'CTT': 'Leu', 'CCT': 'Pro', 'CGT': 'Arg', 'CAT': 'His',

'CTC': 'Leu', 'CCC': 'Pro', 'CGC': 'Arg', 'CAC': 'His',

'CTG': 'Leu', 'CCG': 'Pro', 'CGG': 'Arg', 'CAG': 'Gln',

'CTA': 'Leu', 'CCA': 'Pro', 'CGA': 'Arg', 'CAA': 'Gln',

'GTT': 'Val', 'GCT': 'Ala', 'GGT': 'Gly', 'GAT': 'Asp',

'GTC': 'Val', 'GCC': 'Ala', 'GGC': 'Gly', 'GAC': 'Asp',

'GTG': 'Val', 'GCG': 'Ala', 'GGG': 'Gly', 'GAG': 'Glu',

'GTA': 'Val', 'GCA': 'Ala', 'GGA': 'Gly', 'GAA': 'Glu',

'ATT': 'Ile', 'ACT': 'Thr', 'AGT': 'Ser', 'AAT': 'Asn',

'ATC': 'Ile', 'ACC': 'Thr', 'AGC': 'Ser', 'AAC': 'Asn',

'ATG': 'Met', 'ACG': 'Thr', 'AGG': 'Arg', 'AAG': 'Lys',

'ATA': 'Ile', 'ACA': 'Thr', 'AGA': 'Arg', 'AAA': 'Lys'

}

string = input("Enter Sequence or just click Enter to quit: ")

sequence_list = []

count = 0

gene = ""

for x in range(len(string)):

if count < 3:

gene += string[x]

count += 1

else:

sequence_list.append(gene)

gene = ""

gene += string[x]

count = 1

sequence_list.append(gene)

for gene in sequence_list:

if gene.upper() in data:

print(str(gene.upper()) + ": " + str(data[gene.upper()]))

else:

print(str(gene.upper()) + ": invalid sequence")

printAminoAcids()

Write a program that repeatedly accepts as input a string of ACGT triples and produces-example-1
User Shaundell
by
2.4k points