Ejemplo n.º 1
0
def tst_02():
    # Test for remove_clashes
    import mmtbx.model
    from mmtbx.clashes import remove_clashes
    import iotbx.pdb
    import sys
    pdb_inp = iotbx.pdb.input(lines=pdb_poor.splitlines(), source_info='None')
    model = mmtbx.model.manager(model_input=pdb_inp, )

    model.set_log(log=null_out())

    print "\n", "-" * 79
    print " Summary of input model statistics "
    print "-" * 79
    model.get_restraints_manager()
    geometry = model.geometry_statistics()
    geometry.show(log=sys.stdout)

    rc = remove_clashes(model=model)

    print "\n", "-" * 79
    print "Starting residues: %d " % (
        rc.model.get_hierarchy().overall_counts().n_residues)
    print "Side-chains removed: %d    Residues removed: %d" % (
        rc.side_chains_removed, rc.residues_removed)
    print "Final residues: %d " % (
        rc.new_model.get_hierarchy().overall_counts().n_residues)

    rc.new_model.set_log(log=null_out())
    rc.new_model.get_restraints_manager()
    new_geometry = rc.new_model.geometry_statistics()
    new_geometry.show(log=sys.stdout)
    assert rc.side_chains_removed == 1
    assert rc.residues_removed == 0
Ejemplo n.º 2
0
def exercise_allowed_outliers_emsley_filling():
    file_name = libtbx.env.find_in_repositories(
        relative_path="phenix_regression/pdb/3ifk.pdb", test=os.path.isfile)
    if (file_name is None):
        print("Skipping test.")
        return
    params = mmtbx.model.manager.get_default_pdb_interpretation_params()
    params.pdb_interpretation.ramachandran_plot_restraints.enabled = True
    params.pdb_interpretation.ramachandran_plot_restraints.favored = "oldfield"
    params.pdb_interpretation.ramachandran_plot_restraints.allowed = "emsley"
    params.pdb_interpretation.ramachandran_plot_restraints.outlier = None
    params.pdb_interpretation.ramachandran_plot_restraints.inject_emsley8k_into_oldfield_favored = False

    pdb_inp = iotbx.pdb.input(file_name=file_name)
    model = mmtbx.model.manager(model_input=pdb_inp,
                                pdb_interpretation_params=params,
                                log=null_out(),
                                build_grm=True)
    grm = model.get_restraints_manager().geometry
    assert grm.ramachandran_manager.get_n_proxies() == 167
    assert grm.ramachandran_manager.get_n_oldfield_proxies() == 164
    assert grm.ramachandran_manager.get_n_emsley_proxies() == 3
    params.pdb_interpretation.ramachandran_plot_restraints.enabled = True
    params.pdb_interpretation.ramachandran_plot_restraints.favored = "oldfield"
    params.pdb_interpretation.ramachandran_plot_restraints.allowed = None
    params.pdb_interpretation.ramachandran_plot_restraints.outlier = None
    model.set_pdb_interpretation_params(params)
    model.process_input_model(make_restraints=True)
    grm = model.get_restraints_manager().geometry
    nprox = grm.ramachandran_manager.get_n_proxies()
    assert nprox == 164
    assert grm.ramachandran_manager.get_n_oldfield_proxies() == 164
    assert grm.ramachandran_manager.get_n_emsley_proxies() == 0
Ejemplo n.º 3
0
def exercise_allowed_outliers_emsley_filling():
  file_name = libtbx.env.find_in_repositories(
    relative_path="phenix_regression/pdb/3ifk.pdb",
    test=os.path.isfile)
  if (file_name is None):
    print("Skipping test.")
    return
  params = mmtbx.model.manager.get_default_pdb_interpretation_params()
  params.pdb_interpretation.peptide_link.ramachandran_restraints = True
  params.pdb_interpretation.peptide_link.restrain_rama_outliers = False
  params.pdb_interpretation.peptide_link.restrain_rama_allowed = True
  params.pdb_interpretation.peptide_link.restrain_allowed_outliers_with_emsley=True
  pdb_inp = iotbx.pdb.input(file_name=file_name)
  model = mmtbx.model.manager(
      model_input=pdb_inp,
      pdb_interpretation_params=params,
      log=null_out())
  grm = model.get_restraints_manager().geometry
  assert grm.ramachandran_manager.get_n_proxies() == 170
  assert grm.ramachandran_manager.get_n_oldfield_proxies() == 167
  assert grm.ramachandran_manager.get_n_emsley_proxies() == 3

  params.pdb_interpretation.peptide_link.ramachandran_restraints = True
  params.pdb_interpretation.peptide_link.restrain_rama_outliers = False
  params.pdb_interpretation.peptide_link.restrain_rama_allowed = False
  params.pdb_interpretation.peptide_link.restrain_allowed_outliers_with_emsley=True
  model.set_pdb_interpretation_params(params)
  grm = model.get_restraints_manager().geometry
  nprox = grm.ramachandran_manager.get_n_proxies()
  assert nprox == 170
  assert grm.ramachandran_manager.get_n_oldfield_proxies() == 164
  assert grm.ramachandran_manager.get_n_emsley_proxies() == 6
