openfe_analysis.utils.universe_utils

Functions

create_universe_single_state(top, trj, state)

Construct a raw MDAnalysis Universe for a single thermodynamic state.

guess_ligand_bonds(atomgroup[, delete_existing])

Guess bonds for a ligand AtomGroup in-place.

select_state_atoms(universe, end_state)

Select all atoms present at a given end state.

openfe_analysis.utils.universe_utils.select_state_atoms(universe: MDAnalysis.Universe, end_state: Literal['A', 'B']) MDAnalysis.AtomGroup

Select all atoms present at a given end state.

Atoms are identified by their b-factor values:

  • 0.25 — unique to state A

  • 0.75 — unique to state B

  • 0.5 — shared by both end states

Parameters:
  • universe (mda.Universe) – Universe containing the hybrid topology.

  • end_state ({"A", "B"}) – The end state to select atoms for.

Returns:

All atoms present at the given end state.

Return type:

mda.AtomGroup

Raises:

ValueError – If end_state is not "A" or "B".

openfe_analysis.utils.universe_utils.guess_ligand_bonds(atomgroup: MDAnalysis.AtomGroup, delete_existing: bool = False) None

Guess bonds for a ligand AtomGroup in-place.

Parameters:
  • atomgroup (mda.AtomGroup) – Ligand atoms for which bonds will be guessed.

  • delete_existing (bool, optional) – If True, delete existing bonds on the atomgroup before guessing. This may be necessary to avoid cross-state bonds in hybrid topologies. Default is False.

openfe_analysis.utils.universe_utils.create_universe_single_state(top: Path | mda.core.topology.Topology, trj: nc.Dataset, state: int) mda.Universe

Construct a raw MDAnalysis Universe for a single thermodynamic state.

Parameters:
  • top (pathlib.Path | mda.core.topology.Topology) – Path to a topology file (e.g. PDB).

  • trj (nc.Dataset) – Open NetCDF dataset produced by openmmtools.multistate.MultiStateReporter.

  • state (int) – Thermodynamic state index to extract from the multistate trajectory.

Returns:

A Universe with no trajectory transformations applied.

Return type:

mda.Universe