1 //
2 // Copyright 2001-2018 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
12 #include "types.h"
13
14 namespace RDKit {
15 namespace detail {
16 const std::string computedPropName = "__computedProps";
17 }
18
19 namespace common_properties {
20 const std::string TWOD = "2D";
21 const std::string BalabanJ = "BalabanJ";
22 const std::string BalanbanJ = "BalanbanJ";
23 const std::string Discrims = "Discrims";
24 const std::string DistanceMatrix_Paths = "DistanceMatrix_Paths";
25 const std::string MolFileComments = "MolFileComments";
26 const std::string MolFileInfo = "MolFileInfo";
27 const std::string NullBond = "NullBond";
28 const std::string _2DConf = "_2DConf";
29 const std::string _3DConf = "_3DConf";
30 const std::string _AtomID = "_AtomID";
31 const std::string _BondsPotentialStereo = "_BondsPotentialStereo";
32 const std::string _CIPCode = "_CIPCode";
33 const std::string _CIPRank = "_CIPRank";
34 const std::string _ChiralityPossible = "_ChiralityPossible";
35 const std::string _CrippenLogP = "_CrippenLogP";
36 const std::string _CrippenMR = "_CrippenMR";
37 const std::string _MMFFSanitized = "_MMFFSanitized";
38 const std::string _MolFileChiralFlag = "_MolFileChiralFlag";
39 const std::string MRV_SMA = "MRV SMA";
40 const std::string _MolFileRLabel = "_MolFileRLabel";
41 const std::string _MolFileAtomQuery = "_MolFileAtomQuery";
42 const std::string _MolFileBondQuery = "_MolFileBondQuery";
43 const std::string _MolFileBondEndPts = "_MolFileBondEndPts";
44 const std::string _MolFileBondAttach = "_MolFileBondAttach";
45 const std::string _MolFileBondType = "_MolFileBondType";
46 const std::string _MolFileBondStereo = "_MolFileBondStereo";
47 const std::string _MolFileBondCfg = "_MolFileBondCfg";
48
49 const std::string _Name = "_Name";
50 const std::string _NeedsQueryScan = "_NeedsQueryScan";
51 const std::string _QueryFormalCharge = "_QueryFormalCharge";
52 const std::string _QueryHCount = "_QueryHCount";
53 const std::string _QueryIsotope = "_QueryIsotope";
54 const std::string _QueryMass = "_QueryMass";
55 const std::string _ReactionDegreeChanged = "_ReactionDegreeChanged";
56 const std::string reactantAtomIdx = "react_atom_idx";
57 const std::string reactionMapNum = "old_mapno";
58
59 const std::string _RingClosures = "_RingClosures";
60 const std::string _SLN_s = "_SLN_s";
61 const std::string _SmilesStart = "_SmilesStart";
62 const std::string _StereochemDone = "_StereochemDone";
63 const std::string _TraversalBondIndexOrder = "_TraversalBondIndexOrder";
64 const std::string _TraversalRingClosureBond = "_TraversalRingClosureBond";
65 const std::string _TraversalStartPoint = "_TraversalStartPoint";
66 const std::string _TriposAtomType = "_TriposAtomType";
67 const std::string _Unfinished_SLN_ = "_Unfinished_SLN_";
68 const std::string _UnknownStereo = "_UnknownStereo";
69 const std::string _connectivityHKDeltas = "_connectivityHKDeltas";
70 const std::string _connectivityNVals = "_connectivityNVals";
71 const std::string _crippenLogP = "_crippenLogP";
72 const std::string _crippenLogPContribs = "_crippenLogPContribs";
73 const std::string _crippenMR = "_crippenMR";
74 const std::string _crippenMRContribs = "_crippenMRContribs";
75 const std::string _GasteigerCharge = "_GasteigerCharge";
76 const std::string _GasteigerHCharge = "_GasteigerHCharge";
77 const std::string _doIsoSmiles = "_doIsoSmiles";
78 const std::string _fragSMARTS = "_fragSMARTS";
79 const std::string _hasMassQuery = "_hasMassQuery";
80 const std::string _labuteASA = "_labuteASA";
81 const std::string _labuteAtomContribs = "_labuteAtomContribs";
82 const std::string _labuteAtomHContrib = "_labuteAtomHContrib";
83 const std::string _protected = "_protected";
84 const std::string _queryRootAtom = "_queryRootAtom";
85 const std::string _ringStereoAtoms = "_ringStereoAtoms";
86 const std::string _ringStereoWarning = "_ringStereoWarning";
87 const std::string _ringStereochemCand = "_ringStereochemCand";
88 const std::string _smilesAtomOutputOrder = "_smilesAtomOutputOrder";
89 const std::string _starred = "_starred";
90 const std::string _supplementalSmilesLabel = "_supplementalSmilesLabel";
91 const std::string _tpsa = "_tpsa";
92 const std::string _tpsaAtomContribs = "_tpsaAtomContribs";
93 const std::string _unspecifiedOrder = "_unspecifiedOrder";
94 const std::string _brokenChirality = "_brokenChirality";
95 const std::string _rgroupAtomMaps = "_rgroupAtomMaps";
96 const std::string _rgroupBonds = "_rgroupBonds";
97 const std::string dummyLabel = "dummyLabel";
98 const std::string extraRings = "extraRings";
99 const std::string isImplicit = "isImplicit";
100 const std::string maxAttachIdx = "maxAttachIdx";
101 const std::string molAtomMapNumber = "molAtomMapNumber";
102 const std::string molFileAlias = "molFileAlias";
103 const std::string molFileValue = "molFileValue";
104 const std::string molInversionFlag = "molInversionFlag";
105 const std::string molParity = "molParity";
106 const std::string molStereoCare = "molStereoCare";
107 const std::string molRxnComponent = "molRxnComponent";
108 const std::string molRxnRole = "molRxnRole";
109 const std::string molTotValence = "molTotValence";
110 const std::string molFileLinkNodes = "molLinkNodes";
111 const std::string numArom = "numArom";
112 const std::string origNoImplicit = "origNoImplicit";
113 const std::string ringMembership = "ringMembership";
114 const std::string smilesSymbol = "smilesSymbol";
115 const std::string atomLabel = "atomLabel";
116 const std::string internalRgroupSmiles = "internalRgroupSmiles";
117
118 const std::string molSubstCount = "molSubstCount";
119 const std::string molAttachPoint = "molAttchpt";
120 const std::string molAttachOrder = "molAttchord";
121 const std::string molAtomClass = "molClass";
122 const std::string molAtomSeqId = "molSeqid";
123 const std::string molRxnExactChange = "molRxnExachg";
124 const std::string molReactStatus = "molReactStatus";
125
126 const std::string molNote = "molNote";
127 const std::string atomNote = "atomNote";
128 const std::string bondNote = "bondNote";
129 const std::string _isotopicHs = "_isotopicHs";
130
131 // molecule drawing
132 const std::string _displayLabel = "_displayLabel";
133 const std::string _displayLabelW = "_displayLabelW";
134
135 } // namespace common_properties
136
137 const double MAX_DOUBLE = std::numeric_limits<double>::max();
138 const double EPS_DOUBLE = std::numeric_limits<double>::epsilon();
139 const double SMALL_DOUBLE = 1.0e-8;
140 const double MAX_INT = static_cast<double>(std::numeric_limits<int>::max());
141 const double MAX_LONGINT =
142 static_cast<double>(std::numeric_limits<LONGINT>::max());
143
144 // template <typename T>
145 // T larger_of(T arg1,T arg2) { return arg1>arg2 ? arg1 : arg2; };
146
Union(const INT_VECT & r1,const INT_VECT & r2,INT_VECT & res)147 void Union(const INT_VECT &r1, const INT_VECT &r2, INT_VECT &res) {
148 res.resize(0);
149 res = r1;
150 INT_VECT_CI ri;
151 for (ri = r2.begin(); ri != r2.end(); ri++) {
152 if (std::find(res.begin(), res.end(), (*ri)) == res.end()) {
153 res.push_back(*ri);
154 }
155 }
156 }
157
Intersect(const INT_VECT & r1,const INT_VECT & r2,INT_VECT & res)158 void Intersect(const INT_VECT &r1, const INT_VECT &r2, INT_VECT &res) {
159 res.resize(0);
160 INT_VECT_CI ri;
161 for (ri = r1.begin(); ri != r1.end(); ri++) {
162 if (std::find(r2.begin(), r2.end(), (*ri)) != r2.end()) {
163 res.push_back(*ri);
164 }
165 }
166 }
167
Union(const VECT_INT_VECT & rings,INT_VECT & res,const INT_VECT * exclude)168 void Union(const VECT_INT_VECT &rings, INT_VECT &res, const INT_VECT *exclude) {
169 res.resize(0);
170 INT_VECT ring;
171 unsigned int id;
172 auto nrings = static_cast<unsigned int>(rings.size());
173 INT_VECT_CI ri;
174
175 for (id = 0; id < nrings; id++) {
176 if (exclude) {
177 if (std::find(exclude->begin(), exclude->end(), static_cast<int>(id)) !=
178 exclude->end()) {
179 continue;
180 }
181 }
182 ring = rings[id];
183 for (ri = ring.begin(); ri != ring.end(); ri++) {
184 if (std::find(res.begin(), res.end(), (*ri)) == res.end()) {
185 res.push_back(*ri);
186 }
187 }
188 }
189 }
190
nextCombination(INT_VECT & comb,int tot)191 int nextCombination(INT_VECT &comb, int tot) {
192 int nelem = static_cast<int>(comb.size());
193 int celem = nelem - 1;
194
195 while (comb[celem] == (tot - nelem + celem)) {
196 celem--;
197 if (celem < 0) {
198 return -1;
199 }
200 }
201
202 unsigned int i;
203 comb[celem] += 1;
204 for (i = celem + 1; i < comb.size(); i++) {
205 comb[i] = comb[i - 1] + 1;
206 }
207 return celem;
208 }
209 } // namespace RDKit
210