Skip to content

class_hydrophobicity.py

Computation is based on next formula:

\[ \phi_{\text{hydr}} = - \displaystyle\sum_{s=1}^S K_s \displaystyle\sum_{a=1}^{A_s} \exp \left[ - \dfrac{\left( \mu_{\text{hydr}} - d_a \right)^2}{2 \sigma_{\text{hydr}}^2} \right] \]

With \(\phi*{\text{hydr}}\) the field in a 3D space, \(S\) the total number of selected “chemical specie” (residues, RNA base, sugar or phosphate), \(K_s\) the chemical specie hydrophobicity score (from Kyte Doolittle Scale), \(A_r\) the selected atoms from the residue \(r\), \(\mu*{\text{hydr}} (= 4.0~\text{Å})\) the mean (distance residue / receptor), \(d*a\) the distance, \(\sigma*{\text{hydr}}^2\) (with \(\sigma*\text{hydr}= 1.5~\text{Å})\) the variance (distance residue / receptor).

Contains a class with strategy to fill a grid with hydrophobic properties.

StrategyHydrophobic

Bases: StrategyProperty

A class for defining strategies to fill a grid with hydrophobic
properties.

Inheritance

This class is the child of StrategyProperty. Check this one for other
attributes and methods definitions.

Source code in src/smiffer/grid/property_strategy/class_hydrophobicity.py
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
class StrategyHydrophobic(StrategyProperty):
    """A class for defining strategies to fill a grid with hydrophobic
    properties.

    Inheritance
    -----------
    This class is the child of `StrategyProperty`. Check this one for other
    **attributes** and **methods** definitions.
    """

    def __init__(
        self, name: str, atom_constant: object, macro_type: str, key: str
    ):
        super().__init__(name, atom_constant)

        if macro_type not in ["protein", "nucleic"]:
            raise ValueError(
                f'[Err##] macro_type "{macro_type}" not accepted. List of '
                'accepted macro_types are "["protein", '
                '"nucleic"]".'
            )

        if key not in ["hydrophobic", "hydrophilic"]:
            raise ValueError(
                f'[Err##] key "{key}" not accepted. List of '
                'accepted keys are "["hydrophobic", '
                '"hydrophilic"]".'
            )

        self._isNucleic: bool = macro_type == "nucleic"
        self._key: str = key

    def populate_grid(self, grid: np.ndarray, grid_object) -> None:
        """Populate a grid following H-bond properties.

        Parameters
        ----------
        grid : `np.ndarray`
            The grid to fill.

        grid_object : `Grid`
            The grid object to access all attributes.
        """
        do_hydrophobic: bool = self._key == "hydrophobic"

        if do_hydrophobic:
            radius: float = (
                grid_object.yaml["function_hydrophobic_mu"]
                + grid_object.yaml["function_hydrophobic_sigma"]
                * grid_object.yaml["other_gaussian_kernel_scalar"]
            )

            kernel: GaussianKernel = GaussianKernel(
                radius=radius,
                delta=grid_object.delta,
                v_mu=grid_object.yaml["function_hydrophobic_mu"],
                v_sigma=grid_object.yaml["function_hydrophobic_sigma"],
            )

        else:
            radius: float = (
                grid_object.yaml["function_hydrophilic_mu"]
                + grid_object.yaml["function_hydrophilic_sigma"]
                * grid_object.yaml["other_gaussian_kernel_scalar"]
            )

            kernel: GaussianKernel = GaussianKernel(
                radius=radius,
                delta=grid_object.delta,
                v_mu=grid_object.yaml["function_hydrophilic_mu"],
                v_sigma=grid_object.yaml["function_hydrophilic_sigma"],
            )

        stamp: Stamp = Stamp(
            grid=grid,
            grid_origin=grid_object.coord[0],
            delta=grid_object.delta,
            kernel=kernel,
        )

        for atom in grid_object.molecule:
            # atom is part of a protein
            if not self._isNucleic:
                mul_factor = self._atom_constant["ww_scale"][atom.resname]

            # atom is in the nitrogenous base (RNA)
            elif (
                atom.name in self._atom_constant["nucleic_bases"][atom.resname]
            ):
                mul_factor = self._atom_constant["ww_scale"][atom.resname]

            # atom is part of the phosphate backbone (RNA)
            elif atom.name in self._atom_constant["backbone_phosphate"]:
                mul_factor = self._atom_constant["hphil_rna_phosphate"]

            # atom is part of the sugar (RNA)
            elif atom.name in self._atom_constant["backbone_sugar"]:
                mul_factor = self._atom_constant["hphil_rna_sugar"]

            # unknown atom type
            else:
                continue

            # skip hydrophilic atoms in the hydrophobic grid
            if do_hydrophobic:
                if mul_factor < 0:
                    continue

            # skip hydrophobic atoms in the hydrophilic grid
            elif mul_factor > 0:
                continue

            stamp.stamp_kernel(
                center=atom.position,
                factor=np.abs(mul_factor),
            )

