Skip to content

config #

Common configuration models.

Classes:

  • FlatBottomRestraint

    Configuration for a flat bottom restraint.

  • BoreschRestraint

    Configuration for a Boresch style restraint between three receptor atoms

  • Solvent

    Configuration for solvating a system.

  • LangevinIntegrator

    Configuration for a Langevin integrator.

  • REST

    Configure REST2 setup.

  • Minimization

    Configuration for a minimization.

  • Simulation

    Configuration for an MD simulation.

  • Anneal

    Configuration for a temperature annealing NVT MD simulation.

  • HREMDSwapMode

    The mode in which to propose state swaps between replicas.

  • HREMD

    Configuration for Hamiltonian replica exchange sampling

Functions:

Attributes:

DEFAULT_TEMPERATURE module-attribute #

DEFAULT_TEMPERATURE = 298.15 * kelvin

The default temperature to simulate at

DEFAULT_PRESSURE module-attribute #

DEFAULT_PRESSURE = 1.0 * bar

The default pressure to simulate at

DEFAULT_TLEAP_SOURCES module-attribute #

DEFAULT_TLEAP_SOURCES = [
    "leaprc.water.tip3p",
    "leaprc.protein.ff14SB",
]

The default Leap parameter files to load when parameterizing the solvent / receptor

FlatBottomRestraint pydantic-model #

Bases: BaseModel

Configuration for a flat bottom restraint.

Fields:

k pydantic-field #

k: OpenMMQuantity[_KCAL_PER_ANG_SQR]

Force constant [kcal/mol/Å^2] of the restraint.

radius pydantic-field #

radius: OpenMMQuantity[_ANGSTROM]

The radius [Å] of the restraint.

model_dump_yaml #

model_dump_yaml(
    output_path: Path | None = None, **kwargs
) -> str

Dump the model to a YAML representation.

Parameters:

  • output_path (Path | None, default: None ) –

    The (optional) path to save the YAML representation to.

Returns:

  • str

    The YAML representation.

Source code in femto/md/utils/models.py
def model_dump_yaml(self, output_path: pathlib.Path | None = None, **kwargs) -> str:
    """Dump the model to a YAML representation.

    Args:
        output_path: The (optional) path to save the YAML representation to.

    Returns:
        The YAML representation.
    """

    model_yaml = yaml.safe_dump(self.model_dump(), **kwargs)

    if output_path is not None:
        output_path.parent.mkdir(exist_ok=True, parents=True)
        output_path.write_text(model_yaml)

    return model_yaml

BoreschRestraint pydantic-model #

Bases: BaseModel

Configuration for a Boresch style restraint between three receptor atoms (r1, r2, r3) and three ligand atoms (l1, l2, l3).

Fields:

k_distance pydantic-field #

k_distance: OpenMMQuantity[_KCAL_PER_ANG_SQR]

Force constant [kcal/mol/Å^2] of the harmonic distance restraint between r3 and l1.

k_angle_a pydantic-field #

k_angle_a: OpenMMQuantity[_KCAL_PER_RAD_SQR]

Force constant [kcal/mol/rad^2] of the harmonic angle restraint on the angle formed by r2, r3, and l1.

k_angle_b pydantic-field #

k_angle_b: OpenMMQuantity[_KCAL_PER_RAD_SQR]

Force constant [kcal/mol/rad^2] of the harmonic angle restraint on the angle formed by r3, l1, and l2.

k_dihedral_a pydantic-field #

k_dihedral_a: OpenMMQuantity[_KCAL_PER_RAD_SQR]

Force constant [kcal/mol/rad^2] of the harmonic dihedral restraint on the dihedral angle formed by r1, r2, r3, and l1.

k_dihedral_b pydantic-field #

k_dihedral_b: OpenMMQuantity[_KCAL_PER_RAD_SQR]

Force constant [kcal/mol/rad^2] of the harmonic dihedral restraint on the dihedral angle formed by r2, r3, l1, and l2.

k_dihedral_c pydantic-field #

k_dihedral_c: OpenMMQuantity[_KCAL_PER_RAD_SQR]

Force constant [kcal/mol/rad^2] of the harmonic dihedral restraint on the dihedral angle formed by r3, l1, l2, and l3.

model_dump_yaml #

model_dump_yaml(
    output_path: Path | None = None, **kwargs
) -> str

Dump the model to a YAML representation.

Parameters:

  • output_path (Path | None, default: None ) –

    The (optional) path to save the YAML representation to.

Returns:

  • str

    The YAML representation.

