This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Biopython: Retrieving atomic coordinates of a model from a pdb file

Hi,

I have multiple models in a pdb file and I want to specifically retrieve the atomic coordinates of a model. I wrote the following code:

#!/usr/bin/python

from Bio.PDB.PDBParser import PDBParser

parser=PDBParser(PERMISSIVE=1)

structure_id="mode_7"
filename="mode_7.pdb"

structure=parser.get_structure(structure_id, filename)
model=structure[0]
residues=model.get_residues()
atoms=residues.get_atoms()
coord=atoms.get_coord()

And it yields the following error:

Traceback (most recent call last):
  File "./average.py", line 12, in <module>
    coord=model.get_coord()
AttributeError: 'Model' object has no attribute 'get_coord'

Can anyone please help???

Update:

I solved this problem using the following code:

#!/usr/bin/python

from Bio.PDB.PDBParser import PDBParser

parser=PDBParser(PERMISSIVE=1)

structure_id="mode_7"
filename="mode_7.pdb"

structure=parser.get_structure(structure_id, filename)
model=structure[0]
for chain in model.get_list():
    for residue in chain.get_list():
        ca=residue["CA"]
        print(ca.get_coord())
biopython python structure models

1 answer

The error you posted does not match with the code posted. In the error, in line 12 the code is:

 coord=model.get_coord()

And in the code in line 12 you have:

coord=atoms.get_coord()

The code you posted should work fine,as get_coord() is an instance of the atom class. could you update the error with the code posted?

Log in to answer this question.