In case it is of use to anyone else, the working script is below (I have also 
posted it on http://cootscripts.tiddlyspace.com/):

#Force addition of residue - useful when
#Coot says "No acceptable position found"
#but density is clear.
def force_add_terminal_residue():
  def force_addition(res1):
    mol_id=res1[1]
    ch_id=res1[2]
    res_no=res1[3]
    res_type="auto"
    add_terminal_residue_using_phi_psi(mol_id,ch_id,res_no,
    res_type,-57.82,-47)
    sort_residues(mol_id)
  user_defined_click(1,force_addition)
add_simple_coot_menu_menuitem(menu,
"Forced addition of terminal residue (click terminus)",
lambda func: force_add_terminal_residue())

On Apr 29, 2014, at 9:30 AM, Oliver Clarke <olibcla...@gmail.com> wrote:

> Aha, didn’t know about sort_residues() - great, works now, thanks Bernhard!
> 
> Oliver.
> On Apr 29, 2014, at 9:27 AM, Bernhard Lohkamp <bernhard.lohk...@ki.se> wrote:
> 
>> 
>> "N" and "C" works fine for me. Actually "auto" as well, but what is missing 
>> is a resorting of the residues (they are in the wrong order after addition). 
>> So, do a
>> 
>> sort_residues(imol)
>> 
>> after addition and everything will be fine.
>> 
>> B
>> 
>> On 29/04/2014 15:08, Oliver Clarke wrote:
>>> Hi Bernhard,
>>> 
>>> Thanks, but I’m not sure that’s the case - in the scheme manual that
>>> parameter is listed as residue_type, same as for
>>> add_terminal_residue, and in any case when I change it to “N” it
>>> still adds at the C-terminus.
>>> 
>>> Also, even when adding at the C-terminus, it adds after the TER flag
>>> and whatever solvent molecules are part of the chain, which does not
>>> seem like the desired behaviour.
>>> 
>>> Best, Oliver. On Apr 29, 2014, at 2:45 AM, Bernhard Lohkamp
>>> <bernhard.lohk...@ki.se> wrote:
>>> 
>>>> 
>>>> I believe what you call res_type is rather actually term_type and
>>>> this function doesnt take "auto", only "N" and "C". So I am afraid
>>>> you have to specify yourself which end you want to add.
>>>> 
>>>> HTH,
>>>> 
>>>> B
>>>> 
>>>> On 28/04/2014 21:33, Oliver Clarke wrote:
>>>>> Hi all,
>>>>> 
>>>>> I’ve used the add_terminal_residue_using_phi_psi function to make
>>>>> a little shortcut to force Coot to add a terminal residue (code
>>>>> below), which I can then refine into the density (sometimes Coot
>>>>> cannot find an acceptable position for a terminal residue, when I
>>>>> can clearly see appropriate density).
>>>>> 
>>>>> It works fine, except that there seems to be a bug in
>>>>> add_terminal_residue_using_phi_psi - it always adds the new
>>>>> residue at the end of the chain, regardless of whether the N-term
>>>>> or C-term residue is clicked, and it also adds after the TER flag
>>>>> if present. This means that I can’t use this to add residues to
>>>>> the N-term, as Coot will not recognize that the adjacent residues
>>>>> are linked if they are not adjacent in the file. Thoughts?
>>>>> 
>>>>> Oli.
>>>>> 
>>>>> #Force addition of residue - useful when #Coot says "No
>>>>> acceptable position found" # but density is clear. def
>>>>> force_add_terminal_residue(): def force_addition(res1):
>>>>> mol_id=res1[1] ch_id=res1[2] res_no=res1[3] res_type="auto"
>>>>> add_terminal_residue_using_phi_psi(mol_id,ch_id,res_no,
>>>>> res_type,-64,-41) user_defined_click(1,force_addition)
>>>>> add_simple_coot_menu_menuitem(menu, "Forced addition of terminal
>>>>> residue (click terminus)", lambda func:
>>>>> force_add_terminal_residue())
>>>>> 
>>>> 
>>>> -- ***************************************************
>>>> 
>>>> Dr. Bernhard Lohkamp Associate Professor/Docent Div. Molecular
>>>> Structural Biology Dept. of Medical Biochemistry and Biophysics
>>>> (MBB) Karolinska Institutet S-17177 Stockholm Sweden
>>>> 
>>>> phone: (+46) 08-52487651 fax:   (+46) 08-327626 email:
>>>> bernhard.lohk...@ki.se
>> 
>> -- 
>> ***************************************************
>> 
>> Dr. Bernhard Lohkamp
>> Associate Professor/Docent
>> Div. Molecular Structural Biology
>> Dept. of Medical Biochemistry and Biophysics (MBB)
>> Karolinska Institutet
>> S-17177 Stockholm
>> Sweden
>> 
>> phone: (+46) 08-52487651
>> fax:   (+46) 08-327626
>> email: bernhard.lohk...@ki.se
> 

Reply via email to