
Dear Chimera users, I am trying to write a script to change the phi and psi angle of a peptide. I am trying to adapt the code from http://plato.cgl.ucsf.edu/pipermail/chimera-users/2005-September/000456.html . I am trying to invert the angles so I am multiplying the angles by -1. My code is import chimera from chimera import selection, UserError, BondRot, replyobj opened = chimera.openModels.open('fun.pdb') mol = opened[0] RES_LIST = mol.residues for res in mol.residues: b = str(res.phi) if b != 'None': c = -1*float(b) atomsMap = res.atomsMap N = atomsMap['N'][0] CA = atomsMap['CA'][0] C = atomsMap['C'][0] CAmap = CA.bondsMap phiBond = CAmap[N] psiBond = CAmap[C] phiAnchor = N psiAnchor = CA phi = BondRot(phiBond) phi.setAngle(c, phiAnchor) When I run this script i get the error phi.setAngle(c, phiAnchor) AttributeError: '_molecule.BondRot' object has no attribute 'setAngle' Can someone please help me with this? Warm regards. Amin.

Hi Amin, That is a pretty old message; probably the name of something changed ... it may be simpler now (in later versions of Chimera) that peptide residues are automatically assigned attributes named "phi" and "psi" with the torsion values. If your script can get the current residue attribute value and multiply it by -1, it can then reset it to the new value. I can't advise on python, but you can use the Chimera setattr command to specify the value of some attribute directly, for example to set phi to -60 for residue 40 in chain A: setattr r phi -60 :40.a <http://www.rbvi.ucsf.edu/chimera/docs/UsersGuide/midas/setattr.html> Best, Elaine ----- Elaine C. Meng, Ph.D. UCSF Computer Graphics Lab (Chimera team) and Babbitt Lab Department of Pharmaceutical Chemistry University of California, San Francisco On Feb 8, 2014, at 11:03 AM, amin@imtech.res.in wrote:
Dear Chimera users,
I am trying to write a script to change the phi and psi angle of a peptide. I am trying to adapt the code from http://plato.cgl.ucsf.edu/pipermail/chimera-users/2005-September/000456.html . I am trying to invert the angles so I am multiplying the angles by -1. My code is
import chimera
from chimera import selection, UserError, BondRot, replyobj
opened = chimera.openModels.open('fun.pdb') mol = opened[0] RES_LIST = mol.residues for res in mol.residues: b = str(res.phi) if b != 'None': c = -1*float(b) atomsMap = res.atomsMap N = atomsMap['N'][0] CA = atomsMap['CA'][0] C = atomsMap['C'][0] CAmap = CA.bondsMap phiBond = CAmap[N] psiBond = CAmap[C] phiAnchor = N psiAnchor = CA phi = BondRot(phiBond) phi.setAngle(c, phiAnchor)
When I run this script i get the error
phi.setAngle(c, phiAnchor) AttributeError: '_molecule.BondRot' object has no attribute 'setAngle'
Can someone please help me with this?
Warm regards.
Amin.

Hi Amin, As Elaine alluded to, the code for changing phi/psi is a lot simpler than what was necessary in 2005. In particular you can just assign a value to the phi or psi attribute to change it. Therefore in your script, the loop would just be: for res in mol.residues: if res.phi is not None: res.phi = -res.phi --Eric Eric Pettersen UCSF Computer Graphics Lab On Feb 8, 2014, at 11:03 AM, amin@imtech.res.in wrote:
Dear Chimera users,
I am trying to write a script to change the phi and psi angle of a peptide. I am trying to adapt the code from http://plato.cgl.ucsf.edu/pipermail/chimera-users/2005-September/000456.html . I am trying to invert the angles so I am multiplying the angles by -1. My code is
import chimera
from chimera import selection, UserError, BondRot, replyobj
opened = chimera.openModels.open('fun.pdb') mol = opened[0] RES_LIST = mol.residues for res in mol.residues: b = str(res.phi) if b != 'None': c = -1*float(b) atomsMap = res.atomsMap N = atomsMap['N'][0] CA = atomsMap['CA'][0] C = atomsMap['C'][0] CAmap = CA.bondsMap phiBond = CAmap[N] psiBond = CAmap[C] phiAnchor = N psiAnchor = CA phi = BondRot(phiBond) phi.setAngle(c, phiAnchor)
When I run this script i get the error
phi.setAngle(c, phiAnchor) AttributeError: '_molecule.BondRot' object has no attribute 'setAngle'
Can someone please help me with this?
Warm regards.
Amin.
_______________________________________________ Chimera-users mailing list Chimera-users@cgl.ucsf.edu http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users

