I am trying to replace a character in a string but it shows "None". This is related to Bioinformatics where we convert a string of sequence from DNA sequence to mRNA sequence to a protein. I want to make the following code work:
li = "ATGC"
def translate(self):
for a in li:
if a == "T":
print(a.replace("T", "U"))
else:
print(a)
li = translate(li)
li = str(li)
print(li)
li = [li[n:n+3] for n in range(0, len(li), 3)]
nucleotide_sequence_lookup_table = {
'AUG': "M",
'UUU': "F",
'UUC': "F",
'UUA': "L",
'UUG': "L",
'CUU': "L",
'CUC': "L",
'CUA': "L",
'CUG': "L",
'AUU': "I",
'AUC': "I",
'AUA': "I",
'GUU': "V",
'GUC': "V",
'GUA': "V",
'GUG': "V",
'UCU': "S",
'UCC': "S",
'UCA': "S",
'UCG': "S",
'CCU': "P",
'CCC': "P",
'CCA': "P",
'CCG': "P",
'ACU': "T",
'ACC': "T",
'ACA': "T",
'ACG': "T",
'GCU': "A",
'GCC': "A",
'GCA': "A",
'GCG': "A",
'UAU': "Y",
'UAC': "Y",
'UAA': "STOP",
'UAG': "STOP",
'CAU': "H",
'CAC': "H",
'CAA': "Q",
'CAG': "Q",
'AAU': "N",
'AAC': "N",
'AAA': "K",
'AAG': "K",
'GAU': "D",
'GAC': "D",
'GAA': "E",
'GAG': "E",
'UGU': "C",
'UGC': "C",
'UGA': "STOP",
'UGG': "W",
'CGU': "R",
'CGC': "R",
'CGA': "R",
'CGG': "R",
'AGU': "S",
'AGC': "S",
'AGA': "R",
'AGG': "R",
'GGU': "G",
'GGC': "G",
'GGA': "G",
'GGG': "G",
}
Amino_acid_list = [nucleotide_sequence_lookup_table [i] for i in li[0:-1]]
print(Amino_acid_list)
output of print after function:
A U G C None
Can anyone suggest how can we drop the none in the string and use the rest of the string for translation and transcription?