Error: Parsing Pdb File With Biopython
1
1
Entering edit mode
13.1 years ago
Mkl ▴ 100

I am trying to parse a PDB file and also trying to extract some Model, Chain, Residue and Atom objects with Biopython. I tried the following code

from Bio.PDB.PDBParser import PDBParser
parser=PDBParser()
structure=parser.get_structure("test", "1fat.pdb")
model=structure[0]
chain=model["A"]
residue=chain[1]

File "<pyshell#48>", line 1, in <module>
residue = chain[(' ', 1, ' ')]
File "C:\Python27\lib\site-packages\Bio\PDB\Chain.py", line 67, in __getitem__
return Entity.__getitem__(self, id)
File "C:\Python27\lib\site-packages\Bio\PDB\Entity.py", line 38, in __getitem__
return self.child_dict[id]
KeyError: (' ', 1, ' ')
biopython parsing pdb • 9.0k views
ADD COMMENT
2
Entering edit mode

Is that the complete code? Which version of Biopython are you using? It works for me although I do see eight warnings about discontinuous chains (a problem in the data itself).

ADD REPLY
0
Entering edit mode

Just checked the code myself, Works perfectly fine, I also get the discontinuous chain error

ADD REPLY
0
Entering edit mode

@peter Iam using biopython 1.57

ADD REPLY
0
Entering edit mode

Can you update your Biopython, the current release is 1.58

ADD REPLY
2
Entering edit mode
12.8 years ago
Aurobhima ▴ 100

you need to make sure that the residue you are trying to get is actually labelled 1.. what I do when I want something from a PDB structure is:

from Bio import PDB
parser= PDBParser()
structure=parser.get_structure("test", "1fat.pdb")
model=structure[0]
chain = model['A']

residue_list = Selection.unfold_entities(chain, 'R')

Now you have the complete list of residues within the chain you specified.

you can then specify that you want the first residue in the list:

 my_residue= residue_list[0]

NOTE: It is not uncommon that during the crystallisation process the N and C terminals of the structure have been cleaved. The residue numbering will be consistent with the residue numbering you see in the PDB file.. to check which residues you have try:

my_residue.id()

to make sure it has the number you want..

ADD COMMENT
0
Entering edit mode

I get this error "NameError: name 'Selection' is not defined"

ADD REPLY
1
Entering edit mode

I'm unfamiliar with Biopython PDB, but my first guess would be to try the following:

residue_list = PDB.Selection.unfold_entities(chain, 'R')
ADD REPLY

Login before adding your answer.

Traffic: 2168 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6