def test_3():
  """ test for command-line tool iotbx.unique_with_biomt"""
  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)
  pdb_str = model.model_as_pdb()
  fname = 'tst_reduce_model_with_biomt_test3.pdb'
  with open(fname, 'w') as f:
    f.write(pdb_str)
  assert os.path.isfile(fname)

  cmd = "iotbx.unique_with_biomt %s" % fname
  print(cmd)
  easy_run.call(cmd)
  res_fname = 'tst_reduce_model_with_biomt_test3_unique_biomt_000.cif'
  assert_lines_in_file(res_fname, """
      ATOM 1 N . LYS 0 151 ? 72.74200 43.65400 193.22800 14.010 14.01000 N ? A ? 1 1""")
  assert_lines_in_file(res_fname, """
      _pdbx_struct_assembly_gen.asym_id_list
       1 (1-9) A""")

  cmd = "iotbx.unique_with_biomt %s chain_id_to_leave='C' output.serial=1" % fname
  print(cmd)
  easy_run.call(cmd)
  res_fname = 'tst_reduce_model_with_biomt_test3_unique_biomt_001.cif'
  assert_lines_in_file(res_fname, """
      ATOM 1 N . LYS C 151 ? 186.74500 185.38200 236.77300 14.010 14.01000 N ? A ? 1 1""")
  assert_lines_in_file(res_fname, """
      _pdbx_struct_assembly_gen.asym_id_list
       1 (1-9) A""")
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)
Example #3
0
def run(args):
    assert len(args) == 1
    # Read file into pdb_input class
    inp = iotbx.pdb.input(file_name=args[0])

    # create a model manager
    # Catch Sorry about MTRIX here.
    model = mmtbx.model.manager(
        model_input=inp,
        restraint_objects=
        None,  # these are ligands if any [('fname', cif_object), ()]
        log=null_out(),
    )
    print("=" * 80)
    print("number of atoms with MTRIX multiplication:",
          model.get_number_of_atoms())
    show_ss_counts(model)

    # Expand with BIOMT if needed. MTRIX are already expanded by default
    # Catch case when both MTRIX and BIOMT present, or other Sorry raised by
    # BIOMT handling.
    # LIMITATION: this should be done before any selections made on model.manager
    double_counter = 0
    try:
        model.expand_with_BIOMT_records()
    except Sorry as e:
        if str(e).startswith("Model has been already expanded"):
            double_counter += 1
    print("=" * 80)
    print("number of atoms with BIOMT multiplication:",
          model.get_number_of_atoms())
    show_ss_counts(model)

    # Get default params
    pdb_int_params = mmtbx.model.manager.get_default_pdb_interpretation_params(
    )
    # Set whatever you want
    pdb_int_params.pdb_interpretation.secondary_structure.protein.enabled = True
    pdb_int_params.pdb_interpretation.ncs_search.enabled = True
    pdb_int_params.pdb_interpretation.ncs_search.residue_match_radius = 999
    pdb_int_params.pdb_interpretation.clash_guard.nonbonded_distance_threshold = None

    #pdb_int_params.pdb_interpretation.nonbonded_weight = None

    # set the params. Note, that GRM would be dropped, even if it was already
    # constructed. In this example it is not yet constructed.
    model.set_pdb_interpretation_params(params=pdb_int_params)
    grm = model.get_restraints_manager()

    # Not clear which one should be used at the moment
    gs = model.geometry_statistics()
    gs.show()
    # The second way
    msi = model.get_model_statistics_info()
    msi.show_remark_3()
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)
Example #5
0
def exercise_06():
    """ Test that when building bio-molecule and then finding NCS relations
  from it, we get the same rotation and translation"""
    pdb_strings = [pdb_str_4, pdb_str_5]
    for method, pdb_string in enumerate(pdb_strings):
        pdb_inp = pdb.input(source_info=None, lines=pdb_string)
        model = mmtbx.model.manager(pdb_inp, expand_with_mtrix=False)
        crystal_symmetry = model.crystal_symmetry()
        # The exact transforms from pdb_string
        r1_expected = matrix.sqr([
            0.309017, -0.951057, 0.0, 0.951057, 0.309017, -0.0, 0.0, 0.0, 1.0
        ])
        r2_expected = matrix.sqr([
            -0.809017, -0.587785, 0.0, 0.587785, -0.809017, -0.0, 0.0, 0.0, 1.0
        ])
        t1_expected = matrix.col([0, 0, 7])
        t2_expected = matrix.col([0, 0, 0])
        # Look at biomt records retrieved from PDB file
        if method == 0:
            rec = model._model_input.process_BIOMT_records()
            model.expand_with_BIOMT_records()
            h = model.get_hierarchy()
        else:
            rec = model._model_input.process_MTRIX_records()
            model.expand_with_MTRIX_records()
            h = model.get_hierarchy()
        r1 = rec.r[1]
        r2 = rec.r[2]
        t1 = rec.t[1]
        t2 = rec.t[2]
        assert approx_equal(r1, r1_expected, eps=0.001)
        assert approx_equal(t1, t1_expected, eps=0.1)
        assert approx_equal(r2, r2_expected, eps=0.001)
        assert approx_equal(t2, t2_expected, eps=0.1)
        # Look at the rotation and translation found by the NCS search
        s = h.as_pdb_string(crystal_symmetry=crystal_symmetry)
        ncs_obj = ncs.input(hierarchy=pdb.input(source_info=None,
                                                lines=s).construct_hierarchy())
        nrgl = ncs_obj.get_ncs_restraints_group_list()
        assert approx_equal(r1_expected, nrgl[0].copies[0].r, eps=0.001)
        assert approx_equal(t1_expected, nrgl[0].copies[0].t, eps=0.1)
        assert approx_equal(r2_expected, nrgl[0].copies[1].r, eps=0.001)
        assert approx_equal(t2_expected, nrgl[0].copies[1].t, eps=0.1)
        if method == 0:
            assert nrgl.get_n_groups() == 1
        elif method == 1:
            assert nrgl.get_n_groups() == 2