Dear Dr. Pettersen and Dr. Meng, Thanks for the suggestion. I tried the simpler scripts and they work. But I am not sure that what atoms are moved when I set res.phi = -res.phi. The earlier script had set anchor residues to solve this problem. Can you please guide me on how to use anchor residues on newer versions of chimera? Warm Regards. Amin. On 2014-02-09 07:44, Eric Pettersen wrote:
Hi Amin, As Elaine alluded to, the code for changing phi/psi is a lot simpler than what was necessary in 2005. In particular you can just assign a value to the phi or psi attribute to change it. Therefore in your script, the loop would just be:
for res in mol.residues: if res.phi is not None: res.phi = -res.phi
--Eric
Eric Pettersen UCSF Computer Graphics Lab
On Feb 8, 2014, at 11:03 AM, amin@imtech.res.in wrote:
Dear Chimera users,
I am trying to write a script to change the phi and psi angle of a peptide. I am trying to adapt the code from http://plato.cgl.ucsf.edu/pipermail/chimera-users/2005-September/000456.html [1] . I am trying to invert the angles so I am multiplying the angles by -1. My code is
import chimera
from chimera import selection, UserError, BondRot, replyobj
opened = chimera.openModels.open('fun.pdb') mol = opened[0] RES_LIST = mol.residues for res in mol.residues: b = str(res.phi) if b != 'None': c = -1*float(b) atomsMap = res.atomsMap N = atomsMap['N'][0] CA = atomsMap['CA'][0] C = atomsMap['C'][0] CAmap = CA.bondsMap phiBond = CAmap[N] psiBond = CAmap[C] phiAnchor = N psiAnchor = CA phi = BondRot(phiBond) phi.setAngle(c, phiAnchor)
When I run this script i get the error
phi.setAngle(c, phiAnchor) AttributeError: '_molecule.BondRot' object has no attribute 'setAngle'
Can someone please help me with this?
Warm regards.
Amin. _______________________________________________ Chimera-users mailing list Chimera-users@cgl.ucsf.edu http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users
Links: ------ [1] http://plato.cgl.ucsf.edu/pipermail/chimera-users/2005-September/000456.html

Hi Amin, I'm not sure why you care which side moves, but by default the "smaller" side moves. So if the residue is near the N terminus then the N-terminal part will move, if it's near the C terminus then the C-terminal side will move. Unless these changes are relative to some other structure, it shouldn't matter which side "moves"; the resulting conformation is the same either way. --Eric Eric Pettersen UCSF Computer Graphics Lab http://www.cgl.ucsf.edu On Feb 8, 2014, at 8:33 PM, amin wrote:
Dear Dr. Pettersen and Dr. Meng,
Thanks for the suggestion. I tried the simpler scripts and they work. But I am not sure that what atoms are moved when I set res.phi = -res.phi. The earlier script had set anchor residues to solve this problem. Can you please guide me on how to use anchor residues on newer versions of chimera?
Warm Regards.
Amin.
On 2014-02-09 07:44, Eric Pettersen wrote:
Hi Amin, As Elaine alluded to, the code for changing phi/psi is a lot simpler than what was necessary in 2005. In particular you can just assign a value to the phi or psi attribute to change it. Therefore in your script, the loop would just be:
for res in mol.residues: if res.phi is not None: res.phi = -res.phi
--Eric
Eric Pettersen UCSF Computer Graphics Lab
On Feb 8, 2014, at 11:03 AM, amin@imtech.res.in wrote:
Dear Chimera users,
I am trying to write a script to change the phi and psi angle of a peptide. I am trying to adapt the code from http://plato.cgl.ucsf.edu/pipermail/chimera-users/2005-September/000456.html . I am trying to invert the angles so I am multiplying the angles by -1. My code is
import chimera
from chimera import selection, UserError, BondRot, replyobj
opened = chimera.openModels.open('fun.pdb') mol = opened[0] RES_LIST = mol.residues for res in mol.residues: b = str(res.phi) if b != 'None': c = -1*float(b) atomsMap = res.atomsMap N = atomsMap['N'][0] CA = atomsMap['CA'][0] C = atomsMap['C'][0] CAmap = CA.bondsMap phiBond = CAmap[N] psiBond = CAmap[C] phiAnchor = N psiAnchor = CA phi = BondRot(phiBond) phi.setAngle(c, phiAnchor)
When I run this script i get the error
phi.setAngle(c, phiAnchor) AttributeError: '_molecule.BondRot' object has no attribute 'setAngle'
Can someone please help me with this?
Warm regards.
Amin.
_______________________________________________ Chimera-users mailing list Chimera-users@cgl.ucsf.edu http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users

