示例#1
0
  def __init__(self,map_data,unit_cell,label,site_cart_1,site_cart_2,step=0.005):
    x1,y1,z1 = site_cart_1
    x2,y2,z2 = site_cart_2
    self.one_dim_point  = None
    self.peak_value     = None
    self.peak_site_cart = None
    self.status = None
    self.bond_length = math.sqrt((x1-x2)**2+(y1-y2)**2+(z1-z2)**2)
    alp = 0
    self.data = flex.double()
    self.dist = flex.double()
    self.peak_sites = flex.vec3_double()
    i_seq = 0
    while alp <= 1.0+1.e-6:
      xp = x1+alp*(x2-x1)
      yp = y1+alp*(y2-y1)
      zp = z1+alp*(z2-z1)
      site_frac = unit_cell.fractionalize((xp,yp,zp))
      ed_ = maptbx.eight_point_interpolation(map_data, site_frac)
      self.dist.append( math.sqrt((x1-xp)**2+(y1-yp)**2+(z1-zp)**2) )
      self.data.append(ed_)
      self.peak_sites.append(unit_cell.orthogonalize(site_frac))
      alp += step
      i_seq += 1
    i_seq_left, i_seq_right, max_peak_i_seq = self.find_peak()
    self.b_estimated, self.q_estimated = None, None
    self.a, self.b = None, None
    self.peak_data, self.peak_dist = None, None
    if([i_seq_left, i_seq_right].count(None) == 0):
      self.one_dim_point  = self.dist[max_peak_i_seq]
      self.peak_value     = self.data[max_peak_i_seq]
      self.peak_site_cart = self.peak_sites[max_peak_i_seq]
      self.peak_data = self.data[i_seq_left:i_seq_right+1]
      self.peak_dist = self.dist[i_seq_left:i_seq_right+1]
      assert (self.peak_data < 0.0).count(True) == 0
      origin = self.dist[max_peak_i_seq]

      dist = (self.peak_dist - origin).deep_copy()
      sel = self.peak_data > 0.0
      data = self.peak_data.select(sel)
      dist = dist.select(sel)
      if(data.size() > 0):
         approx_obj = maptbx.one_gaussian_peak_approximation(
                                                data_at_grid_points    = data,
                                                distances              = dist,
                                                use_weights            = False,
                                                optimize_cutoff_radius = False)
         a_real = approx_obj.a_real_space()
         b_real = approx_obj.b_real_space()
         gof = approx_obj.gof()
         self.a = ias_scattering_dict[label].array_of_a()[0]
         self.b = ias_scattering_dict[label].array_of_b()[0]
         self.b_estimated = approx_obj.b_reciprocal_space()-self.b
         self.q_estimated = approx_obj.a_reciprocal_space()/self.a
         #print "%.2f %.2f"%(self.q_estimated, self.b_estimated)
         if(self.b_estimated <= 0.0):
            self.b_estimated = self.b
         if(self.q_estimated <= 0.0):
            self.q_estimated = self.a
    self.set_status()
示例#2
0
def exercise_1(grid_step,
               radius,
               shell,
               a,
               b,
               buffer_layer,
               site_cart):
  xray_structure = xray_structure_of_one_atom(site_cart    = site_cart,
                                              buffer_layer = buffer_layer,
                                              a            = a,
                                              b            = b)
  sampled_density = mmtbx.real_space.sampled_model_density(
                                            xray_structure = xray_structure,
                                            grid_step      = grid_step)
  site_frac = xray_structure.unit_cell().fractionalization_matrix()*site_cart
  assert approx_equal(flex.max(sampled_density.data()),
              sampled_density.data().value_at_closest_grid_point(site_frac[0]))

  around_atom_obj = mmtbx.real_space.around_atom(
                           unit_cell = xray_structure.unit_cell(),
                           map_data  = sampled_density.data(),
                           radius    = radius,
                           shell     = shell,
                           site_frac = list(xray_structure.sites_frac())[0])
  data_exact = around_atom_obj.data()
  dist_exact = around_atom_obj.distances()
  approx_obj = maptbx.one_gaussian_peak_approximation(
                                           data_at_grid_points    = data_exact,
                                           distances              = dist_exact,
                                           use_weights            = False,
                                           optimize_cutoff_radius = True)
  assert approx_equal(approx_obj.a_reciprocal_space(), 6.0, 1.e-3)
  assert approx_equal(approx_obj.b_reciprocal_space(), 3.0, 1.e-3)
  assert approx_obj.gof() < 0.3
  assert approx_obj.cutoff_radius() < radius