Example #6
0
def exercise_biomt():
  inp = iotbx.pdb.input(lines=biomt_txt+ss_txt+atoms_txt, source_info=None)
  model = mmtbx.model.manager(
    model_input = inp)
  assert model.get_number_of_atoms() == 300, model.get_number_of_atoms()
  assert model.get_hierarchy().atoms_size() == 300
  assert model.get_xray_structure().scatterers().size() == 300
  ss_ann = model.get_ss_annotation()
  assert ss_ann.get_n_helices() == 2
  assert ss_ann.get_n_sheets() == 1
  model.expand_with_BIOMT_records()
  assert model.get_number_of_atoms() == 900, model.get_number_of_atoms()
  assert model.get_hierarchy().atoms_size() == 900
  assert model.get_xray_structure().scatterers().size() == 900, model.get_xray_structure().scatterers().size()
  ss_ann = model.get_ss_annotation()
  assert ss_ann.get_n_helices() == 6
  assert ss_ann.get_n_sheets() == 3
Example #7
0
def exercise_04():
    """Test MTRIX record processing"""
    expected = """\
CRYST1   10.000   10.000   10.000  90.00  90.00  90.00 P 1
SCALE1      0.100000  0.000000  0.000000        0.00000
SCALE2      0.000000  0.100000  0.000000        0.00000
SCALE3      0.000000  0.000000  0.100000        0.00000
ATOM      1   N  ILE A  40       1.000   1.000   1.000  1.00162.33           C
ATOM      2  CA  LEU A  40      94.618  -5.253  91.582  1.00 87.10           C
TER
ATOM      3   C  ARG B  40      62.395  51.344  80.786  1.00107.25           C
TER
HETATM    4  C1  EDO A  40      39.954  51.526  72.372  0.33 60.93           C
ATOM      1   N  ILE C  40       1.000  -1.000   1.000  1.00162.33           C
ATOM      2  CA  LEU C  40      94.618 -91.582  -5.253  1.00 87.10           C
TER
ATOM      3   C  ARG D  40      62.395 -80.786  51.344  1.00107.25           C
TER
HETATM    4  C1  EDO C  40      39.954 -72.372  51.526  0.33 60.93           C
ATOM      1   N  ILE E  40       1.000   1.000  -1.000  1.00162.33           C
ATOM      2  CA  LEU E  40      91.582  -5.253 -94.618  1.00 87.10           C
TER
ATOM      3   C  ARG F  40      80.786  51.344 -62.395  1.00107.25           C
TER
HETATM    4  C1  EDO E  40      72.372  51.526 -39.954  0.33 60.93           C
ATOM      1   N  ILE G  40      -1.000   1.000   1.000  1.00162.33           C
ATOM      2  CA  LEU G  40       5.253  94.618  91.582  1.00 87.10           C
TER
ATOM      3   C  ARG H  40     -51.344  62.395  80.786  1.00107.25           C
TER
HETATM    4  C1  EDO G  40     -51.526  39.954  72.372  0.33 60.93           C
ATOM      1   N  ILE I  40       1.000   1.000  -1.000  1.00162.33           C
ATOM      2  CA  LEU I  40      91.582  -5.253 -94.618  1.00 87.10           C
TER
ATOM      3   C  ARG J  40      80.786  51.344 -62.395  1.00107.25           C
TER
HETATM    4  C1  EDO I  40      72.372  51.526 -39.954  0.33 60.93           C
ATOM      1   N  ILE K  40      -1.000   1.000  -1.000  1.00162.33           C
ATOM      2  CA  LEU K  40       5.253  91.582 -94.618  1.00 87.10           C
TER
ATOM      3   C  ARG L  40     -51.344  80.786 -62.395  1.00107.25           C
TER
HETATM    4  C1  EDO K  40     -51.526  72.372 -39.954  0.33 60.93           C
ATOM      1   N  ILE M  40      -0.366   1.366   1.000  1.00162.33           C
ATOM      2  CA  LEU M  40      51.858  79.315  91.582  1.00 87.10           C
TER
ATOM      3   C  ARG N  40     -13.268  79.708  80.786  1.00107.25           C
TER
HETATM    4  C1  EDO M  40     -24.646  60.364  72.372  0.33 60.93           C
ATOM      1   N  ILE O  40      -1.366   0.366   1.000  1.00162.33           C
ATOM      2  CA  LEU O  40     -42.760  84.568  91.582  1.00 87.10           C
TER
ATOM      3   C  ARG P  40     -75.663  28.364  80.786  1.00107.25           C
TER
HETATM    4  C1  EDO O  40     -64.600   8.838  72.372  0.33 60.93           C
ATOM      1   N  ILE Q  40       1.000   1.500   1.000  1.00162.33           C
ATOM      2  CA  LEU Q  40      94.618  -4.753  91.582  1.00 87.10           C
TER
ATOM      3   C  ARG R  40      62.395  51.844  80.786  1.00107.25           C
TER
HETATM    4  C1  EDO Q  40      39.954  52.026  72.372  0.33 60.93           C
ATOM      1   N  ILE S  40      -1.366   0.366   0.000  1.00162.33           C
ATOM      2  CA  LEU S  40     -42.760  84.568  90.582  1.00 87.10           C
TER
ATOM      3   C  ARG T  40     -75.663  28.364  79.786  1.00107.25           C
TER
HETATM    4  C1  EDO S  40     -64.600   8.838  71.372  0.33 60.93           C
END
"""
    pdb_inp = iotbx.pdb.input(source_info=None, lines=pdb_str_3)
    model = mmtbx.model.manager(pdb_inp, expand_with_mtrix=False)
    model.expand_with_BIOMT_records()
    assert not show_diff(expected, model.model_as_pdb())