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

# RingSymmetryEnergy

> Energy that maximises the symmetry of different groups. Symmetry is measured by finding the centroid of the backbone of each group and checking how consistently they are spaced from one another.

## Definition

The ring symmetry energy is the standard deviation of pairwise centroid distances between groups, penalizing asymmetric spacing.

$$
E_{\mathrm{sym}} = \mathrm{std}\left(d_{G_i, G_j}\right)
$$

* $d_{G_i, G_j}$ is the distance between the backbone centroids of groups $G_i$ and $G_j$
* The standard deviation is taken over all unique group pairs (or only direct neighbours if `direct_neighbours_only=True`)

## Parameters

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

<ResponseField name="symmetry_groups" type="list[list[Residue]]" required>
  A list of at least length 2, with each element containing a list of residues corresponding to a symmetry group.
</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="direct_neighbours_only" type="bool" default="False">
  Whether to compare the spacing of each each group to its direct neighbour (compare group i to group i+1 only), or each group to all other groups. Defaults to the latter.
</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 numpy as np
import bagel as bg

# Create a 190-residue chain
sequence = np.random.choice(list(bg.constants.aa_dict.keys()), size=190)
residues = [bg.Residue(name=aa, chain_ID="A", index=i, mutable=True) for i, aa in enumerate(sequence)]

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

# Define 4 symmetry groups of 40 residues each (with 10-residue gaps)
symmetry_groups = [residues[i * 50 : (i * 50) + 40] for i in range(4)]

ring_symmetry = bg.energies.RingSymmetryEnergy(
    oracle=esmfold,
    symmetry_groups=symmetry_groups,
    weight=1.0,
)

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