[Chimera-users] triggering events when findhbond finds a bond
pett at cgl.ucsf.edu
Mon Jun 4 15:55:51 PDT 2012
On Jun 4, 2012, at 2:42 PM, Anne Bowen wrote:
> I currently have a "Per-Frame Command" set up (in the MD Movie
> dialog) that finds the H bonds (findhbond makePseudobonds true
> lineWidth 2.0 color green intramodel true intermodel false
> selRestrict any)
> every frame of a trajectory. Whenever a hbond is detected, I
> would like to turn the entire structure a different color just for
> that frame, and then have it go back to being colored by
> heteroatom. Is there an easy way to accomplish this? I tried to
> look through the documentation to determine if "findhbond" could
> return true or false if an h bond was found and it did not seem like
> it was possible. Is the only way to do this to change the findhbond
> script itself? Any help or suggestions is greatly appreciated!
You will have to resort to Python to do what you want to do here.
Very simple Python, but Python nonetheless. The reason it can be
simple is that there is a Python command named runCommand that allows
you to execute regular Chimera commands and therefore the bulk of the
script is just Python calls of commands you already know, with a
little extra logic/glue to perform the test for the H-bonds and
execute the corresponding color command.
So first, in the "Per-Frame" dialog change the "Interpret script as"
to "Python". Then put this in as your script:
from chimera import runCommand
runCommand("findhbond makePseudobonds true lineWidth 2.0 color green
intramodel true intermodel false selRestrict any")
if len(chimera.misc.getPseudoBondGroup("hydrogen bonds").pseudoBonds)
runCommand("~color; color byhet")
I chose red as the "other color"; change it to whatever you like. The
"~color" is needed before the "color byhet" so that the carbon atoms
will go to their non-red color.
I'm guessing you'd like it if MD Movie's Analysis->Plot menu item
allowed for plotting number of H-bonds?
UCSF Computer Graphics Lab
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Chimera-users