RDCode: RingInfo.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories

# 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   public:
    00019     typedef std::vector<int> MemberType;
    00020     typedef std::vector<MemberType > DataType;
    00021     typedef std::vector<int> INT_VECT;
    00022     typedef std::vector< INT_VECT > VECT_INT_VECT;
    00023
    00024     RingInfo() : df_init(false) {};
    00025     RingInfo(const RingInfo &other) : df_init(other.df_init),
    00026                                       d_atomMembers(other.d_atomMembers),
    00027                                       d_bondMembers(other.d_bondMembers),
    00028                                       d_atomRings(other.d_atomRings),
    00029                                       d_bondRings(other.d_bondRings) {};
    00030
    00031
    00032     //! returns whether or not the atom with index \c idx is in a \c size - ring.
    00033     /*!
    00034       <b>Notes:</b>
    00035         - the object must be initialized before calling this
    00036     */
    00037     bool isAtomInRingOfSize(unsigned int idx,unsigned int size) const;
    00038     //! returns the number of rings atom \c idx is involved in
    00039     /*!
    00040       <b>Notes:</b>
    00041         - the object must be initialized before calling this
    00042     */
    00043     unsigned int numAtomRings(unsigned int idx) const;
    00044     //! returns the size of the smallest ring atom \c idx is involved in
    00045     /*!
    00046       <b>Notes:</b>
    00047         - the object must be initialized before calling this
    00048     */
    00049     unsigned int minAtomRingSize(unsigned int idx) const;
    00050
    00051
    00052     //! returns whether or not the bond with index \c idx is in a \c size - ring.
    00053     /*!
    00054       <b>Notes:</b>
    00055         - the object must be initialized before calling this
    00056     */
    00057     bool isBondInRingOfSize(unsigned int idx,unsigned int size) const;
    00058     //! returns the number of rings bond \c idx is involved in
    00059     /*!
    00060       <b>Notes:</b>
    00061         - the object must be initialized before calling this
    00062     */
    00063     unsigned int numBondRings(unsigned int idx) const;
    00064     //! returns the size of the smallest ring bond \c idx is involved in
    00065     /*!
    00066       <b>Notes:</b>
    00067         - the object must be initialized before calling this
    00068     */
    00069     unsigned int minBondRingSize(unsigned int idx) const;
    00070
    00071     //! returns the total number of rings
    00072     /*!
    00073       <b>Notes:</b>
    00074         - the object must be initialized before calling this
    00075     */
    00076     unsigned int numRings() const;
    00077
    00078     //! returns our \c atom-rings vectors
    00079     /*!
    00080       <b>Notes:</b>
    00081         - the object must be initialized before calling this
    00082     */
    00083     const VECT_INT_VECT &atomRings() const { return d_atomRings; };
    00084     //! returns our \c bond-rings vectors
    00085     /*!
    00086       <b>Notes:</b>
    00087         - the object must be initialized before calling this
    00088     */
    00089     const VECT_INT_VECT &bondRings() const { return d_bondRings; };
    00090
    00091     //! checks to see if we've been properly initialized
    00092     bool isInitialized() const { return df_init; };
    00093     //! does initialization
    00094     void initialize();
    00095
    00096     //! adds a ring to our data
    00097     /*!
    00098       \param atomIndices the integer indices of the atoms involved in the ring
    00099       \param bondIndices the integer indices of the bonds involved in the ring,
    00100         this must be the same size as \c atomIndices.
    00101
    00102       \return the number of rings
    00103
    00104       <b>Notes:</b>
    00105         - the object must be initialized before calling this
    00106
    00107     */
    00108     unsigned int addRing(const INT_VECT &atomIndices,const INT_VECT &bondIndices);
    00109
    00110     //! blows out all current data and de-initializes
    00111     void reset();
    00112
    00113     //! pre-allocates some memory to save time later
    00114     void preallocate(unsigned int numAtoms,unsigned int numBonds);
    00115
    00116   private:
    00117     bool df_init;
    00118     DataType d_atomMembers,d_bondMembers;
    00119     VECT_INT_VECT d_atomRings,d_bondRings;
    00120   };
    00121 }
    00122
    00123 #endif