示例#3
0
def exercise_1(grid_step,
               radius,
               shell,
               a,
               b,
               buffer_layer,
               site_cart):
  xray_structure = xray_structure_of_one_atom(site_cart    = site_cart,
                                              buffer_layer = buffer_layer,
                                              a            = a,
                                              b            = b)
  sampled_density = mmtbx.real_space.sampled_model_density(
                                            xray_structure = xray_structure,
                                            grid_step      = grid_step)
  site_frac = xray_structure.unit_cell().fractionalization_matrix()*site_cart
  assert approx_equal(flex.max(sampled_density.data()),
              sampled_density.data().value_at_closest_grid_point(site_frac[0]))

  around_atom_obj = mmtbx.real_space.around_atom(
                           unit_cell = xray_structure.unit_cell(),
                           map_data  = sampled_density.data(),
                           radius    = radius,
                           shell     = shell,
                           site_frac = list(xray_structure.sites_frac())[0])
  data_exact = around_atom_obj.data()
  dist_exact = around_atom_obj.distances()
  approx_obj = maptbx.one_gaussian_peak_approximation(
                                           data_at_grid_points    = data_exact,
                                           distances              = dist_exact,
                                           use_weights            = False,
                                           optimize_cutoff_radius = True)
  assert approx_equal(approx_obj.a_reciprocal_space(), 6.0, 1.e-3)
  assert approx_equal(approx_obj.b_reciprocal_space(), 3.0, 1.e-3)
  assert approx_obj.gof() < 0.3
  assert approx_obj.cutoff_radius() < radius
示例#4
0
  def __init__(self,map_data,unit_cell,label,site_cart_1,site_cart_2,step=0.005):
    x1,y1,z1 = site_cart_1
    x2,y2,z2 = site_cart_2
    self.one_dim_point  = None
    self.peak_value     = None
    self.peak_site_cart = None
    self.status = None
    self.bond_length = math.sqrt((x1-x2)**2+(y1-y2)**2+(z1-z2)**2)
    alp = 0
    self.data = flex.double()
    self.dist = flex.double()
    self.peak_sites = flex.vec3_double()
    i_seq = 0
    while alp <= 1.0+1.e-6:
      xp = x1+alp*(x2-x1)
      yp = y1+alp*(y2-y1)
      zp = z1+alp*(z2-z1)
      site_frac = unit_cell.fractionalize((xp,yp,zp))
      ed_ = maptbx.eight_point_interpolation(map_data, site_frac)
      self.dist.append( math.sqrt((x1-xp)**2+(y1-yp)**2+(z1-zp)**2) )
      self.data.append(ed_)
      self.peak_sites.append(unit_cell.orthogonalize(site_frac))
      alp += step
      i_seq += 1
    i_seq_left, i_seq_right, max_peak_i_seq = self.find_peak()
    self.b_estimated, self.q_estimated = None, None
    self.a, self.b = None, None
    self.peak_data, self.peak_dist = None, None
    if([i_seq_left, i_seq_right].count(None) == 0):
      self.one_dim_point  = self.dist[max_peak_i_seq]
      self.peak_value     = self.data[max_peak_i_seq]
      self.peak_site_cart = self.peak_sites[max_peak_i_seq]
      self.peak_data = self.data[i_seq_left:i_seq_right+1]
      self.peak_dist = self.dist[i_seq_left:i_seq_right+1]
      assert (self.peak_data < 0.0).count(True) == 0
      origin = self.dist[max_peak_i_seq]

      dist = (self.peak_dist - origin).deep_copy()
      sel = self.peak_data > 0.0
      data = self.peak_data.select(sel)
      dist = dist.select(sel)
      if(data.size() > 0):
         approx_obj = maptbx.one_gaussian_peak_approximation(
                                                data_at_grid_points    = data,
                                                distances              = dist,
                                                use_weights            = False,
                                                optimize_cutoff_radius = False)
         a_real = approx_obj.a_real_space()
         b_real = approx_obj.b_real_space()
         gof = approx_obj.gof()
         self.a = ias_scattering_dict[label].array_of_a()[0]
         self.b = ias_scattering_dict[label].array_of_b()[0]
         self.b_estimated = approx_obj.b_reciprocal_space()-self.b
         self.q_estimated = approx_obj.a_reciprocal_space()/self.a
         #print "%.2f %.2f"%(self.q_estimated, self.b_estimated)
         if(self.b_estimated <= 0.0):
            self.b_estimated = self.b
         if(self.q_estimated <= 0.0):
            self.q_estimated = self.a
    self.set_status()
