RDKit
Open-source cheminformatics and machine learning.
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 More...
 
RWMoloperator= (const RWMol &)
 
void insertMol (const ROMol &other)
 insert the atoms and bonds from other into this molecule More...
 
void clear ()
 removes all atoms, bonds, properties, bookmarks, etc. More...
 
Atoms
unsigned int addAtom (bool updateLabel=true)
 adds an empty Atom to our collection More...
 
unsigned int addAtom (Atom *atom, bool updateLabel=true, bool takeOwnership=false)
 adds an Atom to our collection More...
 
unsigned int addAtom (ATOM_SPTR atom, bool updateLabel=true)
 adds an Atom to our collection More...
 
void replaceAtom (unsigned int idx, Atom *atom, bool updateLabel=false)
 replaces a particular Atom More...
 
AtomgetLastAtom ()
 returns a pointer to the highest-numbered Atom More...
 
AtomgetActiveAtom ()
 returns a pointer to the "active" Atom More...
 
void setActiveAtom (Atom *atom)
 sets our activeAtom More...
 
void setActiveAtom (unsigned int idx)
 
void removeAtom (unsigned int idx)
 removes an Atom from the molecule More...
 
void removeAtom (Atom *atom)
 
Bonds
unsigned int addBond (unsigned int beginAtomIdx, unsigned int endAtomIdx, Bond::BondType order=Bond::UNSPECIFIED)
 adds a Bond between the indicated Atoms More...
 
unsigned int addBond (ATOM_SPTR beginAtom, ATOM_SPTR endAtom, Bond::BondType order=Bond::UNSPECIFIED)
 
unsigned int addBond (Atom *beginAtom, Atom *endAtom, Bond::BondType order=Bond::UNSPECIFIED)
 
unsigned int addBond (Bond *bond, bool takeOwnership=false)
 adds a Bond to our collection More...
 
unsigned int addBond (BOND_SPTR bsp)
 adds a Bond to our collection More...
 
BondcreatePartialBond (unsigned int beginAtomIdx, Bond::BondType order=Bond::UNSPECIFIED)
 starts a Bond and sets its beginAtomIdx More...
 
unsigned int finishPartialBond (unsigned int endAtomIdx, int bondBookmark, Bond::BondType order=Bond::UNSPECIFIED)
 finishes a partially constructed bond More...
 
void removeBond (unsigned int beginAtomIdx, unsigned int endAtomIdx)
 removes a bond from the molecule More...
 
void replaceBond (unsigned int idx, Bond *bond)
 replaces a particular Bond More...
 
- Public Member Functions inherited from RDKit::ROMol
 ROMol ()
 
 ROMol (const ROMol &other, bool quickCopy=false, int confId=-1)
 copy constructor with a twist More...
 
 ROMol (const std::string &binStr)
 construct a molecule from a pickle string More...
 
virtual ~ROMol ()
 
ATOM_SPTR operator[] (const vertex_descriptor &v)
 
const ATOM_SPTR operator[] (const vertex_descriptor &v) const
 
BOND_SPTR operator[] (const edge_descriptor &e)
 
const BOND_SPTR operator[] (const edge_descriptor &e) const
 
unsigned int getNumAtoms (bool onlyExplicit=1) const
 returns our number of atoms More...
 
unsigned int getNumHeavyAtoms () const
 returns our number of heavy atoms (atomic number > 1) More...
 
AtomgetAtomWithIdx (unsigned int idx)
 returns a pointer to a particular Atom More...
 
const AtomgetAtomWithIdx (unsigned int idx) const
 
template<class U >
AtomgetAtomWithIdx (const U idx)
 
template<class U >
const AtomgetAtomWithIdx (const U idx) const
 
unsigned int getAtomDegree (const Atom *at) const
 returns the degree (number of neighbors) of an Atom in the graph More...
 
unsigned int getAtomDegree (ATOM_SPTR at) const
 
unsigned int getNumBonds (bool onlyHeavy=1) const
 returns our number of Bonds More...
 
BondgetBondWithIdx (unsigned int idx)
 returns a pointer to a particular Bond More...
 
const BondgetBondWithIdx (unsigned int idx) const
 
template<class U >
BondgetBondWithIdx (const U idx)
 
template<class U >
const BondgetBondWithIdx (const U idx) const
 
BondgetBondBetweenAtoms (unsigned int idx1, unsigned int idx2)
 returns a pointer to the bond between two atoms, Null on failure More...
 
const BondgetBondBetweenAtoms (unsigned int idx1, unsigned int idx2) const
 
template<class U , class V >
BondgetBondBetweenAtoms (const U idx1, const V idx2)
 
template<class U , class V >
const BondgetBondBetweenAtoms (const U idx1, const V idx2) const
 
void setAtomBookmark (ATOM_SPTR at, int mark)
 associates an Atom pointer with a bookmark More...
 
void setAtomBookmark (Atom *at, int mark)
 
