00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef OB_DATA_H
00021 #define OB_DATA_H
00022
00023 #include "babelconfig.h"
00024
00025 #include <stdio.h>
00026
00027 #if HAVE_IOSTREAM
00028 #include <iostream>
00029 #elif HAVE_IOSTREAM_H
00030 #include <iostream.h>
00031 #endif
00032
00033 #if HAVE_FSTREAM
00034 #include <fstream>
00035 #elif HAVE_FSTREAM_H
00036 #include <fstream.h>
00037 #endif
00038
00039 #include <vector>
00040 #include <string>
00041
00042 namespace OpenBabel
00043 {
00044
00045 class OBElement;
00046 class OBAtom;
00047 class OBElementTable;
00048
00049 class OBMol;
00050 class OBBitVec;
00051
00060 class OBAPI OBGlobalDataBase
00061 {
00062 protected:
00063 bool _init;
00064 const char *_dataptr;
00065 std::string _filename;
00066 std::string _dir;
00067 std::string _subdir;
00068 std::string _envvar;
00069
00070 public:
00072 OBGlobalDataBase()
00073 {
00074 _init = false;
00075 _dataptr = (char*)NULL;
00076 }
00078 virtual ~OBGlobalDataBase() {}
00080 void Init();
00082 virtual unsigned int GetSize() { return 0;}
00084 void SetReadDirectory(char *dir) { _dir = dir; }
00086 void SetEnvironmentVariable(char *var) { _envvar = var; }
00088 virtual void ParseLine(const char*) {}
00089 };
00090
00094 class OBAPI OBElement
00095 {
00096 int _num;
00097 char _symbol[3];
00098 std::string _name;
00099 double _Rcov,_Rvdw,_mass,_elNeg,_ionize,_elAffinity;
00100 double _red, _green, _blue;
00101 int _maxbonds;
00102 public:
00103 OBElement() {}
00104 OBElement(int num, const char *sym, double rcov, double rvdw,
00105 int maxbo, double mass, double elNeg, double ionize,
00106 double elAffin, double red, double green, double blue,
00107 std::string name) :
00108 _num(num), _name(name), _Rcov(rcov), _Rvdw(rvdw), _mass(mass),
00109 _elNeg(elNeg), _ionize(ionize), _elAffinity(elAffin),
00110 _red(red), _green(green), _blue(blue),
00111 _maxbonds(maxbo)
00112 {
00113 strncpy(_symbol, sym, 3);
00114 }
00115
00117 int GetAtomicNum() { return(_num); }
00119 char *GetSymbol() { return(_symbol); }
00121 double GetCovalentRad() { return(_Rcov); }
00123 double GetVdwRad() { return(_Rvdw); }
00125 double GetMass() { return(_mass); }
00127 int GetMaxBonds() { return(_maxbonds);}
00129 double GetElectroNeg() { return(_elNeg); }
00131 double GetIonization() { return(_ionize); }
00133 double GetElectronAffinity(){ return(_elAffinity); }
00135 std::string GetName() { return(_name); }
00137 double GetRed() { return(_red); }
00139 double GetGreen() { return(_green); }
00141 double GetBlue() { return(_blue); }
00142 };
00143
00144
00145 class OBAPI OBElementTable : public OBGlobalDataBase
00146 {
00147 std::vector<OBElement*> _element;
00148
00149 public:
00150
00151 OBElementTable(void);
00152 ~OBElementTable();
00153
00154 void ParseLine(const char*);
00155
00157 unsigned int GetNumberOfElements();
00158 unsigned int GetSize() { return GetNumberOfElements(); }
00159
00161 int GetAtomicNum(const char *);
00165 int GetAtomicNum(const char *, int &iso);
00167 char *GetSymbol(int);
00169 double GetVdwRad(int);
00171 double GetCovalentRad(int);
00174 double GetMass(int);
00177 double CorrectedBondRad(int,int = 3);
00180 double CorrectedVdwRad(int,int = 3);
00182 int GetMaxBonds(int);
00184 double GetElectroNeg(int);
00186 double GetIonization(int);
00188 double GetElectronAffinity(int);
00190 std::vector<double> GetRGB(int);
00192 std::string GetName(int);
00193 };
00194
00195
00196 class OBAPI OBIsotopeTable : public OBGlobalDataBase
00197 {
00198 std::vector<std::vector<std::pair <unsigned int, double> > > _isotopes;
00199
00200 public:
00201
00202 OBIsotopeTable(void);
00203 ~OBIsotopeTable() {}
00204
00206 unsigned int GetSize() { return _isotopes.size(); }
00207
00208 void ParseLine(const char*);
00211 double GetExactMass(const unsigned int atomicNum,
00212 const unsigned int isotope = 0);
00213 };
00214
00215
00216 class OBAPI OBTypeTable : public OBGlobalDataBase
00217 {
00218 int _linecount;
00219 unsigned int _ncols,_nrows;
00220 int _from,_to;
00221 std::vector<std::string> _colnames;
00222 std::vector<std::vector<std::string> > _table;
00223
00224 public:
00225
00226 OBTypeTable(void);
00227 ~OBTypeTable() {}
00228
00229 void ParseLine(const char*);
00230
00232 unsigned int GetSize() { return _table.size(); }
00233
00235 bool SetFromType(const char*);
00237 bool SetToType(const char*);
00239 bool Translate(char *to, const char *from);
00241 bool Translate(std::string &to, const std::string &from);
00242
00244 std::string GetFromType();
00246 std::string GetToType();
00247 };
00248
00251 class OBAPI OBResidueData : public OBGlobalDataBase
00252 {
00253 int _resnum;
00254 std::vector<std::string> _resname;
00255 std::vector<std::vector<std::string> > _resatoms;
00256 std::vector<std::vector<std::pair<std::string,int> > > _resbonds;
00257
00258
00259 std::vector<std::string> _vatmtmp;
00260 std::vector<std::pair<std::string,int> > _vtmp;
00261 public:
00262
00263 OBResidueData();
00264 void ParseLine(const char*);
00265
00267 unsigned int GetSize() { return _resname.size(); }
00268
00272 bool SetResName(const std::string &);
00275 int LookupBO(const std::string &);
00278 int LookupBO(const std::string &, const std::string&);
00282 bool LookupType(const std::string &,std::string&,int&);
00286 bool AssignBonds(OBMol &,OBBitVec &);
00287 };
00288
00289
00290 #ifdef WIN32
00291 #define FILE_SEP_CHAR "\\"
00292 #else
00293 #define FILE_SEP_CHAR "/"
00294 #endif
00295
00296 }
00297
00298 #endif //DATA_H
00299