Dictionary can be used to translate a given cDNA sequence into a protein sequence
1 #!/bin/python2 #Dictionary Protein Translation3 4My_dna = open ("/home/maque/my_dna.txt"). Read (). replace ('\ n',"')#use Str.replace () method to remove ' \ n ' so that My_dna is a single string5 6Condon_table = {"TTT":"F","TTC":"F","TTA":"L","TTG":"L",7 "TCT":"S","TCC":"S","TCA":"S","TCG":"S",8 "TAT":"Y","TAC":"Y","TAA":"*","TAG":"*",9 "TGT":"C","TGC":"C","TGA":"*","TGG":"W",Ten "CTT":"L","CTC":"L","CTA":"L","CTG":"L", One "CCT":"P","CCC":"P","CCA":"P","CCG":"P", A "CAT":"H","CAC":"H","CAA":"Q","CAG":"Q", - "CGT":"R","CGC":"R","CGA":"R","CGG":"R", - "ATT":"I","ATC":"I","ATA":"I","ATG":"M", the "ACT":"T","ACC":"T","ACA":"T","ACG":"T", - "AAT":"N","AAC":"N","AAA":"K","AAG":"K", - "AGT":"S","AGC":"S","AGA":"R","AGG":"R", - "GTT":"V","GTC":"V","GTA":"V","GTG":"V", + "GCT":"A","GCC":"A","GCA":"A","GCG":"A", - "GAT":"D","GAC":"D","GAA":"E","GAG":"E", + "GGT":"G","GGC":"G","GGA":"G","GGG":"G"}#Create a dictionary contains the codon table A atCodon_range = Range (0, Len (My_dna), 3)#Vary clever step -Protein ="" - - forSiteinchCodon_range: -codon = my_dna[site:site+3] -Amino_acid = Condon_table[codon]#codon is a ' key ' ina dictionary inProtein = protein +Amino_acid - to Print(protein)
Translating a given sequence into a protein sequence