Example #1
0
class angle_restraint_test_case(geometry_restraints_test_case):
    manager = restraints.manager(
        angle_proxies=geometry_restraints.shared_angle_proxy([
            geom.angle_proxy((30, 0, 19), 115, 1),
            geom.angle_proxy((21, 1, 2), 110, 1)
        ]))
    proxies = manager.angle_proxies
    restraint_t = geom.angle
Example #2
0
class dihedral_restraint_test_case(geometry_restraints_test_case):
    manager = restraints.manager(
        dihedral_proxies=geometry_restraints.shared_dihedral_proxy([
            geom.dihedral_proxy((21, 19, 24, 26), 180, 1),
            geom.dihedral_proxy((5, 26, 28, 7), 60, 1)
        ]))
    proxies = manager.dihedral_proxies
    restraint_t = geom.dihedral
Example #3
0
class bond_restraint_test_case(geometry_restraints_test_case):
    manager = restraints.manager(
        bond_proxies=geometry_restraints.shared_bond_simple_proxy([
            geom.bond_simple_proxy((0, 30), 1.42, 1),
            geom.bond_simple_proxy((1, 21), 1.42, 1)
        ]))
    proxies = manager.bond_proxies
    restraint_t = geom.bond
Example #4
0
class fixed_u_eq_adp_test_case(adp_restraints_test_case):
    proxies = fixed_u_eq_adp_restraints(
        xray_structure=smtbx.development.sucrose(), u_eq_ideal=0.025).proxies
    # no need to test all of them every time
    proxies = adp.shared_fixed_u_eq_adp_proxy(
        flex.select(proxies, flags=flex.random_bool(proxies.size(), 0.5)))
    manager = restraints.manager(fixed_u_eq_adp_proxies=proxies)

    def restraint(self, proxy, u_iso=None, u_cart=None):
        if u_cart is None:
            u_cart = self.xray_structure.scatterers().extract_u_cart(
                self.xray_structure.unit_cell())
        return adp.fixed_u_eq_adp(adp_restraint_params(u_cart=u_cart), proxy)
Example #5
0
class rigid_bond_test_case(adp_restraints_test_case):
    proxies = rigid_bond_restraints(
        xray_structure=smtbx.development.sucrose()).proxies
    # no need to test all of them every time
    proxies = adp.shared_rigid_bond_proxy(
        flex.select(proxies, flags=flex.random_bool(proxies.size(), 0.3)))
    manager = restraints.manager(rigid_bond_proxies=proxies)

    def restraint(self, proxy, u_iso=None, u_cart=None):
        if u_cart is None:
            u_cart = self.xray_structure.scatterers().extract_u_cart(
                self.xray_structure.unit_cell())
        sites_cart = self.xray_structure.sites_cart()
        return adp.rigid_bond(
            adp_restraint_params(sites_cart=sites_cart, u_cart=u_cart), proxy)
Example #6
0
class adp_u_eq_similarity_test_case(adp_restraints_test_case):
  proxies = adp_u_eq_similarity_restraints(
    xray_structure=smtbx.development.sucrose()).proxies
  # no need to test all of them every time
  #proxies = adp.shared_adp_u_eq_similarity_proxy(
    #flex.select(proxies, flags=flex.random_bool(proxies.size(), 0.5)))
  manager = restraints.manager(adp_u_eq_similarity_proxies=proxies)

  def restraint(self, proxy, u_iso=None, u_cart=None):
    if u_cart is None:
      u_cart=self.xray_structure.scatterers().extract_u_cart(
        self.xray_structure.unit_cell())
    if u_iso is None:
      u_iso=self.xray_structure.scatterers().extract_u_iso()
    use_u_aniso=self.xray_structure.use_u_aniso()
    return adp.adp_u_eq_similarity(
      adp_restraint_params(u_cart=u_cart, u_iso=u_iso, use_u_aniso=use_u_aniso),
      proxy)