Ejemplo n.º 4
0
def exercise_ramachandran_selections(mon_lib_srv, ener_lib):
  # Just check overall rama proxies
  file_name = libtbx.env.find_in_repositories(
    # relative_path="phenix_regression/pdb/3mku.pdb",
    relative_path="phenix_regression/pdb/fab_a_cut.pdb",
    test=os.path.isfile)
  if (file_name is None):
    print("Skipping test.")
    return
  params = mmtbx.model.manager.get_default_pdb_interpretation_params()
  params.pdb_interpretation.peptide_link.ramachandran_restraints = True
  pdb_inp = iotbx.pdb.input(file_name=file_name)
  model = mmtbx.model.manager(
      model_input=pdb_inp,
      pdb_interpretation_params=params,
      log=null_out())
  grm = model.get_restraints_manager().geometry
  assert grm.ramachandran_manager.get_n_proxies() == 53

  # simple selection
  params.pdb_interpretation.peptide_link.ramachandran_restraints = True
  params.pdb_interpretation.peptide_link.rama_selection = "chain A and resid 1:7"
  model.set_pdb_interpretation_params(params)
  grm = model.get_restraints_manager().geometry
  nprox = grm.ramachandran_manager.get_n_proxies()
  assert nprox == 5, ""+\
      "Want to get 5 rama proxies, got %d" % nprox
  # 7 residues: there are insertion codes
  params.pdb_interpretation.peptide_link.ramachandran_restraints = True
  params.pdb_interpretation.peptide_link.rama_selection = "chain A and resid 27:28"
  model.set_pdb_interpretation_params(params)
  grm = model.get_restraints_manager().geometry
  nprox = grm.ramachandran_manager.get_n_proxies()
  assert nprox == 5, ""+\
      "Want to get 5 rama proxies, got %d" % nprox
Ejemplo n.º 5
0
def exercise(pdb_str, use_ideal_bonds_angles):
    # --------------------------------------------------------------
    #          code to switch off CDL
    # --------------------------------------------------------------
    #params_line = grand_master_phil_str
    #params = iotbx.phil.parse(
    #    input_string=params_line, process_includes=True).extract()
    #params.pdb_interpretation.restraints_library.cdl=False
    # ---------------------------------------------------------------

    pdb_inp = iotbx.pdb.input(lines=pdb_str.split("\n"), source_info=None)
    model = mmtbx.model.manager(model_input=pdb_inp,
                                log=null_out(),
                                build_grm=True)

    pdb_hierarchy = model.get_hierarchy()
    geometry_restraints = model.get_restraints_manager().geometry
    xray_structure = model.get_xray_structure()

    sites_cart = model.get_sites_cart()

    grf = cctbx.geometry_restraints.flags.flags(default=True)
    minimized = mmtbx.refinement.geometry_minimization.lbfgs(
        sites_cart=sites_cart,
        correct_special_position_tolerance=1.0,
        geometry_restraints_manager=geometry_restraints,
        geometry_restraints_flags=grf,
        lbfgs_termination_params=scitbx.lbfgs.termination_parameters(
            max_iterations=500))
    xray_structure.set_sites_cart(sites_cart)
    pdb_hierarchy.adopt_xray_structure(xray_structure)
    atoms = pdb_hierarchy.atoms()
    sites_cart = xray_structure.sites_cart()

    riding_h_manager = riding.manager(
        pdb_hierarchy=pdb_hierarchy,
        geometry_restraints=geometry_restraints,
        use_ideal_bonds_angles=use_ideal_bonds_angles)

    h_parameterization = riding_h_manager.h_parameterization

    diagnostics = riding_h_manager.diagnostics(sites_cart=sites_cart,
                                               threshold=0.05)
    h_distances = diagnostics.h_distances

    number_h = model.get_hd_selection().count(True)
    number_h_para = len(h_parameterization) - h_parameterization.count(None)

    assert (number_h_para == number_h), 'Not all H atoms are parameterized'

    for ih in h_distances:
        labels = atoms[ih].fetch_labels()
        if use_ideal_bonds_angles:
            assert (h_distances[ih] < 0.03), \
              'distance too large: %s  atom: %s (%s) residue: %s ' \
              % (h_parameterization[ih].htype, atoms[ih].name, ih, labels.resseq.strip())
        else:
            assert (h_distances[ih] < 1e-7), \
              'distance too large: %s  atom: %s (%s) residue: %s  distance %s' \
              % (h_parameterization[ih].htype, atoms[ih].name, ih, labels.resseq.strip(), h_distances[ih])
Ejemplo n.º 6
0
def get_pdb_inputs(pdb_str):
    pdb_inp = iotbx.pdb.input(source_info=None, lines=pdb_str.split('\n'))
    model = mmtbx.model.manager(model_input=pdb_inp)
    model.process(make_restraints=True)
    return group_args(ph=model.get_hierarchy(),
                      grm=model.get_restraints_manager(),
                      xrs=model.get_xray_structure())
Ejemplo n.º 7
0
def exclude_h_on_SS(model):
    rm = model.get_restraints_manager()
    bond_proxies_simple, asu = rm.geometry.get_all_bond_proxies(
        sites_cart=model.get_sites_cart())
    els = model.get_hierarchy().atoms().extract_element()
    ss_i_seqs = []
    all_proxies = [p for p in bond_proxies_simple]
    for proxy in asu:
        all_proxies.append(proxy)
    for proxy in all_proxies:
        if (isinstance(proxy, ext.bond_simple_proxy)): i, j = proxy.i_seqs
        elif (isinstance(proxy, ext.bond_asu_proxy)):
            i, j = proxy.i_seq, proxy.j_seq
        else:
            assert 0  # never goes here
        if ([els[i], els[j]
             ].count("S") == 2):  # XXX may be coordinated if metal edits used
            ss_i_seqs.extend([i, j])
    sel_remove = flex.size_t()
    for proxy in all_proxies:
        if (isinstance(proxy, ext.bond_simple_proxy)): i, j = proxy.i_seqs
        elif (isinstance(proxy, ext.bond_asu_proxy)):
            i, j = proxy.i_seq, proxy.j_seq
        else:
            assert 0  # never goes here
        if (els[i] in ["H", "D"] and j in ss_i_seqs): sel_remove.append(i)
        if (els[j] in ["H", "D"] and i in ss_i_seqs): sel_remove.append(j)
    return model.select(~flex.bool(model.size(), sel_remove))
