Re: [Chimera-users] defining rotation of a chimera markers file

Hi Jeff, Attached is a Python script to rotate Chimera markers about the origin using specified Euler angles. You open the script with Chimera menu entry File/Open... to apply the rotation which is specified at the end of the script. Tom Jeff wrote on Wed, Jan 24, 2007: thanks Tom (and Elaine), did not have the chance to reply yet. I have not done a whole lot w/ Euler angles in general but do know there are several conventions - seems like one for each package... As for a convention, the reason this came up is b/c the slicer tool in the IMOD viewer allows the user to rotate the volume according to the angles listed in the slider tool window. I use IMOD quite a bit to look plane by plane in various orientations in a reconstruction, and I'd like to be able to go back and forth with chimera (the IMOD extension in chimera only cycles through z; for an arbitrary plane, one would have to rotate the volume and reload into chimera). So, the convention used by IMOD would be preferred by me, for practical reasons. Here's the manpage for 'rotatevol' in IMOD, which mentions the convention: http://bio3d.colorado.edu/imod/doc/man/rotatevol.html 15 lines of code is fine; I might actually be able to dissect something that size and use it to learn. If I had a script I could do it through a python prompt, which would get me started. A command in chimera would be nicer, but not required (same goes for a graphical interface). You know, if I knew how to import the marker positions into an array in python, I could probably play with this myself - I guess I would also have to know how to write out the file too, and I'd have to brush up on my rotations. I have scanned through the contents of a marker file (`cat foo.cmm | less`, for example) and realize it is text, but I don't have enough familiarity with python to parse it into something useful. If you were to write a simple script, for basic I/O of a marker file (or tell me how to go about that) and a rotation matrix / execution as an example, I could probably run with that. For instance, if I do some things in EMAN or SPIDER, I might be able to adjust the convention when needed without further assistance. At some point, I'd like to know enough to make extensions for chimera, but lack the time to plug away at it. -Jeff # ------------------------------------------------------------------------------ # Rotate all markers in the active path tracer marker set. # def rotate_markers(xform): from VolumePath import volume_path_dialog d = volume_path_dialog() if d == None: return # No marker sets exist. ms = d.active_marker_set if ms == None: return # No marker set chosen in dialog. from chimera import Point for m in ms.markers(): xyz = m.xyz() # Python tuple txyz = xform.apply(Point(*xyz)).data() m.set_xyz(txyz) # ------------------------------------------------------------------------------ # Convert Euler angles to an equivalent Chimera transformation matrix. # # Angles must be in degrees, not radians. # # Uses the most common Euler angle convention (the chi-convention) described at # # http://mathworld.wolfram.com/EulerAngles.html # def euler_transform(phi, theta, psi): from chimera import Xform, Vector xf1 = Xform.rotation(Vector(0,0,1), phi) # Rotate about z-axis xp = xf1.apply(Vector(1,0,0)) # New x-axis xf2 = Xform.rotation(xp, theta) # Rotate about new x-axis zp = xf2.apply(Vector(0,0,1)) # New z-axis xf3 = Xform.rotation(zp, psi) # Rotate about new z-axis xf = Xform() xf.premultiply(xf1) xf.premultiply(xf2) xf.premultiply(xf3) return xf # ------------------------------------------------------------------------------ # xf = euler_transform(30, 60, 45) rotate_markers(xf)
participants (1)
-
Thomas Goddard