HierarchyElement

class openff.toolkit.topology.HierarchyElement(scheme, identifier, atom_indices)[source]

An element in a metadata hierarchy scheme, such as a residue or chain.

__init__(scheme, identifier, atom_indices)[source]

Create a new hierarchy element.

Parameters
  • scheme (HierarchyScheme) – The scheme to which this HierarchyElement belongs

  • id (tuple of str and int) – Tuple of metadata values (not keys) that define the uniqueness criteria for this element

  • atom_indices (iterable int) – The indices of particles in scheme.parent that are in this element

Methods

__init__(scheme, identifier, atom_indices)

Create a new hierarchy element.

atom(index)

Get the atom with the specified index.

generate_unique_atom_names()

Generate unique atom names from the element symbol and count.

to_dict()

Serialize this object to a basic dict of strings, ints, and floats.

Attributes

atoms

Iterator over the atoms in this hierarchy element.

has_unique_atom_names

True if the element has unique atom names, False otherwise.

n_atoms

The number of atoms in this hierarchy element.

parent

The parent molecule for this hierarchy element

to_dict()[source]

Serialize this object to a basic dict of strings, ints, and floats.

property n_atoms

The number of atoms in this hierarchy element.

property atoms

Iterator over the atoms in this hierarchy element.

atom(index: int) Atom[source]

Get the atom with the specified index.

property parent: FrozenMolecule

The parent molecule for this hierarchy element

property has_unique_atom_names: bool

True if the element has unique atom names, False otherwise.

generate_unique_atom_names()[source]

Generate unique atom names from the element symbol and count.

Names are generated from the elemental symbol and the number of times that element is found in the hierarchy element. The character ‘x’ is appended to these generated names to reduce the odds that they clash with an atom name or type imported from another source. For example, generated atom names might begin ‘C1x’, ‘H1x’, ‘O1x’, ‘C2x’, etc.