Source code in femto/md/utils/models.py
def model_dump_yaml(self, output_path: pathlib.Path | None = None, **kwargs) -> str:
    """Dump the model to a YAML representation.

    Args:
        output_path: The (optional) path to save the YAML representation to.

    Returns:
        The YAML representation.
    """

    model_yaml = yaml.safe_dump(self.model_dump(), **kwargs)

    if output_path is not None:
        output_path.parent.mkdir(exist_ok=True, parents=True)
        output_path.write_text(model_yaml)

    return model_yaml

Solvent pydantic-model #

Bases: BaseModel

Configuration for solvating a system.

Fields:

Validators:

  • _validate_n_waters

ionic_strength pydantic-field #

ionic_strength: OpenMMQuantity[molar] = 0.0 * molar

The total concentration of ions pairs (anion and cation) to add to approximate an ionic strength. This does not include ions that are added to neutralize the system.

neutralize pydantic-field #

neutralize: bool = True

Whether to add counter ions to neutralize the system.

cation pydantic-field #

cation: Literal['Na+', 'K+'] = 'K+'

The cation to use when neutralizing the system.

anion pydantic-field #

anion: Literal['Cl-'] = 'Cl-'

The anion to use when neutralizing the system.

water_model pydantic-field #

water_model: Literal['tip3p'] = 'tip3p'

The water model to use.

tleap_sources pydantic-field #

tleap_sources: list[str] = [*DEFAULT_TLEAP_SOURCES]

The tLeap parameters to source when parameterizing the system minus any ligands (and possibly receptors) which should be handled separately

box_padding pydantic-field #

box_padding: OpenMMQuantity[_ANGSTROM] | None = (
    10.0 * _ANGSTROM
)

The minimum distance between any complex atom (including any offset ligands) and the box wall. This option is mutually exclusive with n_waters.

n_waters pydantic-field #

n_waters: int | None = None

The number of extra waters to solvate the complex using. This option is mutually exclusive with box_padding.

model_dump_yaml #

model_dump_yaml(
    output_path: Path | None = None, **kwargs
) -> str

Dump the model to a YAML representation.

Parameters:

  • output_path (Path | None, default: None ) –

    The (optional) path to save the YAML representation to.

Returns:

  • str

    The YAML representation.

Source code in femto/md/utils/models.py
def model_dump_yaml(self, output_path: pathlib.Path | None = None, **kwargs) -> str:
    """Dump the model to a YAML representation.

    Args:
        output_path: The (optional) path to save the YAML representation to.

    Returns:
        The YAML representation.
    """

    model_yaml = yaml.safe_dump(self.model_dump(), **kwargs)

    if output_path is not None:
        output_path.parent.mkdir(exist_ok=True, parents=True)
        output_path.write_text(model_yaml)

    return model_yaml

LangevinIntegrator pydantic-model #

Bases: BaseModel

Configuration for a Langevin integrator.

Fields:

constraint_tolerance pydantic-field #

constraint_tolerance: float = 1e-06

The tolerance with which constraints are maintained.

model_dump_yaml #

model_dump_yaml(
    output_path: Path | None = None, **kwargs
) -> str

Dump the model to a YAML representation.

Parameters:

  • output_path (Path | None, default: None ) –

    The (optional) path to save the YAML representation to.

Returns:

  • str

    The YAML representation.

Source code in femto/md/utils/models.py
def model_dump_yaml(self, output_path: pathlib.Path | None = None, **kwargs) -> str:
    """Dump the model to a YAML representation.

    Args:
        output_path: The (optional) path to save the YAML representation to.

    Returns:
        The YAML representation.
    """

    model_yaml = yaml.safe_dump(self.model_dump(), **kwargs)

    if output_path is not None:
        output_path.parent.mkdir(exist_ok=True, parents=True)
        output_path.write_text(model_yaml)

    return model_yaml

REST pydantic-model #

Bases: BaseModel

Configure REST2 setup.

Fields:

scale_bonds pydantic-field #

scale_bonds: bool = False

Whether to scale bond force constants by beta_m / beta_0.

scale_angles pydantic-field #

scale_angles: bool = False

Whether to scale angle force constants by beta_m / beta_0.

scale_torsions pydantic-field #

scale_torsions: bool = True

Whether to scale torsion barrier heights by beta_m / beta_0.

scale_nonbonded pydantic-field #

scale_nonbonded: bool = True

Whether to scale non-bonded epsilons by beta_m / beta_0 and charges by sqrt(beta_m / beta_0).

model_dump_yaml #

model_dump_yaml(
    output_path: Path | None = None, **kwargs
) -> str

Dump the model to a YAML representation.

Parameters:

  • output_path (Path | None, default: None ) –

    The (optional) path to save the YAML representation to.

