mdtraj.Topology¶
-
class
mdtraj.Topology¶ Topology stores the topological information about a system.
The structure of a Topology object is similar to that of a PDB file. It consists of a set of Chains (often but not always corresponding to polymer chains). Each Chain contains a set of Residues, and each Residue contains a set of Atoms. In addition, the Topology stores a list of which atom pairs are bonded to each other.
Atom and residue names should follow the PDB 3.0 nomenclature for all molecules for which one exists.
Examples
>>> topology = md.load('example.pdb').topology >>> print(topology) <mdtraj.Topology with 1 chains, 3 residues, 22 atoms, 21 bonds at 0x105a98e90> >>> table, bonds = topology.to_dataframe() >>> print(table.head()) serial name element resSeq resName chainID 0 0 H1 H 1 CYS 0 1 1 CH3 C 1 CYS 0 2 2 H2 H 1 CYS 0 3 3 H3 H 1 CYS 0 4 4 C C 1 CYS 0 >>> # rename residue "CYS" to "CYSS" >>> table[table['residue'] == 'CYS']['residue'] = 'CYSS' >>> print(table.head()) serial name element resSeq resName chainID 0 0 H1 H 1 CYSS 0 1 1 CH3 C 1 CYSS 0 2 2 H2 H 1 CYSS 0 3 3 H3 H 1 CYSS 0 4 4 C C 1 CYSS 0 >>> t2 = md.Topology.from_dataframe(table, bonds)
- Attributes
chainsgeneratorIterator over all Chains in the Topology.
residuesgeneratorIterator over all Residues in the Topology.
atomsgeneratorIterator over all Atoms in the Topology.
bondsgeneratorIterator over all bonds (each represented as a tuple of two Atoms) in the Topology.
Methods
add_atom(self, name, element, residue[, serial])Create a new Atom and add it to the Topology.
add_bond(self, atom1, atom2[, type, order])Create a new bond and add it to the Topology.
add_chain(self)Create a new Chain and add it to the Topology.
add_residue(self, name, chain[, resSeq, …])Create a new Residue and add it to the Topology.
atom(self, index)Get a specific atom by index.
atoms_by_name(self, name)Iterator over all Atoms in the Topology with a specified name
chain(self, index)Get a specific chain by index.
copy(self)Return a copy of the topology
create_disulfide_bonds(self, positions)Identify disulfide bonds based on proximity and add them to the Topology.
create_standard_bonds(self)Create bonds based on the atom and residue names for all standard residue types.
delete_atom_by_index(self, index)Delete an Atom from the topology.
find_molecules(self)Identify molecules based on bonds.
from_dataframe(atoms[, bonds])Create a mdtraj topology from a pandas data frame
from_openmm(value)Create a mdtraj topology from an OpenMM topology
guess_anchor_molecules(self)Guess anchor molecules for imaging
insert_atom(self, name, element, residue[, …])Create a new Atom and insert it into the Topology at a specific position.
join(self, other)Join two topologies together
residue(self, index)Get a specific residue by index.
select(self, selection_string)Execute a selection against the topology
select_atom_indices(self[, selection])Get the indices of biologically-relevant groups by name.
select_expression(self, selection_string)Translate a atom selection expression into a pure python expression.
select_pairs(self[, selection1, selection2])Generate unique pairs of atom indices.
subset(self, atom_indices)Create a new Topology from a subset of the atoms in an existing topology.
to_bondgraph(self)Create a NetworkX graph from the atoms and bonds in this topology
to_dataframe(self)Convert this topology into a pandas dataframe
to_fasta(self[, chain])Convert this topology into FASTA string
to_openmm(self[, traj])Convert this topology into OpenMM topology
-
__init__(self)¶ Create a new Topology object
Methods
__init__(self)Create a new Topology object
add_atom(self, name, element, residue[, serial])Create a new Atom and add it to the Topology.
add_bond(self, atom1, atom2[, type, order])Create a new bond and add it to the Topology.
add_chain(self)Create a new Chain and add it to the Topology.
add_residue(self, name, chain[, resSeq, …])Create a new Residue and add it to the Topology.
atom(self, index)Get a specific atom by index.
atoms_by_name(self, name)Iterator over all Atoms in the Topology with a specified name
chain(self, index)Get a specific chain by index.
copy(self)Return a copy of the topology
create_disulfide_bonds(self, positions)Identify disulfide bonds based on proximity and add them to the Topology.
create_standard_bonds(self)Create bonds based on the atom and residue names for all standard residue types.
delete_atom_by_index(self, index)Delete an Atom from the topology.
find_molecules(self)Identify molecules based on bonds.
from_dataframe(atoms[, bonds])Create a mdtraj topology from a pandas data frame
from_openmm(value)Create a mdtraj topology from an OpenMM topology
guess_anchor_molecules(self)Guess anchor molecules for imaging
insert_atom(self, name, element, residue[, …])Create a new Atom and insert it into the Topology at a specific position.
join(self, other)Join two topologies together
residue(self, index)Get a specific residue by index.
select(self, selection_string)Execute a selection against the topology
select_atom_indices(self[, selection])Get the indices of biologically-relevant groups by name.
select_expression(self, selection_string)Translate a atom selection expression into a pure python expression.
select_pairs(self[, selection1, selection2])Generate unique pairs of atom indices.
subset(self, atom_indices)Create a new Topology from a subset of the atoms in an existing topology.
to_bondgraph(self)Create a NetworkX graph from the atoms and bonds in this topology
to_dataframe(self)Convert this topology into a pandas dataframe
to_fasta(self[, chain])Convert this topology into FASTA string
to_openmm(self[, traj])Convert this topology into OpenMM topology
Attributes
atomsIterator over all Atoms in the Topology.
bondsIterator over all bonds (each represented as a tuple of two Atoms) in the Topology.
chainsIterator over all Chains in the Topology.
n_atomsGet the number of atoms in the Topology
n_bondsGet the number of bonds in the Topology
n_chainsGet the number of chains in the Topology
n_residuesGet the number of residues in the Topology.
residuesIterator over all Residues in the Topology.