<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Jan 25, 2010, at 9:42 AM, Yasser Almeida Hernández wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hi..<br><br>How can i rename atoms? How would be the script python syntax?</div></blockquote><br></div><div>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':</div><div><br></div><div>from chimera import runCommand</div><div>runCommand("setattr a name X1 sel")</div><div><br></div><div>--or--</div><div><br></div><div>from chimera import selection</div><div>for a in selection.currentAtoms():</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>a.name = "X1"</div><div><br></div><div>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:</div><div><br></div><div>from chimera import selection</div><div>for a in selection.currentAtoms():</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>r = a.residue</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>r.removeAtom(a)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>a.name = "X1"</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>r.addAtom(a)</div><div><br></div><div>--Eric</div><div><br></div><div><div><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="5" style="font: normal normal normal 16px/normal Helvetica; "> Eric Pettersen</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="5" style="font: normal normal normal 16px/normal Helvetica; "> UCSF Computer Graphics Lab</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="5" style="font: normal normal normal 16px/normal Helvetica; "> <a href="http://www.cgl.ucsf.edu">http://www.cgl.ucsf.edu</a></font></div><br class="Apple-interchange-newline"></div></span></div><br><div></div></div></body></html>