Ejemplo n.º 8
0
 def __init__(
     self,
     model,
     rs_values=[2.0, 3.8, 5.2, 5.5, 6.2, 7.0, 8.6, 10.0],
     # probe distances (A) for radial
     radial_eta=4,
     cutoff=8.1,
     # radial cutoff distance
     ts_values=[0.392699, 1.178097, 1.963495, 2.748894],
     # probe angles (rad) for angular
     angular_rs_values=[3.8, 5.2, 5.5, 6.2],
     # probe distances (A) for angular
     angular_eta=4,
     angular_zeta=8,
     # ???
 ):
     self.hierarchy = model.get_hierarchy()
     self.geometry_restraints_manager = model.get_restraints_manager(
     ).geometry
     self.rs_values = rs_values
     self.radial_eta = radial_eta
     # NOT USED!!!
     # self.Rj = Rj
     self.cutoff = cutoff
     self.ts_values = ts_values
     self.angular_rs_values = angular_rs_values
     self.angular_eta = angular_eta
     self.angular_zeta = angular_zeta
     self.EAEVs = format_class(length_of_radial=len(self.rs_values))
     self.MAEVs = format_class(length_of_radial=len(self.rs_values))
     self.BAEVs = format_class(length_of_radial=len(self.rs_values))
     self.center_atom = None
     self.chain_hierarchy = None
     self.generate_AEV()
Ejemplo n.º 9
0
def exercise_1():
    pdb_inp = iotbx.pdb.input(lines=flex.std_string(pdb_str_1.splitlines()),
                              source_info=None)
    model = mmtbx.model.manager(model_input=pdb_inp)
    model.process(make_restraints=True)
    grm = model.get_restraints_manager().geometry
    pdb_hierarchy = model.get_hierarchy()
    sites_cart = model.get_sites_cart()
    # c-beta restraints are added by default!!!
    assert len(grm.get_c_beta_torsion_proxies()) == 4

    #test global selection and removing c-beta restraints
    tst_boolsel = pdb_hierarchy.atom_selection_cache().selection("resname TYR")
    tst_iselection = tst_boolsel.iselection()
    #test global selection
    grm2 = grm.select(iselection=tst_iselection)
    assert len(grm2.get_c_beta_torsion_proxies()) == 2
    grm2 = grm.select(selection=tst_boolsel)
    assert len(grm2.get_c_beta_torsion_proxies()) == 2
    #remove a selection
    grm.remove_c_beta_torsion_restraints_in_place(selection=tst_iselection)
    assert len(grm.get_c_beta_torsion_proxies()) == 2
    #add a selection
    grm.remove_c_beta_torsion_restraints_in_place()
    assert len(grm.get_c_beta_torsion_proxies()) == 0
    c_beta_torsion_proxies = c_beta.get_c_beta_torsion_proxies(
        pdb_hierarchy, selection=tst_iselection, sigma=2.5)
    assert len(c_beta_torsion_proxies) == 2
Ejemplo n.º 10
0
def get_pdb_inputs(pdb_str):
  pdb_inp = iotbx.pdb.input(source_info=None, lines=pdb_str)
  model = mmtbx.model.manager(model_input = pdb_inp, log = null_out(), build_grm=True)
  return group_args(
    ph  = model.get_hierarchy(),
    grm = model.get_restraints_manager(),
    xrs = model.get_xray_structure())
Ejemplo n.º 11
0
def run(maxnum_residues_in_cluster):
  result = []
  for clustering in [True, False]:
    if 0: print("  clustering", clustering, "-"*30)
    model = get_model()
    fq = from_cctbx(restraints_manager = model.get_restraints_manager())
    if(clustering):
      fm = fragments(
       working_folder             = os.path.split("./ase/tmp_ase.pdb")[0]+ "/",
       clustering_method          = betweenness_centrality_clustering,
       maxnum_residues_in_cluster = maxnum_residues_in_cluster,
       altloc_method              = "subtract",
       charge_embedding           = False,
       two_buffers                = False,
       clustering                 = clustering,
       pdb_hierarchy              = model.get_hierarchy().deep_copy(),
       qm_engine_name             = "mopac",
       fast_interaction           = True,
       crystal_symmetry           = model.crystal_symmetry())
    else:
      fc = fq
    fc = from_cluster(
      restraints_manager = fq,
      fragment_manager   = fm,
      parallel_params    = get_master_phil().extract())
    energy, gradients = fc.target_and_gradients(sites_cart=model.get_sites_cart())
    gradients = gradients.as_double()
    result.append(gradients.deep_copy())
  diff = flex.abs(result[0] - result[1])
  max_diff = flex.max(diff)
  #print "  max(diff_grad):", max_diff
  assert max_diff < 1.e-9
Ejemplo n.º 12
0
def test_1_5_overlaps():
  '''
  Test if 1_5 overlaps are correctly identified
  '''
  model = obtain_model(raw_records_0)
  hd_sel = model.get_hd_selection()
  grm = model.get_restraints_manager().geometry
  full_connectivity_table = grm.shell_sym_tables[0].full_simple_connectivity()

  outstring = '1-5 Interaction test error. {}'
  # check that direction of function calling does not matter
  tst = pnp.check_if_1_5_interaction(21, 33,hd_sel,full_connectivity_table)
  msg = 'Test results depend on atoms order'
  assert(tst), msg
  tst = pnp.check_if_1_5_interaction(33, 21,hd_sel,full_connectivity_table)
  assert(tst), msg
  # check 1-4 interaction
  tst = pnp.check_if_1_5_interaction(33, 20,hd_sel,full_connectivity_table)
  msg = 'Test fails on 1-4 interaction'
  assert(not tst), msg
  # check 1-6 interaction
  tst = pnp.check_if_1_5_interaction(33, 38,hd_sel,full_connectivity_table)
  msg = 'Test fails on 1-6 interaction'
  assert(not tst), msg
  # 1-5 interaction of atoms other than hydrogen
  tst = pnp.check_if_1_5_interaction(38, 25,hd_sel,full_connectivity_table)
  msg = 'Test fails on 1-5 non hydrogen interaction'
  assert(not tst), msg
  # 1-5 interaction of two hydrogens
  tst = pnp.check_if_1_5_interaction(33, 31,hd_sel,full_connectivity_table)
  msg = 'Test fails on 1-5 two hydrogen interaction'
  assert(not tst), msg
Ejemplo n.º 13
0
def exercise_ramachandran_selections(mon_lib_srv, ener_lib):
    # Just check overall rama proxies
    file_name = libtbx.env.find_in_repositories(
        # relative_path="phenix_regression/pdb/3mku.pdb",
        relative_path="phenix_regression/pdb/fab_a_cut.pdb",
        test=os.path.isfile)
    if (file_name is None):
        print("Skipping test.")
        return
    params = mmtbx.model.manager.get_default_pdb_interpretation_params()
    params.pdb_interpretation.ramachandran_plot_restraints.enabled = True
    params.pdb_interpretation.ramachandran_plot_restraints.inject_emsley8k_into_oldfield_favored = False
    pdb_inp = iotbx.pdb.input(file_name=file_name)
    model = mmtbx.model.manager(model_input=pdb_inp,
                                pdb_interpretation_params=params,
                                log=null_out(),
                                build_grm=True)
    grm = model.get_restraints_manager().geometry
    n = grm.ramachandran_manager.get_n_proxies()
    assert n == 53, n

    # simple selection
    model = mmtbx.model.manager(model_input=pdb_inp,
                                pdb_interpretation_params=params,
                                log=null_out())
    params.pdb_interpretation.ramachandran_plot_restraints.enabled = True
    params.pdb_interpretation.ramachandran_plot_restraints.inject_emsley8k_into_oldfield_favored = False
    params.pdb_interpretation.ramachandran_plot_restraints.selection = "chain A and resid 1:7"
    model.set_pdb_interpretation_params(params)
    model.process_input_model(make_restraints=True)
    grm = model.get_restraints_manager().geometry
    nprox = grm.ramachandran_manager.get_n_proxies()
    assert nprox == 5, ""+\
        "Want to get 5 rama proxies, got %d" % nprox
    # 7 residues: there are insertion codes
    model = mmtbx.model.manager(model_input=pdb_inp,
                                pdb_interpretation_params=params,
                                log=null_out())
    params.pdb_interpretation.ramachandran_plot_restraints.enabled = True
    params.pdb_interpretation.ramachandran_plot_restraints.inject_emsley8k_into_oldfield_favored = False
    params.pdb_interpretation.ramachandran_plot_restraints.selection = "chain A and resid 27:28"
    model.set_pdb_interpretation_params(params)
    model.process_input_model(make_restraints=True)
    grm = model.get_restraints_manager().geometry
    nprox = grm.ramachandran_manager.get_n_proxies()
    assert nprox == 5, ""+\
        "Want to get 5 rama proxies, got %d" % nprox
Ejemplo n.º 14
0
def exercise_1(prefix="tst_model_ramachandran_1"):
    """ Make sure that set_ramachandran_plot_restraints() works. """
    inp = iotbx.pdb.input(lines=tst_pdb_str, source_info=None)
    model = mmtbx.model.manager(model_input=inp)
    model.set_ramachandran_plot_restraints(rama_potential='oldfield')
    n = model.get_restraints_manager(
    ).geometry.ramachandran_manager.get_n_oldfield_proxies()
    assert n == 2
Ejemplo n.º 15
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)
Ejemplo n.º 16
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
    """)
Ejemplo n.º 17
0
def exercise_bond_near_symmetry3(mon_lib_srv, ener_lib):
    """ Since neighbors_fast_pair_generator for non-symmetry interactions
  provides only (i,j) pair and not (j,i), and there's no sorting involved
  (no way to guess what to check), there was a bug where non-symmetry interaction
  was missed in add_new_bond_restraints_in_place.
  Actually testing that both bonds are added without symmetry operators.
  """

    from cctbx.geometry_restraints.linking_class import linking_class
    origin_ids = linking_class()
    pdb_inp = iotbx.pdb.input(source_info=None, lines=raw_records8)
    model = mmtbx.model.manager(model_input=pdb_inp,
                                log=null_out(),
                                build_grm=True)
    grm = model.get_restraints_manager().geometry
    h = model.get_hierarchy()
    proxy = geometry_restraints.bond_simple_proxy(
        i_seqs=(64, 37),
        distance_ideal=2.9,
        weight=400,
        origin_id=origin_ids.get_origin_id('hydrogen bonds'))
    proxy2 = geometry_restraints.bond_simple_proxy(
        i_seqs=(72, 37),
        distance_ideal=2.9,
        weight=400,
        origin_id=origin_ids.get_origin_id('hydrogen bonds'))
    grm.add_new_hbond_restraints_in_place(
        proxies=[proxy, proxy2],
        sites_cart=h.atoms().extract_xyz(),
        max_distance_between_connecting_atoms=10)
    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="",
        origin_id=origin_ids.get_origin_id('hydrogen bonds'))
    outtxt = out.getvalue()
    assert not show_diff(
        outtxt, """\
Bond restraints: 2
Sorted by residual:
bond pdb=" O   ARG A  25 "
     pdb=" N  AASN A  29 "
  ideal  model  delta    sigma   weight residual
  2.900  2.934 -0.034 5.00e-02 4.00e+02 4.53e-01
bond pdb=" O   ARG A  25 "
     pdb=" N  BASN A  29 "
  ideal  model  delta    sigma   weight residual
  2.900  2.888  0.012 5.00e-02 4.00e+02 5.59e-02
""")
Ejemplo n.º 18
0
def exercise_dihedral_edits_change():
    edits = """\
