> ## Documentation Index
> Fetch the complete documentation index at: https://bagel.softnanolab.com/llms.txt
> Use this file to discover all available pages before exploring further.

# HydrophobicEnergy

> Energy Proportional to the amount of hydrophobic residues present. This is measured by the fraction of selected atoms that belong to hydrophobic residues (valine, isoleucine, leucine, phenylalanine, methionine, tryptophan).

## Definition

The hydrophobic energy is the fraction of atoms belonging to hydrophobic residues within the selected group.

$$
E_{\mathrm{hydrophobic}} = \frac{N_{\mathrm{hydrophobic}}}{N_{G}}
$$

* $N_{\mathrm{hydrophobic}}$ is the count of atoms belonging to hydrophobic residues (V, I, L, F, M, W) in the group
* $N_G$ is the total atom count in the group

When `mode` is set to `'surface'` or `'core'`, this fraction is additionally weighted by the mean normalized SASA of the hydrophobic atoms.

## Parameters

<ResponseField name="oracle" type="FoldingOracle" required>
  The oracle to use for the energy term.
</ResponseField>

<ResponseField name="inheritable" type="bool" default="True">
  If a new residue is added next to a residue included in this energy term, this dictates whether that new residue could then be added to this energy term.
</ResponseField>

<ResponseField name="residues" type="list[Residue] | None" default="None">
  Which residues to include in the calculation. If not set, simply considers **all** residues by default.
</ResponseField>

<ResponseField name="mode" type="Literal['surface', 'core', 'all']" default="'all'">
  Selection of which atoms contribute to the hydrophobicity score: - 'surface': counts hydrophobic residues at the surface, weighted by normalised SASA - 'core': counts hydrophobic residues in the core, weighted by 1 - normalised SASA - 'all': counts all hydrophobic residues, no SASA weighting Normalisation uses `max_sasa_values['S']` and the probe radius `probe_radius_water`.
</ResponseField>

<ResponseField name="surface_only" type="bool" default="False">
  Deprecated. Use `mode='surface'` instead.
</ResponseField>

<ResponseField name="core_only" type="bool" default="False">
  Deprecated. Use `mode='core'` instead.
</ResponseField>

<ResponseField name="weight" type="float" default="1.0">
  The weight of the energy term.
</ResponseField>

<ResponseField name="name" type="str | None" default="None">
  Optional name to append to the energy term name.
</ResponseField>

## Methods

### compute

**Parameters**

<ResponseField name="oracles_result" type="OraclesResultDict" required />

## Example

```python theme={null}
import bagel as bg

# Create the folding oracle
esmfold = bg.oracles.ESMFold()

# Penalize surface hydrophobic residues (default mode='all' counts everywhere)
hydrophobic = bg.energies.HydrophobicEnergy(
    oracle=esmfold,
    weight=5.0,
    mode="surface",
)

# Add to a state
state = bg.State(
    chains=[chain],
    energy_terms=[hydrophobic],
    name="my_state",
)
```
