Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add supported charge methods to API #1834

Merged
merged 11 commits into from
Mar 22, 2024
Merged

Conversation

mattwthompson
Copy link
Member

@mattwthompson mattwthompson commented Mar 7, 2024

Implements #1830

In [1]: from openff.toolkit.utils import *

In [2]: for _class in GLOBAL_TOOLKIT_REGISTRY.registered_toolkits:
   ...:     print(_class.__class__.__name__, _class.supported_charge_methods)
   ...:
OpenEyeToolkitWrapper ['am1bcc', 'am1-mulliken', 'gasteiger', 'mmff94', 'am1bccnosymspt', 'am1elf10', 'am1bccelf10']
RDKitToolkitWrapper ['mmff94', 'gasteiger']
AmberToolsToolkitWrapper ['am1bcc', 'am1-mulliken', 'gasteiger']
BuiltInToolkitWrapper ['zeros', 'formal_charge']

In [3]: from openff.toolkit import Molecule

In [4]: molecule = Molecule.from_smiles("CCO")

In [5]: molecule.get_available_charge_methods()
Out[5]:
['am1elf10',
 'am1bccelf10',
 'zeros',
 'am1bcc',
 'gasteiger',
 'am1-mulliken',
 'am1bccnosymspt',
 'formal_charge',
 'mmff94']

In [6]: from openff.toolkit.utils.nagl_wrapper import NAGLToolkitWrapper

In [7]: NAGLToolkitWrapper().supported_charge_methods
Out[7]: ['openff-gnn-am1bcc-0.0.1-alpha.1.pt', 'openff-gnn-am1bcc-0.1.0-rc.1.pt']

Copy link

codecov bot commented Mar 7, 2024

Codecov Report

Merging #1834 (d9cd9b0) into main (858d55e) will decrease coverage by 0.01%.
The diff coverage is 96.15%.

❗ Current head d9cd9b0 differs from pull request most recent head 81e14e0. Consider uploading reports for the commit 81e14e0 to get more accurate results

Additional details and impacted files

@mattwthompson mattwthompson marked this pull request as ready for review March 7, 2024 19:06
@mattwthompson mattwthompson changed the title Supported charge methods api Add supported charge methods to API Mar 7, 2024
Copy link
Member

@j-wags j-wags left a comment

Choose a reason for hiding this comment

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

I generally like the structure and goals of this PR. Only blocking point is whether this needs to be an API break. It's possible I'm overlooking something but let's discuss on that review comment.

@@ -37,6 +37,26 @@ class AmberToolsToolkitWrapper(base_wrapper.ToolkitWrapper):
"The AmberTools toolkit (free and open source) can be found at "
"https://anaconda.org/conda-forge/ambertools"
)
_supported_charge_methods = {
Copy link
Member

Choose a reason for hiding this comment

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

(blocking) Would it be possible to leave this as SUPPORTED_CHARGE_METHODS to avoid an API change?

Copy link
Member Author

Choose a reason for hiding this comment

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

I can maintain the API at the cost of duplicated code

Copy link
Member Author

Choose a reason for hiding this comment

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

I've made an attempt to do that - unfortunately the wrappers disagree on what to call this attribute, so it's not easy to move it into the base class

@mattwthompson mattwthompson requested a review from j-wags March 21, 2024 21:45
Copy link
Member

@j-wags j-wags left a comment

Choose a reason for hiding this comment

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

Awesome, thanks @mattwthompson! Please update the releasenotes before you merge 🚀

@@ -9,6 +9,7 @@ Releases follow the `major.minor.micro` scheme recommended by [PEP440](https://w
## Current development

* #1798 Adds type annotations to most of the codebase.
* #1834 Adds `Molecule.get_available_charge_methods` and `BaseWrapper.supported_charge_methods`.
Copy link
Member Author

Choose a reason for hiding this comment

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

@j-wags just noting here that these have different names; I think there's okay reason for it

@mattwthompson mattwthompson merged commit 7c22c1e into main Mar 22, 2024
16 of 17 checks passed
@mattwthompson mattwthompson deleted the supported-charge-methods-api branch March 22, 2024 13:33
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants