Exemplo n.º 1
0
def exercise_bond_over_symmetry(mon_lib_srv, ener_lib):
    from cctbx.geometry_restraints.linking_class import linking_class
    origin_ids = linking_class()
    pdb_inp = iotbx.pdb.input(source_info=None, lines=raw_records9)
    params = mmtbx.model.manager.get_default_pdb_interpretation_params()
    params.pdb_interpretation.restraints_library.mcl = False
    model = mmtbx.model.manager(model_input=pdb_inp,
                                pdb_interpretation_params=params,
                                log=null_out(),
                                build_grm=True)
    grm = model.get_restraints_manager().geometry
    simple, asu = grm.get_all_bond_proxies()
    assert (simple.size(), asu.size()) == (29, 0)
    h = model.get_hierarchy()
    proxy = geometry_restraints.bond_simple_proxy(
        i_seqs=(32, 4),
        distance_ideal=2.9,
        weight=400,
        origin_id=origin_ids.get_origin_id('hydrogen bonds'))
    proxy2 = geometry_restraints.bond_simple_proxy(
        i_seqs=(32, 24),
        distance_ideal=2.9,
        weight=400,
        origin_id=origin_ids.get_origin_id('hydrogen bonds'))
    grm.add_new_bond_restraints_in_place(proxies=[proxy, proxy2],
                                         sites_cart=h.atoms().extract_xyz())
    simple, asu = grm.get_all_bond_proxies()
    assert (simple.size(), asu.size()) == (30, 2)

    sites_cart = h.atoms().extract_xyz()
    site_labels = model.get_xray_structure().scatterers().extract_labels()
    pair_proxies = grm.pair_proxies(flags=None, sites_cart=sites_cart)

    out = StringIO()
    pair_proxies.bond_proxies.show_sorted(by_value="residual",
                                          sites_cart=sites_cart,
                                          site_labels=site_labels,
                                          f=out,
                                          prefix="")
    outtxt = out.getvalue()
    # print(outtxt)
    #
    # Not clear why ZN-NE2 bond adds as 2 bonds.
    assert_lines_in_text(
        outtxt, """\
bond pdb="ZN    ZN A   8 "
     pdb=" NE2 HIS B 304 "
  ideal  model  delta    sigma   weight residual sym.op.
  2.900  2.969 -0.069 5.00e-02 4.00e+02 1.92e+00 -x-1/2,y+1/2,-z+3/4
    """)
    assert_lines_in_text(
        outtxt, """\
bond pdb=" NE2 HIS B 304 "
     pdb="ZN    ZN A   8 "
  ideal  model  delta    sigma   weight residual sym.op.
  2.900  2.969 -0.069 5.00e-02 4.00e+02 1.92e+00 -x-1/2,y-1/2,-z+3/4
    """)
Exemplo n.º 2
0
def check_cmd_line():
  cmd = "mmtbx.rama_z %s" % fname
  r = easy_run.fully_buffered(cmd)
  stdout = r.stdout_lines
  # print ("\n".join(stdout))
  assert_lines_in_text("\n".join(stdout), """\
      whole: -0.40 (0.66), residues: 134
      helix:  None (None), residues: 0
      sheet: -0.06 (0.58), residues: 63
      loop : -0.36 (0.69), residues: 71""")
Exemplo n.º 3
0
def check_cmd_line_cryst1(prefix="tst_rama_z_01_cryst1"):
    with open(fname, 'r') as f:
        pdbtext = f.read()
    with open(prefix + '.pdb', 'w') as f:
        f.write(cryst1)
        f.write(pdbtext)
    cmd = "mmtbx.rama_z %s" % (prefix + '.pdb')
    r = easy_run.fully_buffered(cmd)
    assert r.return_code == 0
    stdout = r.stdout_lines
    # print ("\n".join(stdout))
    assert_lines_in_text(
        "\n".join(stdout), """\
      whole: -0.40 (0.66), residues: 134
      helix:  None (None), residues: 0
      sheet: -0.06 (0.58), residues: 63
      loop : -0.36 (0.69), residues: 71""")
