5.26. Guessing unknown Topology information — MDAnalysis.topology.guessers

In general guess_atom_X returns the guessed value for a single value, while guess_Xs will work on an array of many atoms.


Return the atomic mass in u for element.

Masses are looked up in MDAnalysis.topology.tables.masses.


Unknown masses are set to 0.0

Changed in version 0.20.0: Try uppercase atom type name as well


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._topology
Return type:list of tuples

See also



Guess atom charge from the name.


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.


Guess a mass based on the atom name.

guess_atom_element() is used to determine the kind of atom.


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().

MDAnalysis.topology.guessers.guess_bonds(atoms, coords, box=None, **kwargs)[source]

Guess if bonds exist between two atoms based on their distance.

Bond between two atoms is created, if the two atoms are within

\[d < f \cdot (R_1 + R_2)\]

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.

  • atoms (AtomGroup) – atoms for which bonds should be guessed
  • coords (array) – coordinates of the atoms (i.e., AtomGroup.positions))
  • fudge_factor (float, optional) – The factor by which atoms must overlap eachother to be considered a bond. Larger values will increase the number of bonds found. [0.55]
  • vdwradii (dict, optional) – To supply custom vdwradii for atoms in the algorithm. Must be a dict of format {type:radii}. The default table of van der Waals radii is hard-coded as MDAnalysis.topology.tables.vdwradii. Any user defined vdwradii passed as an argument will supercede the table values. [None]
  • lower_bound (float, optional) – The minimum bond length. All bonds found shorter than this length will be ignored. This is useful for parsing PDB with altloc records where atoms with altloc A and B maybe very close together and there should be no chemical bond between them. [0.1]
  • box (array_like, optional) – Bonds are found using a distance search, if unit cell information is given, periodic boundary conditions will be considered in the distance search. [None]

List of tuples suitable for use in Universe topology building.

Return type:



No check is done after the bonds are guessed to see if Lewis structure is correct. This is wrong and will burn somebody.

Raises:ValueError if inputs are malformed or vdwradii data is missing.

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 as \(O(n^2)\). vdwradii argument now augments table list rather than replacing entirely.


Given a list of Angles, find all dihedrals 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 dihedral.

  • list of tuples – List of tuples defining the dihedrals. Suitable for use in u._topology
  • .. versionadded 0.9.0

Given a list of Angles, find all improper dihedrals 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 dihedral. ie the improper dihedral is the angle between the planes formed by (1, 2, 3) and (1, 3, 4)

  • List of tuples defining the improper dihedrals.
  • Suitable for use in u._topology

Guess the mass of many atoms based upon their type

Parameters:atom_types – Type of each atom
Return type:np.ndarray dtype float64

Guess the atom type of many atoms based on atom name

Parameters:atom_names – Name of each atom
Return type:np.ndarray dtype object

Vaildates the atom types based on whether they are available in our tables

Parameters:atom_types – Type of each atom
  • None
  • .. versionchanged:: 0.20.0 – Try uppercase atom type name as well