Loading...
Searching...
No Matches
ring.h
Go to the documentation of this file.
/**********************************************************************
ring.h - Deal with rings, find smallest set of smallest rings (SSSR).
Copyright (C) 1998-2001 by OpenEye Scientific Software, Inc.
Some portions Copyright (C) 2001-2005 by Geoffrey R. Hutchison
This file is part of the Open Babel project.
For more information, see <http://openbabel.org/>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
***********************************************************************/
#ifndef OB_RING_H
#define OB_RING_H
#include <deque>
#include <algorithm>
// TODO: Make this work as a free-standing header
// Currently only used in ring.cpp which imports mol.h beforehand
#include <openbabel/bitvec.h>
#include <openbabel/typer.h>
namespace OpenBabel
{
class OBMol;
class OBAtom;
class OBBond;
class vector3;
// class introduction in ring.cpp
class OBAPI OBRing
{
OBMol *_parent;
public:
//public data members
int ring_id;
std::vector<int> _path;
OBBitVec _pathset;
OBRing() {}
OBRing(std::vector<int>& path, int size);
OBRing(std::vector<int>& path, OBBitVec set) : _path(path), _pathset(set) {}
OBRing(const OBRing &src);
OBRing& operator=(const OBRing &src);
//member functions
size_t Size() const { return(_path.size()); }
size_t PathSize() const { return(_path.size()); }
bool IsAromatic();
void SetType(char *type);
void SetType(std::string &type);
char *GetType();
unsigned int GetRootAtom();
bool IsMember(OBAtom *a);
bool IsMember(OBBond *b);
bool IsInRing(int i)
{
return(_pathset.BitIsSet(i));
}
void SetParent(OBMol *m) { _parent = m; }
OBMol *GetParent() { return(_parent);}
bool findCenterAndNormal(vector3 & center, vector3 &norm1, vector3 &norm2);
private:
char _type[30];
};
OBAPI bool CompareRingSize(const OBRing *,const OBRing *);
class OBAPI OBRingSearch
{
std::vector<OBBond*> _bonds;
std::vector<OBRing*> _rlist;
public:
OBRingSearch() {}
~OBRingSearch();
void SortRings()
{
std::vector<OBRing*>::iterator j;
int ring_id; // for each ring, assign a unique id to ensure a stable sort
for (j = _rlist.begin(), ring_id = 0; j != _rlist.end(); ++j, ++ring_id)
(*j)->ring_id = ring_id;
std::sort(_rlist.begin(),_rlist.end(),CompareRingSize);
}
void RemoveRedundant(int);
void AddRingFromClosure(OBMol &,OBBond *);
bool SaveUniqueRing(std::deque<int>&,std::deque<int>&);
void WriteRings();
std::vector<OBRing*>::iterator BeginRings()
{
return(_rlist.begin());
}
std::vector<OBRing*>::iterator EndRings()
{
return(_rlist.end());
}
};
class OBAPI OBRTree
{
OBAtom *_atom;
OBRTree *_prv;
public:
OBRTree(OBAtom*,OBRTree*);
~OBRTree() {}
int GetAtomIdx();
void PathToRoot(std::vector<OBAtom*>&);
};
} // end namespace OpenBabel
#endif // OB_RING_H
bitvec.h
Fast and efficient bitstring class.
OpenBabel::OBAtom
Atom class.
Definition atom.h:72
OpenBabel::OBBitVec
A speed-optimized vector of bits.
Definition bitvec.h:58
OpenBabel::OBBond
Bond class.
Definition bond.h:59
OpenBabel::OBMol
Molecule Class.
Definition mol.h:121
OpenBabel::OBRTree::~OBRTree
~OBRTree()
Definition ring.h:172
OpenBabel::OBRTree::OBRTree
OBRTree(OBAtom *, OBRTree *)
Construct a search tree from a possible parent entry and atom entry.
Definition ring.cpp:739
OpenBabel::OBRingSearch
Internal class to facilitate OBMol::FindSSSR().
Definition ring.h:119
OpenBabel::OBRingSearch::EndRings
std::vector< OBRing * >::iterator EndRings()
Definition ring.h:154
OpenBabel::OBRingSearch::BeginRings
std::vector< OBRing * >::iterator BeginRings()
Definition ring.h:149
OpenBabel::OBRingSearch::SortRings
void SortRings()
Sort ring sizes from smallest to largest.
Definition ring.h:127
OpenBabel::OBRingSearch::OBRingSearch
OBRingSearch()
Definition ring.h:123
OpenBabel::OBRing
Stores information on rings in a molecule from SSSR perception.
Definition ring.h:41
OpenBabel::OBRing::GetParent
OBMol * GetParent()
Definition ring.h:97
OpenBabel::OBRing::OBRing
OBRing(std::vector< int > &path, OBBitVec set)
Definition ring.h:54
OpenBabel::OBRing::Size
size_t Size() const
Definition ring.h:62
OpenBabel::OBRing::SetParent
void SetParent(OBMol *m)
Set the parent of this ring to m.
Definition ring.h:95
OpenBabel::OBRing::_path
std::vector< int > _path
the path of this ring (i.e., the atom indexes)
Definition ring.h:46
OpenBabel::OBRing::IsInRing
bool IsInRing(int i)
Definition ring.h:89
OpenBabel::OBRing::ring_id
int ring_id
a unique id to ensure a stable sort in SSSR determination
Definition ring.h:45
OpenBabel::OBRing::_pathset
OBBitVec _pathset
the path of this ring as a redundant bit vector
Definition ring.h:47
OpenBabel::OBRing::OBRing
OBRing()
Definition ring.h:51
OpenBabel::OBRing::PathSize
size_t PathSize() const
Definition ring.h:65
OpenBabel::vector3
Represents a vector in 3-dimensional real space.
Definition vector3.h:45
OpenBabel
Global namespace for all Open Babel code.
Definition alias.h:23
OpenBabel::CompareRingSize
bool CompareRingSize(const OBRing *, const OBRing *)
Definition ring.cpp:486
typer.h
Open Babel atom and aromaticity typer.