>
> I'm looking for a script that automatically loads a PDB file when it has
>> changed on disk in order to display the changes with a previous version of
>> that file.
>>
>
Here is a Python version. I prefer to overwrite the old molecule - but this
will work either way. (I think - it is untested but I do similar things
already.)
import os.path
import gobject
import coot
# usage:
# pdb_file_monitor(pdb_file)
# or:
# imol = read_pdb(pdb_file)
# pdb_file_monitor(pdb_file, imol)
#
class pdb_file_monitor (object) :
def __init__ (self, pdb_file, pdb_object_id=None) :
self.pdb_file = pdb_file
self.pdb_object_id = pdb_object_id
self.last_mtime = os.path.getmtime(pdb_file)
gobject.timeout_add(200, self.update_pdb)
def update_pdb (self, *args) :
current_mtime = os.path.getmtime(self.pdb_file)
if current_mtime > self.last_mtime :
if self.pdb_object_id is None :
handle_read_draw_molecule_with_recentre(self.pdb_file)
else :
clear_and_update_model_molecule_from_file(self.pdb_object_id,
self.pdb_file)
self.last_mtime = current_mtime