def minimize(self):
   utils.assert_xray_structures_equal(
     x1 = self.fmodels.fmodel_xray().xray_structure,
     x2 = self.model.xray_structure)
   self.model.set_refine_individual_adp()
   lbfgs_termination_params = scitbx.lbfgs.termination_parameters(
     max_iterations = self.individual_adp_params.iso.max_number_of_iterations)
   is_neutron_scat_table = False
   if(self.all_params.main.scattering_table == "neutron"):
     is_neutron_scat_table = True
   minimized = minimization.lbfgs(
     restraints_manager       = self.model.restraints_manager,
     fmodels                  = self.fmodels,
     model                    = self.model,
     refine_adp               = True,
     is_neutron_scat_table    = is_neutron_scat_table,
     lbfgs_termination_params = lbfgs_termination_params,
     iso_restraints           = self.adp_restraints_params.iso,
     verbose                  = 0,
     target_weights           = self.target_weights,
     h_params                 = self.h_params)
   self.model.xray_structure = self.fmodels.fmodel_xray().xray_structure
   assert minimized.xray_structure is self.model.xray_structure
   utils.assert_xray_structures_equal(
     x1 = minimized.xray_structure,
     x2 = self.model.xray_structure)
   return minimized
Exemple #2
0
 def minimize(self):
     utils.assert_xray_structures_equal(
         x1=self.fmodels.fmodel_xray().xray_structure,
         x2=self.model.xray_structure)
     self.model.set_refine_individual_adp()
     lbfgs_termination_params = scitbx.lbfgs.termination_parameters(
         max_iterations=self.individual_adp_params.iso.
         max_number_of_iterations)
     is_neutron_scat_table = False
     if (self.all_params.main.scattering_table == "neutron"):
         is_neutron_scat_table = True
     minimized = minimization.lbfgs(
         restraints_manager=self.model.restraints_manager,
         fmodels=self.fmodels,
         model=self.model,
         refine_adp=True,
         is_neutron_scat_table=is_neutron_scat_table,
         lbfgs_termination_params=lbfgs_termination_params,
         iso_restraints=self.adp_restraints_params.iso,
         verbose=0,
         target_weights=self.target_weights,
         h_params=self.h_params)
     self.model.xray_structure = self.fmodels.fmodel_xray().xray_structure
     assert minimized.xray_structure is self.model.xray_structure
     utils.assert_xray_structures_equal(x1=minimized.xray_structure,
                                        x2=self.model.xray_structure)
     return minimized
