Skip to content

Tleap

Prepare Amber simulations with tleap.

FF_WATER_SOLVENT_BOX_MAP: dict[str, Any] = {'tip3p': 'TIP3PBOX', 'tip4p': 'TIP4PBOX', 'tip4pew': 'TIP4PEWBOX', 'tip5p': 'TIP5PBOX', 'opc': 'OPCBOX', 'opc3': 'OPC3BOX', 'pol3': 'POL3BOX', 'spce': 'SPCBOX'} module-attribute

Maps ff_water in simulation contexts to tleap box types.

TLEAP_PATH = os.environ.get('TLEAP_PATH', 'tleap') module-attribute

Path to tleap executable.

You can specify this by setting the path to the TLEAP_PATH environmental variable. For example:

export TLEAP_PATH="~/miniconda3/envs/metalflare-dev/bin/tleap

cli_run_tleap()

Command-line interface to running tleap

get_prelim_sim_info(pdb_path, simulation_context, add_lines=None)

Run a preliminary tleap preparation to get information about the system.

PARAMETER DESCRIPTION
pdb_path

Path to PDB file to load into tleap.

TYPE: str

simulation_context

A simulation context for system preparation.

TYPE: SimulationContextManager

add_lines

Additional tleap lines to add before loading the PDB file.

TYPE: Iterable[str] | None DEFAULT: None

RETURNS DESCRIPTION
dict[str, Any]

Parsed information from the tleap log.

Examples:

The base tleap input file is shown below with AMBER_PROTEIN_STANDARD_CONTEXT.

source leaprc.protein.ff19SB
source leaprc.water.opc3
<add_lines>
mol = loadpdb <pdb_path>
solvatebox mol OPC3BOX 10.0
savepdb mol <temp file>
charge mol
quit

get_source_ff_lines(simulation_context)

Prepare tleap commands for loading force fields.

PARAMETER DESCRIPTION
simulation_context

A simulation context for system preparation.

TYPE: SimulationContextManager

RETURNS DESCRIPTION
list[str]

source leaprc. commands for tleap.

Examples:

amber_context = {
    "ff_protein": "ff14SB", "ff_water": "tip3p", "ff_small_molecule": "gaff2"
}
simulation_context = SimulationContextManager(**amber_context)
tleap_lines = get_source_ff_lines(simulation_context)

would result in

["source leaprc.protein.ff14SB", "source leaprc.water.tip3p", "source leaprc.gaff2"]

parse_tleap_log(log_lines)

Parse information from tleap log file.

PARAMETER DESCRIPTION
log_lines

Lines of the tleap.log file.

TYPE: list[str]

RETURNS DESCRIPTION
dict[str, Any]

Parsed information from the log file.

Information:

  • duplicate_atoms: list[dict[str, str]]

    Each atom in a residue should have a unique type. This list collects information of duplicated atom types.

    [
        {'residue_number': 23, 'atom_type': 'ND2'},
        {'residue_number': 23, 'atom_type': 'OD1'},
        {'residue_number': 92, 'atom_type': 'NE2'}
    ]
    

prepare_amber_files(pdb_path, prmtop_path, inpcrd_path, simulation_context, pdb_output_path=None, cations=0, anions=0, add_lines=None)

Prepare amber input files.

PARAMETER DESCRIPTION
pdb_path

Path to PDB file to load into tleap.

TYPE: str

prmtop_path

Path to save topology file.

TYPE: str

inpcrd

Path to save coordinate file.

simulation_context

A simulation context for system preparation.

TYPE: SimulationContextManager

pdb_output_path

Path to save final system.

TYPE: str | None DEFAULT: None

cations

Number of cations to add.

TYPE: int DEFAULT: 0

anions

Number of anions to add.

TYPE: int DEFAULT: 0

add_lines

Additional tleap lines to add before generating parameters.

TYPE: Iterable[str] | None DEFAULT: None

RETURNS DESCRIPTION
dict[str, Any]

Parsed information from the tleap log.

Examples:

The base tleap input file is shown below with AMBER_PROTEIN_STANDARD_CONTEXT.

source leaprc.protein.ff19SB
source leaprc.water.opc3
<add_lines>
mol = loadpdb <pdb_path>
addIons2 mol Na+ <cations>
addIons2 mol Cl- <anions>
solvatebox mol OPC3BOX 10.0
savepdb mol <temp file>
saveamberparm mol <prmtop_path> <inpcrd_path>
charge mol
quit

run_tleap(pdb_path, topo_path, coord_path, yaml_paths, work_dir=None)

Run tleap preparation of a system.

PARAMETER DESCRIPTION
pdb_path

Path to PDB file to prepare.

TYPE: str

topo_path

Path to save topology file.

TYPE: str

coord_path

Path to save coordinate file.

TYPE: str

yaml_paths

YAML file paths context.

You can include a list under add_lines_tleap key for adding lines to the tleap preparation in get_prelim_sim_info.

TYPE: Iterable[str]

work_dir

Working directory to run tleap and specifying relative paths.

TYPE: str | None DEFAULT: None