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
- chainsgenerator
- Iterator over all Chains in the Topology. 
- residuesgenerator
- Iterator over all Residues in the Topology. 
- atomsgenerator
- Iterator over all Atoms in the Topology. 
- bondsgenerator
- Iterator over all bonds (each represented as a tuple of two Atoms) in the Topology. 
 
 - Methods - add_atom(name, element, residue[, serial])- Create a new Atom and add it to the Topology. - add_bond(atom1, atom2[, type, order])- Create a new bond and add it to the Topology. - add_chain()- Create a new Chain and add it to the Topology. - add_residue(name, chain[, resSeq, segment_id])- Create a new Residue and add it to the Topology. - atom(index)- Get a specific atom by index. - atoms_by_name(name)- Iterator over all Atoms in the Topology with a specified name - chain(index)- Get a specific chain by index. - copy()- Return a copy of the topology - create_disulfide_bonds(positions)- Identify disulfide bonds based on proximity and add them to the Topology. - create_standard_bonds()- Create bonds based on the atom and residue names for all standard residue types. - delete_atom_by_index(index)- Delete an Atom from the topology. - find_molecules()- 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()- Guess anchor molecules for imaging - insert_atom(name, element, residue[, index, …])- Create a new Atom and insert it into the Topology at a specific position. - join(other[, keep_resSeq])- Join two topologies together - residue(index)- Get a specific residue by index. - select(selection_string)- Execute a selection against the topology - select_atom_indices([selection])- Get the indices of biologically-relevant groups by name. - select_expression(selection_string)- Translate a atom selection expression into a pure python expression. - select_pairs([selection1, selection2])- Generate unique pairs of atom indices. - subset(atom_indices)- Create a new Topology from a subset of the atoms in an existing topology. - to_bondgraph()- Create a NetworkX graph from the atoms and bonds in this topology - to_dataframe()- Convert this topology into a pandas dataframe - to_fasta([chain])- Convert this topology into FASTA string - to_openmm([traj])- Convert this topology into OpenMM topology - 
__init__()¶
- Create a new Topology object 
 - Methods - __init__()- Create a new Topology object - add_atom(name, element, residue[, serial])- Create a new Atom and add it to the Topology. - add_bond(atom1, atom2[, type, order])- Create a new bond and add it to the Topology. - add_chain()- Create a new Chain and add it to the Topology. - add_residue(name, chain[, resSeq, segment_id])- Create a new Residue and add it to the Topology. - atom(index)- Get a specific atom by index. - atoms_by_name(name)- Iterator over all Atoms in the Topology with a specified name - chain(index)- Get a specific chain by index. - copy()- Return a copy of the topology - create_disulfide_bonds(positions)- Identify disulfide bonds based on proximity and add them to the Topology. - create_standard_bonds()- Create bonds based on the atom and residue names for all standard residue types. - delete_atom_by_index(index)- Delete an Atom from the topology. - find_molecules()- 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()- Guess anchor molecules for imaging - insert_atom(name, element, residue[, index, …])- Create a new Atom and insert it into the Topology at a specific position. - join(other[, keep_resSeq])- Join two topologies together - residue(index)- Get a specific residue by index. - select(selection_string)- Execute a selection against the topology - select_atom_indices([selection])- Get the indices of biologically-relevant groups by name. - select_expression(selection_string)- Translate a atom selection expression into a pure python expression. - select_pairs([selection1, selection2])- Generate unique pairs of atom indices. - subset(atom_indices)- Create a new Topology from a subset of the atoms in an existing topology. - to_bondgraph()- Create a NetworkX graph from the atoms and bonds in this topology - to_dataframe()- Convert this topology into a pandas dataframe - to_fasta([chain])- Convert this topology into FASTA string - to_openmm([traj])- Convert this topology into OpenMM topology - Attributes - atoms- Iterator over all Atoms in the Topology. - bonds- Iterator over all bonds (each represented as a tuple of two Atoms) in the Topology. - chains- Iterator over all Chains in the Topology. - n_atoms- Get the number of atoms in the Topology - n_bonds- Get the number of bonds in the Topology - n_chains- Get the number of chains in the Topology - n_residues- Get the number of residues in the Topology. - residues- Iterator over all Residues in the Topology.