RDCode: RingInfo.h Source File

# RingInfo.h

Go to the documentation of this file.

    00001 //
    00002 //  Copyright (C) 2004-2006 Rational Discovery LLC
    00003 //
    00004 //   @@ All Rights Reserved  @@
    00005 //
    00006 #ifndef _RD_RINGINFO_H
    00007 #define _RD_RINGINFO_H
    00008
    00009 #include <map>
    00010 #include <vector>
    00011
    00012 namespace RDKit {
    00013   //! A class to store information about a molecule's rings
    00014   /*!
    00015
    00016    */
    00017   class RingInfo {
    00018     friend class MolPickler;
    00019   public:
    00020     typedef std::vector<int> MemberType;
    00021     typedef std::vector<MemberType > DataType;
    00022     typedef std::vector<int> INT_VECT;
    00023     typedef std::vector< INT_VECT > VECT_INT_VECT;
    00024
    00025     RingInfo() : df_init(false) {};
    00026     RingInfo(const RingInfo &other) : df_init(other.df_init),
    00027                                       d_atomMembers(other.d_atomMembers),
    00028                                       d_bondMembers(other.d_bondMembers),
    00029                                       d_atomRings(other.d_atomRings),
    00030                                       d_bondRings(other.d_bondRings) {};
    00031
    00032     //! checks to see if we've been properly initialized
    00033     bool isInitialized() const { return df_init; };
    00034     //! does initialization
    00035     void initialize();
    00036
    00037     //! blows out all current data and de-initializes
    00038     void reset();
    00039
    00040     //! adds a ring to our data
    00041     /*!
    00042       \param atomIndices the integer indices of the atoms involved in the ring
    00043       \param bondIndices the integer indices of the bonds involved in the ring,
    00044         this must be the same size as \c atomIndices.
    00045
    00046       \return the number of rings
    00047
    00048       <b>Notes:</b>
    00049         - the object must be initialized before calling this
    00050
    00051     */
    00052     unsigned int addRing(const INT_VECT &atomIndices,const INT_VECT &bondIndices);
    00053
    00054
    00055     //! \name Atom information
    00056     //@{
    00057
    00058     //! returns whether or not the atom with index \c idx is in a \c size - ring.
    00059     /*!
    00060       <b>Notes:</b>
    00061         - the object must be initialized before calling this
    00062     */
    00063     bool isAtomInRingOfSize(unsigned int idx,unsigned int size) const;
    00064     //! returns the number of rings atom \c idx is involved in
    00065     /*!
    00066       <b>Notes:</b>
    00067         - the object must be initialized before calling this
    00068     */
    00069     unsigned int numAtomRings(unsigned int idx) const;
    00070     //! returns the size of the smallest ring atom \c idx is involved in
    00071     /*!
    00072       <b>Notes:</b>
    00073         - the object must be initialized before calling this
    00074     */
    00075     unsigned int minAtomRingSize(unsigned int idx) const;
    00076
    00077     //! returns our \c atom-rings vectors
    00078     /*!
    00079       <b>Notes:</b>
    00080         - the object must be initialized before calling this
    00081     */
    00082     const VECT_INT_VECT &atomRings() const { return d_atomRings; };
    00083
    00084     //@}
    00085
    00086     //! \name Bond information
    00087     //@{
    00088
    00089     //! returns whether or not the bond with index \c idx is in a \c size - ring.
    00090     /*!
    00091       <b>Notes:</b>
    00092         - the object must be initialized before calling this
    00093     */
    00094     bool isBondInRingOfSize(unsigned int idx,unsigned int size) const;
    00095     //! returns the number of rings bond \c idx is involved in
    00096     /*!
    00097       <b>Notes:</b>
    00098         - the object must be initialized before calling this
    00099     */
    00100     unsigned int numBondRings(unsigned int idx) const;
    00101     //! returns the size of the smallest ring bond \c idx is involved in
    00102     /*!
    00103       <b>Notes:</b>
    00104         - the object must be initialized before calling this
    00105     */
    00106     unsigned int minBondRingSize(unsigned int idx) const;
    00107
    00108     //! returns the total number of rings
    00109     /*!
    00110       <b>Notes:</b>
    00111         - the object must be initialized before calling this
    00112     */
    00113     unsigned int numRings() const;
    00114
    00115     //! returns our \c bond-rings vectors
    00116     /*!
    00117       <b>Notes:</b>
    00118         - the object must be initialized before calling this
    00119     */
    00120     const VECT_INT_VECT &bondRings() const { return d_bondRings; };
    00121
    00122     //@}
    00123
    00124   private:
    00125     //! pre-allocates some memory to save time later
    00126     void preallocate(unsigned int numAtoms,unsigned int numBonds);
    00127
    00128     bool df_init;
    00129     DataType d_atomMembers,d_bondMembers;
    00130     VECT_INT_VECT d_atomRings,d_bondRings;
    00131   };
    00132 }
    00133
    00134 #endif