[Chimera-users] Rename atoms...
Eric Pettersen
pett at cgl.ucsf.edu
Mon Jan 25 14:25:38 PST 2010
On Jan 25, 2010, at 9:42 AM, Yasser Almeida Hernández wrote:
> Hi..
>
> How can i rename atoms? How would be the script python syntax?
This is actually a little trickier than it really should be in the
current builds. As of tomorrow's daily build the following will work
without any issues to set the name of selected atoms to 'X1':
from chimera import runCommand
runCommand("setattr a name X1 sel")
--or--
from chimera import selection
for a in selection.currentAtoms():
a.name = "X1"
The issue in current builds is that the C++ container of atoms for a
residue is keyed on the atom name, so if the atom name changes that
container needs to be updated, and the current code doesn't do that.
Therefore in any current build you can't use the 'runCommand'
approach, and in the other approach you would need some additional code:
from chimera import selection
for a in selection.currentAtoms():
r = a.residue
r.removeAtom(a)
a.name = "X1"
r.addAtom(a)
--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/20100125/8d108d44/attachment.html>
More information about the Chimera-users
mailing list