Returns:

  • str

    The YAML representation.

Source code in femto/md/utils/models.py
def model_dump_yaml(self, output_path: pathlib.Path | None = None, **kwargs) -> str:
    """Dump the model to a YAML representation.

    Args:
        output_path: The (optional) path to save the YAML representation to.

    Returns:
        The YAML representation.
    """

    model_yaml = yaml.safe_dump(self.model_dump(), **kwargs)

    if output_path is not None:
        output_path.parent.mkdir(exist_ok=True, parents=True)
        output_path.write_text(model_yaml)

    return model_yaml

Minimization pydantic-model #

Bases: BaseModel

Configuration for a minimization.

Fields:

restraints pydantic-field #

restraints: dict[str, FlatBottomRestraint] = {}

The position restraints to apply during the minimization. The keys should be AMBER style selection masks.

tolerance pydantic-field #

tolerance: OpenMMQuantity[_KCAL_PER_MOL / _ANGSTROM] = (
    10.0 * _KCAL_PER_MOL / _ANGSTROM
)

Minimization will be halted once the root-mean-square value of all force components reaches this tolerance.

max_iterations pydantic-field #

max_iterations: int = 0

The maximum number of iterations to perform. If 0, minimization will continue until the tolerance is met.

model_dump_yaml #

model_dump_yaml(
    output_path: Path | None = None, **kwargs
) -> str

Dump the model to a YAML representation.

Parameters:

  • output_path (Path | None, default: None ) –

    The (optional) path to save the YAML representation to.

Returns:

  • str

    The YAML representation.

Source code in femto/md/utils/models.py
def model_dump_yaml(self, output_path: pathlib.Path | None = None, **kwargs) -> str:
    """Dump the model to a YAML representation.

    Args:
        output_path: The (optional) path to save the YAML representation to.

    Returns:
        The YAML representation.
    """

    model_yaml = yaml.safe_dump(self.model_dump(), **kwargs)

    if output_path is not None:
        output_path.parent.mkdir(exist_ok=True, parents=True)
        output_path.write_text(model_yaml)

    return model_yaml

Simulation pydantic-model #

Bases: _SimulationStep

Configuration for an MD simulation.

Fields:

integrator pydantic-field #

integrator: LangevinIntegrator

The integrator to use during the simulation.

restraints pydantic-field #

restraints: dict[str, FlatBottomRestraint] = {}

The position restraints to apply during the minimization. The keys should be AMBER style selection masks.

temperature pydantic-field #

temperature: OpenMMQuantity[kelvin]

The temperature to simulate at.

pressure pydantic-field #

pressure: OpenMMQuantity[atmospheres] | None

The pressure to simulate at, or none to run in NVT.

barostat_frequency pydantic-field #

barostat_frequency: int = 25

The frequency at which to apply the barostat. This is ignored if pressure is None.

n_steps pydantic-field #

n_steps: int

The number of steps to simulate for.

model_dump_yaml #

model_dump_yaml(
    output_path: Path | None = None, **kwargs
) -> str

Dump the model to a YAML representation.

Parameters:

  • output_path (Path | None, default: None ) –

    The (optional) path to save the YAML representation to.

Returns:

  • str

    The YAML representation.

Source code in femto/md/utils/models.py
def model_dump_yaml(self, output_path: pathlib.Path | None = None, **kwargs) -> str:
    """Dump the model to a YAML representation.

    Args:
        output_path: The (optional) path to save the YAML representation to.

    Returns:
        The YAML representation.
    """

    model_yaml = yaml.safe_dump(self.model_dump(), **kwargs)

    if output_path is not None:
        output_path.parent.mkdir(exist_ok=True, parents=True)
        output_path.write_text(model_yaml)

    return model_yaml

Anneal pydantic-model #

Bases: _SimulationStep

Configuration for a temperature annealing NVT MD simulation.

Fields:

integrator pydantic-field #

integrator: LangevinIntegrator

The integrator to use during the simulation.

restraints pydantic-field #

restraints: dict[str, FlatBottomRestraint] = {}

The position restraints to apply during the minimization. The keys should be AMBER style selection masks.

temperature_initial pydantic-field #

temperature_initial: OpenMMQuantity[kelvin]

The starting temperature to simulate at.

temperature_final pydantic-field #

temperature_final: OpenMMQuantity[kelvin]

The final temperature to simulate at.

n_steps pydantic-field #

n_steps: int

The number of steps to simulate for.

frequency pydantic-field #

frequency: int

The frequency at which to increment the temperature.

model_dump_yaml #

model_dump_yaml(
    output_path: Path | None = None, **kwargs
) -> str