Example #7
0
class adp_volume_similarity_test_case(adp_restraints_test_case):
  proxies = adp_volume_similarity_restraints(
    xray_structure=smtbx.development.sucrose()).proxies
  manager = restraints.manager(adp_volume_similarity_proxies=proxies)
  def __init__(self):
    adp_restraints_test_case.__init__(self)
    # eigen values and eigen vectors are dependent after all...
    # may need to make smaller
    self.tolerance = 0.2
  def restraint(self, proxy, u_iso=None, u_cart=None):
    if u_cart is None:
      u_cart=self.xray_structure.scatterers().extract_u_cart(
        self.xray_structure.unit_cell())
    if u_iso is None:
      u_iso=self.xray_structure.scatterers().extract_u_iso()
    use_u_aniso=self.xray_structure.use_u_aniso()
    return adp.adp_volume_similarity(
      adp_restraint_params(u_cart=u_cart, u_iso=u_iso, use_u_aniso=use_u_aniso),
      proxy)
Example #8
0
 def from_cif(cls, model, reflections):
   """
   We could try to read in the weighting scheme.
   As for constraints and restraints, the CIF format does not support them
   yet
   """
   from iotbx.reflection_file_reader import any_reflection_file
   xs_dict = xray.structure.from_cif(file_path=model)
   assert len(xs_dict) == 1, "CIF should contain only one xray structure"
   xs = xs_dict.values()[0]
   mas = any_reflection_file(reflections).as_miller_arrays(crystal_symmetry=xs)
   fo_sq = None
   for ma in mas:
     if ma.is_xray_intensity_array() and ma.sigmas() is not None:
       fo_sq = ma.as_xray_observations()
       break
   assert fo_sq is not None
   return cls(fo_sq=fo_sq, xray_structure=xs,
              constraints=[],
              restraints_manager=restraints.manager(),
              weighting_scheme=least_squares.sigma_weighting())
Example #9
0
def exercise_manager(verbose=0):
  xray_structure = smtbx.development.sucrose()
  xray_structure.scatterers()[10].set_use_u_iso_only()
  asu_mappings = xray_structure.asu_mappings(buffer_thickness=3.5)
  pair_asu_table = crystal.pair_asu_table(asu_mappings=asu_mappings)
  scattering_types = xray_structure.scatterers().extract_scattering_types()
  pair_asu_table.add_covalent_pairs(
    scattering_types, exclude_scattering_types=flex.std_string(("H","D")))
  pair_sym_table = pair_asu_table.extract_pair_sym_table()
  # setup adp restraint proxies
  adp_similarity_proxies = \
    adp_restraints.adp_similarity_restraints(
      pair_sym_table=pair_sym_table).proxies
  rigid_bond_proxies = \
    adp_restraints.rigid_bond_restraints(
      pair_sym_table=pair_sym_table).proxies
  isotropic_adp_proxies = \
    adp_restraints.isotropic_adp_restraints(
      xray_structure=xray_structure,
      pair_sym_table=pair_sym_table).proxies
  bond_proxies = cctbx.geometry_restraints.shared_bond_simple_proxy()
  bond_proxies.append(
    cctbx.geometry_restraints.bond_simple_proxy(
      i_seqs=(3,23), distance_ideal=1.44, weight=2))
  bond_proxies.append(
    cctbx.geometry_restraints.bond_simple_proxy(
      i_seqs=(5,25), distance_ideal=1.44, weight=2))
  bond_proxies.append(
    cctbx.geometry_restraints.bond_simple_proxy(
      i_seqs=(1,21), distance_ideal=1.44, weight=2))
  angle_proxies = cctbx.geometry_restraints.shared_angle_proxy()
  angle_proxies.append(
    cctbx.geometry_restraints.angle_proxy(
      i_seqs=(25,28,30),angle_ideal=110,weight=2))
  angle_proxies.append(
    cctbx.geometry_restraints.angle_proxy(
      i_seqs=(23,25,28),angle_ideal=110,weight=2))
  angle_proxies.append(
    cctbx.geometry_restraints.angle_proxy(
      i_seqs=(19,23,25),angle_ideal=110,weight=2))
  bond_similarity_proxies=cctbx.geometry_restraints.shared_bond_similarity_proxy()
  bond_similarity_proxies.append(
    cctbx.geometry_restraints.bond_similarity_proxy(
      i_seqs=((14,36),(12,38)),
      weights=(10,10),
      sym_ops=(sgtbx.rt_mx(),sgtbx.rt_mx())))
  # setup restraints manager
  manager = restraints.manager(
    bond_proxies=bond_proxies,
    angle_proxies=angle_proxies,
    bond_similarity_proxies=bond_similarity_proxies,
    adp_similarity_proxies=adp_similarity_proxies,
    rigid_bond_proxies=rigid_bond_proxies,
    isotropic_adp_proxies=isotropic_adp_proxies)
  sio = StringIO()
  manager.show_sorted(xray_structure, max_items=1, f=sio)
  if sys.platform.startswith("win") and sys.version_info[:2] < (2,6):
    # This appears to be a windows-specific bug with string formatting
    # for python versions prior to 2.6, where the exponent is printed
    # with 3 digits rather than 2.
    pass
  else:
    assert not show_diff(sio.getvalue(), """\
Bond restraints: 3
Sorted by residual:
bond O3
     C3
  ideal  model  delta    sigma   weight residual
  1.440  1.422  0.018 7.07e-01 2.00e+00 6.58e-04
... (remaining 2 not shown)

Bond angle restraints: 3
Sorted by residual:
angle C3
      C4
      C5
    ideal   model   delta    sigma   weight residual
   110.00  108.00    2.00 7.07e-01 2.00e+00 8.03e+00
... (remaining 2 not shown)

Bond similarity restraints: 1
Sorted by residual:
               delta    sigma   weight rms_deltas residual sym.op.
bond O9-C9    -0.010 3.16e-01 1.00e+01   9.93e-03 9.87e-05
     O8-C10    0.010 3.16e-01 1.00e+01

ADP similarity restraints: 24
Sorted by residual:
scatterers O7
           C12
          delta    sigma   weight rms_deltas residual
 U11  -1.02e+00 8.00e-02 1.56e+02   5.93e-01 4.95e+02
 U22  -1.03e+00 8.00e-02 1.56e+02
 U33  -1.03e+00 8.00e-02 1.56e+02
 U12  -4.23e-03 8.00e-02 1.56e+02
 U13  -3.49e-03 8.00e-02 1.56e+02
 U23   5.66e-03 8.00e-02 1.56e+02
... (remaining 23 not shown)

Rigid bond restraints: 60
Sorted by residual:
scatterers O7
           C12
   delta_z    sigma   weight residual
 -6.42e-01 1.00e-02 1.00e+04 4.12e+03
... (remaining 59 not shown)

Isotropic ADP restraints: 22
Sorted by residual:
scatterer O3
         delta    sigma   weight rms_deltas residual
 U11  1.20e-03 2.00e-01 2.50e+01   1.34e-02 4.06e-02
 U22 -2.46e-02 2.00e-01 2.50e+01
 U33  2.34e-02 2.00e-01 2.50e+01
 U12 -8.14e-03 2.00e-01 2.50e+01
 U13  9.78e-03 2.00e-01 2.50e+01
 U23 -8.63e-03 2.00e-01 2.50e+01
... (remaining 21 not shown)

""")
  if (0 or verbose): print sio.getvalue()
