Пример #1
0
def exercise_set_sites_cart_no_ncs():
    inp = iotbx.pdb.input(lines=pdb_str_5, source_info=None)
    model = mmtbx.model.manager(model_input=inp, expand_with_mtrix=False)
    model.search_for_ncs()
    nrgl = model.get_ncs_groups()
    nrgl._show()
    print('n model atoms:', model.get_number_of_atoms())
    print('n master atoms:', model.get_master_selection().count(True))
    print('n master atoms:', model.get_master_selection().iselection().size())
    print('n master atoms:', model.get_master_hierarchy().atoms_size())

    assert model.get_master_selection().count(True) ==\
        model.get_master_selection().iselection().size() ==\
        model.get_master_hierarchy().atoms_size()

    h = model.get_hierarchy()
    # Warning: here here mh is not deep-copy, therefore when we change atom coords
    # they are changing in model.get_hierarchy() as well
    mh = model.get_master_hierarchy()
    new_sites_cart = flex.vec3_double([(1.0, 1.0, 1.0)] * 42)
    mh.atoms().set_xyz(new_sites_cart)
    model.set_sites_cart_from_hierarchy(multiply_ncs=True)
    h = model.get_hierarchy()
    new_xyz = h.atoms().extract_xyz()
    # print('h sites:', list(new_xyz))
    # checking if setting went as supposed:
    for j in range(42):
        assert approx_equal(new_xyz[j], (1.0, 1.0, 1.0), eps=1e-4)
def test_2():
  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)
  model.search_for_ncs()
  model.setup_ncs_constraints_groups(filter_groups=True)
  assert model.ncs_constraints_present()
  assert not model.can_be_unique_with_biomt()
  assert "" == model.model_as_mmcif(try_unique_with_biomt=True)
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)
Пример #4
0
def exercise_set_sites_cart_ncs():
    """
  No extra atoms
  """
    inp = iotbx.pdb.input(lines=pdb_str_5, source_info=None)
    model = mmtbx.model.manager(model_input=inp)
    model.search_for_ncs()
    nrgl = model.get_ncs_groups()
    nrgl._show()
    print('n model atoms:', model.get_number_of_atoms())
    print('n master atoms:', model.get_master_selection().count(True))
    print('n master atoms:', model.get_master_selection().iselection().size())
    print('n master atoms:', model.get_master_hierarchy().atoms_size())

    assert model.get_master_selection().count(True) ==\
        model.get_master_selection().iselection().size() ==\
        model.get_master_hierarchy().atoms_size()

    h = model.get_hierarchy()
    # print('h sites:', list(h.atoms().extract_xyz()))

    # Warning: here here mh is not deep-copy, therefore when we change atom coords
    # they are changing in model.get_hierarchy() as well
    mh = model.get_master_hierarchy()
    new_sites_cart = flex.vec3_double([(1.0, 1.0, 1.0)] * 42)
    mh.atoms().set_xyz(new_sites_cart)
    model.set_sites_cart_from_hierarchy(multiply_ncs=True)
    h = model.get_hierarchy()
    new_xyz = h.atoms().extract_xyz()
    # print('h sites:', list(new_xyz))

    # checking if setting went as supposed:
    assert approx_equal(new_xyz[0], (1.0, 1.0, 1.0), eps=1e-4)
    assert approx_equal(
        new_xyz[42],
        (-0.6420293330506949, 1.2600792663765976, 7.999997229451341),
        eps=1e-4)
    assert approx_equal(
        new_xyz[84],
        (-1.396802536808536, -0.22123285934616377, 1.000000038694047),
        eps=1e-4)
    for i in range(3):
        for j in range(42):
            assert approx_equal(new_xyz[42 * i + j], new_xyz[42 * i], eps=1e-4)
