import string
import os,sys
file=open("C:\Python27\\New Text Document.txt",'r')\
seq =file.readlines() basecomplement = {'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A'}
def translate(seq):
aaseq = []
for str in seq:
aaseq.append(basecomplement[str])
return aaseq
for frame in range(1):
rseqn= (''.join(item.split('|')[0] for item in translate(seq[frame:])))
rseqn = rseqn[::-1]
print(rseqn)
print(seq)
ERROR這裏是文件關鍵錯誤補充
"C:\Users\ram\Desktop\pythonhw\dnacomp.py", line 13, in <module>
rseqn= (''.join(item.split('|')[0] for item in
translate(seq[frame:]))) File
"C:\Users\ram\Desktop\pythonhw\dnacomp.py", line 10, in translate
aaseq.append(basecomplement[str]) KeyError:
'AGTCTGGCATACCAGTACAGACTATCA'
如果我使用簡單的字符串,我也越來越序列,但我試圖讀取該文件作爲輸入,它顯示了以下錯誤
請清洗碼! – 2014-10-03 22:20:19