Hi, I am rather new to this, but I looking to learn Biopython.
I am using Anaconda 5.3, Biopython 1.72, Jupyter 5.7.2 on Windows 10.
I am trying the following code:
from Bio.PDB import *
from Bio.PDB.PDBParser import PDBParser
parser = PDBParser()
struc = parser.get_structure('test', '1FAT.pdb')
However, I get a FileNotFoundError:
FileNotFoundError Traceback (most recent call last)
<ipython-input-5-bc8e45627a00> in <module>()
4 from Bio.PDB.PDBParser import PDBParser
5 p = PDBParser()
----> 6 struc = p.get_structure('test', '1FAT.pdb')
~\Anaconda3\lib\site-packages\Bio\PDB\PDBParser.py in get_structure(self, id, file)
83 self.structure_builder.init_structure(id)
84
---> 85 with as_handle(file, mode='rU') as handle:
86 self._parse(handle.readlines())
87
~\Anaconda3\lib\contextlib.py in __enter__(self)
110 del self.args, self.kwds, self.func
111 try:
--> 112 return next(self.gen)
113 except StopIteration:
114 raise RuntimeError("generator didn't yield") from None
~\Anaconda3\lib\site-packages\Bio\File.py in as_handle(handleish, mode, **kwargs)
99 yield fp
100 else:
--> 101 with open(handleish, mode, **kwargs) as fp:
102 yield fp
103 else:
FileNotFoundError: [Errno 2] No such file or directory: '1FAT.pdb'
It can be that I am very tired at the moment, but I can't get it to work. I thought Bio.PDB was automatically set up to get files from the PDB database. I have tried to retrive the file from PDB first, and putting in the whole filepath, but I keep on getting the same error. I tried to understand what the error message tells me, but I must confess I don't completely understand it, more than it can't find the file. I will be very grateful for any help.
I don't think that's the case, you'll need to download the file first. Maybe Bio.PDB has a different method to download directly from PDB site, but it's not the
parser.get_structure()
method.Could you maybe show us the command that has the whole file path? Have you tried using that file path with vanilla file reading code? That will tell you if the parser's method is the problem or if the path itself is not being read properly. If you have spaces or special characters in the file path, many programs can error out.
EDIT:
From the manual:
Thank you! I got it to work when I used MMCIFParser() and downloaded the files in beforehand.