[Chimera-users] Flushing output during the script execution

Thomas Goddard goddard at cgl.ucsf.edu
Mon Oct 27 16:03:47 PDT 2008


Hi Lukas,

   Eric's suggestion to add a "wait 1" explains the immediate problem.

   But your use of sleep(1) is not so nice since that freezes Chimera. 
You won't be able to rotate or change the contour level.  Better to let 
Chimera run its event loop and use a timer to check every second for a 
new file.  I've attached the python code that does that.  This code 
isn't perfect.  Sometimes the program writing the map may only have it 
partially written when Chimera reads it and that will produce an error 
in Chimera.  The attached code will continue trying to read but I didn't 
see an easy way to suppress the error message.

	Tom

Lukas Palatinus wrote:
> Hello all,
> I am using Chimera as a visualization tool for small-molecule electron 
> densities obtained by ab initio structure solution. I want to create a 
> small script that will make Chimera read and display the intermediate 
> electron densities as they are produced during the iterative structure 
> solution process. I am not skilled in Python, but I could make a simple 
> Python script by copying and modifying scripts previously posted in this 
> list. Here is the script:
> 
> from chimera import runCommand as run
> from os.path import exists
> from time import sleep
> map_file= 'test.xplor'
> while exists(map_file):
>    run('close all')
>    run('open ' + map_file)
>    sleep(1)
> 
> I am sure this is not the most elegant way to achieve what I need, but 
> it should do the job. What the script should in my opinion do is to read 
> and display the file test.xplor, then wait one second, close the map and 
> reopen it again, until the file test.xplor is deleted. The script does 
>  >>almost<< that, it opens the volume viewer, reads the map, but it does 
> not display the map in the main Chimera window. Only after the file 
> test.xplor is deleted, the last map is displayed. Can anybody give me a 
> hint what am I doing wrong? I am using Chimera 1.2540 on Mac OS X 10.4.
> 
> Thanks in advance for any help.
> 
> Best regards
> 
> Lukas
> 
> 
> Lukas Palatinus
> Laboratoire de Cristallographie
> EPFL Lausanne
> Tel.: +41 (0)21 693 0639
> mailto: palat at fzu.cz <mailto:palat at fzu.cz>
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Chimera-users mailing list
> Chimera-users at cgl.ucsf.edu
> http://www.cgl.ucsf.edu/mailman/listinfo/chimera-users

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: monitor.py
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-users/attachments/20081027/26604255/attachment.ksh>


More information about the Chimera-users mailing list