00001 /********************************************************************** 00002 bond.h - Handle OBBond class. 00003 00004 Copyright (C) 1998-2001 by OpenEye Scientific Software, Inc. 00005 Some portions Copyright (C) 2001-2006 by Geoffrey R. Hutchison 00006 Some portions Copyright (C) 2003 by Michael Banck 00007 Some portions Copyright (C) 2008 by Tim Vandermeersch 00008 00009 This file is part of the Open Babel project. 00010 For more information, see <http://openbabel.org/> 00011 00012 This program is free software; you can redistribute it and/or modify 00013 it under the terms of the GNU General Public License as published by 00014 the Free Software Foundation version 2 of the License. 00015 00016 This program is distributed in the hope that it will be useful, 00017 but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 GNU General Public License for more details. 00020 ***********************************************************************/ 00021 00022 #ifndef OB_BOND_H 00023 #define OB_BOND_H 00024 00025 #include <openbabel/babelconfig.h> 00026 00027 #ifndef EXTERN 00028 # define EXTERN extern 00029 #endif 00030 00031 #include <openbabel/base.h> 00032 #include <openbabel/atom.h> 00033 00034 namespace OpenBabel 00035 { 00036 class OBAtom; 00037 class OBRing; 00038 00040 typedef OBBond OBEdgeBase; 00041 00042 //BOND Property Macros (flags) 00044 #define OB_AROMATIC_BOND (1<<1) 00045 00046 #define OB_WEDGE_BOND (1<<2) 00047 00048 #define OB_HASH_BOND (1<<3) 00049 00050 #define OB_RING_BOND (1<<4) 00051 00052 #define OB_TORUP_BOND (1<<5) 00053 00054 #define OB_TORDOWN_BOND (1<<6) 00055 00056 #define OB_KSINGLE_BOND (1<<7) 00057 00058 #define OB_KDOUBLE_BOND (1<<8) 00059 00060 #define OB_KTRIPLE_BOND (1<<9) 00061 00062 #define OB_CLOSURE_BOND (1<<10) 00063 // 11-16 currently unused 00064 00065 #define OB_WEDGE_OR_HASH_BOND (1<<11) 00066 #define OB_CIS_OR_TRANS_BOND (1<<12) 00067 00068 //class OBBondPrivate; 00069 class OBAPI OBBond: public OBBase 00070 { 00071 protected: 00072 unsigned int _idx; 00073 OBMol *_parent; 00074 OBAtom *_bgn; 00075 OBAtom *_end; 00076 char _order; 00077 unsigned short int _flags; 00078 unsigned long _id; 00079 //OBBondPrivate * const d; 00080 00084 bool HasFlag(int flag) const { return ((_flags & flag) != 0); } 00088 void SetFlag(int flag) { _flags |= flag; } 00092 void UnsetFlag(int flag) { _flags &= (~(flag)); } 00093 00094 public: 00095 enum Flag { 00096 Aromatic = (1<<1), 00097 Ring = (1<<4), 00098 Closure = (1<<10) 00099 }; 00100 enum StereoFlag { 00101 Wedge = (1<<2), 00102 Hash = (1<<3), 00103 WedgeOrHash = (1<<11), 00104 CisOrTrans = (1<<12) 00105 }; 00107 00108 bool Visit; 00109 00111 OBBond(); 00113 virtual ~OBBond(); 00114 00116 00117 00118 00120 void SetIdx(int idx) { _idx = idx; } 00121 void SetId(unsigned long id) { _id = id; } 00123 00124 void SetBO(int order); 00126 void SetBondOrder(int order); 00128 void SetBegin(OBAtom *begin){ _bgn = begin; } 00130 void SetEnd(OBAtom *end) { _end = end; } 00132 void SetParent(OBMol *ptr) { _parent= ptr; } 00134 void SetLength(OBAtom *fixed,double length); 00137 void SetLength(double length); 00139 void Set(int index, OBAtom* begin,OBAtom* end,int order,int flags); 00141 void SetKSingle(); 00143 void SetKDouble(); 00145 void SetKTriple(); 00147 void SetAromatic() { SetFlag(OB_AROMATIC_BOND); } 00152 void SetWedge() { SetFlag(Wedge); } 00157 void SetHash() { SetFlag(Hash); } 00162 void SetWedgeOrHash() { SetFlag(WedgeOrHash); } 00164 void SetUp() { SetFlag(OB_TORUP_BOND); UnsetFlag(OB_TORDOWN_BOND); } 00166 void SetDown() { SetFlag(OB_TORDOWN_BOND); UnsetFlag(OB_TORUP_BOND); } 00168 void SetInRing(bool set=true) { if(set)SetFlag(OB_RING_BOND); else UnsetFlag(OB_RING_BOND);} 00170 00173 void SetClosure() { SetFlag(OB_CLOSURE_BOND); } 00175 void UnsetHash() { UnsetFlag(OB_HASH_BOND); } 00177 void UnsetWedge() { UnsetFlag(OB_WEDGE_BOND); } 00179 void UnsetUp() { UnsetFlag(OB_TORUP_BOND); } 00181 void UnsetDown() { UnsetFlag(OB_TORDOWN_BOND); } 00183 void UnsetAromatic() { UnsetFlag(OB_AROMATIC_BOND);} 00185 void UnsetKekule() 00186 { 00187 _flags &= (~(OB_KSINGLE_BOND|OB_KDOUBLE_BOND|OB_KTRIPLE_BOND)); 00188 } 00190 00192 00193 00194 unsigned int GetIdx() const { return(_idx); } 00195 unsigned long GetId() const { return _id; } 00197 00198 unsigned int GetBO() const { return(_order); } 00200 unsigned int GetBondOrder() const { return(_order); } 00202 unsigned int GetFlags() const { return(_flags); } 00204 unsigned int GetBeginAtomIdx() const 00205 { return (_bgn ? _bgn->GetIdx() : 0); } 00207 unsigned int GetEndAtomIdx() const 00208 { return (_end ? _end->GetIdx() : 0); } 00210 OBAtom *GetBeginAtom() { return(_bgn); } 00211 const OBAtom *GetBeginAtom() const 00212 { return(_bgn); } 00214 OBAtom *GetEndAtom() { return(_end); } 00215 const OBAtom *GetEndAtom() const 00216 { return(_end); } 00218 00220 OBAtom *GetNbrAtom(OBAtom *ptr) 00221 { 00222 return((ptr != _bgn)? _bgn : _end); 00223 } 00225 OBMol *GetParent() {return(_parent);} 00227 00228 double GetEquibLength() const; 00230 double GetLength() const; 00232 00234 unsigned int GetNbrAtomIdx(OBAtom *ptr) 00235 { 00236 if (ptr!=_bgn) 00237 return (_bgn ? _bgn->GetIdx() : 0); 00238 else 00239 return (_end ? _end->GetIdx() : 0); 00240 } 00242 OBRing* FindSmallestRing() const; 00244 00246 00247 00248 00249 00250 bool IsAromatic() const; 00252 bool IsInRing() const; 00254 00259 bool IsRotor(); 00262 bool IsAmide(); 00265 bool IsPrimaryAmide(); 00268 bool IsSecondaryAmide(); 00271 bool IsTertiaryAmide(); 00273 bool IsEster(); 00275 bool IsCarbonyl(); 00277 bool IsSingle(); 00279 bool IsDouble(); 00281 bool IsTriple(); 00283 bool IsKSingle(); 00285 bool IsKDouble(); 00287 bool IsKTriple(); 00289 bool IsClosure(); 00292 bool IsUp() { return(HasFlag(OB_TORUP_BOND)); } 00295 bool IsDown() { return(HasFlag(OB_TORDOWN_BOND)); } 00298 bool IsWedge() { return(HasFlag(OB_WEDGE_BOND)); } 00301 bool IsHash() { return(HasFlag(OB_HASH_BOND)); } 00307 bool IsWedgeOrHash() const { return(HasFlag(WedgeOrHash)); } 00312 bool IsCisOrTrans() const { return(HasFlag(CisOrTrans)); } 00313 00315 bool IsDoubleBondGeometry(); 00317 00318 }; // class OBBond 00319 00321 typedef std::vector<OBBond*>::iterator OBBondIterator; 00322 00323 }// namespace OpenBabel 00324 00325 #endif // OB_BOND_H 00326
This file is part of the documentation for Open Babel, version 2.3.