Пример #1
0
def set_ion_determinants(conformation_container, version):
    """Add ion determinants and perturbations.

    Args:
        conformation_container:  conformation to set
        version:  version object
    """
    for titratable_group in conformation_container.get_titratable_groups():
        for ion_group in conformation_container.get_ions():
            dist_sq = squared_distance(titratable_group, ion_group)
            if dist_sq < version.parameters.coulomb_cutoff2_squared:
                weight = version.calculate_pair_weight(
                    titratable_group.num_volume, ion_group.num_volume)
                # the pKa of both acids and bases are shifted up by negative
                # ions (and vice versa)
                value = (-ion_group.charge * version.calculate_coulomb_energy(
                    math.sqrt(dist_sq), weight))
                new_det = Determinant(ion_group, value)
                titratable_group.determinants['coulomb'].append(new_det)
Пример #2
0
def radial_volume_desolvation(parameters, group):
    """Calculate desolvation terms for group.

    Args:
        parameters:  parameters for desolvation calculation
        group:  group of atoms for calculation
    """
    all_atoms = group.atom.conformation_container.get_non_hydrogen_atoms()
    volume = 0.0
    group.num_volume = 0
    min_dist_4th = MIN_DISTANCE_4TH
    for atom in all_atoms:
        # ignore atoms in the same residue
        if (atom.res_num == group.atom.res_num
                and atom.chain_id == group.atom.chain_id):
            continue
        sq_dist = squared_distance(group, atom)
        # desolvation
        if sq_dist < parameters.desolv_cutoff_squared:
            # use a default relative volume of 1.0 if the volume of the element
            # is not found in parameters
            # insert check for methyl groups
            if atom.element == 'C' and atom.name not in ['CA', 'C']:
                dvol = parameters.VanDerWaalsVolume['C4']
            else:
                dvol = parameters.VanDerWaalsVolume.get(atom.element, 1.0)
            dv_inc = dvol / max(min_dist_4th, sq_dist * sq_dist)
            volume += dv_inc
        # buried
        if sq_dist < parameters.buried_cutoff_squared:
            group.num_volume += 1
    group.buried = calculate_weight(parameters, group.num_volume)
    scale_factor = calculate_scale_factor(parameters, group.buried)
    volume_after_allowance = max(0.00,
                                 volume - parameters.desolvationAllowance)
    group.energy_volume = (group.charge * parameters.desolvationPrefactor *
                           volume_after_allowance * scale_factor)
