有人可以帮帮我吗? 我一直收到这个错误:
AttributeError:' builtin_function_or_method'对象没有属性' count'
这是我的代码:
fin=open("ah_d_01_CGATGT_L003_R1_001.fastq","r")
fout=open("ah_d_01_CGATGT_L003_R1_001.filt.fastq","w")
maxN=4
contatutte=containcl=0
seq=""
for line in fin:
seq=fin.readline
ctrl=fin.readline
qual=fin.readline
countN=seq.count("N", start=0, end=len(seq))
if maxN>countN:
fout.write(line) #eventualmente aggiungi +"\n"
fout.write(seq)
fout.write(ctrl)
fout.write(qual)
containcl+=1
fin.close
fout.close
print contatutte,containcl
由于
答案 0 :(得分:1)
您必须正确调用您的功能。在Python中,您不能省略()
。
...
for line in fin:
seq=fin.readline()
ctrl=fin.readline()
qual=fin.readline()
...
答案 1 :(得分:0)
您需要对代码进行两处更改:
seq += fin.read()
countN = seq.count("N", 0, len(seq))
下面的代码没有任何错误,但您必须根据您的算法进行一些更改
fin=open("README.txt","r")
fout=open("submittest.txt","w")
maxN=4
contatutte=containcl=0
seq=""
seq += fin.read()
ctrl=fin.read()
qual=fin.read()
countN = seq.count("N", 0, len(seq))
if maxN>countN:
#fout.write(line) #eventualmente aggiungi +"\n"
fout.write(seq)
fout.write(ctrl)
fout.write(qual)
containcl+=1
fin.close
fout.close
print contatutte,containcl
或
fout=open("submittest.txt","w")
maxN=1000
contatutte=containcl=0
seq=""
with open('README.txt') as f:
for line in f:
seq += line
ctrl = line
qual = line
countN = seq.count("N", 0, len(seq))
if maxN>countN:
#fout.write(line) #eventualmente aggiungi +"\n"
fout.write(seq)
fout.write(ctrl)
fout.write(qual)
containcl+=1
if 'str' in line:
break
fout.close
print contatutte,containcl