Пример #1
0
 def __init__(self,
              pdb_hierarchy,
              geometry_restraints,
              use_ideal_bonds_angles=True,
              process_manager=True):
     self.pdb_hierarchy = pdb_hierarchy
     self.geometry_restraints = geometry_restraints
     self.use_ideal_bonds_angles = use_ideal_bonds_angles
     #
     self.hd_selection = self.pdb_hierarchy.atom_selection_cache().\
       selection("element H or element D")
     self.not_hd_selection = ~self.hd_selection
     self.h_parameterization = []
     self.parameterization_cpp = []
     if process_manager is True:
         connectivity_manager = connectivity.determine_connectivity(
             pdb_hierarchy=self.pdb_hierarchy,
             geometry_restraints=geometry_restraints)
         h_connectivity = connectivity_manager.h_connectivity
         diagnostics_connectivity = connectivity_manager.get_diagnostics()
         parameterization_manager = parameterization.manager(
             h_connectivity=h_connectivity,
             sites_cart=self.pdb_hierarchy.atoms().extract_xyz(),
             use_ideal_bonds_angles=use_ideal_bonds_angles)
         self.h_parameterization = parameterization_manager.h_parameterization
         self.parameterization_cpp = self.get_parameterization_cpp(
             h_parameterization=self.h_parameterization)
Пример #2
0
 def __init__(self,
              pdb_hierarchy,
              geometry_restraints,
              use_ideal_bonds_angles=True):
     self.cs = geometry_restraints.crystal_symmetry
     self.pdb_hierarchy = pdb_hierarchy
     self.connectivity_manager = connectivity.determine_connectivity(
         pdb_hierarchy=self.pdb_hierarchy,
         geometry_restraints=geometry_restraints)
     self.h_connectivity = self.connectivity_manager.h_connectivity
     self.double_H = self.connectivity_manager.double_H
     self.connectivity_slipped = self.connectivity_manager.connectivity_slipped
     self.parameterization_manager = parameterization.manager(
         h_connectivity=self.h_connectivity,
         sites_cart=self.pdb_hierarchy.atoms().extract_xyz(),
         use_ideal_bonds_angles=use_ideal_bonds_angles)
     self.h_parameterization = \
       self.parameterization_manager.determine_parameterization()
     self.parameterization_cpp = []
     for hp in self.h_parameterization:
         if (hp is not None):
             self.parameterization_cpp.append(hp)
     self.hd_selection = self.pdb_hierarchy.atom_selection_cache().\
       selection("element H or element D")
     self.not_hd_selection = ~self.hd_selection
Пример #3
0
 def __init__(self,
              pdb_hierarchy,
              geometry_restraints,
              use_ideal_bonds_angles=True,
              process_manager=True,
              use_ideal_dihedral=False,
              ignore_h_with_dof=False):
     self.pdb_hierarchy = pdb_hierarchy
     self.geometry_restraints = geometry_restraints
     self.use_ideal_bonds_angles = use_ideal_bonds_angles
     self.ignore_h_with_dof = ignore_h_with_dof
     #
     self.hd_selection = self.pdb_hierarchy.atom_selection_cache().\
       selection("element H or element D")
     self.not_hd_selection = ~self.hd_selection
     self.h_parameterization = []
     self.parameterization_cpp = []
     if process_manager is True:
         connectivity_manager = connectivity.determine_connectivity(
             pdb_hierarchy=self.pdb_hierarchy,
             geometry_restraints=geometry_restraints)
         h_connectivity = connectivity_manager.h_connectivity
         diagnostics_connectivity = connectivity_manager.get_diagnostics()
         parameterization_manager = parameterization.manager(
             h_connectivity=h_connectivity,
             sites_cart=self.pdb_hierarchy.atoms().extract_xyz(),
             use_ideal_bonds_angles=use_ideal_bonds_angles,
             site_labels=[
                 atom.id_str().replace('pdb=', '').replace('"', '')
                 for atom in pdb_hierarchy.atoms()
             ],
             use_ideal_dihedral=use_ideal_dihedral,
             ignore_h_with_dof=self.ignore_h_with_dof)
         self.h_parameterization = parameterization_manager.h_parameterization
         self.parameterization_cpp = self.get_parameterization_cpp(
             h_parameterization=self.h_parameterization)