Example #10
0
def exercise_restrained_refinement(options):
    import random
    random.seed(1)
    flex.set_random_seed(1)
    xs0 = smtbx.development.random_xray_structure(
        sgtbx.space_group_info('P1'),
        n_scatterers=options.n_scatterers,
        elements="random")
    for sc in xs0.scatterers():
        sc.flags.set_grad_site(True)
    sc0 = xs0.scatterers()
    uc = xs0.unit_cell()

    mi = xs0.build_miller_set(anomalous_flag=False, d_min=options.resolution)
    fo_sq = mi.structure_factors_from_scatterers(
        xs0, algorithm="direct").f_calc().norm()
    fo_sq = fo_sq.customized_copy(sigmas=flex.double(fo_sq.size(), 1))

    i, j, k, l = random.sample(xrange(options.n_scatterers), 4)
    bond_proxies = geometry_restraints.shared_bond_simple_proxy()
    w = 1e9
    d_ij = uc.distance(sc0[i].site, sc0[j].site) * 0.8
    bond_proxies.append(
        geom.bond_simple_proxy(i_seqs=(i, j), distance_ideal=d_ij, weight=w))
    d_jk = uc.distance(sc0[j].site, sc0[k].site) * 0.85
    bond_proxies.append(
        geom.bond_simple_proxy(i_seqs=(j, k), distance_ideal=d_jk, weight=w))
    d_ki = min(
        uc.distance(sc0[k].site, sc0[i].site) * 0.9, (d_ij + d_jk) * 0.8)
    bond_proxies.append(
        geom.bond_simple_proxy(i_seqs=(k, i), distance_ideal=d_ki, weight=w))
    d_jl = uc.distance(sc0[j].site, sc0[l].site) * 0.9
    bond_proxies.append(
        geom.bond_simple_proxy(i_seqs=(j, l), distance_ideal=d_jl, weight=w))
    d_lk = min(
        uc.distance(sc0[l].site, sc0[k].site) * 0.8, 0.75 * (d_jk + d_jl))
    bond_proxies.append(
        geom.bond_simple_proxy(i_seqs=(l, k), distance_ideal=d_jl, weight=w))
    restraints_manager = restraints.manager(bond_proxies=bond_proxies)

    xs1 = xs0.deep_copy_scatterers()
    xs1.shake_sites_in_place(rms_difference=0.1)

    def ls_problem():
        xs = xs1.deep_copy_scatterers()
        reparametrisation = constraints.reparametrisation(
            structure=xs,
            constraints=[],
            connectivity_table=smtbx.utils.connectivity_table(xs),
            temperature=20)
        return least_squares.crystallographic_ls(
            fo_sq.as_xray_observations(),
            reparametrisation=reparametrisation,
            restraints_manager=restraints_manager)

    gradient_threshold, step_threshold = 1e-6, 1e-6
    eps = 5e-3

    ls = ls_problem()
    t = wall_clock_time()
    cycles = normal_eqns_solving.naive_iterations(
        ls,
        gradient_threshold=gradient_threshold,
        step_threshold=step_threshold,
        track_all=True)
    if options.verbose:
        print "%i %s steps in %.6f s" % (cycles.n_iterations, cycles,
                                         t.elapsed())
    sc = ls.xray_structure.scatterers()
    for p in bond_proxies:
        d = uc.distance(*[sc[i_pair].site for i_pair in p.i_seqs])
        assert approx_equal(d, p.distance_ideal, eps)

    ls = ls_problem()
    t = wall_clock_time()
    cycles = normal_eqns_solving.levenberg_marquardt_iterations(
        ls,
        gradient_threshold=gradient_threshold,
        step_threshold=step_threshold,
        tau=1e-3,
        track_all=True)
    if options.verbose:
        print "%i %s steps in %.6f s" % (cycles.n_iterations, cycles,
                                         t.elapsed())
    sc = ls.xray_structure.scatterers()
    sc = ls.xray_structure.scatterers()
    for p in bond_proxies:
        d = uc.distance(*[sc[i].site for i in p.i_seqs])
        assert approx_equal(d, p.distance_ideal, eps)
