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

RWMol is a molecule class that is intended to be edited. More...

#include <RWMol.h>

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

Public Member Functions

 RWMol ()
 
 RWMol (const ROMol &other, bool quickCopy=false, int confId=-1)
 copy constructor with a twist
 
 RWMol (const RWMol &other)
 
RWMoloperator= (const RWMol &)
 
 RWMol (RWMol &&other) noexcept
 
RWMoloperator= (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 ()
 
Atoms
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
 
AtomgetLastAtom ()
 returns a pointer to the highest-numbered Atom
 
AtomgetActiveAtom ()
 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.
 
Bonds
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
 
BondcreatePartialBond (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 *constatoms () 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)
 
CXXBondIterator< MolGraph, Bond * > bonds ()
 
CXXBondIterator< const MolGraph, Bond *constbonds () 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
 
ROMoloperator= (ROMol &&o) noexcept
 
ROMoloperator= (const ROMol &)=delete
 
virtual ~ROMol ()
 
Atomoperator[] (const vertex_descriptor &v)
 
const Atomoperator[] (const vertex_descriptor &v) const
 
Bondoperator[] (const edge_descriptor &e)
 
const Bondoperator[] (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)
 
AtomgetAtomWithIdx (unsigned int idx)
 returns a pointer to a particular Atom
 
const AtomgetAtomWithIdx (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 >
AtomgetAtomWithIdx (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 AtomgetAtomWithIdx (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
 
BondgetBondWithIdx (unsigned int idx)
 returns a pointer to a particular Bond
 
const BondgetBondWithIdx (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 >
BondgetBondWithIdx (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 BondgetBondWithIdx (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.
 
BondgetBondBetweenAtoms (unsigned int idx1, unsigned int idx2)
 returns a pointer to the bond between two atoms, Null on failure
 
const BondgetBondBetweenAtoms (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 >
BondgetBondBetweenAtoms (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 BondgetBondBetweenAtoms (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
 
AtomgetAtomWithBookmark (int mark)
 returns the first Atom associated with the bookmark provided
 
AtomgetUniqueAtomWithBookmark (int mark)
 
ATOM_PTR_LISTgetAllAtomsWithBookmark (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_MAPgetAtomBookmarks ()
 returns a pointer to all of our atom bookmarks
 
void setBondBookmark (Bond *bond, int mark)
 associates a Bond pointer with a bookmark
 
BondgetBondWithBookmark (int mark)
 returns the first Bond associated with the bookmark provided
 
BondgetUniqueBondWithBookmark (int mark)
 
BOND_PTR_LISTgetAllBondsWithBookmark (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_MAPgetBondBookmarks ()
 returns a pointer to all of our bond bookmarks
 
const ConformergetConformer (int id=-1) const
 
ConformergetConformer (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
 
RingInfogetRingInfo () 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 constgetTopology () 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 (QueryAtom const *query)
 get an AtomIterator pointing at our first Atom that matches query
 
ConstQueryAtomIterator beginQueryAtoms (QueryAtom const *) 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 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 debugMol (std::ostream &str) const
 
- Public Member Functions inherited from RDKit::RDProps
 RDProps ()
 
 RDProps (const RDProps &rhs)
 
RDPropsoperator= (const RDProps &rhs)
 
 RDProps (RDProps &&o) noexcept=default
 
RDPropsoperator= (RDProps &&rhs) noexcept=default
 
void clear ()
 
const DictgetDict () const
 gets the underlying Dictionary
 
DictgetDict ()
 
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 &key, T val, bool computed=false) const
 sets a property value
 
template<typename T >
void getProp (const std::string &key, T &res) const
 allows retrieval of a particular property value
 
template<typename T >
getProp (const std::string &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 &key, T &res) const
 
bool hasProp (const std::string &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 &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

RWMol is a molecule class that is intended to be edited.

See documentation for ROMol for general remarks

Definition at line 32 of file RWMol.h.

Constructor & Destructor Documentation

◆ RWMol() [1/4]

RDKit::RWMol::RWMol ( )
inline

Definition at line 34 of file RWMol.h.

◆ RWMol() [2/4]

RDKit::RWMol::RWMol ( const ROMol other,
bool  quickCopy = false,
int  confId = -1 
)
inline

copy constructor with a twist

Parameters
otherthe molecule to be copied
quickCopy(optional) if this is true, the resulting ROMol will not copy any of the properties or bookmarks and conformers from other. This can make the copy substantially faster (thus the name).
confIdif this is >=0, the resulting ROMol will contain only the specified conformer from other.

Definition at line 45 of file RWMol.h.

◆ RWMol() [3/4]

RDKit::RWMol::RWMol ( const RWMol other)
inline

Definition at line 47 of file RWMol.h.

◆ RWMol() [4/4]

RDKit::RWMol::RWMol ( RWMol &&  other)
inlinenoexcept

Definition at line 49 of file RWMol.h.

Member Function Documentation

◆ addAtom() [1/2]

unsigned int RDKit::RWMol::addAtom ( Atom atom,
bool  updateLabel = true,
bool  takeOwnership = false 
)
inline

adds an Atom to our collection

Parameters
atompointer to the Atom to add
updateLabel(optional) if this is true, the new Atom will be our activeAtom
takeOwnership(optional) if this is true, we take ownership of atom instead of copying it.
Returns
the index of the added atom

Definition at line 82 of file RWMol.h.

◆ addAtom() [2/2]

unsigned int RDKit::RWMol::addAtom ( bool  updateLabel = true)

adds an empty Atom to our collection

Parameters
updateLabel(optional) if this is true, the new Atom will be our activeAtom
Returns
the index of the added atom

◆ addBond() [1/3]

unsigned int RDKit::RWMol::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.

◆ addBond() [2/3]

unsigned int RDKit::RWMol::addBond ( Bond bond,
bool  takeOwnership = false 
)
inline

adds a Bond to our collection

Parameters
bondpointer to the Bond to add
takeOwnership(optional) if this is true, we take ownership of bond instead of copying it.
Returns
the new number of bonds

Definition at line 143 of file RWMol.h.

◆ addBond() [3/3]

unsigned int RDKit::RWMol::addBond ( unsigned int  beginAtomIdx,
unsigned int  endAtomIdx,
Bond::BondType  order = Bond::UNSPECIFIED 
)

adds a Bond between the indicated Atoms

Returns
the number of Bonds

◆ beginBatchEdit()

void RDKit::RWMol::beginBatchEdit ( )

◆ clear()

void RDKit::RWMol::clear ( )
inline

removes all atoms, bonds, properties, bookmarks, etc.

Definition at line 203 of file RWMol.h.

◆ commitBatchEdit()

void RDKit::RWMol::commitBatchEdit ( )

◆ createPartialBond()

Bond * RDKit::RWMol::createPartialBond ( unsigned int  beginAtomIdx,
Bond::BondType  order = Bond::UNSPECIFIED 
)

starts a Bond and sets its beginAtomIdx

Returns
a pointer to the new bond

The caller should set a bookmark to the returned Bond in order to be able to later complete it:

  Bond *pBond = mol->createPartialBond(1);
  mol->setBondBookmark(pBond,666);
  ... do some other stuff ...
  mol->finishPartialBond(2,666,Bond::SINGLE);
  mol->clearBondBookmark(666,pBond);

or, if we want to set the BondType initially:

  Bond *pBond = mol->createPartialBond(1,Bond::DOUBLE);
  mol->setBondBookmark(pBond,666);
  ... do some other stuff ...
  mol->finishPartialBond(2,666);
  mol->clearBondBookmark(666,pBond);

the call to finishPartialBond() will take priority if you set the BondType in both calls.

◆ finishPartialBond()

unsigned int RDKit::RWMol::finishPartialBond ( unsigned int  endAtomIdx,
int  bondBookmark,
Bond::BondType  order = Bond::UNSPECIFIED 
)

finishes a partially constructed bond

Returns
the final number of Bonds

See the documentation for createPartialBond() for more details

◆ getActiveAtom()

Atom * RDKit::RWMol::getActiveAtom ( )

returns a pointer to the "active" Atom

If we have an activeAtom, it will be returned, otherwise the results of getLastAtom() will be returned.

◆ getLastAtom()

Atom * RDKit::RWMol::getLastAtom ( )
inline

returns a pointer to the highest-numbered Atom

Definition at line 101 of file RWMol.h.

◆ insertMol()

void RDKit::RWMol::insertMol ( const ROMol other)

insert the atoms and bonds from other into this molecule

◆ operator=() [1/2]

RWMol & RDKit::RWMol::operator= ( const RWMol )

◆ operator=() [2/2]

RWMol & RDKit::RWMol::operator= ( RWMol &&  other)
inlinenoexcept

Definition at line 50 of file RWMol.h.

◆ removeAtom() [1/3]

void RDKit::RWMol::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.

◆ removeAtom() [2/3]

void RDKit::RWMol::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.

◆ removeAtom() [3/3]

void RDKit::RWMol::removeAtom ( unsigned int  idx)

removes an Atom from the molecule

◆ removeBond()

void RDKit::RWMol::removeBond ( unsigned int  beginAtomIdx,
unsigned int  endAtomIdx 
)

removes a bond from the molecule

◆ replaceAtom()

void RDKit::RWMol::replaceAtom ( unsigned int  idx,
Atom atom,
bool  updateLabel = false,
bool  preserveProps = false 
)

adds an Atom to our collection

replaces a particular Atom

Parameters
idxthe index of the Atom to replace
atomthe new atom, which will be copied.
updateLabel(optional) if this is true, the new Atom will be our activeAtom
preservePropsif true preserve the original atom property data

◆ replaceBond()

void RDKit::RWMol::replaceBond ( unsigned int  idx,
Bond bond,
bool  preserveProps = false,
bool  keepSGroups = true 
)

replaces a particular Bond

Parameters
idxthe index of the Bond to replace
bondthe new bond, which will be copied.
preservePropsif true preserve the original bond property data
keepSGroupsif true, keep Substance groups referencing the bond

◆ rollbackBatchEdit()

void RDKit::RWMol::rollbackBatchEdit ( )
inline

Definition at line 211 of file RWMol.h.

◆ setActiveAtom() [1/2]

void RDKit::RWMol::setActiveAtom ( Atom atom)

sets our activeAtom

◆ setActiveAtom() [2/2]

void RDKit::RWMol::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.


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