RDCode: RDKit::RWMol Class Reference

# RDKit::RWMol Class Reference

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

`#include <RWMol.h>`

Inheritance diagram for RDKit::RWMol:

List of all members.

## Public Member Functions
| RWMol ()
| RWMol (const ROMol &other, bool quickCopy=false)
| copy constructor with a twist
void | insertMol (const ROMol &other)
| insert the atoms and bonds from `other` into this molecule
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
unsigned int | addAtom (ATOM_SPTR atom, bool updateLabel=true)
| adds an Atom to our collection
void | replaceAtom (unsigned int idx, Atom *atom, bool updateLabel=false)
| replaces a particular Atom
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)
void | removeAtom (unsigned int idx)
| removes an Atom from the molecule
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
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
unsigned int | addBond (BOND_SPTR bsp)
| 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

## Detailed Description

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

See documentation for ROMol for general remarks

Definition at line 25 of file RWMol.h.

## Constructor & Destructor Documentation

RDKit::RWMol::RWMol | ( |  | ) | `[inline]`

Definition at line 28 of file RWMol.h.

RDKit::RWMol::RWMol | ( | const ROMol & | other,
|  | bool | quickCopy = `false` |
| ) |  |  | `[inline]`

copy constructor with a twist

Parameters:

  | other | the 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).

Definition at line 37 of file RWMol.h.

## Member Function Documentation

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

insert the atoms and bonds from `other` into this molecule

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 RDKit::SLNParse::startMol().

unsigned int RDKit::RWMol::addAtom | ( | Atom * | atom,
|  | bool | updateLabel = `true`,
|  | bool | takeOwnership = `false` |
| ) |  |  | `[inline]`

adds an Atom to our collection

Parameters:

  | atom | pointer 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

Reimplemented from RDKit::ROMol.

Definition at line 67 of file RWMol.h.

unsigned int RDKit::RWMol::addAtom | ( | ATOM_SPTR | atom,
|  | bool | updateLabel = `true` |
| ) |  |  | `[inline]`

adds an Atom to our collection

Parameters:

  | atom | pointer 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.

Reimplemented from RDKit::ROMol.

Definition at line 84 of file RWMol.h.

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

replaces a particular Atom

Parameters:

  | idx | the index of the Atom to replace
  | atom | the new atom, which will be copied.
  | updateLabel | (optional) if this is true, the new Atom will be our `activeAtom`

Atom* RDKit::RWMol::getLastAtom | ( |  | ) | `[inline]`

returns a pointer to the highest-numbered Atom

Definition at line 98 of file RWMol.h.

References RDKit::ROMol::getAtomWithIdx(), and RDKit::ROMol::getNumAtoms().

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.

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

sets our `activeAtom`

void RDKit::RWMol::setActiveAtom | ( | unsigned int | idx | ) |

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

removes an Atom from the molecule

void RDKit::RWMol::removeAtom | ( | Atom * | atom | ) |

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 RDKit::SLNParse::addBondToMol(), and RDKit::SLNParse::startMol().

unsigned int RDKit::RWMol::addBond | ( | ATOM_SPTR | beginAtom,
|  | ATOM_SPTR | endAtom,
|  | Bond::BondType | order = `Bond::UNSPECIFIED` |
| ) |  |  |

unsigned int RDKit::RWMol::addBond | ( | Atom * | beginAtom,
|  | Atom * | endAtom,
|  | Bond::BondType | order = `Bond::UNSPECIFIED` |
| ) |  |  |

unsigned int RDKit::RWMol::addBond | ( | Bond * | bond,
|  | bool | takeOwnership = `false` |
| ) |  |  | `[inline]`

adds a Bond to our collection

Parameters:

  | bond | pointer 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

Reimplemented from RDKit::ROMol.

Definition at line 142 of file RWMol.h.

unsigned int RDKit::RWMol::addBond | ( | BOND_SPTR | bsp | ) | `[inline]`

adds a Bond to our collection

Parameters:

  | bond | 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.

Reimplemented from RDKit::ROMol.

Definition at line 154 of file RWMol.h.

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.

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

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

removes a bond from the molecule

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

- RWMol.h