[Chimera-users] Assign distance between every atom and an axis or plane to an attribute

Eric Pettersen pett at cgl.ucsf.edu
Wed Feb 24 11:09:13 PST 2016

This will assign attributes such as “dist_p1”, “dist_p2”, “dist_c1" etc. to every atom for every axis/plane/centroid in your session:

from StructMeasure.Geometry import geomManager
from chimera import openModels, Molecule
for item in geomManager.items:
	for m in openModels.list(modelTypes=[Molecule]):
		for a, d in zip(m.atoms, item.pointDistances([a.xformCoord() for a in atoms])):
			setattr(a, “dist_” + item.id, d)

For the bonus point part, if the atoms of your conformers are in the same respective order in their input files, then their m.atoms will be in the same order in Chimera.  So, if the models are ‘m1’ and ‘m2’:

for a1, a2 in zip(m1.atoms, m2.atoms):
	a1.diff_p1 = a2.diff_p1 = a1.dist_p1 - a2.dist_p1


	Eric Pettersen
	UCSF Computer Graphics Lab

> On Feb 24, 2016, at 5:21 AM, Oliver Clarke <olibclarke at gmail.com> wrote:
> Hi,
> I would like to iterate over all atoms in a model, measure the distance between each atom and a predefined axis or plane in the session, and assign the distance to an attribute associated with the atom. For bonus points I would like to do the same for two models (the same protein in different conformations), and then calculate the difference in this distance for matched pairs of atoms.
> The first part of this - iterating over every atom - I know how to do, more or less, in the scripting interface (I am assuming there is no way to do this kind of "iterate/run command/ assign command output to attribute" operation in the attribute calculator).
> But how do I measure the distance between an atom and a selected plane/axis, and then assign it to an attribute that I can use for example in Render by Attribute? I can see how to measure the distance between pairs of atoms, but not between atoms and a plane or axis.
> Cheers,
> Oli
> _______________________________________________
> Chimera-users mailing list: Chimera-users at cgl.ucsf.edu
> Manage subscription: http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-users/attachments/20160224/5f779965/attachment.html>

More information about the Chimera-users mailing list