File: Params.h

package info (click to toggle)
rdkit 201809.1%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 123,688 kB
  • sloc: cpp: 230,509; python: 70,501; java: 6,329; ansic: 5,427; sql: 1,899; yacc: 1,739; lex: 1,243; makefile: 445; xml: 229; fortran: 183; sh: 123; cs: 93
file content (1445 lines) | stat: -rw-r--r-- 56,048 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
//
//  Copyright (C) 2013 Paolo Tosco
//
//  Copyright (C) 2004-2006 Rational Discovery LLC
//
//   @@ All Rights Reserved @@
//  This file is part of the RDKit.
//  The contents are covered by the terms of the BSD license
//  which is included in the file license.txt, found at the root
//  of the RDKit source tree.
//
#include <RDGeneral/export.h>
#ifndef __RD_MMFFPARAMS_H__
#define __RD_MMFFPARAMS_H__

#include <RDGeneral/Invariant.h>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iostream>
#include <boost/cstdint.hpp>

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

// binary searches are slightly faster than std::map;
// however when I moved to binary searches I had already
// written the code for std::map, so the two methods
// can be toggled defining RDKIT_MMFF_PARAMS_USE_STD_MAP

//#define RDKIT_MMFF_PARAMS_USE_STD_MAP 1

namespace ForceFields {
namespace MMFF {

const double DEG2RAD = M_PI / 180.0;
const double RAD2DEG = 180.0 / M_PI;
const double MDYNE_A_TO_KCAL_MOL = 143.9325;
inline bool isDoubleZero(const double x) {
  return ((x < 1.0e-10) && (x > -1.0e-10));
}
inline void clipToOne(double &x) {
  if (x > 1.0) {
    x = 1.0;
  } else if (x < -1.0) {
    x = -1.0;
  }
}

//! class to store MMFF atom type equivalence levels
class RDKIT_FORCEFIELD_EXPORT MMFFDef {
 public:
  boost::uint8_t eqLevel[4];
};

//! class to store MMFF Properties
class RDKIT_FORCEFIELD_EXPORT MMFFProp {
 public:
  boost::uint8_t atno;
  boost::uint8_t crd;
  boost::uint8_t val;
  boost::uint8_t pilp;
  boost::uint8_t mltb;
  boost::uint8_t arom;
  boost::uint8_t linh;
  boost::uint8_t sbmb;
};

//! class to store MMFF Partial Bond Charge Increments
class RDKIT_FORCEFIELD_EXPORT MMFFPBCI {
 public:
  double pbci;
  double fcadj;
};

//! class to store MMFF bond-charge-increment parameters used to
//! construct MMFF partial atomic charges
class RDKIT_FORCEFIELD_EXPORT MMFFChg {
 public:
  double bci;
};

//! class to store MMFF parameters for bond stretching
class RDKIT_FORCEFIELD_EXPORT MMFFBond {
 public:
  double kb;
  double r0;
};

//! class to store parameters for Herschbach-Laurie's version
//! of Badger's rule
class RDKIT_FORCEFIELD_EXPORT MMFFHerschbachLaurie {
 public:
  double a_ij;
  double d_ij;
  double dp_ij;
};

//! class to store covalent radius and Pauling electronegativity
//! values for MMFF bond stretching empirical rule
class RDKIT_FORCEFIELD_EXPORT MMFFCovRadPauEle {
 public:
  double r0;
  double chi;
};

//! class to store MMFF parameters for angle bending
class RDKIT_FORCEFIELD_EXPORT MMFFAngle {
 public:
  double ka;
  double theta0;
};

//! class to store MMFF parameters for stretch-bending
class RDKIT_FORCEFIELD_EXPORT MMFFStbn {
 public:
  double kbaIJK;
  double kbaKJI;
};

//! class to store MMFF parameters for out-of-plane bending
class RDKIT_FORCEFIELD_EXPORT MMFFOop {
 public:
  double koop;
};

//! class to store MMFF parameters for torsions
class RDKIT_FORCEFIELD_EXPORT MMFFTor {
 public:
  double V1;
  double V2;
  double V3;
};

//! class to store MMFF parameters for non-bonded Van der Waals
class RDKIT_FORCEFIELD_EXPORT MMFFVdW {
 public:
  double alpha_i;
  double N_i;
  double A_i;
  double G_i;
  double R_star;
  boost::uint8_t DA;
};

class RDKIT_FORCEFIELD_EXPORT MMFFVdWRijstarEps {
 public:
  double R_ij_starUnscaled;
  double epsilonUnscaled;
  double R_ij_star;
  double epsilon;
};

class RDKIT_FORCEFIELD_EXPORT MMFFAromCollection {
 public:
  //! gets a pointer to the singleton MMFFAromCollection
  /*!
    \param mmffArom (optional) a string with parameter data. See
     below for more information about this argument

    \return a pointer to the singleton MMFFAromCollection

    <b>Notes:</b>
      - do <b>not</b> delete the pointer returned here
      - if the singleton MMFFAromCollection has already been instantiated and
        \c mmffArom is empty, the singleton will be returned.
      - if \c mmffArom is empty and the singleton MMFFAromCollection has
        not yet been instantiated, the default MMFFArom parameters (from
    Params.cpp)
        will be used.
      - if \c mmffArom is supplied, a new singleton will be instantiated.
        The current instantiation (if there is one) will be deleted.
  */
  static MMFFAromCollection *getMMFFArom(
      const boost::uint8_t *aromatic_types = NULL);
  //! Looks up the parameters for a particular key and returns them.
  /*!
    \return a pointer to the MMFFArom object, NULL on failure.
  */
  bool isMMFFAromatic(const unsigned int atomType) const {
    return ((std::find(d_params.begin(), d_params.end(), atomType) !=
             d_params.end())
                ? true
                : false);
  }

 private:
  //! to force this to be a singleton, the constructor must be private
  MMFFAromCollection(const boost::uint8_t mmffArom[]);
  static class MMFFAromCollection *ds_instance;  //!< the singleton
  std::vector<boost::uint8_t> d_params;          //!< the aromatic type vector
};

class RDKIT_FORCEFIELD_EXPORT MMFFDefCollection {
 public:
  //! gets a pointer to the singleton MMFFDefCollection
  /*!
    \param mmffDef (optional) a string with parameter data. See
     below for more information about this argument

    \return a pointer to the singleton MMFFDefCollection

    <b>Notes:</b>
      - do <b>not</b> delete the pointer returned here
      - if the singleton MMFFDefCollection has already been instantiated and
        \c mmffDef is empty, the singleton will be returned.
      - if \c mmffDef is empty and the singleton MMFFDefCollection has
        not yet been instantiated, the default MMFFDef parameters (from
    Params.cpp)
        will be used.
      - if \c mmffDef is supplied, a new singleton will be instantiated.
        The current instantiation (if there is one) will be deleted.
  */
  static MMFFDefCollection *getMMFFDef(const std::string &mmffDef = "");
  //! Looks up the parameters for a particular key and returns them.
  /*!
    \return a pointer to the MMFFDef object, NULL on failure.
  */
  const MMFFDef *operator()(const unsigned int atomType) const {
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
    std::map<const unsigned int, MMFFDef>::const_iterator res;
    res = d_params.find(atomType);

    return ((res != d_params.end()) ? &((*res).second) : NULL);
#else
    return ((atomType && (atomType <= d_params.size()))
                ? &d_params[atomType - 1]
                : NULL);
#endif
  }

