<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Jul 28, 2010, at 5:30 PM, Jozef Lewandowski wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hi everybody,<br>Lately, I have been using "measure inertia" command a lot. For my <br>purposes I needed to visualize the inertia axes as arrows instead of the <br>default ellipsoid. I used the vectors from the reply log to write BILD <br>files defining the arrows for the inertia axes.<br>Is there an easy way to script just that? Or differently, is there an <br>easy way to visualize as arrows inertia axes for peptide planes in a <br>protein?</div></blockquote><div><br></div>Hi Jozef,<br><span class="Apple-tab-span" style="white-space:pre"> </span>Let's say that the atoms you want to base the axes on are selected then:</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>from chimera.selection import currentAtoms, numpyArrayFromAtoms</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>coords = numpyArrayFromAtoms(currentAtoms())</div><div><br></div><div>would give you a numpy array of the atoms coordinates. Then:</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>from numpy.linalg import svd</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>centroid = coords.mean(0)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>centered = coords - centroid</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>ignore, vals, vecs = svd(centered)</div><div><br></div><div>would give you the eigenvalues, eigenvectors, and centroid of the selection. BTW, the above was gleaned from nosing around StructMeasure/__init__.py. Similarly, by nosing around the new Metal Geometry tool (specifically MetalGeom/gui.py, available only in the daily build), we find some code for constructing BILD arrows on the fly:</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>bildString = ".color orange\n"</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>for val, vec in zip(vals, vecs):</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>bildString += ".arrow %g %g %g %g %g %g .1 .2 .9\n" % (</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>centroid[0], centroid[1], centroid[2],</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>centroid[0] + val[0] * vec[0],</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>centroid[1] + val[1] * vec[1],</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>centroid[2] + val[2] * vec[2])</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>from StringIO import StringIO</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>bild = StringIO(bildString)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>mol = currentAtoms()[0].molecule</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>from chimera import openModels</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>openModels.open(bild, type="Bild", identifyAs="inertial axes", sameAs=mol)</div><div><br></div><div>Putting all the above in a .py file and opening it in Chimera will show the inertial axes on the display and list them as a model in the Model Panel.</div><div><br></div><div>--Eric</div><div><br></div><div><span class="Apple-style-span" style="font-size: 16px; "> </span><span class="Apple-style-span" style="font-size: 16px; "> </span><span class="Apple-style-span" style="font-size: 16px; ">Eric Pettersen</span></div><div apple-content-edited="true"><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="5" style="font: 16.0px Helvetica"><span class="Apple-converted-space"> <span class="Apple-converted-space"> </span></span>UCSF Computer Graphics Lab</font></p><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="5" style="font: 16.0px Helvetica"><span class="Apple-converted-space"> </span><a href="http://www.cgl.ucsf.edu">http://www.cgl.ucsf.edu</a></font></p><br class="Apple-interchange-newline"></div></span> </div><br></body></html>