<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Dec 19, 2008, at 7:14 AM, Dr. Jean-Didier Maréchal wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Dear all,<br><br>Based on early queries, I am now using xform coord for most of my scripts.<br>However, now I have a problem because I have mixture between xforms and<br>coord.<br><br>For example, I want to place a helium at the center of mass of the molecular<br>and having previously calculated it using xform coordinates... The center of<br>mass is therefore located at another part of the space.<br><br>How could I transform on set of coords to the other? </div></blockquote><div><br></div>Hi JD,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>When a new Model is open/created in Chimera, by default it is given the same transformation matrix as the lowest currently-open model. This is based on the presumption that frequently model coordinate systems are related and that therefore it is useful to show them in the relative positions that their raw coordinates imply. This presumption is hosing you: you want <i>your</i> new model to start with an identity matrix as its transformation matrix, since you are basing your model on the <i>transformed</i> coordinates of the existing model(s).</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>So, you need to set your model's transform to be the identity. The first thing you should do is change your code a little so that your <font class="Apple-style-span" face="Courier">placing_points</font> function returns the atom it placed (which is easy since the <font class="Apple-style-span" face="Courier">placeHelium</font> function returns the new helium atom). So the last line of <span class="Apple-style-span" style="font-family: Courier; ">placing_points</span> becomes:</div><div><br></div><div>return BuildStructure.placeHelium('com', model='scratch', position=center)</div><div><br></div><div>Then the last line of your script changes from:</div><div><br></div><div>placing_points(center)</div><div><br></div><div>to:</div><div><br></div><div>a = placing_points(center)</div><div>a.molecule.openState.xform = chimera.Xform.identity()</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>I don't know if your center of mass of calculation will always be restricted to a single model (in your example it is), but if so then you can get away with using coord() instead of xformCoord() and I think your script will work without further changes in that case.</div><div><br></div><div>--Eric<br></div><div><div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="5" style="font: normal normal normal 16px/normal Helvetica; "><br class="Apple-interchange-newline"> Eric Pettersen</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="5" style="font: normal normal normal 16px/normal Helvetica; "> UCSF Computer Graphics Lab</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="5" style="font: normal normal normal 16px/normal Helvetica; "> <a href="http://www.cgl.ucsf.edu">http://www.cgl.ucsf.edu</a></font></div></div></div><br><div></div><blockquote type="cite"><div>Here is the script<br><br>from chimera import selection<br>from chimera import Point, Vector, Xform<br>import BuildStructure<br><br>def com(sub):<br> for i in range(len(sub.atoms)):<br> sumi=0<br> center = Vector(0, 0, 0)<br> for a in sub.atoms:<br> sumi += a.element.mass<br> center += a.element.mass * Vector(*a.xformCoord().data())<br> center_point=Point(center[0]/sumi,center[1]/sumi,center[2]/sumi)<br> return center_point<br><br>def placing_points(center):<br> #pt=Point(center[0]/sum,center[1]/sum,center[2]/sum)<br> #print pt<br> BuildStructure.placeHelium('com', model='scratch', position=center)<br><br>ligand = selection.currentResidues()[0]<br>center=com(ligand)<br>placing_points(center)<br><br><br><br>_______________________________________________<br>Chimera-dev mailing list<br><a href="mailto:Chimera-dev@cgl.ucsf.edu">Chimera-dev@cgl.ucsf.edu</a><br>http://www.cgl.ucsf.edu/mailman/listinfo/chimera-dev<br></div></blockquote></div><br></body></html>