ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/openbabel/ring.hpp
Revision: 2440
Committed: Wed Nov 16 19:42:11 2005 UTC (18 years, 7 months ago) by tim
File size: 3406 byte(s)
Log Message:
adding openbabel

File Contents

# Content
1 /**********************************************************************
2 ring.h - Deal with rings, find smallest set of smallest rings (SSSR).
3
4 Copyright (C) 1998-2001 by OpenEye Scientific Software, Inc.
5 Some portions Copyright (C) 2001-2005 by Geoffrey R. Hutchison
6
7 This file is part of the Open Babel project.
8 For more information, see <http://openbabel.sourceforge.net/>
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation version 2 of the License.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 ***********************************************************************/
19
20 #ifndef OB_RING_H
21 #define OB_RING_H
22
23 #include <deque>
24 #include <algorithm>
25
26 namespace OpenBabel
27 {
28
29 class OBMol;
30 class OBAtom;
31 class OBBond;
32
33 //! Internal class for OBRing search algorithms to create a search tree of OBAtom objects
34 class OBAPI OBRTree
35 {
36 OBAtom *_atom; //!< Atom represented by this node in the tree
37 OBRTree *_prv; //!< Previous (parent) entry in an OBRing tree
38 public:
39 OBRTree(OBAtom*,OBRTree*);
40 ~OBRTree() {}
41
42 //! \return the OBAtom::GetIdx() index of the atom in this node
43 int GetAtomIdx();
44 //! Recursively find the root of this tree, building up a vector of OBAtom nodes.
45 void PathToRoot(std::vector<OBNodeBase*>&);
46 };
47
48 // class introduction in ring.cpp
49 class OBAPI OBRing
50 {
51 OBMol *_parent;
52 public:
53 //public data members
54 std::vector<int> _path;
55 OBBitVec _pathset;
56 bool findCenterAndNormal(vector3 & center, vector3 &norm1, vector3 &norm2);
57
58 //constructors
59 OBRing() {}
60 OBRing(std::vector<int>&,int);
61 OBRing(const OBRing &src);
62 OBRing& operator=(const OBRing &src);
63
64 //member functions
65 int Size() const
66 {
67 return(_path.size());
68 }
69 int PathSize() const
70 {
71 return(_path.size());
72 }
73 bool IsMember(OBAtom *a);
74 bool IsMember(OBBond *b);
75 bool IsAromatic();
76 bool IsInRing(int i)
77 {
78 return(_pathset.BitIsOn(i));
79 }
80 void SetParent(OBMol *m)
81 {
82 _parent = m;
83 }
84 OBMol *GetParent()
85 {
86 return(_parent);
87 }
88 };
89
90 bool CompareRingSize(const OBRing *,const OBRing *);
91
92
93 //! Internal class to facilitate OBMol::FindSSSR()
94 class OBAPI OBRingSearch
95 {
96 std::vector<OBBond*> _bonds;
97 std::vector<OBRing*> _rlist;
98 public:
99 OBRingSearch() {}
100 ~OBRingSearch();
101
102 //! Sort ring sizes from smallest to largest
103 void SortRings()
104 {
105 std::sort(_rlist.begin(),_rlist.end(),CompareRingSize);
106 }
107 //! Starting with a full ring set - reduce to SSSR set
108 void RemoveRedundant(int);
109 void AddRingFromClosure(OBMol &,OBBond *);
110 //! For debugging only, write the rings to std::cout
111 void WriteRings();
112
113 bool SaveUniqueRing(std::deque<int>&,std::deque<int>&);
114
115 std::vector<OBRing*>::iterator BeginRings()
116 {
117 return(_rlist.begin());
118 }
119 std::vector<OBRing*>::iterator EndRings()
120 {
121 return(_rlist.end());
122 }
123 };
124
125 } // end namespace OpenBabel
126
127 #endif // OB_RING_H
128
129 //! \file ring.h
130 //! \brief Deal with rings, find smallest set of smallest rings (SSSR).