Hi Phil,
one option to get access to the coordinates is using the chempy model of a
given selection ( named "(sele)" if you clicked it).
m = cmd.get_model("(sele)")
the chempy model contains a list of atom objects which contain most properties
you might need.
for atom in m.atom:
print atom.id, atom.name, atom.resn, atom.resi, atom.coord
To extract the coordinates of all atoms you can simple do:
coords = map(lambda a: a.coord, m.atom)
or if you need the coordinates as numpy arrays use:
from numpy import *
coords = map(lambda a: array(a.coord), m.atom)
gives you a list of numpy arrays
or:
coords = matrix(map(lambda a: a.coord, m.atom))
will produce a numpy matrix with your coords.
Then you might do whatever you want with the coordinates and update the
coordinates of the chempy model.
As far as I now, you can not transfer them back easily to PyMOL but you can do
a little trick.
Load the modified model as new pymol object:
cmd.load_model(m,"modified")
and then update the original selection with the coords from the modified
object.
cmd.update("(sele)","modified")
Then you can delete the modified object.
cmd.delete("modified")
Cheers,
Daniel
On Tuesday 19 January 2010 08:00:51 pm Phil Payne Local wrote:
> I am writing a Pymol plugin, in which I need to extract, manipulate, and
> replace the coordinates of selected atoms. Are there examples out there
> I could use as a prototype?
>
> For starters, what command(s) do I use to get the name strings of
> residues that I've selected with mouse clicks. I would like to assign
> these to a variable.
>
> Then the same question applies to coordinates. How do I assign the
> values of atomic coordinates to a list variable in my plug_in script?
>
>
> ---------------------------------------------------------------------------
> --- Throughout its 18-year history, RSA Conference consistently attracts
> the world's best and brightest in the field, creating opportunities for
> Conference attendees to learn about information security's most important
> issues through interactions with peers, luminaries and emerging and
> established companies. http://p.sf.net/sfu/rsaconf-dev2dev
> _______________________________________________
> PyMOL-users mailing list ([email protected])
> Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
> Archives: http://www.mail-archive.com/[email protected]
>
--
Dr. Daniel Seeliger
Computational Biomolecular Dynamics Group
Max-Planck-Institute for Biophysical Chemistry
Tel. +49 (0) 551-201-2310
http://wwwuser.gwdg.de/~dseelig
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
PyMOL-users mailing list ([email protected])
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/[email protected]