 private:
  //! to force this to be a singleton, the constructor must be private
  MMFFDefCollection(std::string mmffDef);
  static class MMFFDefCollection *ds_instance;  //!< the singleton
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
  std::map<const unsigned int, MMFFDef> d_params;  //!< the parameter map
#else
  std::vector<MMFFDef> d_params;  //!< the parameter vector
#endif
};

class RDKIT_FORCEFIELD_EXPORT MMFFPropCollection {
 public:
  //! gets a pointer to the singleton MMFFPropCollection
  /*!
    \param mmffProp (optional) a string with parameter data. See
     below for more information about this argument

    \return a pointer to the singleton MMFFPropCollection

    <b>Notes:</b>
      - do <b>not</b> delete the pointer returned here
      - if the singleton MMFFPropCollection has already been instantiated and
        \c mmffProp is empty, the singleton will be returned.
      - if \c mmffProp is empty and the singleton MMFFPropCollection has
        not yet been instantiated, the default parameters (from Params.cpp)
        will be used.
      - if \c mmffProp is supplied, a new singleton will be instantiated.
        The current instantiation (if there is one) will be deleted.
  */
  static MMFFPropCollection *getMMFFProp(const std::string &mmffProp = "");
  //! Looks up the parameters for a particular key and returns them.
  /*!
    \return a pointer to the MMFFProp object, NULL on failure.
  */
  const MMFFProp *operator()(const unsigned int atomType) const {
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
    std::map<const unsigned int, MMFFProp>::const_iterator res;
    res = d_params.find(atomType);

    return ((res != d_params.end()) ? &((*res).second) : NULL);
#else
    std::pair<std::vector<boost::uint8_t>::const_iterator,
              std::vector<boost::uint8_t>::const_iterator> bounds =
        std::equal_range(d_iAtomType.begin(), d_iAtomType.end(), atomType);

    return ((bounds.first != bounds.second)
                ? &d_params[bounds.first - d_iAtomType.begin()]
                : NULL);
#endif
  }

 private:
  //! to force this to be a singleton, the constructor must be private
  MMFFPropCollection(std::string mmffProp);
  static class MMFFPropCollection *ds_instance;  //!< the singleton
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
  std::map<const unsigned int, MMFFProp> d_params;  //!< the parameter map
#else
  std::vector<MMFFProp> d_params;
  std::vector<boost::uint8_t> d_iAtomType;  //!< the parameter vector
#endif
};

class RDKIT_FORCEFIELD_EXPORT MMFFPBCICollection {
 public:
  //! gets a pointer to the singleton MMFFPBCICollection
  /*!
    \param mmffPBCI (optional) a string with parameter data. See
     below for more information about this argument

    \return a pointer to the singleton MMFFPBCICollection

    <b>Notes:</b>
      - do <b>not</b> delete the pointer returned here
      - if the singleton MMFFPBCICollection has already been instantiated and
        \c mmffPBCI is empty, the singleton will be returned.
      - if \c mmffPBCI is empty and the singleton MMFFPBCICollection has
        not yet been instantiated, the default parameters (from Params.cpp)
        will be used.
      - if \c mmffPBCI is supplied, a new singleton will be instantiated.
        The current instantiation (if there is one) will be deleted.
  */
  static MMFFPBCICollection *getMMFFPBCI(const std::string &mmffPBCI = "");
  //! Looks up the parameters for a particular key and returns them.
  /*!
    \return a pointer to the MMFFPBCI object, NULL on failure.
  */
  const MMFFPBCI *operator()(const unsigned int atomType) const {
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
    std::map<const unsigned int, MMFFPBCI>::const_iterator res;
    res = d_params.find(atomType);

    return ((res != d_params.end()) ? &((*res).second) : NULL);
#else
    return ((atomType && (atomType <= d_params.size()))
                ? &d_params[atomType - 1]
                : NULL);
#endif
  }

 private:
  //! to force this to be a singleton, the constructor must be private
  MMFFPBCICollection(std::string mmffPBCI);
  static class MMFFPBCICollection *ds_instance;  //!< the singleton
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
  std::map<const unsigned int, MMFFPBCI> d_params;  //!< the parameter map
#else
  std::vector<MMFFPBCI> d_params;  //!< the parameter vector
#endif
};

class RDKIT_FORCEFIELD_EXPORT MMFFChgCollection {
 public:
  //! gets a pointer to the singleton MMFFChgCollection
  /*!
    \param mmffChg (optional) a string with parameter data. See
     below for more information about this argument

    \return a pointer to the singleton MMFFChgCollection

    <b>Notes:</b>
      - do <b>not</b> delete the pointer returned here
      - if the singleton MMFFChgCollection has already been instantiated and
        \c mmffChg is empty, the singleton will be returned.
      - if \c mmffChg is empty and the singleton MMFFChgCollection has
        not yet been instantiated, the default parameters (from Params.cpp)
        will be used.
      - if \c mmffChg is supplied, a new singleton will be instantiated.
        The current instantiation (if there is one) will be deleted.
  */
  static MMFFChgCollection *getMMFFChg(const std::string &mmffChg = "");
  //! Looks up the parameters for a particular key and returns them.
  /*!
    \return a pointer to the MMFFChg object, NULL on failure.
  */
  const std::pair<int, const MMFFChg *> getMMFFChgParams(
      const unsigned int bondType, const unsigned int iAtomType,
      const unsigned int jAtomType) {
    int sign = -1;
    const MMFFChg *mmffChgParams = NULL;
    unsigned int canIAtomType = iAtomType;
    unsigned int canJAtomType = jAtomType;
    if (iAtomType > jAtomType) {
      canIAtomType = jAtomType;
      canJAtomType = iAtomType;
      sign = 1;
    }
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
    std::map<const unsigned int,
             std::map<const unsigned int, MMFFChg> >::const_iterator res1;
    std::map<const unsigned int, MMFFChg>::const_iterator res2;
    res1 = d_params[bondType].find(canIAtomType);
    if (res1 != d_params[bondType].end()) {
      res2 = ((*res1).second).find(canJAtomType);
      if (res2 != ((*res1).second).end()) {
        mmffChgParams = &((*res2).second);
      }
    }
#else
    std::pair<std::vector<boost::uint8_t>::const_iterator,
              std::vector<boost::uint8_t>::const_iterator> bounds;

    bounds =
        std::equal_range(d_iAtomType.begin(), d_iAtomType.end(), canIAtomType);
    if (bounds.first != bounds.second) {
      bounds = std::equal_range(
          d_jAtomType.begin() + (bounds.first - d_iAtomType.begin()),
          d_jAtomType.begin() + (bounds.second - d_iAtomType.begin()),
          canJAtomType);
      if (bounds.first != bounds.second) {
        bounds = std::equal_range(
            d_bondType.begin() + (bounds.first - d_jAtomType.begin()),
            d_bondType.begin() + (bounds.second - d_jAtomType.begin()),
            bondType);
        if (bounds.first != bounds.second) {
          mmffChgParams = &d_params[bounds.first - d_bondType.begin()];
        }
      }
    }
#endif

    return std::make_pair(sign, mmffChgParams);
  }

