/src/openbabel/include/openbabel/groupcontrib.h
Line | Count | Source |
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, me@cheminformatics.eu |
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 | | |
38 | | /** \class OBGroupContrib groupcontrib.h <openbabel/groupcontrib.h> |
39 | | \brief Handle group contribution algorithms. |
40 | | |
41 | | This is the base class for calculations that use the JOELib2 contribution |
42 | | algorithm. |
43 | | */ |
44 | | class OBDESC OBGroupContrib : public OBDescriptor |
45 | | { |
46 | | public: |
47 | | |
48 | | /*! Predict the logP, MR, TPSA (each instance of OBGroupContrib |
49 | | * uses different parameters loaded from its own datafile) for |
50 | | * molecule mol using the group contributions algorithm from JOELib2. |
51 | | */ |
52 | | |
53 | | //! constructor. Each instance provides an ID and a datafile. |
54 | | OBGroupContrib(const char* ID, const char* filename, const char* descr) |
55 | 6 | : OBDescriptor(ID, false), _filename(filename), _descr(descr), _debug(false){} |
56 | | |
57 | | virtual ~OBGroupContrib(); |
58 | | |
59 | | const char* Description() override; |
60 | | |
61 | | virtual OBGroupContrib* MakeInstance(const std::vector<std::string>& textlines) override |
62 | 0 | { |
63 | 0 | return new OBGroupContrib(textlines[1].c_str(),textlines[2].c_str(),textlines[3].c_str()); |
64 | 0 | } |
65 | | |
66 | | double Predict(OBBase* pOb, std::string* param=nullptr) override; |
67 | | |
68 | | private: |
69 | | bool ParseFile(); |
70 | | |
71 | | const char* _filename; |
72 | | const char* _descr; |
73 | | std::vector<std::pair<OBSmartsPattern*, double> > _contribsHeavy; //! heavy atom contributions |
74 | | std::vector<std::pair<OBSmartsPattern*, double> > _contribsHydrogen; //! hydrogen contributions |
75 | | bool _debug; |
76 | | }; |
77 | | |
78 | | /* The classes OBLogp, OBPSA and OBMR have been replaced by instances of |
79 | | OBGroupContrib with different IDs. |
80 | | So instead of: |
81 | | OBLogp logP; |
82 | | cout << "logP " << logP.Predict(mol) << endl; |
83 | | use: |
84 | | OBDescriptor* pDesc = OBDescriptor::FindType("logP") |
85 | | if(pDesc) |
86 | | cout << "logP " << pDesc->Predict(&mol) << endl; |
87 | | */ |
88 | | } // end namespace OpenBabel |
89 | | |
90 | | #endif // OB_GROUPCONTRIB_H |
91 | | |
92 | | //! \file groupcontrib.h |
93 | | //! \brief Handle group contribution algorithms. |