BioPython SeqIO:[Errno 2]没有这样的文件或目录:'d'

时间:2018-10-10 14:41:07

标签: python biopython

我正在尝试使用SeqIO.parse遍历一个很大的fasta文件,但是遇到了一些问题。这是我的测试脚本示例:

from Bio import SeqIO

file = 'large.fasta'

for seq_record in SeqIO.parse(file[0], 'fasta'):
    print (seq_record)

它给出的错误是:

Traceback (most recent call last):
  File "test.py", line 12, in <module>
    for seq_record in SeqIO.parse(file[0], 'fasta'):
  File "/Users/francoiskroll/miniconda3/lib/python3.6/site-packages/Bio/SeqIO/__init__.py", line 618, in parse
    with as_handle(handle, mode) as fp:
  File "/Users/francoiskroll/miniconda3/lib/python3.6/contextlib.py", line 81, in __enter__
    return next(self.gen)
  File "/Users/francoiskroll/miniconda3/lib/python3.6/site-packages/Bio/File.py", line 101, in as_handle
    with open(handleish, mode, **kwargs) as fp:
FileNotFoundError: [Errno 2] No such file or directory: 'l'

你能帮忙吗?

1 个答案:

答案 0 :(得分:0)

文件的第一个字母是d,因为如果file是字符串,则file[0]是第一个字符

for seq_record in SeqIO.parse(file, 'fasta'):
    print (seq_record)