NuriKit v0.1.0b2
Loading...
Searching...
No Matches
nuri::Molecule Class Reference

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
Moleculeoperator= (const Molecule &other) noexcept
Moleculeoperator= (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 GraphTyperaw_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

Detailed Description

Read-only molecule class.

The few allowed mutable operations on the molecule are:

  • updating atom/bond properties,
  • modifing conformers, and
  • adding/removing hydrogens.

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.

Member Typedef Documentation

◆ Atom

◆ atom_iterator

◆ Bond

◆ bond_iterator

◆ const_atom_iterator

◆ const_bond_iterator

◆ const_iterator

◆ const_neighbor_iterator

◆ GraphType

◆ iterator

◆ MutableAtom

◆ MutableBond

◆ MutableNeighbor

◆ Neighbor

◆ neighbor_iterator

Constructor & Destructor Documentation

◆ Molecule() [1/4]

nuri::Molecule::Molecule ( )
defaultnoexcept

Construct an empty Molecule object.

◆ ~Molecule()

nuri::Molecule::~Molecule ( )
defaultnoexcept

◆ Molecule() [2/4]

nuri::Molecule::Molecule ( const Molecule & other)
noexcept

◆ Molecule() [3/4]

nuri::Molecule::Molecule ( Molecule && other)
noexcept

◆ Molecule() [4/4]

template<class Iterator, class>
nuri::Molecule::Molecule ( Iterator begin,
Iterator end )

Construct a Molecule object from a range of atom data.

Template Parameters
IteratorThe type of the iterator.
Parameters
beginThe begin iterator of the range, where AtomData must be constructible from value type of begin.
endThe past-the-end iterator of the range.

Member Function Documentation

◆ add_hydrogens()

ABSL_MUST_USE_RESULT bool nuri::Molecule::add_hydrogens ( bool update_confs = true,
bool optimize = true )

Make all implicit hydrogens explicit.

Parameters
update_confsWhether to update the conformers after adding hydrogens. Default is true.
optimizeWhether 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.
Returns
Whether the operation was successful. Fails only if the molecule has more than one conformers and the geometry optimization fails. When this function returns false, the coordinates of the newly added hydrogens are not guaranteed to be chemically valid.

◆ add_prop()

template<class KT, class VT>
void nuri::Molecule::add_prop ( KT && key,
VT && val )
inline

◆ atom() [1/2]

MutableAtom nuri::Molecule::atom ( int atom_idx)
inline

Get a mutable atom of the molecule.

Parameters
atom_idxIndex of the atom to get.
Returns
A mutable view over atom_idx -th atom of the molecule.
Note
If the atom index is out of range, the behavior is undefined. The returned reference is invalidated when the molecule is modified.

◆ atom() [2/2]

Atom nuri::Molecule::atom ( int atom_idx) const
inline

Get an atom of the molecule.

Parameters
atom_idxIndex of the atom to get.
Returns
A read-only view over atom_idx -th atom of the molecule.
Note
If the atom index is out of range, the behavior is undefined. The returned reference is invalidated when the molecule is modified.

◆ atom_begin() [1/2]

iterator nuri::Molecule::atom_begin ( )
inline

The begin iterator of the molecule over atoms.

See also
begin()

◆ atom_begin() [2/2]

const_iterator nuri::Molecule::atom_begin ( ) const
inline

The begin iterator of the molecule over atoms.

See also
begin()

◆ atom_end() [1/2]

iterator nuri::Molecule::atom_end ( )
inline

The past-the-end iterator of the molecule over atoms.

◆ atom_end() [2/2]

const_iterator nuri::Molecule::atom_end ( ) const
inline

The past-the-end iterator of the molecule over atoms.

◆ atom_substructure() [1/2]

Substructure nuri::Molecule::atom_substructure ( internal::IndexSet && atoms,
SubstructCategory cat = SubstructCategory::kUnknown )
inline

Create and return a substurcture of the molecule.

Parameters
atomsIndices of atoms in the substructure. All bonds between the atoms will also be included in the substructure.
catThe category of the substructure.

◆ atom_substructure() [2/2]

ConstSubstructure nuri::Molecule::atom_substructure ( internal::IndexSet && atoms,
SubstructCategory cat = SubstructCategory::kUnknown ) const
inline

Create and return a substurcture of the molecule.

Parameters
atomsIndices of atoms in the substructure. All bonds between the atoms will also be included in the substructure.
catThe category of the substructure.

◆ begin() [1/2]

iterator nuri::Molecule::begin ( )
inline

The begin iterator of the molecule over atoms.

See also
atom_begin()

◆ begin() [2/2]

const_iterator nuri::Molecule::begin ( ) const
inline

The begin iterator of the molecule over atoms.

See also
atom_begin()

◆ bond() [1/2]

MutableBond nuri::Molecule::bond ( int bond_idx)
inline

Get a mutable bond of the molecule.

Parameters
bond_idxIndex of the bond to get.
Returns
A mutable view over bond bond_idx of the molecule.
Note
If the atom index is out of range, the behavior is undefined. The returned reference is invalidated when the molecule is modified.

◆ bond() [2/2]

Bond nuri::Molecule::bond ( int bond_idx) const
inline

Get a bond of the molecule.

Parameters
bond_idxIndex of the bond to get.
Returns
A read-only view over bond bond_idx of the molecule.
Note
If the atom index is out of range, the behavior is undefined. The returned reference is invalidated when the molecule is modified.

◆ bond_begin() [1/2]

bond_iterator nuri::Molecule::bond_begin ( )
inline

The begin iterator of the molecule over bonds.

◆ bond_begin() [2/2]

const_bond_iterator nuri::Molecule::bond_begin ( ) const
inline

The begin iterator of the molecule over bonds.

◆ bond_empty()

bool nuri::Molecule::bond_empty ( ) const
inline

Check if the molecule has any bonds.

◆ bond_end() [1/2]

bond_iterator nuri::Molecule::bond_end ( )
inline

The past-the-end iterator of the molecule over bonds.

◆ bond_end() [2/2]

const_bond_iterator nuri::Molecule::bond_end ( ) const
inline

The past-the-end iterator of the molecule over bonds.

◆ bond_lengths()

ArrayXd nuri::Molecule::bond_lengths ( int conf = 0) const

Calculate the bond lengths of the molecule.

Parameters
confIndex of the conformer to use for the calculation.
Returns
An array of bond lengths. The order of the bond lengths is the same as the order of the bonds returned by bonds().
Note
The behavior is undefined if conf is out of range.

◆ bond_substructure() [1/2]

ConstSubstructure nuri::Molecule::bond_substructure ( internal::IndexSet && bonds,
SubstructCategory cat = SubstructCategory::kUnknown ) const
inline

Create and return a substurcture of the molecule.

Parameters
bondsIndices of bonds in the substructure. All atoms connected by the bonds will also be included in the substructure.
catThe category of the substructure.

◆ bond_substructure() [2/2]

Substructure nuri::Molecule::bond_substructure ( internal::IndexSet && bonds,
SubstructCategory cat = SubstructCategory::kUnknown )
inlinenoexcept

Create and return a substurcture of the molecule.

Parameters
bondsIndices of bonds in the substructure. All atoms connected by the bonds will also be included in the substructure.
catThe category of the substructure.

◆ bonds() [1/2]

auto nuri::Molecule::bonds ( )
inline

Get an iterable, modifiable view over bonds of the molecule.

◆ bonds() [2/2]

auto nuri::Molecule::bonds ( ) const
inline

Get an iterable, non-modifiable view over bonds of the molecule.

◆ cbonds()

auto nuri::Molecule::cbonds ( ) const
inline

Get an iterable, non-modifiable view over bonds of the molecule.

◆ clear()

void nuri::Molecule::clear ( )
noexcept

Reset the molecule to an empty state.

Note
Don't call this method if you have an active MoleculeMutator object. Call MoleculeMutator::clear() instead.

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.

◆ clear_atoms()

void nuri::Molecule::clear_atoms ( )
noexcept

Clear all atoms and bonds of the molecule.

Note
Don't call this method if you have an active MoleculeMutator object. Call MoleculeMutator::clear_atoms() instead.

All conformers will be resized to 0. All substructures will contain no atoms.

◆ clear_bonds()

void nuri::Molecule::clear_bonds ( )
noexcept

Clear all bonds of the molecule.

Note
Don't call this method if you have an active MoleculeMutator object. Call MoleculeMutator::clear_bonds() instead.

Conformers and substructures are not affected.

◆ confs() [1/2]

std::vector< Matrix3Xd > & nuri::Molecule::confs ( )
inline

Get all atomic coordinates of the conformers.

Returns
Atomic coordinates of the conformers of the molecule.
Note
If any conformer's column size is not equal to the number of atoms, the behavior is undefined.

◆ confs() [2/2]

const std::vector< Matrix3Xd > & nuri::Molecule::confs ( ) const
inline

Get all atomic coordinates of the conformers.

Returns
Atomic coordinates of the conformers of the molecule.

◆ count_heavy_atoms()

int nuri::Molecule::count_heavy_atoms ( ) const
inline

Get the number of heavy atoms in the molecule (i.e., non-hydrogen atoms).

See also
size(), num_atoms()
Note
Time complexity is O(V).

◆ count_heavy_bonds()

int nuri::Molecule::count_heavy_bonds ( ) const
inline

Get the number of bonds between heavy atoms in the molecule.

See also
num_bonds()
Note
Time complexity is O(E).

◆ distance() [1/2]

double nuri::Molecule::distance ( Bond bond,
int conf = 0 ) const
inline

Calculate the distance between two bonded atoms.

Parameters
bondThe bond between the two atoms.
confIndex of the conformer to use for the calculation.
Returns
The distance between the two atoms.
Note
The behavior is undefined the bond is not in the molecule, or if the conformer index is out of range.

◆ distance() [2/2]

double nuri::Molecule::distance ( int src,
int dst,
int conf = 0 ) const
inline

Calculate the distance between two atoms.

Parameters
srcIndex of the source atom.
dstIndex of the destination atom.
confIndex of the conformer to use for the calculation.
Returns
The distance between the two atoms.
Note
The behavior is undefined if any of the indices are out of range.

◆ distsq() [1/2]

double nuri::Molecule::distsq ( Bond bond,
int conf = 0 ) const
inline

Calculate the squared distance between two bonded atoms.

Parameters
bondThe bond between the two atoms.
confIndex of the conformer to use for the calculation.
Returns
The squared distance between the two atoms.
Note
The behavior is undefined the bond is not in the molecule, or if the conformer index is out of range.

◆ distsq() [2/2]

double nuri::Molecule::distsq ( int src,
int dst,
int conf = 0 ) const

Calculate the squared distance between two atoms.

Parameters
srcIndex of the source atom.
dstIndex of the destination atom.
confIndex of the conformer to use for the calculation.
Returns
The squared distance between the two atoms.
Note
The behavior is undefined if any of the indices are out of range.

◆ empty()

bool nuri::Molecule::empty ( ) const
inline

Check if the molecule has any atoms.

◆ end() [1/2]

iterator nuri::Molecule::end ( )
inline

The past-the-end iterator of the molecule over atoms.

◆ end() [2/2]

const_iterator nuri::Molecule::end ( ) const
inline

The past-the-end iterator of the molecule over atoms.

◆ erase_hydrogens()

void nuri::Molecule::erase_hydrogens ( )

Erase all trivial hydrogens from the molecule.

Trivial hydrogens must satisfy the following conditions:

  1. The hydrogen atom has single neighbor,
  2. The neighbor is a heavy atom,
  3. The two atoms are connected by a single bond, and
  4. The hydrogen atom has no implicit hydrogens.

◆ find_bond() [1/4]

bond_iterator nuri::Molecule::find_bond ( Atom src,
Atom dst )
inline

Get a bond of the molecule.

Parameters
srcThe source atom of the bond.
dstThe destination atom of the bond.
Returns
An iterator to the bond between src and dst of the molecule. If no such bond exists, the returned iterator is equal to bond_end().

◆ find_bond() [2/4]

const_bond_iterator nuri::Molecule::find_bond ( Atom src,
Atom dst ) const
inline

Get a bond of the molecule.

Parameters
srcThe source atom of the bond.
dstThe destination atom of the bond.
Returns
An iterator to the bond between src and dst of the molecule. If no such bond exists, the returned iterator is equal to bond_end().

◆ find_bond() [3/4]

bond_iterator nuri::Molecule::find_bond ( int src,
int dst )
inline

Get a bond of the molecule.

Parameters
srcIndex of the source atom of the bond.
dstIndex of the destination atom of the bond.
Returns
An iterator to the bond between src and dst of the molecule. If no such bond exists, the returned iterator is equal to bond_end().

◆ find_bond() [4/4]

const_bond_iterator nuri::Molecule::find_bond ( int src,
int dst ) const
inline

Get a bond of the molecule.

Parameters
srcIndex of the source atom of the bond.
dstIndex of the destination atom of the bond.
Returns
An iterator to the bond between src and dst of the molecule. If no such bond exists, the returned iterator is equal to bond_end().

◆ find_neighbor() [1/4]

neighbor_iterator nuri::Molecule::find_neighbor ( Atom src,
Atom dst )
inline

Find a neighbor of the atom.

Parameters
srcThe source atom of the bond.
dstThe destination atom of the bond.
Returns
An iterator to the neighbor wrapper between src and dst of the molecule. If no such bond exists, the returned iterator is equal to neighbor_end(src)

◆ find_neighbor() [2/4]

const_neighbor_iterator nuri::Molecule::find_neighbor ( Atom src,
Atom dst ) const
inline

Find a neighbor of the atom.

Parameters
srcThe source atom of the bond.
dstThe destination atom of the bond.
Returns
An iterator to the neighbor wrapper between src and dst of the molecule. If no such bond exists, the returned iterator is equal to neighbor_end(src)

◆ find_neighbor() [3/4]

neighbor_iterator nuri::Molecule::find_neighbor ( int src,
int dst )
inline

Find a neighbor of the atom.

Parameters
srcIndex of the source atom of the bond.
dstIndex of the destination atom of the bond.
Returns
An iterator to the neighbor wrapper between src and dst of the molecule. If no such bond exists, the returned iterator is equal to neighbor_end(src)

◆ find_neighbor() [4/4]

const_neighbor_iterator nuri::Molecule::find_neighbor ( int src,
int dst ) const
inline

Find a neighbor of the atom.

Parameters
srcIndex of the source atom of the bond.
dstIndex of the destination atom of the bond.
Returns
An iterator to the neighbor wrapper between src and dst of the molecule. If no such bond exists, the returned iterator is equal to neighbor_end(src)

◆ is_3d()

bool nuri::Molecule::is_3d ( ) const
inline

Check if the molecule has any 3D conformations.

Returns
true if the molecule has any 3D conformations, false otherwise.

◆ merge()

template<class MoleculeLike>
void nuri::Molecule::merge ( const MoleculeLike & other)
inline

Merge other molecule-like object into this molecule.

Template Parameters
MoleculeLikeType of the other molecule-like object.
Parameters
otherThe other molecule-like object.
Warning
The resulting molecule might not be chemically valid. Use the MolculeSanitizer class to sanitize the molecule if necessary.
Note
Size of conformers will be updated, but the positions of the added atoms will not be set. It is the responsibility of the user to set the positions of the added atoms if necessary.
This method effectively calls update_topology().

◆ mutator()

MoleculeMutator nuri::Molecule::mutator ( )
inline

Get a MoleculeMutator object associated with the molecule.

Returns
The MoleculeMutator object to update this molecule.
See also
MoleculeMutator

◆ name() [1/2]

std::string & nuri::Molecule::name ( )
inline

◆ name() [2/2]

const std::string & nuri::Molecule::name ( ) const
inline

◆ neighbor_begin() [1/2]

neighbor_iterator nuri::Molecule::neighbor_begin ( int atom_idx)
inline

The begin iterator of an atom over its neighbors.

◆ neighbor_begin() [2/2]

const_neighbor_iterator nuri::Molecule::neighbor_begin ( int atom_idx) const
inline

The begin iterator of an atom over its neighbors.

◆ neighbor_end() [1/2]

neighbor_iterator nuri::Molecule::neighbor_end ( int atom_idx)
inline

The past-the-end iterator of an atom over its neighbors.

◆ neighbor_end() [2/2]

const_neighbor_iterator nuri::Molecule::neighbor_end ( int atom_idx) const
inline

The past-the-end iterator of an atom over its neighbors.

◆ num_atoms()

int nuri::Molecule::num_atoms ( ) const
inline

Get the number of atoms in the molecule.

See also
size()

◆ num_bonds()

int nuri::Molecule::num_bonds ( ) const
inline

Get the number of bonds in the molecule.

◆ num_fragments()

int nuri::Molecule::num_fragments ( ) const
inline

Get number of fragments (aka connected components).

Returns
The number of fragments.

◆ num_neighbors()

int nuri::Molecule::num_neighbors ( int atom) const
inline

Get the explicitly connected neighbor atoms of the atom.

Parameters
atomIndex of the atom.
Returns
The number of bonds connected to the atom.
Note
If the atom index is out of range, the behavior is undefined.
See also
all_neighbors(), count_heavy(), count_hydrogens()

◆ num_sssr()

int nuri::Molecule::num_sssr ( ) const
inline

Get size of SSSR.

Returns
The number of rings in the smallest set of smallest rings.

◆ operator=() [1/2]

Molecule & nuri::Molecule::operator= ( const Molecule & other)
noexcept

◆ operator=() [2/2]

Molecule & nuri::Molecule::operator= ( Molecule && other)
noexcept

◆ operator[]() [1/2]

MutableAtom nuri::Molecule::operator[] ( int atom_idx)
inline

Get a mutable atom of the molecule.

Parameters
atom_idxIndex of the atom to get.
Returns
A mutable view over atom_idx -th atom of the molecule.
Note
If the atom index is out of range, the behavior is undefined. The returned reference is invalidated when the molecule is modified.

◆ operator[]() [2/2]

Atom nuri::Molecule::operator[] ( int atom_idx) const
inline

Get an atom of the molecule.

Parameters
atom_idxIndex of the atom to get.
Returns
A read-only view over atom_idx -th atom of the molecule.
Note
If the atom index is out of range, the behavior is undefined. The returned reference is invalidated when the molecule is modified.

◆ props() [1/2]

internal::PropertyMap & nuri::Molecule::props ( )
inline

◆ props() [2/2]

const internal::PropertyMap & nuri::Molecule::props ( ) const
inline

◆ raw_graph()

const GraphType & nuri::Molecule::raw_graph ( ) const
inline

Get the underlying graph of the molecule.

Note
This is a low-level API and mostly used for internal purposes. Use the higher-level APIs provided by the Molecule class instead.

◆ reserve()

void nuri::Molecule::reserve ( int num_atoms)
inline

◆ reserve_bonds()

void nuri::Molecule::reserve_bonds ( int num_bonds)
inline

◆ ring_groups()

const std::vector< std::vector< int > > & nuri::Molecule::ring_groups ( ) const
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.

Returns
List of the ring groups. If a ring group consists of single ring, the atom indices form a ring in the order of the returned vector.

◆ rotate_bond() [1/2]

bool nuri::Molecule::rotate_bond ( int bid,
double angle )

Rotate a bond.

Parameters
bidThe index of bond to rotate.
angleAngle to rotate (in degrees).
Returns
true if the rotation was applied, false if the rotation was not applied.
Note
Rotatability only considers ring membership. The user is responsible to check bond order or other constraints.

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.

◆ rotate_bond() [2/2]

bool nuri::Molecule::rotate_bond ( int ref_atom,
int pivot_atom,
double angle )

Rotate a bond.

Parameters
ref_atomIndex of the reference atom.
pivot_atomIndex of the pivot atom.
angleAngle to rotate (in degrees).
Returns
true if the rotation was applied, false if the rotation was not applied.
Note
Rotatability only considers ring membership. The user is responsible to check bond order or other constraints.

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.

◆ rotate_bond_conf() [1/2]

bool nuri::Molecule::rotate_bond_conf ( int i,
int bid,
double angle )

Rotate a bond of a conformer.

Parameters
iThe index of the conformer to transform.
bidThe index of bond to rotate.
angleAngle to rotate (in degrees).
Returns
true if the rotation was applied, false if the rotation was not applied (e.g. the bond is not rotatable, etc.).
Note
Rotatability only considers ring membership. The user is responsible to check bond order or other constraints.

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.

◆ rotate_bond_conf() [2/2]

bool nuri::Molecule::rotate_bond_conf ( int i,
int ref_atom,
int pivot_atom,
double angle )

Rotate a bond of a conformer.

Parameters
iThe index of the conformer to transform.
ref_atomIndex of the pivot atom.
pivot_atomIndex of the pivot atom.
angleAngle to rotate (in degrees).
Returns
true if the rotation was applied, false if the rotation was not applied.
Note
Rotatability only considers ring membership. The user is responsible to check bond order or other constraints.

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.

◆ size()

int nuri::Molecule::size ( ) const
inline

Get the number of atoms in the molecule.

See also
num_atoms()

◆ substructure() [1/4]

Substructure nuri::Molecule::substructure ( internal::IndexSet && atoms,
internal::IndexSet && bonds,
SubstructCategory cat = SubstructCategory::kUnknown )
inline

Create and return a substurcture of the molecule.

Parameters
atomsIndices of atoms in the substructure.
bondsIndices of bonds in the substructure.
catThe category of the substructure.
Returns
The new substructure.

◆ substructure() [2/4]

ConstSubstructure nuri::Molecule::substructure ( internal::IndexSet && atoms,
internal::IndexSet && bonds,
SubstructCategory cat = SubstructCategory::kUnknown ) const
inline

Create and return a substurcture of the molecule.

Parameters
atomsIndices of atoms in the substructure.
bondsIndices of bonds in the substructure.
catThe category of the substructure.
Returns
The new substructure.

◆ substructure() [3/4]

Substructure nuri::Molecule::substructure ( SubstructCategory cat = SubstructCategory::kUnknown)
inline

Create and return a substurcture of the molecule.

Parameters
catThe category of the substructure.
Returns
The new substructure.

◆ substructure() [4/4]

ConstSubstructure nuri::Molecule::substructure ( SubstructCategory cat = SubstructCategory::kUnknown) const
inline

Create and return a substurcture of the molecule.

Parameters
catThe category of the substructure.
Returns
The new substructure.

◆ substructures() [1/2]

std::vector< Substructure > & nuri::Molecule::substructures ( )
inline

Get the substructures.

Returns
A reference to all substructures.

◆ substructures() [2/2]

const std::vector< Substructure > & nuri::Molecule::substructures ( ) const
inline

Get the substructures.

Returns
A const reference to all substructures.

◆ transform() [1/2]

void nuri::Molecule::transform ( const Eigen::Isometry3d & trans)
inline

Transform the molecule with the given affine transformation.

Parameters
transThe affine transformation to apply.

◆ transform() [2/2]

void nuri::Molecule::transform ( int i,
const Eigen::Isometry3d & trans )
inline

Transform a conformer of the molecule with the given affine transformation.

Parameters
iThe index of the conformer to transform.
transThe affine transformation to apply.
Note
The behavior is undefined if the conformer index is out of range.

◆ update_topology()

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.

Note
This only changes ring atom/bond flags. If the molecule is modified in a way that changes aromaticity, the aromaticity flags should be updated manually or by using the MoleculeSanitizer class.
Warning
All molecule-related methods/functions assume that the molecule has valid topology data.

Member Data Documentation

◆ MoleculeMutator

friend nuri::Molecule::MoleculeMutator

The documentation for this class was generated from the following file: