代码之家  ›  专栏  ›  技术社区  ›  Ana

biopython脚本出现错误“无效语法”

  •  0
  • Ana  · 技术社区  · 7 年前

    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))
    

    在此行中: 对于i,枚举中的批处理(batch\u迭代器(record\u iter,93)): 正在给我 语法错误:无效语法 . 但是我看不到错误,有人能帮我找到吗? http://biopython.org/wiki/Split_large_file 谢谢

    1 回复  |  直到 7 年前
        1
  •  2
  •   Mitiku    7 年前

    此行缺少括号

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

    尝试添加一个

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