Example #1
0
 def __init__(self, crystal_symmetry, symmetry_flags):
     self.cb_op_original_to_sampling = crystal_symmetry \
       .change_of_basis_op_to_reference_setting()
     point_group_type = crystal_symmetry.space_group().point_group_type()
     add_cb_op = {"2": "z,x,y", "m": "y,z,x"}.get(point_group_type, None)
     if (add_cb_op is not None):
         self.cb_op_original_to_sampling = sgtbx.change_of_basis_op(add_cb_op) \
                                         * self.cb_op_original_to_sampling
     sampling_symmetry = crystal_symmetry.change_basis(
         self.cb_op_original_to_sampling)
     search_symmetry = sgtbx.search_symmetry(
         flags=symmetry_flags,
         space_group_type=sampling_symmetry.space_group_info().type(),
         seminvariant=sampling_symmetry.space_group_info(
         ).structure_seminvariants())
     expanded_symmetry = crystal.symmetry(
         unit_cell=sampling_symmetry.unit_cell(),
         space_group=search_symmetry.projected_subgroup())
     self.rational_asu = expanded_symmetry.space_group_info(
     ).direct_space_asu()
     self.rational_asu.add_planes(
         normal_directions=search_symmetry.continuous_shifts(),
         both_directions=True)
     self.float_asu = self.rational_asu.define_metric(
         unit_cell=expanded_symmetry.unit_cell()).as_float_asu()
     self.continuous_shift_flags = search_symmetry.continuous_shift_flags()
Example #2
0
 def __init__(self, crystal_symmetry, symmetry_flags):
   self.cb_op_original_to_sampling = crystal_symmetry \
     .change_of_basis_op_to_reference_setting()
   point_group_type = crystal_symmetry.space_group().point_group_type()
   add_cb_op = {"2": "z,x,y",
                "m": "y,z,x"}.get(point_group_type, None)
   if (add_cb_op is not None):
     self.cb_op_original_to_sampling = sgtbx.change_of_basis_op(add_cb_op) \
                                     * self.cb_op_original_to_sampling
   sampling_symmetry = crystal_symmetry.change_basis(
     self.cb_op_original_to_sampling)
   search_symmetry = sgtbx.search_symmetry(
     flags=symmetry_flags,
     space_group_type=sampling_symmetry.space_group_info().type(),
     seminvariant=sampling_symmetry.space_group_info()
       .structure_seminvariants())
   expanded_symmetry = crystal.symmetry(
     unit_cell=sampling_symmetry.unit_cell(),
     space_group=search_symmetry.projected_subgroup())
   self.rational_asu = expanded_symmetry.space_group_info().direct_space_asu()
   self.rational_asu.add_planes(
     normal_directions=search_symmetry.continuous_shifts(),
     both_directions=True)
   self.float_asu=self.rational_asu.define_metric(
     unit_cell=expanded_symmetry.unit_cell()).as_float_asu()
   self.continuous_shift_flags=search_symmetry.continuous_shift_flags()
 def __init__(self, space_group_info, use_k2l, use_l2n):
     adopt_init_args(self, locals())
     search_symmetry = sgtbx.search_symmetry(
         flags=sgtbx.search_symmetry_flags(use_space_group_symmetry=False,
                                           use_space_group_ltr=-1,
                                           use_seminvariants=True,
                                           use_normalizer_k2l=use_k2l,
                                           use_normalizer_l2n=use_l2n),
         space_group_type=space_group_info.type(),
         seminvariant=space_group_info.structure_seminvariants())
     self.rt_mx = search_symmetry.subgroup()
     self.continuous_shifts = search_symmetry.continuous_shifts()
     assert search_symmetry.continuous_shifts_are_principal()
     self.continuous_shift_flags = search_symmetry.continuous_shift_flags()
 def __init__(self, space_group_info, use_k2l, use_l2n):
   adopt_init_args(self, locals())
   search_symmetry = sgtbx.search_symmetry(
     flags=sgtbx.search_symmetry_flags(
       use_space_group_symmetry=False,
       use_space_group_ltr=-1,
       use_seminvariants=True,
       use_normalizer_k2l=use_k2l,
       use_normalizer_l2n=use_l2n),
     space_group_type=space_group_info.type(),
     seminvariant=space_group_info.structure_seminvariants())
   self.rt_mx = search_symmetry.subgroup()
   self.continuous_shifts = search_symmetry.continuous_shifts()
   assert search_symmetry.continuous_shifts_are_principal()
   self.continuous_shift_flags = search_symmetry.continuous_shift_flags()
