Beispiel #1
0
def exercise_lbfgs_simple(mon_lib_srv, ener_lib, verbose=False):
    # three peptides:
    #  1 = poly-ALA, favored
    #  2 = poly-ALA, outlier
    #  3 = poly-TRP, outlier
    #
    # Note that the ramalyze score for the first actually gets slightly worse,
    # but it's still good and we're starting from an excellent score anyway.
    #
    residuals = [0.00168766995882, 170.84797160, 161.5214609]
    for i, peptide in enumerate([pdb1, pdb2, pdb3]):
        pdb_in = iotbx.pdb.input(source_info="peptide",
                                 lines=flex.split_lines(peptide))
        log = StringIO()
        pdb_hierarchy = pdb_in.construct_hierarchy()
        atoms = pdb_hierarchy.atoms()
        sites_cart_1 = atoms.extract_xyz().deep_copy()
        gradients_fd = flex.vec3_double(sites_cart_1.size(), (0, 0, 0))
        gradients_an = flex.vec3_double(sites_cart_1.size(), (0, 0, 0))
        params = ramachandran.master_phil.fetch().extract(
        ).ramachandran_plot_restraints
        rama_manager = ramachandran.ramachandran_manager(
            pdb_hierarchy, params, log)
        assert rama_manager.get_n_proxies() == 1
        residual_an = rama_manager.target_and_gradients(
            unit_cell=None,
            sites_cart=sites_cart_1,
            gradient_array=gradients_an)
        # print "comparing", residual_an
        assert approx_equal(residual_an, residuals[i], eps=0.001)
        # approx_equal(residual_an, residuals[i], eps=0.001)
    if verbose:
        print("")
    for i, peptide in enumerate([pdb1, pdb2, pdb3]):
        pdb_in = iotbx.pdb.input(source_info="peptide",
                                 lines=flex.split_lines(peptide))
        o = benchmark_structure(pdb_in, mon_lib_srv, ener_lib, verbose)
        phi0, psi0 = o.r0.results[0].phi, o.r0.results[0].psi
        phi1, psi1 = o.r1.results[0].phi, o.r1.results[0].psi
        phi2, psi2 = o.r2.results[0].phi, o.r2.results[0].psi
        r0 = o.r0.results[0].score
        r1 = o.r1.results[0].score
        r2 = o.r2.results[0].score
        if verbose:
            print("peptide %d" % (i + 1))
            print(" before: rmsd_bonds=%-6.4f rmsd_angles=%-6.3f" %
                  (o.b0, o.a0))
            print("         phi=%-6.1f psi=%-6.1f score=%-.2f" %
                  (phi0, psi0, r0))
            print(" simple: rmsd_bonds=%-6.4f rmsd_angles=%-6.3f" %
                  (o.b1, o.a1))
            print("         phi=%-6.1f psi=%-6.1f score=%-.2f" %
                  (phi1, psi1, r1))
            print(" + Rama: rmsd_bonds=%-6.4f rmsd_angles=%-6.3f" %
                  (o.b2, o.a2))
            print("         phi=%-6.1f psi=%-6.1f score=%-.2f" %
                  (phi2, psi2, r2))
            print("")
def exercise_lbfgs_simple (mon_lib_srv, ener_lib, verbose=False) :
  # three peptides:
  #  1 = poly-ALA, favored
  #  2 = poly-ALA, outlier
  #  3 = poly-TRP, outlier
  #
  # Note that the ramalyze score for the first actually gets slightly worse,
  # but it's still good and we're starting from an excellent score anyway.
  #
  # residuals = [0.00024512, 307.616444, 294.913714]
  residuals = [0.00168766995882, 186.24718562, 177.259069807]
  for i, peptide in enumerate([pdb1, pdb2, pdb3]) :
    pdb_in = iotbx.pdb.input(source_info="peptide",
      lines=flex.split_lines(peptide))
    params = pdb_interpretation.master_params.extract()
    processed_pdb_file = pdb_interpretation.process(
      mon_lib_srv=mon_lib_srv,
      ener_lib=ener_lib,
      params=params,
      pdb_inp=pdb_in,
      log=StringIO())
    log = StringIO()
    pdb_hierarchy = processed_pdb_file.all_chain_proxies.pdb_hierarchy
    atoms = pdb_hierarchy.atoms()
    sites_cart_1 = atoms.extract_xyz().deep_copy()
    gradients_fd = flex.vec3_double(sites_cart_1.size(), (0,0,0))
    gradients_an = flex.vec3_double(sites_cart_1.size(), (0,0,0))
    params = ramachandran.master_phil.fetch().extract()
    rama_manager = ramachandran.ramachandran_manager(
        pdb_hierarchy, None, params, log)
    assert rama_manager.get_n_proxies() == 1
    residual_an = rama_manager.target_and_gradients(
      unit_cell=None,
      sites_cart=sites_cart_1,
      gradient_array=gradients_an)
    # print "comparing", residual_an
    assert approx_equal(residual_an, residuals[i], eps=0.00001)
  if verbose :
    print ""
  for i, peptide in enumerate([pdb1, pdb2, pdb3]) :
    pdb_in = iotbx.pdb.input(source_info="peptide",
      lines=flex.split_lines(peptide))
    o = benchmark_structure(pdb_in, mon_lib_srv, ener_lib, verbose)
    phi0, psi0 = o.r0.results[0].phi, o.r0.results[0].psi
    phi1, psi1 = o.r1.results[0].phi, o.r1.results[0].psi
    phi2, psi2 = o.r2.results[0].phi, o.r2.results[0].psi
    r0 = o.r0.results[0].score
    r1 = o.r1.results[0].score
    r2 = o.r2.results[0].score
    if verbose :
      print "peptide %d" % (i+1)
      print " before: rmsd_bonds=%-6.4f rmsd_angles=%-6.3f" % (o.b0,o.a0)
      print "         phi=%-6.1f psi=%-6.1f score=%-.2f" % (phi0, psi0, r0)
      print " simple: rmsd_bonds=%-6.4f rmsd_angles=%-6.3f" % (o.b1,o.a1)
      print "         phi=%-6.1f psi=%-6.1f score=%-.2f" % (phi1, psi1, r1)
      print " + Rama: rmsd_bonds=%-6.4f rmsd_angles=%-6.3f" % (o.b2,o.a2)
      print "         phi=%-6.1f psi=%-6.1f score=%-.2f" % (phi2, psi2, r2)
      print ""
