I am trying to loop through a large fasta file with SeqIO.parse
, but I am having some issues. Here is my test script as example:
from Bio import SeqIO
file = 'large.fasta'
for seq_record in SeqIO.parse(file[0], 'fasta'):
print (seq_record)
The error it gives is:
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'
Can you help?
The first letter of your file is a d, because if file
is a string, file[0]
is the first character
for seq_record in SeqIO.parse(file, 'fasta'):
print (seq_record)