12#ifndef RD_MMFFPARAMS_H
13#define RD_MMFFPARAMS_H
25#define M_PI 3.14159265358979323846
42 return ((x < 1.0e-10) && (x > -1.0e-10));
44inline void clipToOne(
double &x) { x = std::clamp(x, -1.0, 1.0); }
172#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
173 const auto res =
d_params.find(atomType);
174 return ((res !=
d_params.end()) ? &((*res).second) : NULL);
176 return ((atomType && (atomType <=
d_params.size()))
184#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
185 std::map<const unsigned int, MMFFDef>
d_params;
198#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
199 const auto res =
d_params.find(atomType);
200 return ((res !=
d_params.end()) ? &((*res).second) : NULL);
204 return ((bounds.first != bounds.second)
211#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
212 std::map<const unsigned int, MMFFProp>
d_params;
226#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
227 const auto res =
d_params.find(atomType);
228 return ((res !=
d_params.end()) ? &((*res).second) : NULL);
230 return ((atomType && (atomType <=
d_params.size()))
238#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
239 std::map<const unsigned int, MMFFPBCI>
d_params;
252 const unsigned int bondType,
const unsigned int iAtomType,
253 const unsigned int jAtomType)
const {
255 const MMFFChg *mmffChgParams =
nullptr;
256 unsigned int canIAtomType = iAtomType;
257 unsigned int canJAtomType = jAtomType;
258 if (iAtomType > jAtomType) {
259 canIAtomType = jAtomType;
260 canJAtomType = iAtomType;
263#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
264 const auto res1 =
d_params[bondType].find(canIAtomType);
265 if (res1 !=
d_params[bondType].end()) {
266 const auto res2 = ((*res1).second).find(canJAtomType);
267 if (res2 != ((*res1).second).end()) {
268 mmffChgParams = &((*res2).second);
274 if (bounds.first != bounds.second) {
275 bounds = std::equal_range(
279 if (bounds.first != bounds.second) {
280 bounds = std::equal_range(
284 if (bounds.first != bounds.second) {
291 return std::make_pair(sign, mmffChgParams);
297#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
298 std::map<
const unsigned int,
299 std::map<const unsigned int, std::map<const unsigned int, MMFFChg>>>
316 const unsigned int atomType,
317 const unsigned int nbrAtomType)
const {
318 const MMFFBond *mmffBondParams =
nullptr;
319 unsigned int canAtomType = atomType;
320 unsigned int canNbrAtomType = nbrAtomType;
321 if (atomType > nbrAtomType) {
322 canAtomType = nbrAtomType;
323 canNbrAtomType = atomType;
325#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
326 const auto res1 =
d_params.find(bondType);
327 std::map<
const unsigned int,
328 std::map<const unsigned int, MMFFBond>>::const_iterator res2;
329 std::map<const unsigned int, MMFFBond>::const_iterator res3;
331 res2 = ((*res1).second).find(canAtomType);
332 if (res2 != ((*res1).second).end()) {
333 res3 = ((*res2).second).find(canNbrAtomType);
334 if (res3 != ((*res2).second).end()) {
335 mmffBondParams = &((*res3).second);
342 if (bounds.first != bounds.second) {
343 bounds = std::equal_range(
347 if (bounds.first != bounds.second) {
348 bounds = std::equal_range(
352 if (bounds.first != bounds.second) {
359 return mmffBondParams;
363#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
364 std::map<
const unsigned int,
365 std::map<const unsigned int, std::map<const unsigned int, MMFFBond>>>
382 const int nbrAtomicNum)
const {
383 const MMFFBond *mmffBndkParams =
nullptr;
384 unsigned int canAtomicNum = atomicNum;
385 unsigned int canNbrAtomicNum = nbrAtomicNum;
386 if (atomicNum > nbrAtomicNum) {
387 canAtomicNum = nbrAtomicNum;
388 canNbrAtomicNum = atomicNum;
390#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
391 const auto res1 =
d_params.find(canAtomicNum);
392 std::map<const unsigned int, MMFFBond>::const_iterator res2;
394 res2 = ((*res1).second).find(canNbrAtomicNum);
395 if (res2 != ((*res1).second).end()) {
396 mmffBndkParams = &((*res2).second);
402 if (bounds.first != bounds.second) {
403 bounds = std::equal_range(
407 if (bounds.first != bounds.second) {
413 return mmffBndkParams;
417#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
418 std::map<const unsigned int, std::map<const unsigned int, MMFFBond>>
435 unsigned int canIRow = iRow;
436 unsigned int canJRow = jRow;
441#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
442 const auto res1 =
d_params.find(canIRow);
443 std::map<const unsigned int, MMFFHerschbachLaurie>::const_iterator res2;
445 res2 = ((*res1).second).find(canJRow);
446 if (res2 != ((*res1).second).end()) {
447 mmffHerschbachLaurieParams = &((*res2).second);
451 auto bounds = std::equal_range(
d_iRow.begin(),
d_iRow.end(), canIRow);
452 if (bounds.first != bounds.second) {
453 bounds = std::equal_range(
455 d_jRow.begin() + (bounds.second -
d_iRow.begin()), canJRow);
456 if (bounds.first != bounds.second) {
457 mmffHerschbachLaurieParams = &
d_params[bounds.first -
d_jRow.begin()];
462 return mmffHerschbachLaurieParams;
467#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
468 std::map<
const unsigned int,
469 std::map<const unsigned int, MMFFHerschbachLaurie>>
485#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
486 const auto res =
d_params.find(atomicNum);
487 return ((res !=
d_params.end()) ? &((*res).second) : NULL);
491 return ((bounds.first != bounds.second)
498#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
499 std::map<const unsigned int, MMFFCovRadPauEle>
514 const unsigned int angleType,
515 const unsigned int iAtomType,
516 const unsigned int jAtomType,
517 const unsigned int kAtomType)
const {
518 const MMFFAngle *mmffAngleParams =
nullptr;
519 unsigned int iter = 0;
525#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
526 while ((iter < 4) && (!mmffAngleParams)) {
527 unsigned int canIAtomType = (*mmffDef)(iAtomType)->eqLevel[iter];
528 unsigned int canKAtomType = (*mmffDef)(kAtomType)->eqLevel[iter];
529 if (canIAtomType > canKAtomType) {
530 std::swap(canIAtomType, canKAtomType);
532 const auto res1 =
d_params.find(angleType);
534 const auto res2 = ((*res1).second).find(canIAtomType);
535 if (res2 != ((*res1).second).end()) {
536 const auto res3 = ((*res2).second).find(jAtomType);
537 if (res3 != ((*res2).second).end()) {
538 const auto res4 = ((*res3).second).find(canKAtomType);
539 if (res4 != ((*res3).second).end()) {
540 mmffAngleParams = &((*res4).second);
550 if (jBounds.first != jBounds.second) {
551 while ((iter < 4) && (!mmffAngleParams)) {
552 unsigned int canIAtomType = (*mmffDef)(iAtomType)->eqLevel[iter];
553 unsigned int canKAtomType = (*mmffDef)(kAtomType)->eqLevel[iter];
554 if (canIAtomType > canKAtomType) {
555 std::swap(canIAtomType, canKAtomType);
558 auto bounds = std::equal_range(
562 if (bounds.first != bounds.second) {
563 bounds = std::equal_range(
567 if (bounds.first != bounds.second) {
568 bounds = std::equal_range(
572 if (bounds.first != bounds.second) {
582 return mmffAngleParams;
586#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
587 std::map<
const unsigned int,
588 std::map<
const unsigned int,
589 std::map<
const unsigned int,
590 std::map<const unsigned int, MMFFAngle>>>>
608 const unsigned int stretchBendType,
const unsigned int bondType1,
609 const unsigned int bondType2,
const unsigned int iAtomType,
610 const unsigned int jAtomType,
const unsigned int kAtomType)
const {
611 const MMFFStbn *mmffStbnParams =
nullptr;
613 unsigned int canIAtomType = iAtomType;
614 unsigned int canKAtomType = kAtomType;
615 unsigned int canStretchBendType = stretchBendType;
616 if (iAtomType > kAtomType) {
617 canIAtomType = kAtomType;
618 canKAtomType = iAtomType;
620 }
else if (iAtomType == kAtomType) {
621 swap = (bondType1 < bondType2);
623#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
624 const auto res1 =
d_params.find(canStretchBendType);
626 const auto res2 = ((*res1).second).find(canIAtomType);
627 if (res2 != ((*res1).second).end()) {
628 const auto res3 = ((*res2).second).find(jAtomType);
629 if (res3 != ((*res2).second).end()) {
630 const auto res4 = ((*res3).second).find(canKAtomType);
631 if (res4 != ((*res3).second).end()) {
632 mmffStbnParams = &((*res4).second);
640 if (jBounds.first != jBounds.second) {
641 auto bounds = std::equal_range(
645 if (bounds.first != bounds.second) {
646 bounds = std::equal_range(
650 if (bounds.first != bounds.second) {
651 bounds = std::equal_range(
655 if (bounds.first != bounds.second) {
664 return std::make_pair(swap, mmffStbnParams);
668#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
669 std::map<
const unsigned int,
670 std::map<
const unsigned int,
671 std::map<
const unsigned int,
672 std::map<const unsigned int, MMFFStbn>>>>
679 std::vector<std::uint8_t>
691 const unsigned int periodicTableRow1,
692 const unsigned int periodicTableRow2,
693 const unsigned int periodicTableRow3)
const {
694 const MMFFStbn *mmffDfsbParams =
nullptr;
696 unsigned int canPeriodicTableRow1 = periodicTableRow1;
697 unsigned int canPeriodicTableRow3 = periodicTableRow3;
698 if (periodicTableRow1 > periodicTableRow3) {
699 canPeriodicTableRow1 = periodicTableRow3;
700 canPeriodicTableRow3 = periodicTableRow1;
703 const auto res1 =
d_params.find(canPeriodicTableRow1);
705 const auto res2 = ((*res1).second).find(periodicTableRow2);
706 if (res2 != ((*res1).second).end()) {
707 const auto res3 = ((*res2).second).find(canPeriodicTableRow3);
708 if (res3 != ((*res2).second).end()) {
709 mmffDfsbParams = &((*res3).second);
714 return std::make_pair(swap, mmffDfsbParams);
718 std::map<
const unsigned int,
719 std::map<const unsigned int, std::map<const unsigned int, MMFFStbn>>>
730 const unsigned int iAtomType,
731 const unsigned int jAtomType,
732 const unsigned int kAtomType,
733 const unsigned int lAtomType)
const {
734 const MMFFOop *mmffOopParams =
nullptr;
735 unsigned int iter = 0;
736 std::vector<unsigned int> canIKLAtomType(3);
741#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
742 while ((iter < 4) && (!mmffOopParams)) {
743 canIKLAtomType[0] = (*mmffDef)(iAtomType)->eqLevel[iter];
744 unsigned int canJAtomType = jAtomType;
745 canIKLAtomType[1] = (*mmffDef)(kAtomType)->eqLevel[iter];
746 canIKLAtomType[2] = (*mmffDef)(lAtomType)->eqLevel[iter];
747 std::sort(canIKLAtomType.begin(), canIKLAtomType.end());
748 const auto res1 =
d_params.find(canIKLAtomType[0]);
750 const auto res2 = ((*res1).second).find(canJAtomType);
751 if (res2 != ((*res1).second).end()) {
752 const auto res3 = ((*res2).second).find(canIKLAtomType[1]);
753 if (res3 != ((*res2).second).end()) {
754 const auto res4 = ((*res3).second).find(canIKLAtomType[2]);
755 if (res4 != ((*res3).second).end()) {
756 mmffOopParams = &((*res4).second);
766 if (jBounds.first != jBounds.second) {
767 while ((iter < 4) && (!mmffOopParams)) {
768 canIKLAtomType[0] = (*mmffDef)(iAtomType)->eqLevel[iter];
769 canIKLAtomType[1] = (*mmffDef)(kAtomType)->eqLevel[iter];
770 canIKLAtomType[2] = (*mmffDef)(lAtomType)->eqLevel[iter];
771 std::sort(canIKLAtomType.begin(), canIKLAtomType.end());
772 auto bounds = std::equal_range(
776 if (bounds.first != bounds.second) {
777 bounds = std::equal_range(
781 if (bounds.first != bounds.second) {
782 bounds = std::equal_range(
786 if (bounds.first != bounds.second) {
796 return mmffOopParams;
801#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
802 std::map<
const unsigned int,
803 std::map<
const unsigned int,
804 std::map<
const unsigned int,
805 std::map<const unsigned int, MMFFOop>>>>
824 const std::pair<unsigned int, unsigned int> torType,
825 const unsigned int iAtomType,
const unsigned int jAtomType,
826 const unsigned int kAtomType,
const unsigned int lAtomType)
const {
827 const MMFFTor *mmffTorParams =
nullptr;
828 unsigned int iter = 0;
829 unsigned int iWildCard = 0;
830 unsigned int lWildCard = 0;
831 unsigned int canTorType = torType.first;
832 unsigned int maxIter = 5;
837#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
841 while (((iter < maxIter) && ((!mmffTorParams) || (maxIter == 4))) ||
842 ((iter == 4) && (torType.first == 5) && torType.second)) {
848 if ((maxIter == 5) && (iter == 4)) {
851 canTorType = torType.second;
858 }
else if (iter == 2) {
862 unsigned int canIAtomType = (*mmffDef)(iAtomType)->eqLevel[iWildCard];
863 unsigned int canJAtomType = jAtomType;
864 unsigned int canKAtomType = kAtomType;
865 unsigned int canLAtomType = (*mmffDef)(lAtomType)->eqLevel[lWildCard];
866 if (canJAtomType > canKAtomType) {
867 unsigned int temp = canKAtomType;
868 canKAtomType = canJAtomType;
871 canLAtomType = canIAtomType;
873 }
else if ((canJAtomType == canKAtomType) &&
874 (canIAtomType > canLAtomType)) {
875 unsigned int temp = canLAtomType;
876 canLAtomType = canIAtomType;
879#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
880 const auto res1 =
d_params.find(canTorType);
882 const auto res2 = ((*res1).second).find(canIAtomType);
883 if (res2 != ((*res1).second).end()) {
884 const auto res3 = ((*res2).second).find(canJAtomType);
885 if (res3 != ((*res2).second).end()) {
886 const auto res4 = ((*res3).second).find(canKAtomType);
887 if (res4 != ((*res3).second).end()) {
888 const auto res5 = ((*res4).second).find(canLAtomType);
889 if (res5 != ((*res4).second).end()) {
890 mmffTorParams = &((*res5).second);
902 if (jBounds.first != jBounds.second) {
903 auto bounds = std::equal_range(
907 if (bounds.first != bounds.second) {
908 bounds = std::equal_range(
912 if (bounds.first != bounds.second) {
913 bounds = std::equal_range(
917 if (bounds.first != bounds.second) {
918 bounds = std::equal_range(
922 if (bounds.first != bounds.second) {
936 return std::make_pair(canTorType, mmffTorParams);
940#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
945 std::map<
const unsigned int,
946 std::map<
const unsigned int, std::map<
const unsigned int,
955 std::vector<std::uint8_t>
973#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
974 const auto res =
d_params.find(atomType);
975 return (res !=
d_params.end() ? &((*res).second) : NULL);
979 return ((bounds.first != bounds.second)
986#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP
987 std::map<const unsigned int, MMFFVdW>
d_params;
const MMFFAngle * operator()(const MMFFDefCollection *mmffDef, const unsigned int angleType, const unsigned int iAtomType, const unsigned int jAtomType, const unsigned int kAtomType) const
Looks up the parameters for a particular key and returns them.
std::vector< MMFFAngle > d_params
the parameter vector
std::vector< std::uint8_t > d_angleType
angle type vector for angle i-j-k
MMFFAngleCollection(std::string mmffAngle="")
std::vector< std::uint8_t > d_kAtomType
atom type vector for atom k
std::vector< std::uint8_t > d_jAtomType
atom type vector for atom j
std::vector< std::uint8_t > d_iAtomType
atom type vector for atom i
class to store MMFF parameters for angle bending
MMFFAromCollection(const std::vector< std::uint8_t > *mmffArom=nullptr)
std::vector< std::uint8_t > d_params
the aromatic type vector
bool isMMFFAromatic(const unsigned int atomType) const
Looks up the parameters for a particular key and returns them.
MMFFBndkCollection(std::string mmffBndk="")
std::vector< std::uint8_t > d_jAtomicNum
atomic number vector for atom j
std::vector< std::uint8_t > d_iAtomicNum
atomic number vector for atom i
std::vector< MMFFBond > d_params
the parameter vector
const MMFFBond * operator()(const int atomicNum, const int nbrAtomicNum) const
Looks up the parameters for a particular key and returns them.
std::vector< std::uint8_t > d_jAtomType
atom type vector for atom j
std::vector< std::uint8_t > d_bondType
bond type vector for bond i-j
std::vector< std::uint8_t > d_iAtomType
atom type vector for atom i
MMFFBondCollection(std::string mmffBond="")
const MMFFBond * operator()(const unsigned int bondType, const unsigned int atomType, const unsigned int nbrAtomType) const
Looks up the parameters for a particular key and returns them.
std::vector< MMFFBond > d_params
the parameter vector
class to store MMFF parameters for bond stretching
std::vector< MMFFChg > d_params
the parameter vector
std::vector< std::uint8_t > d_jAtomType
atom type vector for atom j
MMFFChgCollection(std::string mmffChg="")
the parameter 3D-map
const std::pair< int, const MMFFChg * > getMMFFChgParams(const unsigned int bondType, const unsigned int iAtomType, const unsigned int jAtomType) const
Looks up the parameters for a particular key and returns them.
std::vector< std::uint8_t > d_iAtomType
atom type vector for atom i
std::vector< std::uint8_t > d_bondType
bond type vector for bond i-j
const MMFFCovRadPauEle * operator()(const unsigned int atomicNum) const
Looks up the parameters for a particular key and returns them.
std::vector< MMFFCovRadPauEle > d_params
the parameter vector
std::vector< std::uint8_t > d_atomicNum
the atomic number vector
MMFFCovRadPauEleCollection(std::string mmffCovRadPauEle="")
const MMFFDef * operator()(const unsigned int atomType) const
Looks up the parameters for a particular key and returns them.
std::vector< MMFFDef > d_params
the parameter vector
MMFFDefCollection(std::string mmffDef="")
class to store MMFF atom type equivalence levels
const std::pair< bool, const MMFFStbn * > getMMFFDfsbParams(const unsigned int periodicTableRow1, const unsigned int periodicTableRow2, const unsigned int periodicTableRow3) const
Looks up the parameters for a particular key and returns them.
MMFFDfsbCollection(std::string mmffDfsb="")
std::map< const unsigned int, std::map< const unsigned int, std::map< const unsigned int, MMFFStbn > > > d_params
the parameter 3D-map
const MMFFHerschbachLaurie * operator()(const int iRow, const int jRow) const
Looks up the parameters for a particular key and returns them.
std::vector< std::uint8_t > d_iRow
periodic row number vector for atom i
std::vector< std::uint8_t > d_jRow
periodic row number vector for atom j
MMFFHerschbachLaurieCollection(std::string mmffHerschbachLaurie="")
std::vector< MMFFHerschbachLaurie > d_params
the parameter vector
MMFFOopCollection(const bool isMMFFs, std::string mmffOop="")
std::vector< std::uint8_t > d_iAtomType
atom type vector for atom i
std::vector< std::uint8_t > d_kAtomType
atom type vector for atom k
std::vector< MMFFOop > d_params
the parameter vector
const MMFFOop * operator()(const MMFFDefCollection *mmffDef, const unsigned int iAtomType, const unsigned int jAtomType, const unsigned int kAtomType, const unsigned int lAtomType) const
Looks up the parameters for a particular key and returns them.
std::vector< std::uint8_t > d_jAtomType
atom type vector for atom j
std::vector< std::uint8_t > d_lAtomType
atom type vector for atom l
class to store MMFF parameters for out-of-plane bending
const MMFFPBCI * operator()(const unsigned int atomType) const
Looks up the parameters for a particular key and returns them.
MMFFPBCICollection(std::string mmffPBCI="")
std::vector< MMFFPBCI > d_params
the parameter vector
class to store MMFF Partial Bond Charge Increments
const MMFFProp * operator()(const unsigned int atomType) const
Looks up the parameters for a particular key and returns them.
std::vector< MMFFProp > d_params
MMFFPropCollection(std::string mmffProp="")
std::vector< std::uint8_t > d_iAtomType
the parameter vector
class to store MMFF Properties
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
Looks up the parameters for a particular key and returns them.
MMFFStbnCollection(std::string mmffStbn="")
std::vector< std::uint8_t > d_jAtomType
atom type vector for atom j
std::vector< std::uint8_t > d_stretchBendType
stretch-bend type vector for angle i-j-k
std::vector< MMFFStbn > d_params
the parameter vector
std::vector< std::uint8_t > d_kAtomType
atom type vector for atom k
std::vector< std::uint8_t > d_iAtomType
atom type vector for atom i
class to store MMFF parameters for stretch-bending
std::vector< std::uint8_t > d_jAtomType
atom type vector for atom j
MMFFTorCollection(const bool isMMFFs, std::string mmffTor="")
std::vector< std::uint8_t > d_kAtomType
atom type vector for atom k
std::vector< std::uint8_t > d_torType
torsion type vector for angle i-j-k-l
const std::pair< const unsigned int, const MMFFTor * > getMMFFTorParams(const MMFFDefCollection *mmffDef, const std::pair< unsigned int, unsigned int > torType, const unsigned int iAtomType, const unsigned int jAtomType, const unsigned int kAtomType, const unsigned int lAtomType) const
Looks up the parameters for a particular key and returns them.
std::vector< std::uint8_t > d_lAtomType
atom type vector for atom l
std::vector< MMFFTor > d_params
the parameter vector
std::vector< std::uint8_t > d_iAtomType
atom type vector for atom i
class to store MMFF parameters for torsions
double power
gets a pointer to the singleton MMFFVdWCollection
std::vector< MMFFVdW > d_params
the parameter vector
MMFFVdWCollection(std::string mmffVdW="")
std::vector< std::uint8_t > d_atomType
atom type vector
const MMFFVdW * operator()(const unsigned int atomType) const
Looks up the parameters for a particular key and returns them.
class to store MMFF parameters for non-bonded Van der Waals
#define RDKIT_FORCEFIELD_EXPORT
constexpr double MDYNE_A_TO_KCAL_MOL
bool isDoubleZero(const double x)
void clipToOne(double &x)