Molecular Dynamics Extension#

The molecular_dynamics extension provides a set of tools to help with various tasks related to running molecular dynamics simulations from BuildAMol Molecules. Currently, it provides the following sub-packages:

The solvate package provides the solvate function that can be used to create a solvation box around a molecule. It can use the following backend softwares to create the solvation box (requires the respective software to be installed):

Backend Settings
Biobb Amber Backend
PDBFixer Backend

The atom_typing package provides a base-class AtomTyper class that can be used to assign atom types to a molecule. It also implements a CHARMMTyper class as an example class.

Base Atom Typer
class buildamol.extensions.molecular_dynamics.atom_typing.atom_typer.AtomTyper(_dict=None)[source]#

Bases: object

A base class to assign atom types to atoms in a molecule based on reference data

assign_attribute(atom_or_higher, attribute: str)[source]#

Assign an attribute on one or more atoms based on the atom type data

Parameters:
  • atom_or_higher (Atom or Residue or Chain or Model or Structure) – Any object that is an Atom or has a get_atoms method

  • attribute (str) – The attribute to assign

assign_charges(atom_or_higher)[source]#

Assign the “pqr_charge” attribute on one or more atoms based on the atom type data

Parameters:

atom_or_higher (Atom or Residue or Chain or Model or Structure) – Any object that is an Atom or has a get_atoms method

assign_types(atom_or_higher)[source]#

Assign a “type” attribute on one or more atoms based on the atom type data

Parameters:

atom_or_higher (Atom or Residue or Chain or Model or Structure) – Any object that is an Atom or has a get_atoms method

atom_key(atom: Atom)[source]#

The atom key to locate the reference data for a given atom in the dictionary Each subclass should implement this method to return an appropriate key for the dictionary

classmethod from_dict(_dict)[source]#
classmethod from_file(filename: str)[source]#
get(key)[source]#
get_data(atom: Atom) dict[source]#

Get the atom type data for a given atom

Parameters:

atom (Atom) – The atom for which the type data is requested

Returns:

The atom type data

Return type:

dict

get_type(atom: Atom) str[source]#

Get the atom type for a given atom

Parameters:

atom (Atom) – The atom for which the type is requested

Returns:

The atom type

Return type:

str

get_types(residue_or_higher) dict[source]#

Get the atom types for all atoms in a residue

Parameters:

residue_or_higher (Molecule or Residue or Chain or Model or Structure) – Any object that has a get_atoms method

Returns:

A dictionary with atoms as keys and atom types as values

Return type:

dict

prepare_dict_for(atom_or_higher) dict[source]#

Prepare a dictionary with atom types for one or more atoms which can be added to the atom typer dictionary

Return type:

dict

set_data(atom: Atom, data: dict)[source]#

Set the atom type data for a given atom

Parameters:
  • atom (Atom) – The atom for which the type data is set

  • data (dict) – The atom type data

set_type(atom: Atom, atom_type: str)[source]#

Set the atom type for a given atom

Parameters:
  • atom (Atom) – The atom for which the type is set

  • atom_type (str) – The atom type

update(_dict_or_typer)[source]#
CHARMM Typer
class buildamol.extensions.molecular_dynamics.atom_typing.charmm_typer.CHARMMTyper(_dict=None)[source]#

Bases: AtomTyper

A class to assign CHARMM atom types to atoms in a molecule based on a CHARMM Topology file This requires that the molecule has residue names and atom names match with those in the CHARMM Topology file

atom_key(atom)[source]#

The atom key to locate the reference data for a given atom in the dictionary Each subclass should implement this method to return an appropriate key for the dictionary

classmethod from_file(filename: str)[source]#

Create a CHARMMTyper object from a CHARMM Topology file

Parameters:

filename (str) – The filename of the CHARMM Topology file

Returns:

The CHARMMTyper object

Return type:

CHARMMTyper

property residue_names: list#

Get the residue names in the CHARMM Topology file

Returns:

The residue names

Return type:

list

The psf module works with the atom_typing package to generate a PSF file for a molecule.

class buildamol.extensions.molecular_dynamics.psf.PSFMaker(atom_typer=None)[source]#

Bases: object

A class to generate a PSF file from a molecule

Parameters:

atom_typer (AtomTyper, optional) – The atom typer, by default None. If None, the atom type, mass, and charge must all be set as attributes of the atoms in the molecule.

encode_psf(molecule, angles: bool = False, dihedrals: bool = False) str[source]#

Encode a the content for a PSF file from a molecule

Parameters:
  • molecule (Molecule) – The molecule

  • angles (bool, optional) – Whether to include angle information, by default False

  • dihedrals (bool, optional) – Whether to include dihedral information, by default False

Returns:

The PSF content

Return type:

str

write_psf(molecule, filename: str, angles: bool = False, dihedrals: bool = False)[source]#

Write a PSF file from a molecule

Parameters:
  • molecule (Molecule) – The molecule

  • filename (str) – The filename of the PSF file

  • angles (bool, optional) – Whether to include angle information, by default False

  • dihedrals (bool, optional) – Whether to include dihedral information, by default False

buildamol.extensions.molecular_dynamics.psf.write_psf(molecule, filename: str, angles=False, dihedrals=False, _atom_typer=None)[source]#

Write a PSF file from a molecule

Parameters:
  • molecule (Molecule) – The molecule

  • filename (str) – The filename of the PSF file

  • angles (bool, optional) – Whether to include angle information, by default False

  • dihedrals (bool, optional) – Whether to include dihedral information, by default False

  • _atom_typer (AtomTyper, optional) – The atom typer, by default None. If None, the atom type, mass, and charge must all be set as attributes of the atoms in the molecule.