 private:
  //! to force this to be a singleton, the constructor must be private
  MMFFChgCollection(std::string mmffChg);
  static class MMFFChgCollection *ds_instance;  //!< the singleton
//!< the parameter 3D-map
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
  std::map<
      const unsigned int,
      std::map<const unsigned int, std::map<const unsigned int, MMFFChg> > >
      d_params;  //!< the parameter 3D-map
#else
  std::vector<MMFFChg> d_params;            //! the parameter vector
  std::vector<boost::uint8_t> d_iAtomType;  //! atom type vector for atom i
  std::vector<boost::uint8_t> d_jAtomType;  //! atom type vector for atom j
  std::vector<boost::uint8_t> d_bondType;   //! bond type vector for bond i-j
#endif
};

class RDKIT_FORCEFIELD_EXPORT MMFFBondCollection {
 public:
  //! gets a pointer to the singleton MMFFBondCollection
  /*!
    \param mmffBond (optional) a string with parameter data. See
     below for more information about this argument

    \return a pointer to the singleton MMFFBondCollection

    <b>Notes:</b>
      - do <b>not</b> delete the pointer returned here
      - if the singleton MMFFBondCollection has already been instantiated and
        \c mmffBond is empty, the singleton will be returned.
      - if \c mmffBond is empty and the singleton MMFFBondCollection has
        not yet been instantiated, the default parameters (from Params.cpp)
        will be used.
      - if \c mmffBond is supplied, a new singleton will be instantiated.
        The current instantiation (if there is one) will be deleted.
  */
  static MMFFBondCollection *getMMFFBond(const std::string &mmffBond = "");
  //! Looks up the parameters for a particular key and returns them.
  /*!
    \return a pointer to the MMFFBond object, NULL on failure.
  */
  const MMFFBond *operator()(const unsigned int bondType,
                             const unsigned int atomType,
                             const unsigned int nbrAtomType) {
    const MMFFBond *mmffBondParams = NULL;
    unsigned int canAtomType = atomType;
    unsigned int canNbrAtomType = nbrAtomType;
    if (atomType > nbrAtomType) {
      canAtomType = nbrAtomType;
      canNbrAtomType = atomType;
    }
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
    std::map<const unsigned int,
             std::map<const unsigned int,
                      std::map<const unsigned int, MMFFBond> > >::const_iterator
        res1;
    std::map<const unsigned int,
             std::map<const unsigned int, MMFFBond> >::const_iterator res2;
    std::map<const unsigned int, MMFFBond>::const_iterator res3;
    res1 = d_params.find(bondType);
    if (res1 != d_params.end()) {
      res2 = ((*res1).second).find(canAtomType);
      if (res2 != ((*res1).second).end()) {
        res3 = ((*res2).second).find(canNbrAtomType);
        if (res3 != ((*res2).second).end()) {
          mmffBondParams = &((*res3).second);
        }
      }
    }
#else
    std::pair<std::vector<boost::uint8_t>::const_iterator,
              std::vector<boost::uint8_t>::const_iterator> bounds;
    bounds =
        std::equal_range(d_iAtomType.begin(), d_iAtomType.end(), canAtomType);
    if (bounds.first != bounds.second) {
      bounds = std::equal_range(
          d_jAtomType.begin() + (bounds.first - d_iAtomType.begin()),
          d_jAtomType.begin() + (bounds.second - d_iAtomType.begin()),
          canNbrAtomType);
      if (bounds.first != bounds.second) {
        bounds = std::equal_range(
            d_bondType.begin() + (bounds.first - d_jAtomType.begin()),
            d_bondType.begin() + (bounds.second - d_jAtomType.begin()),
            bondType);
        if (bounds.first != bounds.second) {
          mmffBondParams = &d_params[bounds.first - d_bondType.begin()];
        }
      }
    }
#endif

    return mmffBondParams;
  }

 private:
  //! to force this to be a singleton, the constructor must be private
  MMFFBondCollection(std::string mmffBond);
  static class MMFFBondCollection *ds_instance;  //!< the singleton
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
  std::map<
      const unsigned int,
      std::map<const unsigned int, std::map<const unsigned int, MMFFBond> > >
      d_params;  //!< the parameter 3D-map
#else
  std::vector<MMFFBond> d_params;           //!< the parameter vector
  std::vector<boost::uint8_t> d_iAtomType;  //! atom type vector for atom i
  std::vector<boost::uint8_t> d_jAtomType;  //! atom type vector for atom j
  std::vector<boost::uint8_t> d_bondType;   //! bond type vector for bond i-j
#endif
};

class RDKIT_FORCEFIELD_EXPORT MMFFBndkCollection {
 public:
  //! gets a pointer to the singleton MMFFBndkCollection
  /*!
    \param mmffBndk (optional) a string with parameter data. See
     below for more information about this argument

    \return a pointer to the singleton MMFFBndkCollection

    <b>Notes:</b>
      - do <b>not</b> delete the pointer returned here
      - if the singleton MMFFBndkCollection has already been instantiated and
        \c mmffBndk is empty, the singleton will be returned.
      - if \c mmffBndk is empty and the singleton MMFFBndkCollection has
        not yet been instantiated, the default parameters (from Params.cpp)
        will be used.
      - if \c mmffBndk is supplied, a new singleton will be instantiated.
        The current instantiation (if there is one) will be deleted.
  */
  static MMFFBndkCollection *getMMFFBndk(const std::string &mmffBndk = "");
  //! Looks up the parameters for a particular key and returns them.
  /*!
    \return a pointer to the MMFFBndk object, NULL on failure.
  */
  const MMFFBond *operator()(const int atomicNum, const int nbrAtomicNum) {
    const MMFFBond *mmffBndkParams = NULL;
    unsigned int canAtomicNum = atomicNum;
    unsigned int canNbrAtomicNum = nbrAtomicNum;
    if (atomicNum > nbrAtomicNum) {
      canAtomicNum = nbrAtomicNum;
      canNbrAtomicNum = atomicNum;
    }
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
    std::map<const unsigned int,
             std::map<const unsigned int, MMFFBond> >::const_iterator res1;
    std::map<const unsigned int, MMFFBond>::const_iterator res2;
    res1 = d_params.find(canAtomicNum);
    if (res1 != d_params.end()) {
      res2 = ((*res1).second).find(canNbrAtomicNum);
      if (res2 != ((*res1).second).end()) {
        mmffBndkParams = &((*res2).second);
      }
    }
#else
    std::pair<std::vector<boost::uint8_t>::const_iterator,
              std::vector<boost::uint8_t>::const_iterator> bounds;
    bounds = std::equal_range(d_iAtomicNum.begin(), d_iAtomicNum.end(),
                              canAtomicNum);
    if (bounds.first != bounds.second) {
      bounds = std::equal_range(
          d_jAtomicNum.begin() + (bounds.first - d_iAtomicNum.begin()),
          d_jAtomicNum.begin() + (bounds.second - d_iAtomicNum.begin()),
          canNbrAtomicNum);
      if (bounds.first != bounds.second) {
        mmffBndkParams = &d_params[bounds.first - d_jAtomicNum.begin()];
      }
    }
#endif

    return mmffBndkParams;
  }

