[Biopython] Bio.PDB: removing disordred atoms

Brad Chapman chapmanb at 50mail.com
Thu May 21 12:09:26 UTC 2009


Ramon;
Great to hear you got this figured out with Peter's helpful
direction. It would be very useful if you could contribute this as a
cookbook example:

http://biopython.org/wiki/Category:Cookbook

with a short description of your motivation and the final code. This
would make it accessible to others with a similar problem in the
future. 

Brad

> Thanks,
> The easyiest way I found was defining a class to assert disordered atoms:
> 
> 
> class NotDisordered(Select):
>     def accept_atom(self, atom):
>         if not atom.is_disordered():
>             return 1
>         elif atom.get_altloc()=='B':
>             return 1
>         else:
>             return 0
> 
> io=PDBIO()
> 
> io.set_structure(s)
> io.save("1GS5-ord.pdb", select=NotDisordered())
> 
> 
> 
> Peter Cock wrote:
> > 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
> > 
> 
> _______________________________________________
> Biopython mailing list  -  Biopython at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biopython



More information about the Biopython mailing list