Beispiel #3
0
def benchmark_structure(pdb_in, mon_lib_srv, ener_lib, verbose=False, w=1.0):
    log = StringIO()

    params = mmtbx.model.manager.get_default_pdb_interpretation_params()
    params.pdb_interpretation.peptide_link.ramachandran_restraints = True
    params.pdb_interpretation.ramachandran_plot_restraints.inject_emsley8k_into_oldfield_favored = False
    model = mmtbx.model.manager(model_input=pdb_in,
                                pdb_interpretation_params=params,
                                log=null_out(),
                                build_grm=True)
    grm = model.get_restraints_manager().geometry
    pdb_hierarchy = model.get_hierarchy()
    r0 = ramalyze(pdb_hierarchy=pdb_hierarchy, outliers_only=False)
    atoms = pdb_hierarchy.atoms()
    sites_cart_1 = atoms.extract_xyz().deep_copy()
    sites_cart_2 = sites_cart_1.deep_copy()
    assert (grm is not None)
    e = grm.energies_sites(sites_cart=sites_cart_1)
    b0 = e.bond_deviations()[-1]
    a0 = e.angle_deviations()[-1]
    flags = cctbx.geometry_restraints.flags.flags(default=True)
    lbfgs = geometry_minimization.lbfgs(
        sites_cart=sites_cart_1,
        correct_special_position_tolerance=1.0,
        geometry_restraints_manager=grm,
        geometry_restraints_flags=flags,
        lbfgs_termination_params=scitbx.lbfgs.termination_parameters(
            max_iterations=500))
    a1 = lbfgs.rmsd_angles
    b1 = lbfgs.rmsd_bonds
    atoms.set_xyz(sites_cart_1)
    r1 = ramalyze(pdb_hierarchy=pdb_hierarchy, outliers_only=False)
    rama_params = ramachandran.master_phil.fetch().extract(
    ).ramachandran_plot_restraints
    rama_manager = ramachandran.ramachandran_manager(pdb_hierarchy,
                                                     rama_params, log)
    grm.set_ramachandran_restraints(rama_manager)
    lbfgs = geometry_minimization.lbfgs(
        sites_cart=sites_cart_2,
        correct_special_position_tolerance=1.0,
        geometry_restraints_manager=grm,
        geometry_restraints_flags=flags,
        lbfgs_termination_params=scitbx.lbfgs.termination_parameters(
            max_iterations=500))
    a2 = lbfgs.rmsd_angles
    b2 = lbfgs.rmsd_bonds
    atoms.set_xyz(sites_cart_2)
    r2 = ramalyze(pdb_hierarchy=pdb_hierarchy, outliers_only=False)
    return group_args(a0=a0,
                      a1=a1,
                      a2=a2,
                      b0=b0,
                      b1=b1,
                      b2=b2,
                      r0=r0,
                      r1=r1,
                      r2=r2)
def benchmark_structure (pdb_in, mon_lib_srv, ener_lib, verbose=False, w=1.0) :
  params = pdb_interpretation.master_params.extract()
  processed_pdb_file = pdb_interpretation.process(
    mon_lib_srv=mon_lib_srv,
    ener_lib=ener_lib,
    params=params,
    pdb_inp=pdb_in,
    log=StringIO())
  log = StringIO()
  pdb_hierarchy = processed_pdb_file.all_chain_proxies.pdb_hierarchy
  r0 = ramalyze(pdb_hierarchy=pdb_hierarchy, outliers_only=False)
  atoms = pdb_hierarchy.atoms()
  sites_cart_1 = atoms.extract_xyz().deep_copy()
  sites_cart_2 = sites_cart_1.deep_copy()
  grm = processed_pdb_file.geometry_restraints_manager()
  assert (grm is not None)
  e = grm.energies_sites(sites_cart=sites_cart_1)
  b0 = e.bond_deviations()[-1]
  a0 = e.angle_deviations()[-1]
  flags = cctbx.geometry_restraints.flags.flags(default=True)
  lbfgs = geometry_minimization.lbfgs(
    sites_cart=sites_cart_1,
    correct_special_position_tolerance=1.0,
    geometry_restraints_manager=grm,
    geometry_restraints_flags=flags,
    lbfgs_termination_params=scitbx.lbfgs.termination_parameters(
        max_iterations=500))
  a1 = lbfgs.rmsd_angles
  b1 = lbfgs.rmsd_bonds
  atoms.set_xyz(sites_cart_1)
  r1 = ramalyze(pdb_hierarchy=pdb_hierarchy, outliers_only=False)
  rama_params = ramachandran.master_phil.fetch().extract()
  rama_manager = ramachandran.ramachandran_manager(
      pdb_hierarchy, None, rama_params, log)
  grm.set_ramachandran_restraints(rama_manager)
  lbfgs = geometry_minimization.lbfgs(
    sites_cart=sites_cart_2,
    correct_special_position_tolerance=1.0,
    geometry_restraints_manager=grm,
    geometry_restraints_flags=flags,
    lbfgs_termination_params=scitbx.lbfgs.termination_parameters(
        max_iterations=500))
  a2 = lbfgs.rmsd_angles
  b2 = lbfgs.rmsd_bonds
  atoms.set_xyz(sites_cart_2)
  r2 = ramalyze(pdb_hierarchy=pdb_hierarchy, outliers_only=False)
  return group_args(
    a0=a0,
    a1=a1,
    a2=a2,
    b0=b0,
    b1=b1,
    b2=b2,
    r0=r0,
    r1=r1,
    r2=r2)