 private:
  //! to force this to be a singleton, the constructor must be private
  MMFFBndkCollection(std::string mmffBndk);
  static class MMFFBndkCollection *ds_instance;  //!< the singleton
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
  std::map<const unsigned int, std::map<const unsigned int, MMFFBond> >
      d_params;  //!< the parameter 2D-map
#else
  std::vector<MMFFBond> d_params;            //!< the parameter vector
  std::vector<boost::uint8_t> d_iAtomicNum;  //! atomic number vector for atom i
  std::vector<boost::uint8_t> d_jAtomicNum;  //! atomic number vector for atom j
#endif
};

class RDKIT_FORCEFIELD_EXPORT MMFFHerschbachLaurieCollection {
 public:
  //! gets a pointer to the singleton MMFFHerschbachLaurieCollection
  /*!
    \param mmffHerschbachLaurie (optional) a string with parameter data. See
     below for more information about this argument

    \return a pointer to the singleton MMFFHerschbachLaurieCollection

    <b>Notes:</b>
      - do <b>not</b> delete the pointer returned here
      - if the singleton MMFFHerschbachLaurieCollection has already been
    instantiated and
        \c mmffHerschbachLaurie is empty, the singleton will be returned.
      - if \c mmffHerschbachLaurie is empty and the singleton
    MMFFHerschbachLaurieCollection has
        not yet been instantiated, the default parameters (from Params.cpp)
        will be used.
      - if \c mmffHerschbachLaurie is supplied, a new singleton will be
    instantiated.
        The current instantiation (if there is one) will be deleted.
  */
  static MMFFHerschbachLaurieCollection *getMMFFHerschbachLaurie(
      const std::string &mmffHerschbachLaurie = "");
  //! Looks up the parameters for a particular key and returns them.
  /*!
    \return a pointer to the MMFFHerschbachLaurie object, NULL on failure.
  */
  const MMFFHerschbachLaurie *operator()(const int iRow, const int jRow) {
    const MMFFHerschbachLaurie *mmffHerschbachLaurieParams = NULL;
    unsigned int canIRow = iRow;
    unsigned int canJRow = jRow;
    if (iRow > jRow) {
      canIRow = jRow;
      canJRow = iRow;
    }
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
    std::map<const unsigned int,
             std::map<const unsigned int,
                      MMFFHerschbachLaurie> >::const_iterator res1;
    std::map<const unsigned int, MMFFHerschbachLaurie>::const_iterator res2;
    res1 = d_params.find(canIRow);
    if (res1 != d_params.end()) {
      res2 = ((*res1).second).find(canJRow);
      if (res2 != ((*res1).second).end()) {
        mmffHerschbachLaurieParams = &((*res2).second);
      }
    }
#else
    std::pair<std::vector<boost::uint8_t>::const_iterator,
              std::vector<boost::uint8_t>::const_iterator> bounds;
    bounds = std::equal_range(d_iRow.begin(), d_iRow.end(), canIRow);
    if (bounds.first != bounds.second) {
      bounds = std::equal_range(
          d_jRow.begin() + (bounds.first - d_iRow.begin()),
          d_jRow.begin() + (bounds.second - d_iRow.begin()), canJRow);
      if (bounds.first != bounds.second) {
        mmffHerschbachLaurieParams = &d_params[bounds.first - d_jRow.begin()];
      }
    }
#endif

    return mmffHerschbachLaurieParams;
  }

 private:
  //! to force this to be a singleton, the constructor must be private
  MMFFHerschbachLaurieCollection(std::string mmffHerschbachLaurie);
  static class MMFFHerschbachLaurieCollection *ds_instance;  //!< the singleton
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
  std::map<const unsigned int,
           std::map<const unsigned int, MMFFHerschbachLaurie> >
      d_params;  //!< the parameter 2D-map
#else
  std::vector<MMFFHerschbachLaurie> d_params;  //!< the parameter vector
  std::vector<boost::uint8_t> d_iRow;  //! periodic row number vector for atom i
  std::vector<boost::uint8_t> d_jRow;  //! periodic row number vector for atom j
#endif
};

class RDKIT_FORCEFIELD_EXPORT MMFFCovRadPauEleCollection {
 public:
  //! gets a pointer to the singleton MMFFCovRadPauEleCollection
  /*!
    \param mmffCovRadPauEle (optional) a string with parameter data. See
     below for more information about this argument

    \return a pointer to the singleton MMFFCovRadPauEleCollection

    <b>Notes:</b>
      - do <b>not</b> delete the pointer returned here
      - if the singleton MMFFCovRadPauEleCollection has already been
    instantiated and
        \c mmffCovRadPauEle is empty, the singleton will be returned.
      - if \c mmffCovRadPauEle is empty and the singleton
    MMFFCovRadPauEleCollection has
        not yet been instantiated, the default parameters (from Params.cpp)
        will be used.
      - if \c mmffCovRadPauEle is supplied, a new singleton will be
    instantiated.
        The current instantiation (if there is one) will be deleted.
  */
  static MMFFCovRadPauEleCollection *getMMFFCovRadPauEle(
      const std::string &mmffCovRadPauEle = "");
  //! Looks up the parameters for a particular key and returns them.
  /*!
    \return a pointer to the MMFFCovRadPauEle object, NULL on failure.
  */
  const MMFFCovRadPauEle *operator()(const unsigned int atomicNum) const {
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
    std::map<const unsigned int, MMFFCovRadPauEle>::const_iterator res;
    res = d_params.find(atomicNum);

    return ((res != d_params.end()) ? &((*res).second) : NULL);
#else
    std::pair<std::vector<boost::uint8_t>::const_iterator,
              std::vector<boost::uint8_t>::const_iterator> bounds =
        std::equal_range(d_atomicNum.begin(), d_atomicNum.end(), atomicNum);

    return ((bounds.first != bounds.second)
                ? &d_params[bounds.first - d_atomicNum.begin()]
                : NULL);
#endif
  }

