[Chimera-users] Question about animated Ramachandran plot

Eric Pettersen pett at cgl.ucsf.edu
Mon Jun 4 17:40:36 PDT 2012


On Jun 1, 2012, at 12:19 PM, Trina Manalo wrote:

> Hello,
>
> I would like to create an animated Ramachandran plot using an MD  
> trajectory. One approach I've considered is using a per-frame script  
> to save Ramachandran plot images (i.e., using the model panel, its  
> possible to create a plot and then save the image as a png)
>
> Is there a way to do this using commands? Or is there an easier way  
> to animate a plot of phi and psi angles over time?

Hi Trina,
	Um, how good are you with Python?  This is definitely a Python  
thing.  Here is a script you would use, after some modification, in  
the MD Movie per-frame dialog (with "Interpret script as" set to  
"Python"):

from Ramachandran import RamachandranPlot
plt = RamachandranPlot(mdInfo['mol'])
import os.path
plt.figure.savefig(os.path.join(os.path.expanduser("~"), "rama", "rama 
%05d.png" % mdInfo['frame']),
	format="png")
plt.destroy()

Notes:
(1) You probably want to turn off looping before running the script.

(2) The script will save a series of PNG format images into a folder  
named "rama" under your home directory.  Make sure to create that  
folder before running the script.  The files will have names like  
rama00005.png (for the fifth frame).  If you want to change where the  
images are saved or their names you need to modify the 'savefig' in  
the script.  If you know any Python it's simple.  You may be able to  
figure it out if you don't, but if you need help let me know.  If you  
want a format other than PNG or possibly other behaviors, the  
documentation for the savefig command is here:

http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.savefig

(3) You will need to get tomorrow's daily build to run the script  
successfully because I had to fix two problems to get it to work.  
There was a bug in the code that destroyed the Ramachandran plot  
dialog after it was used (don't want a million plots on the screen!).   
Also, the script was not being executed for the frame where it was  
defined -- so if you defined it when frame 1 was showing you wouldn't  
get a rama00001.png, the pngs would start with rama00002.png.  Though  
if looping was on you would eventually get a rama00001.png when it  
looped around.  This bug was introduced sometime between the 1.4.1 and  
1.5.3 releases.  Anyway, anybody running MD Movie scripts:  get a  
daily build!

--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/20120604/516ec731/attachment.html>


More information about the Chimera-users mailing list