Example #11
0
def test_manager():
  xray_structure = smtbx.development.sucrose()
  xray_structure.scatterers()[10].set_use_u_iso_only()
  asu_mappings = xray_structure.asu_mappings(buffer_thickness=3.5)
  pair_asu_table = crystal.pair_asu_table(asu_mappings=asu_mappings)
  scattering_types = xray_structure.scatterers().extract_scattering_types()
  pair_asu_table.add_covalent_pairs(
    scattering_types, exclude_scattering_types=flex.std_string(("H","D")))
  pair_sym_table = pair_asu_table.extract_pair_sym_table()
  # setup adp restraint proxies
  adp_similarity_proxies = \
    adp_restraints.adp_similarity_restraints(
      pair_sym_table=pair_sym_table).proxies
  rigid_bond_proxies = \
    adp_restraints.rigid_bond_restraints(
      pair_sym_table=pair_sym_table).proxies
  rigu_proxies = \
    adp_restraints.rigu_restraints(
      pair_sym_table=pair_sym_table).proxies
  isotropic_adp_proxies = \
    adp_restraints.isotropic_adp_restraints(
      xray_structure=xray_structure,
      pair_sym_table=pair_sym_table).proxies
  bond_proxies = cctbx.geometry_restraints.shared_bond_simple_proxy()
  bond_proxies.append(
    cctbx.geometry_restraints.bond_simple_proxy(
      i_seqs=(3,23), distance_ideal=1.44, weight=2))
  bond_proxies.append(
    cctbx.geometry_restraints.bond_simple_proxy(
      i_seqs=(5,25), distance_ideal=1.44, weight=2))
  bond_proxies.append(
    cctbx.geometry_restraints.bond_simple_proxy(
      i_seqs=(1,21), distance_ideal=1.44, weight=2))
  angle_proxies = cctbx.geometry_restraints.shared_angle_proxy()
  angle_proxies.append(
    cctbx.geometry_restraints.angle_proxy(
      i_seqs=(25,28,30),angle_ideal=110,weight=2))
  angle_proxies.append(
    cctbx.geometry_restraints.angle_proxy(
      i_seqs=(23,25,28),angle_ideal=110,weight=2))
  angle_proxies.append(
    cctbx.geometry_restraints.angle_proxy(
      i_seqs=(19,23,25),angle_ideal=110,weight=2))
  bond_similarity_proxies=cctbx.geometry_restraints.shared_bond_similarity_proxy()
  bond_similarity_proxies.append(
    cctbx.geometry_restraints.bond_similarity_proxy(
      i_seqs=((14,36),(12,38)),
      weights=(10,10),
      sym_ops=(sgtbx.rt_mx(),sgtbx.rt_mx())))
  chirality_proxies=cctbx.geometry_restraints.shared_chirality_proxy()
  chirality_proxies.append(
    cctbx.geometry_restraints.chirality_proxy(
      i_seqs=(14,36,12,38),
      weight=10**4,
      volume_ideal=1.2,
      both_signs=False))
  # setup restraints manager
  manager = restraints.manager(
    bond_proxies=bond_proxies,
    angle_proxies=angle_proxies,
    bond_similarity_proxies=bond_similarity_proxies,
    adp_similarity_proxies=adp_similarity_proxies,
    rigid_bond_proxies=rigid_bond_proxies,
    rigu_proxies=rigu_proxies,
    isotropic_adp_proxies=isotropic_adp_proxies,
    chirality_proxies=chirality_proxies)
  sio = StringIO()
  manager.show_sorted(xray_structure, max_items=1, f=sio)
  if sys.platform.startswith("win") and sys.version_info[:2] < (2,6):
    # This appears to be a windows-specific bug with string formatting
    # for python versions prior to 2.6, where the exponent is printed
    # with 3 digits rather than 2.
    pass
  else:
    assert sio.getvalue() == """\
Example #12
0
def exercise_restrained_refinement(options):
  import random
  random.seed(1)
  flex.set_random_seed(1)
  xs0 = smtbx.development.random_xray_structure(
    sgtbx.space_group_info('P1'),
    n_scatterers=options.n_scatterers,
    elements="random")
  for sc in xs0.scatterers():
    sc.flags.set_grad_site(True)
  sc0 = xs0.scatterers()
  uc = xs0.unit_cell()

  mi = xs0.build_miller_set(anomalous_flag=False, d_min=options.resolution)
  fo_sq = mi.structure_factors_from_scatterers(
    xs0, algorithm="direct").f_calc().norm()
  fo_sq = fo_sq.customized_copy(sigmas=flex.double(fo_sq.size(), 1))

  i, j, k, l = random.sample(xrange(options.n_scatterers), 4)
  bond_proxies = geometry_restraints.shared_bond_simple_proxy()
  w = 1e9
  d_ij = uc.distance(sc0[i].site, sc0[j].site)*0.8
  bond_proxies.append(geom.bond_simple_proxy(
    i_seqs=(i, j),
    distance_ideal=d_ij,
    weight=w))
  d_jk = uc.distance(sc0[j].site, sc0[k].site)*0.85
  bond_proxies.append(geom.bond_simple_proxy(
    i_seqs=(j, k),
    distance_ideal=d_jk,
    weight=w))
  d_ki = min(uc.distance(sc0[k].site, sc0[i].site)*0.9, (d_ij + d_jk)*0.8)
  bond_proxies.append(geom.bond_simple_proxy(
    i_seqs=(k, i),
    distance_ideal=d_ki,
    weight=w))
  d_jl = uc.distance(sc0[j].site, sc0[l].site)*0.9
  bond_proxies.append(geom.bond_simple_proxy(
    i_seqs=(j, l),
    distance_ideal=d_jl,
    weight=w))
  d_lk = min(uc.distance(sc0[l].site, sc0[k].site)*0.8, 0.75*(d_jk + d_jl))
  bond_proxies.append(geom.bond_simple_proxy(
    i_seqs=(l, k),
    distance_ideal=d_jl,
    weight=w))
  restraints_manager = restraints.manager(bond_proxies=bond_proxies)

  xs1 = xs0.deep_copy_scatterers()
  xs1.shake_sites_in_place(rms_difference=0.1)

  def ls_problem():
    xs = xs1.deep_copy_scatterers()
    reparametrisation = constraints.reparametrisation(
      structure=xs,
      constraints=[],
      connectivity_table=smtbx.utils.connectivity_table(xs),
      temperature=20)
    return least_squares.crystallographic_ls(
      fo_sq.as_xray_observations(),
      reparametrisation=reparametrisation,
      restraints_manager=restraints_manager)

  gradient_threshold, step_threshold = 1e-6, 1e-6
  eps = 5e-3

  ls = ls_problem()
  t = wall_clock_time()
  cycles = normal_eqns_solving.naive_iterations(
    ls,
    gradient_threshold=gradient_threshold,
    step_threshold=step_threshold,
    track_all=True)
  if options.verbose:
    print "%i %s steps in %.6f s" % (cycles.n_iterations, cycles, t.elapsed())
  sc = ls.xray_structure.scatterers()
  for p in bond_proxies:
    d = uc.distance(*[ sc[i_pair].site for i_pair in p.i_seqs ])
    assert approx_equal(d, p.distance_ideal, eps)

  ls = ls_problem()
  t = wall_clock_time()
  cycles = normal_eqns_solving.levenberg_marquardt_iterations(
    ls,
    gradient_threshold=gradient_threshold,
    step_threshold=step_threshold,
    tau=1e-3,
    track_all=True)
  if options.verbose:
    print "%i %s steps in %.6f s" % (cycles.n_iterations, cycles, t.elapsed())
  sc = ls.xray_structure.scatterers()
  sc = ls.xray_structure.scatterers()
  for p in bond_proxies:
    d = uc.distance(*[ sc[i].site for i in p.i_seqs ])
    assert approx_equal(d, p.distance_ideal, eps)
Example #13
0
 def restraints_manager(self):
     from smtbx.refinement.restraints import manager
     kwds = dict([("%s_proxies" % name, value)
                  for name, value in self.proxies().iteritems()])
     return manager(**kwds)
Example #14
0
def exercise_manager(verbose=0):
    xray_structure = smtbx.development.sucrose()
    xray_structure.scatterers()[10].set_use_u_iso_only()
    asu_mappings = xray_structure.asu_mappings(buffer_thickness=3.5)
    pair_asu_table = crystal.pair_asu_table(asu_mappings=asu_mappings)
    scattering_types = xray_structure.scatterers().extract_scattering_types()
    pair_asu_table.add_covalent_pairs(scattering_types,
                                      exclude_scattering_types=flex.std_string(
                                          ("H", "D")))
    pair_sym_table = pair_asu_table.extract_pair_sym_table()
    # setup adp restraint proxies
    adp_similarity_proxies = \
      adp_restraints.adp_similarity_restraints(
        pair_sym_table=pair_sym_table).proxies
    rigid_bond_proxies = \
      adp_restraints.rigid_bond_restraints(
        pair_sym_table=pair_sym_table).proxies
    isotropic_adp_proxies = \
      adp_restraints.isotropic_adp_restraints(
        xray_structure=xray_structure,
        pair_sym_table=pair_sym_table).proxies
    bond_proxies = cctbx.geometry_restraints.shared_bond_simple_proxy()
    bond_proxies.append(
        cctbx.geometry_restraints.bond_simple_proxy(i_seqs=(3, 23),
                                                    distance_ideal=1.44,
                                                    weight=2))
    bond_proxies.append(
        cctbx.geometry_restraints.bond_simple_proxy(i_seqs=(5, 25),
                                                    distance_ideal=1.44,
                                                    weight=2))
    bond_proxies.append(
        cctbx.geometry_restraints.bond_simple_proxy(i_seqs=(1, 21),
                                                    distance_ideal=1.44,
                                                    weight=2))
    angle_proxies = cctbx.geometry_restraints.shared_angle_proxy()
    angle_proxies.append(
        cctbx.geometry_restraints.angle_proxy(i_seqs=(25, 28, 30),
                                              angle_ideal=110,
                                              weight=2))
    angle_proxies.append(
        cctbx.geometry_restraints.angle_proxy(i_seqs=(23, 25, 28),
                                              angle_ideal=110,
                                              weight=2))
    angle_proxies.append(
        cctbx.geometry_restraints.angle_proxy(i_seqs=(19, 23, 25),
                                              angle_ideal=110,
                                              weight=2))
    bond_similarity_proxies = cctbx.geometry_restraints.shared_bond_similarity_proxy(
    )
    bond_similarity_proxies.append(
        cctbx.geometry_restraints.bond_similarity_proxy(
            i_seqs=((14, 36), (12, 38)),
            weights=(10, 10),
            sym_ops=(sgtbx.rt_mx(), sgtbx.rt_mx())))
    # setup restraints manager
    manager = restraints.manager(
        bond_proxies=bond_proxies,
        angle_proxies=angle_proxies,
        bond_similarity_proxies=bond_similarity_proxies,
        adp_similarity_proxies=adp_similarity_proxies,
        rigid_bond_proxies=rigid_bond_proxies,
        isotropic_adp_proxies=isotropic_adp_proxies)
    sio = StringIO()
    manager.show_sorted(xray_structure, max_items=1, f=sio)
    if sys.platform.startswith("win") and sys.version_info[:2] < (2, 6):
        # This appears to be a windows-specific bug with string formatting
        # for python versions prior to 2.6, where the exponent is printed
        # with 3 digits rather than 2.
        pass
    else:
        assert not show_diff(
            sio.getvalue(), """\
