RDKit: RingInfo.h Source File

| RDKit Open-source cheminformatics and machine learning.

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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