示例#5
0
def exercise_4(grid_step,
               radius,
               shell,
               a,
               b,
               d_min,
               volume_per_atom,
               use_weights,
               optimize_cutoff_radius,
               scatterer_chemical_type = "C"):
  xray_structure = random_structure.xray_structure(
                        space_group_info       = sgtbx.space_group_info("P 1"),
                        elements               = ((scatterer_chemical_type)*1),
                        volume_per_atom        = volume_per_atom,
                        min_distance           = 1.5,
                        general_positions_only = True)
  custom_dict = \
             {scatterer_chemical_type: eltbx.xray_scattering.gaussian([a],[b])}
  xray_structure.scattering_type_registry(custom_dict = custom_dict)
  miller_set = miller.build_set(
                          crystal_symmetry = xray_structure.crystal_symmetry(),
                          anomalous_flag   = False,
                          d_min            = d_min,
                          d_max            = None)
  f_calc = miller_set.structure_factors_from_scatterers(
                                 xray_structure               = xray_structure,
                                 algorithm                    = "direct",
                                 cos_sin_table                = False,
                                 exp_table_one_over_step_size = False).f_calc()
  fft_map = f_calc.fft_map(grid_step = grid_step, symmetry_flags = None)
  fft_map = fft_map.apply_volume_scaling()
  site_frac = xray_structure.sites_frac()
  m = fft_map.real_map_unpadded()
  amm = abs(flex.max(m))
  r = abs(amm-abs(m.value_at_closest_grid_point(site_frac[0]))) / amm
  assert r < 0.15, r
  around_atom_obj_ = mmtbx.real_space.around_atom(
                            unit_cell = xray_structure.unit_cell(),
                            map_data  = fft_map.real_map_unpadded(),
                            radius    = radius,
                            shell     = shell,
                            site_frac = list(xray_structure.sites_frac())[0])
  data = around_atom_obj_.data()
  dist = around_atom_obj_.distances()
  approx_obj_ = maptbx.one_gaussian_peak_approximation(
                               data_at_grid_points    = data,
                               distances              = dist,
                               use_weights            = use_weights,
                               optimize_cutoff_radius = optimize_cutoff_radius)
  assert approx_equal(approx_obj_.a_reciprocal_space(), 6.0, 0.1)
  assert approx_equal(approx_obj_.b_reciprocal_space(), 3.0, 0.1)
  assert approx_obj_.gof() < 1.0
  assert approx_obj_.cutoff_radius() < radius
示例#6
0
def exercise_4(grid_step,
               radius,
               shell,
               a,
               b,
               d_min,
               volume_per_atom,
               use_weights,
               optimize_cutoff_radius,
               scatterer_chemical_type = "C"):
  xray_structure = random_structure.xray_structure(
                        space_group_info       = sgtbx.space_group_info("P 1"),
                        elements               = ((scatterer_chemical_type)*1),
                        volume_per_atom        = volume_per_atom,
                        min_distance           = 1.5,
                        general_positions_only = True)
  custom_dict = \
             {scatterer_chemical_type: eltbx.xray_scattering.gaussian([a],[b])}
  xray_structure.scattering_type_registry(custom_dict = custom_dict)
  miller_set = miller.build_set(
                          crystal_symmetry = xray_structure.crystal_symmetry(),
                          anomalous_flag   = False,
                          d_min            = d_min,
                          d_max            = None)
  f_calc = miller_set.structure_factors_from_scatterers(
                                 xray_structure               = xray_structure,
                                 algorithm                    = "direct",
                                 cos_sin_table                = False,
                                 exp_table_one_over_step_size = False).f_calc()
  fft_map = f_calc.fft_map(grid_step = grid_step, symmetry_flags = None)
  fft_map = fft_map.apply_volume_scaling()
  site_frac = xray_structure.sites_frac()
  m = fft_map.real_map_unpadded()
  amm = abs(flex.max(m))
  r = abs(amm-abs(m.value_at_closest_grid_point(site_frac[0]))) / amm
  assert r < 0.15, r
  around_atom_obj_ = mmtbx.real_space.around_atom(
                            unit_cell = xray_structure.unit_cell(),
                            map_data  = fft_map.real_map_unpadded(),
                            radius    = radius,
                            shell     = shell,
                            site_frac = list(xray_structure.sites_frac())[0])
  data = around_atom_obj_.data()
  dist = around_atom_obj_.distances()
  approx_obj_ = maptbx.one_gaussian_peak_approximation(
                               data_at_grid_points    = data,
                               distances              = dist,
                               use_weights            = use_weights,
                               optimize_cutoff_radius = optimize_cutoff_radius)
  assert approx_equal(approx_obj_.a_reciprocal_space(), 6.0, 0.1)
  assert approx_equal(approx_obj_.b_reciprocal_space(), 3.0, 0.1)
  assert approx_obj_.gof() < 1.0
  assert approx_obj_.cutoff_radius() < radius
示例#7
0
def exercise_3(grid_step,
               radius,
               shell,
               a,
               b,
               d_min,
               site_cart,
               buffer_layer):
  xray_structure = xray_structure_of_one_atom(site_cart    = site_cart,
                                              buffer_layer = buffer_layer,
                                              a            = a,
                                              b            = b)
  miller_set = miller.build_set(
                          crystal_symmetry = xray_structure.crystal_symmetry(),
                          anomalous_flag   = False,
                          d_min            = d_min,
                          d_max            = None)
  f_calc = miller_set.structure_factors_from_scatterers(
                                 xray_structure               = xray_structure,
                                 algorithm                    = "direct",
                                 cos_sin_table                = False,
                                 exp_table_one_over_step_size = False).f_calc()
  fft_map = f_calc.fft_map(grid_step = grid_step, symmetry_flags = None)
  fft_map = fft_map.apply_volume_scaling()
  site_frac = xray_structure.sites_frac()
  r = abs(abs(flex.max(fft_map.real_map_unpadded()))-\
    abs(fft_map.real_map_unpadded().value_at_closest_grid_point(site_frac[0])))/\
    abs(flex.max(fft_map.real_map_unpadded())) * 100.0
  assert approx_equal(r, 0.0)
  around_atom_obj_ = mmtbx.real_space.around_atom(
                            unit_cell = xray_structure.unit_cell(),
                            map_data  = fft_map.real_map_unpadded(),
                            radius    = radius,
                            shell     = shell,
                            site_frac = list(xray_structure.sites_frac())[0])
  data = around_atom_obj_.data()
  dist = around_atom_obj_.distances()
  approx_obj_ = maptbx.one_gaussian_peak_approximation(
                                                data_at_grid_points    = data,
                                                distances              = dist,
                                                use_weights            = False,
                                                optimize_cutoff_radius = True)
  assert approx_equal(approx_obj_.a_reciprocal_space(), 6.0, 0.1)
  assert approx_equal(approx_obj_.b_reciprocal_space(), 3.0, 0.01)
  assert approx_obj_.gof() < 0.6
  assert approx_obj_.cutoff_radius() < radius
示例#8
0
def exercise_3(grid_step,
               radius,
               shell,
               a,
               b,
               d_min,
               site_cart,
               buffer_layer):
  xray_structure = xray_structure_of_one_atom(site_cart    = site_cart,
                                              buffer_layer = buffer_layer,
                                              a            = a,
                                              b            = b)
  miller_set = miller.build_set(
                          crystal_symmetry = xray_structure.crystal_symmetry(),
                          anomalous_flag   = False,
                          d_min            = d_min,
                          d_max            = None)
  f_calc = miller_set.structure_factors_from_scatterers(
                                 xray_structure               = xray_structure,
                                 algorithm                    = "direct",
                                 cos_sin_table                = False,
                                 exp_table_one_over_step_size = False).f_calc()
  fft_map = f_calc.fft_map(grid_step = grid_step, symmetry_flags = None)
  fft_map = fft_map.apply_volume_scaling()
  site_frac = xray_structure.sites_frac()
  r = abs(abs(flex.max(fft_map.real_map_unpadded()))-\
    abs(fft_map.real_map_unpadded().value_at_closest_grid_point(site_frac[0])))/\
    abs(flex.max(fft_map.real_map_unpadded())) * 100.0
  assert approx_equal(r, 0.0)
  around_atom_obj_ = mmtbx.real_space.around_atom(
                            unit_cell = xray_structure.unit_cell(),
                            map_data  = fft_map.real_map_unpadded(),
                            radius    = radius,
                            shell     = shell,
                            site_frac = list(xray_structure.sites_frac())[0])
  data = around_atom_obj_.data()
  dist = around_atom_obj_.distances()
  approx_obj_ = maptbx.one_gaussian_peak_approximation(
                                                data_at_grid_points    = data,
                                                distances              = dist,
                                                use_weights            = False,
                                                optimize_cutoff_radius = True)
  assert approx_equal(approx_obj_.a_reciprocal_space(), 6.0, 0.1)
  assert approx_equal(approx_obj_.b_reciprocal_space(), 3.0, 0.01)
  assert approx_obj_.gof() < 0.6
  assert approx_obj_.cutoff_radius() < radius
