[Biopython] Writing into a PDB file using PDBIO module
Iddo Friedberg
idoerg at gmail.com
Thu Jul 23 18:09:03 UTC 2009
Kumar:
The following works. The main error you had was that you instantiated Select
upon definition like so:
Select = Bio.PDB.Select()
Instead of:
Select = Bio.PDB.Select
Also, you used residue.get_name() instead of residue.get_resname() (there is
no get_name() method).
#!/usr/bin/python
import Bio
import os
from Bio import PDB
from Bio.PDB import PDBIO
from Bio.PDB.PDBParser import PDBParser
parser = PDBParser()
mypdb="/home/idoerg/results/libbuilder/einat_blocks/pdb/1ZUG.pdb"
filehandle = open(os.path.join(mypdb), 'rb')
structure = parser.get_structure( "1ZUG", filehandle)
filehandle.close()
Select = Bio.PDB.Select
class GlySelect(Select):
def accept_residue(self, residue):
# print dir(residue)
if residue.get_resname()=='GLY':
return 1
else:
return 0
if __name__ == '__main__':
io=PDBIO()
io.set_structure(structure)
io.save('gly_only.pdb', GlySelect())
On Thu, Jul 23, 2009 at 10:45 AM, life happy <iitlife2008 at gmail.com> wrote:
> Hi Peter ,
>
> Thanks, the links were helpful. But I am facing this problem.
>
> from Bio.PDB.PDBParser import PDBParser
> parser = PDBParser()
> filehandle = gzip.open(os.path.join("3dh4.pdb"), 'rb')
> structure = parser.get_structure( "3DH4", filehandle)
> filehandle.close()
> Select = Bio.PDB.Select()
> class GlySelect(Select):
> def accept_residue(self, residue):
> if residue.get_name()=='GLY':
> return 1
> else:
> return 0
> io=PDBIO()
> io.set_structure(structure)
> io.save('gly_only.pdb', GlySelect())
>
> I use this code but I am getting the following error!
>
> File "aligned_matches_written_to_new_pdb_file.py", line 34, in <module>
> class GlySelect(Select):
> TypeError: Error when calling the metaclass bases
> this constructor takes no arguments
>
> I have also tried the example in
> http://biopython.org/wiki/Remove_PDB_disordered_atoms.I get the same error
> message. What does this mean? Any remedy?
>
> Secondly, I didn't understand your answer to my question.."In which step
> are
> we sending the transformed co-ordinates into the PDB file? " The
> Superimposer is a black box for me. I give it atom lists, it gives me RMSD.
> But I want the aligned co-ordinates of the given atom lists, so that I can
> see the alignment in PyMol.I don't know how to extract aligned atom
> co-ordinates!
>
> Your example :-
>
>
> http://www2.warwick.ac.uk/fac/sci/moac/currentstudents/peter_cock/python/protein_superposition/?fromGo=http%3A%2F%2Fgo.warwick.ac.uk%2Fpeter_cock%2Fpython%2Fprotein_superposition%2F
>
> does this job perfectly.It aptly prints out aligned models into a new PDB
> file.But I am working on two atom lists from two different proteins, unlike
> two models of same structure.Can you give me little push on how to deal
> superimposing two different structures?
>
> sincerely,
> Kumar.
>
>
> On Tue, Jul 21, 2009 at 1:48 PM, Peter <biopython at maubp.freeserve.co.uk
> >wrote:
>
> > On Tue, Jul 21, 2009 at 9:35 PM, life happy<iitlife2008 at gmail.com>
> wrote:
> > > I have tried using io.save("pdb_out_filename",
> > se.accept_model(alt_model))
> > >
> > > I get error as , 'int' object has no attribute 'accept_model'
> >
> > If "se" really is an integer, that isn't surprising!
> >
> > > If I use io.save("pdb_out_filename", se = accept_model(alt_model))
> > >
> > > I get Error: name 'accept_model' is not defined
> > >
> > > In both the cases I created 'se' an object of Bio.PDB.Select()
> > > Do you have an example for printing out some part of PDB?
> >
> > The examples here may help:
> > http://lists.open-bio.org/pipermail/biopython/2009-May/005173.html
> > http://biopython.org/wiki/Remove_PDB_disordered_atoms
> > http://lists.open-bio.org/pipermail/biopython/2009-March/005005.html
> >
> > See also pages 5 and 6 of the Bio.PDB documentation, the bit
> > on the Select class:
> > http://biopython.org/DIST/docs/cookbook/biopdb_faq.pdf
> >
> > Peter
> >
> _______________________________________________
> Biopython mailing list - Biopython at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biopython
>
--
Iddo Friedberg, Ph.D.
Atkinson Hall, mail code 0446
University of California, San Diego
9500 Gilman Drive
La Jolla, CA 92093-0446, USA
T: +1 (858) 534-0570
http://iddo-friedberg.org
More information about the Biopython
mailing list