This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Python, DNA to Amino Acid Translation But Start at ATG Help

Second week working in Python, I am struggling to figure out how to ammend block so that translation starts at "atg" . Any help or suggestions would greatly be appreciated. Thank you

Got the translation program running but I need it to only start at "atg" reading through first 3 elements of seq. Code should be generic for any seq

out=[]
for i in range(4,len(dna),3):
 triplet=dna[i:i+3] #groups elements of DNA into triplets
 try: 
  amino=xlate[triplet] #generates string of AA for each triplet using dictionary
  if amino=='0':break
 except:
   break
 out.append(amino) 
out="".join(out)
print(out)
python protein tranlsation programming

The trick is to search first where to start, just go over your sequence and check for "atg", save that coordinate and use in the for loop.

0 answers

No answers yet.

Log in to answer this question.