Open Babel  3.0
groupcontrib.h
Go to the documentation of this file.
1 /**********************************************************************
2 groupcontrib.h - Handle group contribution algorithms.
3 
4 Copyright (C) 2007 by Tim Vandermeersch
5  2001-2007 by Stephen Jelfs
6  2001-2007 by Joerg Kurt Wegner, [email protected]
7 
8 Original version: JOELib2, http://joelib.sf.net
9 
10 This file is part of the Open Babel project.
11 For more information, see <http://openbabel.org/>
12 
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation version 2 of the License.
16 
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21 ***********************************************************************/
22 
23 #ifndef OB_GROUPCONTRIB_H
24 #define OB_GROUPCONTRIB_H
25 
26 #include <openbabel/parsmart.h>
27 #include <openbabel/descriptor.h>
28 
29 // This macro is used in DLL builds. If it has not
30 // been set in babelconfig.h, define it as nothing.
31 #ifndef OBDESC
32  #define OBDESC
33 #endif
34 
35 namespace OpenBabel
36 {
37 
45 {
46 public:
47 
53  OBGroupContrib(const char* ID, const char* filename, const char* descr)
55  : OBDescriptor(ID, false), _filename(filename), _descr(descr), _debug(false){}
56 
57  virtual const char* Description();
58 
59  virtual OBGroupContrib* MakeInstance(const std::vector<std::string>& textlines)
60  {
61  return new OBGroupContrib(textlines[1].c_str(),textlines[2].c_str(),textlines[3].c_str());
62  }
63 
64 
65  virtual double Predict(OBBase* pOb, std::string* param=NULL);
66 
67  private:
68  bool ParseFile();
69 
70  const char* _filename;
71  const char* _descr;
72  std::vector<std::pair<OBSmartsPattern*, double> > _contribsHeavy;
73  std::vector<std::pair<OBSmartsPattern*, double> > _contribsHydrogen;
74  bool _debug;
75 };
76 
77 /* The classes OBLogp, OBPSA and OBMR have been replaced by instances of
78 OBGroupContrib with different IDs.
79 So instead of:
80  OBLogp logP;
81  cout << "logP " << logP.Predict(mol) << endl;
82 use:
83  OBDescriptor* pDesc = OBDescriptor::FindType("logP")
84  if(pDesc)
85  cout << "logP " << pDesc->Predict(&mol) << endl;
86 */
87 } // end namespace OpenBabel
88 
89 #endif // OB_GROUPCONTRIB_H
90 
Handle group contribution algorithms.
Definition: groupcontrib.h:44
Base class for molecular descriptors.
virtual OBGroupContrib * MakeInstance(const std::vector< std::string > &textlines)
Definition: groupcontrib.h:59
#define OBDESC
Definition: groupcontrib.h:32
Base class for molecular properties, descriptors or features.
Definition: descriptor.h:34
Base Class.
Definition: base.h:239
Daylight SMARTS parser.
Global namespace for all Open Babel code.
Definition: alias.h:22