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.sourceforge.net/> 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 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 unsigned int 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 unsigned int GetSize() { return GetNumberOfElements(); } 00167 00169 int GetAtomicNum(const char *); 00173 int GetAtomicNum(const char *, int &iso); 00175 const char *GetSymbol(int); 00177 double GetVdwRad(int); 00179 double GetCovalentRad(int); 00182 double GetMass(int); 00185 double CorrectedBondRad(int,int = 3); // atomic #, hybridization 00188 double CorrectedVdwRad(int,int = 3); // atomic #, hybridization 00190 int GetMaxBonds(int); 00192 double GetElectroNeg(int); 00194 double GetAllredRochowElectroNeg(int); 00196 double GetIonization(int); 00198 double GetElectronAffinity(int); 00200 std::vector<double> GetRGB(int); 00202 std::string GetName(int); 00203 }; 00204 00205 // class introduction in data.cpp 00206 class OBAPI OBIsotopeTable : public OBGlobalDataBase 00207 { 00208 std::vector<std::vector<std::pair <unsigned int, double> > > _isotopes; 00209 00210 public: 00211 00212 OBIsotopeTable(void); 00213 ~OBIsotopeTable() {} 00214 00216 unsigned int GetSize() { return _isotopes.size(); } 00217 00218 void ParseLine(const char*); 00221 double GetExactMass(const unsigned int atomicNum, 00222 const unsigned int isotope = 0); 00223 }; 00224 00225 // class introduction in data.cpp 00226 class OBAPI OBTypeTable : public OBGlobalDataBase 00227 { 00228 int _linecount; 00229 unsigned int _ncols,_nrows; 00230 int _from,_to; 00231 std::vector<std::string> _colnames; 00232 std::vector<std::vector<std::string> > _table; 00233 00234 public: 00235 00236 OBTypeTable(void); 00237 ~OBTypeTable() {} 00238 00239 void ParseLine(const char*); 00240 00242 unsigned int GetSize() { return _table.size(); } 00243 00245 bool SetFromType(const char*); 00247 bool SetToType(const char*); 00249 bool Translate(char *to, const char *from); // to, from 00252 bool Translate(std::string &to, const std::string &from); // to, from 00255 std::string Translate(const std::string &from); 00256 00258 std::string GetFromType(); 00260 std::string GetToType(); 00261 }; 00262 00268 class OBAPI OBResidueData : public OBGlobalDataBase 00269 { 00270 int _resnum; 00271 std::vector<std::string> _resname; 00272 std::vector<std::vector<std::string> > _resatoms; 00273 std::vector<std::vector<std::pair<std::string,int> > > _resbonds; 00274 00275 //variables used only temporarily for parsing resdata.txt 00276 std::vector<std::string> _vatmtmp; 00277 std::vector<std::pair<std::string,int> > _vtmp; 00278 public: 00279 00280 OBResidueData(); 00281 void ParseLine(const char*); 00282 00284 unsigned int GetSize() { return _resname.size(); } 00285 00289 bool SetResName(const std::string &); 00292 int LookupBO(const std::string &); 00295 int LookupBO(const std::string &, const std::string&); 00299 bool LookupType(const std::string &,std::string&,int&); 00303 bool AssignBonds(OBMol &,OBBitVec &); 00304 }; 00305 00306 } // end namespace OpenBabel 00307 00308 #endif //DATA_H 00309
This file is part of the documentation for Open Babel, version 2.2.0.