我是新的编程,希望这只是一个简单的修复。除了我试图在序列中找到N
的数目外,其他一切都在工作。这是我正在使用的代码:
from __future__ import division
print "Sequence Information"
f = open('**,fasta','r')
while True:
seqId = f.readline()
#Check if there are still lines
if not seqId: break
seqId = seqId.strip()[1:]
seq = f.readline()
# Find the %GC
gcPercent = (( seq.count('G') + seq.count('g') + seq.count('c') + seq.count('C') ) / (len( seq )) *100)
N = (seq.count('N') + 1)
print "%s\t%d\t%.4f" % (seqId, len( seq ), gcPercent, N)
我不断得到以下错误:
Traceback (most recent call last):
File "length", line 20, in <module>
print "%s\t%d\t%.4f" % (seqId, len( seq ), gcPercent, N)
TypeError: not all arguments converted during string formatting
如何将N
的值添加到第4列?你知道吗
您为
%
提供了四个参数,但只有三个格式字段:Python要求每个参数有一个格式字段,如下所示:
当然,现代Python代码应该使用^{} :
相关问题 更多 >
编程相关推荐