def test_1():
  inp = iotbx.pdb.input(source_info=None, lines=pdb_str_0)
  model = mmtbx.model.manager(model_input=inp)
  model.expand_with_BIOMT_records()
  model = shift_and_box_model(model)

  sel = model.selection("chain '0' or chain 'C' or chain 'F' or chain 'I' or chain 'L' or chain 'O' or chain 'R' or chain 'U' or chain 'X'")
  model = model.select(sel)

  model.search_for_ncs()
  model.setup_ncs_constraints_groups(filter_groups=True)
  n1 = model.get_number_of_atoms()
  assert n1 == 648, n1
  assert model.ncs_constraints_present()
  nrgl = model.get_ncs_groups()
  assert len(nrgl[0].master_iselection) == 72
  assert len(nrgl[0].copies) == 8
  # nrgl._show()
  # print (model.can_be_unique_with_biomt())
  cif_txt = model.model_as_mmcif(try_unique_with_biomt=True)
  # print (cif_txt)
  assert_lines_in_text(cif_txt, """
loop_
  _pdbx_struct_assembly_gen.assembly_id
  _pdbx_struct_assembly_gen.oper_expression
  _pdbx_struct_assembly_gen.asym_id_list
   1 (1-9) A""")
  assert_lines_in_text(cif_txt, """
loop_
  _pdbx_struct_assembly.id
  _pdbx_struct_assembly.details
  _pdbx_struct_assembly.method_details
  _pdbx_struct_assembly.oligomeric_details
  _pdbx_struct_assembly.oligomeric_count
   1 'Symmetry assembly' ? ? ? """)
  assert_lines_in_text(cif_txt, """
  _pdbx_struct_oper_list.vector[1]
  _pdbx_struct_oper_list.vector[2]
  _pdbx_struct_oper_list.vector[3]
   1 'point symmetry operation' ? ? 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0""")


  inp = iotbx.pdb.input(source_info=None, lines=cif_txt)
  m2 = mmtbx.model.manager(model_input=inp)
  n2_1 = m2.get_number_of_atoms()
  assert n2_1 == 72
  m2.expand_with_BIOMT_records()
  n2_2 = m2.get_number_of_atoms()
  # print (n1, n2)
  assert n1 == n2_2, "%d, %d" % (n1, n2)
Exemplo n.º 5
0
def exercise_bond_over_symmetry_2(mon_lib_srv, ener_lib):
    """ This test is to illustrate that bond over symmetry actually
  adds 2 proxies.
  """
    from cctbx.geometry_restraints.linking_class import linking_class
    origin_ids = linking_class()
    pdb_inp = iotbx.pdb.input(source_info=None, lines=raw_records10)
    params = mmtbx.model.manager.get_default_pdb_interpretation_params()
    params.pdb_interpretation.restraints_library.mcl = False
    model = mmtbx.model.manager(model_input=pdb_inp,
                                pdb_interpretation_params=params,
                                log=null_out(),
                                build_grm=True)
    grm = model.get_restraints_manager().geometry
    simple, asu = grm.get_all_bond_proxies()
    assert (simple.size(), asu.size()) == (0, 0)

    h = model.get_hierarchy()
    sites_cart = h.atoms().extract_xyz()
    site_labels = model.get_xray_structure().scatterers().extract_labels()
    pair_proxies = grm.pair_proxies(flags=None, sites_cart=sites_cart)

    out = StringIO()
    pair_proxies.bond_proxies.show_sorted(by_value="residual",
                                          sites_cart=sites_cart,
                                          site_labels=site_labels,
                                          f=out,
                                          prefix="")
    outtxt = out.getvalue()
    # print(outtxt)

    proxy = geometry_restraints.bond_simple_proxy(
        i_seqs=(0, 1),
        distance_ideal=2.9,
        weight=400,
        origin_id=origin_ids.get_origin_id('hydrogen bonds'))
    grm.add_new_bond_restraints_in_place(proxies=[proxy],
                                         sites_cart=h.atoms().extract_xyz())
    simple, asu = grm.get_all_bond_proxies()
    # print(simple.size(), asu.size())
    assert (simple.size(), asu.size()) == (0, 2)

    sites_cart = h.atoms().extract_xyz()
    site_labels = model.get_xray_structure().scatterers().extract_labels()
    pair_proxies = grm.pair_proxies(flags=None, sites_cart=sites_cart)

    out = StringIO()
    pair_proxies.bond_proxies.show_sorted(by_value="residual",
                                          sites_cart=sites_cart,
                                          site_labels=site_labels,
                                          f=out,
                                          prefix="")
    outtxt = out.getvalue()
    # print(outtxt)
    assert_lines_in_text(
        outtxt, """\
bond pdb=" CA  HIS A   2 "
     pdb=" N   MET A   1 "
  ideal  model  delta    sigma   weight residual sym.op.
  2.900  1.998  0.902 5.00e-02 4.00e+02 3.25e+02 x,y+1,z
bond pdb=" N   MET A   1 "
     pdb=" CA  HIS A   2 "
  ideal  model  delta    sigma   weight residual sym.op.
  2.900  1.998  0.902 5.00e-02 4.00e+02 3.25e+02 x,y-1,z
    """)

    es = grm.energies_sites(sites_cart=sites_cart, compute_gradients=True)
    out = StringIO()
    es.show(f=out)
    outtxt = out.getvalue()
    # print(outtxt)
    # do for x coordinate
    # ATOM      1  N   MET A   1       9.821   1.568   5.000  1.00 66.07           N
    # ATOM      2  CA  HIS A   2       9.946  12.171   5.357  1.00 66.55           C

    # calculation is from geometry_restraints/bond.h: gradient_0()
    # weight * 2 * delta_slack * d_distance_d_site_0(epsilon);
    # print("X gradient:", 400*2*0.902*(9.946-9.821)) # 90
    # Note that n=2 but residual sum is 325.349. 349 is chopped off in rounding in
    # cctbx/geometry_restraints/__init__py, def _bond_show_sorted_impl(...)
    # where %6.2e is used. in cctbx/geometry_restraints/energies.py: def show()
    # %.6g is used which is showing more numbers.
    assert_lines_in_text(outtxt, """\
      bond_residual_sum (n=2): 325.349""")
    # print("Gradients:", list(es.gradients))
    # Seems that gradients were splitted in half (note the X gradient is 90 8 lines above)
    assert approx_equal(
        list(es.gradients),
        [(45.135801792665134, -708.451544937652, 128.90784991984805),
         (-45.13580179266516, 708.4515449376522, -128.90784991984813)])
