Let the force field resolve the partial charge assignment - #2152
Let the force field resolve the partial charge assignment#2152jthorton wants to merge 11 commits into
Conversation
|
No API break detected ✅ Griffe output |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2152 +/- ##
==========================================
- Coverage 95.20% 90.59% -4.61%
==========================================
Files 213 213
Lines 21138 21169 +31
==========================================
- Hits 20124 19178 -946
- Misses 1014 1991 +977
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| RDKitToolkitWrapper, | ||
| ) | ||
| from openff.units import unit | ||
| from sympy.codegen.ast import continue_ |
There was a problem hiding this comment.
good catch not sure why pycharm pulled that in!
| @@ -290,6 +291,7 @@ def assign_offmol_partial_charges( | |||
There was a problem hiding this comment.
I liked your idea yesterday of having a "forcefield" entry to make it clear that this is the method that was being applied.
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
# Conflicts: # src/openfe/tests/protocols/test_openmmutils.py
IAlibay
left a comment
There was a problem hiding this comment.
Couple of things - mainly it doesn't look like the CLI would work right now (maybe it just needs a test to check it).
| off_toolkit_backend: ambertools | ||
| number_of_conformers: None | ||
| nagl_model: None | ||
| forcefields: None |
There was a problem hiding this comment.
Are there other changes necessary to enable this on the CLI? If so and you want them in a different PR, I'd move these changes to a separate CLI-focused PR.
There was a problem hiding this comment.
Finished up the CLI support and added tests, I did intend to do it all in this PR.
| offmol: OFFMol, | ||
| overwrite: bool, | ||
| method: Literal["am1bcc", "am1bccelf10", "nagl", "espaloma"], | ||
| method: Literal["am1bcc", "am1bccelf10", "nagl", "espaloma", "forcefield"], |
There was a problem hiding this comment.
We'll need to update the OpenFFPartialChargeSettings to match this.
| forcefields = [forcefields] | ||
|
|
||
| # this expects the full file name of the force field offxml file, e.g. "openff-2.0.0.offxml" | ||
| # which is different to how settings work which can leave off the .offxml extension |
There was a problem hiding this comment.
I think now we can use .offxml directly right? Should we change the defaults?
Also what happens if this encounters a non .offxml str? Should we try to add it?
There was a problem hiding this comment.
Updated to accept both and added a test, and yes maybe the default should now have the extension as well.
| Charges are applied based on the following source preferences: | ||
| - Charges already present on the ligand are retained if overwrite is ``False`` | ||
| - Charges are applied using the input method and settings | ||
| - the forcefield option will apply the default charges as intended by the force field. |
There was a problem hiding this comment.
I think this is no longer true, is that correct?
There was a problem hiding this comment.
Updated to represent the correct ordering.
| # which is different to how settings work which can leave off the .offxml extension | ||
| ff = ForceField(*forcefields) | ||
| # let the force field resolve the partial charge assignment | ||
| charges = ff.get_partial_charges(offmol) |
There was a problem hiding this comment.
I believe this needs to get wrapped around toolkit_registry_manager, otherwise we'll go back to encountering the annoying rdkit & openeye toolkit aren't compatible problem.
There was a problem hiding this comment.
Probably but which registry would we use as it could influence the charge method used? I think the default is openeye and am1bccelf10 and then fall back to AmberToolsam1bcc?
| ) | ||
|
|
||
| assert uncharged_mol.partial_charges is not None | ||
| assert np.any(uncharged_mol.partial_charges) |
There was a problem hiding this comment.
Do you want to check against charging with ashgc directly?
There was a problem hiding this comment.
Yeah extended the test to cover this.
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
Fixes #2116, #2117
LLM / AI generated code disclosure
LLMs or other AI-powered tools (beyond simple IDE use cases) were used in this contribution: yes / no
If yes, please provide details here: No
Checklist
newsentry, or the changes are not user-facing.pre-commit.ci autofix.Manual Tests: these are slow so don't need to be run every commit, only before merging and when relevant changes are made (generally at reviewer-discretion).
Developers certificate of origin