Aug-24-2017, 12:41 AM
my question here
Hello. I have been practicing on my Python skills by making a little program translating DRA/RNA codons. However, while everything else works correctly thus far, it seems that my lis.append function doesn't work properly, and doesn't actually add items to my list. Can someone spot what is going on?
Hello. I have been practicing on my Python skills by making a little program translating DRA/RNA codons. However, while everything else works correctly thus far, it seems that my lis.append function doesn't work properly, and doesn't actually add items to my list. Can someone spot what is going on?
def analyser(): bases=("A","T","U","G","C") type=0 #0=Undefined, 1=DNA, 2=RNA, 3=Hybrid DNA/RNA data=input("Please insert your DNA or RNA strand here:") print("Checking for errors...") #The following segment is incomplete, as it assumed that all codons are translated toaminoacids-regardless of start/end codons. Updates should change this segment to allow a more realistic spectrum of strands. if len(data)%3!=0: print("Incompatible number of bases. Please check your input and try again.") analyser() for i in range(1,len(data)): if data[i] not in bases: print("Incorrect base input found at position",i+1,"of the strand. Please correct your input and try again.") analyser() if "T" in data and "U" not in data: print("Strand classified as a DNA strand.") type=1 if "U" in data and "T" not in data: print("Strand classified as an RNA strand.") type=2 if "T" in data and "U" in data: print("Strand contains both U and T bases. The strand will be classified as a hybrid DNA/RNA strand, and translated accordingly.") type=3 if "T" not in data and "U" not in data: print("Strand type not determined. The strand will be translated regardless.") type=0 print("Translating strand...") amino=[] for i in range(1,len(data),3): if data[i+1]=="A": if data[i+2]=="T" or data[i+2]=="U": if data[i+3]=="G": amino.append("Methionine") else: amino.append("Isoleucine") if data[i+2]=="C": amino.append("Threonine") if data[i+2]=="A": if data[i+3]=="A" or data[i+3]=="G": amino.append("Lysine") else: amino.append("Asparagine") if data[i+2]=="G": if data[i+3]=="A" or data[i+3]=="G": amino.append("Arginine") else: amino.append("Serine") #The rest of the aminoacids have to be added. print("The strand translates into a polypeptide chain with this aminoacid composition:") print(amino)