
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

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@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@cgl.ucsf.edu <mailto:Chimera-dev@cgl.ucsf.edu> http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev <http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev>

Thanks, I’ll try that. Jim From: Eric Pettersen [mailto:pett@cgl.ucsf.edu] Sent: Thursday, July 20, 2017 2:09 PM To: James Prestegard <jpresteg@ccrc.uga.edu> Cc: chimera-dev@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@ccrc.uga.edu<mailto:jpresteg@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@cgl.ucsf.edu<mailto:Chimera-dev@cgl.ucsf.edu> http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev
participants (2)
-
Eric Pettersen
-
James Prestegard