atom.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef OB_ATOM_H
00022 #define OB_ATOM_H
00023
00024 #include <openbabel/babelconfig.h>
00025
00026 #ifndef EXTERN
00027 # define EXTERN extern
00028 #endif
00029
00030 #include <vector>
00031 #include <string>
00032
00033 #include <openbabel/base.h>
00034 #include <openbabel/residue.h>
00035 #include <openbabel/math/vector3.h>
00036
00037 namespace OpenBabel
00038 {
00039
00040 class OBBond;
00041 class OBMol;
00042
00044 typedef OBAtom OBNodeBase;
00046 typedef std::vector<OBBond*>::iterator OBBondIterator;
00048 typedef std::vector<OBAtom*>::iterator OBAtomIterator;
00049
00050
00052 #define OB_4RING_ATOM (1<<1)
00054 #define OB_3RING_ATOM (1<<2)
00056 #define OB_AROMATIC_ATOM (1<<3)
00058 #define OB_RING_ATOM (1<<4)
00060 #define OB_CSTEREO_ATOM (1<<5)
00062 #define OB_ACSTEREO_ATOM (1<<6)
00064 #define OB_DONOR_ATOM (1<<7)
00066 #define OB_ACCEPTOR_ATOM (1<<8)
00068 #define OB_CHIRAL_ATOM (1<<9)
00070 #define OB_POS_CHIRAL_ATOM (1<<10)
00072 #define OB_NEG_CHIRAL_ATOM (1<<11)
00074 #define OB_ATOM_HAS_NO_H (1<<12)
00076 #define OB_ATOM_NOT_H_DEFICIENT (1<<13)
00077
00078
00079
00080 class OBAPI OBAtom: public OBBase
00081 {
00082 protected:
00083 unsigned char _ele;
00084 char _impval;
00085 char _type[6];
00086 short _fcharge;
00087 unsigned short _isotope;
00088 short _spinmultiplicity;
00089
00090 unsigned int _idx;
00091 OBMol *_parent;
00092 std::vector<OBBond*> _vbond;
00093
00094 unsigned int _cidx;
00095 unsigned short _hyb;
00096 unsigned short _flags;
00097 double _pcharge;
00098 double **_c;
00099 mutable vector3 _v;
00100 OBResidue *_residue;
00101
00102 unsigned long _id;
00103
00105 int GetFlag() const { return(_flags); }
00107 void SetFlag(int flag) { _flags |= flag; }
00109 bool HasFlag(int flag) { return((_flags & flag) ? true : false); }
00110
00111 public:
00112 enum StereoFlag {
00113
00114 };
00115
00116
00118 bool Visit;
00119
00121 OBAtom();
00123 virtual ~OBAtom();
00125 OBAtom &operator = (OBAtom &);
00127 bool operator==(const OBAtom * other) const { return (GetIdx() == other->GetIdx()); }
00130 void Duplicate(OBAtom *);
00133 bool Clear();
00134
00136
00137
00138 void SetIdx(int idx) { _idx = idx; _cidx = (idx-1)*3; }
00139 void SetId(unsigned long id) { _id = id; }
00141 void SetHyb(int hyb) { _hyb = hyb; }
00143 void SetAtomicNum(int atomicnum) { _ele = (char)atomicnum; }
00145 void SetIsotope(unsigned int iso);
00147 void SetImplicitValence(int val) { _impval = (char)val; }
00149 void IncrementImplicitValence() { _impval++; }
00151 void DecrementImplicitValence() { _impval--; }
00153 void SetFormalCharge(int fcharge) { _fcharge = fcharge; }
00155 void SetSpinMultiplicity(short spin){ _spinmultiplicity = spin; }
00157 void SetType(const char *type);
00159 void SetType(const std::string &type);
00161 void SetPartialCharge(double pcharge){ _pcharge = pcharge; }
00163 void SetVector(const vector3 &v);
00165 void SetVector(const double x,const double y,const double z);
00167 void SetCoordPtr(double **c) { _c = c; _cidx = (GetIdx()-1)*3; }
00169 void SetVector();
00171 void SetResidue(OBResidue *res) { _residue=res; }
00173 void SetParent(OBMol *ptr) { _parent=ptr; }
00175 void SetAromatic() { SetFlag(OB_AROMATIC_ATOM); }
00177 void UnsetAromatic() { _flags &= (~(OB_AROMATIC_ATOM)); }
00179
00181
00183
00185
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00198 void SetInRing() { SetFlag(OB_RING_ATOM); }
00200 void SetChiral() { SetFlag(OB_CHIRAL_ATOM); }
00202 void ClearCoordPtr() { _c = NULL; _cidx=0; }
00204
00206
00207
00208 int GetFormalCharge() const { return(_fcharge); }
00210 unsigned int GetAtomicNum() const { return((unsigned int)_ele); }
00212 unsigned short int GetIsotope() const { return(_isotope); }
00215 int GetSpinMultiplicity() const { return(_spinmultiplicity); }
00218 double GetAtomicMass() const;
00221 double GetExactMass() const;
00223 unsigned int GetIdx() const { return((int)_idx); }
00224 unsigned int GetIndex() const { return _idx - 1; }
00225 unsigned long GetId() const { return _id; }
00228 unsigned int GetCoordinateIdx() const { return((int)_cidx); }
00230 unsigned int GetCIdx() const { return((int)_cidx); }
00232 unsigned int GetValence() const
00233 {
00234 return((_vbond.empty()) ? 0 : static_cast<unsigned int> (_vbond.size()));
00235 }
00237 unsigned int GetHyb() const;
00239 unsigned int GetImplicitValence() const;
00241 unsigned int GetHvyValence() const;
00243 unsigned int GetHeteroValence() const;
00245 char *GetType();
00246
00248 double GetX() const { return(x()); }
00250 double GetY() const { return(y()); }
00252 double GetZ() const { return(z()); }
00253
00254
00255
00257 double x() const {
00258 if (_c) return((*_c)[_cidx]);
00259 else return _v.x();
00260 }
00262 double y() const {
00263 if (_c) return((*_c)[_cidx+1]);
00264 else return _v.y();
00265 }
00267 double z() const {
00268 if (_c) return((*_c)[_cidx+2]);
00269 else return _v.z();
00270 }
00275 double *GetCoordinate(){
00276 if (_c) return(&(*_c)[_cidx]);
00277 else return NULL;
00278 }
00280 vector3 &GetVector();
00282 const vector3 &GetVector() const;
00284 double GetPartialCharge();
00286 OBResidue *GetResidue();
00289 OBResidue *GetResidue(bool perception);
00291 OBMol *GetParent() {return((OBMol*)_parent);}
00294 bool GetNewBondVector(vector3 &v,double length);
00297 OBBond *GetBond(OBAtom *);
00302 OBAtom *GetNextAtom();
00304
00306
00307
00308 OBBondIterator BeginBonds()
00309 { return(_vbond.begin()); }
00311 OBBondIterator EndBonds()
00312 { return(_vbond.end()); }
00315 OBBond *BeginBond(OBBondIterator &i);
00318 OBBond *NextBond(OBBondIterator &i);
00321 OBAtom *BeginNbrAtom(OBBondIterator &i);
00324 OBAtom *NextNbrAtom(OBBondIterator &i);
00326
00328 double GetDistance(int index);
00330 double GetDistance(OBAtom*);
00332 double GetAngle(int b, int c);
00334 double GetAngle(OBAtom *b, OBAtom *c);
00335
00337
00338
00340 void NewResidue()
00341 {
00342 if (!_residue)
00343 _residue = new OBResidue;
00344 }
00346 void AddResidue(OBResidue *res) { SetResidue(res); }
00348 void DeleteResidue(){
00349 if (_residue) {
00350 delete _residue;
00351 _residue = NULL;
00352 }
00353 }
00355 void AddBond(OBBond *bond) { _vbond.push_back(bond); }
00358 void InsertBond(OBBondIterator &i, OBBond *bond)
00359 {
00360 _vbond.insert(i, bond);
00361 }
00363 bool DeleteBond(OBBond* bond);
00365 void ClearBond() {_vbond.clear();}
00367
00369
00370
00373 bool HtoMethyl();
00376 bool SetHybAndGeom(int);
00378 void ForceNoH() {SetFlag(OB_ATOM_HAS_NO_H);}
00380 bool HasNoHForced() {return HasFlag(OB_ATOM_HAS_NO_H);}
00381
00384 void ForceImplH() {SetFlag(OB_ATOM_NOT_H_DEFICIENT);}
00387 bool HasImplHForced() {return HasFlag(OB_ATOM_NOT_H_DEFICIENT);}
00389
00391
00392
00393 unsigned int CountFreeOxygens() const;
00395 unsigned int ImplicitHydrogenCount() const;
00397 unsigned int ExplicitHydrogenCount(bool ExcludeIsotopes=false) const;
00399 unsigned int MemberOfRingCount() const;
00401 unsigned int MemberOfRingSize() const;
00403 unsigned int CountRingBonds() const;
00405 double SmallestBondAngle();
00407 double AverageBondAngle();
00409 unsigned int BOSum() const;
00412 unsigned int KBOSum() const;
00414 bool HasResidue() { return(_residue != NULL); }
00416 bool IsHydrogen() { return(GetAtomicNum() == 1); }
00418 bool IsCarbon() { return(GetAtomicNum() == 6); }
00420 bool IsNitrogen() { return(GetAtomicNum() == 7); }
00422 bool IsOxygen() { return(GetAtomicNum() == 8); }
00424 bool IsSulfur() { return(GetAtomicNum() == 16);}
00426 bool IsPhosphorus() { return(GetAtomicNum() == 15);}
00428 bool IsAromatic() const;
00430 bool IsInRing() const;
00432 bool IsInRingSize(int) const;
00435 bool IsHeteroatom();
00437 bool IsNotCorH();
00439 bool IsConnected(OBAtom*);
00442 bool IsOneThree(OBAtom*);
00445 bool IsOneFour(OBAtom*);
00447 bool IsCarboxylOxygen();
00449 bool IsPhosphateOxygen();
00451 bool IsSulfateOxygen();
00453 bool IsNitroOxygen();
00455 bool IsAmideNitrogen();
00458 bool IsPolarHydrogen();
00461 bool IsNonPolarHydrogen();
00464 bool IsAromaticNOxide();
00466 bool IsChiral();
00468 bool IsAxial();
00470
00472
00474
00476
00478
00479
00481
00482
00484 bool IsHbondAcceptor();
00486 bool IsHbondDonor();
00488 bool IsHbondDonorH();
00493 bool HasAlphaBetaUnsat(bool includePandS=true);
00495 bool HasBondOfOrder(unsigned int bo);
00497 int CountBondsOfOrder(unsigned int bo);
00499 bool HasNonSingleBond();
00501 bool HasSingleBond() { return(HasBondOfOrder(1)); }
00503 bool HasDoubleBond() { return(HasBondOfOrder(2)); }
00505 bool HasAromaticBond() { return(HasBondOfOrder(5)); }
00507 bool MatchesSMARTS(const char *);
00509
00510 };
00511
00512 }
00513
00514 #endif // OB_ATOM_H
00515