
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? Thanks as always for your help. Dan -- ____________________________ Daniel Gurnon, Ph. D. Associate Professor of Chemistry and Biochemistry DePauw University Greencastle, IN 46135 p: 765-658-6279 e: danielgurnon@depauw.edu

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?

Oops, missed these questions in my first reply... On Aug 7, 2011, at 11:14 AM, Daniel Gurnon wrote:
runCommand("copy file C:\Users\Dan\Desktop" + "\\" +start + ".png" + " width 2000 width 2000 supersample 3")
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?
In Chimera commands, tilde ('~') can be used in place of the user's home directory. Also, you probably want to prefix the string with 'r' so that the backslashes aren't handled specially by Python. Lastly, you probably want to zero-pad the PNG file names to make them sort correctly in listings and be easier to handle in scripts. Therefore, the above command becomes: runCommand(r"copy file ~\Desktop\%06d.png width 2000 width 2000 supersample 3" % frameNumber) The "%06d" will be replaced by a 6-digit version of frameNumber, padded with zeroes as needed. --Eric Eric Pettersen UCSF Computer Graphics Lab http://www.cgl.ucsf.edu
participants (2)
-
Daniel Gurnon
-
Eric Pettersen