<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Sep 26, 2012, at 11:04 AM, Yasser Almeida Hernandez wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div ocsi="0" fpstyle="1"><div style="direction: ltr; font-family: Tahoma; color: rgb(0, 0, 0); font-size: 10pt; ">Dear Chimerians...<br><br>I'm running an analysis about H-bonds geometries in several models.<br><br>I need to measure the distance of a H-bond and the angle formed with a third atom bonded to one of the H-bond atoms.<br>How could I do that in a python IDLE/script?<br><br>In a more general way, how could I measure the angle between three atoms linked by a bond o pseudobond?</div></div></span></blockquote><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>In regards to the Python part, probably the single most salient fact is that there is an "angle" function in the chimera module, <i>i.e.</i>:</div><div><br></div><div>chimera.angle(a1.coord(), a2.coord(), a3.coord())</div><div><br></div><div>returns the a1-a2-a3 angle in degrees formed by the Python Atom objects. If the Atoms could be in different models, then use .xformCoord() rather than .coord().</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>So, how to get an Atom object? Let's say you've selected the Atom by some means, then:</div><div><br></div><div>a = chimera.selection.currentAtoms()[0]</div><div><br></div><div>would get you the selected Atom object. Along the same lines, if you've selected a (covalent) Bond, then:</div><div><br></div><div>b = chimera.selection.currentBonds()[0]</div><div>a1, a2 = b.atoms</div><div><br></div><div>would get you the two Atoms that form the bond. If the third Atom of interest is a neighbor of a1 or a2 then you could look through a1.neighbors or a2.neighbors to find it (FYI an Atom's name is <a href="http://a.name">a.name</a>). Hydrogen bonds are PseudoBonds, so an analogous procedure could be used with chimera.selection.currentPseudobonds().</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>It sounds like you may want to run the hydrogen-bond finding code directly in your Python script, which will return a list of donor/acceptor Atom pairs, which you could then use in your angle call once you've found the third atom that you care about. This is how:</div><div><br></div><div>from FindHBond import findHBonds</div><div>da_list = findHBonds(chimera.openModels.list(modelTypes=[chimera.Molecule]))</div><div><br></div><div>that call will return only hbonds meeting the strict angle/distance cutoff parameters. If you want to use the default GUI/command relaxed parameters (+0.4 angstroms / +20 degrees), then use this code instead:</div><div><br></div><div>from FindHBonds import findHBonds, recDistSlop, recAngleSlop</div><div><div>da_list = findHBonds(chimera.openModels.list(modelTypes=[chimera.Molecule]), distSlop=recDistSlop, angleSlop=recAngleSlop)</div><div><br></div><div>--Eric</div><div><br></div></div><div>
<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; "><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>Eric Pettersen</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 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"></span>
</div>
<br></body></html>