Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
biopython脚本给出错误';无效语法';_Python_Biopython - Fatal编程技术网

biopython脚本给出错误';无效语法';

biopython脚本给出错误';无效语法';,python,biopython,Python,Biopython,我正在尝试应用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()

我正在尝试应用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))
def批处理迭代器():
entry=True#确保循环运行一次
进入时:
批次=[]
而透镜(批次)<批次尺寸:
尝试:
entry=iterator.next()
除停止迭代外:
条目=无
如果输入为无:
#文件结束
打破
批处理追加(条目)
如果是批次:
产量批次
record_iter=SeqIO.parse(open('/home/to/file/sorted_sequence.fa','fasta'))
对于i,枚举中的批(批迭代器(记录iter,93)):
filename='gene\%i.fasta'(i+1)
以open('/home/path/files/',filename'w')作为输出句柄:
count=SeqIO.write(批处理、输出句柄、“fasta”)
打印('已将%i条记录写入%s'(计数,文件名))
在这一行中: 对于i,枚举中的批处理(批迭代器(record_iter,93)):给了我 语法错误:无效语法。但是我看不到错误,有人能帮我找到吗? 我从这里取了密码
谢谢。

这一行缺少括号

record_iter = SeqIO.parse(open('/home/to/file/sorted_sequence.fa', 'fasta')
尝试添加一个

record_iter = SeqIO.parse(open('/home/to/file/sorted_sequence.fa'), 'fasta')

这一行缺少括号

record_iter = SeqIO.parse(open('/home/to/file/sorted_sequence.fa', 'fasta')
尝试添加一个

record_iter = SeqIO.parse(open('/home/to/file/sorted_sequence.fa'), 'fasta')

是的,我缺少一个括号,但正确的位置在文件名之后:
record\u iter=SeqIO.parse(open('home/to/file/sorted\u sequences.fa'),'fasta')
Yeap,我缺少一个括号,但正确的位置在文件名之后:
record\u iter=SeqIO.parse(open('home/to/file/sorted\u sequences.fa'),'fasta')