RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
RDKit::MacroMol Class Reference

#include <MacroMol.h>

Inheritance diagram for RDKit::MacroMol:
RDKit::RWMol RDKit::ROMol RDKit::RDProps

Public Member Functions

 MacroMol ()
 Constructs a MacroMol with an empty local template library.
 MacroMol (std::unique_ptr< MacroMolTemplateLibrary > localTemplateLibrary)
 Constructs a MacroMol that takes ownership of a local template library.
 MacroMol (const MacroMol &other)
MacroMol & operator= (const MacroMol &other)
 MacroMol (MacroMol &&other) noexcept=default
MacroMol & operator= (MacroMol &&other) noexcept=default
void setLocalTemplateLibrary (std::unique_ptr< MacroMolTemplateLibrary > newTemplateLibrary)
 Replaces the local template library and takes ownership of it.
MacroMolTemplateLibrary & getLocalTemplateLibrary ()
 Returns this molecule's local template library.
const MacroMolTemplateLibrary & getLocalTemplateLibrary () const
 Returns this molecule's local template library.
bool checkLocalTemplateReferences () const
 Checks that every macro atom resolves in the local template library.
unsigned int addMacroAtom (std::string symbol, MonomerClass monomerClass)
 Adds a new macro atom to the molecule.
unsigned int addMacroBond (unsigned int beginAtomIdx, unsigned int endAtomIdx, int beginAttachPt, int endAttachPt, Bond::BondType bondType=Bond::SINGLE)
 Adds a bond between two macro atoms.
unsigned int addAtomToMacroAtomBond (unsigned int beginAtomIdx, unsigned int endMacroAtomIdx, int endAttachPt, Bond::BondType bondType=Bond::BondType::SINGLE)
 Adds a bond from a regular atom to a macro atom.
unsigned int addMacroAtomToAtomBond (unsigned int beginMacroAtomIdx, unsigned int endAtomIdx, int beginAttachPt, Bond::BondType bondType=Bond::BondType::SINGLE)
 Adds a bond from a macro atom to a regular atom.
unsigned int addBond (unsigned int beginAtomIdx, unsigned int endAtomIdx, Bond::BondType bondType=Bond::SINGLE)
 Adds a bond between two regular atoms.
unsigned int addBond (Atom *beginAtom, Atom *endAtom, Bond::BondType bondType=Bond::SINGLE)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
unsigned int addBond (Bond *bond, bool takeOwnership=false)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Public Member Functions inherited from RDKit::RWMol
 RWMol ()
 RWMol (const ROMol &other, bool quickCopy=false, int confId=-1)
 copy constructor with a twist
 RWMol (const RWMol &other)
RWMol & operator= (const RWMol &)
 RWMol (RWMol &&other) noexcept
RWMol & operator= (RWMol &&other) noexcept
void insertMol (const ROMol &other)
 insert the atoms and bonds from other into this molecule
void clear ()
 removes all atoms, bonds, properties, bookmarks, etc.
void beginBatchEdit ()
void rollbackBatchEdit ()
void commitBatchEdit ()
unsigned int addAtom (bool updateLabel=true)
 adds an empty Atom to our collection
unsigned int addAtom (Atom *atom, bool updateLabel=true, bool takeOwnership=false)
 adds an Atom to our collection
void replaceAtom (unsigned int idx, Atom *atom, bool updateLabel=false, bool preserveProps=false)
 adds an Atom to our collection
Atom * getLastAtom ()
 returns a pointer to the highest-numbered Atom
Atom * getActiveAtom ()
 returns a pointer to the "active" Atom
void setActiveAtom (Atom *atom)
 sets our activeAtom
void setActiveAtom (unsigned int idx)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void removeAtom (unsigned int idx)
 removes an Atom from the molecule
void removeAtom (Atom *atom)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void removeAtom (Atom *atom, bool clearProps)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
unsigned int addBond (unsigned int beginAtomIdx, unsigned int endAtomIdx, Bond::BondType order=Bond::UNSPECIFIED)
 adds a Bond between the indicated Atoms
unsigned int addBond (Atom *beginAtom, Atom *endAtom, Bond::BondType order=Bond::UNSPECIFIED)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
unsigned int addBond (Bond *bond, bool takeOwnership=false)
 adds a Bond to our collection
