RDKit
Open-source cheminformatics and machine learning.
GasteigerParams.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2003-2015 Rational Discovery LLC
3 //
4 // @@ All Rights Reserved @@
5 // This file is part of the RDKit.
6 // The contents are covered by the terms of the BSD license
7 // which is included in the file license.txt, found at the root
8 // of the RDKit source tree.
9 //
10 #ifndef _RD_GASTEIGERPARAMS_H
11 #define _RD_GASTEIGERPARAMS_H
12 
13 #include <RDGeneral/types.h>
14 #include <RDGeneral/Exceptions.h>
15 #include <string>
16 #include <map>
17 
18 namespace RDKit {
19 extern std::string paramData;
20 extern std::string additionalParamData;
21 
22 // this is a constant used during the iteration procedure for the hydrogen atoms
23 // for the remaining atoms it is computed on the fly
24 const double IONXH = 20.02;
25 
26 const double DAMP_SCALE = 0.5;
27 const double DAMP = 0.5;
28 
30  /* \brief Container for all the partial charge paramters
31  *
32  * It is filled by the paramData string defined in GasteigerParams.cpp
33  * The main data member is a STL map that take a pair<std::string,
34  *std::string>
35  * of element name and mode (hybridization or bonding mode) and return a
36  *vector
37  * of three parameters, used int eh ierative partial charges euqlization
38  *procedure
39  */
40 
41  public:
42  static const GasteigerParams *getParams(const std::string &paramData = "");
43 
44  ~GasteigerParams() { d_paramMap.clear(); }
45 
46  DOUBLE_VECT getParams(std::string elem, std::string mode,
47  bool throwOnFailure = false) const {
48  std::pair<std::string, std::string> query(elem, mode);
49  std::map<std::pair<std::string, std::string>, DOUBLE_VECT>::const_iterator
50  iter;
51  iter = d_paramMap.find(query);
52  if (iter != d_paramMap.end()) {
53  return iter->second;
54  } else {
55  if (throwOnFailure) {
56  std::string message =
57  "ERROR: No Gasteiger Partial Charge parameters for Element: ";
58  message += elem;
59  message += " Mode: ";
60  message += mode;
61  throw ValueErrorException(message);
62  } else {
63  iter =
64  d_paramMap.find(std::make_pair(std::string("X"), std::string("*")));
65  if (iter != d_paramMap.end()) {
66  return iter->second;
67  } else {
68  std::string message =
69  "ERROR: Default Gasteiger Partial Charge parameters are missing";
70  throw ValueErrorException(message);
71  }
72  }
73  }
74  }
75 
76  GasteigerParams(std::string paramData = "");
77 
78  private:
79  std::map<std::pair<std::string, std::string>, DOUBLE_VECT> d_paramMap;
80 
81  static class GasteigerParams *ds_instance;
82 };
83 };
84 
85 #endif
static const GasteigerParams * getParams(const std::string &paramData="")
std::vector< double > DOUBLE_VECT
Definition: types.h:216
std::string additionalParamData
const double DAMP
std::string paramData
Std stuff.
Definition: Atom.h:29
const double IONXH
GasteigerParams(std::string paramData="")
const double DAMP_SCALE
Class to allow us to throw a ValueError from C++ and have it make it back to Python.
Definition: Exceptions.h:32
DOUBLE_VECT getParams(std::string elem, std::string mode, bool throwOnFailure=false) const