Пример #3
0
def assign_sybyl_type(atom):
    """Assign Sybyl type to atom.

    Args:
        atom:  atom to assign
    """
    # check if we already have assigned a name to this atom
    if atom.sybyl_assigned:
        return
    # find some properties of the atom
    ring_atoms = is_ring_member(atom)
    aromatic = is_aromatic_ring(ring_atoms)
    planar = is_planar(atom)
    bonded_elements = {}
    for i, bonded_atom in enumerate(atom.bonded_atoms):
        bonded_elements[i] = bonded_atom.element
    # Aromatic carbon/nitrogen
    if aromatic:
        for ring_atom in ring_atoms:
            if ring_atom.element in ['C', 'N']:
                set_type(ring_atom, ring_atom.element + '.ar')
        return
    # check for amide
    if atom.element in ['O', 'N', 'C']:
        o_atom = None
        n_atom = None
        c_atom = None
        # oxygen, nitrogen
        if atom.element in ['O', 'N']:
            for bonded_elem in atom.get_bonded_elements('C'):
                for bonded_atom in bonded_elem.bonded_atoms:
                    if (bonded_atom.element == 'N' and atom.element == 'O'):
                        o_atom = atom
                        c_atom = bonded_elem
                        n_atom = bonded_atom
                    elif (bonded_atom.element == 'O' and atom.element == 'N'):
                        n_atom = atom
                        c_atom = bonded_elem
                        o_atom = bonded_atom
        # carbon
        if atom.element == 'C':
            nitrogens = atom.get_bonded_elements('N')
            oxygens = atom.get_bonded_elements('O')
            if len(nitrogens) == 1 and len(oxygens) == 1:
                c_atom = atom
                n_atom = nitrogens[0]
                o_atom = oxygens[0]
        if c_atom and n_atom and o_atom:
            # make sure that the Nitrogen is not aromatic and that it has two
            # heavy atom bonds
            if (not is_aromatic_ring(is_ring_member(n_atom))
                    and len(n_atom.get_bonded_heavy_atoms()) == 2):
                set_type(n_atom, 'N.am')
                set_type(c_atom, 'C.2')
                set_type(o_atom, 'O.2')
                return
    if atom.element == 'C':
        # check for carboxyl
        if (len(atom.bonded_atoms) == 3
                and list(bonded_elements.values()).count('O') == 2):
            index1 = list(bonded_elements.values()).index('O')
            index2 = list(bonded_elements.values()).index('O', index1 + 1)
            if (len(atom.bonded_atoms[index1].bonded_atoms) == 1
                    and len(atom.bonded_atoms[index2].bonded_atoms) == 1):
                set_type(atom.bonded_atoms[index1], 'O.co2-')
                set_type(atom.bonded_atoms[index2], 'O.co2')
                set_type(atom, 'C.2')
                return
        # sp carbon
        if len(atom.bonded_atoms) <= 2:
            for bonded_atom in atom.bonded_atoms:
                if (squared_distance(atom, bonded_atom) <
                        MAX_C_TRIPLE_BOND_SQUARED):
                    set_type(atom, 'C.1')
                    set_type(bonded_atom, bonded_atom.element + '.1')
            if atom.sybyl_assigned:
                return
        # sp2 carbon
        if planar:
            set_type(atom, 'C.2')
            # check for N.pl3
            for bonded_atom in atom.bonded_atoms:
                if bonded_atom.element == 'N':
                    if (len(bonded_atom.bonded_atoms) < 3
                            or is_planar(bonded_atom)):
                        set_type(bonded_atom, 'N.pl3')
            return
        # sp3 carbon
        set_type(atom, 'C.3')
        return
    # Nitrogen
    if atom.element == 'N':
        # check for planar N
        if len(atom.bonded_atoms) == 1:
            if is_planar(atom.bonded_atoms[0]):
                set_type(atom, 'N.pl3')
                return
        if planar:
            set_type(atom, 'N.pl3')
            return
        set_type(atom, 'N.3')
        return
    # Oxygen
    if atom.element == 'O':
        set_type(atom, 'O.3')
        if len(atom.bonded_atoms) == 1:
            # check for carboxyl
            if atom.bonded_atoms[0].element == 'C':
                the_carbon = atom.bonded_atoms[0]
                if (len(the_carbon.bonded_atoms) == 3
                        and the_carbon.count_bonded_elements('O') == 2):
                    [oxy1, oxy2] = the_carbon.get_bonded_elements('O')
                    if (len(oxy1.bonded_atoms) == 1
                            and len(oxy2.bonded_atoms) == 1):
                        set_type(oxy1, 'O.co2-')
                        set_type(oxy2, 'O.co2')
                        set_type(the_carbon, 'C.2')
                        return
            # check for X=O
            if (squared_distance(atom, atom.bonded_atoms[0]) <
                    MAX_C_DOUBLE_BOND_SQUARED):
                set_type(atom, 'O.2')
                if atom.bonded_atoms[0].element == 'C':
                    set_type(atom.bonded_atoms[0], 'C.2')
        return
    # Sulphur
    if atom.element == 'S':
        # check for SO2
        if list(bonded_elements.values()).count('O') == 2:
            index1 = list(bonded_elements.values()).index('O')
            index2 = list(bonded_elements.values()).index('O', index1 + 1)
            set_type(atom.bonded_atoms[index1], 'O.2')
            set_type(atom.bonded_atoms[index2], 'O.2')
            set_type(atom, 'S.o2')
            return
        # check for SO4
        if list(bonded_elements.values()).count('O') == 4:
            no_o2 = 0
            for i in range(len(atom.bonded_atoms)):
                if len(atom.bonded_atoms[i].bonded_atoms) == 1 and no_o2 < 2:
                    set_type(atom.bonded_atoms[i], 'O.2')
                    no_o2 += 1
                else:
                    set_type(atom.bonded_atoms[i], 'O.3')
        set_type(atom, 'S.3')
        return
    # Phosphorus
    if atom.element == 'P':
        set_type(atom, 'P.3')
        # check for phosphate group
        bonded_oxygens = atom.get_bonded_elements('O')
        for o_atom in bonded_oxygens:
            set_type(o_atom, 'O.3')
        return
    element = atom.element.capitalize()
    set_type(atom, element)