RDCode: RWMol.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories

# RWMol.h

Go to the documentation of this file.

    00001 //
    00002 //  Copyright (C) 2003-2006 Greg Landrum and Rational Discovery LLC
    00003 //
    00004 //   @@ All Rights Reserved  @@
    00005 //
    00006
    00007 #ifndef __RD_RWMOL_H__
    00008 #define __RD_RWMOL_H__
    00009
    00010 // our stuff
    00011 #include "ROMol.h"
    00012
    00013 namespace RDKit{
    00014
    00015   //! RWMol is a molecule class that is intended to be edited
    00016   /*!
    00017       See documentation for ROMol for general remarks
    00018
    00019    */
    00020   class RWMol : public ROMol {
    00021   public:
    00022
    00023     using ROMol::addAtom;
    00024     using ROMol::addBond;
    00025
    00026     RWMol() { d_partialBonds.clear(); }
    00027
    00028     //! copy constructor with a twist
    00029     /*!
    00030       \param other     the molecule to be copied
    00031       \param quickCopy (optional) if this is true, the resulting ROMol will not
    00032            copy any of the properties or bookmarks and conformers from \c other.  This can
    00033            make the copy substantially faster (thus the name).
    00034     */
    00035     RWMol(const ROMol &other,bool quickCopy=false) {d_partialBonds.clear(); initFromOther(other,quickCopy);};
    00036
    00037
    00038     //! insert the atoms and bonds from \c other into this molecule
    00039     void insertMol( const ROMol &other);
    00040
    00041
    00042     // --------------------------------------------
    00043     //
    00044     //  Atoms
    00045     //
    00046     // --------------------------------------------
    00047
    00048     //! adds an empty Atom to our collection
    00049     /*!
    00050       \param updateLabel   (optional) if this is true, the new Atom will be
    00051                            our \c activeAtom
    00052
    00053       \return the new number of atoms
    00054
    00055     */
    00056     unsigned int addAtom(bool updateLabel=true);
    00057     //! replaces a particular Atom
    00058     /*!
    00059       \param idx          the index of the Atom to replace
    00060       \param atom         the new atom, which will be copied.
    00061       \param updateLabel   (optional) if this is true, the new Atom will be
    00062                            our \c activeAtom
    00063
    00064     */
    00065     void replaceAtom(unsigned int idx,Atom *atom,bool updateLabel=false);
    00066     //! returns a pointer to the highest-numbered Atom
    00067     GRAPH_NODE_TYPE getLastAtom() { return getAtomWithIdx(getNumAtoms()-1); };
    00068     //! returns a pointer to the "active" Atom
    00069     /*!
    00070        If we have an \c activeAtom, it will be returned,
    00071        otherwise the results of getLastAtom() will be returned.
    00072      */
    00073     GRAPH_NODE_TYPE getActiveAtom();
    00074     //! sets our \c activeAtom
    00075     void setActiveAtom(Atom *atom);
    00076     //! \overload
    00077     void setActiveAtom(unsigned int idx);
    00078     //! removes an Atom from the molecule
    00079     void removeAtom(unsigned int idx);
    00080     //! \overload
    00081     void removeAtom(Atom *atom);
    00082
    00083
    00084     // --------------------------------------------
    00085     //
    00086     //  Bonds
    00087     //
    00088     // --------------------------------------------
    00089
    00090     //! adds a Bond between the indicated Atoms
    00091     /*!
    00092        \return the number of Bonds
    00093     */
    00094     unsigned int addBond(unsigned int beginAtomIdx,unsigned int endAtomIdx,
    00095                          Bond::BondType order=Bond::UNSPECIFIED);
    00096     //! \overload
    00097     unsigned int addBond(ATOM_SPTR beginAtom,ATOM_SPTR endAtom,
    00098                          Bond::BondType order=Bond::UNSPECIFIED);
    00099     //! \overload
    00100     unsigned int addBond(Atom *beginAtom, Atom *endAtom,
    00101                          Bond::BondType order=Bond::UNSPECIFIED);
    00102
    00103     //! starts a Bond and sets its beginAtomIdx
    00104     /*!
    00105       \return a pointer to the new bond
    00106
    00107       The caller should set a bookmark to the returned Bond in order
    00108       to be able to later complete it:
    00109
    00110       \verbatim
    00111         Bond *pBond = mol->createPartialBond(1);
    00112         mol->setBondBookmark(pBond,666);
    00113         ... do some other stuff ...
    00114         mol->finishPartialBond(2,666,Bond::SINGLE);
    00115         mol->clearBondBookmark(666,pBond);
    00116       \endverbatim
    00117
    00118       or, if we want to set the \c BondType initially:
    00119       \verbatim
    00120         Bond *pBond = mol->createPartialBond(1,Bond::DOUBLE);
    00121         mol->setBondBookmark(pBond,666);
    00122         ... do some other stuff ...
    00123         mol->finishPartialBond(2,666);
    00124         mol->clearBondBookmark(666,pBond);
    00125       \endverbatim
    00126
    00127       the call to finishPartialBond() will take priority if you set the
    00128       \c BondType in both calls.
    00129
    00130     */
    00131     Bond *createPartialBond(unsigned int beginAtomIdx,
    00132                             Bond::BondType order=Bond::UNSPECIFIED);
    00133     //! finishes a partially constructed bond
    00134     /*!
    00135       \return the final number of Bonds
    00136
    00137       See the documentation for createPartialBond() for more details
    00138     */
    00139     unsigned int finishPartialBond(unsigned int endAtomIdx,int bondBookmark,
    00140                                    Bond::BondType order=Bond::UNSPECIFIED);
    00141
    00142     //! removes a bond from the molecule
    00143     void removeBond(unsigned int beginAtomIdx, unsigned int endAtomIdx);
    00144
    00145   private:
    00146     std::vector<BOND_SPTR> d_partialBonds;
    00147     void destroy();
    00148     ROMol &operator=(const ROMol &); // disable assignment
    00149
    00150   };
    00151
    00152   typedef boost::shared_ptr<RWMol>    RWMOL_SPTR;
    00153   typedef std::vector< RWMOL_SPTR > RWMOL_SPTR_VECT;
    00154
    00155 }; // end of RDKit namespace
    00156
    00157 #endif