Entering edit mode
4.4 years ago
Juliofdiaz
▴
140
I using bio python to parse a GFF file, and I am using some of the sample code I found in their website (Basic GFF parsing section).
from BCBio import GFF
in_file = "my_genome.gff"
in_handle = open(in_file)
for rec in GFF.parse(in_handle):
print(rec)
in_handle.close()
When I run it on my system, I get the following error:
Traceback (most recent call last):
File "/home/zoo/zool2417/anaconda2/lib/python3.7/site-packages/Bio/SeqIO/Interfaces.py", line 42, in __init__
self.stream = open(source, "r" + mode)
TypeError: expected str, bytes or os.PathLike object, not FakeHandle
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 6, in <module>
for rec in GFF.parse(in_handle):
File "/home/zoo/user/anaconda2/lib/python3.7/site-packages/BCBio/GFF/GFFParser.py", line 746, in parse
target_lines):
File "/home/zoo/user/anaconda2/lib/python3.7/site-packages/BCBio/GFF/GFFParser.py", line 322, in parse_in_parts
for results in self.parse_simple(gff_files, limit_info, target_lines):
File "/home/zoo/user/anaconda2/lib/python3.7/site-packages/BCBio/GFF/GFFParser.py", line 343, in parse_simple
for results in self._gff_process(gff_files, limit_info, target_lines):
File "/home/zoo/zool2417/anaconda2/lib/python3.7/site-packages/BCBio/GFF/GFFParser.py", line 637, in _gff_process
for out in self._lines_to_out_info(line_gen, limit_info, target_lines):
File "/home/zoo/user/anaconda2/lib/python3.7/site-packages/BCBio/GFF/GFFParser.py", line 699, in _lines_to_out_info
fasta_recs = self._parse_fasta(FakeHandle(line_iter))
File "/home/zoo/user/anaconda2/lib/python3.7/site-packages/BCBio/GFF/GFFParser.py", line 560, in _parse_fasta
return list(SeqIO.parse(in_handle, "fasta"))
File "/home/zoo/user/anaconda2/lib/python3.7/site-packages/Bio/SeqIO/__init__.py", line 627, in parse
i = iterator_generator(handle)
File "/home/zoo/user/anaconda2/lib/python3.7/site-packages/Bio/SeqIO/FastaIO.py", line 181, in __init__
super().__init__(source, alphabet=alphabet, mode="t", fmt="Fasta")
File "/home/zoo/user/anaconda2/lib/python3.7/site-packages/Bio/SeqIO/Interfaces.py", line 46, in __init__
if source.read(0) != "":
TypeError: read() takes 1 positional argument but 2 were given
I am running python v. 3.7 and bio python v. 1.77, and bobio-gff v. 0.6.6 installed with bioconda
Any clues?
Hi,
Not related with your problem, but you forgot a bracket in
print
.António
Thanks, fixed it in the post
I didn't forget the bracket (in my comment) and it still wasn't displayed in the code block. It works with extra spaces.
For me, this seems to work with
open
and withoutopen
:bcbio-gff-0.6.6, biopython==1.77
When I try your code I get a different exception:
That's because tabs in the string
gff = "..."
didn't survive the copy-pasting. This linegff = "\t".join(gff.split())
would fix it.Anyway, the message was: try without
open
.