-
Notifications
You must be signed in to change notification settings - Fork 845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup: Force field #7406
Merged
Merged
Cleanup: Force field #7406
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
2ed6b55
fix unsigned int to int comparison
AnnaBruenisholz fd8a0f3
revert previous mistake
AnnaBruenisholz 2f6834c
declaration & init together, sinthetaSq in [0, 1]
AnnaBruenisholz 6e56c25
using std::swap
AnnaBruenisholz 4f3cd8f
use that sinThetaSq in [0,1]
AnnaBruenisholz 446845b
declare & init at same time
AnnaBruenisholz df28453
use knowledge about target range
AnnaBruenisholz 20d0bf9
use std::clamp
AnnaBruenisholz be8c773
use std::max
AnnaBruenisholz 2d21acc
numerically more stable trigonometrics
AnnaBruenisholz 786a0c5
numerically more stable trigonometrics
AnnaBruenisholz 3b9c2f7
numerically more stable trigonometrics
AnnaBruenisholz 0864889
range based for-loop
AnnaBruenisholz 8432eb9
actually do the assignement
AnnaBruenisholz a486b39
Update Code/ForceField/MMFF/Params.h
AnnaBruenisholz f56e8f0
implemented suggested changes
AnnaBruenisholz e9b778f
Revert "implemented suggested changes"
AnnaBruenisholz 09a73d2
auto typing
AnnaBruenisholz fbf1176
remove old comment
AnnaBruenisholz a627d7a
revert to numerically more stable expression
AnnaBruenisholz bd70aae
now correctly formatted
AnnaBruenisholz File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ | |
// 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 | ||
// #define RDKIT_MMFF_PARAMS_USE_STD_MAP 1 | ||
|
||
namespace ForceFields { | ||
namespace MMFF { | ||
|
@@ -43,13 +43,7 @@ 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; | ||
} | ||
} | ||
inline void clipToOne(double &x) { x = std::clamp(x, -1.0, 1.0); } | ||
|
||
//! class to store MMFF atom type equivalence levels | ||
class RDKIT_FORCEFIELD_EXPORT MMFFDef { | ||
|
@@ -178,9 +172,7 @@ class RDKIT_FORCEFIELD_EXPORT MMFFDefCollection { | |
*/ | ||
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); | ||
|
||
const auto res = d_params.find(atomType); | ||
return ((res != d_params.end()) ? &((*res).second) : NULL); | ||
#else | ||
return ((atomType && (atomType <= d_params.size())) | ||
|
@@ -206,16 +198,12 @@ class RDKIT_FORCEFIELD_EXPORT MMFFPropCollection { | |
*/ | ||
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); | ||
const auto res = d_params.find(atomType); | ||
|
||
return ((res != d_params.end()) ? &((*res).second) : NULL); | ||
#else | ||
std::pair<std::vector<std::uint8_t>::const_iterator, | ||
std::vector<std::uint8_t>::const_iterator> | ||
bounds = | ||
std::equal_range(d_iAtomType.begin(), d_iAtomType.end(), atomType); | ||
|
||
auto bounds = | ||
std::equal_range(d_iAtomType.begin(), d_iAtomType.end(), atomType); | ||
return ((bounds.first != bounds.second) | ||
? &d_params[bounds.first - d_iAtomType.begin()] | ||
: nullptr); | ||
|
@@ -239,9 +227,8 @@ class RDKIT_FORCEFIELD_EXPORT MMFFPBCICollection { | |
*/ | ||
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); | ||
|
||
std::map<const unsigned int, MMFFPBCI>::const_iterator res = | ||
d_params.find(atomType); | ||
return ((res != d_params.end()) ? &((*res).second) : NULL); | ||
#else | ||
return ((atomType && (atomType <= d_params.size())) | ||
|
@@ -278,22 +265,16 @@ class RDKIT_FORCEFIELD_EXPORT MMFFChgCollection { | |
sign = 1; | ||
} | ||
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP | ||
std::map<const unsigned int, | ||
std::map<const unsigned int, MMFFChg>>::const_iterator res1; | ||
const auto res1 = d_params[bondType].find(canIAtomType); | ||
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<std::uint8_t>::const_iterator, | ||
std::vector<std::uint8_t>::const_iterator> | ||
bounds; | ||
|
||
bounds = | ||
auto bounds = | ||
std::equal_range(d_iAtomType.begin(), d_iAtomType.end(), canIAtomType); | ||
if (bounds.first != bounds.second) { | ||
bounds = std::equal_range( | ||
|
@@ -350,11 +331,10 @@ class RDKIT_FORCEFIELD_EXPORT MMFFBondCollection { | |
std::map<const unsigned int, | ||
std::map<const unsigned int, | ||
std::map<const unsigned int, MMFFBond>>>::const_iterator | ||
res1; | ||
res1 = d_params.find(bondType); | ||
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()) { | ||
|
@@ -365,10 +345,7 @@ class RDKIT_FORCEFIELD_EXPORT MMFFBondCollection { | |
} | ||
} | ||
#else | ||
std::pair<std::vector<std::uint8_t>::const_iterator, | ||
std::vector<std::uint8_t>::const_iterator> | ||
bounds; | ||
bounds = | ||
auto bounds = | ||
std::equal_range(d_iAtomType.begin(), d_iAtomType.end(), canAtomType); | ||
if (bounds.first != bounds.second) { | ||
bounds = std::equal_range( | ||
|
@@ -420,21 +397,18 @@ class RDKIT_FORCEFIELD_EXPORT MMFFBndkCollection { | |
} | ||
#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 res1 = | ||
d_params.find(canAtomicNum); | ||
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<std::uint8_t>::const_iterator, | ||
std::vector<std::uint8_t>::const_iterator> | ||
bounds; | ||
bounds = std::equal_range(d_iAtomicNum.begin(), d_iAtomicNum.end(), | ||
canAtomicNum); | ||
auto 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()), | ||
|
@@ -477,20 +451,16 @@ class RDKIT_FORCEFIELD_EXPORT MMFFHerschbachLaurieCollection { | |
#ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP | ||
std::map<const unsigned int, | ||
std::map<const unsigned int, MMFFHerschbachLaurie>>::const_iterator | ||
res1; | ||
res1 = d_params.find(canIRow); | ||
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<std::uint8_t>::const_iterator, | ||
std::vector<std::uint8_t>::const_iterator> | ||
bounds; | ||
bounds = std::equal_range(d_iRow.begin(), d_iRow.end(), canIRow); | ||
auto 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()), | ||
|
@@ -525,16 +495,13 @@ class RDKIT_FORCEFIELD_EXPORT MMFFCovRadPauEleCollection { | |
*/ | ||
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); | ||
std::map<const unsigned int, MMFFCovRadPauEle>::const_iterator res = | ||
d_params.find(atomicNum); | ||
|
||
return ((res != d_params.end()) ? &((*res).second) : NULL); | ||
#else | ||
std::pair<std::vector<std::uint8_t>::const_iterator, | ||
std::vector<std::uint8_t>::const_iterator> | ||
bounds = | ||
std::equal_range(d_atomicNum.begin(), d_atomicNum.end(), atomicNum); | ||
|
||
auto bounds = | ||
std::equal_range(d_atomicNum.begin(), d_atomicNum.end(), atomicNum); | ||
return ((bounds.first != bounds.second) | ||
? &d_params[bounds.first - d_atomicNum.begin()] | ||
: nullptr); | ||
|
@@ -586,9 +553,9 @@ class RDKIT_FORCEFIELD_EXPORT MMFFAngleCollection { | |
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; | ||
unsigned int temp = canIAtomType; | ||
canIAtomType = canKAtomType; | ||
canKAtomType = temp; | ||
} | ||
res1 = d_params.find(angleType); | ||
if (res1 != d_params.end()) { | ||
|
@@ -606,10 +573,8 @@ class RDKIT_FORCEFIELD_EXPORT MMFFAngleCollection { | |
++iter; | ||
} | ||
#else | ||
std::pair<std::vector<std::uint8_t>::const_iterator, | ||
std::vector<std::uint8_t>::const_iterator> | ||
jBounds = | ||
std::equal_range(d_jAtomType.begin(), d_jAtomType.end(), jAtomType); | ||
auto jBounds = | ||
std::equal_range(d_jAtomType.begin(), d_jAtomType.end(), jAtomType); | ||
std::pair<std::vector<std::uint8_t>::const_iterator, | ||
std::vector<std::uint8_t>::const_iterator> | ||
bounds; | ||
|
@@ -618,10 +583,11 @@ class RDKIT_FORCEFIELD_EXPORT MMFFAngleCollection { | |
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; | ||
unsigned int temp = canIAtomType; | ||
canIAtomType = canKAtomType; | ||
canKAtomType = temp; | ||
Comment on lines
+562
to
+564
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
bounds = std::equal_range( | ||
d_iAtomType.begin() + (jBounds.first - d_jAtomType.begin()), | ||
d_iAtomType.begin() + (jBounds.second - d_jAtomType.begin()), | ||
|
@@ -692,15 +658,14 @@ class RDKIT_FORCEFIELD_EXPORT MMFFStbnCollection { | |
std::map<const unsigned int, | ||
std::map<const unsigned int, | ||
std::map<const unsigned int, MMFFStbn>>>>:: | ||
const_iterator res1; | ||
const_iterator res1 = d_params.find(canStretchBendType); | ||
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()) { | ||
|
@@ -714,10 +679,8 @@ class RDKIT_FORCEFIELD_EXPORT MMFFStbnCollection { | |
} | ||
} | ||
#else | ||
std::pair<std::vector<std::uint8_t>::const_iterator, | ||
std::vector<std::uint8_t>::const_iterator> | ||
jBounds = | ||
std::equal_range(d_jAtomType.begin(), d_jAtomType.end(), jAtomType); | ||
auto jBounds = | ||
std::equal_range(d_jAtomType.begin(), d_jAtomType.end(), jAtomType); | ||
std::pair<std::vector<std::uint8_t>::const_iterator, | ||
std::vector<std::uint8_t>::const_iterator> | ||
bounds; | ||
|
@@ -864,10 +827,8 @@ class RDKIT_FORCEFIELD_EXPORT MMFFOopCollection { | |
++iter; | ||
} | ||
#else | ||
std::pair<std::vector<std::uint8_t>::const_iterator, | ||
std::vector<std::uint8_t>::const_iterator> | ||
jBounds = | ||
std::equal_range(d_jAtomType.begin(), d_jAtomType.end(), jAtomType); | ||
auto jBounds = | ||
std::equal_range(d_jAtomType.begin(), d_jAtomType.end(), jAtomType); | ||
std::pair<std::vector<std::uint8_t>::const_iterator, | ||
std::vector<std::uint8_t>::const_iterator> | ||
bounds; | ||
|
@@ -1104,16 +1065,12 @@ class RDKIT_FORCEFIELD_EXPORT MMFFVdWCollection { | |
*/ | ||
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); | ||
|
||
std::map<const unsigned int, MMFFVdW>::const_iterator res = | ||
d_params.find(atomType); | ||
return (res != d_params.end() ? &((*res).second) : NULL); | ||
#else | ||
std::pair<std::vector<std::uint8_t>::const_iterator, | ||
std::vector<std::uint8_t>::const_iterator> | ||
bounds = | ||
std::equal_range(d_atomType.begin(), d_atomType.end(), atomType); | ||
|
||
auto bounds = | ||
std::equal_range(d_atomType.begin(), d_atomType.end(), atomType); | ||
return ((bounds.first != bounds.second) | ||
? &d_params[bounds.first - d_atomType.begin()] | ||
: nullptr); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could have been a
std::swap(canIAtomType, canKAtomType);