Example #1
0
def check_coo_coo_exception(group1, group2, version):
    """Check for COO-COO hydrogen-bond atypical interaction behavior.

    Args:
        group1:  first group for check
        group2:  second group for check
        version:  version object
    Returns:
        1. Boolean indicating atypical behavior,
        2. value associated with atypical interaction (None if Boolean is False)
    """
    exception = True
    interact_groups12 = group1.get_interaction_atoms(group2)
    interact_groups21 = group2.get_interaction_atoms(group1)
    [closest_atom1, dist,
     closest_atom2] = get_smallest_distance(interact_groups12,
                                            interact_groups21)
    [dpka_max,
     cutoff] = version.get_hydrogen_bond_parameters(closest_atom1,
                                                    closest_atom2)
    f_angle = 1.00
    value = hydrogen_bond_energy(dist, dpka_max, cutoff, f_angle)
    weight = calculate_pair_weight(version.parameters, group1.num_volume,
                                   group2.num_volume)
    value = value * (1.0 + weight)
    return exception, value
Example #2
0
def check_coo_arg_exception(group_coo, group_arg, version):
    """Check for COO-ARG interaction atypical behavior.

    Uses the two shortest unique distances (involving 2+2 atoms)

    Args:
        group_coo:  COO group
        group_arg:  ARG group
        version:  version object
    Returns:
        1. Boolean indicating atypical behavior,
        2. value associated with atypical interaction (None if Boolean is
           False)
    """
    exception = True
    value_tot = 0.00
    # needs to be this way since you want to find shortest distance first
    atoms_coo = []
    atoms_coo.extend(group_coo.get_interaction_atoms(group_arg))
    atoms_arg = []
    atoms_arg.extend(group_arg.get_interaction_atoms(group_coo))
    for _ in ["shortest", "runner-up"]:
        # find the closest interaction pair
        [closest_coo_atom, dist,
         closest_arg_atom] = get_smallest_distance(atoms_coo, atoms_arg)
        [dpka_max, cutoff
         ] = version.get_hydrogen_bond_parameters(closest_coo_atom,
                                                  closest_arg_atom)
        # calculate and sum up interaction energy
        f_angle = 1.00
        if (group_arg.type in
                version.parameters.angular_dependent_sidechain_interactions):
            atom3 = closest_arg_atom.bonded_atoms[0]
            dist, f_angle, _ = angle_distance_factors(closest_coo_atom,
                                                      closest_arg_atom, atom3)
        value = hydrogen_bond_energy(dist, dpka_max, cutoff, f_angle)
        value_tot += value
        # remove closest atoms before we attemp to find the runner-up pair
        atoms_coo.remove(closest_coo_atom)
        atoms_arg.remove(closest_arg_atom)
    return exception, value_tot
Example #3
0
def set_backbone_determinants(titratable_groups, backbone_groups, version):
    """Set determinants between titrable and backbone groups.

    Args:
        titratable_groups:  list of titratable groups
        backbone_groups:  list of backbone groups
        version:  version object
    """
    for titratable_group in titratable_groups:
        titratable_group_interaction_atoms = (
            titratable_group.interaction_atoms_for_acids)
        if not titratable_group_interaction_atoms:
            continue
        # find out which backbone groups this titratable is interacting with
        for backbone_group in backbone_groups:
            # find the interacting atoms
            backbone_interaction_atoms = (
                backbone_group.get_interaction_atoms(titratable_group))
            if not backbone_interaction_atoms:
                continue
            # find the smallest distance
            [backbone_atom, distance, titratable_atom
             ] = (get_smallest_distance(backbone_interaction_atoms,
                                        titratable_group_interaction_atoms))
            # get the parameters
            parameters = (version.get_backbone_hydrogen_bond_parameters(
                backbone_atom, titratable_atom))
            if not parameters:
                continue
            [dpka_max, [cutoff1, cutoff2]] = parameters
            if distance < cutoff2:
                # calculate angle factor
                f_angle = 1.0
                # for BBC groups, the hydrogen is on the titratable group
                #
                #        Titra.
                #       /
                #      H
                #     .
                #    O
                #    ||
                #    C
                if backbone_group.type == 'BBC':
                    if (titratable_group.type in version.parameters.
                            angular_dependent_sidechain_interactions):
                        if titratable_atom.element == 'H':
                            heavy_atom = titratable_atom.bonded_atoms[0]
                            hydrogen_atom = titratable_atom
                            [_, f_angle,
                             _] = angle_distance_factors(atom1=heavy_atom,
                                                         atom2=hydrogen_atom,
                                                         atom3=backbone_atom)
                        else:
                            # Either the structure is corrupt (no hydrogen),
                            # or the heavy atom is closer to the titratable
                            # atom than the hydrogen. In either case we set the
                            # angle factor to 0
                            f_angle = 0.0
                # for BBN groups, the hydrogen is on the backbone group
                #
                #      Titra.
                #     .
                #    H
                #    |
                #    N
                #  /   \
                if backbone_group.type == 'BBN':
                    if backbone_atom.element == 'H':
                        backbone_n = backbone_atom.bonded_atoms[0]
                        backbone_h = backbone_atom
                        [_, f_angle,
                         _] = (angle_distance_factors(atom1=titratable_atom,
                                                      atom2=backbone_h,
                                                      atom3=backbone_n))
                    else:
                        # Either the structure is corrupt (no hydrogen), or the
                        # heavy atom is closer to the titratable atom than the
                        # hydrogen. In either case we set the angle factor to 0
                        f_angle = 0.0
                if f_angle > FANGLE_MIN:
                    value = (titratable_group.charge * hydrogen_bond_energy(
                        distance, dpka_max, [cutoff1, cutoff2], f_angle))
                    new_determinant = Determinant(backbone_group, value)
                    titratable_group.determinants['backbone'].append(
                        new_determinant)
