我正在尝试读取一个FASTA文件,然后查找特定的motif(string)并打印出其序列和出现次数。FASTA文件只是一系列以头部行开始的序列(字符串),头部或新序列的标志为">"。在头部之后的新行中是字母序列。目前我还没有完成代码,但到目前为止我有这个并且它给我这个错误:
我不确定这里出了什么问题。
AttributeError:'str'对象没有'next'属性
我不确定这里出了什么问题。
import re
header=""
counts=0
newline=""
f1=open('fpprotein_fasta(2).txt','r')
f2=open('motifs.xls','w')
for line in f1:
if line.startswith('>'):
header=line
#print header
nextline=line.next()
for i in nextline:
motif="ML[A-Z][A-Z][IV]R"
if re.findall(motif,nextline):
counts+=1
#print (header+'\t'+counts+'\t'+motif+'\n')
fout.write(header+'\t'+counts+'\t'+motif+'\n')
f1.close()
f2.close()