biopython 脚本给出错误 'invalid syntax'
biopython script giving error 'invalid syntax'
我正在尝试应用 biopython 代码来拆分大型 fasta 文件。代码就是上面那个:
def batch_iterator():
entry=True # to make sure the loop run once
while entry:
batch=[]
while len(batch) < batch_size:
try:
entry=iterator.next()
except StopIteration:
entry=None
if entry is None:
#end of file
break
batch.append(entry)
if batch:
yield batch
record_iter=SeqIO.parse(open('/home/to/file/sorted_sequence.fa', 'fasta')
for i, batch in enumerate (batch_iterator(record_iter, 93)):
filename='gene_%i.fasta' % (i + 1)
with open('/home/path/files/', filename, 'w') as ouput_handle:
count=SeqIO.write(batch, ouput_handle, 'fasta')
print ('Wrote %i records to %s' % (count, filename))
在这一行中:
for i, batch in enumerate (batch_iterator(record_iter, 93)): 给了我
语法错误:语法无效。但是我看不到错误,谁能帮我找到它吗?
我从这个 http://biopython.org/wiki/Split_large_file 中获取了代码
谢谢
您在这一行中缺少括号
record_iter = SeqIO.parse(open('/home/to/file/sorted_sequence.fa', 'fasta')
尝试添加一个
record_iter = SeqIO.parse(open('/home/to/file/sorted_sequence.fa'), 'fasta')
我正在尝试应用 biopython 代码来拆分大型 fasta 文件。代码就是上面那个:
def batch_iterator():
entry=True # to make sure the loop run once
while entry:
batch=[]
while len(batch) < batch_size:
try:
entry=iterator.next()
except StopIteration:
entry=None
if entry is None:
#end of file
break
batch.append(entry)
if batch:
yield batch
record_iter=SeqIO.parse(open('/home/to/file/sorted_sequence.fa', 'fasta')
for i, batch in enumerate (batch_iterator(record_iter, 93)):
filename='gene_%i.fasta' % (i + 1)
with open('/home/path/files/', filename, 'w') as ouput_handle:
count=SeqIO.write(batch, ouput_handle, 'fasta')
print ('Wrote %i records to %s' % (count, filename))
在这一行中: for i, batch in enumerate (batch_iterator(record_iter, 93)): 给了我 语法错误:语法无效。但是我看不到错误,谁能帮我找到它吗? 我从这个 http://biopython.org/wiki/Split_large_file 中获取了代码 谢谢
您在这一行中缺少括号
record_iter = SeqIO.parse(open('/home/to/file/sorted_sequence.fa', 'fasta')
尝试添加一个
record_iter = SeqIO.parse(open('/home/to/file/sorted_sequence.fa'), 'fasta')