RDKit
Open-source cheminformatics and machine learning.
RingInfo.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 Rational Discovery LLC
3 //
4 // @@ All Rights Reserved @@
5 // This file is part of the RDKit.
6 // The contents are covered by the terms of the BSD license
7 // which is included in the file license.txt, found at the root
8 // of the RDKit source tree.
9 //
10 #ifndef _RD_RINGINFO_H
11 #define _RD_RINGINFO_H
12 
13 #include <map>
14 #include <vector>
15 
16 namespace RDKit {
17  //! A class to store information about a molecule's rings
18  /*!
19 
20  */
21  class RingInfo {
22  friend class MolPickler;
23  public:
24  typedef std::vector<int> MemberType;
25  typedef std::vector<MemberType > DataType;
26  typedef std::vector<int> INT_VECT;
27  typedef std::vector< INT_VECT > VECT_INT_VECT;
28 
29  RingInfo() : df_init(false) {};
30  RingInfo(const RingInfo &other) : df_init(other.df_init),
31  d_atomMembers(other.d_atomMembers),
32  d_bondMembers(other.d_bondMembers),
33  d_atomRings(other.d_atomRings),
34  d_bondRings(other.d_bondRings) {};
35 
36  //! checks to see if we've been properly initialized
37  bool isInitialized() const { return df_init; };
38  //! does initialization
39  void initialize();
40 
41  //! blows out all current data and de-initializes
42  void reset();
43 
44  //! adds a ring to our data
45  /*!
46  \param atomIndices the integer indices of the atoms involved in the ring
47  \param bondIndices the integer indices of the bonds involved in the ring,
48  this must be the same size as \c atomIndices.
49 
50  \return the number of rings
51 
52  <b>Notes:</b>
53  - the object must be initialized before calling this
54 
55  */
56  unsigned int addRing(const INT_VECT &atomIndices,const INT_VECT &bondIndices);
57 
58 
59  //! \name Atom information
60  //@{
61 
62  //! returns whether or not the atom with index \c idx is in a \c size - ring.
63  /*!
64  <b>Notes:</b>
65  - the object must be initialized before calling this
66  */
67  bool isAtomInRingOfSize(unsigned int idx,unsigned int size) const;
68  //! returns the number of rings atom \c idx is involved in
69  /*!
70  <b>Notes:</b>
71  - the object must be initialized before calling this
72  */
73  unsigned int numAtomRings(unsigned int idx) const;
74  //! returns the size of the smallest ring atom \c idx is involved in
75  /*!
76  <b>Notes:</b>
77  - the object must be initialized before calling this
78  */
79  unsigned int minAtomRingSize(unsigned int idx) const;
80 
81  //! returns our \c atom-rings vectors
82  /*!
83  <b>Notes:</b>
84  - the object must be initialized before calling this
85  */
86  const VECT_INT_VECT &atomRings() const { return d_atomRings; };
87 
88  //@}
89 
90  //! \name Bond information
91  //@{
92 
93  //! returns whether or not the bond with index \c idx is in a \c size - ring.
94  /*!
95  <b>Notes:</b>
96  - the object must be initialized before calling this
97  */
98  bool isBondInRingOfSize(unsigned int idx,unsigned int size) const;
99  //! returns the number of rings bond \c idx is involved in
100  /*!
101  <b>Notes:</b>
102  - the object must be initialized before calling this
103  */
104  unsigned int numBondRings(unsigned int idx) const;
105  //! returns the size of the smallest ring bond \c idx is involved in
106  /*!
107  <b>Notes:</b>
108  - the object must be initialized before calling this
109  */
110  unsigned int minBondRingSize(unsigned int idx) const;
111 
112  //! returns the total number of rings
113  /*!
114  <b>Notes:</b>
115  - the object must be initialized before calling this
116  */
117  unsigned int numRings() const;
118 
119  //! returns our \c bond-rings vectors
120  /*!
121  <b>Notes:</b>
122  - the object must be initialized before calling this
123  */
124  const VECT_INT_VECT &bondRings() const { return d_bondRings; };
125 
126  //@}
127 
128  private:
129  //! pre-allocates some memory to save time later
130  void preallocate(unsigned int numAtoms,unsigned int numBonds);
131 
132  bool df_init;
133  DataType d_atomMembers,d_bondMembers;
134  VECT_INT_VECT d_atomRings,d_bondRings;
135  };
136 }
137 
138 #endif
unsigned int numRings() const
returns the total number of rings
bool isBondInRingOfSize(unsigned int idx, unsigned int size) const
returns whether or not the bond with index idx is in a size - ring.
unsigned int addRing(const INT_VECT &atomIndices, const INT_VECT &bondIndices)
adds a ring to our data
unsigned int minAtomRingSize(unsigned int idx) const
returns the size of the smallest ring atom idx is involved in
void reset()
blows out all current data and de-initializes
unsigned int numAtomRings(unsigned int idx) const
returns the number of rings atom idx is involved in
std::vector< int > MemberType
Definition: RingInfo.h:24
Includes a bunch of functionality for handling Atom and Bond queries.
Definition: Atom.h:28
A class to store information about a molecule&#39;s rings.
Definition: RingInfo.h:21
const VECT_INT_VECT & bondRings() const
returns our bond-rings vectors
Definition: RingInfo.h:124
RingInfo(const RingInfo &other)
Definition: RingInfo.h:30
bool isAtomInRingOfSize(unsigned int idx, unsigned int size) const
returns whether or not the atom with index idx is in a size - ring.
handles pickling (serializing) molecules
Definition: MolPickler.h:46
unsigned int numBondRings(unsigned int idx) const
returns the number of rings bond idx is involved in
std::vector< INT_VECT > VECT_INT_VECT
Definition: RingInfo.h:27
const VECT_INT_VECT & atomRings() const
returns our atom-rings vectors
Definition: RingInfo.h:86
std::vector< int > INT_VECT
Definition: RingInfo.h:26
void initialize()
does initialization
std::vector< MemberType > DataType
Definition: RingInfo.h:25
bool isInitialized() const
checks to see if we&#39;ve been properly initialized
Definition: RingInfo.h:37
unsigned int minBondRingSize(unsigned int idx) const
returns the size of the smallest ring bond idx is involved in