[Biopython] Save custom structure...

Peter biopython at maubp.freeserve.co.uk
Wed Jan 6 15:49:24 UTC 2010


2010/1/6 Yasser Almeida Hernández <pedro.al at fenhi.uh.cu>:
> You thought right!! But my big doubt is how to use the Select class. The
> example with the Gly selection in the FAQ document is not so clear to me to
> apply on my problem.
> Let's say:
> I've selected the ASP 10 in the chain 'A' and the atom O1 in a ligand, all
> in the pdb file 1xyz. How i use the Select class (sintaxis) to write a new
> pdb file with only the residue/atom selected before? How would be the code?

Have you got a real example? There is no Asp10 in PDB file 1xyz.
But, if for the sake of argument you wanted Arg519 (in either chain)
in 1xyz you could do it like this - based on the following example I
pointed to earlier:

http://lists.open-bio.org/pipermail/biopython/2009-May/005174.html

from Bio.PDB import Select, PDBIO
from Bio.PDB.PDBParser import PDBParser

class MySelector(Select):
    def accept_residue(self, residue):
        #Only want Arg519 (in any chain)
        return residue.resname=="ARG" and residue.id[1]==519

s=PDBParser().get_structure("1XYZ", "1XYZ.pdb")
io=PDBIO()
io.set_structure(s)
io.save("1XYZ-interesting.pdb", select=MySelector())
print "Done"


Peter




More information about the Biopython mailing list