Re: [chimera-dev] Accessing rotation matrix of molecule models

Hello Mike, We haven't yet implemented the matrixget/matrixset commands that were in the predecessor program Midas. The write command just got implemented but is not in the released version (it will be in the next release). In the meanwhile, I can think of a few possibilities: (1) individual distances can be measured manually within Chimera ("distance" command or Controllers...Distances) (2) if you are on unix, the "pdbrun" command can be used to send out the coordinates of everything that is displayed. Note that the coordinates of both structures would be transformed, but you would be able to use these coordinate sets for the position of one relative to the other. The command would look something like pdbrun nouser cat > bothstructures.pdb You would have to make sure that all the atoms you want the coordinates of in the file bothstructures.pdb are displayed. All displayed models are in the output file, with END between them; you might need to make separate files out of this output file, depending on what you want to do next. (3) there is probably some not too complicated way to get and apply the transformation matrices out using the Python interface or a Python script, but I am not skilled in this area - other members of the development team could probably give you more details. I hope this helps. Anybody else with current solutions, please chime in... In the next version, I think the simplest way would be to use the "write" command to save the coordinates of one model relative to those of the other. Elaine =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Elaine C. Meng, R.Ph., Ph.D. Babbitt Lab and Computer Graphics Lab meng@cgl.ucsf.edu http://www.cgl.ucsf.edu/home/meng/index.html =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Hi Elaine, Thanks for your response. I've been playing with the python interface to the chimera modules and I think I'm having some success. The HappyDoc generated documentation isn't very helpful, especially when most function documentation is just "FunctionName documentation" In any case, I found that I can get access to the transforms through model.openState.xform. However in the documentation there is something called 'globalXform' and 'localXform' for setting xform, and I don't know what that means. Are there two different transforms, or just one? If there are two, how do I retrieve them individually and which one should I manipulate? Also if I want one structure to have the same xform as another structure, can I just assign the xform attribute of the openState? Or will this end up having the two models share the object and cause problems? Oh, one more thing. Is the xform applied by translation first then rotation? If that's the case, I was wondering why spinning a molecule causes the translation vector of the xform to change. I would expect it to be the same because it is spinning on the same center (maybe I'm wrong). Yeah, lots of questions, but thanks for any help you can give! Mike ----- Original Message ----- From: "Elaine Meng" <meng@cgl.ucsf.EDU> To: <mliang@Stanford.EDU> Cc: <chimera-dev@cgl.ucsf.EDU> Sent: Thursday, July 18, 2002 4:34 PM Subject: Re: [chimera-dev] Accessing rotation matrix of molecule models
Hello Mike, We haven't yet implemented the matrixget/matrixset commands that were in the predecessor program Midas. The write command just got implemented but is not in the released version (it will be in the next release).
In the meanwhile, I can think of a few possibilities:
(1) individual distances can be measured manually within Chimera ("distance" command or Controllers...Distances)
(2) if you are on unix, the "pdbrun" command can be used to send out the coordinates of everything that is displayed. Note that the coordinates of both structures would be transformed, but you would be able to use these coordinate sets for the position of one relative to the other. The command would look something like pdbrun nouser cat > bothstructures.pdb You would have to make sure that all the atoms you want the coordinates of in the file bothstructures.pdb are displayed. All displayed models are in the output file, with END between them; you might need to make separate files out of this output file, depending on what you want to do next.
(3) there is probably some not too complicated way to get and apply the transformation matrices out using the Python interface or a Python script, but I am not skilled in this area - other members of the development team could probably give you more details.
I hope this helps. Anybody else with current solutions, please chime in... In the next version, I think the simplest way would be to use the "write" command to save the coordinates of one model relative to those of the other. Elaine =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Elaine C. Meng, R.Ph., Ph.D. Babbitt Lab and Computer Graphics Lab meng@cgl.ucsf.edu http://www.cgl.ucsf.edu/home/meng/index.html =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Hi Mike, There is just one Xform per Chimera model that you access using model.openState.xform You can set the transform of one model to be the same as another with model2.openState.xform = model1.openState.xform The assignment copies the xform so each model will have its own copy. The xform first applies the rotation matrix and then a translation. You probably see the translation changing when you rotate the molecule because the center of rotation when using the mouse is not at the origin (0,0,0). (The center of rotation for mouse rotations can be controlled -- see the Rotation tab of the Side View dialog.) When you get atom coordinates with atom.coord() you get the original xyz values from say a PDB file. The m.openState.xform applied to those coordinates gives you the displayed xyz Chimera coordinates of the atom taking into account the rotation and translation. So you should apply the xform before comparing distances between atoms in different molecules. Tom

On Thu, 18 Jul 2002, Thomas Goddard wrote:
When you get atom coordinates with atom.coord() you get the original xyz values from say a PDB file. The m.openState.xform applied to those coordinates gives you the displayed xyz Chimera coordinates of the atom taking into account the rotation and translation. So you should apply the xform before comparing distances between atoms in different molecules.
Use atom.xformCoord() to get the transformed coordinate. Same thing, but the transformation is done in C++ instead of Python. Greg

The one thing I would add, and you may know this already, is that if you have atom1 and atom2 in Python and want the distance between them after transformation, you do: atom1.xformCoord().dist(atom2.xformCoord()) --Eric On Thursday, July 18, 2002, at 05:47 PM, Greg Couch wrote:
On Thu, 18 Jul 2002, Thomas Goddard wrote:
When you get atom coordinates with atom.coord() you get the original xyz values from say a PDB file. The m.openState.xform applied to those coordinates gives you the displayed xyz Chimera coordinates of the atom taking into account the rotation and translation. So you should apply the xform before comparing distances between atoms in different molecules.
Use atom.xformCoord() to get the transformed coordinate. Same thing, but the transformation is done in C++ instead of Python.
Greg
_______________________________________________ Chimera-dev mailing list Chimera-dev@cgl.ucsf.edu http://www.cgl.ucsf.edu/mailman/listinfo/chimera-dev

Hi Mike, I forgot to mention that the difference between the OpenState localXform(xform) and globalXform(xform) routines. These routines change the current openState.xform by multiplying the xform argument on the right or left respectively. If c = atom.coord() and orig_xf is the current openState.xform then the displayed position is orig_xf * c. After calling openState.localXform(xform) the displayed position is orig_xf * xform * c, while after openState.globalXform(xform) the displayed position is xform * orig_xf * c. Tom

Think of globalXform() as happening in the global (world/lab) coordinate space and localXform() as happening the the model's coordinate space. The point of having globalXform and localXform is to avoid having to know if the coordinates are a row vector or a column vector with the corresponding opposite orders of multiplication for the global/local effect. You don't know and you don't care :-) -- you just pick where you want the transformation to take place. That said, chimera's transformations are for a right-handed coordinate system with coordinates written as column vectors. Greg On Thu, 18 Jul 2002, Thomas Goddard wrote:
I forgot to mention that the difference between the OpenState localXform(xform) and globalXform(xform) routines. These routines change the current openState.xform by multiplying the xform argument on the right or left respectively. If c = atom.coord() and orig_xf is the current openState.xform then the displayed position is orig_xf * c. After calling openState.localXform(xform) the displayed position is
orig_xf * xform * c,
while after openState.globalXform(xform) the displayed position is
xform * orig_xf * c.
Tom

Hi guys, Thank you so much for your quick responses. They were exactly what I was looking for. Thanks! Mike On Thu, 18 Jul 2002, Greg Couch wrote: Date: Thu, 18 Jul 2002 18:03:12 -0700 (PDT) From: Greg Couch <gregc@cgl.ucsf.edu> To: Thomas Goddard <goddard@cgl.ucsf.edu> Cc: mliang@Stanford.EDU, chimera-dev@cgl.ucsf.edu Subject: Re: [chimera-dev] Accessing rotation matrix of molecule models Think of globalXform() as happening in the global (world/lab) coordinate space and localXform() as happening the the model's coordinate space. The point of having globalXform and localXform is to avoid having to know if the coordinates are a row vector or a column vector with the corresponding opposite orders of multiplication for the global/local effect. You don't know and you don't care :-) -- you just pick where you want the transformation to take place. That said, chimera's transformations are for a right-handed coordinate system with coordinates written as column vectors. Greg On Thu, 18 Jul 2002, Thomas Goddard wrote:
I forgot to mention that the difference between the OpenState localXform(xform) and globalXform(xform) routines. These routines change the current openState.xform by multiplying the xform argument on the right or left respectively. If c = atom.coord() and orig_xf is the current openState.xform then the displayed position is orig_xf * c. After calling openState.localXform(xform) the displayed position is
orig_xf * xform * c,
while after openState.globalXform(xform) the displayed position is
xform * orig_xf * c.
Tom
participants (5)
-
Elaine Meng
-
Eric Pettersen
-
Greg Couch
-
Mike Liang
-
Thomas Goddard