Re: [COOT] Feature Request: Notes

2009-03-11 Thread Bernhard Lohkamp

> 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: bernhard.lohk...@ki.se




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)))


Re: [COOT] Feature Request: Notes

2009-03-11 Thread Dirk Kostrewa

Am 11.03.2009 um 16:10 schrieb Paul Emsley:


Dirk Kostrewa wrote:

Dear Paul,
could you please write a second litte extension script that allows  
to put text at a clickable atom, too? Then, this would be  
complete ...


I don't understand it seems.  Why not just centre on the atom you  
want and then add the annotation?


yes, that's a possibility ...




Paul.


Dirk.

***
Dirk Kostrewa
Gene Center, A 5.07
Ludwig-Maximilians-University
Feodor-Lynen-Str. 25
81377 Munich
Germany
Phone:  +49-89-2180-76845
Fax:+49-89-2180-76999
E-mail: kostr...@lmb.uni-muenchen.de
***


Re: [COOT] Feature Request: Notes

2009-03-11 Thread Paul Emsley

OK, I see that Bernhard had the same doubt as I did.

When you load annotations, any previous annotations that you had are 
overwritten.  (It seems that) we are not sure that that is a good thing.
On the other hand, not overwriting them could/would leave you with 
unneeded duplicates. Thoughts?


P.


Re: [COOT] Feature Request: Notes

2009-03-11 Thread Paul Emsley
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.


Re: [COOT] Feature Request: Notes

2009-03-11 Thread Paul Emsley

Dirk Kostrewa wrote:

Thanks, would like to try it. But how do call it? I've saved the code 
as "test.scm" and opened it with Calculate -> Run Script -> test.scm, 
but nothing happens?


Yes, you can do that, or:
$ coot --script test.scm


Annotation menu items should have added themselves to the Extension menu.




Ahh! This does exactly, what I wanted! 



Good stuff.


So, could you please add this 
extension to the next version of Coot?



Yes, OK.  I will put it in a submenu.


Meanwhile, where can I put this little script such that it is 
automatically loaded upon starting coot?



There are several ways

1) Add the text to your ~/.coot file

2) Put the file in your ~/.coot-preferences directory (make sure it has 
.scm extension)


3) If you want to share it with others (typically) put that file in a 
directory pointed to by the COOT_SCHEME_EXTRAS_DIR environment variable


Regards,

Paul.


Re: [COOT] Feature Request: Notes

2009-03-11 Thread Dirk Kostrewa

Hi Ashley,

no, it is really the place_text function that I want ...

Dirk.

Am 11.03.2009 um 15:09 schrieb Ashley Pike:

Hi - I think what Paul is referring to can be done in Extensions>  
Views > Add Views
get to attach text to current pointer position which is added to a  
new views palette

- views are clickable
- can be saved and imported again at a later date etc.

Ashley

--
Dr. Ashley Pike
Structural Genomics Consortium,
Old Road Campus Research Building,
University of Oxford,
Headington,
Oxford OX3 7DQ.

Phone:   +44 (0)1865 617576
FAX: +44 (0)1865 617575
Email: ashley.p...@sgc.ox.ac.uk
WWW: www.sgc.ox.ac.uk



Dirk Kostrewa  11/03/2009 13:41 >>>

Dear Paul,

Am 11.03.2009 um 14:22 schrieb Paul Emsley:


Dear Dirk, David,


2009/3/11 Dirk Kostrewa :

Dear Paul,

this is a feature request: I would like to attach notes to the
structure, like "water or sodium", "alternative conformation?",
"peptide flipped", that should be displayed in the next session
like labels as a "three-dimensional" notebook of what I've already
done or want to do.


There is place-text to do this.  That has been available since Coot
0.0.



I can't find anything about "place-text", neither in Coot itself, nor
in any of its documentations on the Coot web site - where is it
described?


This can be very useful, especially to avoid
perpetual re-fitting/omitting of the same feature again, or simply
to mark checkpoints. It should be possible to put a note both at
an atomic position or at the pointer position (to mark unexplained
density for instance). The notes could be saved with the session
file or as an external file that could be read into a new session.
Could you please think about adding this feature?






If text is attached to a position in space there is no issue of
transferring annotations and you can use place-text.  Attached is a
simple piece of code to do that where I add a gui wrapper to place-
text so that you can make a 3D annotation, and save and load those
annotations.