 private:
  //! to force this to be a singleton, the constructor must be private
  MMFFCovRadPauEleCollection(std::string mmffCovRadPauEle);
  static class MMFFCovRadPauEleCollection *ds_instance;  //!< the singleton
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
  std::map<const unsigned int, MMFFCovRadPauEle>
      d_params;  //!< the parameter map
#else
  std::vector<MMFFCovRadPauEle> d_params;   //!< the parameter vector
  std::vector<boost::uint8_t> d_atomicNum;  //!< the atomic number vector
#endif
};

class RDKIT_FORCEFIELD_EXPORT MMFFAngleCollection {
 public:
  //! gets a pointer to the singleton MMFFAngleCollection
  /*!
    \param mmffAngle (optional) a string with parameter data. See
     below for more information about this argument

    \return a pointer to the singleton MMFFAngleCollection

    <b>Notes:</b>
      - do <b>not</b> delete the pointer returned here
      - if the singleton MMFFAngleCollection has already been instantiated and
        \c mmffAngle is empty, the singleton will be returned.
      - if \c mmffAngle is empty and the singleton MMFFAngleCollection has
        not yet been instantiated, the default parameters (from Params.cpp)
        will be used.
      - if \c mmffAngle is supplied, a new singleton will be instantiated.
        The current instantiation (if there is one) will be deleted.
  */
  static MMFFAngleCollection *getMMFFAngle(const std::string &mmffAngle = "");
  //! Looks up the parameters for a particular key and returns them.
  /*!
    \return a pointer to the MMFFAngle object, NULL on failure.
  */
  const MMFFAngle *operator()(const unsigned int angleType,
                              const unsigned int iAtomType,
                              const unsigned int jAtomType,
                              const unsigned int kAtomType) {
    MMFFDefCollection *mmffDef = MMFFDefCollection::getMMFFDef();
    const MMFFAngle *mmffAngleParams = NULL;
    unsigned int iter = 0;

// For bending of the i-j-k angle, a five-stage process based
// in the level combinations 1-1-1,2-2-2,3-2-3,4-2-4, and
// 5-2-5 is used. (MMFF.I, note 68, page 519)
// We skip 1-1-1 since Level 2 === Level 1
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
    std::map<const unsigned int,
             std::map<const unsigned int,
                      std::map<const unsigned int,
                               std::map<const unsigned int, MMFFAngle> > > >::
        const_iterator res1;
    std::map<const unsigned int,
             std::map<const unsigned int,
                      std::map<const unsigned int, MMFFAngle> > >::
        const_iterator res2;
    std::map<const unsigned int,
             std::map<const unsigned int, MMFFAngle> >::const_iterator res3;
    std::map<const unsigned int, MMFFAngle>::const_iterator res4;
    while ((iter < 4) && (!mmffAngleParams)) {
      unsigned int canIAtomType = (*mmffDef)(iAtomType)->eqLevel[iter];
      unsigned int canKAtomType = (*mmffDef)(kAtomType)->eqLevel[iter];
      if (canIAtomType > canKAtomType) {
        unsigned int temp = canKAtomType;
        canKAtomType = canIAtomType;
        canIAtomType = temp;
      }
      res1 = d_params.find(angleType);
      if (res1 != d_params.end()) {
        res2 = ((*res1).second).find(canIAtomType);
        if (res2 != ((*res1).second).end()) {
          res3 = ((*res2).second).find(jAtomType);
          if (res3 != ((*res2).second).end()) {
            res4 = ((*res3).second).find(canKAtomType);
            if (res4 != ((*res3).second).end()) {
              mmffAngleParams = &((*res4).second);
            }
          }
        }
      }
      ++iter;
    }
#else
    std::pair<std::vector<boost::uint8_t>::const_iterator,
              std::vector<boost::uint8_t>::const_iterator> jBounds =
        std::equal_range(d_jAtomType.begin(), d_jAtomType.end(), jAtomType);
    std::pair<std::vector<boost::uint8_t>::const_iterator,
              std::vector<boost::uint8_t>::const_iterator> bounds;
    if (jBounds.first != jBounds.second) {
      while ((iter < 4) && (!mmffAngleParams)) {
        unsigned int canIAtomType = (*mmffDef)(iAtomType)->eqLevel[iter];
        unsigned int canKAtomType = (*mmffDef)(kAtomType)->eqLevel[iter];
        if (canIAtomType > canKAtomType) {
          unsigned int temp = canKAtomType;
          canKAtomType = canIAtomType;
          canIAtomType = temp;
        }
        bounds = std::equal_range(
            d_iAtomType.begin() + (jBounds.first - d_jAtomType.begin()),
            d_iAtomType.begin() + (jBounds.second - d_jAtomType.begin()),
            canIAtomType);
        if (bounds.first != bounds.second) {
          bounds = std::equal_range(
              d_kAtomType.begin() + (bounds.first - d_iAtomType.begin()),
              d_kAtomType.begin() + (bounds.second - d_iAtomType.begin()),
              canKAtomType);
          if (bounds.first != bounds.second) {
            bounds = std::equal_range(
                d_angleType.begin() + (bounds.first - d_kAtomType.begin()),
                d_angleType.begin() + (bounds.second - d_kAtomType.begin()),
                angleType);
            if (bounds.first != bounds.second) {
              mmffAngleParams = &d_params[bounds.first - d_angleType.begin()];
            }
          }
        }
        ++iter;
      }
    }
#endif

    return mmffAngleParams;
  }

 private:
  //! to force this to be a singleton, the constructor must be private
  MMFFAngleCollection(std::string mmffAngle);
  static class MMFFAngleCollection *ds_instance;  //!< the singleton
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
  std::map<const unsigned int,
           std::map<const unsigned int,
                    std::map<const unsigned int,
                             std::map<const unsigned int, MMFFAngle> > > >
      d_params;  //!< the parameter 4D-map
#else
  std::vector<MMFFAngle> d_params;          //!< the parameter vector
  std::vector<boost::uint8_t> d_iAtomType;  //! atom type vector for atom i
  std::vector<boost::uint8_t> d_jAtomType;  //! atom type vector for atom j
  std::vector<boost::uint8_t> d_kAtomType;  //! atom type vector for atom k
  std::vector<boost::uint8_t>
      d_angleType;  //! angle type vector for angle i-j-k
#endif
};

class RDKIT_FORCEFIELD_EXPORT MMFFStbnCollection {
 public:
  //! gets a pointer to the singleton MMFFStbnCollection
  /*!
    \param mmffStbn (optional) a string with parameter data. See
     below for more information about this argument

    \return a pointer to the singleton MMFFStbnCollection

    <b>Notes:</b>
      - do <b>not</b> delete the pointer returned here
      - if the singleton MMFFStbnCollection has already been instantiated and
        \c mmffStbn is empty, the singleton will be returned.
      - if \c mmffStbn is empty and the singleton MMFFStbnCollection has
        not yet been instantiated, the default parameters (from Params.cpp)
        will be used.
      - if \c mmffStbn is supplied, a new singleton will be instantiated.
        The current instantiation (if there is one) will be deleted.
  */
  static MMFFStbnCollection *getMMFFStbn(const std::string &mmffStbn = "");
  //! Looks up the parameters for a particular key and returns them.
  /*!
    \return a pointer to the MMFFStbn object, NULL on failure.
  */
  const std::pair<bool, const MMFFStbn *> getMMFFStbnParams(
      const unsigned int stretchBendType, const unsigned int bondType1,
      const unsigned int bondType2, const unsigned int iAtomType,
      const unsigned int jAtomType, const unsigned int kAtomType) {
    const MMFFStbn *mmffStbnParams = NULL;
    bool swap = false;
    unsigned int canIAtomType = iAtomType;
    unsigned int canKAtomType = kAtomType;
    unsigned int canStretchBendType = stretchBendType;
    if (iAtomType > kAtomType) {
      canIAtomType = kAtomType;
      canKAtomType = iAtomType;
      swap = true;
    } else if (iAtomType == kAtomType) {
      swap = (bondType1 < bondType2);
    }
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
    std::map<const unsigned int,
             std::map<const unsigned int,
                      std::map<const unsigned int,
                               std::map<const unsigned int, MMFFStbn> > > >::
        const_iterator res1;
    std::map<const unsigned int,
             std::map<const unsigned int,
                      std::map<const unsigned int, MMFFStbn> > >::const_iterator
        res2;
    std::map<const unsigned int,
             std::map<const unsigned int, MMFFStbn> >::const_iterator res3;
    std::map<const unsigned int, MMFFStbn>::const_iterator res4;
    res1 = d_params.find(canStretchBendType);
    if (res1 != d_params.end()) {
      res2 = ((*res1).second).find(canIAtomType);
      if (res2 != ((*res1).second).end()) {
        res3 = ((*res2).second).find(jAtomType);
        if (res3 != ((*res2).second).end()) {
          res4 = ((*res3).second).find(canKAtomType);
          if (res4 != ((*res3).second).end()) {
            mmffStbnParams = &((*res4).second);
          }
        }
      }
    }
#else
    std::pair<std::vector<boost::uint8_t>::const_iterator,
              std::vector<boost::uint8_t>::const_iterator> jBounds =
        std::equal_range(d_jAtomType.begin(), d_jAtomType.end(), jAtomType);
    std::pair<std::vector<boost::uint8_t>::const_iterator,
              std::vector<boost::uint8_t>::const_iterator> bounds;
    if (jBounds.first != jBounds.second) {
      bounds = std::equal_range(
          d_iAtomType.begin() + (jBounds.first - d_jAtomType.begin()),
          d_iAtomType.begin() + (jBounds.second - d_jAtomType.begin()),
          canIAtomType);
      if (bounds.first != bounds.second) {
        bounds = std::equal_range(
            d_kAtomType.begin() + (bounds.first - d_iAtomType.begin()),
            d_kAtomType.begin() + (bounds.second - d_iAtomType.begin()),
            canKAtomType);
        if (bounds.first != bounds.second) {
          bounds = std::equal_range(
              d_stretchBendType.begin() + (bounds.first - d_kAtomType.begin()),
              d_stretchBendType.begin() + (bounds.second - d_kAtomType.begin()),
              canStretchBendType);
          if (bounds.first != bounds.second) {
            mmffStbnParams =
                &d_params[bounds.first - d_stretchBendType.begin()];
          }
        }
      }
    }
#endif

    return std::make_pair(swap, mmffStbnParams);
  }