Example #5
0
def check_with_grid_tags(inp_symmetry, symmetry_flags, sites_cart,
                         point_distance, strictly_inside, flag_write_pdb,
                         verbose):
    cb_op_inp_ref = inp_symmetry.change_of_basis_op_to_reference_setting()
    if (verbose):
        print("cb_op_inp_ref.c():", cb_op_inp_ref.c())
    ref_symmetry = inp_symmetry.change_basis(cb_op_inp_ref)
    search_symmetry = sgtbx.search_symmetry(
        flags=symmetry_flags,
        space_group_type=ref_symmetry.space_group_info().type(),
        seminvariant=ref_symmetry.space_group_info().structure_seminvariants())
    assert search_symmetry.continuous_shifts_are_principal()
    continuous_shift_flags = search_symmetry.continuous_shift_flags()
    if (flag_write_pdb):
        tag_sites_frac = flex.vec3_double()
    else:
        tag_sites_frac = None
    if (strictly_inside):
        inp_tags = inp_symmetry.gridding(step=point_distance * .7,
                                         symmetry_flags=symmetry_flags).tags()
        if (tag_sites_frac is not None):
            for point in flex.nested_loop(inp_tags.n_real()):
                if (inp_tags.tags().tag_array()[point] < 0):
                    point_frac_inp = [
                        float(n) / d for n, d in zip(point, inp_tags.n_real())
                    ]
                    tag_sites_frac.append(point_frac_inp)
        if (inp_tags.tags().n_independent() < sites_cart.size()):
            print("FAIL:", inp_symmetry.space_group_info(), \
                           inp_tags.tags().n_independent(), sites_cart.size())
            raise AssertionError
    else:
        inp_tags = inp_symmetry.gridding(step=point_distance / 2.,
                                         symmetry_flags=symmetry_flags).tags()
        sites_frac_inp = inp_symmetry.unit_cell().fractionalize(
            sites_cart=sites_cart)
        rt = cb_op_inp_ref.c().as_double_array()
        sites_frac_ref = rt[:9] * sites_frac_inp
        sites_frac_ref += rt[9:]
        max_distance = 2 * ((.5 * math.sqrt(3) * point_distance) * 2 / 3.)
        if (verbose):
            print("max_distance:", max_distance)
        for point in flex.nested_loop(inp_tags.n_real()):
            if (inp_tags.tags().tag_array()[point] < 0):
                point_frac_inp = [
                    float(n) / d for n, d in zip(point, inp_tags.n_real())
                ]
                if (tag_sites_frac is not None):
                    tag_sites_frac.append(point_frac_inp)
                point_frac_ref = cb_op_inp_ref.c() * point_frac_inp
                equiv_points = sgtbx.sym_equiv_sites(
                    unit_cell=ref_symmetry.unit_cell(),
                    space_group=search_symmetry.subgroup(),
                    original_site=point_frac_ref,
                    minimum_distance=2.e-6,
                    tolerance=1.e-6)
                min_dist = sgtbx.min_sym_equiv_distance_info(
                    reference_sites=equiv_points,
                    others=sites_frac_ref,
                    principal_continuous_allowed_origin_shift_flags=
                    continuous_shift_flags).dist()
                if (min_dist > max_distance):
                    print("FAIL:", inp_symmetry.space_group_info(), \
                                   point_frac_ref, min_dist)
                    raise AssertionError
        if (inp_tags.tags().n_independent() + 10 < sites_cart.size()):
            print("FAIL:", inp_symmetry.space_group_info(), \
                           inp_tags.tags().n_independent(), sites_cart.size())
            raise AssertionError
    if (tag_sites_frac is not None):
        dump_pdb(file_name="tag_sites.pdb",
                 crystal_symmetry=inp_symmetry,
                 sites_cart=inp_symmetry.unit_cell().orthogonalize(
                     sites_frac=tag_sites_frac))