Bond * createPartialBond (unsigned int beginAtomIdx, Bond::BondType order=Bond::UNSPECIFIED)
 starts a Bond and sets its beginAtomIdx
unsigned int finishPartialBond (unsigned int endAtomIdx, int bondBookmark, Bond::BondType order=Bond::UNSPECIFIED)
 finishes a partially constructed bond
void removeBond (unsigned int beginAtomIdx, unsigned int endAtomIdx)
 removes a bond from the molecule
void replaceBond (unsigned int idx, Bond *bond, bool preserveProps=false, bool keepSGroups=true)
 replaces a particular Bond
Public Member Functions inherited from RDKit::ROMol
CXXAtomIterator< MolGraph, Atom * > atoms ()
 C++11 Range iterator.
CXXAtomIterator< const MolGraph, Atom *const > atoms () const
CXXAtomIterator< MolGraph, Atom *, MolGraph::vertex_iterator, true > checkedAtoms ()
CXXAtomIterator< const MolGraph, Atom *const, MolGraph::vertex_iterator, true > checkedAtoms () const
CXXAtomIterator< const MolGraph, Atom *const, MolGraph::adjacency_iterator > atomNeighbors (Atom const *at) const
CXXAtomIterator< MolGraph, Atom *, MolGraph::adjacency_iterator > atomNeighbors (Atom const *at)
CXXBondIterator< const MolGraph, Bond *const, MolGraph::out_edge_iterator > atomBonds (Atom const *at) const
CXXBondIterator< MolGraph, Bond *, MolGraph::out_edge_iterator > atomBonds (Atom const *at)
CXXAtomIterator< const MolGraph, Atom *const, MolGraph::adjacency_iterator, true, true > checkedAtomNeighbors (Atom const *at) const
CXXAtomIterator< MolGraph, Atom *, MolGraph::adjacency_iterator, true, true > checkedAtomNeighbors (Atom const *at)
CXXBondIterator< const MolGraph, Bond *const, MolGraph::out_edge_iterator, true > checkedAtomBonds (Atom const *at) const
CXXBondIterator< MolGraph, Bond *, MolGraph::out_edge_iterator, true > checkedAtomBonds (Atom const *at)
CXXBondIterator< MolGraph, Bond * > bonds ()
CXXBondIterator< const MolGraph, Bond *const > bonds () const
CXXBondIterator< MolGraph, Bond *, MolGraph::edge_iterator, true > checkedBonds ()
CXXBondIterator< const MolGraph, Bond *const, MolGraph::edge_iterator, true > checkedBonds () const
 ROMol ()
 ROMol (const ROMol &other, bool quickCopy=false, int confId=-1)
 copy constructor with a twist
 ROMol (const std::string &binStr)
 construct a molecule from a pickle string
 ROMol (const std::string &binStr, unsigned int propertyFlags)
 construct a molecule from a pickle string
 ROMol (ROMol &&o) noexcept
ROMol & operator= (ROMol &&o) noexcept
ROMol & operator= (const ROMol &)=delete
virtual ~ROMol ()
Atom * operator[] (const vertex_descriptor &v)
const Atom * operator[] (const vertex_descriptor &v) const
Bond * operator[] (const edge_descriptor &e)
const Bond * operator[] (const edge_descriptor &e) const
const std::vector< StereoGroup > & getStereoGroups () const
 Gets a reference to the groups of atoms with relative stereochemistry.
void setStereoGroups (std::vector< StereoGroup > stereo_groups)
 Sets groups of atoms with relative stereochemistry.
unsigned int getNumAtoms () const
 returns our number of atoms
unsigned int getNumAtoms (bool onlyExplicit) const
unsigned int getNumHeavyAtoms () const
 returns our number of heavy atoms (atomic number > 1)
Atom * getAtomWithIdx (unsigned int idx)
 returns a pointer to a particular Atom
const Atom * getAtomWithIdx (unsigned int idx) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class U>
Atom * getAtomWithIdx (const U idx)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class U>
const Atom * getAtomWithIdx (const U idx) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
unsigned int getAtomDegree (const Atom *at) const
 returns the degree (number of neighbors) of an Atom in the graph
unsigned int getNumBonds (bool onlyHeavy=1) const
 returns our number of Bonds
Bond * getBondWithIdx (unsigned int idx)
 returns a pointer to a particular Bond
