[BioPython] Superimposer

Peter biopython at maubp.freeserve.co.uk
Tue Mar 24 12:41:53 UTC 2009


On Tue, Mar 24, 2009 at 12:18 PM, mitlox <mitlox at op.pl> wrote:
> Thank you for you email.  I would like only rotate and translate a pdb file
> that I can see the result in a pdb viewer.

I see.

> Maybe I do not need the Superimposer object to rotate and translate a pdb
> file with known rotation matrix and translation vector?

Correct.

> Do you know how could I rotate and translate a pdb file?

You've got most of the steps already.  This is my suggestion:

import numpy
from Bio import PDB

pdb_fix = "1z9g.pdb"
pdb_mov = "1z9g_moved.pdb"

structure = PDB.PDBParser().get_structure("FIXED", pdb_fix)

rot=numpy.identity(3).astype('f')
tran=numpy.array((-0.99996603, -2.00002559, -2.99998285))
rot=numpy.array(((+0.19411441, -0.85385353, +0.48296351),
                 (+0.94858827, +0.28884874, +0.12940907),
                 (-0.24999979, +0.43301335, +0.86602514)))

print "Applying transformation..."
for atom in structure.get_atoms() :
    atom.transform(rot, tran)

print "Saving transformed structure as PDB file %s" % pdb_mov
io=PDB.PDBIO()
io.set_structure(structure)
io.save(pdb_mov)
print "Done"

NOTE - When giving a translation mapping as a translation vector and
a rotation matrix there is some ambiguity about which order to apply them
in.  If the results using Bio.PDB don't match what you expect, you may
want to double check this first.

Peter




More information about the Biopython mailing list