[Chimera-users] python and MD

Eric Pettersen pett at cgl.ucsf.edu
Mon Aug 8 11:45:13 PDT 2011


Hi Dan,
	You are correct that "coordset" can't go to a frame that hasn't been  
loaded yet.  Right now, only the MD Movie tool knows how to load a  
frame from a trajectory, therefore what you have to do is find the  
Python instance of the MD Movie interface and call its LoadFrame  
method.  So here's some code to do that:

def findMDMovie():
     # locate and return the newest instance
     # of MD Movie
     from Movie.gui import MovieDialog
     from chimera.extension import manager
     mdms = [inst for inst in manager.instances
                     if isinstance(inst, MovieDialog)]
     if not mdms:
         raise AssertionError("No MD Movie instances!")
     return mdms[-1]

mdm = findMDMovie()
mdm.LoadFrame(frameNumber)

	So, not too bad.  LoadFrame() will not only load the frame but will  
also go to that frame.  Let me know if you have more questions.

--Eric

                         Eric Pettersen
                         UCSF Computer Graphics Lab
                         http://www.cgl.ucsf.edu'

On Aug 7, 2011, at 11:14 AM, Daniel Gurnon wrote:

> Hi everyone,
> I have a question for the python experts:
>
> Suppose I have opened an MD trajectory using MD movie.
>
> I want a script that will capture images along the trajectory spaced  
> by user-defined timespans. Problem is, I don't know how to use a  
> script to go to a specific frame in MD movie. As I understand it,  
> coordset, as employed in the following example, requires the user to  
> first play through the entire trajectory. With a million frames,  
> that's not practical. Here's what I have so far, cobbled together  
> from examples and my own limited understanding of Python.
>
>
> ----------------------------
> from chimera import runCommand
>
> timestep=input ("How many picoseconds pass between frames?")
> spacing=input ("What spacing, in ps, do you want between structures?")
> start=input ("Which frame do you want to start with?")
> end=input ("What frame do you want to end with?")
>
> runCommand("coordset #0" + start)
> runCommand("focus")
> runCommand("copy file C:\Users\Dan\Desktop" + "\\" +start + ".png" +  
> " width 2000 width 2000 supersample 3")
> ----------------------------
>
> So in place of coordest, what could I use to jump to frames within  
> MD movie?
>
> And while I'm at it,
> How can I generically specify the desktop in a windows environment  
> (so that I could give this to a student and they wouldn't have to  
> change "Dan" in c:\users\Dan\Desktp")
> How can I change the filename for the image to reflect framenumber?




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-users/attachments/20110808/24f5fa65/attachment.html>


More information about the Chimera-users mailing list