Example #4
0
def hydrogen_bond_interaction(group1, group2, version):
    """Calculate energy for hydrogen bond interactions between two groups.

    Args:
        group1:  first interacting group
        group2:  second interacting group
        version:  an object that contains version-specific parameters
    Returns:
        hydrogen bond interaction energy
    """
    # find the smallest distance between interacting atoms
    atoms1 = group1.get_interaction_atoms(group2)
    atoms2 = group2.get_interaction_atoms(group1)
    [closest_atom1, dist,
     closest_atom2] = get_smallest_distance(atoms1, atoms2)
    if None in [closest_atom1, closest_atom2]:
        warning('Side chain interaction failed for {0:s} and {1:s}'.format(
            group1.label, group2.label))
        return None
    # get the parameters
    [dpka_max,
     cutoff] = version.get_hydrogen_bond_parameters(closest_atom1,
                                                    closest_atom2)
    if (dpka_max is None) or (None in cutoff):
        return None
    # check that the closest atoms are close enough
    if dist >= cutoff[1]:
        return None
    # check that bond distance criteria is met
    min_hbond_dist = version.parameters.min_bond_distance_for_hydrogen_bonds
    if group1.atom.is_atom_within_bond_distance(group2.atom, min_hbond_dist,
                                                1):
        return None
    # set angle factor
    f_angle = 1.0
    if group2.type in version.parameters.angular_dependent_sidechain_interactions:
        if closest_atom2.element == 'H':
            heavy_atom = closest_atom2.bonded_atoms[0]
            hydrogen = closest_atom2
            dist, f_angle, _ = angle_distance_factors(closest_atom1, hydrogen,
                                                      heavy_atom)
        else:
            # Either the structure is corrupt (no hydrogen), or the heavy atom
            # is closer to the titratable atom than the hydrogen. In either
            # case, we set the angle factor to 0
            f_angle = 0.0
    elif group1.type in version.parameters.angular_dependent_sidechain_interactions:
        if closest_atom1.element == 'H':
            heavy_atom = closest_atom1.bonded_atoms[0]
            hydrogen = closest_atom1
            dist, f_angle, _ = angle_distance_factors(closest_atom2, hydrogen,
                                                      heavy_atom)
        else:
            # Either the structure is corrupt (no hydrogen), or the heavy atom
            # is closer to the titratable atom than the hydrogen. In either
            # case, we set the angle factor to 0
            f_angle = 0.0
    weight = version.calculate_pair_weight(group1.num_volume,
                                           group2.num_volume)
    exception, value = version.check_exceptions(group1, group2)
    if exception:
        # Do nothing, value should have been assigned.
        pass
    else:
        value = version.calculate_side_chain_energy(dist, dpka_max, cutoff,
                                                    weight, f_angle)
    return value