geometry_restraints.edits {
  dihedral {
    action = *change
    atom_selection_1 = resid 1 and name CA
    atom_selection_2 = resid 1 and name C
    atom_selection_3 = resid 2 and name N
    atom_selection_4 = resid 2 and name CA
    angle_ideal = 100.00
    alt_angle_ideals = 90,110
    sigma = 2
    periodicity = 2
  }
}"""
    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_records2, source_info=None)
    model = mmtbx.model.manager(model_input=inp)
    model.process(make_restraints=True)
    grm = model.get_restraints_manager().geometry
    assert grm.dihedral_proxies.size() == 9
    dih1 = grm.dihedral_proxies.proxy_select(n_seq=model.get_number_of_atoms(),
                                             iselection=flex.size_t(
                                                 [1, 2, 5, 6]))
    assert dih1.size() == 1
    dp1 = dih1[0]
    assert approx_equal(dp1.angle_ideal, 180)
    assert dp1.alt_angle_ideals == None
    assert dp1.origin_id == 0
    assert dp1.periodicity == 0
    assert dp1.slack == 0
    assert not dp1.top_out
    assert approx_equal(dp1.weight, 0.04)

    # Now with modifications
    inp = iotbx.pdb.input(lines=raw_records2, source_info=None)
    model2 = mmtbx.model.manager(model_input=inp)
    model2.process(pdb_interpretation_params=params, make_restraints=True)
    grm2 = model2.get_restraints_manager().geometry
    assert grm2.dihedral_proxies.size() == 9
    dih2 = grm2.dihedral_proxies.proxy_select(
        n_seq=model2.get_number_of_atoms(),
        iselection=flex.size_t([1, 2, 5, 6]))
    assert dih2.size() == 1
    dp2 = dih2[0]
    assert approx_equal(dp2.angle_ideal, 100)
    assert dp2.alt_angle_ideals == (90, 110)
    assert dp2.origin_id == origin_ids.get_origin_id('edits')
    assert dp2.periodicity == 2
    assert dp2.slack == 0
    assert not dp2.top_out
    assert approx_equal(dp2.weight, 0.25)
Ejemplo n.º 19
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()
Ejemplo n.º 20
0
def exercise_1(prefix="tst_model_ramachandran_1"):
    """ Make sure that set_ramachandran_plot_restraints() works. """
    inp = iotbx.pdb.input(lines=tst_pdb_str, source_info=None)
    model = mmtbx.model.manager(model_input=inp)
    rama_params = master_phil.fetch().extract().ramachandran_plot_restraints
    rama_params.favored = 'oldfield'
    rama_params.allowed = 'oldfield'
    rama_params.outlier = 'oldfield'
    model.set_ramachandran_plot_restraints(rama_params=rama_params)
    n = model.get_restraints_manager(
    ).geometry.ramachandran_manager.get_n_oldfield_proxies()
    assert n == 2

    rama_params.favored = 'emsley'
    rama_params.allowed = 'emsley'
    rama_params.outlier = 'emsley'
    model.set_ramachandran_plot_restraints(rama_params=rama_params)
    n = model.get_restraints_manager(
    ).geometry.ramachandran_manager.get_n_emsley_proxies()
    assert n == 2
def run_tst_grm_after_neutralize_scatterers():
    # Look at nonbonded interaction CB - OE2 in Glu
    # OE2 has negative charge
    # vdw distance is 2.560 A when OE2 is neutral
    # vdw distance is 2.752 A when OE1 has O1- charge
    pdb_inp = iotbx.pdb.input(source_info=None, lines=pdb_str_2)

    model = mmtbx.model.manager(model_input=pdb_inp,
                                log=null_out(),
                                build_grm=True)
    atoms = model.get_hierarchy().atoms()
    grm = model.get_restraints_manager()
    #  with open('1.geo', 'w') as f:
    #    f.write(model.restraints_as_geo())
    nonbonded_proxies = grm.geometry.pair_proxies().nonbonded_proxies.simple
    for nb_proxy in nonbonded_proxies:
        iseq, jseq = nb_proxy.i_seqs
        if (iseq == 4 and jseq == 8):
            vdw_distance1 = nb_proxy.vdw_distance
            assert (atoms[iseq].name.strip() == 'CB')
            assert (atoms[jseq].name.strip() == 'OE2')

    model = mmtbx.model.manager(model_input=pdb_inp,
                                log=null_out(),
                                build_grm=False)
    model.neutralize_scatterers()
    model.process_input_model(make_restraints=True)
    atoms2 = model.get_hierarchy().atoms()
    grm2 = model.get_restraints_manager()
    #  with open('2.geo', 'w') as f:
    #    f.write(model.restraints_as_geo())
    nonbonded_proxies2 = grm2.geometry.pair_proxies().nonbonded_proxies.simple
    for nb_proxy in nonbonded_proxies2:
        iseq, jseq = nb_proxy.i_seqs
        if (iseq == 4 and jseq == 8):
            vdw_distance2 = nb_proxy.vdw_distance
            assert (atoms2[iseq].name.strip() == 'CB')
            assert (atoms2[jseq].name.strip() == 'OE2')

    assert (vdw_distance1 != vdw_distance2)
Ejemplo n.º 22
0
def compare_XH_bond_length_to_ideal(model):
    geometry = model.get_restraints_manager().geometry
    atoms = model.get_hierarchy().atoms()
    sites_cart = model.get_sites_cart()
    bond_proxies_simple, asu = \
      geometry.get_all_bond_proxies(sites_cart = sites_cart)
    hd_selection = model.get_hd_selection()
    for bp in bond_proxies_simple:
        i, j = bp.i_seqs
        if hd_selection[i] or hd_selection[j]:
            assert approx_equal(atoms[i].distance(atoms[j]),
                                bp.distance_ideal,
                                eps=0.001)
def get_CNCO_bond_angle(model):
    geometry = model.get_restraints_manager()
    bond_proxies_simple, asu = geometry.geometry.get_all_bond_proxies(
        sites_cart=model.get_sites_cart())
    bps_dict = {}
    [bps_dict.setdefault(p.i_seqs, True) for p in bond_proxies_simple]
    hierarchy = model.get_hierarchy()
    atom1s = []
    atom2s = []
    atom3s = []
    results = []
    for a in hierarchy.atoms():
        if (not a.parent().resname == "MTN"): continue
        if a.element.strip().upper() == "C":
            atom1s.append(a)
        if a.element.strip().upper() == "N":
            atom2s.append(a)
        if a.element.strip().upper() == "O":
            atom3s.append(a)
    for i, a1 in enumerate(atom1s):
        for a2 in atom2s:
            if (not a1.is_in_same_conformer_as(a2)): continue
            if (not is_bonded(a1, a2, bps_dict)): continue
            for j, a4 in enumerate(atom1s):
                if (j <= i): continue
                if (not a4.is_in_same_conformer_as(a2)): continue
                if (not is_bonded(a4, a2, bps_dict)): continue
                if (not a1.is_in_same_conformer_as(a4)): continue
                if (is_bonded(a1, a4, bps_dict)): continue
                for a3 in atom3s:
                    if (not a2.is_in_same_conformer_as(a3)): continue
                    if (not is_bonded(a3, a2, bps_dict)): continue
                    d12 = a1.distance(a2)
                    d23 = a2.distance(a3)
                    d24 = a2.distance(a4)
                    angle123 = a2.angle(a1, a3, deg=True)
                    angle124 = a2.angle(a1, a4, deg=True)
                    angle324 = a2.angle(a3, a4, deg=True)
                    result = group_args(atom_1=a1,
                                        atom_2=a2,
                                        atom_3=a3,
                                        atom_4=a4,
                                        d_C_L_N=d12,
                                        d_O_N=d23,
                                        d_C_R_N=d24,
                                        a_C_L_N_O=angle123,
                                        a_C_N_C=angle124,
                                        a_C_R_N_O=angle324)
                    if (result is not None): results.append(result)
    return results
Ejemplo n.º 24
0
def tst_1(prefix="gm_ncs_constr_tst1"):
    log = sys.stdout
    pdb_in = iotbx.pdb.input(source_info=None, lines=pdb_string1.split('\n'))
    # print dir(pdb_in)
    pdb_int_params = mmtbx.model.manager.get_default_pdb_interpretation_params(
    )
    pdb_int_params.pdb_interpretation.ncs_search.enabled = True
    model = mmtbx.model.manager(model_input=pdb_in,
                                pdb_interpretation_params=pdb_int_params,
                                build_grm=True)
    ncs_obj = iotbx.ncs.input(hierarchy=model.get_hierarchy())
    original_ncs_transform = ncs_obj.ncs_transform
    ncs_restraints_group_list = ncs_obj.get_ncs_restraints_group_list()
    ncs_obj.show(format='phil')
    grm = model.get_restraints_manager()
    tmp_xrs = model.get_xray_structure().deep_copy_scatterers()
    refine_selection = flex.size_t(xrange(model.get_number_of_atoms()))

    # print "refining sites"
    cycle = 0
    tfg_obj = mmtbx.refinement.minimization_ncs_constraints.\
        target_function_and_grads_geometry_minimization(
            xray_structure=tmp_xrs,
            ncs_restraints_group_list=ncs_restraints_group_list,
            refine_selection=refine_selection,
            restraints_manager=grm.geometry,
            refine_sites=True,
            refine_transformations=False,
            )
    minimized = mmtbx.refinement.minimization_ncs_constraints.lbfgs(
        target_and_grads_object=tfg_obj,
        xray_structure=tmp_xrs,
        ncs_restraints_group_list=ncs_restraints_group_list,
        refine_selection=refine_selection,
        finite_grad_differences_test=False,
        max_iterations=100,
        refine_sites=True,
        refine_transformations=False)
    refined_pdb_h = model.get_hierarchy().deep_copy()
    refined_pdb_h.adopt_xray_structure(tmp_xrs)
    refined_pdb_h.write_pdb_file("refined_%d.pdb" % cycle)
    new_ncs_obj = iotbx.ncs.input(hierarchy=refined_pdb_h)
    new_ncs_transform = new_ncs_obj.ncs_transform
    spec = new_ncs_obj.get_ncs_info_as_spec()
    for k, v in original_ncs_transform.iteritems():
        assert approx_equal(v.r.elems, new_ncs_transform[k].r.elems)
        assert approx_equal(v.t, new_ncs_transform[k].t)
    overall_rmsd_after = spec.overall_rmsd()
    assert overall_rmsd_after < 1e-6
Ejemplo n.º 25
0
def run(prefix):
    """
  Exercise combined energy and gradients from cluster qm.
  """
    for restraints in ["cctbx", "qm"]:
        if 0:
            print("Using restraints:", restraints)
        result = []
        for clustering in [True, False]:
            if 0:
                print("  clustering", clustering, "-" * 30)
            model = get_model()
            if (restraints == "qm"):
                fq = from_qm(pdb_hierarchy=model.get_hierarchy(),
                             qm_engine_name="mopac",
                             method="PM3",
                             crystal_symmetry=model.crystal_symmetry(),
                             clustering=clustering)
            else:
                fq = from_cctbx(
                    restraints_manager=model.get_restraints_manager())
            if (clustering):
                fm = fragments(
                    working_folder=os.path.split("./ase/tmp_ase.pdb")[0] + "/",
                    clustering_method=betweenness_centrality_clustering,
                    maxnum_residues_in_cluster=8,
                    charge_embedding=False,
                    two_buffers=False,
                    fast_interaction=True,
                    pdb_hierarchy=model.get_hierarchy().deep_copy(
                    ),  # deep copy just in case
                    qm_engine_name="mopac",
                    crystal_symmetry=model.crystal_symmetry())
                fc = from_cluster(restraints_manager=fq,
                                  fragment_manager=fm,
                                  parallel_params=get_master_phil().extract())
            else:
                fc = fq
            energy, gradients = fc.target_and_gradients(
                sites_cart=model.get_sites_cart())
            if (restraints == "qm"):
                energy = energy * (kcal / mol) * (kcal / mol) / Hartree
                gradients = gradients * (kcal / mol) * (kcal / mol) * (Bohr /
                                                                       Hartree)
            gradients = gradients.as_double()
            result.append(gradients.deep_copy())
        #
        diff = flex.abs(result[0] - result[1])
        max_diff = flex.max(diff)
def exercise_adopting_coord_restraints():
    inp_1 = iotbx.pdb.input(lines=pdb_str_h, source_info=None)
    h_model = mmtbx.model.manager(model_input=inp_1)

    inp_2 = iotbx.pdb.input(lines=pdb_str, source_info=None)
    model = mmtbx.model.manager(model_input=inp_2)

    # case 1: big model adopting small model.
    h_model.set_reference_coordinate_restraints(ref_model=model)
    # print h_model.restraints_as_geo()
    rcp = h_model.get_restraints_manager(
    ).geometry.reference_coordinate_proxies
    assert len(rcp) == 59
    # Note iseqs, hydrogens are skipped
    answer = [[(0, ), (-9.009, 4.612, 6.102), 25.0],
              [(1, ), (-9.052, 4.207, 4.651), 25.0],
              [(2, ), (-8.015, 3.14, 4.419), 25.0],
              [(3, ), (-7.523, 2.521, 5.381), 25.0],
              [(9, ), (-7.656, 2.923, 3.155), 25.0],
              [(10, ), (-6.522, 2.038, 2.831), 25.0]]
    # for p in rcp:
    #   print p.i_seqs, p.ref_sites, p.weight

    for i in range(6):
        assert rcp[i].i_seqs == answer[i][0], "%s %s" % (rcp[i].i_seqs,
                                                         answer[i][0])
        assert approx_equal(rcp[i].ref_sites, answer[i][1])
        assert approx_equal(
            rcp[i].weight,
            answer[i][2]), "%s, %s" % (rcp[i].weight, answer[i][2])

    # case 2: small model adopting big model.
    model.set_reference_coordinate_restraints(ref_model=h_model)
    rcp = model.get_restraints_manager().geometry.reference_coordinate_proxies
    assert len(rcp) == 59
    # Note iseqs, hydrogens are skipped
    answer = [[(0, ), (-9.009, 4.612, 6.102), 25.0],
              [(1, ), (-9.052, 4.207, 4.651), 25.0],
              [(2, ), (-8.015, 3.14, 4.419), 25.0],
              [(3, ), (-7.523, 2.521, 5.381), 25.0],
              [(4, ), (-7.656, 2.923, 3.155), 25.0],
              [(5, ), (-6.522, 2.038, 2.831), 25.0]]
    for i in range(6):
        assert rcp[i].i_seqs == answer[i][0]
        assert approx_equal(rcp[i].ref_sites, answer[i][1])
        assert approx_equal(
            rcp[i].weight,
            answer[i][2]), "%s, %s" % (rcp[i].weight, answer[i][2])
Ejemplo n.º 27
0
def exercise_1():
  inp = iotbx.pdb.input(source_info=None, lines=pdb_str_1)
  model = mmtbx.model.manager(
      model_input = inp,
      log = null_out())
  assert model.get_number_of_atoms() == 21
  assert model.get_hierarchy().atoms_size() == 21
  assert model.get_xray_structure().scatterers().size() == 21
  ss = model.get_ss_annotation()
  # print ss.as_pdb_str()
  # STOP()
  assert ss.get_n_helices() == 3
  # because the second strand contains chain B which is not in ATOM records
  # whole sheet got discarded.
  assert ss.get_n_sheets() == 0
  rm = model.get_restraints_manager()
  assert rm.geometry.pair_proxies().bond_proxies.simple.size() == 6
  # since No NCS was set, these functions return the whole thing and no
  # master selection
  assert model.get_master_hierarchy().atoms_size() == 21
  assert model.get_master_selection().size() == 0
  # print model.model_as_pdb()
  # print "="*40

  # Here we set NCS constraints
  inp = iotbx.pdb.input(source_info=None, lines=pdb_str_1)
  pdb_int_params = mmtbx.model.manager.get_default_pdb_interpretation_params()
  pdb_int_params.pdb_interpretation.ncs_search.enabled=True
  model = mmtbx.model.manager(
      model_input = inp,
      pdb_interpretation_params = pdb_int_params,
      process_input=True,
      log = null_out())
  # model.get_xray_structure()
  assert not model.ncs_constraints_present()
  assert model.get_ncs_obj() is not None
  model.setup_ncs_constraints_groups()
  # print model.get_ncs_obj()
  assert model.ncs_constraints_present()
  assert model.get_master_hierarchy().atoms_size() == 7
  # print model.get_master_hierarchy().as_pdb_string()
  # print list(model.get_master_selection())
  assert list(model.get_master_selection()).count(True) == 7
Ejemplo n.º 28
0
def exclude_h_on_coordinated_S(model): # XXX if edits used it should be like in exclude_h_on_SS
  rm = model.get_restraints_manager().geometry
  els = model.get_hierarchy().atoms().extract_element()
  # Find possibly coordinated S
  exclusion_list = ["H","D","T","S","O","P","N","C","SE"]
  sel_s = []
  for proxy in rm.pair_proxies().nonbonded_proxies.simple:
    i,j = proxy.i_seqs
    if(els[i] == "S" and not els[j] in exclusion_list): sel_s.append(i)
    if(els[j] == "S" and not els[i] in exclusion_list): sel_s.append(j)
  # Find H attached to possibly coordinated S
  bond_proxies_simple, asu = rm.get_all_bond_proxies(
    sites_cart = model.get_sites_cart())
  sel_remove = flex.size_t()
  for proxy in bond_proxies_simple:
    i,j = proxy.i_seqs
    if(els[i] in ["H","D"] and j in sel_s): sel_remove.append(i)
    if(els[j] in ["H","D"] and i in sel_s): sel_remove.append(j)
  return model.select(~flex.bool(model.size(), sel_remove))
Ejemplo n.º 29
0
def get_dihedrals_and_phi_psi(model):
    from cctbx.geometry_restraints import dihedral_proxy_registry
    dihedral_registry = dihedral_proxy_registry(strict_conflict_handling=True)
    dihedral_registry.initialize_table()
    from mmtbx.conformation_dependent_library import generate_protein_threes
    grm = None
    try:
        grm = model._processed_pdb_file.geometry_restraints_manager()
    except AttributeError:
        grm = model.get_restraints_manager().geometry
    assert grm is not None
    dihedral_proxies = grm.get_dihedral_proxies().deep_copy()
    for p in dihedral_proxies:
        dihedral_registry.add_if_not_duplicated(p)
    for three in generate_protein_threes(hierarchy=model.get_hierarchy(),
                                         geometry=None):
        proxies = three.get_dummy_dihedral_proxies(only_psi_phi_pairs=False)
        for p in proxies:
            dihedral_registry.add_if_not_duplicated(p)
    return dihedral_registry.proxies
Ejemplo n.º 30
0
def validate(pdb_str, threshold_bonds=0.02 * 4, threshold_angles=2.5 * 4):
    pdb_inp = iotbx.pdb.input(source_info=None, lines=pdb_str)
    params = mmtbx.model.manager.get_default_pdb_interpretation_params()
    params.pdb_interpretation.use_neutron_distances = True
    params.pdb_interpretation.restraints_library.cdl = False
    model = mmtbx.model.manager(
        model_input=pdb_inp,
        build_grm=True,
        stop_for_unknowns=True,  #False,
        pdb_interpretation_params=params,
        log=null_out())
    grm = model.get_restraints_manager().geometry
    sites_cart = model.get_sites_cart()
    b_deltas = flex.abs(
        grm.get_all_bond_proxies()[0].deltas(sites_cart=sites_cart))
    b_outl = b_deltas.select(b_deltas > threshold_bonds)
    if (b_outl.size() > 0): return None
    a_deltas = flex.abs(
        grm.get_all_angle_proxies().deltas(sites_cart=sites_cart))
    a_outl = a_deltas.select(a_deltas > threshold_angles)
    if (a_outl.size() > 0): return None
    return pdb_str