def benchmark_structure(pdb_in, mon_lib_srv, ener_lib, verbose=False, w=1.0):
    params = pdb_interpretation.master_params.extract()
    processed_pdb_file = pdb_interpretation.process(mon_lib_srv=mon_lib_srv,
                                                    ener_lib=ener_lib,
                                                    params=params,
                                                    pdb_inp=pdb_in,
                                                    log=StringIO())
    log = StringIO()
    pdb_hierarchy = processed_pdb_file.all_chain_proxies.pdb_hierarchy
    r0 = ramalyze(pdb_hierarchy=pdb_hierarchy, outliers_only=False)
    atoms = pdb_hierarchy.atoms()
    sites_cart_1 = atoms.extract_xyz().deep_copy()
    sites_cart_2 = sites_cart_1.deep_copy()
    grm = processed_pdb_file.geometry_restraints_manager()
    assert (grm is not None)
    e = grm.energies_sites(sites_cart=sites_cart_1)
    b0 = e.bond_deviations()[-1]
    a0 = e.angle_deviations()[-1]
    flags = cctbx.geometry_restraints.flags.flags(default=True)
    lbfgs = geometry_minimization.lbfgs(
        sites_cart=sites_cart_1,
        correct_special_position_tolerance=1.0,
        geometry_restraints_manager=grm,
        geometry_restraints_flags=flags,
        lbfgs_termination_params=scitbx.lbfgs.termination_parameters(
            max_iterations=500))
    a1 = lbfgs.rmsd_angles
    b1 = lbfgs.rmsd_bonds
    atoms.set_xyz(sites_cart_1)
    r1 = ramalyze(pdb_hierarchy=pdb_hierarchy, outliers_only=False)
    rama_params = ramachandran.master_phil.fetch().extract()
    rama_manager = ramachandran.ramachandran_manager(pdb_hierarchy, None,
                                                     rama_params, log)
    grm.set_ramachandran_restraints(rama_manager)
    lbfgs = geometry_minimization.lbfgs(
        sites_cart=sites_cart_2,
        correct_special_position_tolerance=1.0,
        geometry_restraints_manager=grm,
        geometry_restraints_flags=flags,
        lbfgs_termination_params=scitbx.lbfgs.termination_parameters(
            max_iterations=500))
    a2 = lbfgs.rmsd_angles
    b2 = lbfgs.rmsd_bonds
    atoms.set_xyz(sites_cart_2)
    r2 = ramalyze(pdb_hierarchy=pdb_hierarchy, outliers_only=False)
    return group_args(a0=a0,
                      a1=a1,
                      a2=a2,
                      b0=b0,
                      b1=b1,
                      b2=b2,
                      r0=r0,
                      r1=r1,
                      r2=r2)
