The various topology parsers make use of functions and classes in this module. They are mostly of use to developers.
See also
MDAnalysis.topology.tables for some hard-coded atom information that is used by functions such as guess_atom_type() and guess_atom_mass().
An angle between three Atom instances. Atom 2 is the apex of the angle
New in version 0.8.
Changed in version 0.9.0: * Now a subclass of TopologyObject * Changed class to use __slots__ * Changed class to store atoms in .atoms attribute.
A bond between two Atom instances.
Two Bond instances can be compared with the == and != operators. A bond is equal to another if the same atom numbers are connected and they have the same bond order. The ordering of the two atom numbers is ignored as is the fact that a bond was guessed.
>>> Atom in Bond
True / False
Changed in version 0.9.0: * Now a subclass of TopologyObject * Changed class to use __slots__ * Changed class to store atoms in .atoms attribute.
Improper Torsion (improper dihedral angle) between four Atom instances.
MDAnalysis treats the improper torsion angle as the angle between the planes formed by Atoms (1, 2, 3) and (2, 3, 4).
Warning
Definitions of Atom ordering in improper torsions can change. Check the definitions here against your software.
A customised dictionary designed for sorting the bonds, angles and torsions present in a group of atoms.
Usage:
topologydict = TopologyDict(members)
Arguments : |
|
---|---|
Returns : |
|
TopologyDicts are also built lazily from a TopologyGroup.topDict attribute.
The TopologyDict collects all the selected topology type from the atoms and categorises them according to the types of the atoms within. A TopologyGroup containing all of a given bond type can be made by querying with the appropriate key. The keys to the topologyDict are a tuple of the atom types that the bond represents and can be viewed using the keys() method.
For example, from a system containing pure ethanol
>>> td = u.bonds.topDict
>>> td.keys()
[('C', 'C'),
('C', 'H'),
('O', 'H'),
('C', 'O')]
>>> td['C', 'O']
< TopologyGroup containing 912 bonds >
Note
The key for a bond is taken from the type attribute of the atoms.
Getting and setting types of bonds is done smartly, so a C-C-H angle is considered identical to a H-C-C angle.
Duplicate entries are automatically removed upon creation and combination of different Dicts. This means a bond between atoms 1 and 2 will only ever appear once in a dict despite both atoms 1 and 2 having the bond in their .bond attribute.
Two TopologyDicts can be combined using addition, this will not create any duplicate bonds in the process.
New in version 0.8.
Changed in version 0.9.0: * Changed initialisation to use a list of TopologyObjects instead of list of atoms * Now used from within TopologyGroup instead of accessed from AtomGroup
A container for a groups of bonds.
All bonds of a certain types can be retrieved from within the TopologyGroup by querying with a tuple of types:
tg2 = tg.selectBonds([key])
Where key describes the desired bond as a tuple of the involved Atom types, as defined by the .type Atom attribute). A list of available keys can be displayed using the types() method.
Alternatively, all the bonds which are in a given AtomGroup can be extracted using atomgroup_intersection():
tg2 = tg.atomgroup_intersection(ag)
This allows the keyword strict to be given, which forces all members of all bonds to be inside the AtomGroup passed to it.
Finally, a TopologyGroup can be sliced similarly to AtomGroups:
tg2 = tg[5:10]
The bonds(), angles() and torsions() methods offer a “shortcut” to the Cython distance calculation functions in MDAnalysis.core.distances.
TopologyGroups can be combined with TopologyGroups of the same bond type (ie can combine two angle containing TopologyGroups).
New in version 0.8.
Changed in version 0.9.0: Overhauled completely * Added internal TopologyDict accessible by the topDict attribute * selectBonds() allows the topDict to be queried with tuple of types * Added atomgroup_intersection() to allow bonds which are in a given AtomGroup to be retrieved.
Calculates the angle in radians formed between a bond between atoms 1 and 2 and a bond between atoms 2 & 3
Keywords : |
|
---|
Uses cython implementation
Changed in version 0.9.0: Added pbc option (default False)
Retrieve all bonds from within this TopologyGroup that are within the AtomGroup which is passed.
Keywords : |
|
---|
New in version 0.9.0.
Calculates the distance between all bonds in this TopologyGroup
Keywords : |
|
---|
Uses cython implementation
Return a tuple of tuples which define the contents of this TopologyGroup in terms of the atom numbers, (0 based index within u.atoms)
This format should be identical to the original contents of the entries in universe._psf. Note that because bonds are sorted as they are initialised, the order that atoms are defined in each entry might be reversed.
Calculate the torsional angle in radians for this topology group.
Defined as the angle between a plane formed by atoms 1, 2 and 3 and a plane formed by atoms 2, 3 and 4.
Keywords : |
|
---|
Uses cython implementation.
Changed in version 0.9.0: Added pbc option (default False)
Base class for all Topology items
Defines the behaviour by which Bonds/Angles/etc in MDAnalysis should behave.
Torsion (dihedral angle) between four Atom instances.
The torsion is defined as the angle between the planes formed by Atoms (1, 2, 3) and (2, 3, 4).
New in version 0.8.
Changed in version 0.9.0: * Now a subclass of TopologyObject * Changed class to use __slots__ * Changed class to store atoms in .atoms attribute.
Create a list Residue instances from a list of Atom instances.
Updating residues also changes the underlying Atom instances, which record to which residue an atom belongs.
Returns : | List of Residue instances |
---|
New in version 0.8.
Changed in version 0.9.0: Now allows resids to be given in non sequential order
Create all Segment instancess from a list of Atom instances.
The function also builds the Residue instances by tracking residue numbers.
Updating segments also changes the underlying Atom instances, which record to which residue and segment an atom belongs.
Returns : | structure dict, which associates a segname with a Segment |
---|
Changed in version 0.9.0: Now allows resids in a given Segment to be given in non sequential order.
Return the atomic mass in u for element.
Masses are looked up in MDAnalysis.topology.tables.masses.
Warning
Unknown masses are set to 0.00
Return the appropriate topology parser for filename.
Automatic detection is disabled when an explicit format is provided.
Given a list of Bonds, find all angles that exist between atoms.
Works by assuming that if atoms 1 & 2 are bonded, and 2 & 3 are bonded, then (1,2,3) must be an angle.
Returns : | List of tuples defining the angles. Suitable for use in u._psf |
---|
See also
Guess atom charge from the name.
Warning
Not implemented; simply returns 0.
Guess the element of the atom from the name.
Looks in dict to see if element is found, otherwise it uses the first character in the atomname. The table comes from CHARMM and AMBER atom types, where the first character is not sufficient to determine the atom type. Some GROMOS ions have also been added.
See also
guess_atom_type() and MDAnalysis.topology.tables (where the data are stored)
Guess a mass based on the atom name.
guess_atom_element() is used to determine the kind of atom.
Warning
Anything not recognized is simply set to 0; if you rely on the masses you might want to double check.
Guess atom type from the name.
At the moment, this function simply returns the element, as guessed by guess_atom_element().
See also
Guess if bonds exist between two atoms based on their distance.
Bond between two atoms is created, if the two atoms are within
of each other, where \(R_1\) and \(R_2\) are the VdW radii of the atoms and \(f\) is an ad-hoc fudge_factor. This is the same algorithm that VMD uses.
Keywords : |
|
---|---|
Returns : | List of tuples suitable for use in Universe topology building. |
Warning
No check is done after the bonds are guessed to see if Lewis structure is correct. This is wrong and will burn somebody.
New in version 0.7.7.
Changed in version 0.9.0: * Updated method internally to use more numpy, should work faster. * Should also use less memory, previously scaled O(n^2) * vdwradii argument now augments table list rather than replacing entirely
Returns the type of topology file filename.
The current heuristic simply looks at the filename extension but more complicated probes could be implemented here or in the individual packages (e.g. as static methods).
If format is supplied then it overrides the auto detection.
Given a list of Angles, find all improper torsions that exist between atoms.
Works by assuming that if (1,2,3) is an angle, and 2 & 4 are bonded, then (2, 1, 3, 4) must be an improper torsion. ie the improper torsion is the angle between the planes formed by (1, 2, 3) and (1, 3, 4)
Returns : | List of tuples defining the improper torsions. Suitable for use in u._psf |
---|
Given a list of Angles, find all torsions that exist between atoms.
Works by assuming that if (1,2,3) is an angle, and 3 & 4 are bonded, then (1,2,3,4) must be a torsion.
Returns : | List of tuples defining the torsions. Suitable for use in u._psf |
---|