I guess I didn't completely answer your question. If you want strict control over which side of the phi/psi moves, then you are going to have to set up the bond rotation yourself rather than use res.phi/res/psi. You do this by finding the bond you want to rotate and then using the BondRotMgr module: from BondRotMgr import bondRotMgr rot = bondRotMgr.rotationForBond(bond) rot.anchorSide = anchor_atom then you'll have to measure the current phi/psi (which you could get via res.phi/res.psi) and use: rot.increment(angle_diff) to get to the desired value. When you are completely done adjusting the bond rotation, call: rot.destroy() --Eric On Feb 11, 2014, at 4:57 PM, Eric Pettersen <pett@cgl.ucsf.edu> wrote:
Hi Amin, I'm not sure why you care which side moves, but by default the "smaller" side moves. So if the residue is near the N terminus then the N-terminal part will move, if it's near the C terminus then the C-terminal side will move. Unless these changes are relative to some other structure, it shouldn't matter which side "moves"; the resulting conformation is the same either way.
--Eric
Eric Pettersen UCSF Computer Graphics Lab http://www.cgl.ucsf.edu
On Feb 8, 2014, at 8:33 PM, amin wrote:
Dear Dr. Pettersen and Dr. Meng,
Thanks for the suggestion. I tried the simpler scripts and they work. But I am not sure that what atoms are moved when I set res.phi = -res.phi. The earlier script had set anchor residues to solve this problem. Can you please guide me on how to use anchor residues on newer versions of chimera?
Warm Regards.
Amin.
On 2014-02-09 07:44, Eric Pettersen wrote:
Hi Amin, As Elaine alluded to, the code for changing phi/psi is a lot simpler than what was necessary in 2005. In particular you can just assign a value to the phi or psi attribute to change it. Therefore in your script, the loop would just be:
for res in mol.residues: if res.phi is not None: res.phi = -res.phi
--Eric
Eric Pettersen UCSF Computer Graphics Lab
On Feb 8, 2014, at 11:03 AM, amin@imtech.res.in wrote:
Dear Chimera users,
I am trying to write a script to change the phi and psi angle of a peptide. I am trying to adapt the code from http://plato.cgl.ucsf.edu/pipermail/chimera-users/2005-September/000456.html . I am trying to invert the angles so I am multiplying the angles by -1. My code is
import chimera
from chimera import selection, UserError, BondRot, replyobj
opened = chimera.openModels.open('fun.pdb') mol = opened[0] RES_LIST = mol.residues for res in mol.residues: b = str(res.phi) if b != 'None': c = -1*float(b) atomsMap = res.atomsMap N = atomsMap['N'][0] CA = atomsMap['CA'][0] C = atomsMap['C'][0] CAmap = CA.bondsMap phiBond = CAmap[N] psiBond = CAmap[C] phiAnchor = N psiAnchor = CA phi = BondRot(phiBond) phi.setAngle(c, phiAnchor)
When I run this script i get the error
phi.setAngle(c, phiAnchor) AttributeError: '_molecule.BondRot' object has no attribute 'setAngle'
Can someone please help me with this?
Warm regards.
Amin.
_______________________________________________ Chimera-users mailing list Chimera-users@cgl.ucsf.edu http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users
_______________________________________________ Chimera-users mailing list Chimera-users@cgl.ucsf.edu http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users

