[Chimera-users] Re: chimera questions
Thomas Goddard
goddard at cgl.ucsf.edu
Fri Jun 11 09:36:32 PDT 2004
Hi Wen,
There is not a Chimera command to print the transformation of one model
relative to another. But you can get it with some Python code. Below
is some Python code to add two keyboard shortcuts that print the transform
of model 0 relative to model 1 or model 1 relative to model 0. The model
numbers are shown in the Model Panel dialog (Tools/Inspectors or Favorites
menu), 0 being the first model you opened.
To use the keyboard shortcuts copy the Python code below to a file,
say accel.py. Show the accelerator dialog, Tools/Keyboard/Accelerator List,
and enter the path to the accelerator file and press Load. Also click
the "Accelerators on" switch. After loading two models you can type x0 or
x1 in the Chimera graphics window and it will print out the transform to
the Chimera reply log (Favorites/Reply Log). The accelerator file is
remembered so you only need to do this setup once. To have the accelerators
be on whenever you start Chimera, set Accelerators On to "auto start" in
Favorites/Preferences/Category Tools.
The transformation matrix is a 3 by 4 matrix. The first 3 columns give
the rotation, and the 4th column is a translation. The rotation is applied
first, then the translation.
Tom
def print_transform(model_id_1, model_id_2):
'''Print transformation matrix of model 1 relative to model 2.'''
import chimera
m1 = chimera.openModels.list(id = model_id_1)[0] # returns a list
m2 = chimera.openModels.list(id = model_id_2)[0]
xf1 = m1.openState.xform
xf2 = m2.openState.xform
xf2.invert()
xf1.multiply(xf2)
print xf1
def register_accelerators():
from Accelerators import standard_accelerators, add_accelerator
standard_accelerators.register_accelerators()
add_accelerator('x0', 'Print model 0 transform relative to model 1',
lambda: print_transform(0,1))
add_accelerator('x1', 'Print model 1 transform relative to model 0',
lambda: print_transform(1,0))
More information about the Chimera-users
mailing list