Question: Biopython: Retrieving atomic coordinates of a model from a pdb file
1
gravatar for souparnoa91
3.4 years ago by
souparnoa9120
souparnoa9120 wrote:

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())
structure biopython python models • 2.4k views
ADD COMMENTlink modified 3.4 years ago by IP700 • written 3.4 years ago by souparnoa9120
1
gravatar for IP
3.4 years ago by
IP700
Denmark/University of Copenagen
IP700 wrote:

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 COMMENTlink modified 3.4 years ago • written 3.4 years ago by IP700
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: 999 users visited in the last hour