[Biopython] Bio.PDB: removing disordred atoms

Peter Cock p.j.a.cock at googlemail.com
Tue May 19 05:39:07 EDT 2009


On Tue, May 19, 2009 at 9:55 AM, Ramon Crehuet <rcsqtc at iqac.csic.es> wrote:
> Dear all,
> I'd like to save a pdb without the positions of alternative atoms,
> i.e, for disordered atoms keep only atom.altloc='A'.
> I though of something like:
>
> all_atoms=[]
> for chain in structure[0]:
>    for residue in chain.child_list:
>        all_atoms=all_atoms+residue.get_unpacked_list()
>
> for atom in all_atoms:
>    if atom.altloc=='B': del atom
> ...

Doing "del atom" just deletes the local variable atom.
i.e. it won't affect the PDB structure at all.

I would suggest you look at pages 5 and 6 of the Bio.PDB
documentation, the bit on the Select class:
http://biopython.org/DIST/docs/cookbook/biopdb_faq.pdf

You might also find this recent thread useful:
http://lists.open-bio.org/pipermail/biopython/2009-March/005005.html

Peter



More information about the Biopython mailing list