[Biopython] Bio.PDB: removing disordred atoms

Ramon Crehuet rcsqtc at iqac.csic.es
Tue May 19 14:55:11 UTC 2009


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
> 




More information about the Biopython mailing list