> ## 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.

# SeparationEnergy

> Energy that minimizes the distance between two groups of residues. The position of each group is defined as the centroid of the backbone atoms of the residues belonging of that group.

## Definition

The separation energy is the Euclidean distance between the backbone centroids of two residue groups.

$$
E_{\mathrm{sep}} = \| \mathbf{c}_1 - \mathbf{c}_2 \|
$$

* $\mathbf{c}_1$ and $\mathbf{c}_2$ are the centroids of the backbone atoms in residue groups 1 and 2
* If a custom `function` $f$ is provided, the energy becomes $E_{\mathrm{sep}} = f(\| \mathbf{c}_1 - \mathbf{c}_2 \|)$

## Parameters

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

<ResponseField name="residues" type="tuple[list[Residue], list[Residue]]" required>
  A tuple containing two lists of residues, those to include in the first \[0] and second \[1] group.
</ResponseField>

<ResponseField name="function" type="Callable[[float], float] | None" default="None">
  Optional callable f(x) applied to the centroid distance x (in Å) before weighting. If None, the identity function is used (i.e., energy equals the distance).
</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="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()

# Define two groups of residues (e.g. hotspot and binder)
hotspot_residues = [residues_target[i] for i in range(10, 20)]
binder_residues = residues_binder

# Minimize the distance between the centroids of the two groups
separation = bg.energies.SeparationEnergy(
    oracle=esmfold,
    residues=[hotspot_residues, binder_residues],
    weight=1.0,
)

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