Note that residue with alt confs do not undergo auto-fit-rotamer. This is because that autofit-rotamer then refine will tend to put both rotamers into the same place. Not good. It seems a reasonable expectation that residues with an alternate conformation are already resonably well-fitted. So residues with alternate conformations undergo only real space refinement.
This is simple-minded and outdated now we have the interruptible version (below).
These 2 variables are used by multi-refine function(s), called by idle functions to refine just one residue.
chain-specifier can be a string, where it is the chain of interest. or 'all-chains, where all chains are chosen.
func is a refinement function that takes 2 args, one a residue spec, the other the imol-refinement-map. e.g. fit-protein-fit-function
For each residue in chain chain-id of molecule number imol, do a rotamer fit and real space refinement of each residue. Don't update the graphics while this is happening (which makes it faster than fit-protein, but much less interesting to look at).
For each residue in the solvent chains of molecule number imol, do a rigid body fit of the water to the density.
Step through the residues of molecule number imol and at each step do a residue range refinement (unlike fit-protein for example, which does real-space refinement for every residue).
The step is set internally to 2.
test-func is a function given one argument (a molecule number) that returns either #f if the condition is not satisfied or something else if it is. And that "something else" can be a list like (list label x y z) or (list "Bad Chiral" 0 "A" 23 "" "CA" "A")
It is used in the create a button label and "what to do when the button is pressed".
This totally ignores insertion codes. A clever algorithm would need a re-write, I think. Well, we'd have at this end a function that took a chain-id res-no-1 ins-code-1 res-no-2 ins-code-2
And refine-zone would need to be re-written too, of course. So let's save that for a rainy day (days... (weeks)).