Biopython: Retrieving atomic coordinates of a model from a pdb file
1
1
Entering edit mode
7.5 years ago
souparnoa91 ▴ 20

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 • 4.8k views
ADD COMMENT
1
Entering edit mode
7.5 years ago
IP ▴ 770

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?

ADD COMMENT

Login before adding your answer.

Traffic: 1599 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