Topology
¶A topology contains the definition of all the atoms in the system, as well as the liaisons between the particles (bonds, angles, dihedrals, …) and the residues.
Only the atoms and the bonds are stored, the angles, dihedrals and impropers are automaticaly deduced from the bonds.
It is also possible to iterate over a Topology
, yielding all the atoms in the system.
Public Functions
Topology
()¶Construct a new empty topology
operator[]
(size_t index)¶Get a reference to the atom at the position index
.
index
: the atomic index OutOfBounds
: if index
is greater than size()
operator[]
(size_t index) const¶Get a const reference to the atom at the position index
.
index
: the atomic index OutOfBounds
: if index
is greater than size()
add_atom
(Atom atom)¶Add an atom
at the end of this topology.
atom
: the new atom to add remove
(size_t i)¶Delete the atom at index i
in this topology, as well as all the bonds involving this atom.
This function modify the index of all the atoms after i
, and modify the bond list accordingly.
i
: the index of the atom to remove OutOfBounds
: if i
is greater than size() add_bond
(size_t atom_i, size_t atom_j, Bond::BondOrder bond_order = Bond::UNKNOWN)¶Add a bond in the system, between the atoms at index atom_i
and atom_j
.
atom_i
: the index of the first atom in the bond atom_j
: the index of the second atom in the bond bond_order
: the bond order for the bond added OutOfBounds
: if atom_i
or atom_j
are greater than size()
Error
: if atom_i == atom_j
, as this is an invalid bond remove_bond
(size_t atom_i, size_t atom_j)¶Remove a bond in the system, between the atoms at index atom_i
and atom_j
.
If the bond does not exist, this does nothing.
atom_i
: the index of the first atom in the bond atom_j
: the index of the second atom in the bond OutOfBounds
: if atom_i
or atom_j
are greater than size()
bond_order
(size_t atom_i, size_t atom_j) const¶Get the bond order for the given bond
If the bond does not exist, this will thrown an Error.
atom_i
: the index of the first atom in the bond atom_j
: the index of the second atom in the bond OutOfBounds
: if atom_i
or atom_j
are greater than size()
Error
: if no bond between atom_i
and atom_j
exists. size
() const¶Get the number of atoms in the topology
resize
(size_t size)¶Resize the topology to hold size
atoms, adding new atoms as needed.
If the new number of atoms is bigger than the old one, pre-existing atoms are conserved.
If the new size if smaller than the old one, all atoms and connectivity elements after the new size are removed.
size
: the new size of the topology reserve
(size_t size)¶Allocate memory in the frame to be able to store data for size
atoms.
This function does not change the actual number of atoms in the topology, and should be used as an optimisation.
size
: the number of elements to reserve memory for bonds
() const¶Get the bonds in the system
The bonds are sorted according to operator<(const Bond&, const Bond&)
, which mean it is possible to look for a bond in the list using a binary search (std::lower_bound
).
bond_orders
() const¶Get the bond orders in the system.
The bond orders are sorted so that the index of each bond is the same as its index in the array returned by Topology::bonds
. This means that the bond order for Topology::bonds()[index]
would be given by bond_orders()[index]
.
angles
() const¶Get the angles in the system
The angles are sorted according to operator<(const Angle&, const Angle&)
, which mean it is possible to look for an angle in the list using a binary search (std::lower_bound
).
dihedrals
() const¶Get the dihedral angles in the system
The dihedrals are sorted according to operator<(const Dihedral&, const Dihedral&)
, which mean it is possible to look for a dihedral in the list using a binary search (std::lower_bound
).
impropers
() const¶Get the improper dihedral angles in the system
The impropers are sorted according to operator<(const Improper&, const Improper&)
, which mean it is possible to look for an improper in the list using a binary search (std::lower_bound
).
clear_bonds
()¶Remove all bonding information in the topology (bonds, angles and dihedrals)
add_residue
(Residue residue)¶Add a residue
to this topology.
residue
: the residue to add to this topology chemfiles::Error
: if any atom in the residue
is already in another residue in this topology. In that case, the topology is not modified. are_linked
(const Residue &first, const Residue &second) const¶Check if two residues are linked together, i.e. if there is a bond between one atom in the first
residue and one atom in the second
one. Both residues should be in this topology.
The two residues are the same (first == second
), this function returns true
.
residue_for_atom
(size_t index) const¶Get the residue containing the atom at the given index
.
If no residue contains this atom, this function returns nullopt
.
This function returna an chemfiles::optional
value that is
close to C++17 std::optional
.
Bond
¶The Bond
class ensure a canonical representation of a bond two atoms.
This class implements all the comparison operators, as well as indexing.
Public Types
Public Functions
Bond
(size_t i, size_t j)¶Create a new Bond
containing the atoms i
and j
.
Error
: if i == j
operator[]
(size_t i) const¶Get the index of the i
th atom (i == 0
or i == 1
) in the bond.
OutOfBounds
: if i
is not 0 or 1 Angle
¶The Angle
class ensure a canonical representation of an angle between three atoms.
An angle is formed by two consecutive bonds:
| i k |
| \ / |
| j |
This class implements all the comparison operators, as well as indexing.
Public Functions
Angle
(size_t i, size_t j, size_t k)¶Create a new Angle
containing the atoms i
, j
and k
.
Error
: if i == j
, j == k
or i == k
operator[]
(size_t i) const¶Get the index of the i
th atom (i == 0
, i == 1
or i == 2
) in the angle.
OutOfBounds
: if i
is not 0, 1 or 2 Dihedral
¶The Dihedral
class ensure a canonical representation of a dihedral angle between four atoms.
A dihedral angle is formed by three consecutive bonds:
| i k |
| \ / \ |
| j m |
This class implements all the comparison operators, as well as indexing.
Public Functions
Dihedral
(size_t i, size_t j, size_t k, size_t m)¶Create a new Dihedral
containing the atoms i
, j
, k
and m
.
Error
: if any of i
, j
, k
, m
has the same value as another operator[]
(size_t i) const¶Get the index of the i
th atom (i
can be 0, 1, 2 or 3) in the dihedral.
OutOfBounds
: if i
is not 0, 1, 2 or 3. Improper
¶The Improper
class ensure a canonical representation of an improper dihedral angle between four atoms.
An improper dihedral angle is formed by three bonds around a central atom:
| i k |
| \ / |
| j |
| | |
| m |
This class implements all the comparison operators, as well as indexing.
The second atom of the improper is always the central atom.
Public Functions
Improper
(size_t i, size_t j, size_t k, size_t m)¶Create a new Improper
containing the atoms i
, j
, k
and m
. j
must be the central atom of the improper.
Error
: if any of i
, j
, k
, m
has the same value as another operator[]
(size_t i) const¶Get the index of the i
th atom (i
can be 0, 1, 2 or 3) in the improper.
OutOfBounds
: if i
is not 0, 1, 2 or 3.