Loading...
Searching...
No Matches
bond.h
Go to the documentation of this file.
/**********************************************************************
bond.h - Handle OBBond class.
Copyright (C) 1998-2001 by OpenEye Scientific Software, Inc.
Some portions Copyright (C) 2001-2006 by Geoffrey R. Hutchison
Some portions Copyright (C) 2003 by Michael Banck
Some portions Copyright (C) 2008 by Tim Vandermeersch
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_BOND_H
#define OB_BOND_H
#include <openbabel/babelconfig.h>
#ifndef OB_EXTERN
# define OB_EXTERN extern
#endif
#include <openbabel/base.h>
#include <openbabel/atom.h>
namespace OpenBabel
{
class OBAtom;
class OBRing;
//BOND Property Macros (flags)
#define OB_AROMATIC_BOND (1<<1)
#define OB_WEDGE_BOND (1<<2)
#define OB_HASH_BOND (1<<3)
#define OB_RING_BOND (1<<4)
#define OB_CLOSURE_BOND (1<<10)
// 11-16 currently unused
#define OB_WEDGE_OR_HASH_BOND (1<<11)
#define SET_OR_UNSET_FLAG(X) \
if (value) SetFlag(X); \
else UnsetFlag(X);
class OBAPI OBBond: public OBBase
{
protected:
unsigned int _idx;
OBMol *_parent;
OBAtom *_bgn;
OBAtom *_end;
char _order;
unsigned short int _flags;
unsigned long _id;
//OBBondPrivate * const d;
bool HasFlag(int flag) const { return ((_flags & flag) != 0); }
void SetFlag(int flag) { _flags |= flag; }
void UnsetFlag(int flag) { _flags &= (~(flag)); }
public:
enum Flag {
Aromatic = (1<<1),
Ring = (1<<4),
Closure = (1<<10)
};
enum StereoFlag {
Wedge = (1<<2),
Hash = (1<<3),
WedgeOrHash = (1<<11),
CisOrTrans = (1<<12)
};
bool Visit;
OBBond();
virtual ~OBBond();
void SetIdx(int idx) { _idx = idx; }
void SetId(unsigned long id) { _id = id; }
void SetBondOrder(int order);
void SetBegin(OBAtom *begin){ _bgn = begin; }
void SetEnd(OBAtom *end) { _end = end; }
void SetParent(OBMol *ptr) { _parent= ptr; }
void SetLength(OBAtom *fixed,double length);
void SetLength(double length);
void Set(int index, OBAtom* begin,OBAtom* end,int order,int flags);
void SetAromatic(bool value=true) { SET_OR_UNSET_FLAG(OB_AROMATIC_BOND); }
void SetWedge(bool value=true) { SET_OR_UNSET_FLAG(Wedge); }
void SetHash(bool value=true) { SET_OR_UNSET_FLAG(Hash); }
void SetWedgeOrHash(bool value=true) { SET_OR_UNSET_FLAG(WedgeOrHash); }
void SetInRing(bool value=true) { SET_OR_UNSET_FLAG(OB_RING_BOND); }
void SetClosure(bool value=true) { SET_OR_UNSET_FLAG(OB_CLOSURE_BOND); }
unsigned int GetIdx() const { return(_idx); }
unsigned long GetId() const { return _id; }
unsigned int GetBondOrder() const { return(_order); }
unsigned int GetFlags() const { return(_flags); }
unsigned int GetBeginAtomIdx() const
{ return (_bgn ? _bgn->GetIdx() : 0); }
unsigned int GetEndAtomIdx() const
{ return (_end ? _end->GetIdx() : 0); }
OBAtom *GetBeginAtom() { return(_bgn); }
const OBAtom *GetBeginAtom() const
{ return(_bgn); }
OBAtom *GetEndAtom() { return(_end); }
const OBAtom *GetEndAtom() const
{ return(_end); }
OBAtom *GetNbrAtom(OBAtom *ptr)
{
return((ptr != _bgn)? _bgn : _end);
}
OBMol *GetParent() {return(_parent);}
double GetEquibLength() const;
double GetLength() const;
unsigned int GetNbrAtomIdx(OBAtom *ptr)
{
if (ptr!=_bgn)
return (_bgn ? _bgn->GetIdx() : 0);
else
return (_end ? _end->GetIdx() : 0);
}
OBRing* FindSmallestRing() const;
bool IsAromatic() const;
bool IsInRing() const;
bool IsRotor(bool includeRingBonds=false);
bool IsPeriodic() const;
bool IsAmide();
bool IsPrimaryAmide();
bool IsSecondaryAmide();
bool IsTertiaryAmide();
bool IsEster();
bool IsCarbonyl();
bool IsClosure();
bool IsWedge() { return(HasFlag(OB_WEDGE_BOND)); }
bool IsHash() { return(HasFlag(OB_HASH_BOND)); }
bool IsWedgeOrHash() const { return(HasFlag(WedgeOrHash)); }
bool IsCisOrTrans() const { return(HasFlag(CisOrTrans)); }
bool IsDoubleBondGeometry();
}; // class OBBond
typedef std::vector<OBBond*>::iterator OBBondIterator;
}// namespace OpenBabel
#endif // OB_BOND_H
atom.h
Handle atoms.
SET_OR_UNSET_FLAG
#define SET_OR_UNSET_FLAG(X)
Definition atom.h:64
base.h
Base classes to build a graph.
OB_HASH_BOND
#define OB_HASH_BOND
A dashed "hash" bond in 2D representations – i.e., "down" from the 2D plane.
Definition bond.h:45
OB_CLOSURE_BOND
#define OB_CLOSURE_BOND
A bond which "closes" a ring when walking the molecular graph.
Definition bond.h:49
OB_RING_BOND
#define OB_RING_BOND
A bond in a ring.
Definition bond.h:47
OB_WEDGE_BOND
#define OB_WEDGE_BOND
A solid black wedge in 2D representations – i.e., "up" from the 2D plane.
Definition bond.h:43
OB_AROMATIC_BOND
#define OB_AROMATIC_BOND
An aromatic bond (regardless of bond order).
Definition bond.h:41
OpenBabel::OBAtom
Atom class.
Definition atom.h:72
OpenBabel::OBBase
Base Class.
Definition base.h:240
OpenBabel::OBBond::SetHash
void SetHash(bool value=true)
Definition bond.h:137
OpenBabel::OBBond::_idx
unsigned int _idx
Unique edge index used by GetIdx() and SetIdx().
Definition bond.h:61
OpenBabel::OBBond::GetParent
OBMol * GetParent()
Definition bond.h:182
OpenBabel::OBBond::GetEndAtom
const OBAtom * GetEndAtom() const
Definition bond.h:172
OpenBabel::OBBond::SetWedgeOrHash
void SetWedgeOrHash(bool value=true)
Definition bond.h:141
OpenBabel::OBBond::HasFlag
bool HasFlag(int flag) const
Definition bond.h:73
OpenBabel::OBBond::SetId
void SetId(unsigned long id)
Definition bond.h:110
OpenBabel::OBBond::GetEndAtomIdx
unsigned int GetEndAtomIdx() const
Definition bond.h:164
OpenBabel::OBBond::_bgn
OBAtom * _bgn
I connect one node.
Definition bond.h:63
OpenBabel::OBBond::SetBegin
void SetBegin(OBAtom *begin)
Set the beginning atom of this bond to begin. Does not update begin.
Definition bond.h:114
OpenBabel::OBBond::_order
char _order
Bond order (1, 2, 3, 5=aromatic).
Definition bond.h:65
OpenBabel::OBBond::Flag
Flag
Definition bond.h:84
OpenBabel::OBBond::Closure
@ Closure
A bond which "closes" a ring when walking the molecular graph.
Definition bond.h:87
OpenBabel::OBBond::Aromatic
@ Aromatic
An aromatic bond (regardless of bond order).
Definition bond.h:85
OpenBabel::OBBond::Ring
@ Ring
A bond in a ring.
Definition bond.h:86
OpenBabel::OBBond::UnsetFlag
void UnsetFlag(int flag)
Definition bond.h:81
OpenBabel::OBBond::GetIdx
unsigned int GetIdx() const
Definition bond.h:154
OpenBabel::OBBond::GetBeginAtom
const OBAtom * GetBeginAtom() const
Definition bond.h:168
OpenBabel::OBBond::OBBond
OBBond()
Constructor.
Definition bond.cpp:63
OpenBabel::OBBond::Visit
bool Visit
Whether this bond has been visited by a graph algorithm.
Definition bond.h:97
OpenBabel::OBBond::GetId
unsigned long GetId() const
Definition bond.h:155
OpenBabel::OBBond::IsWedge
bool IsWedge()
Definition bond.h:240
OpenBabel::OBBond::SetInRing
void SetInRing(bool value=true)
Mark that this bond is in a ring. Primarily for internal use.
Definition bond.h:143
OpenBabel::OBBond::SetAromatic
void SetAromatic(bool value=true)
Mark that this bond is aromatic. Does not update atoms or validate.
Definition bond.h:127
OpenBabel::OBBond::SetParent
void SetParent(OBMol *ptr)
Set the parent molecule to ptr. Does not update parent.
Definition bond.h:118
OpenBabel::OBBond::SetEnd
void SetEnd(OBAtom *end)
Set the ending atom of this bond to end. Does not update end.
Definition bond.h:116
OpenBabel::OBBond::_end
OBAtom * _end
to another node
Definition bond.h:64
OpenBabel::OBBond::_parent
OBMol * _parent
The molecule which contains me (if any).
Definition bond.h:62
OpenBabel::OBBond::GetEndAtom
OBAtom * GetEndAtom()
Definition bond.h:171
OpenBabel::OBBond::IsCisOrTrans
bool IsCisOrTrans() const
Definition bond.h:254
OpenBabel::OBBond::IsHash
bool IsHash()
Definition bond.h:243
OpenBabel::OBBond::SetIdx
void SetIdx(int idx)
Set the internal bond index.
Definition bond.h:109
OpenBabel::OBBond::SetWedge
void SetWedge(bool value=true)
Definition bond.h:132
OpenBabel::OBBond::_id
unsigned long _id
unique id
Definition bond.h:67
OpenBabel::OBBond::GetNbrAtom
OBAtom * GetNbrAtom(OBAtom *ptr)
Definition bond.h:177
OpenBabel::OBBond::GetBeginAtom
OBAtom * GetBeginAtom()
Definition bond.h:167
OpenBabel::OBBond::GetFlags
unsigned int GetFlags() const
Definition bond.h:159
OpenBabel::OBBond::GetBondOrder
unsigned int GetBondOrder() const
Definition bond.h:157
OpenBabel::OBBond::SetFlag
void SetFlag(int flag)
Definition bond.h:77
OpenBabel::OBBond::IsWedgeOrHash
bool IsWedgeOrHash() const
Definition bond.h:249
OpenBabel::OBBond::GetBeginAtomIdx
unsigned int GetBeginAtomIdx() const
Definition bond.h:161
OpenBabel::OBBond::GetNbrAtomIdx
unsigned int GetNbrAtomIdx(OBAtom *ptr)
Definition bond.h:191
OpenBabel::OBBond::_flags
unsigned short int _flags
Any flags for this bond.
Definition bond.h:66
OpenBabel::OBBond::SetClosure
void SetClosure(bool value=true)
Mark that this bond indicates a ring closure when walking the molecule.
Definition bond.h:148
OpenBabel::OBBond::StereoFlag
StereoFlag
Definition bond.h:89
OpenBabel::OBBond::CisOrTrans
@ CisOrTrans
Indicates the 2D/3D coordinates are accidentally cis/trans.
Definition bond.h:93
OpenBabel::OBBond::Wedge
@ Wedge
A solid black wedge in 2D representations – i.e., "up" from the 2D plane.
Definition bond.h:90
OpenBabel::OBBond::WedgeOrHash
@ WedgeOrHash
The bond is either wedge or hash, this is a separate flag!
Definition bond.h:92
OpenBabel::OBBond::Hash
@ Hash
A dashed "hash" bond in 2D representations – i.e., "down" from the 2D plane.
Definition bond.h:91
OpenBabel::OBMol
Molecule Class.
Definition mol.h:121
OpenBabel::OBRing
Stores information on rings in a molecule from SSSR perception.
Definition ring.h:41
OpenBabel
Global namespace for all Open Babel code.
Definition alias.h:23
OpenBabel::OBBondIterator
std::vector< OBBond * >::iterator OBBondIterator
A standard iterator over a vector of bonds.
Definition atom.h:46