Loading...
Searching...
No Matches
atom.h
Go to the documentation of this file.
/**********************************************************************
atom.h - Handle OBAtom 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
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_ATOM_H
#define OB_ATOM_H
#include <openbabel/babelconfig.h>
#ifndef OB_EXTERN
# define OB_EXTERN extern
#endif
#include <vector>
#include <string>
#include <openbabel/base.h>
#include <openbabel/residue.h>
#include <openbabel/math/vector3.h>
namespace OpenBabel
{
class OBBond;
class OBMol;
typedef OBAtom OBNodeBase;
typedef std::vector<OBBond*>::iterator OBBondIterator;
typedef std::vector<OBAtom*>::iterator OBAtomIterator;
//ATOM Property Macros (flags)
#define OB_4RING_ATOM (1<<1)
#define OB_3RING_ATOM (1<<2)
#define OB_AROMATIC_ATOM (1<<3)
#define OB_RING_ATOM (1<<4)
#define OB_DONOR_ATOM (1<<7)
#define OB_ACCEPTOR_ATOM (1<<8)
#define SET_OR_UNSET_FLAG(X) \
if (value) SetFlag(X); \
else UnsetFlag(X);
// Class OBAtom
// class introduction in atom.cpp
#define OBATOM_TYPE_LEN 6
class OBAPI OBAtom: public OBBase
{
protected:
unsigned char _ele;
unsigned char _imph;
char _type[OBATOM_TYPE_LEN];
short _fcharge;
unsigned short _isotope;
short _spinmultiplicity;
unsigned int _idx;
OBMol *_parent;
std::vector<OBBond*> _vbond;
unsigned int _cidx;
unsigned short _hyb;
unsigned short _flags;
double _pcharge;
double **_c;
mutable vector3 _v;
OBResidue *_residue;
unsigned long _id;
int GetFlag() const { return(_flags); }
void SetFlag(int flag) { _flags |= flag; }
void UnsetFlag(int flag) { _flags &= (~(flag)); }
bool HasFlag(int flag) { return((_flags & flag) ? true : false); }
public:
enum StereoFlag {
};
bool Visit;
OBAtom();
virtual ~OBAtom();
OBAtom &operator = (OBAtom &);
bool operator==(const OBAtom * other) const { return (GetIdx() == other->GetIdx()); }
void Duplicate(OBAtom *);
bool Clear();
void SetIdx(int idx) { _idx = idx; _cidx = (idx-1)*3; }
void SetId(unsigned long id) { _id = id; }
void SetHyb(int hyb) { _hyb = hyb; }
void SetAtomicNum(int atomicnum) { _ele = (char)atomicnum; }
void SetIsotope(unsigned int iso);
void SetImplicitHCount(unsigned int val) { _imph = (unsigned char)val; }
void SetFormalCharge(int fcharge) { _fcharge = fcharge; }
void SetSpinMultiplicity(short spin){ _spinmultiplicity = spin; }
void SetType(const char *type);
void SetType(const std::string &type);
void SetPartialCharge(double pcharge){ _pcharge = pcharge; }
void SetVector(const vector3 &v);
void SetVector(const double x,const double y,const double z);
void SetCoordPtr(double **c) { _c = c; _cidx = (GetIdx()-1)*3; }
void SetVector();
void SetResidue(OBResidue *res) { _residue=res; }
void SetParent(OBMol *ptr) { _parent=ptr; }
void SetAromatic(bool value=true) { SET_OR_UNSET_FLAG(OB_AROMATIC_ATOM); }
void SetInRing(bool value=true) { SET_OR_UNSET_FLAG(OB_RING_ATOM); }
void ClearCoordPtr() { _c = nullptr; _cidx=0; }
int GetFormalCharge() const { return(_fcharge); }
unsigned int GetAtomicNum() const { return((unsigned int)_ele); }
unsigned short int GetIsotope() const { return(_isotope); }
int GetSpinMultiplicity() const { return(_spinmultiplicity); }
double GetAtomicMass() const;
double GetExactMass() const;
unsigned int GetIdx() const { return((int)_idx); }
unsigned int GetIndex() const { return _idx - 1; }
unsigned long GetId() const { return _id; }
unsigned int GetCoordinateIdx() const { return((int)_cidx); }
unsigned int GetExplicitDegree() const { return (unsigned int)_vbond.size(); }
unsigned int GetTotalDegree() const { return (unsigned int)(_vbond.size() + _imph); }
unsigned int GetExplicitValence() const;
unsigned int GetTotalValence() const;
unsigned int GetHyb() const;
unsigned char GetImplicitHCount() const { return _imph; };
unsigned int GetHvyDegree() const;
unsigned int GetHeteroDegree() const;
char *GetType();
double GetX() const { return(x()); }
double GetY() const { return(y()); }
double GetZ() const { return(z()); }
// These methods check to see if there is a coordinate pointer
// or an internal vector (e.g., SetCoordPtr())
double x() const {
if (_c) return((*_c)[_cidx]);
else return _v.x();
}
double y() const {
if (_c) return((*_c)[_cidx+1]);
else return _v.y();
}
double z() const {
if (_c) return((*_c)[_cidx+2]);
else return _v.z();
}
double *GetCoordinate(){
if (_c) return(&(*_c)[_cidx]);
else return nullptr;
}
vector3 &GetVector();
const vector3 &GetVector() const;
double GetPartialCharge();
OBResidue *GetResidue();
OBMol *GetParent() {return((OBMol*)_parent);}
bool GetNewBondVector(vector3 &v,double length);
OBBond *GetBond(OBAtom *);
OBBondIterator BeginBonds()
{ return(_vbond.begin()); }
OBBondIterator EndBonds()
{ return(_vbond.end()); }
OBBond *BeginBond(OBBondIterator &i);
OBBond *NextBond(OBBondIterator &i);
OBAtom *BeginNbrAtom(OBBondIterator &i);
OBAtom *NextNbrAtom(OBBondIterator &i);
double GetDistance(int index);
double GetDistance(OBAtom*);
double GetDistance(vector3* v);
double GetAngle(int b, int c);
double GetAngle(OBAtom *b, OBAtom *c);
void NewResidue()
{
if (!_residue)
_residue = new OBResidue;
}
void AddResidue(OBResidue *res) { SetResidue(res); }
void DeleteResidue(){
if (_residue) {
delete _residue;
_residue = nullptr; // Make sure to clear that a residue existed
}
}
void AddBond(OBBond *bond) { _vbond.push_back(bond); }
void InsertBond(OBBondIterator &i, OBBond *bond)
{
_vbond.insert(i, bond);
}
bool DeleteBond(OBBond* bond);
void ClearBond() {_vbond.clear();}
bool HtoMethyl();
bool SetHybAndGeom(int);
unsigned int CountFreeOxygens() const;
unsigned int CountFreeSulfurs() const;
unsigned int ExplicitHydrogenCount(bool ExcludeIsotopes=false) const;
unsigned int MemberOfRingCount() const;
unsigned int MemberOfRingSize() const;
unsigned int CountRingBonds() const;
double SmallestBondAngle();
double AverageBondAngle();
std::pair<int, int> LewisAcidBaseCounts() const;
bool HasResidue() { return(_residue != nullptr); }
bool IsHetAtom() {
if (_residue == nullptr)
return false;
else
return _residue->IsHetAtom(this);
}
bool IsElement(const unsigned int e) const {
return e == _ele;
}
bool IsAromatic() const;
bool IsInRing() const;
bool IsInRingSize(int) const;
bool IsHeteroatom();
bool IsConnected(OBAtom*);
bool IsOneThree(OBAtom*);
bool IsOneFour(OBAtom*);
bool IsCarboxylOxygen();
bool IsPhosphateOxygen();
bool IsSulfateOxygen();
bool IsNitroOxygen();
bool IsAmideNitrogen();
bool IsPolarHydrogen();
bool IsNonPolarHydrogen();
bool IsAromaticNOxide();
bool IsChiral();
bool IsPeriodic() const;
bool IsAxial();
bool IsHbondAcceptor();
bool IsHbondAcceptorSimple();
bool IsHbondDonor();
bool IsHbondDonorH();
bool IsMetal();
bool HasAlphaBetaUnsat(bool includePandS=true);
bool HasBondOfOrder(unsigned int bo);
int CountBondsOfOrder(unsigned int bo);
int HighestBondOrder();
bool HasNonSingleBond();
bool HasSingleBond() { return(HasBondOfOrder(1)); }
bool HasDoubleBond() { return(HasBondOfOrder(2)); }
bool HasAromaticBond() { return(HasBondOfOrder(5)); }
bool MatchesSMARTS(const char *);
}; // class OBAtom
}// namespace OpenBabel
#endif // OB_ATOM_H
SET_OR_UNSET_FLAG
#define SET_OR_UNSET_FLAG(X)
Definition atom.h:64
OBATOM_TYPE_LEN
#define OBATOM_TYPE_LEN
Definition atom.h:70
OB_RING_ATOM
#define OB_RING_ATOM
Atom is in a ring.
Definition atom.h:58
OB_AROMATIC_ATOM
#define OB_AROMATIC_ATOM
Atom is aromatic.
Definition atom.h:56
base.h
Base classes to build a graph.
OpenBabel::OBAtom
Atom class.
Definition atom.h:72
OpenBabel::OBAtom::ClearBond
void ClearBond()
Clear all bonding information in this atom (does not delete them).
Definition atom.h:327
OpenBabel::OBAtom::IsElement
bool IsElement(const unsigned int e) const
Definition atom.h:376
OpenBabel::OBAtom::HasDoubleBond
bool HasDoubleBond()
Definition atom.h:448
OpenBabel::OBAtom::HasAromaticBond
bool HasAromaticBond()
Definition atom.h:450
OpenBabel::OBAtom::_idx
unsigned int _idx
unique node index (GetIdx(), SetIdx())
Definition atom.h:81
OpenBabel::OBAtom::GetParent
OBMol * GetParent()
Definition atom.h:255
OpenBabel::OBAtom::InsertBond
void InsertBond(OBBondIterator &i, OBBond *bond)
Insert bond into the internal list at the position from i Does not modify the bond.
Definition atom.h:320
OpenBabel::OBAtom::SetSpinMultiplicity
void SetSpinMultiplicity(short spin)
Set the atomic spin to spin. See _spinmultiplicity.
Definition atom.h:144
OpenBabel::OBAtom::_ele
unsigned char _ele
atomic number (type unsigned char to minimize space – allows for 0..255 elements)
Definition atom.h:74
OpenBabel::OBAtom::_type
char _type[OBATOM_TYPE_LEN]
atomic type
Definition atom.h:76
OpenBabel::OBAtom::GetY
double GetY() const
Definition atom.h:217
OpenBabel::OBAtom::GetFormalCharge
int GetFormalCharge() const
Definition atom.h:174
OpenBabel::OBAtom::SetId
void SetId(unsigned long id)
Definition atom.h:132
OpenBabel::OBAtom::HasFlag
bool HasFlag(int flag)
Definition atom.h:102
OpenBabel::OBAtom::GetCoordinate
double * GetCoordinate()
Definition atom.h:242
OpenBabel::OBAtom::_vbond
std::vector< OBBond * > _vbond
bonds to this atom – assumed to be one of the endpoints
Definition atom.h:83
OpenBabel::OBAtom::AddResidue
void AddResidue(OBResidue *res)
Add (set) the residue for this atom.
Definition atom.h:308
OpenBabel::OBAtom::ClearCoordPtr
void ClearCoordPtr()
Clear the internal coordinate pointer.
Definition atom.h:168
OpenBabel::OBAtom::UnsetFlag
void UnsetFlag(int flag)
Unsets the bitwise flag.
Definition atom.h:100
OpenBabel::OBAtom::GetIdx
unsigned int GetIdx() const
Definition atom.h:189
OpenBabel::OBAtom::GetCoordinateIdx
unsigned int GetCoordinateIdx() const
Definition atom.h:194
OpenBabel::OBAtom::GetSpinMultiplicity
int GetSpinMultiplicity() const
Definition atom.h:181
OpenBabel::OBAtom::SetAtomicNum
void SetAtomicNum(int atomicnum)
Set atomic number.
Definition atom.h:136
OpenBabel::OBAtom::AddBond
void AddBond(OBBond *bond)
Add a bond to the internal list. Does not update the bond.
Definition atom.h:317
OpenBabel::OBAtom::_flags
unsigned short _flags
bitwise flags (e.g. aromaticity)
Definition atom.h:87
OpenBabel::OBAtom::_hyb
unsigned short _hyb
hybridization
Definition atom.h:86
OpenBabel::OBAtom::NewResidue
void NewResidue()
If no residue has been set for this atom, create a new one.
Definition atom.h:302
OpenBabel::OBAtom::Visit
bool Visit
Used internally by graph traversal algorithms.
Definition atom.h:111
OpenBabel::OBAtom::GetId
unsigned long GetId() const
Definition atom.h:191
OpenBabel::OBAtom::_fcharge
short _fcharge
formal charge
Definition atom.h:77
OpenBabel::OBAtom::SetImplicitHCount
void SetImplicitHCount(unsigned int val)
Set the implicit hydrogen count to val.
Definition atom.h:140
OpenBabel::OBAtom::SetInRing
void SetInRing(bool value=true)
Mark an atom as belonging to at least one ring.
Definition atom.h:166
OpenBabel::OBAtom::x
double x() const
Definition atom.h:224
OpenBabel::OBAtom::GetImplicitHCount
unsigned char GetImplicitHCount() const
Definition atom.h:206
OpenBabel::OBAtom::DeleteResidue
void DeleteResidue()
Delete any residue associated with this atom.
Definition atom.h:310
OpenBabel::OBAtom::operator==
bool operator==(const OBAtom *other) const
Equivalence.
Definition atom.h:120
OpenBabel::OBAtom::EndBonds
OBBondIterator EndBonds()
Definition atom.h:270
OpenBabel::OBAtom::GetAtomicNum
unsigned int GetAtomicNum() const
Definition atom.h:176
OpenBabel::OBAtom::_c
double ** _c
coordinate array in double*
Definition atom.h:89
OpenBabel::OBAtom::SetAromatic
void SetAromatic(bool value=true)
Mark atom as being aromatic.
Definition atom.h:164
OpenBabel::OBAtom::SetParent
void SetParent(OBMol *ptr)
Attach an OBMol ptr as the parent container for this atom.
Definition atom.h:162
OpenBabel::OBAtom::SetPartialCharge
void SetPartialCharge(double pcharge)
Set the partial charge to pcharge.
Definition atom.h:150
OpenBabel::OBAtom::SetHyb
void SetHyb(int hyb)
Set atom hybridization (i.e., 1 = sp, 2 = sp2, 3 = sp3 ...).
Definition atom.h:134
OpenBabel::OBAtom::_parent
OBMol * _parent
parent molecule (if any)
Definition atom.h:82
OpenBabel::OBAtom::SetFormalCharge
void SetFormalCharge(int fcharge)
Set the formal charge of the atom to fcharge.
Definition atom.h:142
OpenBabel::OBAtom::GetTotalDegree
unsigned int GetTotalDegree() const
Definition atom.h:198
OpenBabel::OBAtom::GetIndex
unsigned int GetIndex() const
Definition atom.h:190
OpenBabel::OBAtom::SetIdx
void SetIdx(int idx)
Set atom index (i.e., in an OBMol).
Definition atom.h:131
OpenBabel::OBAtom::_residue
OBResidue * _residue
parent residue (if applicable)
Definition atom.h:91
OpenBabel::OBAtom::GetX
double GetX() const
Definition atom.h:215
OpenBabel::OBAtom::BeginBonds
OBBondIterator BeginBonds()
Definition atom.h:267
OpenBabel::OBAtom::y
double y() const
Definition atom.h:229
OpenBabel::OBAtom::GetFlag
int GetFlag() const
Definition atom.h:96
OpenBabel::OBAtom::_id
unsigned long _id
unique id
Definition atom.h:93
OpenBabel::OBAtom::IsHetAtom
bool IsHetAtom()
Definition atom.h:369
OpenBabel::OBAtom::GetExplicitDegree
unsigned int GetExplicitDegree() const
Definition atom.h:196
OpenBabel::OBAtom::OBAtom
OBAtom()
Constructor.
OpenBabel::OBAtom::GetZ
double GetZ() const
Definition atom.h:219
OpenBabel::OBAtom::_isotope
unsigned short _isotope
isotope (0 = most abundant)
Definition atom.h:78
OpenBabel::OBAtom::GetIsotope
unsigned short int GetIsotope() const
Definition atom.h:178
OpenBabel::OBAtom::SetFlag
void SetFlag(int flag)
Sets the bitwise flag.
Definition atom.h:98
OpenBabel::OBAtom::HasBondOfOrder
bool HasBondOfOrder(unsigned int bo)
Definition atom.cpp:288
OpenBabel::OBAtom::SetResidue
void SetResidue(OBResidue *res)
Attach an OBResidue res as containing this atom.
Definition atom.h:160
OpenBabel::OBAtom::~OBAtom
virtual ~OBAtom()
Destructor.
OpenBabel::OBAtom::HasResidue
bool HasResidue()
Definition atom.h:366
OpenBabel::OBAtom::_pcharge
double _pcharge
partial charge
Definition atom.h:88
OpenBabel::OBAtom::z
double z() const
Definition atom.h:234
OpenBabel::OBAtom::_imph
unsigned char _imph
number of implicit hydrogens
Definition atom.h:75
OpenBabel::OBAtom::_v
vector3 _v
coordinate vector
Definition atom.h:90
OpenBabel::OBAtom::_spinmultiplicity
short _spinmultiplicity
atomic spin, e.g., 2 for radical 1 or 3 for carbene
Definition atom.h:79
OpenBabel::OBAtom::_cidx
unsigned int _cidx
index into coordinate array
Definition atom.h:85
OpenBabel::OBAtom::SetCoordPtr
void SetCoordPtr(double **c)
Set the position of this atom from a pointer-driven array of coordinates.
Definition atom.h:156
OpenBabel::OBAtom::HasSingleBond
bool HasSingleBond()
Definition atom.h:446
OpenBabel::OBAtom::StereoFlag
StereoFlag
Definition atom.h:105
OpenBabel::OBBase
Base Class.
Definition base.h:240
OpenBabel::OBBond
Bond class.
Definition bond.h:59
OpenBabel::OBMol
Molecule Class.
Definition mol.h:121
OpenBabel::OBResidue
Residue information.
Definition residue.h:51
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::OBBondIterator
std::vector< OBBond * >::iterator OBBondIterator
A standard iterator over a vector of bonds.
Definition atom.h:46
OpenBabel::OBNodeBase
OBAtom OBNodeBase
OBNodeBase is declared for backwards-compatibility with 2.0 and earlier code.
Definition atom.h:44
OpenBabel::OBAtomIterator
std::vector< OBAtom * >::iterator OBAtomIterator
A standard iterator over a vector of atoms.
Definition atom.h:48
residue.h
Defines for residue properties, names, etc.
vector3.h
Handle 3D coordinates.