Beispiel #1
0
 def refine(self,
            selection,
            optimize_weight = True,
            start_trial_weight_value = 50,
            selection_buffer_radius=5,
            box_cushion=2,
            rms_bonds_limit = 0.03,
            rms_angles_limit = 3.0):
   if(self.ncs_groups is None or len(self.ncs_groups)==0): # no NCS constraints
     sites_cart_moving = self.sites_cart
     selection_within = self.xray_structure.selection_within(
       radius    = selection_buffer_radius,
       selection = selection)
     sel = selection.select(selection_within)
     iselection = flex.size_t()
     for i, state in enumerate(selection):
       if state:
         iselection.append(i)
     box = utils.extract_box_around_model_and_map(
       xray_structure = self.xray_structure,
       map_data       = self.target_map,
       selection      = selection_within,
       box_cushion    = box_cushion)
     new_unit_cell = box.xray_structure_box.unit_cell()
     geo_box = self.geometry_restraints_manager.select(box.selection)
     geo_box = geo_box.discard_symmetry(new_unit_cell=new_unit_cell)
     geo_box.remove_reference_coordinate_restraints_in_place() # disaster happens otherwise
     map_box = box.map_box
     sites_cart_box = box.xray_structure_box.sites_cart()
     rsr_simple_refiner = simple(
       target_map                  = map_box,
       selection                   = sel,
       real_space_gradients_delta  = self.real_space_gradients_delta,
       max_iterations              = self.max_iterations,
       geometry_restraints_manager = geo_box,
       gradients_method            = self.gradients_method)
     real_space_result = refinery(
       refiner                  = rsr_simple_refiner,
       xray_structure           = box.xray_structure_box,
       optimize_weight          = optimize_weight,
       start_trial_weight_value = start_trial_weight_value,
       rms_bonds_limit = rms_bonds_limit,
       rms_angles_limit = rms_angles_limit)
     self.weight_optimal = real_space_result.weight_final
     sites_cart_box_refined = real_space_result.sites_cart_result
     shift_back = [-box.shift_cart[i] for i in xrange(3)]
     sites_cart_box_refined_shifted_back = \
       sites_cart_box_refined + shift_back # Sure + not - ?
     sites_cart_refined = sites_cart_box_refined_shifted_back.select(sel)
     sites_cart_moving = sites_cart_moving.set_selected(
       iselection, sites_cart_refined)
     self.xray_structure.set_sites_cart(sites_cart_moving)
     self.sites_cart = self.xray_structure.sites_cart()
   else: # NCS constraints are present
     # select on xrs, grm, ncs_groups
     grm = self.geometry_restraints_manager.select(selection)
     xrs = self.xray_structure.select(selection)
     sel = flex.bool(xrs.scatterers().size(), True)
     size = self.xray_structure.scatterers().size()
     ncs_groups_ = self.ncs_groups.select(selection=selection)
     #
     rsr_simple_refiner = simple(
       target_map                  = self.target_map,
       selection                   = sel,
       real_space_gradients_delta  = self.real_space_gradients_delta,
       max_iterations              = self.max_iterations,
       geometry_restraints_manager = grm,
       ncs_groups                  = ncs_groups_)
     real_space_result = refinery(
       refiner                  = rsr_simple_refiner,
       xray_structure           = xrs,
       optimize_weight          = optimize_weight,
       start_trial_weight_value = start_trial_weight_value,
       rms_bonds_limit          = rms_bonds_limit,
       rms_angles_limit         = rms_angles_limit)
     self.weight_optimal = real_space_result.weight_final
 def refine(self,
            selection,
            optimize_weight = True,
            start_trial_weight_value = 50,
            selection_buffer_radius=5,
            box_cushion=2,
            rms_bonds_limit = 0.03,
            rms_angles_limit = 3.0):
   if(self.ncs_groups is None): # no NCS constraints
     sites_cart_moving = self.sites_cart
     selection_within = self.xray_structure.selection_within(
       radius    = selection_buffer_radius,
       selection = selection)
     sel = selection.select(selection_within)
     iselection = flex.size_t()
     for i, state in enumerate(selection):
       if state:
         iselection.append(i)
     box = utils.extract_box_around_model_and_map(
       xray_structure = self.xray_structure,
       map_data       = self.target_map,
       selection      = selection_within,
       box_cushion    = box_cushion)
     new_unit_cell = box.xray_structure_box.unit_cell()
     geo_box = self.geometry_restraints_manager.select(box.selection)
     geo_box = geo_box.discard_symmetry(new_unit_cell=new_unit_cell)
     geo_box.remove_reference_coordinate_restraints_in_place() # disaster happens otherwise
     map_box = box.map_box
     sites_cart_box = box.xray_structure_box.sites_cart()
     rsr_simple_refiner = simple(
       target_map                  = map_box,
       selection                   = sel,
       real_space_gradients_delta  = self.real_space_gradients_delta,
       max_iterations              = self.max_iterations,
       geometry_restraints_manager = geo_box)
     real_space_result = refinery(
       refiner                  = rsr_simple_refiner,
       xray_structure           = box.xray_structure_box,
       optimize_weight          = optimize_weight,
       start_trial_weight_value = start_trial_weight_value,
       rms_bonds_limit = rms_bonds_limit,
       rms_angles_limit = rms_angles_limit)
     self.weight_optimal = real_space_result.weight_final
     sites_cart_box_refined = real_space_result.sites_cart_result
     sites_cart_box_refined_shifted_back = \
       sites_cart_box_refined + box.shift_to_map_boxed_sites_back
     sites_cart_refined = sites_cart_box_refined_shifted_back.select(sel)
     sites_cart_moving = sites_cart_moving.set_selected(
       iselection, sites_cart_refined)
     self.xray_structure.set_sites_cart(sites_cart_moving)
     self.sites_cart = self.xray_structure.sites_cart()
   else: # NCS constraints are present
     # select on xrs, grm, ncs_groups
     grm = self.geometry_restraints_manager.select(selection)
     xrs = self.xray_structure.select(selection)
     sel = flex.bool(xrs.scatterers().size(), True)
     size = self.xray_structure.scatterers().size()
     ncs_groups_ = ncs_utils.ncs_groups_selection(
       ncs_restraints_group_list = self.ncs_groups,
       selection                 = selection)
     #
     rsr_simple_refiner = simple(
       target_map                  = self.target_map,
       selection                   = sel,
       real_space_gradients_delta  = self.real_space_gradients_delta,
       max_iterations              = self.max_iterations,
       geometry_restraints_manager = grm,
       ncs_groups                  = ncs_groups_)
     real_space_result = refinery(
       refiner                  = rsr_simple_refiner,
       xray_structure           = xrs,
       optimize_weight          = optimize_weight,
       start_trial_weight_value = start_trial_weight_value,
       rms_bonds_limit          = rms_bonds_limit,
       rms_angles_limit         = rms_angles_limit)
     self.weight_optimal = real_space_result.weight_final