Regards,

Paul.



Thanks, would like to try it. But how do call it? I've saved the code
as "test.scm" and opened it with Calculate -> Run Script -> test.scm,
but nothing happens?

Best regards,

Dirk.

***
Dirk Kostrewa
Gene Center, A 5.07
Ludwig-Maximilians-University
Feodor-Lynen-Str. 25
81377 Munich
Germany
Phone:  +49-89-2180-76845
Fax:+49-89-2180-76999
E-mail: kostr...@lmb.uni-muenchen.de
***



***
Dirk Kostrewa
Gene Center, A 5.07
Ludwig-Maximilians-University
Feodor-Lynen-Str. 25
81377 Munich
Germany
Phone:  +49-89-2180-76845
Fax:+49-89-2180-76999
E-mail: kostr...@lmb.uni-muenchen.de
***


Re: [COOT] Feature Request: Notes

2009-03-11 Thread Dirk Kostrewa

Dear Paul,

could you please write a second litte extension script that allows to  
put text at a clickable atom, too? Then, this would be complete ...


Best regards,

Dirk.

Am 11.03.2009 um 15:09 schrieb Dirk Kostrewa:


Dear Paul,


Dirk Kostrewa wrote:

Dear Paul,
Am 11.03.2009 um 14:22 schrieb Paul Emsley:

Dear Dirk, David,

>> 2009/3/11 Dirk Kostrewa :
>>> Dear Paul,
>>>
>>> this is a feature request: I would like to attach notes to the
>>> structure, like "water or sodium", "alternative conformation?",
>>> "peptide flipped", that should be displayed in the next session
>>> like labels as a "three-dimensional" notebook of what I've  
already

>>> done or want to do.

There is place-text to do this.  That has been available since Coot
0.0.

I can't find anything about "place-text", neither in Coot itself,  
nor in any of its documentations on the Coot web site - where is  
it described?



Ah, the old "Coot scripting documentation is cr^^poor" thread, eh? :)



*cough*, ehm, well, ... ;-)




If text is attached to a position in space there is no issue of
transferring annotations and you can use place-text.  Attached is a
simple piece of code to do that where I add a gui wrapper to  
place-text so that you can make a 3D annotation, and save and  
load those annotations.


Regards,

Paul.
Thanks, would like to try it. But how do call it? I've saved the  
code as "test.scm" and opened it with Calculate -> Run Script ->  
test.scm, but nothing happens?


Yes, you can do that, or:
$ coot --script test.scm


Annotation menu items should have added themselves to the Extension  
menu.


Paul.



Ahh! This does exactly, what I wanted! So, could you please add this  
extension to the next version of Coot?
Meanwhile, where can I put this little script such that it is  
automatically loaded upon starting coot?


Best regards,

Dirk.

***
Dirk Kostrewa
Gene Center, A 5.07
Ludwig-Maximilians-University
Feodor-Lynen-Str. 25
81377 Munich
Germany
Phone:  +49-89-2180-76845
Fax:+49-89-2180-76999
E-mail: kostr...@lmb.uni-muenchen.de
***



***
Dirk Kostrewa
Gene Center, A 5.07
Ludwig-Maximilians-University
Feodor-Lynen-Str. 25
81377 Munich
Germany
Phone:  +49-89-2180-76845
Fax:+49-89-2180-76999
E-mail: kostr...@lmb.uni-muenchen.de
***


Re: [COOT] Feature Request: Notes

2009-03-11 Thread Dirk Kostrewa

Dear Paul,


Dirk Kostrewa wrote:

Dear Paul,
Am 11.03.2009 um 14:22 schrieb Paul Emsley:

Dear Dirk, David,

>> 2009/3/11 Dirk Kostrewa :
>>> Dear Paul,
>>>
>>> this is a feature request: I would like to attach notes to the
>>> structure, like "water or sodium", "alternative conformation?",
>>> "peptide flipped", that should be displayed in the next session
>>> like labels as a "three-dimensional" notebook of what I've  
already

>>> done or want to do.

There is place-text to do this.  That has been available since Coot
0.0.

I can't find anything about "place-text", neither in Coot itself,  
nor in any of its documentations on the Coot web site - where is it  
described?



Ah, the old "Coot scripting documentation is cr^^poor" thread, eh? :)



*cough*, ehm, well, ... ;-)




