> A mail from Michael Miley encourages me to note that this does not
> work
> for WinCoot.
>
> I am sure that in due course, Bernhard will do some Python
> jiggery-pokery to make it happen :)
Paul is right (as usual?) as I was just doing it...
Here it comes
B
***************************************************
Dr. Bernhard Lohkamp
Assistant Professor
Div. Molecular Structural Biology
Dept. of Medical Biochemistry and Biophysics (MBB)
Karolinska Institutet
S-17177 Stockholm
Sweden
phone: (+46) 08-52487673
fax: (+46) 08-327626
email: [email protected]
global annotations
annotations = []
def add_annotation_here(text):
global annotations
rc = rotation_centre()
ann = [text] + rc
annotations.append(ann)
place_text(*(ann + [0]))
graphics_draw()
def save_annotations(file_name):
if (os.path.isfile(file_name)):
# remove existing file
print "BL INFO:: overwrite old annotation file", file_name
os.remove(file_name)
save_string_to_file(str(annotations), file_name)
def load_annotations(file_name):
if (os.path.isfile(file_name)):
from types import ListType
port = open(file_name, 'r')
ls = port.readline()
port.close()
ls = ls.rstrip("\n")
ls = eval(ls)
if (type(ls) is ListType):
global annotations
annotations = ls
for ann in annotations:
place_text(*(ann + [0]))
graphics_draw()
menu = coot_menubar_menu("Extensions")
add_simple_coot_menu_menuitem(menu, "Annotate position...",
lambda func:
generic_single_entry("Annotation: ", "", "Make Annotation",
lambda txt: add_annotation_here(txt)))
add_simple_coot_menu_menuitem(menu, "Save Annotations...",
lambda func:
generic_single_entry("Save Annotations", "coot_annotations.py",
" Save ",
lambda file_name:
save_annotations(file_name)))
add_simple_coot_menu_menuitem(menu, "Load Annotations...",
lambda func:
generic_single_entry("Load Annotations", "coot_annotations.py",
" Load ",
lambda file_name:
load_annotations(file_name)))