HierarchyElement
- class openff.toolkit.topology.HierarchyElement(scheme: HierarchyScheme, identifier: tuple[Union[str, int]], atom_indices: Sequence[int])[source]
An element in a metadata hierarchy scheme, such as a residue or chain.
- __init__(scheme: HierarchyScheme, identifier: tuple[Union[str, int]], atom_indices: Sequence[int])[source]
Create a new hierarchy element.
- Parameters:
scheme – The scheme to which this
HierarchyElement
belongsidentifier – tuple of metadata values (not keys) that define the uniqueness criteria for this element
atom_indices – 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
([suffix])Generate unique atom names from the element symbol and count.
to_dict
()Serialize this object to a basic dict of strings and lists of ints.
Attributes
Iterator over the atoms in this hierarchy element.
True
if the element has unique atom names,False
otherwise.The number of atoms in this hierarchy element.
The parent molecule for this hierarchy element
- to_dict() dict[str, Union[tuple[Union[str, int]], Sequence[int]]] [source]
Serialize this object to a basic dict of strings and lists of ints.
- property n_atoms: int
The number of atoms in this hierarchy element.
- property parent: Molecule | FrozenMolecule | _SimpleMolecule
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(suffix: str = 'x')[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.
- Parameters:
suffix – Optional suffix added to atom names. Assists in denoting molecule types