# [Chimera-users] Measuring angles between atoms pairs

Eric Pettersen pett at cgl.ucsf.edu
Wed Sep 26 11:25:49 PDT 2012

```On Sep 26, 2012, at 11:04 AM, Yasser Almeida Hernandez wrote:

> Dear Chimerians...
>
> I'm running an analysis about H-bonds geometries in several models.
>
> 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.
> How could I do that in a python IDLE/script?
>
> In a more general way, how could I measure the angle between three atoms linked by a bond o pseudobond?

In regards to the Python part, probably the single most salient fact is that there is an "angle" function in the chimera module, i.e.:

chimera.angle(a1.coord(), a2.coord(), a3.coord())

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().
So, how to get an Atom object?  Let's say you've selected the Atom by some means, then:

a = chimera.selection.currentAtoms()

would get you the selected Atom object.  Along the same lines, if you've selected a (covalent) Bond, then:

b = chimera.selection.currentBonds()
a1, a2 = b.atoms

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.name).  Hydrogen bonds are PseudoBonds, so an analogous procedure could be used with chimera.selection.currentPseudobonds().
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:

from FindHBond import findHBonds
da_list = findHBonds(chimera.openModels.list(modelTypes=[chimera.Molecule]))

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:

from FindHBonds import findHBonds, recDistSlop, recAngleSlop
da_list = findHBonds(chimera.openModels.list(modelTypes=[chimera.Molecule]), distSlop=recDistSlop, angleSlop=recAngleSlop)

--Eric

Eric Pettersen
UCSF Computer Graphics Lab
http://www.cgl.ucsf.edu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-users/attachments/20120926/416f2ec2/attachment.html>
```