Exemplo n.º 6
0
def exercise_add_when_restraint_is_present():
    """
  Trying to 'add' values for existing covalent
  """

    edits = """
  geometry_restraints.edits {
    excessive_bond_distance_limit = 10
    bond {
      action = *add delete change
      atom_selection_1 = name N
      atom_selection_2 = name CA
      symmetry_operation = None
      distance_ideal = 4
      sigma = 0.5
      slack = None
    }
    angle {
      action = *add delete change
      atom_selection_1 = name N
      atom_selection_2 = name CA
      atom_selection_3 = name C
      angle_ideal = 130
      sigma = 3
    }
    dihedral {
      action = *add delete change
      atom_selection_1 = name N
      atom_selection_2 = name CA
      atom_selection_3 = name CB
      atom_selection_4 = name CG
      angle_ideal = 90
      sigma = 10
      periodicity = 1
    }
  }
  """
    def_params = mmtbx.model.manager.get_default_pdb_interpretation_scope()
    edits_phil = iotbx.phil.parse(edits)
    working_phil = def_params.fetch(edits_phil)
    params = working_phil.extract()
    inp = iotbx.pdb.input(lines=raw_records1, source_info=None)
    model = mmtbx.model.manager(model_input=inp)
    geo = model.restraints_as_geo(force=True)
    print(geo)
    assert_lines_in_text(geo, """Bond restraints: 8""")
    assert_lines_in_text(
        geo, """bond pdb=" N   LYS A 135 "
      pdb=" CA  LYS A 135 "
      ideal  model  delta    sigma   weight residual
      1.458  1.477 -0.019 1.90e-02 2.77e+03 1.01e+00""")
    assert_lines_in_text(
        geo, """angle pdb=" N   LYS A 135 "
      pdb=" CA  LYS A 135 "
      pdb=" C   LYS A 135 "
      ideal   model   delta    sigma   weight residual
      111.00  107.25    3.75 2.80e+00 1.28e-01 1.79e+00""")
    assert_lines_in_text(
        geo, """dihedral pdb=" N   LYS A 135 "
      pdb=" CA  LYS A 135 "
      pdb=" CB  LYS A 135 "
      pdb=" CG  LYS A 135 "
      ideal   model   delta sinusoidal    sigma   weight residual
     -60.00  -54.19   -5.81     3      1.50e+01 4.44e-03 2.18e-01""")

    # Now with modifications
    print("*" * 80)
    model2 = mmtbx.model.manager(model_input=inp,
                                 pdb_interpretation_params=params)
    geo2 = model2.restraints_as_geo(force=True)
    print(geo2)
    # !!! Note that bond-restraint was applied: one less standard, one more
    # nonstandard.
    assert_lines_in_text(geo2, """Bond restraints: 7""")
    assert_lines_in_text(
        geo2, """User supplied restraints: 1
      Sorted by residual:
      bond pdb=" N   LYS A 135 "
           pdb=" CA  LYS A 135 "
      ideal  model  delta    sigma   weight residual
      4.000  1.477  2.523 5.00e-01 4.00e+00 2.55e+01""")
    #
    # Angles and dihedrals were not changed...
    assert_lines_in_text(
        geo2, """angle pdb=" N   LYS A 135 "
      pdb=" CA  LYS A 135 "
      pdb=" C   LYS A 135 "
      ideal   model   delta    sigma   weight residual
      111.00  107.25    3.75 2.80e+00 1.28e-01 1.79e+00""")
    assert_lines_in_text(
        geo2, """dihedral pdb=" N   LYS A 135 "
      pdb=" CA  LYS A 135 "
      pdb=" CB  LYS A 135 "
      pdb=" CG  LYS A 135 "
      ideal   model   delta sinusoidal    sigma   weight residual
     -60.00  -54.19   -5.81     3      1.50e+01 4.44e-03 2.18e-01""")