 private:
  //! to force this to be a singleton, the constructor must be private
  MMFFStbnCollection(std::string mmffStbn);
  static class MMFFStbnCollection *ds_instance;  //!< the singleton
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
  std::map<const unsigned int,
           std::map<const unsigned int,
                    std::map<const unsigned int,
                             std::map<const unsigned int, MMFFStbn> > > >
      d_params;  //!< the parameter 4D-map
#else
  std::vector<MMFFStbn> d_params;           //!< the parameter vector
  std::vector<boost::uint8_t> d_iAtomType;  //! atom type vector for atom i
  std::vector<boost::uint8_t> d_jAtomType;  //! atom type vector for atom j
  std::vector<boost::uint8_t> d_kAtomType;  //! atom type vector for atom k
  std::vector<boost::uint8_t>
      d_stretchBendType;  //! stretch-bend type vector for angle i-j-k
#endif
};

class RDKIT_FORCEFIELD_EXPORT MMFFDfsbCollection {
 public:
  //! gets a pointer to the singleton MMFFDfsbCollection
  /*!
    \param mmffDfsb (optional) a string with parameter data. See
     below for more information about this argument

    \return a pointer to the singleton MMFFDfsbCollection

    <b>Notes:</b>
      - do <b>not</b> delete the pointer returned here
      - if the singleton MMFFDfsbCollection has already been instantiated and
        \c mmffDfsb is empty, the singleton will be returned.
      - if \c mmffDfsb is empty and the singleton MMFFDfsbCollection has
        not yet been instantiated, the default parameters (from Params.cpp)
        will be used.
      - if \c mmffDfsb is supplied, a new singleton will be instantiated.
        The current instantiation (if there is one) will be deleted.
  */
  static MMFFDfsbCollection *getMMFFDfsb(const std::string &mmffDfsb = "");
  //! Looks up the parameters for a particular key and returns them.
  /*!
    \return a pointer to the MMFFStbn object, NULL on failure.
  */
  const std::pair<bool, const MMFFStbn *> getMMFFDfsbParams(
      const unsigned int periodicTableRow1,
      const unsigned int periodicTableRow2,
      const unsigned int periodicTableRow3) {
    std::map<const unsigned int,
             std::map<const unsigned int,
                      std::map<const unsigned int, MMFFStbn> > >::const_iterator
        res1;
    std::map<const unsigned int,
             std::map<const unsigned int, MMFFStbn> >::const_iterator res2;
    std::map<const unsigned int, MMFFStbn>::const_iterator res3;
    const MMFFStbn *mmffDfsbParams = NULL;
    bool swap = false;
    unsigned int canPeriodicTableRow1 = periodicTableRow1;
    unsigned int canPeriodicTableRow3 = periodicTableRow3;
    if (periodicTableRow1 > periodicTableRow3) {
      canPeriodicTableRow1 = periodicTableRow3;
      canPeriodicTableRow3 = periodicTableRow1;
      swap = true;
    }
    res1 = d_params.find(canPeriodicTableRow1);
    if (res1 != d_params.end()) {
      res2 = ((*res1).second).find(periodicTableRow2);
      if (res2 != ((*res1).second).end()) {
        res3 = ((*res2).second).find(canPeriodicTableRow3);
        if (res3 != ((*res2).second).end()) {
          mmffDfsbParams = &((*res3).second);
        }
      }
    }

    return std::make_pair(swap, mmffDfsbParams);
  }

