Dear Andrew,

     > Having worked with O for many years I am only now getting
     > serious with COOT. There are a couple of things that I would
     > like to do that don't seem to be available (as far as I can
     > tell), but which may well be possible using Macros.

     > Unfortunately a quick Google has not revealed anything about
     > how to use macros in COOT, but a colleague suggested they need
     > to be written in Python or another language that I had not
     > heard of before.

Your colleague is correct. The other language is a form of Lisp - you
will have heard of that.

     > So my first question is where can I find a low level
     > description of how to write macros with some examples (I know
     > nothing about Python, except that it is fashionable) ?

It is fashionable - or at least is was 2 years ago. Now the cool kids
favourite is ruby (on rails) I understand.  We don't use the word
"macros" because that would be confusing given the extant Lisp macros,
which are part of the language.

You can learn about programming python in many ways of course (not
least the python tutorial, which is what I read first)

http://docs.python.org/tutorial/

The coot python extensions are described in the documentation.

There is a standard trivial formatting change that has to be made to
get the syntax right for python, see "Python Scripting" here:

http://www.ysbl.york.ac.uk/~lohkamp/coot/wincoot-faq.html

There is a growing collection of coot scripts in the Wiki

http://strucbio.biologie.uni-konstanz.de/ccp4wiki/index.php/COOT

     > There are specifically two things I want to be able to do:

     > 1. Do an LSQ superposition using specified residues in multiple
     > chains (superposing one oligomer on another).

Something like this then?

clear_lsq_matches()
# specs for reference then moving
add_lsq_match(20, 90, "A",  20, 90, "A", 1)
add_lsq_match(20, 90, "B",  20, 90, "B", 1)
add_lsq_match(15, 75, "D",  15, 75, "D", 1)
apply_lsq_matches(1, 2)

which presumes that the reference molecule is in 1 and the moving molecule 2.

     > 2. To do a LSQ superposition of a homologous structure onto my
     > working structure using ± N residues about the current
     > position, where N is a variable (not essential, could be fixed)
     > and the current position is
     > the last residue that I clicked on.

That is more involved - and more useful because it can be dynamic . Something like the following perhaps (in scheme, just for amusement (not tested)). You will need to set imol-ref, perhaps by reading in the reference pdb, as demonstrated below. The function is bound to Shift-Y.


Paul.

-----


(define dynamic-lsq-range-extent 2) ;; +/- 2 residues either side of centre residue
(define imol-ref (read-pdb "reference.pdb"))

;; convert between the input reference chain id and the chain id of
;; the moving molecule that corresponds to that chain
;;
(define (mov-match-chain ref-chain-id)
  ref-chain-id)

(define (dynamic-lsq-match)

  ;; get the current residue and use that to make residue ranges for
  ;; an LSQ fit
  ;;

  (using-active-atom
   (clear-lsq-matches)
   (add-lsq-match (- aa-res-no dynamic-lsq-range-extent)
                  (+ aa-res-no dynamic-lsq-range-extent)
                  aa-chain-id
                  (- aa-res-no dynamic-lsq-range-extent)
                  (+ aa-res-no dynamic-lsq-range-extent)
                  (mov-match-chain aa-chain-id)
                  1)
   (apply-lsq-matches aa-imol imol-ref)))


(add-key-binding "Dynamic LSQ overlay" "Y" dynamic-lsq-match)



Paul.

Reply via email to