[Biopython] Save custom structure...

Peter biopython at maubp.freeserve.co.uk
Wed Jan 6 16:56:09 UTC 2010


2010/1/6 Yasser Almeida Hernández <pedro.al at fenhi.uh.cu>:
> I just set Asp10 in 1xyz as a hypothetical residue in a hypothetical
> structure.

I thought so - but I was hoping for a concrete example, where you
can describe explicitly which bits you are trying to select.

> One last thing:  to select the CB atom in that Arg519 with the MySelector
> class and return it with the residue, how it would be...?

So out of the entire chain, you just want atom CB from residue Arg519?
Try this then, it will give you a tiny PDB file with just two atoms, the
CB from Arg519 in the two chains.

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
    def accept_atom(self, atom):
        #Only want the CB atom (in residue Arg519)
        return atom.name == "CB"

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