Пример #4
0
def exercise2():
    pdb_str = """
CRYST1   16.660   12.742   18.240  90.00  90.00  90.00 P 1
SCALE1      0.060024  0.000000  0.000000        0.00000
SCALE2      0.000000  0.078481  0.000000        0.00000
SCALE3      0.000000  0.000000  0.054825        0.00000
ATOM      1  N   TYR A   7       9.837   5.000   6.625  1.00 15.00           N
ATOM      2  CA  TYR A   7      10.084   6.426   6.798  1.00 15.00           C
ATOM      3  C   TYR A   7      11.431   6.813   6.197  1.00 15.00           C
ATOM      4  O   TYR A   7      11.660   6.642   5.000  1.00 15.00           O
ATOM      5  CB  TYR A   7      10.042   6.803   8.281  1.00 15.00           C
ATOM      6  CG  TYR A   7       8.697   6.593   8.948  1.00 15.00           C
ATOM      7  CD1 TYR A   7       7.540   6.413   8.198  1.00 15.00           C
ATOM      8  CD2 TYR A   7       8.586   6.575  10.332  1.00 15.00           C
ATOM      9  CE1 TYR A   7       6.315   6.222   8.807  1.00 15.00           C
ATOM     10  CE2 TYR A   7       7.364   6.384  10.950  1.00 15.00           C
ATOM     11  CZ  TYR A   7       6.233   6.208  10.183  1.00 15.00           C
ATOM     12  OH  TYR A   7       5.015   6.018  10.794  1.00 15.00           O
ATOM     13  HA  TYR A   7       9.398   6.930   6.331  1.00 15.00           H
ATOM     14  HB2 TYR A   7      10.693   6.264   8.757  1.00 15.00           H
ATOM     15  HB3 TYR A   7      10.270   7.742   8.369  1.00 15.00           H
ATOM     16  HD1 TYR A   7       7.589   6.422   7.269  1.00 15.00           H
ATOM     17  HD2 TYR A   7       9.347   6.694  10.853  1.00 15.00           H
ATOM     18  HE1 TYR A   7       5.550   6.103   8.292  1.00 15.00           H
ATOM     19  HE2 TYR A   7       7.306   6.375  11.878  1.00 15.00           H
ATOM     20  HH  TYR A   7       5.000   6.415  11.534  1.00 15.00           H
TER
HETATM   21  O   HOH B   1       5.307   7.545  13.240  1.00 30.00           O
TER
END
  """

    edits = """
geometry_restraints.edits {
  bond {
    atom_selection_1 = chain A and resseq 7 and name HH
    atom_selection_2 = chain B and resseq 1 and name O
    distance_ideal = 1.81
    sigma = 0.05
  }
}
  """

    type_list_known = [
        '3neigbs', '2tetra', '2tetra', 'flat_2neigbs', 'flat_2neigbs',
        'flat_2neigbs', 'flat_2neigbs', 'alg1b'
    ]

    gm_phil = iotbx.phil.parse(input_string=grand_master_phil_str,
                               process_includes=True)
    edits_phil = iotbx.phil.parse(edits)
    working_phil = gm_phil.fetch(edits_phil)
    params = working_phil.extract()

    # Make sure the angle edit is present
    assert (params.geometry_restraints.edits.bond[0].atom_selection_1 == \
      "chain A and resseq 7 and name HH")

    pdb_inp = iotbx.pdb.input(lines=pdb_str.split("\n"), source_info=None)

    model = mmtbx.model.manager(model_input=pdb_inp,
                                build_grm=True,
                                pdb_interpretation_params=params)

    pdb_hierarchy = model.get_hierarchy()
    sites_cart = model.get_sites_cart()
    atoms = pdb_hierarchy.atoms()

    model.setup_riding_h_manager()
    riding_h_manager = model.get_riding_h_manager()

    h_para = riding_h_manager.h_parameterization

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

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

    connectivity_manager = connectivity.determine_connectivity(
        pdb_hierarchy=pdb_hierarchy,
        geometry_restraints=model.get_restraints_manager().geometry)
    double_H = connectivity_manager.double_H

    # Test if number of paramterized H atoms is correct
    assert (number_h == number_h_para), 'Not all H atoms are parameterized'
    assert (double_H[19] == [11,
                             20]), 'H bound to two atoms wrongly recognized'
    assert (number_h_para == 8), 'Not all H atoms are parameterized'

    for ih in h_distances:
        labels = atoms[ih].fetch_labels()
        if (h_distances[ih] > 0.1):
            assert (h_distances[ih] < 0.1), \
              'distance too large: %s  atom: %s (%s) residue: %s ' \
              % (h_para[ih].htype, atoms[ih].name, ih, labels.resseq.strip())

    for type1, type2 in zip(type_list, type_list_known):
        assert (type1 == type2)