populate_grid(grid, grid_object)

Populate a grid following H-bond properties.

Parameters

grid : np.ndarray
The grid to fill.

Grid

The grid object to access all attributes.

Source code in src/smiffer/grid/property_strategy/class_hydrophobicity.py
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
def populate_grid(self, grid: np.ndarray, grid_object) -> None:
    """Populate a grid following H-bond properties.

    Parameters
    ----------
    grid : `np.ndarray`
        The grid to fill.

    grid_object : `Grid`
        The grid object to access all attributes.
    """
    do_hydrophobic: bool = self._key == "hydrophobic"

    if do_hydrophobic:
        radius: float = (
            grid_object.yaml["function_hydrophobic_mu"]
            + grid_object.yaml["function_hydrophobic_sigma"]
            * grid_object.yaml["other_gaussian_kernel_scalar"]
        )

        kernel: GaussianKernel = GaussianKernel(
            radius=radius,
            delta=grid_object.delta,
            v_mu=grid_object.yaml["function_hydrophobic_mu"],
            v_sigma=grid_object.yaml["function_hydrophobic_sigma"],
        )

    else:
        radius: float = (
            grid_object.yaml["function_hydrophilic_mu"]
            + grid_object.yaml["function_hydrophilic_sigma"]
            * grid_object.yaml["other_gaussian_kernel_scalar"]
        )

        kernel: GaussianKernel = GaussianKernel(
            radius=radius,
            delta=grid_object.delta,
            v_mu=grid_object.yaml["function_hydrophilic_mu"],
            v_sigma=grid_object.yaml["function_hydrophilic_sigma"],
        )

    stamp: Stamp = Stamp(
        grid=grid,
        grid_origin=grid_object.coord[0],
        delta=grid_object.delta,
        kernel=kernel,
    )

    for atom in grid_object.molecule:
        # atom is part of a protein
        if not self._isNucleic:
            mul_factor = self._atom_constant["ww_scale"][atom.resname]

        # atom is in the nitrogenous base (RNA)
        elif (
            atom.name in self._atom_constant["nucleic_bases"][atom.resname]
        ):
            mul_factor = self._atom_constant["ww_scale"][atom.resname]

        # atom is part of the phosphate backbone (RNA)
        elif atom.name in self._atom_constant["backbone_phosphate"]:
            mul_factor = self._atom_constant["hphil_rna_phosphate"]

        # atom is part of the sugar (RNA)
        elif atom.name in self._atom_constant["backbone_sugar"]:
            mul_factor = self._atom_constant["hphil_rna_sugar"]

        # unknown atom type
        else:
            continue

        # skip hydrophilic atoms in the hydrophobic grid
        if do_hydrophobic:
            if mul_factor < 0:
                continue

        # skip hydrophobic atoms in the hydrophilic grid
        elif mul_factor > 0:
            continue

        stamp.stamp_kernel(
            center=atom.position,
            factor=np.abs(mul_factor),
        )