void replaceAtomBookmark (ATOM_SPTR at, int mark)
 associates an Atom pointer with a bookmark More...
 
void replaceAtomBookmark (Atom *at, int mark)
 
AtomgetAtomWithBookmark (int mark)
 returns the first Atom associated with the bookmark provided More...
 
ATOM_PTR_LIST & getAllAtomsWithBookmark (int mark)
 returns all Atoms associated with the bookmark provided More...
 
void clearAtomBookmark (const int mark)
 removes a bookmark from our collection More...
 
void clearAtomBookmark (const int mark, const Atom *atom)
 removes a particular Atom from the list associated with the bookmark More...
 
void clearAtomBookmark (const int mark, ATOM_SPTR atom)
 
void clearAllAtomBookmarks ()
 blows out all atomic bookmarks More...
 
bool hasAtomBookmark (int mark) const
 queries whether or not any atoms are associated with a bookmark More...
 
ATOM_BOOKMARK_MAP * getAtomBookmarks ()
 returns a pointer to all of our atom bookmarks More...
 
void setBondBookmark (BOND_SPTR bond, int mark)
 associates a Bond pointer with a bookmark More...
 
void setBondBookmark (Bond *bond, int mark)
 
BondgetBondWithBookmark (int mark)
 returns the first Bond associated with the bookmark provided More...
 
BOND_PTR_LIST & getAllBondsWithBookmark (int mark)
 returns all bonds associated with the bookmark provided More...
 
void clearBondBookmark (int mark)
 removes a bookmark from our collection More...
 
void clearBondBookmark (int mark, const Bond *bond)
 removes a particular Bond from the list associated with the bookmark More...
 
void clearBondBookmark (int mark, BOND_SPTR bond)
 
void clearAllBondBookmarks ()
 blows out all bond bookmarks More...
 
bool hasBondBookmark (int mark) const
 queries whether or not any bonds are associated with a bookmark More...
 
BOND_BOOKMARK_MAP * getBondBookmarks ()
 returns a pointer to all of our bond bookmarks More...
 
const ConformergetConformer (int id=-1) const
 
ConformergetConformer (int id=-1)
 
void removeConformer (unsigned int id)
 Delete the conformation with the specified ID. More...
 
void clearConformers ()
 Clear all the conformations on the molecule. More...
 
unsigned int addConformer (Conformer *conf, bool assignId=false)
 Add a new conformation to the molecule. More...
 
unsigned int getNumConformers () const
 
RingInfogetRingInfo () const
 
ADJ_ITER_PAIR getAtomNeighbors (Atom const *at) const
 provides access to all neighbors around an Atom More...
 
ADJ_ITER_PAIR getAtomNeighbors (ATOM_SPTR at) const
 
OBOND_ITER_PAIR getAtomBonds (Atom const *at) const
 provides access to all Bond objects connected to an Atom More...
 
ATOM_ITER_PAIR getVertices ()
 returns an iterator pair for looping over all Atoms More...
 
BOND_ITER_PAIR getEdges ()
 returns an iterator pair for looping over all Bonds More...
 
ATOM_ITER_PAIR getVertices () const
 
BOND_ITER_PAIR getEdges () const
 
MolGraph const & getTopology () const
 brief returns a pointer to our underlying BGL object More...
 
AtomIterator beginAtoms ()
 get an AtomIterator pointing at our first Atom More...
 
ConstAtomIterator beginAtoms () const
 
AtomIterator endAtoms ()
 get an AtomIterator pointing at the end of our Atoms More...
 
ConstAtomIterator endAtoms () const
 
BondIterator beginBonds ()
 get a BondIterator pointing at our first Bond More...
 
ConstBondIterator beginBonds () const
 
BondIterator endBonds ()
 get a BondIterator pointing at the end of our Bonds More...
 
ConstBondIterator endBonds () const
 
AromaticAtomIterator beginAromaticAtoms ()
 get an AtomIterator pointing at our first aromatic Atom More...
 
ConstAromaticAtomIterator beginAromaticAtoms () const
 
AromaticAtomIterator endAromaticAtoms ()
 get an AtomIterator pointing at the end of our Atoms More...
 
ConstAromaticAtomIterator endAromaticAtoms () const
 
HeteroatomIterator beginHeteros ()
 get an AtomIterator pointing at our first hetero Atom More...
 
ConstHeteroatomIterator beginHeteros () const
 
HeteroatomIterator endHeteros ()
 get an AtomIterator pointing at the end of our Atoms More...
 
ConstHeteroatomIterator endHeteros () const
 
QueryAtomIterator beginQueryAtoms (QueryAtom const *query)
 get an AtomIterator pointing at our first Atom that matches query More...
 
ConstQueryAtomIterator beginQueryAtoms (QueryAtom const *) const
 
QueryAtomIterator endQueryAtoms ()
 get an AtomIterator pointing at the end of our Atoms More...
 
