[chimera-dev] adding an atom at the centroid of a blob
Eric Pettersen
pett at cgl.ucsf.edu
Thu Jan 14 13:33:18 PST 2010
On Jan 13, 2010, at 8:01 AM, Jean Didier Pie Marechal wrote:
> Hi everyone,
>
> I have obtained cavities for a given atom selection using surfnet
> and I want to put an atom at the centroid of the main blob. I know
> how to do this for a selected set of atom but I am struggling with
> the surfaces.
>
> At this point, I splitted it (accelator Sc) and then I can select
> the blob I am interested in. But how could I create a particular
> object for this blob? From there, how could I add an atom (i.e.
> helium) and the centroid of the blob?
So, how accurate do you want to be? You could iterate through the
coordinates of the surface vertices to compute a centroid. You would
probably want to look at the code of the ESP extension for that since
it gets the coordinates of surface vertices so it can compute the
electrostatic potential for them.
My preferred (lazier) approach is to place the atom at the center of
the bounding sphere, which is where the focus/window commands place
the center of the view. Cribbed and modifying code from those
commands...
from Midas import boundingSphere
from chimera import selection
sph = boundingSphere(selection.copyCurrent())
if sph is None:
raise ValueError("Nothing selected")
from BuildStructure import placeHelium
a = placeHelium("CTR", position=sph.center)
--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-dev/attachments/20100114/64273ead/attachment.html>
More information about the Chimera-dev
mailing list