ring.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 ring.h - Deal with rings, find smallest set of smallest rings (SSSR).
00003  
00004 Copyright (C) 1998-2001 by OpenEye Scientific Software, Inc.
00005 Some portions Copyright (C) 2001-2005 by Geoffrey R. Hutchison
00006  
00007 This file is part of the Open Babel project.
00008 For more information, see <http://openbabel.sourceforge.net/>
00009  
00010 This program is free software; you can redistribute it and/or modify
00011 it under the terms of the GNU General Public License as published by
00012 the Free Software Foundation version 2 of the License.
00013  
00014 This program is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 GNU General Public License for more details.
00018 ***********************************************************************/
00019 
00020 #ifndef OB_RING_H
00021 #define OB_RING_H
00022 
00023 #include <deque>
00024 #include <algorithm>
00025 
00026 namespace OpenBabel
00027 {
00028 
00029 class OBMol;
00030 class OBAtom;
00031 class OBBond;
00032 
00034 class OBAPI OBRTree
00035 {
00036   OBAtom  *_atom; 
00037   OBRTree *_prv; 
00038 public:
00039   OBRTree(OBAtom*,OBRTree*);
00040   ~OBRTree()    {}
00041   
00043   int  GetAtomIdx();
00045   void PathToRoot(std::vector<OBNodeBase*>&);
00046 };
00047 
00048 // class introduction in ring.cpp
00049 class OBAPI OBRing
00050 {
00051     OBMol *_parent;
00052 public:
00053     //public data members
00054     std::vector<int> _path;
00055     OBBitVec _pathset;
00056     bool findCenterAndNormal(vector3 & center, vector3 &norm1, vector3 &norm2);
00057 
00058     //constructors
00059     OBRing()    {}
00060     OBRing(std::vector<int>&,int);
00061     OBRing(const OBRing &src);
00062     OBRing& operator=(const OBRing &src);
00063 
00064     //member functions
00065     int    Size()     const
00066     {
00067         return(_path.size());
00068     }
00069     int    PathSize() const
00070     {
00071         return(_path.size());
00072     }
00073     bool   IsMember(OBAtom *a);
00074     bool         IsMember(OBBond *b);
00075     bool   IsAromatic();
00076     bool   IsInRing(int i)
00077     {
00078         return(_pathset.BitIsOn(i));
00079     }
00080     void   SetParent(OBMol *m)
00081     {
00082         _parent = m;
00083     }
00084     OBMol *GetParent()
00085     {
00086         return(_parent);
00087     }
00088 };
00089 
00090 bool CompareRingSize(const OBRing *,const OBRing *);
00091 
00092 
00094 class OBAPI OBRingSearch
00095 {
00096     std::vector<OBBond*> _bonds;
00097     std::vector<OBRing*> _rlist;
00098 public:
00099     OBRingSearch()    {}
00100     ~OBRingSearch();
00101 
00103     void    SortRings()
00104     {
00105         std::sort(_rlist.begin(),_rlist.end(),CompareRingSize);
00106     }
00108     void    RemoveRedundant(int);
00109     void    AddRingFromClosure(OBMol &,OBBond *);
00111     void    WriteRings();
00112 
00113     bool    SaveUniqueRing(std::deque<int>&,std::deque<int>&);
00114 
00115     std::vector<OBRing*>::iterator BeginRings()
00116     {
00117         return(_rlist.begin());
00118     }
00119     std::vector<OBRing*>::iterator EndRings()
00120     {
00121         return(_rlist.end());
00122     }
00123 };
00124 
00125 } // end namespace OpenBabel
00126 
00127 #endif // OB_RING_H
00128