|
NuriKit v0.1.0b2
|
Read-only molecule class. More...
#include <nuri/core/molecule.h>
Public Types | |
| using | GraphType = Graph<AtomData, BondData> |
| using | MutableAtom = GraphType::NodeRef |
| using | Atom = GraphType::ConstNodeRef |
| using | iterator = GraphType::iterator |
| using | const_iterator = GraphType::const_iterator |
| using | atom_iterator = iterator |
| using | const_atom_iterator = const_iterator |
| using | MutableBond = GraphType::EdgeRef |
| using | Bond = GraphType::ConstEdgeRef |
| using | bond_iterator = GraphType::edge_iterator |
| using | const_bond_iterator = GraphType::const_edge_iterator |
| using | MutableNeighbor = GraphType::AdjRef |
| using | Neighbor = GraphType::ConstAdjRef |
| using | neighbor_iterator = GraphType::adjacency_iterator |
| using | const_neighbor_iterator = GraphType::const_adjacency_iterator |
Public Member Functions | |
| Molecule () noexcept=default | |
| Construct an empty Molecule object. | |
| ~Molecule () noexcept=default | |
| Molecule (const Molecule &other) noexcept | |
| Molecule (Molecule &&other) noexcept | |
| Molecule & | operator= (const Molecule &other) noexcept |
| Molecule & | operator= (Molecule &&other) noexcept |
| template<class Iterator, class = internal::enable_if_compatible_iter_t<Iterator, AtomData>> | |
| Molecule (Iterator begin, Iterator end) | |
| Construct a Molecule object from a range of atom data. | |
| std::string & | name () |
| const std::string & | name () const |
| void | reserve (int num_atoms) |
| void | reserve_bonds (int num_bonds) |
| bool | empty () const |
| Check if the molecule has any atoms. | |
| int | size () const |
| Get the number of atoms in the molecule. | |
| int | num_atoms () const |
| Get the number of atoms in the molecule. | |
| int | count_heavy_atoms () const |
| Get the number of heavy atoms in the molecule (i.e., non-hydrogen atoms). | |
| MutableAtom | atom (int atom_idx) |
| Get a mutable atom of the molecule. | |
| Atom | atom (int atom_idx) const |
| Get an atom of the molecule. | |
| MutableAtom | operator[] (int atom_idx) |
| Get a mutable atom of the molecule. | |
| Atom | operator[] (int atom_idx) const |
| Get an atom of the molecule. | |
| iterator | begin () |
| The begin iterator of the molecule over atoms. | |
| const_iterator | begin () const |
| The begin iterator of the molecule over atoms. | |
| iterator | atom_begin () |
| The begin iterator of the molecule over atoms. | |
| const_iterator | atom_begin () const |
| The begin iterator of the molecule over atoms. | |
| iterator | end () |
| The past-the-end iterator of the molecule over atoms. | |
| const_iterator | end () const |
| The past-the-end iterator of the molecule over atoms. | |
| iterator | atom_end () |
| The past-the-end iterator of the molecule over atoms. | |
| const_iterator | atom_end () const |
| The past-the-end iterator of the molecule over atoms. | |
| bool | bond_empty () const |
| Check if the molecule has any bonds. | |
| int | num_bonds () const |
| Get the number of bonds in the molecule. | |
| MutableBond | bond (int bond_idx) |
| Get a mutable bond of the molecule. | |
| Bond | bond (int bond_idx) const |
| Get a bond of the molecule. | |
| bond_iterator | find_bond (int src, int dst) |
| Get a bond of the molecule. | |
| const_bond_iterator | find_bond (int src, int dst) const |
| Get a bond of the molecule. | |
| bond_iterator | find_bond (Atom src, Atom dst) |
| Get a bond of the molecule. | |
| const_bond_iterator | find_bond (Atom src, Atom dst) const |
| Get a bond of the molecule. | |
| auto | bonds () |
| Get an iterable, modifiable view over bonds of the molecule. | |
| auto | bonds () const |
| Get an iterable, non-modifiable view over bonds of the molecule. | |
| auto | cbonds () const |
| Get an iterable, non-modifiable view over bonds of the molecule. | |
| bond_iterator | bond_begin () |
| The begin iterator of the molecule over bonds. | |
| const_bond_iterator | bond_begin () const |
| The begin iterator of the molecule over bonds. | |
| bond_iterator | bond_end () |
| The past-the-end iterator of the molecule over bonds. | |
| const_bond_iterator | bond_end () const |
| The past-the-end iterator of the molecule over bonds. | |
| int | count_heavy_bonds () const |
| Get the number of bonds between heavy atoms in the molecule. | |
| int | num_neighbors (int atom) const |
| Get the explicitly connected neighbor atoms of the atom. | |
| neighbor_iterator | find_neighbor (int src, int dst) |
| Find a neighbor of the atom. | |
| const_neighbor_iterator | find_neighbor (int src, int dst) const |
| Find a neighbor of the atom. | |
| neighbor_iterator | find_neighbor (Atom src, Atom dst) |
| Find a neighbor of the atom. | |
| const_neighbor_iterator | find_neighbor (Atom src, Atom dst) const |
| Find a neighbor of the atom. | |
| neighbor_iterator | neighbor_begin (int atom_idx) |
| The begin iterator of an atom over its neighbors. | |
| const_neighbor_iterator | neighbor_begin (int atom_idx) const |
| The begin iterator of an atom over its neighbors. | |
| neighbor_iterator | neighbor_end (int atom_idx) |
| The past-the-end iterator of an atom over its neighbors. | |
| const_neighbor_iterator | neighbor_end (int atom_idx) const |
| The past-the-end iterator of an atom over its neighbors. | |
| MoleculeMutator | mutator () |
| Get a MoleculeMutator object associated with the molecule. | |
| void | clear () noexcept |
| Reset the molecule to an empty state. | |
| void | clear_atoms () noexcept |
| Clear all atoms and bonds of the molecule. | |
| void | clear_bonds () noexcept |
| Clear all bonds of the molecule. | |
| const GraphType & | raw_graph () const |
| Get the underlying graph of the molecule. | |
| ABSL_MUST_USE_RESULT bool | add_hydrogens (bool update_confs=true, bool optimize=true) |
| Make all implicit hydrogens explicit. | |
| void | erase_hydrogens () |
| Erase all trivial hydrogens from the molecule. | |
| bool | is_3d () const |
| Check if the molecule has any 3D conformations. | |
| std::vector< Matrix3Xd > & | confs () |
| Get all atomic coordinates of the conformers. | |
| const std::vector< Matrix3Xd > & | confs () const |
| Get all atomic coordinates of the conformers. | |
| void | transform (const Eigen::Isometry3d &trans) |
| Transform the molecule with the given affine transformation. | |
| void | transform (int i, const Eigen::Isometry3d &trans) |
| Transform a conformer of the molecule with the given affine transformation. | |
| double | distsq (int src, int dst, int conf=0) const |
| Calculate the squared distance between two atoms. | |
| double | distsq (Bond bond, int conf=0) const |
| Calculate the squared distance between two bonded atoms. | |
| double | distance (int src, int dst, int conf=0) const |
| Calculate the distance between two atoms. | |
| double | distance (Bond bond, int conf=0) const |
| Calculate the distance between two bonded atoms. | |
| ArrayXd | bond_lengths (int conf=0) const |
| Calculate the bond lengths of the molecule. | |
| bool | rotate_bond (int ref_atom, int pivot_atom, double angle) |
| Rotate a bond. | |
| bool | rotate_bond (int bid, double angle) |
| Rotate a bond. | |
| bool | rotate_bond_conf (int i, int ref_atom, int pivot_atom, double angle) |
| Rotate a bond of a conformer. | |
| bool | rotate_bond_conf (int i, int bid, double angle) |
| Rotate a bond of a conformer. | |
| Substructure | substructure (SubstructCategory cat=SubstructCategory::kUnknown) |
| Create and return a substurcture of the molecule. | |
| Substructure | substructure (internal::IndexSet &&atoms, internal::IndexSet &&bonds, SubstructCategory cat=SubstructCategory::kUnknown) |
| Create and return a substurcture of the molecule. | |
| Substructure | atom_substructure (internal::IndexSet &&atoms, SubstructCategory cat=SubstructCategory::kUnknown) |
| Create and return a substurcture of the molecule. | |
| Substructure | bond_substructure (internal::IndexSet &&bonds, SubstructCategory cat=SubstructCategory::kUnknown) noexcept |
| Create and return a substurcture of the molecule. | |
| ConstSubstructure | substructure (SubstructCategory cat=SubstructCategory::kUnknown) const |
| Create and return a substurcture of the molecule. | |
| ConstSubstructure | substructure (internal::IndexSet &&atoms, internal::IndexSet &&bonds, SubstructCategory cat=SubstructCategory::kUnknown) const |
| Create and return a substurcture of the molecule. | |
| ConstSubstructure | atom_substructure (internal::IndexSet &&atoms, SubstructCategory cat=SubstructCategory::kUnknown) const |
| Create and return a substurcture of the molecule. | |
| ConstSubstructure | bond_substructure (internal::IndexSet &&bonds, SubstructCategory cat=SubstructCategory::kUnknown) const |
| Create and return a substurcture of the molecule. | |
| std::vector< Substructure > & | substructures () |
| Get the substructures. | |
| const std::vector< Substructure > & | substructures () const |
| Get the substructures. | |
| void | update_topology () |
| Update topology of the molecule. | |
| int | num_sssr () const |
| Get size of SSSR. | |
| const std::vector< std::vector< int > > & | ring_groups () const |
| Get the ring groups of the molecule, i.e. all rings of a molecule, merged into groups of rings that share at least one atom. | |
| int | num_fragments () const |
| Get number of fragments (aka connected components). | |
| template<class MoleculeLike> | |
| void | merge (const MoleculeLike &other) |
| Merge other molecule-like object into this molecule. | |
| template<class KT, class VT> | |
| void | add_prop (KT &&key, VT &&val) |
| internal::PropertyMap & | props () |
| const internal::PropertyMap & | props () const |
Public Attributes | |
| friend | MoleculeMutator |
Read-only molecule class.
The few allowed mutable operations on the molecule are:
Note that it is the responsibility of the user to ensure the molecule is in a chemically valid state after property modification. For sanitization, use the MoleculeSanitizer class.
| using nuri::Molecule::GraphType = Graph<AtomData, BondData> |
|
defaultnoexcept |
Construct an empty Molecule object.
|
defaultnoexcept |
|
noexcept |
|
noexcept |
| nuri::Molecule::Molecule | ( | Iterator | begin, |
| Iterator | end ) |
| ABSL_MUST_USE_RESULT bool nuri::Molecule::add_hydrogens | ( | bool | update_confs = true, |
| bool | optimize = true ) |
Make all implicit hydrogens explicit.
| update_confs | Whether to update the conformers after adding hydrogens. Default is true. |
| optimize | Whether to optimize the geometry of the molecule after initial hydrogen placement. Default is true. When this is false, the resulting molecule may have clashes between atoms. |
|
inline |
|
inline |
Get a mutable atom of the molecule.
| atom_idx | Index of the atom to get. |
atom_idx -th atom of the molecule.
|
inline |
Get an atom of the molecule.
| atom_idx | Index of the atom to get. |
atom_idx -th atom of the molecule.
|
inline |
The begin iterator of the molecule over atoms.
|
inline |
The begin iterator of the molecule over atoms.
|
inline |
The past-the-end iterator of the molecule over atoms.
|
inline |
The past-the-end iterator of the molecule over atoms.
|
inline |
Create and return a substurcture of the molecule.
| atoms | Indices of atoms in the substructure. All bonds between the atoms will also be included in the substructure. |
| cat | The category of the substructure. |
|
inline |
Create and return a substurcture of the molecule.
| atoms | Indices of atoms in the substructure. All bonds between the atoms will also be included in the substructure. |
| cat | The category of the substructure. |
|
inline |
The begin iterator of the molecule over atoms.
|
inline |
The begin iterator of the molecule over atoms.
|
inline |
Get a mutable bond of the molecule.
| bond_idx | Index of the bond to get. |
bond_idx of the molecule.
|
inline |
Get a bond of the molecule.
| bond_idx | Index of the bond to get. |
bond_idx of the molecule.
|
inline |
The begin iterator of the molecule over bonds.
|
inline |
The begin iterator of the molecule over bonds.
|
inline |
Check if the molecule has any bonds.
|
inline |
The past-the-end iterator of the molecule over bonds.
|
inline |
The past-the-end iterator of the molecule over bonds.
| ArrayXd nuri::Molecule::bond_lengths | ( | int | conf = 0 | ) | const |
Calculate the bond lengths of the molecule.
| conf | Index of the conformer to use for the calculation. |
conf is out of range.
|
inline |
Create and return a substurcture of the molecule.
| bonds | Indices of bonds in the substructure. All atoms connected by the bonds will also be included in the substructure. |
| cat | The category of the substructure. |
|
inlinenoexcept |
Create and return a substurcture of the molecule.
| bonds | Indices of bonds in the substructure. All atoms connected by the bonds will also be included in the substructure. |
| cat | The category of the substructure. |
|
inline |
Get an iterable, modifiable view over bonds of the molecule.
|
inline |
Get an iterable, non-modifiable view over bonds of the molecule.
|
inline |
Get an iterable, non-modifiable view over bonds of the molecule.
|
noexcept |
Reset the molecule to an empty state.
This method effectively resets the molecule to the state of a default constructed molecule. Unlike clear_atoms(), this will also clear name, conformers, substructures, and properties.
|
noexcept |
Clear all atoms and bonds of the molecule.
All conformers will be resized to 0. All substructures will contain no atoms.
|
noexcept |
Clear all bonds of the molecule.
Conformers and substructures are not affected.
|
inline |
Get all atomic coordinates of the conformers.
|
inline |
Get all atomic coordinates of the conformers.
|
inline |
Get the number of heavy atoms in the molecule (i.e., non-hydrogen atoms).
|
inline |
Get the number of bonds between heavy atoms in the molecule.
|
inline |
Calculate the distance between two bonded atoms.
| bond | The bond between the two atoms. |
| conf | Index of the conformer to use for the calculation. |
|
inline |
Calculate the distance between two atoms.
| src | Index of the source atom. |
| dst | Index of the destination atom. |
| conf | Index of the conformer to use for the calculation. |
|
inline |
Calculate the squared distance between two bonded atoms.
| bond | The bond between the two atoms. |
| conf | Index of the conformer to use for the calculation. |
| double nuri::Molecule::distsq | ( | int | src, |
| int | dst, | ||
| int | conf = 0 ) const |
Calculate the squared distance between two atoms.
| src | Index of the source atom. |
| dst | Index of the destination atom. |
| conf | Index of the conformer to use for the calculation. |
|
inline |
Check if the molecule has any atoms.
|
inline |
The past-the-end iterator of the molecule over atoms.
|
inline |
The past-the-end iterator of the molecule over atoms.
| void nuri::Molecule::erase_hydrogens | ( | ) |
Erase all trivial hydrogens from the molecule.
Trivial hydrogens must satisfy the following conditions:
|
inline |
Get a bond of the molecule.
| src | The source atom of the bond. |
| dst | The destination atom of the bond. |
src and dst of the molecule. If no such bond exists, the returned iterator is equal to bond_end().
|
inline |
Get a bond of the molecule.
| src | The source atom of the bond. |
| dst | The destination atom of the bond. |
src and dst of the molecule. If no such bond exists, the returned iterator is equal to bond_end().
|
inline |
Get a bond of the molecule.
| src | Index of the source atom of the bond. |
| dst | Index of the destination atom of the bond. |
src and dst of the molecule. If no such bond exists, the returned iterator is equal to bond_end().
|
inline |
Get a bond of the molecule.
| src | Index of the source atom of the bond. |
| dst | Index of the destination atom of the bond. |
src and dst of the molecule. If no such bond exists, the returned iterator is equal to bond_end().
|
inline |
Find a neighbor of the atom.
| src | The source atom of the bond. |
| dst | The destination atom of the bond. |
src and dst of the molecule. If no such bond exists, the returned iterator is equal to neighbor_end(src)
|
inline |
Find a neighbor of the atom.
| src | The source atom of the bond. |
| dst | The destination atom of the bond. |
src and dst of the molecule. If no such bond exists, the returned iterator is equal to neighbor_end(src)
|
inline |
Find a neighbor of the atom.
| src | Index of the source atom of the bond. |
| dst | Index of the destination atom of the bond. |
src and dst of the molecule. If no such bond exists, the returned iterator is equal to neighbor_end(src)
|
inline |
Find a neighbor of the atom.
| src | Index of the source atom of the bond. |
| dst | Index of the destination atom of the bond. |
src and dst of the molecule. If no such bond exists, the returned iterator is equal to neighbor_end(src)
|
inline |
Check if the molecule has any 3D conformations.
|
inline |
Merge other molecule-like object into this molecule.
| MoleculeLike | Type of the other molecule-like object. |
| other | The other molecule-like object. |
|
inline |
Get a MoleculeMutator object associated with the molecule.
|
inline |
|
inline |
|
inline |
The begin iterator of an atom over its neighbors.
|
inline |
The begin iterator of an atom over its neighbors.
|
inline |
The past-the-end iterator of an atom over its neighbors.
|
inline |
The past-the-end iterator of an atom over its neighbors.
|
inline |
Get the number of atoms in the molecule.
|
inline |
Get the number of bonds in the molecule.
|
inline |
Get number of fragments (aka connected components).
|
inline |
Get the explicitly connected neighbor atoms of the atom.
| atom | Index of the atom. |
|
inline |
Get size of SSSR.
|
inline |
Get a mutable atom of the molecule.
| atom_idx | Index of the atom to get. |
atom_idx -th atom of the molecule.
|
inline |
Get an atom of the molecule.
| atom_idx | Index of the atom to get. |
atom_idx -th atom of the molecule.
|
inline |
|
inline |
|
inline |
Get the underlying graph of the molecule.
|
inline |
|
inline |
|
inline |
Get the ring groups of the molecule, i.e. all rings of a molecule, merged into groups of rings that share at least one atom.
| bool nuri::Molecule::rotate_bond | ( | int | bid, |
| double | angle ) |
Rotate a bond.
| bid | The index of bond to rotate. |
| angle | Angle to rotate (in degrees). |
The rotation is applied to all conformers of the molecule.
The source atom of the bond is fixed, and the destination atom will be rotated about the source atom -> destination atom axis. Positive angle means counter-clockwise rotation (as in the right-hand rule).
The behavior is undefined if any of the indices are out of range.
| bool nuri::Molecule::rotate_bond | ( | int | ref_atom, |
| int | pivot_atom, | ||
| double | angle ) |
Rotate a bond.
| ref_atom | Index of the reference atom. |
| pivot_atom | Index of the pivot atom. |
| angle | Angle to rotate (in degrees). |
The rotation is applied to all conformers of the molecule.
The part of the reference atom is fixed, and the part of the pivot atom will be rotated about the reference atom -> pivot atom axis. Positive angle means counter-clockwise rotation (as in the right-hand rule).
The behavior is undefined if any of the indices are out of range, or if the atoms are not connected by a bond.
| bool nuri::Molecule::rotate_bond_conf | ( | int | i, |
| int | bid, | ||
| double | angle ) |
Rotate a bond of a conformer.
| i | The index of the conformer to transform. |
| bid | The index of bond to rotate. |
| angle | Angle to rotate (in degrees). |
The source atom of the bond is fixed, and the destination atom will be rotated about the source atom -> destination atom axis. Positive angle means counter-clockwise rotation (as in the right-hand rule).
The behavior is undefined if any of the indices are out of range.
| bool nuri::Molecule::rotate_bond_conf | ( | int | i, |
| int | ref_atom, | ||
| int | pivot_atom, | ||
| double | angle ) |
Rotate a bond of a conformer.
| i | The index of the conformer to transform. |
| ref_atom | Index of the pivot atom. |
| pivot_atom | Index of the pivot atom. |
| angle | Angle to rotate (in degrees). |
The part of the pivot atom is fixed, and the part of the pivot atom will be rotated about the pivot atom -> pivot atom axis. Positive angle means counter-clockwise rotation (as in the right-hand rule).
The behavior is undefined if any of the indices are out of range, or if the atoms are not connected by a bond.
|
inline |
Get the number of atoms in the molecule.
|
inline |
Create and return a substurcture of the molecule.
| atoms | Indices of atoms in the substructure. |
| bonds | Indices of bonds in the substructure. |
| cat | The category of the substructure. |
|
inline |
Create and return a substurcture of the molecule.
| atoms | Indices of atoms in the substructure. |
| bonds | Indices of bonds in the substructure. |
| cat | The category of the substructure. |
|
inline |
Create and return a substurcture of the molecule.
| cat | The category of the substructure. |
|
inline |
Create and return a substurcture of the molecule.
| cat | The category of the substructure. |
|
inline |
Get the substructures.
|
inline |
Get the substructures.
|
inline |
Transform the molecule with the given affine transformation.
| trans | The affine transformation to apply. |
|
inline |
Transform a conformer of the molecule with the given affine transformation.
| i | The index of the conformer to transform. |
| trans | The affine transformation to apply. |
| void nuri::Molecule::update_topology | ( | ) |
Update topology of the molecule.
This method is safe to call multiple times, but will be automatically called from the MoleculeMutator class anyway. Thus, user code normally don't need to call this method.
| friend nuri::Molecule::MoleculeMutator |