Пример #5
0
def exercise_set_sites_cart_ncs_with_extra_atoms():
    inp = iotbx.pdb.input(lines=test_pdb_6, source_info=None)
    model = mmtbx.model.manager(model_input=inp)

    model.search_for_ncs()
    nrgl = model.get_ncs_groups()
    nrgl._show(brief=False)
    print('n model atoms:', model.get_number_of_atoms())
    print('n master atoms:', model.get_master_selection().count(True))
    print('n master atoms:', model.get_master_selection().iselection().size())
    print('n master isel:', list(model.get_master_selection().iselection()))
    print('n master atoms:', model.get_master_hierarchy().atoms_size())
    print('n master hierarchy:\n',
          model.get_master_hierarchy().as_pdb_string())

    # Note that "HETATM   32  C2  NDG H" and "HETATM   35  C2  NDG L"
    # don't belong to any master/copy
    assert not show_diff(
        model.get_master_hierarchy().as_pdb_string(), """\
ATOM      1  N   ASP H   5      91.286 -31.834  73.572  1.00 77.83           N
ATOM      2  CA  ASP H   5      90.511 -32.072  72.317  1.00 78.04           C
ATOM      3  C   ASP H   5      90.136 -30.762  71.617  1.00 77.70           C
ATOM      4  O   ASP H   5      89.553 -29.857  72.225  1.00 77.56           O
ATOM      5  N   THR H   6      91.286 -31.834  73.572  1.00 77.83           N
ATOM      6  CA  THR H   6      90.511 -32.072  72.317  1.00 78.04           C
TER
ATOM      7  N   GLY I 501      91.286 -31.834  73.572  1.00 77.83           N
ATOM      8  CA  GLY I 501      90.511 -32.072  72.317  1.00 78.04           C
ATOM      9  C   GLY I 501      90.136 -30.762  71.617  1.00 77.70           C
ATOM     10  O   GLY I 501      89.553 -29.857  72.225  1.00 77.56           O
TER
HETATM   31  C1  NDG H 640      91.286 -31.834  73.572  1.00 77.83           C
HETATM   32  C2  NDG H 640      91.286 -31.834  73.572  1.00 77.83           C
HETATM   35  C2  NDG L 646      61.028 -14.273  81.262  1.00 69.80           C
""")

    mh = model.get_master_hierarchy()
    # Note that atoms outside NCS are getting 2.0 as xyz
    new_sites_cart = flex.vec3_double(
        [(1.0, 1.0, 1.0), (1.0, 1.0, 1.0), (1.0, 1.0, 1.0), (1.0, 1.0, 1.0),
         (1.0, 1.0, 1.0), (1.0, 1.0, 1.0)] + [(3.0, 3.0, 3.0)] * 4 +
        [
            (1.0, 1.0, 1.0),  # <--- Note this atom belongs the first NCS group
            (2.0, 2.0, 2.0),
            (2.0, 2.0, 2.0)
        ])
    mh.atoms().set_xyz(new_sites_cart)
    # print('='*80)
    # print (mh.as_pdb_string())
    model.set_sites_cart_from_hierarchy(multiply_ncs=True)
    h = model.get_hierarchy()
    new_xyz = h.atoms().extract_xyz()
    # print(model.model_as_pdb())
    # print (list(new_xyz))

    assert approx_equal(new_xyz[31], (2.0, 2.0, 2.0), eps=1e-4)
    assert approx_equal(new_xyz[34], (2.0, 2.0, 2.0), eps=1e-4)

    assert approx_equal(new_xyz[0], (1.0, 1.0, 1.0), eps=1e-4)
    assert approx_equal(new_xyz[5], (1.0, 1.0, 1.0), eps=1e-4)
    assert approx_equal(new_xyz[6], (3.0, 3.0, 3.0), eps=1e-4)
    assert approx_equal(new_xyz[9], (3.0, 3.0, 3.0), eps=1e-4)

    assert nrgl.check_for_max_rmsd(sites_cart=new_xyz, chain_max_rmsd=0.0)

    for i in [[0, 1, 2, 3, 4, 5, 30], [10, 11, 12, 13, 14, 15, 32],
              [20, 21, 22, 23, 24, 25, 33]]:
        for j in i:
            assert approx_equal(new_xyz[j], new_xyz[i[0]], eps=1e-4)
    for i in [[6, 7, 8, 9], [16, 17, 18, 19], [26, 27, 28, 29]]:
        for j in i:
            assert approx_equal(new_xyz[j], new_xyz[i[0]], eps=1e-4)