mdtop
#
Store topological information about a system to simulate.
Modules:
-
tests
–
Classes:
-
Atom
–Represents atoms and virtual sites stored in a topology.
-
Bond
–Represents a bond between two atoms.
-
Chain
–Represents chains stored in a topology.
-
Residue
–Represents residues stored in a topology.
-
Topology
–Represents topological information about a system.
Attributes:
-
AMINO_ACID_NAMES
(frozenset[str]
) –Common natural amino acid residue names.
-
ION_RES_NAMES
(frozenset[str]
) –Residue names for common ions.
-
WATER_RES_NAMES
(frozenset[str]
) –Common water residue names.
AMINO_ACID_NAMES
module-attribute
#
AMINO_ACID_NAMES: frozenset[str] = frozenset(
[
"ACE",
"NME",
"NMA",
"ALA",
"CYS",
"ASP",
"GLU",
"PHE",
"GLY",
"HIS",
"ILE",
"LYS",
"LEU",
"MET",
"ASN",
"PRO",
"GLN",
"ARG",
"SER",
"THR",
"VAL",
"TRP",
"TYR",
"CYD",
"CYZ",
"HID",
"HIE",
"HIP",
]
)
Common natural amino acid residue names.
ION_RES_NAMES
module-attribute
#
ION_RES_NAMES: frozenset[str] = frozenset(
[
"NA+",
"NA",
"K+",
"K",
"LI+",
"LI",
"CL-",
"CL",
"BR-",
"BR",
"I-",
"I",
"F-",
"F",
"MG+2",
"MG",
"CA+2",
"CA",
"ZN+2",
"ZN",
"FE+3",
"FE+2",
"FE",
]
)
Residue names for common ions.
WATER_RES_NAMES
module-attribute
#
Common water residue names.
Atom
#
Represents atoms and virtual sites stored in a topology.
Attributes:
-
name
(str
) –The name of the atom.
-
atomic_num
(int
) –The atomic number, or 0 if this is a virtual site.
-
formal_charge
(int | None
) –The formal charge on the atom.
-
serial
(int
) –The index of this atom in its original source (e.g. the serial defined
-
symbol
(str
) –The chemical symbol of the atom, or 'X' if this is a virtual site.
-
residue
(Optional[Residue]
) –The residue that the atom belongs to.
-
chain
(Optional[Chain]
) –The chain that the atom belongs to.
-
index
(int | None
) –The index of the atom in the parent topology
Source code in mdtop/_top.py
atomic_num
instance-attribute
#
atomic_num: int = atomic_num
The atomic number, or 0 if this is a virtual site.
formal_charge
instance-attribute
#
formal_charge: int | None = formal_charge
The formal charge on the atom.
Bond
#
Chain
#
Represents chains stored in a topology.
Attributes:
-
id
–The ID of the chain.
-
topology
(Optional[Topology]
) –The topology the chain belongs to (if any).
-
residues
(tuple[Residue, ...]
) –The residues associated with the chain.
-
n_residues
(int
) –The number of chains in the chain.
-
atoms
(tuple[Atom, ...]
) –The atoms associated with the chain.
-
n_atoms
(int
) –The number of atoms in the chain.
-
index
(int | None
) –The index of the chain in the parent topology
Source code in mdtop/_top.py
Residue
#
Represents residues stored in a topology.
Attributes:
-
name
–The name of the residue.
-
seq_num
–The sequence number of the residue.
-
chain
(Optional[Chain]
) –The chain the residue belongs to (if any).
-
topology
(Optional[Topology]
) –The topology the residue belongs to (if any).
-
atoms
(tuple[Atom, ...]
) –The atoms associated with the residue.
-
n_atoms
(int
) –The number of atoms in the residue.
-
index
(int | None
) –The index of the residue in the parent topology
Source code in mdtop/_top.py
Topology
#
Represents topological information about a system.
Methods:
-
add_chain
–Add a new chain to the topology.
-
add_residue
–Add a new residue to the topology.
-
add_atom
–Add a new atom to the topology.
-
add_bond
–Add a new bond to the topology.
-
from_openmm
–Create a topology from an OpenMM topology.
-
to_openmm
–Convert the topology to an OpenMM topology.
-
from_rdkit
–Create a topology from an RDKit molecule.
-
to_rdkit
–Convert the Topology to an RDKit Mol object.
-
from_file
–Load the topology from a file.
-
to_file
–Write the topology to a file.
-
select
–Select atoms from the topology using a selection expression.
-
subset
–Create a subset of the topology.
-
merge
–Merge multiple topologies.
Attributes:
-
chains
(tuple[Chain, ...]
) –The chains associated with the topology.
-
n_chains
(int
) –The number of chains in the topology.
-
residues
(tuple[Residue, ...]
) –The residues associated with the topology.
-
n_residues
(int
) –The number of residues in the topology.
-
atoms
(tuple[Atom, ...]
) –The atoms associated with the topology.
-
n_atoms
(int
) –The number of atoms in the topology.
-
bonds
(tuple[Bond, ...]
) –The bonds associated with the topology.
-
n_bonds
(int
) –The number of bonds in the topology.
-
xyz
(Quantity | None
) –The coordinates of the atoms in the topology.
-
box
(Quantity | None
) –The box vectors of the simulation box.
Source code in mdtop/_top.py
add_chain
#
add_chain(id_: str) -> Chain
Add a new chain to the topology.
Parameters:
-
id_
(str
) –The ID of the chain to add.
Returns:
-
Chain
–The newly created chain.
Source code in mdtop/_top.py
add_residue
#
add_residue(name: str, seq_num: int | None, chain: Chain)
Add a new residue to the topology.
Parameters:
-
name
(str
) –The name of the residue to add
-
seq_num
(int | None
) –The sequence number of the residue. If
None
, the index in the topology will be used. -
chain
(Chain
) –The parent chain to add to.
Returns:
-
–
The newly created residue.
Source code in mdtop/_top.py
add_atom
#
add_atom(
name: str,
atomic_num: int,
formal_charge: int | None,
serial: int | None,
residue: Residue,
)
Add a new atom to the topology.
Parameters:
-
name
(str
) –The name of the atom to add
-
atomic_num
(int
) –The atomic number of the atom to add, or 0 for virtual sites.
-
formal_charge
(int | None
) –The formal charge on the atom (if defined).
-
serial
(int | None
) –The index of this atom in its original source (e.g. the serial defined in a PDB), which may not be zero-index or contiguous. If
None
, the index in the topology will be used. -
residue
(Residue
) –The parent residue to add to.
Returns:
-
–
The newly created atom
Source code in mdtop/_top.py
add_bond
#
Add a new bond to the topology.
Parameters:
-
idx_1
(int
) –The index of the first atom.
-
idx_2
(int
) –The index of the second atom.
-
order
(int | None
) –The formal bond order (if defined).
Returns:
-
–
The newly created bond.
Source code in mdtop/_top.py
from_openmm
classmethod
#
from_openmm(topology_omm: Topology) -> Topology
Create a topology from an OpenMM topology.
Parameters:
-
topology_omm
(Topology
) –The OpenMM topology to convert.
Returns:
-
Topology
–The converted topology.
Source code in mdtop/_top.py
to_openmm
#
Convert the topology to an OpenMM topology.
Returns:
-
Topology
–The OpenMM topology.
Source code in mdtop/_top.py
from_rdkit
classmethod
#
from_rdkit(
mol: Mol, residue_name: str = "LIG", chain: str = ""
) -> Topology
Create a topology from an RDKit molecule.
Parameters:
-
mol
(Mol
) –The RDKit molecule to convert.
-
residue_name
(str
, default:'LIG'
) –The residue name to use for the ligand.
-
chain
(str
, default:''
) –The chain ID to use for the ligand.
Returns:
-
Topology
–The converted topology.
Source code in mdtop/_top.py
to_rdkit
#
Convert the Topology to an RDKit Mol object.
Notes
- Currently this requires formal charges to be set on the atoms, and formal bond orders to be set on the bonds.
Returns:
-
Mol
–The RDKit Mol object.
Source code in mdtop/_top.py
from_file
classmethod
#
from_file(path: Path | str) -> Topology
Load the topology from a file.
Notes
- Currently PDB, SDF, and MOL2 files are supported.
Parameters:
-
path
(Path | str
) –The path to the file to load.
Returns:
-
Topology
–The loaded topology.
Source code in mdtop/_top.py
to_file
#
Write the topology to a file.
Notes
- Currently PDB files are supported.
Parameters:
-
path
(Path | str
) –The path to write the topology to.
Source code in mdtop/_top.py
select
#
Select atoms from the topology using a selection expression.
The selection expression should be expressed in terms of the PyMol selection language. For example, to select all atoms in chain A:
or all atoms within 5 Å of the ligand:
Notes
An Amber-style selection mask can also be used, but this is deprecated and will be removed in a future version.
Parameters:
-
expr
(str
) –The selection expression.
Source code in mdtop/_top.py
subset
#
subset(idxs: Iterable[int]) -> Topology
Create a subset of the topology.
Parameters:
-
idxs
(Iterable[int]
) –The indices of the atoms to include in the subset. Note the order of the atoms in the subset will be the same as in the original topology, regardless of the order of the indices.
Returns:
-
Topology
–The subset of the topology.
Source code in mdtop/_top.py
merge
classmethod
#
Merge multiple topologies.
Notes
- The box vectors of the first topology will be used.
- Topologies without coordinates will be treated as if they have all zero coordinates.
Parameters:
-
topologies
(Topology
, default:()
) –The topologies to merge together.
Returns:
-
Topology
–The merged topology.