If text is attached to a position in space there is no issue of
transferring annotations and you can use place-text.  Attached is a
simple piece of code to do that where I add a gui wrapper to place- 
text so that you can make a 3D annotation, and save and load those  
annotations.


Regards,

Paul.
Thanks, would like to try it. But how do call it? I've saved the  
code as "test.scm" and opened it with Calculate -> Run Script ->  
test.scm, but nothing happens?


Yes, you can do that, or:
$ coot --script test.scm


Annotation menu items should have added themselves to the Extension  
menu.


Paul.



Ahh! This does exactly, what I wanted! So, could you please add this  
extension to the next version of Coot?
Meanwhile, where can I put this little script such that it is  
automatically loaded upon starting coot?


Best regards,

Dirk.

***
Dirk Kostrewa
Gene Center, A 5.07
Ludwig-Maximilians-University
Feodor-Lynen-Str. 25
81377 Munich
Germany
Phone:  +49-89-2180-76845
Fax:+49-89-2180-76999
E-mail: kostr...@lmb.uni-muenchen.de
***


Re: [COOT] Feature Request: Notes

2009-03-11 Thread Paul Emsley
Just to be clear, we've been thinking about annotations. The current 
(poorly documented) annotation mechanisms are a place-holder, waiting 
for "deep" annotations in the manner described by Kevin, which means 
that (at some stage) annotations can appear everywhere: sequence view, 
validation graphs, 3D text and Views Panel and be simply transfered 
between molecules (and colleagues) in scheme or python.



Paul.


Re: [COOT] Feature Request: Notes

2009-03-11 Thread Paul Emsley

Dirk Kostrewa wrote:

Dear Paul,

Am 11.03.2009 um 14:22 schrieb Paul Emsley:


Dear Dirk, David,

>> 2009/3/11 Dirk Kostrewa :
>>> Dear Paul,
>>>
>>> this is a feature request: I would like to attach notes to the
>>> structure, like "water or sodium", "alternative conformation?",
>>> "peptide flipped", that should be displayed in the next session
>>> like labels as a "three-dimensional" notebook of what I've already
>>> done or want to do.

There is place-text to do this.  That has been available since Coot
0.0.



I can't find anything about "place-text", neither in Coot itself, nor in 
any of its documentations on the Coot web site - where is it described?



Ah, the old "Coot scripting documentation is cr^^poor" thread, eh? :)


http://www.ysbl.york.ac.uk/~emsley/coot/doc/doxygen/html/c-interface_8h.html

(it's called "place_text" there of course).



>>> This can be very useful, especially to avoid
>>> perpetual re-fitting/omitting of the same feature again, or simply
>>> to mark checkpoints. It should be possible to put a note both at
>>> an atomic position or at the pointer position (to mark unexplained
>>> density for instance). The notes could be saved with the session
>>> file or as an external file that could be read into a new session.
>>> Could you please think about adding this feature?






If text is attached to a position in space there is no issue of
transferring annotations and you can use place-text.  Attached is a
simple piece of code to do that where I add a gui wrapper to 
place-text so that you can make a 3D annotation, and save and load 
those annotations.


Regards,

Paul.



Thanks, would like to try it. But how do call it? I've saved the code as 
"test.scm" and opened it with Calculate -> Run Script -> test.scm, but 
nothing happens?




Yes, you can do that, or:
$ coot --script test.scm


Annotation menu items should have added themselves to the Extension menu.

Paul.


Re: [COOT] Feature Request: Notes

2009-03-11 Thread Dirk Kostrewa

Dear Paul,

Am 11.03.2009 um 14:22 schrieb Paul Emsley:


Dear Dirk, David,

>> 2009/3/11 Dirk Kostrewa :
>>> Dear Paul,
>>>
>>> this is a feature request: I would like to attach notes to the
>>> structure, like "water or sodium", "alternative conformation?",
>>> "peptide flipped", that should be displayed in the next session
>>> like labels as a "three-dimensional" notebook of what I've already
>>> done or want to do.

There is place-text to do this.  That has been available since Coot
0.0.



I can't find anything about "place-text", neither in Coot itself, nor  
in any of its documentations on the Coot web site - where is it  
described?



>>> This can be very useful, especially to avoid
>>> perpetual re-fitting/omitting of the same feature again, or simply
>>> to mark checkpoints. It should be possible to put a note both at
>>> an atomic position or at the pointer position (to mark unexplained
>>> density for instance). The notes could be saved with the session
>>> file or as an external file that could be read into a new session.
>>> Could you please think about adding this feature?






If text is attached to a position in space there is no issue of
transferring annotations and you can use place-text.  Attached is a
simple piece of code to do that where I add a gui wrapper to place- 
text so that you can make a 3D annotation, and save and load those  
annotations.


Regards,

Paul.



Thanks, would like to try it. But how do call it? I've saved the code  
as "test.scm" and opened it with Calculate -> Run Script -> test.scm,  
but nothing happens?


Best regards,

Dirk.

***
Dirk Kostrewa
Gene Center, A 5.07
Ludwig-Maximilians-University
Feodor-Lynen-Str. 25
81377 Munich
Germany
Phone:  +49-89-2180-76845
Fax:+49-89-2180-76999
E-mail: kostr...@lmb.uni-muenchen.de
***


Re: [COOT] Feature Request: Notes

2009-03-11 Thread Paul Emsley


Curses.  Now with attachment :)

