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