[Chimera-users] How to select a plane from the command line
Eric Pettersen
pett at cgl.ucsf.edu
Mon Aug 17 14:24:09 PDT 2015
Hi Juan,
There are two varieties of Plane objects in Chimera. There is chimera.Plane, which is basically just the abstract mathematical representation of a plane, and supports the kind of math operations you would want to do with a plane. Then there is StructMeasure.Planes.Plane, which supports depicting a plane in the graphics window, and is basically a very fancy wrapper around a chimera.Plane.
You don’t really say what you plan to do with your “plane reference”, so I’m not sure whether just chimera.Plane is sufficient for your needs or if you need the more elaborate graphics Plane. I’m going to assume the former, and if it’s the latter then let me know.
So here’s an example of creating a chimera.Plane from a set of selected atoms. The origin of the plane will be the centroid of the atoms…
# assumes atoms are selected somehow
from chimera import selection, numpyArrayFromAtoms
atoms = selection.currentAtoms()
numpyCoords = numpyArrayFromAtoms(atoms)
import StructMeasure
plane = StructMeasure.plane(numpyCoords)
Some notes:
(1) Useful properties of a plane include ‘origin’ and ‘normal’. You can compute the distance from a plane to a point with distance() and find the nearest point in the plane with nearest(). Both those methods take a point (a.k.a. coord) as an argument. You get an atom’s coordinate with atom.coord(). You can also get the point+vector defining the intersection of two planes with the intersection() method.
(2) All the above assumes you are making plane measurements within a single model, or between two models that haven’t been moved relative to each other after being opened. If you are measuring things involving models that have been moved relative to each other, then you have to use “transformed” coordinates. To do that, add ‘xformed=True’ to the numyArrayFromAtoms call, and use the atom’s xformCoord() method rather than coord().
I hope this helps.
—Eric
Eric Pettersen
UCSF Computer Graphics Lab
> On Aug 14, 2015, at 3:12 PM, JUAN PABLO REYES VALVERDE <reyes_jp at comunidad.unam.mx> wrote:
>
> Dear UCSF Chimera Team:
>
> Please, I would much appreciate your advice on the following:
>
> First issue:
> Given a number of planes - calculated/created through the ‘define’ command - I would like to select one of them, with some command entered at the command line …. How can I do it?
>
> The reason why I want to select it through the command line, and not by directly by clicking at it at the axes/planes/centroids table, is because later I would like to use the command inside a runCommand statement, in a Python/IDLE script (with *.py extension) …
>
> Second issue:
> By the way, do you think this piece of code could work?
> Assume that the desired plane is already selected …. I want to internally handle the plane as ‘p1’ in my Python code:
>
> p1= chimera.Plane()
> from chimera import selection
> p1= selection
>
> or perhaps this single instruction …..
> p1= chimera.selection
>
> Let me try to explain: Within my Python code, I want to have a way to make reference to a plane created by the ‘define’ command ( should I call it a ‘ handle’? … not sure whether it is the correct term …).
>
> Well, I hope that I managed to make it sufficiently clear … Thanks in advance for your kind attention.
> Cheers,
>
>
> Juan
>
>
> Dr. Juan Pablo Reyes Valverde
>
> Laboratorio de Neurobiología Molecular y Celular (D15)
> Instituto de Neurobiología UNAM
> Campus UNAM Juriquilla
> Boulevard Juriquilla 3001
> Querétaro, QRO CP 76230
> MÉXICO
>
> Tel +52 (442) 2381064
> _______________________________________________
> Chimera-users mailing list
> Chimera-users at cgl.ucsf.edu
> 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/20150817/b5df7c72/attachment.html>
More information about the Chimera-users
mailing list