Subject: Re: reloading sparky files
From: Tom Goddard
Date: Jan 30, 2014



Hi Murray,

Sparky does not check if peak files (.save) or spectrum files (.ucsf) have changed since they were last loaded. If you want it to reload files that are changing I see two options. You could have the program that is doing the modifying tell Sparky to reload the files. Sparky doesnt listen for connections from other programs so this would require modifications to Sparky. Or you could write a Sparky extension as you suggested. It could simply check if the files have been modified every few seconds and reload them if needed. I think this is possible with the limited Python API to Sparky

http://www.cgl.ucsf.edu/home/sparky/sparky-api.txt

You would probably use the View destroy() method to close old windows and the Session open_spectrum() method to open the new peak file. It wont be pretty as windows disappear and new ones appear. If you are simply putting new peak markers on a spectrum, you could just read a file of those marker positions and create them in Python after deleting the old ones. Then it would reuse the existing window. If you change the spectrum data, Im not sure there is any way to get Sparky to reread the data values other than closing the spectrum and reopening it. Sparky caches the spectrum data in memory, so in theory the cache could be cleared and maybe the contour level changed to make it redraw the new contours. You can set the cache size to zero in the preferences dialog and it appears that can be set in a peak file (.save) with a set cachesize 0 line.

In short Sparky was not intended to monitor calculations of spectra or peak placements or assignments done by external programs, so you are likely to encounter some challenges.

There is some description of how to write a Sparky extension at the Sparky web site.

http://www.cgl.ucsf.edu/home/sparky/manual/extensions.html#WriteExtension

Tom


On Jan 30, 2014, at 10:05 AM, Murray Coles wrote:


Hello all

I am writing some scripts that generate sparky format files. This works perfectly well, but I find I have to reload the calculated spectrum each time it is changed by the script. This is naturally time consuming and, to some extent, defeats the purpose of the calculations.

I was wondering if there is the possibility to ask sparky to reload a spectrum - e.g. by re-opening the .save file - every time the .ucsf and/or .save file is changed. Perhaps I need to write an extension to open files with this behaviour.

thanks in advance

Murray
Murray Coles
NMR Spectroscopy
Max-Planck Institute for Developmental Biology, Tuebingen
Spemannstr. 35
72076 Tuebingen, Germany