def check_with_grid_tags(inp_symmetry, symmetry_flags,
                         sites_cart, point_distance,
                         strictly_inside, flag_write_pdb, verbose):
  cb_op_inp_ref = inp_symmetry.change_of_basis_op_to_reference_setting()
  if (verbose):
    print "cb_op_inp_ref.c():", cb_op_inp_ref.c()
  ref_symmetry = inp_symmetry.change_basis(cb_op_inp_ref)
  search_symmetry = sgtbx.search_symmetry(
    flags=symmetry_flags,
    space_group_type=ref_symmetry.space_group_info().type(),
    seminvariant=ref_symmetry.space_group_info().structure_seminvariants())
  assert search_symmetry.continuous_shifts_are_principal()
  continuous_shift_flags = search_symmetry.continuous_shift_flags()
  if (flag_write_pdb):
    tag_sites_frac = flex.vec3_double()
  else:
    tag_sites_frac = None
  if (strictly_inside):
    inp_tags = inp_symmetry.gridding(
      step=point_distance*.7,
      symmetry_flags=symmetry_flags).tags()
    if (tag_sites_frac is not None):
      for point in flex.nested_loop(inp_tags.n_real()):
        if (inp_tags.tags().tag_array()[point] < 0):
          point_frac_inp=[float(n)/d for n,d in zip(point, inp_tags.n_real())]
          tag_sites_frac.append(point_frac_inp)
    if (inp_tags.tags().n_independent() < sites_cart.size()):
      print "FAIL:", inp_symmetry.space_group_info(), \
                     inp_tags.tags().n_independent(), sites_cart.size()
      raise AssertionError
  else:
    inp_tags = inp_symmetry.gridding(
      step=point_distance/2.,
      symmetry_flags=symmetry_flags).tags()
    sites_frac_inp = inp_symmetry.unit_cell().fractionalize(
      sites_cart=sites_cart)
    rt = cb_op_inp_ref.c().as_double_array()
    sites_frac_ref = rt[:9] * sites_frac_inp
    sites_frac_ref += rt[9:]
    max_distance = 2 * ((.5 * math.sqrt(3) * point_distance) * 2/3.)
    if (verbose):
      print "max_distance:", max_distance
    for point in flex.nested_loop(inp_tags.n_real()):
      if (inp_tags.tags().tag_array()[point] < 0):
        point_frac_inp = [float(n)/d for n,d in zip(point, inp_tags.n_real())]
        if (tag_sites_frac is not None):
          tag_sites_frac.append(point_frac_inp)
        point_frac_ref = cb_op_inp_ref.c() * point_frac_inp
        equiv_points = sgtbx.sym_equiv_sites(
          unit_cell=ref_symmetry.unit_cell(),
          space_group=search_symmetry.subgroup(),
          original_site=point_frac_ref,
          minimum_distance=2.e-6,
          tolerance=1.e-6)
        min_dist = sgtbx.min_sym_equiv_distance_info(
          reference_sites=equiv_points,
          others=sites_frac_ref,
          principal_continuous_allowed_origin_shift_flags
            =continuous_shift_flags).dist()
        if (min_dist > max_distance):
          print "FAIL:", inp_symmetry.space_group_info(), \
                         point_frac_ref, min_dist
          raise AssertionError
    if (inp_tags.tags().n_independent()+10 < sites_cart.size()):
      print "FAIL:", inp_symmetry.space_group_info(), \
                     inp_tags.tags().n_independent(), sites_cart.size()
      raise AssertionError
  if (tag_sites_frac is not None):
    dump_pdb(
      file_name="tag_sites.pdb",
      crystal_symmetry=inp_symmetry,
      sites_cart=inp_symmetry.unit_cell().orthogonalize(
        sites_frac=tag_sites_frac))