Пример #1
0
 def try_den_weight_cartesian(self, grid_pair):
   local_seed = int(self.random_seed+grid_pair[1])
   flex.set_random_seed(value=local_seed)
   random.seed(local_seed)
   self.fmodels.fmodel_xray().xray_structure.replace_scatterers(
     self.save_scatterers_local.deep_copy())
   self.fmodels.update_xray_structure(
     xray_structure = self.fmodels.fmodel_xray().xray_structure,
     update_f_calc  = True)
   utils.assert_xray_structures_equal(
     x1 = self.fmodels.fmodel_xray().xray_structure,
     x2 = self.model.xray_structure)
   gamma_local = grid_pair[0]
   weight_local = grid_pair[1]
   self.model.restraints_manager.geometry.\
       den_manager.gamma = gamma_local
   self.model.restraints_manager.geometry.\
       den_manager.weight = weight_local
   cycle = 0
   self.model.restraints_manager.geometry.\
       den_manager.current_cycle = cycle+1
   num_den_cycles = self.model.restraints_manager.geometry.\
       den_manager.num_cycles
   if self.params.den.optimize and \
      self.nproc != Auto and \
      self.nproc > 1:
     local_log = sys.stdout
   elif self.params.den.optimize and \
        self.nproc == 1:
     if self.verbose:
       local_log = self.log
     else:
       local_log = StringIO()
   else:
     local_log = self.log
   print >> self.log, "  ...trying gamma %f, weight %f" % (
     gamma_local, weight_local)
   while cycle < num_den_cycles:
     print >> local_log, "DEN cycle %s" % (cycle+1)
     r_free = self.fmodels.fmodel_xray().r_free()
     print >> local_log, "rfree at start of SA cycle: %f" % r_free
     simulated_annealing.manager(
       params         = self.params.simulated_annealing,
       target_weights = self.target_weights,
       macro_cycle    = self.macro_cycle,
       h_params       = self.params.hydrogens,
       fmodels        = self.fmodels,
       model          = self.model,
       all_params     = self.params,
       out            = local_log)
     if self.params.den.bulk_solvent_and_scale:
       self.bulk_solvent_and_scale(log=local_log)
     if self.params.den.refine_adp:
       self.adp_refinement(log=local_log)
     self.model.restraints_manager.geometry.update_dihedral_ncs_restraints(
         sites_cart=self.model.xray_structure.sites_cart(),
         pdb_hierarchy=self.model.pdb_hierarchy(sync_with_xray_structure=True),
         log=local_log)
     cycle += 1
     self.model.restraints_manager.geometry.\
         den_manager.current_cycle += 1
     r_free = self.fmodels.fmodel_xray().r_free()
     print >> local_log, "rfree at end of SA cycle: %f" % r_free
   r_free = self.fmodels.fmodel_xray().r_free()
   step_xray_structure = self.fmodels.fmodel_xray().\
     xray_structure.deep_copy_scatterers().scatterers()
   step_eq_distances = self.model.restraints_manager.geometry.\
       den_manager.get_current_eq_distances()
   return (gamma_local,
           weight_local,
           r_free,
           step_xray_structure,
           step_eq_distances)
Пример #2
0
 def try_den_weight_cartesian(self, grid_pair):
   local_seed = int(self.random_seed+grid_pair[1])
   flex.set_random_seed(value=local_seed)
   random.seed(local_seed)
   self.fmodels.fmodel_xray().xray_structure.replace_scatterers(
     self.save_scatterers_local.deep_copy())
   self.fmodels.update_xray_structure(
     xray_structure = self.fmodels.fmodel_xray().xray_structure,
     update_f_calc  = True)
   utils.assert_xray_structures_equal(
     x1 = self.fmodels.fmodel_xray().xray_structure,
     x2 = self.model.get_xray_structure())
   gamma_local = grid_pair[0]
   weight_local = grid_pair[1]
   self.model.restraints_manager.geometry.\
       den_manager.gamma = gamma_local
   self.model.restraints_manager.geometry.\
       den_manager.weight = weight_local
   cycle = 0
   self.model.restraints_manager.geometry.\
       den_manager.current_cycle = cycle+1
   num_den_cycles = self.model.restraints_manager.geometry.\
       den_manager.num_cycles
   if self.params.den.optimize and \
      self.nproc != Auto and \
      self.nproc > 1:
     local_log = sys.stdout
   elif self.params.den.optimize and \
        self.nproc == 1:
     if self.verbose:
       local_log = self.log
     else:
       local_log = StringIO()
   else:
     local_log = self.log
   print >> self.log, "  ...trying gamma %f, weight %f" % (
     gamma_local, weight_local)
   while cycle < num_den_cycles:
     print >> local_log, "DEN cycle %s" % (cycle+1)
     r_free = self.fmodels.fmodel_xray().r_free()
     print >> local_log, "rfree at start of SA cycle: %f" % r_free
     simulated_annealing.manager(
       params         = self.params.simulated_annealing,
       target_weights = self.target_weights,
       macro_cycle    = self.macro_cycle,
       h_params       = self.params.hydrogens,
       fmodels        = self.fmodels,
       model          = self.model,
       all_params     = self.params,
       out            = local_log)
     if self.params.den.bulk_solvent_and_scale:
       self.bulk_solvent_and_scale(log=local_log)
     if self.params.den.refine_adp:
       self.adp_refinement(log=local_log)
     self.model.torsion_ncs_restraints_update(log=local_log)
     cycle += 1
     self.model.restraints_manager.geometry.\
         den_manager.current_cycle += 1
     r_free = self.fmodels.fmodel_xray().r_free()
     print >> local_log, "rfree at end of SA cycle: %f" % r_free
   r_free = self.fmodels.fmodel_xray().r_free()
   step_xray_structure = self.fmodels.fmodel_xray().\
     xray_structure.deep_copy_scatterers().scatterers()
   step_eq_distances = self.model.restraints_manager.geometry.\
       den_manager.get_current_eq_distances()
   return (gamma_local,
           weight_local,
           r_free,
           step_xray_structure,
           step_eq_distances)