def exercise_geo_output(mon_lib_srv, ener_lib):
  pdb_str = """\
CRYST1   18.879   16.714   25.616  90.00  90.00  90.00 P 1
ATOM      1  N   ALA     1      13.515   7.809  20.095  1.00  0.00           N
ATOM      2  CA  ALA     1      13.087   6.532  19.536  1.00  0.00           C
ATOM      3  C   ALA     1      11.716   6.653  18.880  1.00  0.00           C
ATOM      4  O   ALA     1      11.425   5.972  17.896  1.00  0.00           O
ATOM      5  CB  ALA     1      13.065   5.461  20.616  1.00  0.00           C
ATOM      6  N   ALA     2      10.876   7.524  19.431  1.00  0.00           N
ATOM      7  CA  ALA     2       9.535   7.735  18.900  1.00  0.00           C
ATOM      8  C   ALA     2       9.565   8.647  17.678  1.00  0.00           C
ATOM      9  O   ALA     2       8.787   8.471  16.741  1.00  0.00           O
ATOM     10  CB  ALA     2       8.626   8.316  19.973  1.00  0.00           C
ATOM     11  N   ALA     3      10.469   9.622  17.697  1.00  0.00           N
ATOM     12  CA  ALA     3      10.606  10.565  16.593  1.00  0.00           C
ATOM     13  C   ALA     3      11.132   9.871  15.340  1.00  0.00           C
ATOM     14  O   ALA     3      10.687  10.157  14.228  1.00  0.00           O
ATOM     15  CB  ALA     3      11.520  11.714  16.987  1.00  0.00           C
ATOM     16  N   ALA     4      12.081   8.960  15.530  1.00  0.00           N
ATOM     17  CA  ALA     4      12.656   8.209  14.421  1.00  0.00           C
ATOM     18  C   ALA     4      11.624   7.266  13.812  1.00  0.00           C
ATOM     19  O   ALA     4      11.570   7.090  12.595  1.00  0.00           O
ATOM     20  CB  ALA     4      13.879   7.432  14.883  1.00  0.00           C
ATOM     21  N   ALA     5      10.805   6.663  14.669  1.00  0.00           N
ATOM     22  CA  ALA     5       9.753   5.761  14.218  1.00  0.00           C
ATOM     23  C   ALA     5       8.662   6.528  13.481  1.00  0.00           C
ATOM     24  O   ALA     5       8.107   6.045  12.494  1.00  0.00           O
ATOM     25  CB  ALA     5       9.165   5.000  15.396  1.00  0.00           C
ATOM     26  N   ALA     6       8.360   7.728  13.967  1.00  0.00           N
ATOM     27  CA  ALA     6       7.358   8.580  13.338  1.00  0.00           C
ATOM     28  C   ALA     6       7.860   9.106  11.998  1.00  0.00           C
ATOM     29  O   ALA     6       7.078   9.322  11.072  1.00  0.00           O
ATOM     30  CB  ALA     6       6.986   9.732  14.257  1.00  0.00           C
ATOM     31  N   ALA     7       9.169   9.311  11.903  1.00  0.00           N
ATOM     32  CA  ALA     7       9.781   9.787  10.668  1.00  0.00           C
ATOM     33  C   ALA     7       9.912   8.655   9.655  1.00  0.00           C
ATOM     34  O   ALA     7       9.905   8.886   8.446  1.00  0.00           O
ATOM     35  CB  ALA     7      11.141  10.405  10.952  1.00  0.00           C
ATOM     36  N   ALA     8      10.030   7.429  10.157  1.00  0.00           N
ATOM     37  CA  ALA     8      10.152   6.258   9.297  1.00  0.00           C
ATOM     38  C   ALA     8       8.788   5.809   8.786  1.00  0.00           C
ATOM     39  O   ALA     8       8.667   5.312   7.666  1.00  0.00           O
ATOM     40  CB  ALA     8      10.839   5.124  10.041  1.00  0.00           C
ATOM     41  N   ALA     9       7.762   5.988   9.613  1.00  0.00           N
ATOM     42  CA  ALA     9       6.405   5.603   9.243  1.00  0.00           C
ATOM     43  C   ALA     9       5.816   6.576   8.228  1.00  0.00           C
ATOM     44  O   ALA     9       5.000   6.195   7.389  1.00  0.00           O
ATOM     45  CB  ALA     9       5.521   5.526  10.478  1.00  0.00           C
ATOM     46  N   ALA    10       6.235   7.835   8.309  1.00  0.00           N
ATOM     47  CA  ALA    10       5.751   8.864   7.397  1.00  0.00           C
ATOM     48  C   ALA    10       6.434   8.760   6.038  1.00  0.00           C
ATOM     49  O   ALA    10       5.773   8.734   5.000  1.00  0.00           O
ATOM     50  CB  ALA    10       5.966  10.246   7.995  1.00  0.00           C
TER
END
"""
  pdb_inp = iotbx.pdb.input(source_info="peptide",lines=flex.split_lines(pdb_str))
  hierarchy = pdb_inp.construct_hierarchy()
  atoms = hierarchy.atoms()
  sites_cart = atoms.extract_xyz()
  params = ramachandran.master_phil.fetch().extract()
  params.rama_potential = "emsley"
  rama_manager = ramachandran.ramachandran_manager(
      hierarchy, None, params, StringIO())
  out = StringIO()
  rama_manager.show_sorted(
      by_value="residual",
      sites_cart=sites_cart,
      site_labels=[a.id_str() for a in atoms],
      f=out)
  gv = out.getvalue()
  # print out.getvalue()
  # STOP()
  assert gv == """\
Ramachandran plot restraints: 8
Sorted by residual:
phi-psi angles formed by             residual
    pdb=" C   ALA     7 "            1.53e+01
    pdb=" N   ALA     8 "
    pdb=" CA  ALA     8 "
    pdb=" C   ALA     8 "
    pdb=" N   ALA     9 "
phi-psi angles formed by             residual
    pdb=" C   ALA     1 "            1.52e+01
    pdb=" N   ALA     2 "
    pdb=" CA  ALA     2 "
    pdb=" C   ALA     2 "
    pdb=" N   ALA     3 "
phi-psi angles formed by             residual
    pdb=" C   ALA     6 "            1.20e+01
    pdb=" N   ALA     7 "
    pdb=" CA  ALA     7 "
    pdb=" C   ALA     7 "
    pdb=" N   ALA     8 "
phi-psi angles formed by             residual
    pdb=" C   ALA     2 "            1.14e+01
    pdb=" N   ALA     3 "
    pdb=" CA  ALA     3 "
    pdb=" C   ALA     3 "
    pdb=" N   ALA     4 "
phi-psi angles formed by             residual
    pdb=" C   ALA     8 "            1.06e+01
    pdb=" N   ALA     9 "
    pdb=" CA  ALA     9 "
    pdb=" C   ALA     9 "
    pdb=" N   ALA    10 "
phi-psi angles formed by             residual
    pdb=" C   ALA     4 "            1.06e+01
    pdb=" N   ALA     5 "
    pdb=" CA  ALA     5 "
    pdb=" C   ALA     5 "
    pdb=" N   ALA     6 "
phi-psi angles formed by             residual
    pdb=" C   ALA     3 "            1.03e+01
    pdb=" N   ALA     4 "
    pdb=" CA  ALA     4 "
    pdb=" C   ALA     4 "
    pdb=" N   ALA     5 "
phi-psi angles formed by             residual
    pdb=" C   ALA     5 "            7.58e+00
    pdb=" N   ALA     6 "
    pdb=" CA  ALA     6 "
    pdb=" C   ALA     6 "
    pdb=" N   ALA     7 "

"""

  params.rama_potential = "oldfield"
  rama_manager = ramachandran.ramachandran_manager(
      hierarchy, None, params, StringIO())
  out = StringIO()
  rama_manager.show_sorted(
      by_value="residual",
      sites_cart=sites_cart,
      site_labels=[a.id_str() for a in atoms],
      f=out)
  gv = out.getvalue()
  # print out.getvalue()
  # STOP()
  assert not show_diff(gv, """\
Ramachandran plot restraints: 8
Sorted by residual:
phi-psi angles formed by             residual
    pdb=" C   ALA     7 "            1.52e-01
    pdb=" N   ALA     8 "
    pdb=" CA  ALA     8 "
    pdb=" C   ALA     8 "
    pdb=" N   ALA     9 "
phi-psi angles formed by             residual
    pdb=" C   ALA     4 "            1.28e-01
    pdb=" N   ALA     5 "
    pdb=" CA  ALA     5 "
    pdb=" C   ALA     5 "
    pdb=" N   ALA     6 "
phi-psi angles formed by             residual
    pdb=" C   ALA     6 "            5.19e-02
    pdb=" N   ALA     7 "
    pdb=" CA  ALA     7 "
    pdb=" C   ALA     7 "
    pdb=" N   ALA     8 "
phi-psi angles formed by             residual
    pdb=" C   ALA     5 "            3.46e-02
    pdb=" N   ALA     6 "
    pdb=" CA  ALA     6 "
    pdb=" C   ALA     6 "
    pdb=" N   ALA     7 "
phi-psi angles formed by             residual
    pdb=" C   ALA     2 "            2.54e-02
    pdb=" N   ALA     3 "
    pdb=" CA  ALA     3 "
    pdb=" C   ALA     3 "
    pdb=" N   ALA     4 "
phi-psi angles formed by             residual
    pdb=" C   ALA     8 "            2.00e-02
    pdb=" N   ALA     9 "
    pdb=" CA  ALA     9 "
    pdb=" C   ALA     9 "
    pdb=" N   ALA    10 "
phi-psi angles formed by             residual
    pdb=" C   ALA     1 "            1.21e-02
    pdb=" N   ALA     2 "
    pdb=" CA  ALA     2 "
    pdb=" C   ALA     2 "
    pdb=" N   ALA     3 "
phi-psi angles formed by             residual
    pdb=" C   ALA     3 "            9.28e-03
    pdb=" N   ALA     4 "
    pdb=" CA  ALA     4 "
    pdb=" C   ALA     4 "
    pdb=" N   ALA     5 "

""")
Beispiel #7
0
def exercise_manager_selection(mon_lib_srv, ener_lib):
    pdb_inp = iotbx.pdb.input(source_info="peptide",
                              lines=flex.split_lines(pdb_str))
    hierarchy = pdb_inp.construct_hierarchy()
    atoms = hierarchy.atoms()
    sites_cart = atoms.extract_xyz()
    params = ramachandran.master_phil.fetch().extract()
    params = params.ramachandran_plot_restraints
    params.favored = 'emsley'
    params.allowed = 'emsley'
    params.outlier = 'emsley'
    params.inject_emsley8k_into_oldfield_favored = False
    rama_manager = ramachandran.ramachandran_manager(hierarchy, params,
                                                     StringIO())
    out = StringIO()
    s_out = StringIO()
    rama_manager.show_sorted(by_value="residual",
                             sites_cart=sites_cart,
                             site_labels=[a.id_str() for a in atoms],
                             f=out)
    selected_m = rama_manager.proxy_select(n_seq=hierarchy.atoms_size(),
                                           iselection=flex.size_t(range(40)))
    selected_m.show_sorted(by_value="residual",
                           sites_cart=sites_cart,
                           site_labels=[a.id_str() for a in atoms],
                           f=s_out)
    assert not show_diff(
        s_out.getvalue(), """\
Ramachandran plot restraints (Oldfield): 0
Sorted by residual:

Ramachandran plot restraints (Emsley): 6
Sorted by residual:
phi-psi angles formed by             residual
    pdb=" C   ALA     1 "            1.52e+01
    pdb=" N   ALA     2 "
    pdb=" CA  ALA     2 "
    pdb=" C   ALA     2 "
    pdb=" N   ALA     3 "
phi-psi angles formed by             residual
    pdb=" C   ALA     6 "            1.20e+01
    pdb=" N   ALA     7 "
    pdb=" CA  ALA     7 "
    pdb=" C   ALA     7 "
    pdb=" N   ALA     8 "
phi-psi angles formed by             residual
    pdb=" C   ALA     2 "            1.14e+01
    pdb=" N   ALA     3 "
    pdb=" CA  ALA     3 "
    pdb=" C   ALA     3 "
    pdb=" N   ALA     4 "
phi-psi angles formed by             residual
    pdb=" C   ALA     4 "            1.06e+01
    pdb=" N   ALA     5 "
    pdb=" CA  ALA     5 "
    pdb=" C   ALA     5 "
    pdb=" N   ALA     6 "
phi-psi angles formed by             residual
    pdb=" C   ALA     3 "            1.03e+01
    pdb=" N   ALA     4 "
    pdb=" CA  ALA     4 "
    pdb=" C   ALA     4 "
    pdb=" N   ALA     5 "
phi-psi angles formed by             residual
    pdb=" C   ALA     5 "            7.58e+00
    pdb=" N   ALA     6 "
    pdb=" CA  ALA     6 "
    pdb=" C   ALA     6 "
    pdb=" N   ALA     7 "

Ramachandran plot restraints (emsley8k): 0
Sorted by residual:

Ramachandran plot restraints (phi/psi/2): 0
Sorted by residual:

""")
Beispiel #8
0
def exercise_geo_output(mon_lib_srv, ener_lib):
    pdb_inp = iotbx.pdb.input(source_info="peptide",
                              lines=flex.split_lines(pdb_str))
    hierarchy = pdb_inp.construct_hierarchy()
    atoms = hierarchy.atoms()
    sites_cart = atoms.extract_xyz()
    params = ramachandran.master_phil.fetch().extract()
    params = params.ramachandran_plot_restraints
    params.favored = 'emsley'
    params.allowed = 'emsley'
    params.outlier = 'emsley'
    params.inject_emsley8k_into_oldfield_favored = False
    rama_manager = ramachandran.ramachandran_manager(hierarchy, params,
                                                     StringIO())
    out = StringIO()
    rama_manager.show_sorted(by_value="residual",
                             sites_cart=sites_cart,
                             site_labels=[a.id_str() for a in atoms],
                             f=out)
    gv = out.getvalue()
    assert not show_diff(
        gv, """\
Ramachandran plot restraints (Oldfield): 0
Sorted by residual:

Ramachandran plot restraints (Emsley): 8
Sorted by residual:
phi-psi angles formed by             residual
    pdb=" C   ALA     7 "            1.53e+01
    pdb=" N   ALA     8 "
    pdb=" CA  ALA     8 "
    pdb=" C   ALA     8 "
    pdb=" N   ALA     9 "
phi-psi angles formed by             residual
    pdb=" C   ALA     1 "            1.52e+01
    pdb=" N   ALA     2 "
    pdb=" CA  ALA     2 "
    pdb=" C   ALA     2 "
    pdb=" N   ALA     3 "
phi-psi angles formed by             residual
    pdb=" C   ALA     6 "            1.20e+01
    pdb=" N   ALA     7 "
    pdb=" CA  ALA     7 "
    pdb=" C   ALA     7 "
    pdb=" N   ALA     8 "
phi-psi angles formed by             residual
    pdb=" C   ALA     2 "            1.14e+01
    pdb=" N   ALA     3 "
    pdb=" CA  ALA     3 "
    pdb=" C   ALA     3 "
    pdb=" N   ALA     4 "
phi-psi angles formed by             residual
    pdb=" C   ALA     8 "            1.06e+01
    pdb=" N   ALA     9 "
    pdb=" CA  ALA     9 "
    pdb=" C   ALA     9 "
    pdb=" N   ALA    10 "
phi-psi angles formed by             residual
    pdb=" C   ALA     4 "            1.06e+01
    pdb=" N   ALA     5 "
    pdb=" CA  ALA     5 "
    pdb=" C   ALA     5 "
    pdb=" N   ALA     6 "
phi-psi angles formed by             residual
    pdb=" C   ALA     3 "            1.03e+01
    pdb=" N   ALA     4 "
    pdb=" CA  ALA     4 "
    pdb=" C   ALA     4 "
    pdb=" N   ALA     5 "
phi-psi angles formed by             residual
    pdb=" C   ALA     5 "            7.58e+00
    pdb=" N   ALA     6 "
    pdb=" CA  ALA     6 "
    pdb=" C   ALA     6 "
    pdb=" N   ALA     7 "

Ramachandran plot restraints (emsley8k): 0
Sorted by residual:

Ramachandran plot restraints (phi/psi/2): 0
Sorted by residual:

""")

    params.favored = 'oldfield'
    params.allowed = 'oldfield'
    params.outlier = 'oldfield'
    params.inject_emsley8k_into_oldfield_favored = False
    rama_manager = ramachandran.ramachandran_manager(hierarchy, params,
                                                     StringIO())
    out = StringIO()
    rama_manager.show_sorted(by_value="residual",
                             sites_cart=sites_cart,
                             site_labels=[a.id_str() for a in atoms],
                             f=out)
    gv = out.getvalue()
    #print(gv)
    #STOP()
    assert not show_diff(
        gv, """\
Ramachandran plot restraints (Oldfield): 8
Sorted by residual:
phi-psi angles formed by             residual
    pdb=" C   ALA     5 "            3.46e-02
    pdb=" N   ALA     6 "
    pdb=" CA  ALA     6 "
    pdb=" C   ALA     6 "
    pdb=" N   ALA     7 "
phi-psi angles formed by             residual
    pdb=" C   ALA     6 "            2.86e-02
    pdb=" N   ALA     7 "
    pdb=" CA  ALA     7 "
    pdb=" C   ALA     7 "
    pdb=" N   ALA     8 "
phi-psi angles formed by             residual
    pdb=" C   ALA     2 "            2.54e-02
    pdb=" N   ALA     3 "
    pdb=" CA  ALA     3 "
    pdb=" C   ALA     3 "
    pdb=" N   ALA     4 "
phi-psi angles formed by             residual
    pdb=" C   ALA     8 "            2.00e-02
    pdb=" N   ALA     9 "
    pdb=" CA  ALA     9 "
    pdb=" C   ALA     9 "
    pdb=" N   ALA    10 "
phi-psi angles formed by             residual
    pdb=" C   ALA     1 "            1.21e-02
    pdb=" N   ALA     2 "
    pdb=" CA  ALA     2 "
    pdb=" C   ALA     2 "
    pdb=" N   ALA     3 "
phi-psi angles formed by             residual
    pdb=" C   ALA     4 "            1.00e-02
    pdb=" N   ALA     5 "
    pdb=" CA  ALA     5 "
    pdb=" C   ALA     5 "
    pdb=" N   ALA     6 "
phi-psi angles formed by             residual
    pdb=" C   ALA     3 "            9.28e-03
    pdb=" N   ALA     4 "
    pdb=" CA  ALA     4 "
    pdb=" C   ALA     4 "
    pdb=" N   ALA     5 "
phi-psi angles formed by             residual
    pdb=" C   ALA     7 "            3.90e-03
    pdb=" N   ALA     8 "
    pdb=" CA  ALA     8 "
    pdb=" C   ALA     8 "
    pdb=" N   ALA     9 "

Ramachandran plot restraints (Emsley): 0
Sorted by residual:

Ramachandran plot restraints (emsley8k): 0
Sorted by residual:

Ramachandran plot restraints (phi/psi/2): 0
Sorted by residual:

""")
Beispiel #9
0
def exercise_geo_output(mon_lib_srv, ener_lib):
  pdb_str = """\
CRYST1   18.879   16.714   25.616  90.00  90.00  90.00 P 1
ATOM      1  N   ALA     1      13.515   7.809  20.095  1.00  0.00           N
ATOM      2  CA  ALA     1      13.087   6.532  19.536  1.00  0.00           C
ATOM      3  C   ALA     1      11.716   6.653  18.880  1.00  0.00           C
ATOM      4  O   ALA     1      11.425   5.972  17.896  1.00  0.00           O
ATOM      5  CB  ALA     1      13.065   5.461  20.616  1.00  0.00           C
ATOM      6  N   ALA     2      10.876   7.524  19.431  1.00  0.00           N
ATOM      7  CA  ALA     2       9.535   7.735  18.900  1.00  0.00           C
ATOM      8  C   ALA     2       9.565   8.647  17.678  1.00  0.00           C
ATOM      9  O   ALA     2       8.787   8.471  16.741  1.00  0.00           O
ATOM     10  CB  ALA     2       8.626   8.316  19.973  1.00  0.00           C
ATOM     11  N   ALA     3      10.469   9.622  17.697  1.00  0.00           N
ATOM     12  CA  ALA     3      10.606  10.565  16.593  1.00  0.00           C
ATOM     13  C   ALA     3      11.132   9.871  15.340  1.00  0.00           C
ATOM     14  O   ALA     3      10.687  10.157  14.228  1.00  0.00           O
ATOM     15  CB  ALA     3      11.520  11.714  16.987  1.00  0.00           C
ATOM     16  N   ALA     4      12.081   8.960  15.530  1.00  0.00           N
ATOM     17  CA  ALA     4      12.656   8.209  14.421  1.00  0.00           C
ATOM     18  C   ALA     4      11.624   7.266  13.812  1.00  0.00           C
ATOM     19  O   ALA     4      11.570   7.090  12.595  1.00  0.00           O
ATOM     20  CB  ALA     4      13.879   7.432  14.883  1.00  0.00           C
ATOM     21  N   ALA     5      10.805   6.663  14.669  1.00  0.00           N
ATOM     22  CA  ALA     5       9.753   5.761  14.218  1.00  0.00           C
ATOM     23  C   ALA     5       8.662   6.528  13.481  1.00  0.00           C
ATOM     24  O   ALA     5       8.107   6.045  12.494  1.00  0.00           O
ATOM     25  CB  ALA     5       9.165   5.000  15.396  1.00  0.00           C
ATOM     26  N   ALA     6       8.360   7.728  13.967  1.00  0.00           N
ATOM     27  CA  ALA     6       7.358   8.580  13.338  1.00  0.00           C
ATOM     28  C   ALA     6       7.860   9.106  11.998  1.00  0.00           C
ATOM     29  O   ALA     6       7.078   9.322  11.072  1.00  0.00           O
ATOM     30  CB  ALA     6       6.986   9.732  14.257  1.00  0.00           C
ATOM     31  N   ALA     7       9.169   9.311  11.903  1.00  0.00           N
ATOM     32  CA  ALA     7       9.781   9.787  10.668  1.00  0.00           C
ATOM     33  C   ALA     7       9.912   8.655   9.655  1.00  0.00           C
ATOM     34  O   ALA     7       9.905   8.886   8.446  1.00  0.00           O
ATOM     35  CB  ALA     7      11.141  10.405  10.952  1.00  0.00           C
ATOM     36  N   ALA     8      10.030   7.429  10.157  1.00  0.00           N
ATOM     37  CA  ALA     8      10.152   6.258   9.297  1.00  0.00           C
ATOM     38  C   ALA     8       8.788   5.809   8.786  1.00  0.00           C
ATOM     39  O   ALA     8       8.667   5.312   7.666  1.00  0.00           O
ATOM     40  CB  ALA     8      10.839   5.124  10.041  1.00  0.00           C
ATOM     41  N   ALA     9       7.762   5.988   9.613  1.00  0.00           N
ATOM     42  CA  ALA     9       6.405   5.603   9.243  1.00  0.00           C
ATOM     43  C   ALA     9       5.816   6.576   8.228  1.00  0.00           C
ATOM     44  O   ALA     9       5.000   6.195   7.389  1.00  0.00           O
ATOM     45  CB  ALA     9       5.521   5.526  10.478  1.00  0.00           C
ATOM     46  N   ALA    10       6.235   7.835   8.309  1.00  0.00           N
ATOM     47  CA  ALA    10       5.751   8.864   7.397  1.00  0.00           C
ATOM     48  C   ALA    10       6.434   8.760   6.038  1.00  0.00           C
ATOM     49  O   ALA    10       5.773   8.734   5.000  1.00  0.00           O
ATOM     50  CB  ALA    10       5.966  10.246   7.995  1.00  0.00           C
TER
END
"""
  pdb_inp = iotbx.pdb.input(source_info="peptide",lines=flex.split_lines(pdb_str))
  hierarchy = pdb_inp.construct_hierarchy()
  atoms = hierarchy.atoms()
  sites_cart = atoms.extract_xyz()
  params = ramachandran.master_phil.fetch().extract()
  params.rama_potential = "emsley"
  rama_manager = ramachandran.ramachandran_manager(
      hierarchy, params, StringIO())
  out = StringIO()
  rama_manager.show_sorted(
      by_value="residual",
      sites_cart=sites_cart,
      site_labels=[a.id_str() for a in atoms],
      f=out)
  gv = out.getvalue()
  # print out.getvalue()
  # STOP()
  assert not show_diff(gv, """\
Ramachandran plot restraints (Oldfield): 0
Sorted by residual:

Ramachandran plot restraints (Emsley): 8
Sorted by residual:
phi-psi angles formed by             residual
    pdb=" C   ALA     7 "            1.53e+01
    pdb=" N   ALA     8 "
    pdb=" CA  ALA     8 "
    pdb=" C   ALA     8 "
    pdb=" N   ALA     9 "
phi-psi angles formed by             residual
    pdb=" C   ALA     1 "            1.52e+01
    pdb=" N   ALA     2 "
    pdb=" CA  ALA     2 "
    pdb=" C   ALA     2 "
    pdb=" N   ALA     3 "
phi-psi angles formed by             residual
    pdb=" C   ALA     6 "            1.20e+01
    pdb=" N   ALA     7 "
    pdb=" CA  ALA     7 "
    pdb=" C   ALA     7 "
    pdb=" N   ALA     8 "
phi-psi angles formed by             residual
    pdb=" C   ALA     2 "            1.14e+01
    pdb=" N   ALA     3 "
    pdb=" CA  ALA     3 "
    pdb=" C   ALA     3 "
    pdb=" N   ALA     4 "
phi-psi angles formed by             residual
    pdb=" C   ALA     8 "            1.06e+01
    pdb=" N   ALA     9 "
    pdb=" CA  ALA     9 "
    pdb=" C   ALA     9 "
    pdb=" N   ALA    10 "
phi-psi angles formed by             residual
    pdb=" C   ALA     4 "            1.06e+01
    pdb=" N   ALA     5 "
    pdb=" CA  ALA     5 "
    pdb=" C   ALA     5 "
    pdb=" N   ALA     6 "
phi-psi angles formed by             residual
    pdb=" C   ALA     3 "            1.03e+01
    pdb=" N   ALA     4 "
    pdb=" CA  ALA     4 "
    pdb=" C   ALA     4 "
    pdb=" N   ALA     5 "
phi-psi angles formed by             residual
    pdb=" C   ALA     5 "            7.58e+00
    pdb=" N   ALA     6 "
    pdb=" CA  ALA     6 "
    pdb=" C   ALA     6 "
    pdb=" N   ALA     7 "

""")

  params.rama_potential = "oldfield"
  rama_manager = ramachandran.ramachandran_manager(
      hierarchy, params, StringIO())
  out = StringIO()
  rama_manager.show_sorted(
      by_value="residual",
      sites_cart=sites_cart,
      site_labels=[a.id_str() for a in atoms],
      f=out)
  gv = out.getvalue()
  assert not show_diff(gv, """\
Ramachandran plot restraints (Oldfield): 8
Sorted by residual:
phi-psi angles formed by             residual
    pdb=" C   ALA     5 "            3.46e-02
    pdb=" N   ALA     6 "
    pdb=" CA  ALA     6 "
    pdb=" C   ALA     6 "
    pdb=" N   ALA     7 "
phi-psi angles formed by             residual
    pdb=" C   ALA     6 "            2.86e-02
    pdb=" N   ALA     7 "
    pdb=" CA  ALA     7 "
    pdb=" C   ALA     7 "
    pdb=" N   ALA     8 "
phi-psi angles formed by             residual
    pdb=" C   ALA     2 "            2.54e-02
    pdb=" N   ALA     3 "
    pdb=" CA  ALA     3 "
    pdb=" C   ALA     3 "
    pdb=" N   ALA     4 "
phi-psi angles formed by             residual
    pdb=" C   ALA     8 "            2.00e-02
    pdb=" N   ALA     9 "
    pdb=" CA  ALA     9 "
    pdb=" C   ALA     9 "
    pdb=" N   ALA    10 "
phi-psi angles formed by             residual
    pdb=" C   ALA     1 "            1.21e-02
    pdb=" N   ALA     2 "
    pdb=" CA  ALA     2 "
    pdb=" C   ALA     2 "
    pdb=" N   ALA     3 "
phi-psi angles formed by             residual
    pdb=" C   ALA     4 "            1.00e-02
    pdb=" N   ALA     5 "
    pdb=" CA  ALA     5 "
    pdb=" C   ALA     5 "
    pdb=" N   ALA     6 "
phi-psi angles formed by             residual
    pdb=" C   ALA     3 "            9.28e-03
    pdb=" N   ALA     4 "
    pdb=" CA  ALA     4 "
    pdb=" C   ALA     4 "
    pdb=" N   ALA     5 "
phi-psi angles formed by             residual
    pdb=" C   ALA     7 "            3.90e-03
    pdb=" N   ALA     8 "
    pdb=" CA  ALA     8 "
    pdb=" C   ALA     8 "
    pdb=" N   ALA     9 "

Ramachandran plot restraints (Emsley): 0
Sorted by residual:

""")