00001 /********************************************************************** 00002 data.h - Global data and resource file parsers. 00003 00004 Copyright (C) 1998-2001 by OpenEye Scientific Software, Inc. 00005 Some portions Copyright (C) 2001-2006 by Geoffrey R. Hutchison 00006 00007 This file is part of the Open Babel project. 00008 For more information, see <http://openbabel.org/> 00009 00010 This program is free software; you can redistribute it and/or modify 00011 it under the terms of the GNU General Public License as published by 00012 the Free Software Foundation version 2 of the License. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 ***********************************************************************/ 00019 00020 #ifndef OB_DATA_H 00021 #define OB_DATA_H 00022 00023 #include <openbabel/babelconfig.h> 00024 00025 #include <stdio.h> 00026 #include <cstring> 00027 #include <fstream> 00028 #include <vector> 00029 #include <string> 00030 #include <cstring> 00031 00032 namespace OpenBabel 00033 { 00034 00035 class OBAtom; 00036 class OBMol; 00037 class OBBitVec; 00038 00049 class OBAPI OBGlobalDataBase 00050 { 00051 protected: 00052 bool _init; 00053 const char *_dataptr; 00054 std::string _filename; 00055 std::string _dir; 00056 std::string _subdir; 00057 std::string _envvar; 00058 00059 public: 00061 OBGlobalDataBase(): _init(false), _dataptr(NULL) { } 00063 virtual ~OBGlobalDataBase() {} 00065 void Init(); 00067 virtual size_t GetSize() { return 0;} 00069 void SetReadDirectory(char *dir) { _dir = dir; } 00071 void SetEnvironmentVariable(char *var) { _envvar = var; } 00073 virtual void ParseLine(const char*) {} 00074 }; 00075 00082 class OBAPI OBElement 00083 { 00084 int _num; 00085 char _symbol[4]; 00086 std::string _name; 00087 double _Rcov,_Rvdw,_mass,_elNeg,_ARENeg,_ionize,_elAffinity; 00088 double _red, _green, _blue; 00089 int _maxbonds; 00090 public: 00092 OBElement() {} 00109 OBElement(int num, const char *sym, double ARENeg, double rcov, 00110 double rvdw, int maxbo, double mass, double elNeg, double ionize, 00111 double elAffin, double red, double green, double blue, 00112 std::string name) : 00113 _num(num), _name(name), _Rcov(rcov), _Rvdw(rvdw), _mass(mass), 00114 _elNeg(elNeg), _ARENeg(ARENeg), _ionize(ionize), _elAffinity(elAffin), 00115 _red(red), _green(green), _blue(blue), 00116 _maxbonds(maxbo) 00117 { 00118 strncpy(_symbol, sym, 4); 00119 } 00120 00122 int GetAtomicNum() { return(_num); } 00124 char *GetSymbol() { return(_symbol); } 00126 double GetCovalentRad() { return(_Rcov); } 00128 double GetVdwRad() { return(_Rvdw); } 00130 double GetMass() { return(_mass); } 00132 int GetMaxBonds() { return(_maxbonds);} 00134 double GetElectroNeg() { return(_elNeg); } 00136 double GetAllredRochowElectroNeg() { return(_ARENeg); } 00138 double GetIonization() { return(_ionize); } 00140 double GetElectronAffinity(){ return(_elAffinity); } 00142 std::string GetName() { return(_name); } 00144 double GetRed() { return(_red); } 00146 double GetGreen() { return(_green); } 00148 double GetBlue() { return(_blue); } 00149 }; 00150 00151 // class introduction in data.cpp 00152 class OBAPI OBElementTable : public OBGlobalDataBase 00153 { 00154 std::vector<OBElement*> _element; 00155 00156 public: 00157 00158 OBElementTable(void); 00159 ~OBElementTable(); 00160 00161 void ParseLine(const char*); 00162 00164 unsigned int GetNumberOfElements(); 00166 size_t GetSize() { return GetNumberOfElements(); } 00167 00169 int GetAtomicNum(const char *); 00173 int GetAtomicNum(const char *, int &iso); 00175 int GetAtomicNum(std::string name, int &iso); 00177 const char *GetSymbol(int); 00179 double GetVdwRad(int); 00181 double GetCovalentRad(int); 00184 double GetMass(int); 00187 double CorrectedBondRad(int,int = 3); // atomic #, hybridization 00190 double CorrectedVdwRad(int,int = 3); // atomic #, hybridization 00192 int GetMaxBonds(int); 00194 double GetElectroNeg(int); 00196 double GetAllredRochowElectroNeg(int); 00198 double GetIonization(int); 00200 double GetElectronAffinity(int); 00202 std::vector<double> GetRGB(int); 00204 std::string GetName(int); 00205 }; 00206 00207 // class introduction in data.cpp 00208 class OBAPI OBIsotopeTable : public OBGlobalDataBase 00209 { 00210 std::vector<std::vector<std::pair <unsigned int, double> > > _isotopes; 00211 00212 public: 00213 00214 OBIsotopeTable(void); 00215 ~OBIsotopeTable() {} 00216 00218 size_t GetSize() { return _isotopes.size(); } 00219 00220 void ParseLine(const char*); 00223 double GetExactMass(const unsigned int atomicNum, 00224 const unsigned int isotope = 0); 00225 }; 00226 00227 // class introduction in data.cpp 00228 class OBAPI OBTypeTable : public OBGlobalDataBase 00229 { 00230 int _linecount; 00231 unsigned int _ncols,_nrows; 00232 int _from,_to; 00233 std::vector<std::string> _colnames; 00234 std::vector<std::vector<std::string> > _table; 00235 00236 public: 00237 00238 OBTypeTable(void); 00239 ~OBTypeTable() {} 00240 00241 void ParseLine(const char*); 00242 00244 size_t GetSize() { return _table.size(); } 00245 00247 bool SetFromType(const char*); 00249 bool SetToType(const char*); 00251 bool Translate(char *to, const char *from); // to, from 00254 bool Translate(std::string &to, const std::string &from); // to, from 00257 std::string Translate(const std::string &from); 00258 00260 std::string GetFromType(); 00262 std::string GetToType(); 00263 }; 00264 00270 class OBAPI OBResidueData : public OBGlobalDataBase 00271 { 00272 int _resnum; 00273 std::vector<std::string> _resname; 00274 std::vector<std::vector<std::string> > _resatoms; 00275 std::vector<std::vector<std::pair<std::string,int> > > _resbonds; 00276 00277 //variables used only temporarily for parsing resdata.txt 00278 std::vector<std::string> _vatmtmp; 00279 std::vector<std::pair<std::string,int> > _vtmp; 00280 public: 00281 00282 OBResidueData(); 00283 void ParseLine(const char*); 00284 00286 size_t GetSize() { return _resname.size(); } 00287 00291 bool SetResName(const std::string &); 00294 int LookupBO(const std::string &); 00297 int LookupBO(const std::string &, const std::string&); 00301 bool LookupType(const std::string &,std::string&,int&); 00305 bool AssignBonds(OBMol &,OBBitVec &); 00306 }; 00307 00308 } // end namespace OpenBabel 00309 00310 #endif //DATA_H 00311
This file is part of the documentation for Open Babel, version 2.3.