# 讀取RNA序列字元串
rna = ''
for line in open('A06662-RNA.fasta'):
if not line.startswith('>'):
rna = rna + line.strip()
# translate one frame at a time
for frame in range(3):
prot = ''
print ('Reading frame ' + str(frame + 1))
for i in range(frame, len(rna), 3):
codon = rna[i:i + 3]
if codon in codon_table:
if codon_table[codon] == 'STOP':
prot = prot + '*'
else:
prot = prot + codon_table[codon]
else:
# handle too short codons
prot = prot + '-'
# format to blocks of 48 columns
i = 0
while i < len(prot):
print (prot[i:i + 48])
i = i + 48