[chimera-dev] per-frame python script

James Prestegard jpresteg at ccrc.uga.edu
Fri Jul 21 09:38:03 PDT 2017


Thanks, I’ll try that.
Jim

From: Eric Pettersen [mailto:pett at cgl.ucsf.edu]
Sent: Thursday, July 20, 2017 2:09 PM
To: James Prestegard <jpresteg at ccrc.uga.edu>
Cc: chimera-dev at cgl.ucsf.edu
Subject: Re: [chimera-dev] per-frame python script

Hi Jim,
            You could do something hack-y like stow your persistent variables inside a global module (such as the chimera module), but it would be better to have your script not be a per-frame script, but instead a global script that advances the frames itself, so that you could handle your persistent data more naturally.  Assuming you have opened your trajectory in Chimera, here is the skeletal Python code to do that:

from chimera import openModels, Molecule
m = openModels.list(modelTypes=[Molecule])[0]
m.loadAllFrames()
indices = m.coordSets.keys()
indices.sort()
# set up your persistent variables here
for i in indices:
        m.activeCoordSet = m.coordSets[i]
        # do your per-frame computation here
# output final results here

You would save your script into a file ending in ‘.py’, and then just use the “open” command to run it.

—Eric

            Eric Pettersen
            UCSF Computer Graphics Lab

On Jul 19, 2017, at 2:19 PM, James Prestegard <jpresteg at ccrc.uga.edu<mailto:jpresteg at ccrc.uga.edu>> wrote:

I’m trying to write a script to be used in the per-frame operation of chimera MD Movie (I’m not an accomplished python programmer).   The script I wrote calculates order parameters and internal relaxation elements.  It appears that I have to import some chimera commands as well as the python math library to do this.  Everything works on a single frame, but I need to pass some variables from frame to frame, and the import commands appear to reset all variables at each new frame.  Is there a way to set some global variables or to do the imports only once outside the pre-frame script?
Jim

James H. Prestegard
Professor and GRA Eminent Scholar, Emeritus
Complex Carbohydrate Research Center
University of Georgia
Athens, Georgia, 30602, USA
706-542-6281

_______________________________________________
Chimera-dev mailing list
Chimera-dev at cgl.ucsf.edu<mailto:Chimera-dev at cgl.ucsf.edu>
http://www.rbvi.ucsf.edu/mailman/listinfo/chimera-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-dev/attachments/20170721/ed787b48/attachment.html>


More information about the Chimera-dev mailing list