示例#9
0
def exercise_2(grid_step,
               radius,
               shell,
               a,
               b,
               volume_per_atom,
               scatterer_chemical_type = "C"):
  xray_structure = random_structure.xray_structure(
                        space_group_info       = sgtbx.space_group_info("P 1"),
                        elements               = ((scatterer_chemical_type)*1),
                        volume_per_atom        = volume_per_atom,
                        min_distance           = 1.5,
                        general_positions_only = True)
  custom_dict = \
             {scatterer_chemical_type: eltbx.xray_scattering.gaussian([a],[b])}
  xray_structure.scattering_type_registry(custom_dict = custom_dict)
  sampled_density = mmtbx.real_space.sampled_model_density(
                                            xray_structure = xray_structure,
                                            grid_step      = grid_step)
  site_frac = xray_structure.sites_frac()
  r = abs(abs(flex.max(sampled_density.data()))-\
      abs(sampled_density.data().value_at_closest_grid_point(site_frac[0])))/\
      abs(flex.max(sampled_density.data())) * 100.0
  assert r < 10.

  around_atom_obj = mmtbx.real_space.around_atom(
                           unit_cell = xray_structure.unit_cell(),
                           map_data  = sampled_density.data(),
                           radius    = radius,
                           shell     = shell,
                           site_frac = list(xray_structure.sites_frac())[0])
  data_exact = around_atom_obj.data()
  dist_exact = around_atom_obj.distances()
  approx_obj = maptbx.one_gaussian_peak_approximation(
                                           data_at_grid_points    = data_exact,
                                           distances              = dist_exact,
                                           use_weights            = False,
                                           optimize_cutoff_radius = True)
  assert approx_equal(approx_obj.a_reciprocal_space(), 6.0, 1.e-2)
  assert approx_equal(approx_obj.b_reciprocal_space(), 3.0, 1.e-2)
  assert approx_obj.gof() < 0.3
  assert approx_obj.cutoff_radius() < radius
示例#10
0
def exercise_2(grid_step,
               radius,
               shell,
               a,
               b,
               volume_per_atom,
               scatterer_chemical_type = "C"):
  xray_structure = random_structure.xray_structure(
                        space_group_info       = sgtbx.space_group_info("P 1"),
                        elements               = ((scatterer_chemical_type)*1),
                        volume_per_atom        = volume_per_atom,
                        min_distance           = 1.5,
                        general_positions_only = True)
  custom_dict = \
             {scatterer_chemical_type: eltbx.xray_scattering.gaussian([a],[b])}
  xray_structure.scattering_type_registry(custom_dict = custom_dict)
  sampled_density = mmtbx.real_space.sampled_model_density(
                                            xray_structure = xray_structure,
                                            grid_step      = grid_step)
  site_frac = xray_structure.sites_frac()
  r = abs(abs(flex.max(sampled_density.data()))-\
      abs(sampled_density.data().value_at_closest_grid_point(site_frac[0])))/\
      abs(flex.max(sampled_density.data())) * 100.0
  assert r < 10.

  around_atom_obj = mmtbx.real_space.around_atom(
                           unit_cell = xray_structure.unit_cell(),
                           map_data  = sampled_density.data(),
                           radius    = radius,
                           shell     = shell,
                           site_frac = list(xray_structure.sites_frac())[0])
  data_exact = around_atom_obj.data()
  dist_exact = around_atom_obj.distances()
  approx_obj = maptbx.one_gaussian_peak_approximation(
                                           data_at_grid_points    = data_exact,
                                           distances              = dist_exact,
                                           use_weights            = False,
                                           optimize_cutoff_radius = True)
  assert approx_equal(approx_obj.a_reciprocal_space(), 6.0, 1.e-2)
  assert approx_equal(approx_obj.b_reciprocal_space(), 3.0, 1.e-2)
  assert approx_obj.gof() < 0.3
  assert approx_obj.cutoff_radius() < radius