Пример #5
0
def exercise():
    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)

    restraints_manager = model.get_restraints_manager()
    angle_proxies = restraints_manager.geometry.get_all_angle_proxies()

    connectivity_manager = connectivity.determine_connectivity(
        pdb_hierarchy=model.get_hierarchy(),
        geometry_restraints=restraints_manager.geometry)
    h_connectivity = connectivity_manager.h_connectivity

    # get bonds stored in connectivity
    bond_list = {}
    angle_list = {}
    for neighbors in h_connectivity:
        if (neighbors is None): continue
        ih = neighbors.ih
        a0 = neighbors.a0
        i_a0 = a0['iseq']
        a1 = neighbors.a1
        i_a1 = a1['iseq']
        bond_list[ih] = [i_a0, a0['dist_ideal']]
        selected_atoms = tuple(sorted([ih, i_a0, i_a1]))
        angle_list[selected_atoms] = a1['angle_ideal']
        if neighbors.a2:
            a2 = neighbors.a2
            selected_atoms2 = tuple(sorted([ih, i_a0, a2['iseq']]))
            angle_list[selected_atoms2] = a2['angle_ideal']
        if neighbors.a3:
            a3 = neighbors.a3
            selected_atoms3 = tuple(sorted([ih, i_a0, a3['iseq']]))
            angle_list[selected_atoms3] = a3['angle_ideal']
        if neighbors.h1:
            h1 = neighbors.h1
            selected_atoms4 = tuple(sorted([ih, i_a0, h1['iseq']]))
            angle_list[selected_atoms4] = h1['angle_ideal']
        if neighbors.b1:
            i_b1 = neighbors.b1['iseq']
            third_nb_dict = {ih: i_b1}

    bond_ctrl = {}
    for i in model.xh_connectivity_table():
        bond_ctrl[i[1]] = [i[0], i[3]]

# List of angle restraints
    angles = [(4, 1, 12), (0, 1, 12), (2, 1, 12), (13, 4, 14), (5, 4, 14),
              (5, 4, 13), (1, 4, 13), (1, 4, 14), (8, 6, 15), (5, 6, 15),
              (9, 7, 16), (5, 7, 16), (10, 8, 17), (6, 8, 17), (10, 11, 19),
              (7, 9, 18), (10, 9, 18)]

    angle_ctrl = {}
    for ap in angle_proxies:
        if (ap.i_seqs in angles):
            angle_ctrl[tuple(sorted(list(ap.i_seqs)))] = ap.angle_ideal


# HH needs also third neighbors:
    third_nb_ctrl = {19: 8}

    assert (
        bond_list == bond_ctrl), '1-2 neighbors and distance_ideal are wrong'
    assert (
        angle_list == angle_ctrl), '1-3 neighbors and angle_ideal are wrong'
    assert (third_nb_dict == third_nb_ctrl), '1-4 neighbors are wrong'