Exemple #3
0
 def refine_adp(self):
     if (not self.filter_only and self.params.refine_adp
             and self.model.refinement_flags.individual_adp
             and self.model.solvent_selection().count(True) > 0):
         self.fmodels.update_xray_structure(
             xray_structure=self.model.get_xray_structure(),
             update_f_calc=True,
             update_f_mask=True)
         print(
             "ADP refinement (water only), start r_work=%6.4f r_free=%6.4f"
             % (self.fmodel.r_work(), self.fmodel.r_free()),
             file=self.log)
         # set refinement flags (not exercised!)
         hd_sel = self.model.get_hd_selection()
         not_hd_sel = ~hd_sel
         sol_sel = self.model.solvent_selection()
         not_sol_sel = ~sol_sel
         selection_aniso = self.model.get_xray_structure().use_u_aniso(
         ).deep_copy()
         if (self.params.new_solvent == "anisotropic"):
             selection_aniso.set_selected(sol_sel, True)
         selection_iso = self.model.get_xray_structure().use_u_iso(
         ).deep_copy()
         selection_aniso.set_selected(not_sol_sel, False)
         selection_iso.set_selected(not_sol_sel, False)
         if (not self.is_neutron_scat_table):
             selection_aniso.set_selected(hd_sel, False)
             selection_iso.set_selected(hd_sel, False)
         selection_aniso.set_selected(selection_iso, False)
         selection_iso.set_selected(selection_aniso, False)
         self.model.set_refine_individual_adp(
             selection_aniso=selection_aniso, selection_iso=selection_iso)
         lbfgs_termination_params = scitbx.lbfgs.termination_parameters(
             max_iterations=25)
         minimized = minimization.lbfgs(
             restraints_manager=None,
             fmodels=self.fmodels,
             model=self.model,
             is_neutron_scat_table=self.is_neutron_scat_table,
             refine_adp=True,
             lbfgs_termination_params=lbfgs_termination_params)
         print(
             "ADP refinement (water only), final r_work=%6.4f r_free=%6.4f"
             % (self.fmodel.r_work(), self.fmodel.r_free()),
             file=self.log)
 def refine_adp(self):
   if(not self.filter_only and self.params.refine_adp and
      self.model.refinement_flags.individual_adp and
      self.model.solvent_selection().count(True) > 0):
     self.fmodels.update_xray_structure(
        xray_structure = self.model.xray_structure,
        update_f_calc  = True,
        update_f_mask  = True)
     print >> self.log, \
       "ADP refinement (water only), start r_work=%6.4f r_free=%6.4f"%(
       self.fmodel.r_work(), self.fmodel.r_free())
     # set refinement flags (not exercised!)
     hd_sel     = self.model.xray_structure.hd_selection()
     not_hd_sel = ~hd_sel
     sol_sel    = self.model.solvent_selection()
     not_sol_sel= ~sol_sel
     selection_aniso = self.model.xray_structure.use_u_aniso().deep_copy()
     if(self.params.new_solvent == "anisotropic"):
       selection_aniso.set_selected(sol_sel, True)
     selection_iso   = self.model.xray_structure.use_u_iso().deep_copy()
     selection_aniso.set_selected(not_sol_sel, False)
     selection_iso  .set_selected(not_sol_sel, False)
     if(not self.is_neutron_scat_table):
       selection_aniso.set_selected(hd_sel, False)
       selection_iso.set_selected(hd_sel, False)
     selection_aniso.set_selected(selection_iso, False)
     selection_iso.set_selected(selection_aniso, False)
     self.model.set_refine_individual_adp(
       selection_aniso = selection_aniso, selection_iso = selection_iso)
     lbfgs_termination_params = scitbx.lbfgs.termination_parameters(
         max_iterations = 25)
     minimized = minimization.lbfgs(
       restraints_manager       = None,
       fmodels                  = self.fmodels,
       model                    = self.model,
       is_neutron_scat_table    = self.is_neutron_scat_table,
       refine_adp               = True,
       lbfgs_termination_params = lbfgs_termination_params)
     print >> self.log,\
       "ADP refinement (water only), final r_work=%6.4f r_free=%6.4f"%(
       self.fmodel.r_work(), self.fmodel.r_free())
 def run_lbfgs(self):
     if (self.model.get_ncs_groups() is None
             or not self.all_params.ncs.constraints.apply_to_adp):
         lbfgs_termination_params = scitbx.lbfgs.termination_parameters(
             max_iterations=self.individual_adp_params.iso.
             max_number_of_iterations)
         is_neutron_scat_table = False
         if (self.all_params.main.scattering_table == "neutron"):
             is_neutron_scat_table = True
         minimized = minimization.lbfgs(
             restraints_manager=self.model.restraints_manager,
             fmodels=self.fmodels,
             model=self.model,
             refine_adp=True,
             is_neutron_scat_table=is_neutron_scat_table,
             lbfgs_termination_params=lbfgs_termination_params,
             iso_restraints=self.adp_restraints_params.iso,
             verbose=0,
             target_weights=self.target_weights,
             h_params=self.h_params)
     elif (self.all_params.ncs.constraints.apply_to_coordinates):
         fmodel = self.fmodels.fmodel_xray()
         # update NCS groups
         import mmtbx.ncs.ncs_utils as nu
         nu.get_list_of_best_ncs_copy_map_correlation(
             ncs_groups=self.model.get_ncs_groups(), fmodel=fmodel)
         assert "individual_adp" in self.all_params.refine.strategy
         minimized = minimization.run_constrained(
             model=self.model,
             fmodel=fmodel,
             target_weight=self.target_weights.xyz_weights_result.wx,
             log=self.log,
             params=self.all_params,
             refine_u_iso=True,
             prefix="NCS constrained ADP refinement").minimized
         self.model.set_xray_structure(fmodel.xray_structure)
     else:
         raise RuntimeError("Bad ncs options.")
 def run_lbfgs(self):
   if(self.model.ncs_groups is None or
      not self.all_params.ncs.constraints.apply_to_adp):
     lbfgs_termination_params = scitbx.lbfgs.termination_parameters(
       max_iterations = self.individual_adp_params.iso.max_number_of_iterations)
     is_neutron_scat_table = False
     if(self.all_params.main.scattering_table == "neutron"):
       is_neutron_scat_table = True
     minimized = minimization.lbfgs(
       restraints_manager       = self.model.restraints_manager,
       fmodels                  = self.fmodels,
       model                    = self.model,
       refine_adp               = True,
       is_neutron_scat_table    = is_neutron_scat_table,
       lbfgs_termination_params = lbfgs_termination_params,
       iso_restraints           = self.adp_restraints_params.iso,
       verbose                  = 0,
       target_weights           = self.target_weights,
       h_params                 = self.h_params)
   elif(self.all_params.ncs.constraints.apply_to_coordinates):
     fmodel = self.fmodels.fmodel_xray()
     # update NCS groups
     import mmtbx.ncs.ncs_utils as nu
     nu.get_list_of_best_ncs_copy_map_correlation(
       ncs_groups = self.model.ncs_groups,
       fmodel     = fmodel)
     assert "individual_adp" in self.all_params.refine.strategy
     minimized = minimization.run_constrained(
       model         = self.model,
       fmodel        = fmodel,
       target_weight = self.target_weights.xyz_weights_result.wx,
       log           = self.log,
       params        = self.all_params,
       refine_u_iso  = True,
       prefix        = "NCS constrained ADP refinement").minimized
     self.model.xray_structure = fmodel.xray_structure
   else: raise RuntimeError("Bad ncs options.")