Thanks Dr. Pettersen. This helped me figure out most of the things. The last problem I had was with rotation of prolines. I found this thread regarding the problem http://plato.cgl.ucsf.edu/pipermail/chimera-users/2011-November/006938.html which I hope will solve everything. Thanks for the help. Amin. On 2014-02-12 06:42, Eric Pettersen wrote:
I guess I didn't completely answer your question. If you want strict control over which side of the phi/psi moves, then you are going to have to set up the bond rotation yourself rather than use res.phi/res/psi. You do this by finding the bond you want to rotate and then using the BondRotMgr module:
from BondRotMgr import bondRotMgr rot = bondRotMgr.rotationForBond(bond) rot.anchorSide = anchor_atom
then you'll have to measure the current phi/psi (which you could get via res.phi/res.psi) and use:
rot.increment(angle_diff)
to get to the desired value. When you are completely done adjusting the bond rotation, call:
rot.destroy()
--Eric
On Feb 11, 2014, at 4:57 PM, Eric Pettersen <pett@cgl.ucsf.edu> wrote:
Hi Amin, I'm not sure why you care which side moves, but by default the "smaller" side moves. So if the residue is near the N terminus then the N-terminal part will move, if it's near the C terminus then the C-terminal side will move. Unless these changes are relative to some other structure, it shouldn't matter which side "moves"; the resulting conformation is the same either way.
--Eric
Eric Pettersen UCSF Computer Graphics Lab http://www.cgl.ucsf.edu [1]
On Feb 8, 2014, at 8:33 PM, amin wrote:
Dear Dr. Pettersen and Dr. Meng,
Thanks for the suggestion. I tried the simpler scripts and they work. But I am not sure that what atoms are moved when I set res.phi = -res.phi. The earlier script had set anchor residues to solve this problem. Can you please guide me on how to use anchor residues on newer versions of chimera?
Warm Regards.
Amin.
On 2014-02-09 07:44, Eric Pettersen wrote: Hi Amin, As Elaine alluded to, the code for changing phi/psi is a lot simpler than what was necessary in 2005. In particular you can just assign a value to the phi or psi attribute to change it. Therefore in your script, the loop would just be:
for res in mol.residues: if res.phi is not None: res.phi = -res.phi
--Eric
Eric Pettersen UCSF Computer Graphics Lab
On Feb 8, 2014, at 11:03 AM, amin@imtech.res.in wrote:
Dear Chimera users,
I am trying to write a script to change the phi and psi angle of a peptide. I am trying to adapt the code from http://plato.cgl.ucsf.edu/pipermail/chimera-users/2005-September/000456.html [2] . I am trying to invert the angles so I am multiplying the angles by -1. My code is
import chimera
from chimera import selection, UserError, BondRot, replyobj
opened = chimera.openModels.open('fun.pdb') mol = opened[0] RES_LIST = mol.residues for res in mol.residues: b = str(res.phi) if b != 'None': c = -1*float(b) atomsMap = res.atomsMap N = atomsMap['N'][0] CA = atomsMap['CA'][0] C = atomsMap['C'][0] CAmap = CA.bondsMap phiBond = CAmap[N] psiBond = CAmap[C] phiAnchor = N psiAnchor = CA phi = BondRot(phiBond) phi.setAngle(c, phiAnchor)
When I run this script i get the error
phi.setAngle(c, phiAnchor) AttributeError: '_molecule.BondRot' object has no attribute 'setAngle'
Can someone please help me with this?
Warm regards.
Amin. _______________________________________________ Chimera-users mailing list Chimera-users@cgl.ucsf.edu http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users [3]
_______________________________________________ Chimera-users mailing list Chimera-users@cgl.ucsf.edu http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users Links: ------ [1] http://www.cgl.ucsf.edu/ [2] http://plato.cgl.ucsf.edu/pipermail/chimera-users/2005-September/000456.html [3] http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users
participants (3)
-
amin@imtech.res.in
-
Elaine Meng
-
Eric Pettersen