const Bond * getBondWithIdx (unsigned int idx) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class U>
Bond * getBondWithIdx (const U idx)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class U>
const Bond * getBondWithIdx (const U idx) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Bond * getBondBetweenAtoms (unsigned int idx1, unsigned int idx2)
 returns a pointer to the bond between two atoms, Null on failure
const Bond * getBondBetweenAtoms (unsigned int idx1, unsigned int idx2) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class U, class V>
Bond * getBondBetweenAtoms (const U idx1, const V idx2)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class U, class V>
const Bond * getBondBetweenAtoms (const U idx1, const V idx2) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void setAtomBookmark (Atom *at, int mark)
 associates an Atom pointer with a bookmark
void replaceAtomBookmark (Atom *at, int mark)
 associates an Atom pointer with a bookmark
Atom * getAtomWithBookmark (int mark)
 returns the first Atom associated with the bookmark provided
Atom * getUniqueAtomWithBookmark (int mark)
ATOM_PTR_LIST & getAllAtomsWithBookmark (int mark)
 returns all Atoms associated with the bookmark provided
void clearAtomBookmark (int mark)
 removes a bookmark from our collection
void clearAtomBookmark (int mark, const Atom *atom)
 removes a particular Atom from the list associated with the bookmark
void clearAllAtomBookmarks ()
 blows out all atomic bookmarks
bool hasAtomBookmark (int mark) const
 queries whether or not any atoms are associated with a bookmark
ATOM_BOOKMARK_MAP * getAtomBookmarks ()
 returns a pointer to all of our atom bookmarks
void setBondBookmark (Bond *bond, int mark)
 associates a Bond pointer with a bookmark
Bond * getBondWithBookmark (int mark)
 returns the first Bond associated with the bookmark provided
Bond * getUniqueBondWithBookmark (int mark)
BOND_PTR_LIST & getAllBondsWithBookmark (int mark)
 returns all bonds associated with the bookmark provided
void clearBondBookmark (int mark)
 removes a bookmark from our collection
void clearBondBookmark (int mark, const Bond *bond)
 removes a particular Bond from the list associated with the bookmark
void clearAllBondBookmarks ()
 blows out all bond bookmarks
bool hasBondBookmark (int mark) const
 queries whether or not any bonds are associated with a bookmark
BOND_BOOKMARK_MAP * getBondBookmarks ()
 returns a pointer to all of our bond bookmarks
const Conformer & getConformer (int id=-1) const
Conformer & getConformer (int id=-1)
void removeConformer (unsigned int id)
 Delete the conformation with the specified ID.
void clearConformers ()
 Clear all the conformations on the molecule.
unsigned int addConformer (Conformer *conf, bool assignId=false)
 Add a new conformation to the molecule.
unsigned int getNumConformers () const
RingInfo * getRingInfo () const
ADJ_ITER_PAIR getAtomNeighbors (Atom const *at) const
 provides access to all neighbors around an Atom
OBOND_ITER_PAIR getAtomBonds (Atom const *at) const
 provides access to all Bond objects connected to an Atom
ATOM_ITER_PAIR getVertices ()
 returns an iterator pair for looping over all Atoms
BOND_ITER_PAIR getEdges ()
 returns an iterator pair for looping over all Bonds
ATOM_ITER_PAIR getVertices () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
BOND_ITER_PAIR getEdges () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
MolGraph const & getTopology () const
 brief returns a pointer to our underlying BGL object
AtomIterator beginAtoms ()
 get an AtomIterator pointing at our first Atom
ConstAtomIterator beginAtoms () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
AtomIterator endAtoms ()
 get an AtomIterator pointing at the end of our Atoms
ConstAtomIterator endAtoms () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
BondIterator beginBonds ()
 get a BondIterator pointing at our first Bond
ConstBondIterator beginBonds () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
BondIterator endBonds ()
 get a BondIterator pointing at the end of our Bonds
ConstBondIterator endBonds () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
AromaticAtomIterator beginAromaticAtoms ()
 get an AtomIterator pointing at our first aromatic Atom
ConstAromaticAtomIterator beginAromaticAtoms () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
AromaticAtomIterator endAromaticAtoms ()
 get an AtomIterator pointing at the end of our Atoms
ConstAromaticAtomIterator endAromaticAtoms () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
HeteroatomIterator beginHeteros ()
 get an AtomIterator pointing at our first hetero Atom
