So I want to write a program that checks if the DNA is mutated or not, i'm not quite sure how to explain this, so this is what it says:
Write a program to determine if a patient has a mutation in their DNA sequence which results in a change of amino acid sequence. Your program should work like this:
Enter original DNA: AAT
Enter patient DNA: AAC
The patient's amino acid sequence is not mutated.
Enter original DNA: AATTGTTCTTCT
Enter patient DNA: AACTGCAGCTCA
The patient's amino acid sequence is not mutated.
Enter original DNA: TGTCATGCCTTATTAGAAAACGGTGAG
Enter patient DNA: TGTCATGTCTTATTAGAAAAAGGTGAG
The patient's amino acid sequence is mutated.
And this is part of the text file I use:
The mappings from codon to amino acid are available in a file, called codon_amino.txt, an excerpt of which is shown here:
AAC N
AAG K
AAT N
GCG A
GCT A
GGA G
GGC G
GGG G
GGT G
So this is my code so far:
n = {}
for line in open('codons.txt'):
codon, codons = line.split()
n[codon] = codons
org = input('Enter original DNA: ')
pat = input('Enter patient DNA: ')
if n[org] == n[pat]:
print("The patient's amino acid sequence is not mutated.")
else:
print("The patient's amino acid sequence is mutated.")
So my code works OK with the first example, where there are only 3 letters being used, but the next two have more than 3, and I was wondering how I could manipulate my code to work with that too? I hope someone understands this question. Thank you in advance!