コード例 #1
0
 def refine(self, weight, sites_cart=None, xray_structure=None):
   assert xray_structure is not None and [sites_cart,xray_structure].count(None)==1
   self.refined = real_space_target_and_gradients.minimization(
     xray_structure              = xray_structure,
     miller_array                = self.miller_array,
     crystal_gridding            = self.crystal_gridding,
     map_target                  = self.map_target,
     max_iterations              = self.max_iterations,
     min_iterations              = self.min_iterations,
     step                        = self.step,
     real_space_target_weight    = weight,
     restraints_target_weight    = self.restraints_target_weight,
     geometry_restraints_manager = self.geometry_restraints_manager,
     target_type                 = "diff_map")
コード例 #2
0
 def refine(self, weight, sites_cart=None, xray_structure=None):
   assert xray_structure is not None and [sites_cart,xray_structure].count(None)==1
   self.refined = real_space_target_and_gradients.minimization(
     xray_structure              = xray_structure,
     miller_array                = self.miller_array,
     crystal_gridding            = self.crystal_gridding,
     map_target                  = self.map_target,
     max_iterations              = self.max_iterations,
     min_iterations              = self.min_iterations,
     step                        = self.step,
     real_space_target_weight    = weight,
     restraints_target_weight    = self.restraints_target_weight,
     geometry_restraints_manager = self.geometry_restraints_manager,
     target_type                 = "diff_map")
コード例 #3
0
def run():
    def compute_map(xray_structure, d_min=1.5, resolution_factor=1. / 4):
        fc = xray_structure.structure_factors(d_min=d_min).f_calc()
        fft_map = fc.fft_map(resolution_factor=resolution_factor)
        fft_map.apply_sigma_scaling()
        result = fft_map.real_map_unpadded()
        return result, fc, fft_map

    xrs = random_structure.xray_structure(
        space_group_info=sgtbx.space_group_info("P212121"),
        elements=["N", "C", "O", "S", "P"] * 10,
        volume_per_atom=50)
    map_target, tmp, tmp = compute_map(xray_structure=xrs)
    xrs_sh = xrs.deep_copy_scatterers()
    xrs_sh.shake_sites_in_place(mean_distance=0.8)
    start_error = flex.mean(xrs.distances(other=xrs_sh))
    print "Start:", start_error
    map_current, miller_array, crystal_gridding = compute_map(
        xray_structure=xrs_sh)
    for step in [miller_array.d_min() / 4] * 5:
        if (1):
            minimized = real_space_target_and_gradients.minimization(
                xray_structure=xrs_sh,
                miller_array=miller_array,
                crystal_gridding=crystal_gridding,
                map_target=map_target,
                max_iterations=500,
                min_iterations=25,
                step=step,
                geometry_restraints_manager=None,
                target_type="diff_map")
            xrs_sh = minimized.xray_structure
            map_current = minimized.map_current
            final_error = flex.mean(
                xrs.distances(other=minimized.xray_structure))
        if (0):
            minimized = real_space_refinement_simple.lbfgs(
                sites_cart=xrs_sh.sites_cart(),
                density_map=map_target,
                unit_cell=xrs_sh.unit_cell(),
                geometry_restraints_manager=None,
                real_space_gradients_delta=step)
            xrs_sh = xrs_sh.replace_sites_cart(minimized.sites_cart)
            final_error = flex.mean(xrs.distances(other=xrs_sh))

        print "Final:", final_error
    assert approx_equal(start_error, 0.8, 1.e-3)
    assert final_error < 1.e-4
    print "OK"
コード例 #4
0
def run():
  def compute_map(xray_structure, d_min=1.5, resolution_factor=1./4):
    fc = xray_structure.structure_factors(d_min = d_min).f_calc()
    fft_map = fc.fft_map(resolution_factor=resolution_factor)
    fft_map.apply_sigma_scaling()
    result = fft_map.real_map_unpadded()
    return result, fc, fft_map
  xrs = random_structure.xray_structure(
    space_group_info  = sgtbx.space_group_info("P212121"),
    elements          = ["N","C","O","S","P"]*10,
    volume_per_atom   = 50)
  map_target,tmp,tmp = compute_map(xray_structure = xrs)
  xrs_sh = xrs.deep_copy_scatterers()
  xrs_sh.shake_sites_in_place(mean_distance=0.8)
  start_error = flex.mean(xrs.distances(other = xrs_sh))
  print "Start:", start_error
  map_current, miller_array, crystal_gridding = compute_map(
    xray_structure = xrs_sh)
  for step in [miller_array.d_min()/4]*5:
    if(1):
      minimized = real_space_target_and_gradients.minimization(
        xray_structure              = xrs_sh,
        miller_array                = miller_array,
        crystal_gridding            = crystal_gridding,
        map_target                  = map_target,
        max_iterations              = 500,
        min_iterations              = 25,
        step                        = step,
        geometry_restraints_manager = None,
        target_type                 = "diff_map")
      xrs_sh = minimized.xray_structure
      map_current = minimized.map_current
      final_error = flex.mean(xrs.distances(other = minimized.xray_structure))
    if(0):
      minimized = real_space_refinement_simple.lbfgs(
        sites_cart=xrs_sh.sites_cart(),
        density_map=map_target,
        unit_cell=xrs_sh.unit_cell(),
        geometry_restraints_manager=None,
        real_space_gradients_delta=step)
      xrs_sh = xrs_sh.replace_sites_cart(minimized.sites_cart)
      final_error = flex.mean(xrs.distances(other = xrs_sh))

    print "Final:", final_error
  assert approx_equal(start_error, 0.8, 1.e-3)
  assert final_error < 1.e-4
  print "OK"