And here is a more compact/elegant version courtesy of Paul that accomplishes a
similar function in half the code - morphing with a radius decreasing from 12
to 6 Å over an arbitrary number of cycles, using a map initially blurred with a
B-factor of 100, decreasing incrementally to 0 (the original map) over the
course of the procedure:
def is_polymer_chain(imol, ch_id):
return is_protein_chain_qm(imol, ch_id) or is_nucleotide_chain_qm(imol,
ch_id)
def reso_morph(imol, imol_map, n_rounds):
turn_off_backup(imol)
set_refinement_immediate_replacement(1)
for round in range(n_rounds):
f = float(round)/float(rounds)
for ch_id in chain_ids(mol_id):
if is_polymer_chain(mol_id, ch_id):
# play with these numbers
radius = 6 * (2 - f)
sf = 100 * (1 - f)
sharpen_map(imol_map, sf)
morph_fit_chain(imol, ch_id, radius)
# run the script
imol = 0
reso_morph(imol, imol_map, 20)
On Dec 29, 2013, at 4:59 PM, Oliver Clarke <[email protected]> wrote:
> Here is a modified script (incorporating suggestions from Paul) for first
> rigid-body fitting each chain to a map, then optionally morphing each chain
> to fit the map. The map can be blurred during fitting by altering the
> sharpening_factor to a positive value (the map always reverts to it’s
> original state after fitting).
>
> Script:
>
> def is_polymer(mol_id,ch_id):
> a=is_protein_chain_p(mol_id,"%s"%(ch_id))
> b=is_nucleotide_chain_p(mol_id,"%s"%(ch_id))
> if (a==1) or (b==1):
> result=1
> else:
> result=0
> return result
> set_refinement_immediate_replacement(1) #Accept rigid body without prompting.
> mol_id=0 #Which molecule should we modify?
> map_id=imol_refinement_map()
> r1=20
> r2=10
> r3=5
> r1_cycles=10
> r2_cycles=5
> r3_cycles=5
> morph=“N" #Do extensive morph?
> do_rigid=“Y"
> sharpening_factor=100 #Set to 0 for unaltered map; -ve to sharpen, +ve to blur
> if do_rigid=="Y":
> turn_off_backup(mol_id)
> sharpen(map_id,sharpening_factor) #Sharpen (or blur) map before fitting
> for ch_id in chain_ids(mol_id): #Rigid body refine each chain first.
> if is_polymer(mol_id,ch_id)==1:
> rigid_body_refine_by_atom_selection(mol_id,
> "//%s//"%(ch_id))
> accept_regularizement()
> sharpen(map_id,0) #Return map to normal
> if morph=="Y": #Sequential morph_chain at three radii.
> turn_off_backup(mol_id)
> sharpen(map_id,sharpening_factor)
> for ch_id in chain_ids(mol_id):
> if is_polymer(mol_id,ch_id)==1:
> 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)
> sharpen(map_id,0)
> set_refinement_immediate_replacement(0) #Return to default behavior.
>
> On Dec 29, 2013, at 4:19 PM, Paul Emsley <[email protected]> wrote:
>
>> On 29/12/13 14:51, Oliver Clarke 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 Å.
>>
>> Yes... that will help somewhat, I imagine. But I suspect an unsharpened map
>> is what you (also) want.
>>
>>>
>>> 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?
>>
>> Yes.
>>
>> sharpen(imol, 200) # blurs
>>
>> and
>>
>> sharpen(imol, 0) # restores
>>
>> You can see from that, that the argument is by how much the original data
>> should be sharpened.
>>
>>>
>>> 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?
>>
>> Yes.
>>
>> turn_off_backups(imol)
>>
>> I routinely do this for looped functions. You might like to try the
>> with_no_backups() macro/function.
>>
>>> 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.
>>
>> Probably.
>>
>> As an aside, you might want to adjust these settings in your ~/.coot.py file:
>>
>> clear_out_backup_run_n_days = 7 # run every 7 days
>> clear_out_backup_old_days = 7 # Files older than 7 days are considered
>> for deletion
>>
>>
>> Paul.
>>
>>
>