Question: Error: Parsing Pdb File With Biopython
1
gravatar for Mkl
7.5 years ago by
Mkl100
Mkl100 wrote:

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, ' ')
pdb biopython parsing • 4.5k views
ADD COMMENTlink written 7.5 years ago by Mkl100
2

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 REPLYlink written 7.5 years ago by Peter5.8k

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

ADD REPLYlink written 7.5 years ago by Harpalss310

@peter Iam using biopython 1.57

ADD REPLYlink written 7.4 years ago by Mkl100

Can you update your Biopython, the current release is 1.58

ADD REPLYlink written 7.4 years ago by Peter5.8k
2
gravatar for Aurobhima
7.1 years ago by
Aurobhima100
University of Birmingham
Aurobhima100 wrote:

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 COMMENTlink written 7.1 years ago by Aurobhima100

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

ADD REPLYlink written 2.1 years ago by underoath0060

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 REPLYlink written 2.1 years ago by WouterDeCoster38k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1371 users visited in the last hour