Dump the model to a YAML representation.

Parameters:

  • output_path (Path | None, default: None ) –

    The (optional) path to save the YAML representation to.

Returns:

  • str

    The YAML representation.

Source code in femto/md/utils/models.py
def model_dump_yaml(self, output_path: pathlib.Path | None = None, **kwargs) -> str:
    """Dump the model to a YAML representation.

    Args:
        output_path: The (optional) path to save the YAML representation to.

    Returns:
        The YAML representation.
    """

    model_yaml = yaml.safe_dump(self.model_dump(), **kwargs)

    if output_path is not None:
        output_path.parent.mkdir(exist_ok=True, parents=True)
        output_path.write_text(model_yaml)

    return model_yaml

HREMDSwapMode #

Bases: str, Enum

The mode in which to propose state swaps between replicas.

  • NEIGHBOURS: Only allow swapping the current state with neighbouring states.
  • ALL: Allow swapping the current state with any other state.

HREMD pydantic-model #

Bases: BaseModel

Configuration for Hamiltonian replica exchange sampling

Fields:

temperature pydantic-field #

temperature: OpenMMQuantity[kelvin] = DEFAULT_TEMPERATURE

The temperature to sample at.

n_warmup_steps pydantic-field #

n_warmup_steps: int = 150000

The number of steps to run each replica for before starting hremd trials. All energies gathered during this period will be discarded.

n_steps_per_cycle pydantic-field #

n_steps_per_cycle: int = 1000

The number of steps to propagate the system by before attempting an exchange.

n_cycles pydantic-field #

n_cycles: int = 2500

The number of cycles of 'propagate the system' -> 'exchange replicas' to run.

max_step_retries pydantic-field #

max_step_retries: int = 5

The maximum number of times to attempt to step if a NaN is encountered before raising an exception

swap_mode pydantic-field #

swap_mode: HREMDSwapModeLiteral | None = ALL.value

The mode in which to propose state swaps between replicas. This can either be: 'neighbours', only try and swap adjacent states or ii. 'all', try and swap all states stochastically. If None, no replica exchanges will be attempted.

max_swaps pydantic-field #

max_swaps: int | None = None

The maximum number of swap proposals to make if running in 'all' mode. This variable does nothing when running in 'neighbours' mode.

trajectory_interval pydantic-field #

trajectory_interval: int | None = None

The number of cycles to run before saving the current replica states to DCD trajectory files. If None, no trajectories will be saved.

trajectory_enforce_pbc pydantic-field #

trajectory_enforce_pbc: bool = False

Whether to apply periodic boundary conditions when retrieving coordinates for writing to trajectory files.

checkpoint_interval pydantic-field #

checkpoint_interval: int | None = None

The number of cycles to run before saving the current replica states to checkpoint files. If None, no checkpoints will be saved.

model_dump_yaml #

model_dump_yaml(
    output_path: Path | None = None, **kwargs
) -> str

Dump the model to a YAML representation.

Parameters:

  • output_path (Path | None, default: None ) –

    The (optional) path to save the YAML representation to.

Returns:

  • str

    The YAML representation.

Source code in femto/md/utils/models.py
def model_dump_yaml(self, output_path: pathlib.Path | None = None, **kwargs) -> str:
    """Dump the model to a YAML representation.

    Args:
        output_path: The (optional) path to save the YAML representation to.

    Returns:
        The YAML representation.
    """

    model_yaml = yaml.safe_dump(self.model_dump(), **kwargs)

    if output_path is not None:
        output_path.parent.mkdir(exist_ok=True, parents=True)
        output_path.write_text(model_yaml)

    return model_yaml

merge_configs #

merge_configs(*configs: _T) -> dict[str, Any]

Merge multiple configurations together.

Parameters:

  • configs (_T, default: () ) –

    The configurations to merge. These should either be dataclasses or plain dictionaries. Values in subsequent configs will overwrite values in previous ones.

Returns:

  • dict[str, Any]

    The merged configuration.

Source code in femto/md/config.py
def merge_configs(*configs: _T) -> dict[str, typing.Any]:
    """Merge multiple configurations together.

    Args:
        configs: The configurations to merge. These should either be dataclasses or
            plain dictionaries. Values in subsequent configs will overwrite values in
            previous ones.

    Returns:
        The merged configuration.
    """

    if len(configs) == 0:
        raise ValueError("At least one config must be provided")

    configs = [
        config.model_dump() if isinstance(config, pydantic.BaseModel) else config
        for config in configs
    ]

    return omegaconf.OmegaConf.to_object(omegaconf.OmegaConf.merge(*configs))