Skip to content
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

Add explicit hydrogens if needed in from_openeye #364

Merged
merged 7 commits into from Jun 29, 2019
Merged

Conversation

j-wags
Copy link
Member

@j-wags j-wags commented Jun 19, 2019

@j-wags j-wags changed the title Explicitify OEMols with implicit Hs Add explicit hydrogens if needed in from_openeye Jun 19, 2019
@codecov-io
Copy link

codecov-io commented Jun 19, 2019

Codecov Report

Merging #364 into master will increase coverage by 0.01%.
The diff coverage is 90%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #364      +/-   ##
==========================================
+ Coverage   76.54%   76.56%   +0.01%     
==========================================
  Files          19       19              
  Lines        5585     5594       +9     
==========================================
+ Hits         4275     4283       +8     
- Misses       1310     1311       +1
Impacted Files Coverage Δ
openforcefield/utils/toolkits.py 87.1% <90%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3c34a22...e2df892. Read the comment docs.


# Add explicit hydrogens if they're implicit
if oechem.OEHasImplicitHydrogens(oemol):
oechem.OEAddExplicitHydrogens(oemol)
Copy link
Collaborator

@andrrizzi andrrizzi Jun 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure how we should do this, actually. Does this change make from_smiles(..., hydrogens_are_explicit=True) behave unexpectedly? I think that function calls from_openeye(). Maybe from_openeye() should take an argument to control this behavior as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow. Great thinking, I had totally missed the possible consequences there.

So, the case where this would be a problem is if the user provided a SMILES with a specific explicit protonation state, and the toolkit misinterpreted it as having implicit hydrogens (even though the user set hydrogens_are_explicit=True).

To prevent this from happening, I've updated both OpenEyeToolkitWrapper and RDKitToolkitWrapper's from_smiles functions to assert that, if hydrogens_are_explicit=True, then there are zero implicit hydrogens on the molecule.

Copy link
Collaborator

@andrrizzi andrrizzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you! I've added only a few minor comments, but feel free to merge when you think it's ready.

openforcefield/tests/test_toolkits.py Show resolved Hide resolved
openforcefield/tests/test_toolkits.py Show resolved Hide resolved
openforcefield/utils/toolkits.py Show resolved Hide resolved
openforcefield/utils/toolkits.py Outdated Show resolved Hide resolved
@j-wags j-wags merged commit 5c21a07 into master Jun 29, 2019
@j-wags j-wags deleted the from-oe-add-impl-hyd branch June 29, 2019 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected behavior: Parameter usage statistics incorrect when creating from SMILES without explicit hydrogens
3 participants