 private:
  //! to force this to be a singleton, the constructor must be private
  MMFFDfsbCollection(std::string mmffDfsb);
  static class MMFFDfsbCollection *ds_instance;  //!< the singleton
  std::map<
      const unsigned int,
      std::map<const unsigned int, std::map<const unsigned int, MMFFStbn> > >
      d_params;  //!< the parameter 3D-map
};

class RDKIT_FORCEFIELD_EXPORT MMFFOopCollection {
 public:
  //! gets a pointer to the singleton MMFFOopCollection
  /*!
    \param mmffOop (optional) a string with parameter data. See
     below for more information about this argument

    \return a pointer to the singleton MMFFOopCollection

    <b>Notes:</b>
      - do <b>not</b> delete the pointer returned here
      - if the singleton MMFFOopCollection has already been instantiated and
        \c mmffOop is empty, the singleton will be returned.
      - if \c mmffOop is empty and the singleton MMFFOopCollection has
        not yet been instantiated, the default parameters (from Params.cpp)
        will be used.
      - if \c mmffOop is supplied, a new singleton will be instantiated.
        The current instantiation (if there is one) will be deleted.
  */
  static MMFFOopCollection *getMMFFOop(const bool isMMFFs = false,
                                       const std::string &mmffOop = "");
  //! Looks up the parameters for a particular key and returns them.
  /*!
    \return a pointer to the MMFFOop object, NULL on failure.
  */
  const MMFFOop *operator()(const unsigned int iAtomType,
                            const unsigned int jAtomType,
                            const unsigned int kAtomType,
                            const unsigned int lAtomType) {
    MMFFDefCollection *mmffDef = MMFFDefCollection::getMMFFDef();
    const MMFFOop *mmffOopParams = NULL;
    unsigned int iter = 0;
    std::vector<unsigned int> canIKLAtomType(3);
// For out-of-plane bending ijk; I , where j is the central
// atom [cf. eq. (511, the five-stage protocol 1-1-1; 1, 2-2-2; 2,
// 3-2-3;3, 4-2-4;4, 5-2-5;5 is used. The final stage provides
// wild-card defaults for all except the central atom.
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
    std::map<const unsigned int,
             std::map<const unsigned int,
                      std::map<const unsigned int,
                               std::map<const unsigned int, MMFFOop> > > >::
        const_iterator res1;
    std::map<const unsigned int,
             std::map<const unsigned int,
                      std::map<const unsigned int, MMFFOop> > >::const_iterator
        res2;
    std::map<const unsigned int,
             std::map<const unsigned int, MMFFOop> >::const_iterator res3;
    std::map<const unsigned int, MMFFOop>::const_iterator res4;
    while ((iter < 4) && (!mmffOopParams)) {
      canIKLAtomType[0] = (*mmffDef)(iAtomType)->eqLevel[iter];
      unsigned int canJAtomType = jAtomType;
      canIKLAtomType[1] = (*mmffDef)(kAtomType)->eqLevel[iter];
      canIKLAtomType[2] = (*mmffDef)(lAtomType)->eqLevel[iter];
      std::sort(canIKLAtomType.begin(), canIKLAtomType.end());
      res1 = d_params.find(canIKLAtomType[0]);
      if (res1 != d_params.end()) {
        res2 = ((*res1).second).find(canJAtomType);
        if (res2 != ((*res1).second).end()) {
          res3 = ((*res2).second).find(canIKLAtomType[1]);
          if (res3 != ((*res2).second).end()) {
            res4 = ((*res3).second).find(canIKLAtomType[2]);
            if (res4 != ((*res3).second).end()) {
              mmffOopParams = &((*res4).second);
            }
          }
        }
      }
      ++iter;
    }
#else
    std::pair<std::vector<boost::uint8_t>::const_iterator,
              std::vector<boost::uint8_t>::const_iterator> jBounds =
        std::equal_range(d_jAtomType.begin(), d_jAtomType.end(), jAtomType);
    std::pair<std::vector<boost::uint8_t>::const_iterator,
              std::vector<boost::uint8_t>::const_iterator> bounds;
    if (jBounds.first != jBounds.second) {
      while ((iter < 4) && (!mmffOopParams)) {
        canIKLAtomType[0] = (*mmffDef)(iAtomType)->eqLevel[iter];
        canIKLAtomType[1] = (*mmffDef)(kAtomType)->eqLevel[iter];
        canIKLAtomType[2] = (*mmffDef)(lAtomType)->eqLevel[iter];
        std::sort(canIKLAtomType.begin(), canIKLAtomType.end());
        bounds = std::equal_range(
            d_iAtomType.begin() + (jBounds.first - d_jAtomType.begin()),
            d_iAtomType.begin() + (jBounds.second - d_jAtomType.begin()),
            canIKLAtomType[0]);
        if (bounds.first != bounds.second) {
          bounds = std::equal_range(
              d_kAtomType.begin() + (bounds.first - d_iAtomType.begin()),
              d_kAtomType.begin() + (bounds.second - d_iAtomType.begin()),
              canIKLAtomType[1]);
          if (bounds.first != bounds.second) {
            bounds = std::equal_range(
                d_lAtomType.begin() + (bounds.first - d_kAtomType.begin()),
                d_lAtomType.begin() + (bounds.second - d_kAtomType.begin()),
                canIKLAtomType[2]);
            if (bounds.first != bounds.second) {
              mmffOopParams = &d_params[bounds.first - d_lAtomType.begin()];
            }
          }
        }
        ++iter;
      }
    }
#endif

    return mmffOopParams;
  }