Bond restraints: 3
Sorted by residual:
bond O3
     C3
  ideal  model  delta    sigma   weight residual
  1.440  1.422  0.018 7.07e-01 2.00e+00 6.58e-04
... (remaining 2 not shown)

Bond angle restraints: 3
Sorted by residual:
angle C3
      C4
      C5
    ideal   model   delta    sigma   weight residual
   110.00  108.00    2.00 7.07e-01 2.00e+00 8.03e+00
... (remaining 2 not shown)

Bond similarity restraints: 1
Sorted by residual:
               delta    sigma   weight rms_deltas residual sym.op.
bond O9-C9    -0.010 3.16e-01 1.00e+01   9.93e-03 9.87e-05
     O8-C10    0.010 3.16e-01 1.00e+01

ADP similarity restraints: 24
Sorted by residual:
scatterers O7
           C12
          delta    sigma   weight rms_deltas residual
 U11  -1.02e+00 8.00e-02 1.56e+02   5.93e-01 4.95e+02
 U22  -1.03e+00 8.00e-02 1.56e+02
 U33  -1.03e+00 8.00e-02 1.56e+02
 U12  -4.23e-03 8.00e-02 1.56e+02
 U13  -3.49e-03 8.00e-02 1.56e+02
 U23   5.66e-03 8.00e-02 1.56e+02
... (remaining 23 not shown)

Rigid bond restraints: 60
Sorted by residual:
scatterers O7
           C12
   delta_z    sigma   weight residual
 -6.42e-01 1.00e-02 1.00e+04 4.12e+03
... (remaining 59 not shown)

Isotropic ADP restraints: 22
Sorted by residual:
scatterer O3
         delta    sigma   weight rms_deltas residual
 U11  1.20e-03 2.00e-01 2.50e+01   1.34e-02 4.06e-02
 U22 -2.46e-02 2.00e-01 2.50e+01
 U33  2.34e-02 2.00e-01 2.50e+01
 U12 -8.14e-03 2.00e-01 2.50e+01
 U13  9.78e-03 2.00e-01 2.50e+01
 U23 -8.63e-03 2.00e-01 2.50e+01
... (remaining 21 not shown)

""")
    if (0 or verbose): print sio.getvalue()
Example #15
0
 def fget(self):
   from smtbx.refinement.restraints import manager
   kwds = dict([ ("%s_proxies" % name, value)
                 for name, value in self.proxies().iteritems() ])
   return manager(**kwds)