Open Babel  3.0
data.h
Go to the documentation of this file.
1 /**********************************************************************
2 data.h - Global data and resource file parsers.
3 
4 Copyright (C) 1998-2001 by OpenEye Scientific Software, Inc.
5 Some portions Copyright (C) 2001-2006 by Geoffrey R. Hutchison
6 
7 This file is part of the Open Babel project.
8 For more information, see <http://openbabel.org/>
9 
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation version 2 of the License.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 ***********************************************************************/
19 
20 #ifndef OB_DATA_H
21 #define OB_DATA_H
22 
23 #include <openbabel/babelconfig.h>
24 
25 #include <stdio.h>
26 #include <cstring>
27 #include <fstream>
28 #include <vector>
29 #include <string>
30 #include <cstring>
31 
32 namespace OpenBabel
33 {
34 
35  class OBAtom;
36  class OBMol;
37 
48  class OBAPI OBGlobalDataBase
49  {
50  protected:
51  bool _init;
52  const char *_dataptr;
53  std::string _filename;
54  std::string _dir;
55  std::string _subdir;
56  std::string _envvar;
57 
58  public:
60  OBGlobalDataBase(): _init(false), _dataptr(NULL) { }
62  virtual ~OBGlobalDataBase() {}
64  void Init();
66  virtual size_t GetSize() { return 0;}
68  void SetReadDirectory(char *dir) { _dir = dir; }
70  void SetEnvironmentVariable(char *var) { _envvar = var; }
72  virtual void ParseLine(const char*) {}
73  };
74 
83  class OBAPI OBAtomHOF
84  {
85  private:
86  std::string _element,_method,_desc,_unit;
87  double _T,_value;
88  int _charge;
89  int _multiplicity;
90 
91  public:
103  OBAtomHOF(std::string element,int charge,
104  std::string method,std::string desc,
105  double T,double value,int multiplicity,
106  std::string unit)
107  {
108  _element = element;
109  _charge = charge;
110  _method = method;
111  _desc = desc;
112  _T = T;
113  _value = value;
114  _multiplicity = multiplicity;
115  _unit = unit;
116  }
117 
121  std::string Element() { return _element; }
123  int Charge() { return _charge; }
125  std::string Method() { return _method; }
127  std::string Desc() { return _desc; }
129  double T() { return _T; }
131  double Value() { return _value; }
133  int Multiplicity() { return _multiplicity; }
135  std::string Unit() { return _unit; }
136  };
137 
150  {
151  std::vector<OBAtomHOF> _atomhof;
152 
153  public:
158 
160  size_t GetSize() { return _atomhof.size(); }
161 
165  void ParseLine(const char*);
178  int GetHeatOfFormation(std::string elem,
179  int charge,
180  std::string method,
181  double T, double *dhof0,
182  double *dhofT,double *S0T);
183  };
184 
185  // class introduction in data.cpp
186  class OBAPI OBTypeTable : public OBGlobalDataBase
187  {
188  int _linecount;
189  unsigned int _ncols,_nrows;
190  int _from,_to;
191  std::vector<std::string> _colnames;
192  std::vector<std::vector<std::string> > _table;
193 
194  public:
195 
196  OBTypeTable(void);
198 
199  void ParseLine(const char*);
200 
202  size_t GetSize() { return _table.size(); }
203 
205  bool SetFromType(const char*);
207  bool SetToType(const char*);
209  bool Translate(char *to, const char *from); // to, from
212  bool Translate(std::string &to, const std::string &from); // to, from
215  std::string Translate(const std::string &from);
216 
218  std::string GetFromType();
220  std::string GetToType();
221  };
222 
226 
232  class OBAPI OBResidueData : public OBGlobalDataBase
233  {
234  int _resnum;
235  std::vector<std::string> _resname;
236  std::vector<std::vector<std::string> > _resatoms;
237  std::vector<std::vector<std::pair<std::string,int> > > _resbonds;
238 
239  //variables used only temporarily for parsing resdata.txt
240  std::vector<std::string> _vatmtmp;
241  std::vector<std::pair<std::string,int> > _vtmp;
242  public:
243 
244  OBResidueData();
245  void ParseLine(const char*);
246 
248  size_t GetSize() { return _resname.size(); }
249 
253  bool SetResName(const std::string &);
256  int LookupBO(const std::string &);
259  int LookupBO(const std::string &, const std::string&);
263  bool LookupType(const std::string &,std::string&,int&);
266  bool AssignBonds(OBMol &);
267  };
268 
271 
272 
273 } // end namespace OpenBabel
274 
275 #endif //DATA_H
276 
Atomic Heat of Formation Table.
Definition: data.h:149
Definition: residue.h:336
size_t GetSize()
Definition: data.h:248
void SetEnvironmentVariable(char *var)
Set the environment variable to use before calling Init()
Definition: data.h:70
~OBAtomicHeatOfFormationTable()
Destructor.
Definition: data.h:157
std::string Method()
Return the method used for the measurement/calculation.
Definition: data.h:125
Molecule Class.
Definition: mol.h:118
int Charge()
Return the formal charge.
Definition: data.h:123
~OBAtomHOF()
Destructor.
Definition: data.h:119
OBGlobalDataBase()
Constructor.
Definition: data.h:60
virtual void ParseLine(const char *)
Specified by particular table classes (parses an individual data line)
Definition: data.h:72
void SetReadDirectory(char *dir)
Set the directory before calling Init()
Definition: data.h:68
std::string _subdir
Subdirectory (if using environment variable)
Definition: data.h:55
std::string _filename
File to search for.
Definition: data.h:53
Atom Type Translation Table.
Definition: data.h:186
OBTypeTable ttab
Definition: data.h:225
std::string Unit()
Return the (energy) unit.
Definition: data.h:135
size_t GetSize()
Definition: data.h:202
virtual ~OBGlobalDataBase()
Destructor.
Definition: data.h:62
~OBTypeTable()
Definition: data.h:197
bool _init
Whether the data been read already.
Definition: data.h:51
size_t GetSize()
Definition: data.h:160
const char * _dataptr
Default data table if file is unreadable.
Definition: data.h:52
std::string Desc()
Return specification of the measurement/calculation type.
Definition: data.h:127
Table of common biomolecule residues (for PDB or other files).
Definition: data.h:232
std::string _dir
Data directory for file if _envvar fails.
Definition: data.h:54
std::string _envvar
Environment variable to check first.
Definition: data.h:56
double T()
Return the temperature.
Definition: data.h:129
virtual size_t GetSize()
Definition: data.h:66
helper class for OBAtomicHeatOfFormationTable
Definition: data.h:83
int Multiplicity()
Return the multiplicity.
Definition: data.h:133
OBResidueData resdat
Global OBResidueData biomolecule residue database.
Definition: data.h:270
double Value()
Return the (energy) value.
Definition: data.h:131
OBAtomHOF(std::string element, int charge, std::string method, std::string desc, double T, double value, int multiplicity, std::string unit)
Initialize Heat of Formation for atom.
Definition: data.h:103
Base data table class, handles reading data files.
Definition: data.h:48
std::string Element()
Return the chemical element.
Definition: data.h:121
Global namespace for all Open Babel code.
Definition: alias.h:22