 private:
  //! to force this to be a singleton, the constructor must be private
  MMFFOopCollection(const bool isMMFFs, std::string mmffOop);
  static class MMFFOopCollection *ds_instance[2];  //!< the singleton
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
  std::map<const unsigned int,
           std::map<const unsigned int,
                    std::map<const unsigned int,
                             std::map<const unsigned int, MMFFOop> > > >
      d_params;  //!< the parameter 4D-map
#else
  std::vector<MMFFOop> d_params;            //!< the parameter vector
  std::vector<boost::uint8_t> d_iAtomType;  //! atom type vector for atom i
  std::vector<boost::uint8_t> d_jAtomType;  //! atom type vector for atom j
  std::vector<boost::uint8_t> d_kAtomType;  //! atom type vector for atom k
  std::vector<boost::uint8_t> d_lAtomType;  //! atom type vector for atom l
#endif
};

class RDKIT_FORCEFIELD_EXPORT MMFFTorCollection {
 public:
  //! gets a pointer to the singleton MMFFTorCollection
  /*!
    \param mmffTor (optional) a string with parameter data. See
     below for more information about this argument

    \return a pointer to the singleton MMFFTorCollection

    <b>Notes:</b>
      - do <b>not</b> delete the pointer returned here
      - if the singleton MMFFTorCollection has already been instantiated and
        \c mmffTor is empty, the singleton will be returned.
      - if \c mmffTor is empty and the singleton MMFFTorCollection has
        not yet been instantiated, the default parameters (from Params.cpp)
        will be used.
      - if \c mmffTor is supplied, a new singleton will be instantiated.
        The current instantiation (if there is one) will be deleted.
  */
  static MMFFTorCollection *getMMFFTor(const bool isMMFFs,
                                       const std::string &mmffTor = "");
  //! Looks up the parameters for a particular key and returns them.
  /*!
    \return a pointer to the MMFFTor object, NULL on failure.
  */
  const std::pair<const unsigned int, const MMFFTor *> getMMFFTorParams(
      const std::pair<unsigned int, unsigned int> torType,
      const unsigned int iAtomType, const unsigned int jAtomType,
      const unsigned int kAtomType, const unsigned int lAtomType) {
    MMFFDefCollection *mmffDef = MMFFDefCollection::getMMFFDef();
    const MMFFTor *mmffTorParams = NULL;
    unsigned int iter = 0;
    unsigned int iWildCard = 0;
    unsigned int lWildCard = 0;
    unsigned int canTorType = torType.first;
    unsigned int maxIter = 5;
// For i-j-k-2 torsion interactions, a five-stage
// process based on level combinations 1-1-1-1, 2-2-2-2,
// 3-2-2-5, 5-2-2-3, and 5-2-2-5 is used, where stages 3
// and 4 correspond to "half-default" or "half-wild-card" entries.
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
    std::map<
        const unsigned int,
        std::map<
            const unsigned int,
            std::map<const unsigned int,
                     std::map<const unsigned int,
                              std::map<const unsigned int, MMFFTor> > > > >::
        const_iterator res1;
    std::map<const unsigned int,
             std::map<const unsigned int,
                      std::map<const unsigned int,
                               std::map<const unsigned int, MMFFTor> > > >::
        const_iterator res2;
    std::map<const unsigned int,
             std::map<const unsigned int,
                      std::map<const unsigned int, MMFFTor> > >::const_iterator
        res3;
    std::map<const unsigned int,
             std::map<const unsigned int, MMFFTor> >::const_iterator res4;
    std::map<const unsigned int, MMFFTor>::const_iterator res5;
#else
    std::pair<std::vector<boost::uint8_t>::const_iterator,
              std::vector<boost::uint8_t>::const_iterator> jBounds;
    std::pair<std::vector<boost::uint8_t>::const_iterator,
              std::vector<boost::uint8_t>::const_iterator> bounds;
#endif

    while (((iter < maxIter) && ((!mmffTorParams) || (maxIter == 4))) ||
           ((iter == 4) && (torType.first == 5) && torType.second)) {
      // The rule of setting the torsion type to the value it had
      // before being set to 5 as a last resort in case parameters
      // could not be found is not mentioned in MMFF.IV; it was
      // empirically discovered due to a number of tests in the
      // MMFF validation suite otherwise failing
      if ((maxIter == 5) && (iter == 4)) {
        maxIter = 4;
        iter = 0;
        canTorType = torType.second;
      }
      iWildCard = iter;
      lWildCard = iter;
      if (iter == 1) {
        iWildCard = 1;
        lWildCard = 3;
      } else if (iter == 2) {
        iWildCard = 3;
        lWildCard = 1;
      }
      unsigned int canIAtomType = (*mmffDef)(iAtomType)->eqLevel[iWildCard];
      unsigned int canJAtomType = jAtomType;
      unsigned int canKAtomType = kAtomType;
      unsigned int canLAtomType = (*mmffDef)(lAtomType)->eqLevel[lWildCard];
      if (canJAtomType > canKAtomType) {
        unsigned int temp = canKAtomType;
        canKAtomType = canJAtomType;
        canJAtomType = temp;
        temp = canLAtomType;
        canLAtomType = canIAtomType;
        canIAtomType = temp;
      } else if ((canJAtomType == canKAtomType) &&
                 (canIAtomType > canLAtomType)) {
        unsigned int temp = canLAtomType;
        canLAtomType = canIAtomType;
        canIAtomType = temp;
      }
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
      res1 = d_params.find(canTorType);
      if (res1 != d_params.end()) {
        res2 = ((*res1).second).find(canIAtomType);
        if (res2 != ((*res1).second).end()) {
          res3 = ((*res2).second).find(canJAtomType);
          if (res3 != ((*res2).second).end()) {
            res4 = ((*res3).second).find(canKAtomType);
            if (res4 != ((*res3).second).end()) {
              res5 = ((*res4).second).find(canLAtomType);
              if (res5 != ((*res4).second).end()) {
                mmffTorParams = &((*res5).second);
                if (maxIter == 4) {
                  break;
                }
              }
            }
          }
        }
      }
#else
      jBounds = std::equal_range(d_jAtomType.begin(), d_jAtomType.end(),
                                 canJAtomType);
      if (jBounds.first != jBounds.second) {
        bounds = std::equal_range(
            d_kAtomType.begin() + (jBounds.first - d_jAtomType.begin()),
            d_kAtomType.begin() + (jBounds.second - d_jAtomType.begin()),
            canKAtomType);
        if (bounds.first != bounds.second) {
          bounds = std::equal_range(
              d_iAtomType.begin() + (bounds.first - d_kAtomType.begin()),
              d_iAtomType.begin() + (bounds.second - d_kAtomType.begin()),
              canIAtomType);
          if (bounds.first != bounds.second) {
            bounds = std::equal_range(
                d_lAtomType.begin() + (bounds.first - d_iAtomType.begin()),
                d_lAtomType.begin() + (bounds.second - d_iAtomType.begin()),
                canLAtomType);
            if (bounds.first != bounds.second) {
              bounds = std::equal_range(
                  d_torType.begin() + (bounds.first - d_lAtomType.begin()),
                  d_torType.begin() + (bounds.second - d_lAtomType.begin()),
                  canTorType);
              if (bounds.first != bounds.second) {
                mmffTorParams = &d_params[bounds.first - d_torType.begin()];
                if (maxIter == 4) {
                  break;
                }
              }
            }
          }
        }
      }
#endif
      ++iter;
    }

    return std::make_pair(canTorType, mmffTorParams);
  }

 private:
  //! to force this to be a singleton, the constructor must be private
  MMFFTorCollection(const bool isMMFFs, std::string mmffTor);
  static class MMFFTorCollection *ds_instance[2];  //!< the singleton
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
  std::map<const unsigned int,
           std::map<const unsigned int,
                    std::map<const unsigned int,
                             std::map<const unsigned int,
                                      std::map<const unsigned int,
                                               MMFFTor> > > > >
      d_params;  //!< the parameter 5D-map
#else
  std::vector<MMFFTor> d_params;            //!< the parameter vector
  std::vector<boost::uint8_t> d_iAtomType;  //! atom type vector for atom i
  std::vector<boost::uint8_t> d_jAtomType;  //! atom type vector for atom j
  std::vector<boost::uint8_t> d_kAtomType;  //! atom type vector for atom k
  std::vector<boost::uint8_t> d_lAtomType;  //! atom type vector for atom l
  std::vector<boost::uint8_t>
      d_torType;  //! torsion type vector for angle i-j-k-l
#endif
};

class RDKIT_FORCEFIELD_EXPORT MMFFVdWCollection {
 public:
  //! gets a pointer to the singleton MMFFVdWCollection
  /*!
    \param mmffVdW (optional) a string with parameter data. See
     below for more information about this argument

    \return a pointer to the singleton MMFFVdWCollection

    <b>Notes:</b>
      - do <b>not</b> delete the pointer returned here
      - if the singleton MMFFVdWCollection has already been instantiated and
        \c mmffVdW is empty, the singleton will be returned.
      - if \c mmffVdW is empty and the singleton MMFFVdWCollection has
        not yet been instantiated, the default parameters (from Params.cpp)
        will be used.
      - if \c mmffVdW is supplied, a new singleton will be instantiated.
        The current instantiation (if there is one) will be deleted.
  */
  double power;
  double B;
  double Beta;
  double DARAD;
  double DAEPS;
  static MMFFVdWCollection *getMMFFVdW(const std::string &mmffVdW = "");
  //! Looks up the parameters for a particular key and returns them.
  /*!
    \return a pointer to the MMFFVdW object, NULL on failure.
  */
  const MMFFVdW *operator()(const unsigned int atomType) const {
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
    std::map<const unsigned int, MMFFVdW>::const_iterator res;
    res = d_params.find(atomType);

    return (res != d_params.end() ? &((*res).second) : NULL);
#else
    std::pair<std::vector<boost::uint8_t>::const_iterator,
              std::vector<boost::uint8_t>::const_iterator> bounds =
        std::equal_range(d_atomType.begin(), d_atomType.end(), atomType);

    return ((bounds.first != bounds.second)
                ? &d_params[bounds.first - d_atomType.begin()]
                : NULL);
#endif
  }

 private:
  //! to force this to be a singleton, the constructor must be private
  MMFFVdWCollection(std::string mmffVdW);
  static class MMFFVdWCollection *ds_instance;  //!< the singleton
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
  std::map<const unsigned int, MMFFVdW> d_params;  //!< the parameter map
#else
  std::vector<MMFFVdW> d_params;           //!< the parameter vector
  std::vector<boost::uint8_t> d_atomType;  //! atom type vector
#endif
};
}
}

#endif