ConstQueryAtomIterator endQueryAtoms () const
 
MatchingAtomIterator beginMatchingAtoms (bool(*query)(Atom *))
 get an AtomIterator pointing at our first Atom that matches query More...
 
ConstMatchingAtomIterator beginMatchingAtoms (bool(*query)(const Atom *)) const
 
MatchingAtomIterator endMatchingAtoms ()
 get an AtomIterator pointing at the end of our Atoms More...
 
ConstMatchingAtomIterator endMatchingAtoms () const
 
ConformerIterator beginConformers ()
 
ConformerIterator endConformers ()
 
ConstConformerIterator beginConformers () const
 
ConstConformerIterator endConformers () const
 
void clearComputedProps (bool includeRings=true) const
 clears all of our computed properties More...
 
void updatePropertyCache (bool strict=true)
 calculates any of our lazy properties More...
 
bool needsUpdatePropertyCache () const
 
void debugMol (std::ostream &str) const
 sends some debugging info to a stream More...
 
- Public Member Functions inherited from RDKit::RDProps
 RDProps ()
 
 RDProps (const RDProps &rhs)
 
RDPropsoperator= (const RDProps &rhs)
 
void clear ()
 
const DictgetDict () const
 gets the underlying Dictionary More...
 
DictgetDict ()
 
STR_VECT getPropList (bool includePrivate=true, bool includeComputed=true) const
 returns a list with the names of our properties More...
 
template<typename T >
void setProp (const std::string &key, T val, bool computed=false) const
 sets a property value More...
 
template<typename T >
void getProp (const std::string &key, T &res) const
 allows retrieval of a particular property value More...
 
template<typename T >
getProp (const std::string &key) const
 
template<typename T >
bool getPropIfPresent (const std::string &key, T &res) const
 
bool hasProp (const std::string &key) const
 
void clearProp (const std::string &key) const
 clears the value of a property More...
 
void clearComputedProps () const
 clears all of our computed properties More...
 

Additional Inherited Members

- Protected Attributes inherited from RDKit::ROMol
unsigned int numBonds
 
- Protected Attributes inherited from RDKit::RDProps
Dict dp_props
 

Detailed Description

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

See documentation for ROMol for general remarks

Definition at line 30 of file RWMol.h.

Constructor & Destructor Documentation

RDKit::RWMol::RWMol ( )
inline

Definition at line 32 of file RWMol.h.

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 44 of file RWMol.h.

References addAtom(), insertMol(), and operator=().

Member Function Documentation

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 new number of atoms

Referenced by RWMol(), and RDKit::SLNParse::startMol().

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 new number of atoms

Definition at line 77 of file RWMol.h.

unsigned int RDKit::RWMol::addAtom ( ATOM_SPTR  atom,
bool  updateLabel = true 
)
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
Returns
the new number of atoms

Note: since this is using a smart pointer, we don't need to worry about issues of ownership.

Definition at line 96 of file RWMol.h.

References replaceAtom().

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

Referenced by getLastAtom(), and RDKit::SLNParse::startMol().

unsigned int RDKit::RWMol::addBond ( ATOM_SPTR  beginAtom,
ATOM_SPTR  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 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.

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 153 of file RWMol.h.

unsigned int RDKit::RWMol::addBond ( BOND_SPTR  bsp)
inline

adds a Bond to our collection

Parameters
bspsmart pointer to the Bond to add
Returns
the new number of bonds

Note: since this is using a smart pointer, we don't need to worry about issues of ownership.

Definition at line 166 of file RWMol.h.

References createPartialBond(), finishPartialBond(), removeBond(), replaceBond(), and RDKit::Bond::UNSPECIFIED.

void RDKit::RWMol::clear ( )
inline

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

Definition at line 221 of file RWMol.h.

References RDKit::detail::computedPropName, RDKit::RDProps::dp_props, RDKit::Dict::reset(), and RDKit::Dict::setVal().

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.

Referenced by addBond().

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

Referenced by addBond().

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.

Referenced by getLastAtom().

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

returns a pointer to the highest-numbered Atom

Definition at line 110 of file RWMol.h.

References addBond(), getActiveAtom(), RDKit::ROMol::getAtomWithIdx(), RDKit::ROMol::getNumAtoms(), removeAtom(), setActiveAtom(), and RDKit::Bond::UNSPECIFIED.

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

insert the atoms and bonds from other into this molecule

Referenced by RWMol().

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

Referenced by RWMol().

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

removes an Atom from the molecule

Referenced by getLastAtom().

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.

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

removes a bond from the molecule

Referenced by addBond().

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

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

Referenced by addAtom().

void RDKit::RWMol::replaceBond ( unsigned int  idx,
Bond bond 
)

replaces a particular Bond

Parameters
idxthe index of the Bond to replace
bondthe new bond, which will be copied.

Referenced by addBond().

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

sets our activeAtom

Referenced by getLastAtom().

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: