RDKit: types.h Source File

| RDKit Open-source cheminformatics and machine learning.

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

types.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2016 Greg Landrum and 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
11 #ifndef RD_TYPES_H
12 #define RD_TYPES_H
13
14 #ifdef WIN32
15 #define _USE_MATH_DEFINES
16 #endif
17
18 #include <cmath>
19
20 #include <RDGeneral/Invariant.h>
21 #include "Dict.h"
22
23 namespace detail {
24 // used in various places for computed properties
25 const std::string computedPropName = "__computedProps";
26 }
27
28 #include <vector>
29 #include <deque>
30 #include <map>
31 #include <set>
32 #include <string>
33 #include <algorithm>
34 #include <numeric>
35 #include <list>
36 #include <limits>
37
38 #include <cstring>
39
40 #include <boost/any.hpp>
41 #include <boost/lexical_cast.hpp>
42
43 namespace RDKit {
44 namespace common_properties {
45 extern const std::string TWOD;
46 extern const std::string BalabanJ;
47 extern const std::string BalanbanJ;
48 extern const std::string Discrims;
49 extern const std::string DistanceMatrix_Paths;
50 extern const std::string MolFileComments;
51 extern const std::string MolFileInfo;
52 extern const std::string NullBond;
53 extern const std::string _2DConf;
54 extern const std::string _3DConf;
55 extern const std::string _AtomID;
56 extern const std::string _BondsPotentialStereo;
57 extern const std::string _CIPCode;
58 extern const std::string _CIPRank;
59 extern const std::string _ChiralityPossible;
60 extern const std::string _CrippenLogP;
61 extern const std::string _CrippenMR;
62 extern const std::string _MMFFSanitized;
63 extern const std::string _MolFileChiralFlag;
64 extern const std::string _MolFileRLabel;
65 extern const std::string _Name;
66 extern const std::string _NeedsQueryScan;
67 extern const std::string _QueryFormalCharge;
68 extern const std::string _QueryHCount;
69 extern const std::string _QueryIsotope;
70 extern const std::string _QueryMass;
71 extern const std::string _ReactionDegreeChanged;
72 extern const std::string _RingClosures;
73 extern const std::string _SLN_s;
74 extern const std::string _SmilesStart;
75 extern const std::string _StereochemDone;
76 extern const std::string _TraversalBondIndexOrder;
77 extern const std::string _TraversalRingClosureBond;
78 extern const std::string _TriposAtomType;
79 extern const std::string _Unfinished_SLN_;
80 extern const std::string _UnknownStereo;
81 extern const std::string _connectivityHKDeltas;
82 extern const std::string _connectivityNVals;
83 extern const std::string _crippenLogP;
84 extern const std::string _crippenLogPContribs;
85 extern const std::string _crippenMR;
86 extern const std::string _crippenMRContribs;
87 extern const std::string _doIsoSmiles;
88 extern const std::string _fragSMARTS;
89 extern const std::string _hasMassQuery;
90 extern const std::string _labuteASA;
91 extern const std::string _labuteAtomContribs;
92 extern const std::string _labuteAtomHContrib;
93 extern const std::string _protected;
94 extern const std::string _queryRootAtom;
95 extern const std::string _ringStereoAtoms;
96 extern const std::string _ringStereoWarning;
97 extern const std::string _ringStereochemCand;
98 extern const std::string _smilesAtomOutputOrder;
99 extern const std::string _starred;
100 extern const std::string _supplementalSmilesLabel;
101 extern const std::string _tpsa;
102 extern const std::string _tpsaAtomContribs;
103 extern const std::string _unspecifiedOrder;
104 extern const std::string _brokenChirality;
105 extern const std::string _rgroupAtomMaps;
106 extern const std::string _rgroupBonds;
107 extern const std::string dummyLabel;
108 extern const std::string extraRings;
109 extern const std::string isImplicit;
110 extern const std::string maxAttachIdx;
111 extern const std::string molAtomMapNumber;
112 extern const std::string molFileAlias;
113 extern const std::string molFileValue;
114 extern const std::string molInversionFlag;
115 extern const std::string molParity;
116 extern const std::string molRxnComponent;
117 extern const std::string molRxnRole;
118 extern const std::string molTotValence;
119 extern const std::string numArom;
120 extern const std::string origNoImplicit;
121 extern const std::string ringMembership;
122 extern const std::string smilesSymbol;
123 } // end common_properties
124 #ifndef WIN32
125 typedef long long int LONGINT;
126 #else
127 typedef __int64 LONGINT;
128 #endif
129 #ifdef max
130 #undef max // FUCK I hate this nonsense
131 #endif
132 #ifdef min
133 #undef min // FUCK I hate this nonsense
134 #endif
135
136 extern const double MAX_DOUBLE;
137 extern const double EPS_DOUBLE;
138 extern const double SMALL_DOUBLE;
139 extern const double MAX_INT;
140 extern const double MAX_LONGINT;
141
142 typedef unsigned int UINT;
143 typedef unsigned short USHORT;
144 typedef unsigned char UCHAR;
145
146 typedef std::vector<int> INT_VECT;
147 typedef INT_VECT::iterator INT_VECT_I;
148 typedef INT_VECT::const_iterator INT_VECT_CI;
149 typedef INT_VECT::reverse_iterator INT_VECT_RI;
150 typedef INT_VECT::const_reverse_iterator INT_VECT_CRI;
151
152 typedef std::list<int> INT_LIST;
153 typedef INT_LIST::iterator INT_LIST_I;
154 typedef INT_LIST::const_iterator INT_LIST_CI;
155
156 typedef std::list<INT_VECT> LIST_INT_VECT;
157 typedef LIST_INT_VECT::iterator LIST_INT_VECT_I;
158 typedef LIST_INT_VECT::const_iterator LIST_INT_VECT_CI;
159
160 typedef std::vector<INT_VECT> VECT_INT_VECT;
161 typedef VECT_INT_VECT::iterator VECT_INT_VECT_I;
162 typedef VECT_INT_VECT::const_iterator VECT_INT_VECT_CI;
163
164 typedef std::vector<UINT>::const_iterator UINT_VECT_CI;
165 typedef std::vector<UINT> UINT_VECT;
166
167 typedef std::vector<std::string>::const_iterator STR_VECT_CI;
168 typedef std::vector<std::string>::iterator STR_VECT_I;
169 typedef std::vector<std::string> STR_VECT;
170
171 typedef std::vector<double> DOUBLE_VECT;
172 typedef DOUBLE_VECT::iterator DOUBLE_VECT_I;
173 typedef DOUBLE_VECT::const_iterator DOUBLE_VECT_CI;
174 typedef std::vector<DOUBLE_VECT> VECT_DOUBLE_VECT;
175 typedef VECT_DOUBLE_VECT::iterator VECT_DOUBLE_VECT_I;
176 typedef VECT_DOUBLE_VECT::const_iterator VECT_DOUBLE_VECT_CI;
177
178 typedef std::map<std::string, UINT> STR_UINT_MAP;
179 typedef std::map<std::string, UINT>::const_iterator STR_UINT_MAP_CI;
180
181 typedef std::map<int, INT_VECT> INT_INT_VECT_MAP;
182 typedef INT_INT_VECT_MAP::const_iterator INT_INT_VECT_MAP_CI;
183
184 typedef std::map<int, int> INT_MAP_INT;
185 typedef INT_MAP_INT::iterator INT_MAP_INT_I;
186 typedef INT_MAP_INT::const_iterator INT_MAP_INT_CI;
187
188 typedef std::deque<int> INT_DEQUE;
189 typedef INT_DEQUE::iterator INT_DEQUE_I;
190 typedef INT_DEQUE::const_iterator INT_DEQUE_CI;
191
192 typedef std::map<int, INT_DEQUE> INT_INT_DEQ_MAP;
193 typedef INT_INT_DEQ_MAP::const_iterator INT_INT_DEQ_MAP_CI;
194
195 typedef std::set<int> INT_SET;
196 typedef INT_SET::iterator INT_SET_I;
197 typedef INT_SET::const_iterator INT_SET_CI;
198
199 //! functor to compare two doubles with a tolerance
200 struct ltDouble {
201 public:
202 ltDouble() : _tol(1.0e-8){};
203 bool operator()(double d1, double d2) const {
204 if (fabs(d1 - d2) < _tol) {
205 return false;
206 } else {
207 return (d1 < d2);
208 }
209 }
210
211 private:
212 double _tol;
213 };
214
215 //! std::map from double to integer.
216 typedef std::map<double, int, ltDouble> DOUBLE_INT_MAP;
217
218 //! functor for returning the larger of two values
219 template <typename T>
220 struct larger_of {
221 T operator()(T arg1, T arg2) { return arg1 > arg2 ? arg1 : arg2; };
222 };
223
224 //! functor for comparing two strings
225 struct charptr_functor {
226 bool operator()(const char *s1, const char *s2) const {
227 // std::cout << s1 << " " << s2 << " " << strcmp(s1, s2) << "\n";
228
229 return strcmp(s1, s2) < 0;
230 };
231 };
232
233 //! \brief calculate the union of two INT_VECTs and put the results in a
234 //! third vector
235 void Union(const INT_VECT &r1, const INT_VECT &r2, INT_VECT &res);
236
237 //! \brief calculate the intersection of two INT_VECTs and put the results in a
238 //! third vector
239 void Intersect(const INT_VECT &r1, const INT_VECT &r2, INT_VECT &res);
240
241 //! calculating the union of the INT_VECT's in a VECT_INT_VECT
242 /*!
243 \param rings the INT_VECT's to consider
244 \param res used to return results
245 \param exclude any values in this optional INT_VECT will be excluded
246 from the union.
247 */
248 void Union(const VECT_INT_VECT &rings, INT_VECT &res,
249 const INT_VECT *exclude = NULL);
250
251 //! given a current combination of numbers change it to the next possible
252 // combination
253 /*!
254 \param comb the <b>sorted</b> vector to consider
255 \param tot the maximum number possible in the vector
256
257 \return -1 on failure, the index of the last number changed on success.
258 Example:
259 for all combinations 3 of numbers between 0 and tot=5
260 given (0,1,2) the function wil return (0,1,3) etc.
261
262
263 */
264 int nextCombination(INT_VECT &comb, int tot);
265
266 //! rounds a value to the closest int
267 double round(double v);
268
269 }; // end of namespace
270
271 #endif
RDKit::common_properties::_StereochemDone
const std::string _StereochemDone
RDKit::ltDouble::ltDouble
ltDouble()
Definition: types.h:202
RDKit::common_properties::_protected
const std::string _protected
RDKit::INT_LIST
std::list< int > INT_LIST
Definition: types.h:152
RDKit::USHORT
unsigned short USHORT
Definition: types.h:143
RDKit::common_properties::isImplicit
const std::string isImplicit
RDKit::common_properties::origNoImplicit
const std::string origNoImplicit
RDKit::Union
void Union(const INT_VECT &r1, const INT_VECT &r2, INT_VECT &res)
calculate the union of two INT_VECTs and put the results in a third vector
RDKit::VECT_DOUBLE_VECT_I
VECT_DOUBLE_VECT::iterator VECT_DOUBLE_VECT_I
Definition: types.h:175
RDKit::DOUBLE_VECT_CI
DOUBLE_VECT::const_iterator DOUBLE_VECT_CI
Definition: types.h:173
RDKit::common_properties::_labuteAtomHContrib
const std::string _labuteAtomHContrib
RDKit::common_properties::_connectivityNVals
const std::string _connectivityNVals
RDKit::common_properties::_rgroupAtomMaps
const std::string _rgroupAtomMaps
RDKit::VECT_INT_VECT_I
VECT_INT_VECT::iterator VECT_INT_VECT_I
Definition: types.h:161
RDKit::common_properties::_3DConf
const std::string _3DConf
RDKit::common_properties::_RingClosures
const std::string _RingClosures
RDKit::ltDouble
functor to compare two doubles with a tolerance
Definition: types.h:200
RDKit::MAX_INT
const double MAX_INT
RDKit::round
double round(double v)
rounds a value to the closest int
RDKit::common_properties::_labuteASA
const std::string _labuteASA
RDKit::common_properties::_crippenLogP
const std::string _crippenLogP
RDKit::common_properties::_unspecifiedOrder
const std::string _unspecifiedOrder
RDKit::STR_UINT_MAP_CI
std::map< std::string, UINT >::const_iterator STR_UINT_MAP_CI
Definition: types.h:179
RDKit::common_properties::BalabanJ
const std::string BalabanJ
RDKit::UINT_VECT_CI
std::vector< UINT >::const_iterator UINT_VECT_CI
Definition: types.h:164
RDKit::common_properties::_QueryMass
const std::string _QueryMass
RDKit::common_properties::MolFileInfo
const std::string MolFileInfo
RDKit::DOUBLE_VECT
std::vector< double > DOUBLE_VECT
Definition: types.h:171
RDKit::common_properties::_SLN_s
const std::string _SLN_s
RDKit::common_properties::molTotValence
const std::string molTotValence
RDKit::common_properties::_UnknownStereo
const std::string _UnknownStereo
RDKit::common_properties::TWOD
const std::string TWOD
RDKit::INT_MAP_INT_CI
INT_MAP_INT::const_iterator INT_MAP_INT_CI
Definition: types.h:186
Invariant.h
RDKit::common_properties::_ReactionDegreeChanged
const std::string _ReactionDegreeChanged
RDKit::common_properties::_ringStereoWarning
const std::string _ringStereoWarning
RDKit::larger_of::operator()
T operator()(T arg1, T arg2)
Definition: types.h:221
RDKit::INT_SET_I
INT_SET::iterator INT_SET_I
Definition: types.h:196
RDKit::MAX_DOUBLE
const double MAX_DOUBLE
RDKit::ltDouble::operator()
bool operator()(double d1, double d2) const
Definition: types.h:203
RDKit::common_properties::_Name
const std::string _Name
RDKit::common_properties::molAtomMapNumber
const std::string molAtomMapNumber
RDKit::UCHAR
unsigned char UCHAR
Definition: types.h:144
RDKit::common_properties::molParity
const std::string molParity
RDKit::INT_DEQUE_CI
INT_DEQUE::const_iterator INT_DEQUE_CI
Definition: types.h:190
RDKit::common_properties::NullBond
const std::string NullBond
RDKit::INT_LIST_I
INT_LIST::iterator INT_LIST_I
Definition: types.h:153
RDKit::VECT_DOUBLE_VECT
std::vector< DOUBLE_VECT > VECT_DOUBLE_VECT
Definition: types.h:174
RDKit::VECT_DOUBLE_VECT_CI
VECT_DOUBLE_VECT::const_iterator VECT_DOUBLE_VECT_CI
Definition: types.h:176
RDKit::DOUBLE_VECT_I
DOUBLE_VECT::iterator DOUBLE_VECT_I
Definition: types.h:172
RDKit::INT_INT_DEQ_MAP_CI
INT_INT_DEQ_MAP::const_iterator INT_INT_DEQ_MAP_CI
Definition: types.h:193
RDKit::common_properties::MolFileComments
const std::string MolFileComments
RDKit::common_properties::_2DConf
const std::string _2DConf
RDKit::common_properties::extraRings
const std::string extraRings
Dict.h
Defines the Dict class.
RDKit::common_properties::_Unfinished_SLN_
const std::string _Unfinished_SLN_
RDKit::common_properties::_supplementalSmilesLabel
const std::string _supplementalSmilesLabel
RDKit::common_properties::_crippenMRContribs
const std::string _crippenMRContribs
RDKit::common_properties::maxAttachIdx
const std::string maxAttachIdx
RDKit::INT_SET_CI
INT_SET::const_iterator INT_SET_CI
Definition: types.h:197
RDKit::common_properties::_smilesAtomOutputOrder
const std::string _smilesAtomOutputOrder
RDKit::larger_of
functor for returning the larger of two values
Definition: types.h:220
RDKit::common_properties::_fragSMARTS
const std::string _fragSMARTS
RDKit::INT_MAP_INT_I
INT_MAP_INT::iterator INT_MAP_INT_I
Definition: types.h:185
RDKit::common_properties::_CIPRank
const std::string _CIPRank
RDKit::common_properties::dummyLabel
const std::string dummyLabel
RDKit::common_properties::_labuteAtomContribs
const std::string _labuteAtomContribs
RDKit::INT_VECT_CRI
INT_VECT::const_reverse_iterator INT_VECT_CRI
Definition: types.h:150
RDKit::VECT_INT_VECT
std::vector< INT_VECT > VECT_INT_VECT
Definition: types.h:160
RDKit::common_properties::_tpsa
const std::string _tpsa
RDKit::LONGINT
long long int LONGINT
Definition: types.h:125
detail
Definition: types.h:23
RDKit::common_properties::_TraversalBondIndexOrder
const std::string _TraversalBondIndexOrder
RDKit::charptr_functor
functor for comparing two strings
Definition: types.h:225
RDKit::common_properties::_queryRootAtom
const std::string _queryRootAtom
RDKit::STR_UINT_MAP
std::map< std::string, UINT > STR_UINT_MAP
Definition: types.h:178
RDKit::common_properties::BalanbanJ
const std::string BalanbanJ
RDKit::common_properties::_starred
const std::string _starred
RDKit::INT_VECT
std::vector< int > INT_VECT
Definition: types.h:146
RDKit::common_properties::_MMFFSanitized
const std::string _MMFFSanitized
RDKit::INT_SET
std::set< int > INT_SET
Definition: types.h:195
RDKit::INT_VECT_RI
INT_VECT::reverse_iterator INT_VECT_RI
Definition: types.h:149
RDKit::STR_VECT_CI
std::vector< std::string >::const_iterator STR_VECT_CI
Definition: types.h:167
RDKit::common_properties::_QueryIsotope
const std::string _QueryIsotope
RDKit::charptr_functor::operator()
bool operator()(const char *s1, const char *s2) const
Definition: types.h:226
RDKit::common_properties::molRxnRole
const std::string molRxnRole
RDKit::common_properties::_CIPCode
const std::string _CIPCode
RDKit
Includes a bunch of functionality for handling Atom and Bond queries.
Definition: Atom.h:28
RDKit::UINT
unsigned int UINT
Definition: types.h:142
RDKit::common_properties::molRxnComponent
const std::string molRxnComponent
RDKit::INT_VECT_I
INT_VECT::iterator INT_VECT_I
Definition: types.h:147
RDKit::LIST_INT_VECT_I
LIST_INT_VECT::iterator LIST_INT_VECT_I
Definition: types.h:157
RDKit::common_properties::molInversionFlag
const std::string molInversionFlag
RDKit::INT_VECT_CI
INT_VECT::const_iterator INT_VECT_CI
Definition: types.h:148
RDKit::common_properties::smilesSymbol
const std::string smilesSymbol
detail::computedPropName
const std::string computedPropName
Definition: types.h:25
RDKit::VECT_INT_VECT_CI
VECT_INT_VECT::const_iterator VECT_INT_VECT_CI
Definition: types.h:162
RDKit::common_properties::_QueryHCount
const std::string _QueryHCount
RDKit::common_properties::_NeedsQueryScan
const std::string _NeedsQueryScan
RDKit::DOUBLE_INT_MAP
std::map< double, int, ltDouble > DOUBLE_INT_MAP
std::map from double to integer.
Definition: types.h:216
RDKit::common_properties::numArom
const std::string numArom
RDKit::common_properties::_ringStereoAtoms
const std::string _ringStereoAtoms
RDKit::INT_DEQUE_I
INT_DEQUE::iterator INT_DEQUE_I
Definition: types.h:189
RDKit::common_properties::_rgroupBonds
const std::string _rgroupBonds
RDKit::INT_MAP_INT
std::map< int, int > INT_MAP_INT
Definition: types.h:184
RDKit::common_properties::_BondsPotentialStereo
const std::string _BondsPotentialStereo
RDKit::common_properties::ringMembership
const std::string ringMembership
RDKit::common_properties::_MolFileChiralFlag
const std::string _MolFileChiralFlag
RDKit::LIST_INT_VECT
std::list< INT_VECT > LIST_INT_VECT
Definition: types.h:156
RDKit::common_properties::_AtomID
const std::string _AtomID
RDKit::INT_LIST_CI
INT_LIST::const_iterator INT_LIST_CI
Definition: types.h:154
RDKit::common_properties::_QueryFormalCharge
const std::string _QueryFormalCharge
RDKit::Intersect
void Intersect(const INT_VECT &r1, const INT_VECT &r2, INT_VECT &res)
calculate the intersection of two INT_VECTs and put the results in a third vector ...
RDKit::common_properties::_crippenMR
const std::string _crippenMR
RDKit::common_properties::_MolFileRLabel
const std::string _MolFileRLabel
RDKit::common_properties::molFileValue
const std::string molFileValue
RDKit::common_properties::Discrims
const std::string Discrims
RDKit::INT_INT_DEQ_MAP
std::map< int, INT_DEQUE > INT_INT_DEQ_MAP
Definition: types.h:192
RDKit::INT_INT_VECT_MAP
std::map< int, INT_VECT > INT_INT_VECT_MAP
Definition: types.h:181
RDKit::common_properties::_hasMassQuery
const std::string _hasMassQuery
RDKit::UINT_VECT
std::vector< UINT > UINT_VECT
Definition: types.h:165
RDKit::SMALL_DOUBLE
const double SMALL_DOUBLE
RDKit::common_properties::DistanceMatrix_Paths
const std::string DistanceMatrix_Paths
RDKit::INT_INT_VECT_MAP_CI
INT_INT_VECT_MAP::const_iterator INT_INT_VECT_MAP_CI
Definition: types.h:182
RDKit::INT_DEQUE
std::deque< int > INT_DEQUE
Definition: types.h:188
RDKit::common_properties::_crippenLogPContribs
const std::string _crippenLogPContribs
RDKit::EPS_DOUBLE
const double EPS_DOUBLE
RDKit::common_properties::_TraversalRingClosureBond
const std::string _TraversalRingClosureBond
RDKit::common_properties::_ChiralityPossible
const std::string _ChiralityPossible
RDKit::STR_VECT_I
std::vector< std::string >::iterator STR_VECT_I
Definition: types.h:168
RDKit::common_properties::_ringStereochemCand
const std::string _ringStereochemCand
RDKit::MAX_LONGINT
const double MAX_LONGINT
RDKit::common_properties::_TriposAtomType
const std::string _TriposAtomType
RDKit::LIST_INT_VECT_CI
LIST_INT_VECT::const_iterator LIST_INT_VECT_CI
Definition: types.h:158
RDKit::common_properties::_connectivityHKDeltas
const std::string _connectivityHKDeltas
RDKit::common_properties::_CrippenMR
const std::string _CrippenMR
RDKit::common_properties::_tpsaAtomContribs
const std::string _tpsaAtomContribs
RDKit::nextCombination
int nextCombination(INT_VECT &comb, int tot)
given a current combination of numbers change it to the next possible
RDKit::common_properties::_CrippenLogP
const std::string _CrippenLogP
RDKit::common_properties::_brokenChirality
const std::string _brokenChirality
RDKit::STR_VECT
std::vector< std::string > STR_VECT
Definition: Dict.h:26
RDKit::common_properties::molFileAlias
const std::string molFileAlias
RDKit::common_properties::_SmilesStart
const std::string _SmilesStart
RDKit::common_properties::_doIsoSmiles
const std::string _doIsoSmiles