molecular_simulations.build.build_amber module

AMBER system building module.

This module provides classes for building molecular systems using AmberTools. Supports both implicit and explicit solvent setups with automatic ionization and neutralization.

Classes:

ImplicitSolvent: Build implicit solvent systems with AMBER force fields. ExplicitSolvent: Build explicit solvent cubic boxes with 150mM NaCl.

class molecular_simulations.build.build_amber.ImplicitSolvent(path, pdb, protein=True, glycans=True, rna=False, dna=False, phos_protein=False, mod_protein=False, out=None, delete_temp_file=True, amberhome=None, debug=False, **kwargs)[source]

Bases: object

Build an implicit solvent system using AmberTools.

Produces topology and coordinate files for implicit solvent simulations using tleap with user-specified force fields.

Parameters:
  • path (str | Path | None) – Directory path for output files. If None, uses parent of pdb.

  • pdb (str) – Path to input PDB file.

  • protein (bool) – Whether to load protein force field (ff19SB). Defaults to True.

  • rna (bool) – Whether to load RNA force field (Shaw). Defaults to False.

  • dna (bool) – Whether to load DNA force field (OL21). Defaults to False.

  • phos_protein (bool) – Whether to load phosphorylated protein force field. Defaults to False.

  • mod_protein (bool) – Whether to load modified amino acid force field. Defaults to False.

  • out (str | Path | None) – Output filename. If None, uses ‘system.pdb’. Defaults to None.

  • delete_temp_file (bool) – Whether to delete temporary tleap input files. Defaults to True.

  • amberhome (str | None) – Path to AMBER installation. If None, uses AMBERHOME environment variable. Defaults to None.

  • **kwargs – Additional attributes to set on the instance.

path

Resolved Path object for output directory.

pdb

Resolved Path to input PDB file.

out

Resolved Path for output files.

tleap

Path to tleap executable.

pdb4amber

Path to pdb4amber executable.

ffs

List of force field files to load.

Raises:

ValueError – If AMBERHOME is not set and amberhome is None.

Example

>>> builder = ImplicitSolvent(path="./build", pdb="protein.pdb", protein=True)
>>> builder.build()

Initialize the ImplicitSolvent builder.

__init__(path, pdb, protein=True, glycans=True, rna=False, dna=False, phos_protein=False, mod_protein=False, out=None, delete_temp_file=True, amberhome=None, debug=False, **kwargs)[source]

Initialize the ImplicitSolvent builder.

build()[source]

Orchestrate the implicit solvent system build.

Runs tleap to produce topology (.prmtop) and coordinate (.inpcrd) files for the input structure.

Return type:

None

tleap_it()[source]

Run tleap to build the system.

Runs the input PDB through tleap with FF19SB protein force field and any other enabled force fields. Sets mbondi3 radii for implicit solvent calculations.

Return type:

None

debug_tleap(inp)[source]

Write a tleap input file.

Parameters:

inp (str) – The tleap input file contents as a string.

Return type:

None

Returns:

Path to the written tleap input file.

temp_tleap(inp)[source]

Run tleap with a temporary input file.

Writes a temporary file for tleap and executes it. This approach simplifies parallel tleap runs by avoiding input file conflicts between different workers.

Parameters:

inp (str) – The tleap input file contents as a string.

Return type:

None

class molecular_simulations.build.build_amber.ExplicitSolvent(path, pdb, disulfide_residues=None, padding=10.0, protein=True, glycans=False, rna=False, dna=False, phos_protein=False, mod_protein=False, polarizable=False, delete_temp_file=True, amberhome=None, debug=False, **kwargs)[source]

Bases: ImplicitSolvent

Build an explicit solvent system using AmberTools.

Produces an explicit solvent cubic box with user-specified padding, neutralized and ionized with 150mM NaCl.

Parameters:
  • path (str | Path) – Directory path for output files.

  • pdb (str | Path) – Path to input PDB file.

  • padding (float) – Padding around solute in Angstroms. Defaults to 10.0.

  • protein (bool) – Whether to load protein force field. Defaults to True.

  • rna (bool) – Whether to load RNA force field. Defaults to False.

  • dna (bool) – Whether to load DNA force field. Defaults to False.

  • phos_protein (bool) – Whether to load phosphorylated protein force field. Defaults to False.

  • mod_protein (bool) – Whether to load modified amino acid force field. Defaults to False.

  • polarizable (bool) – Whether to use polarizable force field (ff15ipq/SPC-Eb). Defaults to False.

  • delete_temp_file (bool) – Whether to delete temporary files. Defaults to True.

  • amberhome (str | None) – Path to AMBER installation. Defaults to None.

  • **kwargs – Additional attributes to set on the instance.

pad

Padding value in Angstroms.

water_box

Water box type (‘OPCBOX’ or ‘SPCBOX’).

Example

>>> builder = ExplicitSolvent(path="./build", pdb="protein.pdb", padding=12.0)
>>> builder.build()

Initialize the ExplicitSolvent builder.

__init__(path, pdb, disulfide_residues=None, padding=10.0, protein=True, glycans=False, rna=False, dna=False, phos_protein=False, mod_protein=False, polarizable=False, delete_temp_file=True, amberhome=None, debug=False, **kwargs)[source]

Initialize the ExplicitSolvent builder.

build()[source]

Orchestrate the explicit solvent system build.

Runs pdb4amber to prepare the structure, computes box dimensions, calculates ion numbers for 150mM concentration, and runs tleap to assemble the final solvated system.

Return type:

None

prep_pdb()[source]

Prepare the input PDB using cpptraj.

While pdb4amber has been the standard for some time, it sometimes makes decisions such as distance-based disulfide formation which cannot be stopped and is sometimes undesirable (such as in binder design use cases). For that reason, we are utilizing the more feature-rich prepareforleap function in cpptraj.

Return type:

None

assemble_system(dim, num_ions)[source]

Build the solvated system in tleap.

Parameters:
  • dim (float) – Box dimension (longest axis + padding) in Angstroms.

  • num_ions (int) – Number of Na+/Cl- ion pairs for 150mM concentration.

Return type:

None

get_pdb_extent()[source]

Calculate the required box dimension.

Identifies the longest axis of the protein based on X/Y/Z coordinate projections. Not highly accurate but sufficient for determining periodic box size.

Return type:

int

Returns:

Longest dimension plus twice the padding, in Angstroms.

clean_up_directory()[source]

Organize output directory.

Moves intermediate files to a ‘build’ subdirectory, keeping only the final .prmtop and .inpcrd files in the main directory.

Return type:

None

static get_ion_numbers(volume)[source]

Calculate ion count for 150mM NaCl concentration.

Parameters:

volume (float) – Box volume in cubic Angstroms.

Return type:

int

Returns:

Number of each ion type (Na+ and Cl-) needed for 150mM.