Given: An RNA string s corresponding to a strand of mRNA (of length at most 10 kbp).
Return: The protein string encoded by s.
Return: The protein string encoded by s.
import sys
def codon_table():
nukaa = {}
nukaa['UUU'] = 'F'
nukaa['CUU'] = 'L'
nukaa['AUU'] = 'I'
nukaa['GUU'] = 'V'
nukaa['UUC'] = 'F'
nukaa['CUC'] = 'L'
nukaa['AUC'] = 'I'
nukaa['GUC'] = 'V'
nukaa['UUA'] = 'L'
nukaa['CUA'] = 'L'
nukaa['AUA'] = 'I'
nukaa['GUA'] = 'V'
nukaa['UUG'] = 'L'
nukaa['CUG'] = 'L'
nukaa['AUG'] = 'M'
nukaa['GUG'] = 'V'
nukaa['UCU'] = 'S'
nukaa['CCU'] = 'P'
nukaa['ACU'] = 'T'
nukaa['GCU'] = 'A'
nukaa['UCC'] = 'S'
nukaa['CCC'] = 'P'
nukaa['ACC'] = 'T'
nukaa['GCC'] = 'A'
nukaa['UCA'] = 'S'
nukaa['CCA'] = 'P'
nukaa['ACA'] = 'T'
nukaa['GCA'] = 'A'
nukaa['UCG'] = 'S'
nukaa['CCG'] = 'P'
nukaa['ACG'] = 'T'
nukaa['GCG'] = 'A'
nukaa['UAU'] = 'Y'
nukaa['CAU'] = 'H'
nukaa['AAU'] = 'N'
nukaa['GAU'] = 'D'
nukaa['UAC'] = 'Y'
nukaa['CAC'] = 'H'
nukaa['AAC'] = 'N'
nukaa['GAC'] = 'D'
nukaa['CAA'] = 'Q'
nukaa['AAA'] = 'K'
nukaa['GAA'] = 'E'
nukaa['CAG'] = 'Q'
nukaa['AAG'] = 'K'
nukaa['GAG'] = 'E'
nukaa['UGU'] = 'C'
nukaa['CGU'] = 'R'
nukaa['AGU'] = 'S'
nukaa['GGU'] = 'G'
nukaa['UGC'] = 'C'
nukaa['CGC'] = 'R'
nukaa['AGC'] = 'S'
nukaa['GGC'] = 'G'
nukaa['CGA'] = 'R'
nukaa['AGA'] = 'R'
nukaa['GGA'] = 'G'
nukaa['UGG'] = 'W'
nukaa['CGG'] = 'R'
nukaa['AGG'] = 'R'
nukaa['GGG'] = 'G'
return nukaa
def main():
if len(sys.argv) > 1:
rna_string = sys.argv[1]
nukaa = codon_table()
nucl_str_len = len(rna_string) // 3
nucl_string = ''
i = 0
while i < nucl_str_len:
codon = rna_string[3*i:3*(i+1)]
if codon=='UAA' or codon=='UAG' or codon=='UGA':
break
else:
nucl_string += nukaa[codon]
i+=1
print nucl_string
else:
print 'Enter RNA sequence.'
if __name__ == '__main__':
main()
Комментариев нет:
Отправить комментарий