Paul.



(define *annotations* '())

(define (add-annotation-here text)
  (let ((rc (rotation-centre))
(ann (cons text (rotation-centre

(set! *annotations* (cons ann *annotations*))
(apply place-text text (append (rotation-centre) (list 0)))
(graphics-draw)))

(define (save-annotations file-name)
  (call-with-output-file file-name
(lambda (port)
  (format port "~s~%" *annotations*

(define (load-annotations file-name)
  (if (file-exists? file-name)
  (begin
(call-with-input-file file-name
  (lambda (port)
(let ((ls (read port)))
  (if (list? ls)
  (begin
(set! *annotations* ls)
(for-each (lambda (ann)
(apply place-text (append ann (list 0
  *annotations*)))
  (graphics-draw)))


(let ((menu (coot-menubar-menu "Extensions")))

  (add-simple-coot-menu-menuitem
   menu "Annotate position..."
   (lambda ()
 (generic-single-entry "Annotation: "  "" "Make Annotation" 
   (lambda (txt)
 (add-annotation-here txt)


  (add-simple-coot-menu-menuitem
   menu "Save Annotations.."
   (lambda ()
 (generic-single-entry "Save Annotations" "coot-annotations.scm" " Save "
   (lambda (file-name)
 (save-annotations file-name)

  (add-simple-coot-menu-menuitem
   menu "Load Annotations..."
   (lambda ()
 (generic-single-entry "Save Annotations" "coot-annotations.scm" " Load "
   (lambda (file-name)
 (load-annotations file-name))




Re: [COOT] Feature Request: Notes

2009-03-11 Thread Paul Emsley

Dear Dirk, David,

>> 2009/3/11 Dirk Kostrewa :
>>> Dear Paul,
>>>
>>> this is a feature request: I would like to attach notes to the
>>> structure, like "water or sodium", "alternative conformation?",
>>> "peptide flipped", that should be displayed in the next session
>>> like labels as a "three-dimensional" notebook of what I've already
>>> done or want to do.

There is place-text to do this.  That has been available since Coot
0.0.

>>> This can be very useful, especially to avoid
>>> perpetual re-fitting/omitting of the same feature again, or simply
>>> to mark checkpoints. It should be possible to put a note both at
>>> an atomic position or at the pointer position (to mark unexplained
>>> density for instance). The notes could be saved with the session
>>> file or as an external file that could be read into a new session.
>>> Could you please think about adding this feature?
>>>
>> David Briggs wrote:
>> Seconded!
>>
>> That is a fantastic idea - so essentially a label associated with a
>> feature & a set of co-ordinates.

This is exactly what annotated view labels are.  This has been
available since 0.3.2. Or am I missing your point?  (View descriptions 
are displayed in the views panel - not in 3D).


You can add view descriptions using

(add-view-description view-number text)


Kevin Cowtan wrote:
> Hmmm... Could probably be done with MMDB's UDD records. Then notes
> would be attached to atoms (maybe residues?). THis has the advantage
> that if you move the module to a different asymmetric unit you retain
> the comments.
>
> It might be nice to save them in the PDB file as remarks, but while I
> think recent MMDB can read remarks, I'm not sure if it can write them?
>
> Also relevant to future PDB spec.
>

If text is attached to residues/atoms then that is quite involved -
how do you transfer annotations from one molecule to the next? (as you
would surely want to do after cycling with Refmac). This is not
unsolvable, just needs to be thought about so that it happens is as
slick a way as possible. (Yes, it would be nice if after Refmacing (or 
as you suggest, Phaser, say) annotation remarks were transfered to the 
refined molecule).


If text is attached to a position in space there is no issue of
transferring annotations and you can use place-text.  Attached is a
simple piece of code to do that where I add a gui wrapper to place-text 
so that you can make a 3D annotation, and save and load those annotations.


Regards,

Paul.


Re: [COOT] Feature Request: Notes

2009-03-11 Thread Kevin Cowtan
Hmmm... Could probably be done with MMDB's UDD records. Then notes would 
be attached to atoms (maybe residues?). THis has the advantage that if 
you move the module to a different assymetric unit you retain the comments.


It might be nice to save them in the PDB file as remarks, but while I 
think recent MMDB can read remarks, I'm not sure if it can write them?


Also relevent to future PDB spec.

David Briggs wrote:

Seconded!

That is a fantastic idea - so essentially a label assoicated with a
feature & a set of co-ordinates.

D

2009/3/11 Dirk Kostrewa :

Dear Paul,

this is a feature request: I would like to attach notes to the structure,
like "water or sodium", "alternative conformation?", "peptide flipped", that
should be displayed in the next session like labels as a "three-dimensional"
notebook of what I've already done or want to do. This can be very useful,
especially to avoid perpetual re-fitting/omitting of the same feature again,
or simply to mark checkpoints. It should be possible to put a note both at
an atomic position or at the pointer position (to mark unexplained density
for instance). The notes could be saved with the session file or as an
external file that could be read into a new session.
Could you please think about adding this feature?

Best regards,

Dirk.

***
Dirk Kostrewa
Gene Center, A 5.07
Ludwig-Maximilians-University
Feodor-Lynen-Str. 25
81377 Munich
Germany
Phone:  +49-89-2180-76845
Fax:+49-89-2180-76999
E-mail: kostr...@lmb.uni-muenchen.de
***







Re: [COOT] Feature Request: Notes

2009-03-11 Thread David Briggs
Seconded!

That is a fantastic idea - so essentially a label assoicated with a
feature & a set of co-ordinates.

D

2009/3/11 Dirk Kostrewa :
> Dear Paul,
>
> this is a feature request: I would like to attach notes to the structure,
> like "water or sodium", "alternative conformation?", "peptide flipped", that
> should be displayed in the next session like labels as a "three-dimensional"
> notebook of what I've already done or want to do. This can be very useful,
> especially to avoid perpetual re-fitting/omitting of the same feature again,
> or simply to mark checkpoints. It should be possible to put a note both at
> an atomic position or at the pointer position (to mark unexplained density
> for instance). The notes could be saved with the session file or as an
> external file that could be read into a new session.
> Could you please think about adding this feature?
>
> Best regards,
>
> Dirk.
>
> ***
> Dirk Kostrewa
> Gene Center, A 5.07
> Ludwig-Maximilians-University
> Feodor-Lynen-Str. 25
> 81377 Munich
> Germany
> Phone:  +49-89-2180-76845
> Fax:    +49-89-2180-76999
> E-mail: kostr...@lmb.uni-muenchen.de
> ***
>



-- 

David C. Briggs PhD
Father & Crystallographer
http://drdavidcbriggs.googlepages.com/home
Skype: DocDCB



[COOT] Feature Request: Notes

2009-03-11 Thread Dirk Kostrewa

Dear Paul,

this is a feature request: I would like to attach notes to the  
structure, like "water or sodium", "alternative conformation?",  
"peptide flipped", that should be displayed in the next session like  
labels as a "three-dimensional" notebook of what I've already done or  
want to do. This can be very useful, especially to avoid perpetual re- 
fitting/omitting of the same feature again, or simply to mark  
checkpoints. It should be possible to put a note both at an atomic  
position or at the pointer position (to mark unexplained density for  
instance). The notes could be saved with the session file or as an  
external file that could be read into a new session.

Could you please think about adding this feature?

Best regards,

Dirk.

***
Dirk Kostrewa
Gene Center, A 5.07
Ludwig-Maximilians-University
Feodor-Lynen-Str. 25
81377 Munich
Germany
Phone:  +49-89-2180-76845
Fax:+49-89-2180-76999
E-mail: kostr...@lmb.uni-muenchen.de
***