ConstHeteroatomIterator beginHeteros () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
HeteroatomIterator endHeteros ()
 get an AtomIterator pointing at the end of our Atoms
ConstHeteroatomIterator endHeteros () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool hasQuery () const
 if the Mol has any Query atoms or bonds
QueryAtomIterator beginQueryAtoms (Atom const *query)
 get an AtomIterator pointing at our first Atom that matches query
ConstQueryAtomIterator beginQueryAtoms (Atom const *query) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
QueryAtomIterator endQueryAtoms ()
 get an AtomIterator pointing at the end of our Atoms
ConstQueryAtomIterator endQueryAtoms () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
MatchingAtomIterator beginMatchingAtoms (bool(*query)(Atom *))
 get an AtomIterator pointing at our first Atom that matches query
ConstMatchingAtomIterator beginMatchingAtoms (bool(*query)(const Atom *)) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
MatchingAtomIterator endMatchingAtoms ()
 get an AtomIterator pointing at the end of our Atoms
ConstMatchingAtomIterator endMatchingAtoms () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
ConformerIterator beginConformers ()
ConformerIterator endConformers ()
ConstConformerIterator beginConformers () const
ConstConformerIterator endConformers () const
void setName (const std::string &name) const
 sets the molecule name/title; equivalent to setting the _Name property
std::string getName () const
void clearComputedProps (bool includeRings=true) const
 clears all of our computed properties
void updatePropertyCache (bool strict=true)
 calculates any of our lazy properties
bool needsUpdatePropertyCache () const
void clearPropertyCache ()
void debugMol (std::ostream &str) const
Public Member Functions inherited from RDKit::RDProps
 RDProps ()
 RDProps (const RDProps &rhs)
RDProps & operator= (const RDProps &rhs)
 RDProps (RDProps &&o) noexcept=default
RDProps & operator= (RDProps &&rhs) noexcept=default
void clear ()
const Dict & getDict () const
 gets the underlying Dictionary
Dict & getDict ()
STR_VECT getPropList (bool includePrivate=true, bool includeComputed=true) const
 returns a list with the names of our properties
template<typename T>
void setProp (const std::string_view key, T val, bool computed=false) const
 sets a property value
template<typename T>
void getProp (const std::string_view key, T &res) const
 allows retrieval of a particular property value
template<typename T>
T getProp (const std::string_view key) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<typename T>
bool getPropIfPresent (const std::string_view key, T &res) const
bool hasProp (const std::string_view key) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void clearProp (const std::string_view key) const
 clears the value of a property
void clearComputedProps () const
 clears all of our computed properties
void updateProps (const RDProps &source, bool preserveExisting=false)
 update the properties from another

Additional Inherited Members

Protected Attributes inherited from RDKit::ROMol
unsigned int numBonds {0}
Protected Attributes inherited from RDKit::RDProps
Dict d_props

Detailed Description

Definition at line 23 of file MacroMol.h.

Constructor & Destructor Documentation

◆ MacroMol() [1/4]

RDKit::MacroMol::MacroMol ( )

Constructs a MacroMol with an empty local template library.

Referenced by MacroMol(), MacroMol(), operator=(), and operator=().

◆ MacroMol() [2/4]

RDKit::MacroMol::MacroMol ( std::unique_ptr< MacroMolTemplateLibrary > localTemplateLibrary)
explicit

Constructs a MacroMol that takes ownership of a local template library.

Parameters
localTemplateLibrarythe non-null library to take ownership of

◆ MacroMol() [3/4]

RDKit::MacroMol::MacroMol ( const MacroMol & other)

References MacroMol().

◆ MacroMol() [4/4]

RDKit::MacroMol::MacroMol ( MacroMol && other)
defaultnoexcept

References MacroMol().

Member Function Documentation

◆ addAtomToMacroAtomBond()

unsigned int RDKit::MacroMol::addAtomToMacroAtomBond ( unsigned int beginAtomIdx,
unsigned int endMacroAtomIdx,
int endAttachPt,
Bond::BondType bondType = Bond::BondType::SINGLE )

Adds a bond from a regular atom to a macro atom.

The graph bond's bond type is unspecified; use MacroBondInfo for the macro bond type.

