Open Babel: ring.h Source File

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

# 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.org/>
    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 // TODO: Make this work as a free-standing header
    00027 // Currently only used in ring.cpp which imports mol.h beforehand
    00028 #include <openbabel/bitvec.h>
    00029 #include <openbabel/typer.h>
    00030
    00031 namespace OpenBabel
    00032 {
    00033
    00034   class OBMol;
    00035   class OBAtom;
    00036   class OBBond;
    00037
    00038   // class introduction in ring.cpp
    00039   class OBAPI OBRing
    00040   {
    00041     OBMol *_parent;
    00042   public:
    00043     //public data members
    00044     int ring_id;
    00045     std::vector<int> _path;
    00046     OBBitVec _pathset;
    00047
    00049
    00050     OBRing()    {}
    00052     OBRing(std::vector<int>& path, int size);
    00053     OBRing(std::vector<int>& path, OBBitVec set) : _path(path), _pathset(set) {}
    00054     OBRing(const OBRing &src);
    00055     OBRing& operator=(const OBRing &src);
    00057
    00058     //member functions
    00059
    00061     size_t    Size()     const  {    return(_path.size());  }
    00064     size_t    PathSize() const  {    return(_path.size());  }
    00065
    00069     bool   IsAromatic();
    00070
    00072     void SetType(char *type);
    00074     void SetType(std::string &type);
    00076     char *GetType();
    00080     unsigned int GetRootAtom();
    00081
    00083     bool   IsMember(OBAtom *a);
    00086     bool         IsMember(OBBond *b);
    00088     bool   IsInRing(int i)
    00089     {
    00090       return(_pathset.BitIsOn(i));
    00091     }
    00092
    00094     void   SetParent(OBMol *m)  {    _parent = m;    }
    00096     OBMol *GetParent()          {    return(_parent);}
    00097
    00104     bool findCenterAndNormal(vector3 & center, vector3 &norm1, vector3 &norm2);
    00105   private:
    00106     char _type[30];
    00107   };
    00108
    00111   OBAPI bool CompareRingSize(const OBRing *,const OBRing *);
    00112
    00113
    00117   class OBAPI OBRingSearch
    00118   {
    00119     std::vector<OBBond*> _bonds;
    00120     std::vector<OBRing*> _rlist;
    00121   public:
    00122     OBRingSearch()    {}
    00123     ~OBRingSearch();
    00124
    00126     void    SortRings()
    00127     {
    00128       std::vector<OBRing*>::iterator j;
    00129       int ring_id; // for each ring, assign a unique id to ensure a stable sort
    00130
    00131       for (j = _rlist.begin(), ring_id = 0; j != _rlist.end(); ++j, ++ring_id)
    00132         (*j)->ring_id = ring_id;
    00133       std::sort(_rlist.begin(),_rlist.end(),CompareRingSize);
    00134     }
    00136     void    RemoveRedundant(int);
    00138     void    AddRingFromClosure(OBMol &,OBBond *);
    00139
    00140     bool    SaveUniqueRing(std::deque<int>&,std::deque<int>&);
    00141
    00143     void    WriteRings();
    00144
    00146
    00147
    00148     std::vector<OBRing*>::iterator BeginRings()
    00149       {
    00150         return(_rlist.begin());
    00151       }
    00153     std::vector<OBRing*>::iterator EndRings()
    00154       {
    00155         return(_rlist.end());
    00156       }
    00158   };
    00159
    00164   class OBAPI OBRTree
    00165   {
    00166     OBAtom  *_atom;
    00167     OBRTree *_prv;
    00168   public:
    00170     OBRTree(OBAtom*,OBRTree*);
    00171     ~OBRTree()    {}
    00172
    00174     int  GetAtomIdx();
    00176     void PathToRoot(std::vector<OBAtom*>&);
    00177   };
    00178
    00179 } // end namespace OpenBabel
    00180
    00181 #endif // OB_RING_H
    00182

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

This file is part of the documentation for Open Babel, version 2.3.

Documentation copyright © 1998-2007, the Open Babel Developers.
Open Babel is hosted by:
Generated on Mon Oct 25 2010 11:55:12 by 1.7.2.