As it turns out, there is indeed such a function (thanks Paul!) - 
seqnum_from_serial_number(), which takes the molecule, chain id and serial 
number (where the serial number is a sequential id for each residue in a chain, 
starting at 0). And there is another function, chain_n_residues() which will 
give the number of residues in a chain.

So we can make functions to get the first and last residues of an all-protein  
chain pretty easily, something like:

def first_residue(mol_id,ch_id):
        result=seqnum_from_serial_number(mol_id,"%s"%(ch_id),0)
        return result
def last_residue(mol_id,ch_id):
        n=chain_n_residues(ch_id,mol_id)-1
        result=seqnum_from_serial_number(mol_id,"%s"%(ch_id),n)
        return result

Unfortunately this doesn’t work as well when solvent molecules are present in 
the same chain as the protein, as they will be counted by chain_n_residues.

Oliver.
On Dec 29, 2013, at 1:56 PM, Oliver Clarke <[email protected]> wrote:

> Also - apologies for all the questions - is there any way to easily get the 
> first and last residue of a given chain from the scripting interface? 
> 
> This would be handy for scripting using functions that take a residue range 
> where one might want to apply the function to an entire arbitrary chain (e.g. 
> fit_residue_range_to_map_by_simplex or score_residue_range_fit_to_map).
> 
> Cheers,
> Oliver.
> 
> 
> On Dec 29, 2013, at 1:34 PM, Oliver Clarke <[email protected]> wrote:
> 
>> Maybe something like this - where by default it just does a rigid body, but 
>> if morph is set to “Y” it does a more extensive morph at three different 
>> radii:
>> 
>> set_refinement_immediate_replacement(1) #Accept rigid body without prompting.
>> mol_id=13 #Which molecule should we modify?
>> r1=20
>> r2=10
>> r3=5
>> r1_cycles=10
>> r2_cycles=5
>> r3_cycles=5
>> morph="N" #Do extensive morph?
>> do_rigid="Y"
>> if do_rigid=="Y":
>>       for ch_id in chain_ids(mol_id): #Rigid body refine each chain first.
>>               rigid_body_refine_by_atom_selection(mol_id, "//%s//"%(ch_id))
>>               accept_regularizement()
>> if morph=="Y": #Sequential morph_chain at three radii.
>>       for ch_id in chain_ids(mol_id):
>>               for n1 in range(1,r1_cycles):
>>                       morph_fit_chain(mol_id, "%s"%(ch_id), r1)
>>               for n2 in range(1,r2_cycles):
>>                       morph_fit_chain(mol_id, "%s"%(ch_id), r2)
>>               for n3 in range(1,r3_cycles):
>>                       morph_fit_chain(mol_id, "%s"%(ch_id), r3)
>> set_refinement_immediate_replacement(0) #Return to default behavior.
>> 
>> 
>> On Dec 29, 2013, at 9:51 AM, Oliver Clarke <[email protected]> wrote:
>> 
>>> Thanks Paul - Initially I tried rigid body + 10 cycles of morph_fit_chain 
>>> at a radius of 11 Å - that seemed to work better than rigid body alone, 
>>> although some of the larger domain shifts are still not corrected. 
>>> 
>>> Perhaps I need a larger radius for that - I’ll try doing 10 cycles at a 
>>> radius of 20 Å, followed by 5 each at 10 Å and 5 Å. 
>>> 
>>> Regarding blurred maps, is there any way to adjust the sharpening factor on 
>>> the fly in a script, in such a manner that it can be returned to normal 
>>> afterwards?
>>> 
>>> Also, Coot seems to write out a copy of the pdb to the coot-backup 
>>> directory after every cycle of morph_chain - is there any way to turn off 
>>> this behavior? Normally it would be fine, but with a few hundred operations 
>>> that adds up to several GB of backup files, which probably slows down the 
>>> whole process somewhat.
>>> 
>>> Cheers,
>>> Oliver.
>>> On Dec 29, 2013, at 6:21 AM, Paul Emsley <[email protected]> wrote:
>>> 
>>>> On 29/12/13 02:51, Oliver Clarke wrote:
>>>>> 
>>>>> 
>>>>> I agree that normally rigid body refinement of each chain wouldn’t be 
>>>>> very useful - I’m using this script in a situation where we have a large 
>>>>> complex of many subunits that we need to fit to a quite low-resolution 
>>>>> map (of a related complex from another species),
>>>> 
>>>> Sounds familiar :-)  (... as may be apparent at the Study Weekend).
>>>> 
>>>>> and an initial round of rigid body fitting seemed to be helpful on 
>>>>> individual chains but was quite laborious when performed manually for 
>>>>> each chain.
>>>> 
>>>> Eeek. Yes...
>>>> 
>>>> Also consider Jiggle Fit.
>>>> 
>>>>> This script seemed to help with that, and I was adding morph_fit_chain in 
>>>>> the hope that it would correct errors in the curvature of helices, or the 
>>>>> orientation of two domains within a multi-domain protein.
>>>> 
>>>> OK, for the orientation of domains you need a larger radius, performed on 
>>>> the chain.  For the curvature of helices you need (I would imagine) a 
>>>> smaller radius performed on a residue selection.
>>>> 
>>>>> 
>>>>> Yes, that was the problem - It works when I replace chain_id with ch_id.
>>>>> 
>>>> 
>>>> good.
>>>> 
>>>>> So you would suggest calling morph_chain several times in succession?
>>>> 
>>>> Definitely.  That and the residue selection version.
>>>> 
>>>>> That makes sense, because the modifications from one round were quite 
>>>>> subtle. I’ll give it a go with 5-10 rounds and see how it works.
>>>>> 
>>>>> 
>>>> 
>>>> Also, I found that fitting into blurred maps at the early stages (large 
>>>> radius) was beneficial.
>>>> 
>>>> It is not yet clear to me what's the best relationship of the round 
>>>> number, resolution, and the radii.
>>>> 
>>>> Paul.
>>>> 
>>>> 
>>>> <morph-residues-gui.scm>
>>> 
>> 
> 

Reply via email to