Parameters
beginAtomIdxindex of the regular atom where the bond begins
endMacroAtomIdxindex of the macro atom where the bond ends
endAttachPtthe attachment point on the end (macro) atom
bondTypethe type of the bond
Returns
the new number of bonds

References RDKit::Bond::SINGLE.

◆ addBond() [1/3]

unsigned int RDKit::MacroMol::addBond ( Atom * beginAtom,
Atom * endAtom,
Bond::BondType bondType = Bond::SINGLE )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References RDKit::Bond::SINGLE.

◆ addBond() [2/3]

unsigned int RDKit::MacroMol::addBond ( Bond * bond,
bool takeOwnership = false )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References RDKit::Bond::SINGLE.

◆ addBond() [3/3]

unsigned int RDKit::MacroMol::addBond ( unsigned int beginAtomIdx,
unsigned int endAtomIdx,
Bond::BondType bondType = Bond::SINGLE )

Adds a bond between two regular atoms.

Note: neither atom may be a macro atom; use addMacroBond(), addAtomToMacroAtomBond(), or addMacroAtomToAtomBond() for bonds involving macro atoms.

Parameters
beginAtomIdxindex of the atom where the bond begins
endAtomIdxindex of the atom where the bond ends
bondTypethe type of the bond
Returns
the new number of bonds

References RDKit::Bond::SINGLE.

◆ addMacroAtom()

unsigned int RDKit::MacroMol::addMacroAtom ( std::string symbol,
MonomerClass monomerClass )

Adds a new macro atom to the molecule.

Parameters
symbolthe symbol (dummy label) used to identify the monomer
monomerClassthe class of monomer the macro atom represents
Returns
the index of the newly added atom

References symbol.

◆ addMacroAtomToAtomBond()

unsigned int RDKit::MacroMol::addMacroAtomToAtomBond ( unsigned int beginMacroAtomIdx,
unsigned int endAtomIdx,
int beginAttachPt,
Bond::BondType bondType = Bond::BondType::SINGLE )

Adds a bond from a macro atom to a regular atom.

The graph bond's bond type is unspecified; use MacroBondInfo for the macro bond type.

Parameters
beginMacroAtomIdxindex of the macro atom where the bond begins
endAtomIdxindex of the regular atom where the bond ends
beginAttachPtthe attachment point on the begin (macro) atom
bondTypethe type of the bond
Returns
the new number of bonds

References RDKit::Bond::SINGLE.

◆ addMacroBond()

unsigned int RDKit::MacroMol::addMacroBond ( unsigned int beginAtomIdx,
unsigned int endAtomIdx,
int beginAttachPt,
int endAttachPt,
Bond::BondType bondType = Bond::SINGLE )

Adds a bond between two macro atoms.

Both atoms must be macro atoms. The graph bond's bond type is unspecified; use MacroBondInfo for the macro bond type.

Parameters
beginAtomIdxindex of the atom where the bond begins
endAtomIdxindex of the atom where the bond ends
beginAttachPtthe attachment point on the begin (macro) atom
endAttachPtthe attachment point on the end (macro) atom
bondTypethe type of the bond
Returns
the new number of bonds

References RDKit::Bond::SINGLE.

◆ checkLocalTemplateReferences()

bool RDKit::MacroMol::checkLocalTemplateReferences ( ) const

Checks that every macro atom resolves in the local template library.

Macro atoms are looked up by monomer class and symbol, then by monomer class and template name. Ordinary atoms are ignored.

◆ getLocalTemplateLibrary() [1/2]

MacroMolTemplateLibrary & RDKit::MacroMol::getLocalTemplateLibrary ( )

Returns this molecule's local template library.

◆ getLocalTemplateLibrary() [2/2]

const MacroMolTemplateLibrary & RDKit::MacroMol::getLocalTemplateLibrary ( ) const

Returns this molecule's local template library.

◆ operator=() [1/2]

MacroMol & RDKit::MacroMol::operator= ( const MacroMol & other)

References MacroMol().

◆ operator=() [2/2]

MacroMol & RDKit::MacroMol::operator= ( MacroMol && other)
defaultnoexcept

References MacroMol().

◆ setLocalTemplateLibrary()

void RDKit::MacroMol::setLocalTemplateLibrary ( std::unique_ptr< MacroMolTemplateLibrary > newTemplateLibrary)

Replaces the local template library and takes ownership of it.

Parameters
newTemplateLibrarythe non-null library to take ownership of

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