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

Fix #837 #1214

Merged
merged 1 commit into from
Mar 11, 2022
Merged

Fix #837 #1214

merged 1 commit into from
Mar 11, 2022

Conversation

j-wags
Copy link
Member

@j-wags j-wags commented Mar 10, 2022

@codecov
Copy link

codecov bot commented Mar 10, 2022

Codecov Report

❗ No coverage uploaded for pull request base (topology-biopolymer-refactor@fa03d80). Click here to learn what that means.
The diff coverage is n/a.

@j-wags j-wags requested a review from mattwthompson March 11, 2022 19:59
Copy link
Member

@mattwthompson mattwthompson left a comment

Choose a reason for hiding this comment

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

LGTM. This is a behavior changed so I wanted to be thorough, but I couldn't find anything broken or surprising.

If I'm understanding the specification of this change correctly, it's simple: use amb1bccelf10 if OpenEye Toolkits are available, am1bcc otherwise. I created some systems locally with and without OpenEyeToolkitWrapper available in my development environment and this behavior is encoded as expected: the openmm.System has charges consistent molecule.assign_partial_charges(partial_charge_method="am1bccelf10") before uninstalling OpenEye and partial_charge_method="am1bcc" after.

I noticed that the ELF-10 variant of AM1-BCC is slower, at least when I call it directly on a molecule (presumably because it generates more conformers along the way?). I assume this was considered years ago when the SMIRNOFF spec was written with this behavior in mind. It just came as a small surprise to me.

The only issues I can imagine are out of scope here and arise from cases in which "OpenEye Toolkits are available" is not an identical condition to "OpenEyeToolkitWrapper is in the registry of toolkits". This assumption is already so heavily baked in everywhere that bigger problems would probably arise before we'd need to worry about ELF10 silently not being used - and adding any more testing around the license being available is, again, out of scope here.

@j-wags
Copy link
Member Author

j-wags commented Mar 11, 2022

Thanks for the quick review!

The only issues I can imagine are out of scope here and arise from cases in which "OpenEye Toolkits are available" is not an identical condition to "OpenEyeToolkitWrapper is in the registry of toolkits". This assumption is already so heavily baked in everywhere that bigger problems would probably arise before we'd need to worry about ELF10 silently not being used - and adding any more testing around the license being available is, again, out of scope here.

Agreed. There are lots of complex failure cases possible with weird OE conditions. I think there was an idea a while back of having different decorators/checks for different OE products. If partially-available-OE-products end up causing a lot of trouble then we could consider committing a few days to fix that. But I'll wait for user reports since that would take a significant amount of time to implement.

@j-wags j-wags merged commit 0c42148 into topology-biopolymer-refactor Mar 11, 2022
@j-wags j-wags deleted the use_elf10_if_oe_is_available branch March 11, 2022 21:44
@mattwthompson
Copy link
Member

This has caused a minor regression in cases in which the ELF10 variant of AM1-BCC cannot assign partial charges but the vanilla variant can. Few and far between, I ran into this in a virtual site test using molecular oxygen (with OpenEye Toolkits installed and licensed):

>>> from openff.toolkit.topology import Molecule
>>> molecule = Molecule.from_smiles("O=O")
>>> molecule.assign_partial_charges(partial_charge_method="am1bcc")
>>> molecule.partial_charges
<Quantity([0. 0.], 'elementary_charge')>
>>> molecule.assign_partial_charges(partial_charge_method="am1bccelf10")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/mwt/software/openforcefield/openff/toolkit/topology/molecule.py", line 3666, in assign_partial_charges
    toolkit_registry.call(
  File "/Users/mwt/software/openforcefield/openff/toolkit/utils/toolkit_registry.py", line 380, in call
    raise ValueError(msg)
ValueError: No registered toolkits can provide the capability "assign_partial_charges" for args "()" and kwargs "{'molecule': Molecule with name '' and SMILES 'O=O', 'partial_charge_method': 'am1bccelf10', 'use_conformers': None, 'strict_n_conformers': False, 'normalize_partial_charges': True, '_cls': <class 'openff.toolkit.topology.molecule.Molecule'>}"
Available toolkits are: [ToolkitWrapper around OpenEye Toolkit version 2021.2.0, ToolkitWrapper around The RDKit version 2021.09.5, ToolkitWrapper around AmberTools version 21.0, ToolkitWrapper around Built-in Toolkit version None]
 ToolkitWrapper around OpenEye Toolkit version 2021.2.0 <class 'openff.toolkit.utils.exceptions.ChargeCalculationError'> : Unable to assign charges: Warning: BCIChargeCorrector: BCI charge corrections for mol
Warning:                     missing bcc parameter for the O1-O2 bond (BCIType 310231)
Warning: Unable to assign all BCCs in

 ToolkitWrapper around The RDKit version 2021.09.5 <class 'openff.toolkit.utils.exceptions.ChargeMethodUnavailableError'> : partial_charge_method 'am1bccelf10' is not available from RDKitToolkitWrapper. Available charge methods are ['mmff94']
 ToolkitWrapper around AmberTools version 21.0 <class 'openff.toolkit.utils.exceptions.ChargeMethodUnavailableError'> : partial_charge_method 'am1bccelf10' is not available from AmberToolsToolkitWrapper. Available charge methods are ['am1bcc', 'am1-mulliken', 'gasteiger']
 ToolkitWrapper around Built-in Toolkit version None <class 'openff.toolkit.utils.exceptions.ChargeMethodUnavailableError'> : Partial charge method "am1bccelf10"" is not supported by the Built-in toolkit. Available charge methods are ['zeros', 'formal_charge']

It happens that we don't even have parameters to completely parametrize it:

>>> from openff.toolkit.typing.engines.smirnoff import ForceField
>>> sage = ForceField("openff-2.0.0.offxml")
>>> sage.create_openmm_system(molecule.to_topology())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/mwt/software/openforcefield/openff/toolkit/utils/utils.py", line 85, in wrapper
    return function(*args, **kwargs)
  File "/Users/mwt/software/openforcefield/openff/toolkit/typing/engines/smirnoff/forcefield.py", line 1268, in create_openmm_system
    return self._old_create_openmm_system(topology, **kwargs)
  File "/Users/mwt/software/openforcefield/openff/toolkit/utils/utils.py", line 85, in wrapper
    return function(*args, **kwargs)
  File "/Users/mwt/software/openforcefield/openff/toolkit/typing/engines/smirnoff/forcefield.py", line 1358, in _old_create_openmm_system
    parameter_handler.create_force(system, topology, **kwargs)
  File "/Users/mwt/miniconda3/envs/openff-dev/lib/python3.9/site-packages/openff/utilities/utilities.py", line 75, in wrapper
    return function(*args, **kwargs)
  File "/Users/mwt/software/openforcefield/openff/toolkit/typing/engines/smirnoff/parameters.py", line 2894, in create_force
    self._check_all_valence_terms_assigned(
  File "/Users/mwt/software/openforcefield/openff/toolkit/typing/engines/smirnoff/parameters.py", line 2434, in _check_all_valence_terms_assigned
    raise exception
openff.toolkit.utils.exceptions.UnassignedBondParameterException: BondHandler was not able to find parameters for the following valence terms:

- Topology indices (0, 1): names and elements ( O), ( O),

I don't know how many molecules exhibit this behavior. But I was able to assign partial charges before, and presumably still would in an environment that only had open source cheminformatics toolkits installed.

@j-wags
Copy link
Member Author

j-wags commented Mar 15, 2022

Thanks for reporting - I was a little concerned about this but I've been waiting to see if we have such a case for a druglike molecule. Right now I don't think we support parameterizing O2 (the second output in your post above is missing a bond parameter, unrelated to charge assignment), but if a druglike molecule comes along that works with OE AM1BCC "vanilla"but not AM1BCC ELF19 we can build in some fallback behavior.

There were some tricky cases where ELF10 would sometimes fail for carboxylates but those should have been fixed in #1171.

mattwthompson added a commit that referenced this pull request Mar 24, 2022
commit d34fe857e7cf28c312141bca58ff3b81173eecb0
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Thu Mar 24 13:27:43 2022 -0500

    Fix bad merge

commit 7d309f2
Merge: 9273dbb b373e40
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Thu Mar 24 11:42:15 2022 -0500

    Merge remote-tracking branch 'upstream/add-topology' into add-topology

commit 9273dbb
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Thu Mar 24 10:44:12 2022 -0500

    Fix mypy

commit 4ec3ea7
Merge: b8a5793 45fb642
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Thu Mar 24 10:41:13 2022 -0500

    Merge remote-tracking branch 'upstream/topology-biopolymer-refactor' into add-topology

commit 45fb642
Author: Matt Thompson <mattwthompson@protonmail.com>
Date:   Wed Mar 23 21:34:20 2022 -0500

    Raise descriptive error when OpenEye stereochemistry assumptions fail (#1218)

commit fc3d637
Author: Matt Thompson <mattwthompson@protonmail.com>
Date:   Wed Mar 23 21:33:52 2022 -0500

    Performance improvements in from_openeye (#1217)

    OpenMM quantities are generally as quick and lightweight as
    corresponding NumPy arrays, but Pint units tend to be slower. Most of
    these changes simply defer unit tagging until a final step, carrying
    values with implicit units in some internal functions where the units
    are known and can be expected not to vary.

commit b373e40
Merge: b8a5793 f297b64
Author: Jeff Wagner <jwagnerjpl@gmail.com>
Date:   Wed Mar 23 16:04:17 2022 -0700

    Merge branch 'topology-biopolymer-refactor' into add-topology

commit f297b64
Author: Matt Thompson <mattwthompson@protonmail.com>
Date:   Wed Mar 23 17:21:16 2022 -0500

    Fix incorrect assignment of TIP3P parameters in Sage (#1200) (#1220)

    * Add test for TIP3P charges with Sage

    * Do not uniquify SMARTS in LibraryChargeHandler

    * Also test standalone TIP3P file

    * Consolidate tip3p charge tests

    * black

    * Update release history

    Co-authored-by: j-wags <jwagnerjpl@gmail.com>

    Co-authored-by: j-wags <jwagnerjpl@gmail.com>

commit a8d8b09
Author: Jeff Wagner <jwagnerjpl@gmail.com>
Date:   Mon Mar 21 14:44:21 2022 -0700

    Resolve conflicts (#1224)

commit 8d4a0a8
Author: Matt Thompson <mattwthompson@protonmail.com>
Date:   Fri Mar 11 18:27:50 2022 -0600

    Remove un-used Topology attributes (#1213)

    * Remove un-used Topology attributes

    * Lint

    * Update release history

commit ba879b2
Author: Matt Thompson <mattwthompson@protonmail.com>
Date:   Fri Mar 11 18:26:50 2022 -0600

    Remove some internal calls to deprecated API points (#1204)

    * Remove some internal calls to deprecated API points

    * Fixes

    * Add test that deprecated Topology methods still exist

    * Fix broken list population

commit 59f35b8
Author: Matt Thompson <mattwthompson@protonmail.com>
Date:   Fri Mar 11 17:45:05 2022 -0600

    Avoid silent/implicit units checks in Topology.to_file, update docstring (#1207)

commit 46893b0
Author: Matt Thompson <mattwthompson@protonmail.com>
Date:   Fri Mar 11 16:15:22 2022 -0600

    Add Electrostatics tag to `test_forcefields/tip3p.offxml` (#1188)

    * Add Electrostatics section to data/test_forcefields/tip3p.offxml

    * Update release history

commit 0c42148
Author: Jeff Wagner <jwagnerjpl@gmail.com>
Date:   Fri Mar 11 13:43:59 2022 -0800

    fix #837 (#1214)

commit 0cb3a72
Author: Matt Thompson <mattwthompson@protonmail.com>
Date:   Thu Mar 10 14:34:37 2022 -0600

    Fix formatting in a `.assign_partial_charges` docstring (#1212)

commit b8a5793
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Wed Feb 9 11:58:02 2022 -0600

    Remove old mendeleev import

commit 373262a
Merge: 31c7755 0beef75
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Wed Feb 9 11:38:27 2022 -0600

    Merge remote-tracking branch 'upstream/topology-biopolymer-refactor' into add-topology

commit 31c7755
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Wed Feb 9 11:30:23 2022 -0600

    Update Topology.__add__/__iadd__, add tests, fix annotations

commit fc12de1
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Tue Feb 8 15:33:41 2022 -0600

    Add first implementation of Topoogy.__add__

commit 0321d99
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Thu Jan 27 12:30:12 2022 -0600

    Remove Atom.element

commit a2e7bf9
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Thu Jan 27 12:25:03 2022 -0600

    Fix virtual site creation

commit a383a0a
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Thu Jan 27 11:26:19 2022 -0600

    Fix setting masses while adding OpenMM particles

commit 37e86db
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Thu Jan 27 10:20:30 2022 -0600

    Fix more typos

commit 6555475
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Thu Jan 27 09:33:13 2022 -0600

    Fix typos, tests

commit c529ee0
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Wed Jan 26 18:49:04 2022 -0600

    Draft a refactor to openff.units.elements
mattwthompson added a commit to openforcefield/openff-interchange that referenced this pull request Mar 28, 2022
Co-authored-by: Jeff Wagner <jwagnerjpl@gmail.com>
mattwthompson pushed a commit that referenced this pull request Apr 4, 2022
mattwthompson added a commit that referenced this pull request Apr 4, 2022
* Port #1214 to 0.10.x line

* Update release history

Co-authored-by: Jeff Wagner <jwagnerjpl@gmail.com>
mattwthompson added a commit that referenced this pull request May 11, 2022
* Squashed commit of the following:

commit d34fe857e7cf28c312141bca58ff3b81173eecb0
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Thu Mar 24 13:27:43 2022 -0500

    Fix bad merge

commit 7d309f2
Merge: 9273dbb b373e40
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Thu Mar 24 11:42:15 2022 -0500

    Merge remote-tracking branch 'upstream/add-topology' into add-topology

commit 9273dbb
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Thu Mar 24 10:44:12 2022 -0500

    Fix mypy

commit 4ec3ea7
Merge: b8a5793 45fb642
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Thu Mar 24 10:41:13 2022 -0500

    Merge remote-tracking branch 'upstream/topology-biopolymer-refactor' into add-topology

commit 45fb642
Author: Matt Thompson <mattwthompson@protonmail.com>
Date:   Wed Mar 23 21:34:20 2022 -0500

    Raise descriptive error when OpenEye stereochemistry assumptions fail (#1218)

commit fc3d637
Author: Matt Thompson <mattwthompson@protonmail.com>
Date:   Wed Mar 23 21:33:52 2022 -0500

    Performance improvements in from_openeye (#1217)

    OpenMM quantities are generally as quick and lightweight as
    corresponding NumPy arrays, but Pint units tend to be slower. Most of
    these changes simply defer unit tagging until a final step, carrying
    values with implicit units in some internal functions where the units
    are known and can be expected not to vary.

commit b373e40
Merge: b8a5793 f297b64
Author: Jeff Wagner <jwagnerjpl@gmail.com>
Date:   Wed Mar 23 16:04:17 2022 -0700

    Merge branch 'topology-biopolymer-refactor' into add-topology

commit f297b64
Author: Matt Thompson <mattwthompson@protonmail.com>
Date:   Wed Mar 23 17:21:16 2022 -0500

    Fix incorrect assignment of TIP3P parameters in Sage (#1200) (#1220)

    * Add test for TIP3P charges with Sage

    * Do not uniquify SMARTS in LibraryChargeHandler

    * Also test standalone TIP3P file

    * Consolidate tip3p charge tests

    * black

    * Update release history

    Co-authored-by: j-wags <jwagnerjpl@gmail.com>

    Co-authored-by: j-wags <jwagnerjpl@gmail.com>

commit a8d8b09
Author: Jeff Wagner <jwagnerjpl@gmail.com>
Date:   Mon Mar 21 14:44:21 2022 -0700

    Resolve conflicts (#1224)

commit 8d4a0a8
Author: Matt Thompson <mattwthompson@protonmail.com>
Date:   Fri Mar 11 18:27:50 2022 -0600

    Remove un-used Topology attributes (#1213)

    * Remove un-used Topology attributes

    * Lint

    * Update release history

commit ba879b2
Author: Matt Thompson <mattwthompson@protonmail.com>
Date:   Fri Mar 11 18:26:50 2022 -0600

    Remove some internal calls to deprecated API points (#1204)

    * Remove some internal calls to deprecated API points

    * Fixes

    * Add test that deprecated Topology methods still exist

    * Fix broken list population

commit 59f35b8
Author: Matt Thompson <mattwthompson@protonmail.com>
Date:   Fri Mar 11 17:45:05 2022 -0600

    Avoid silent/implicit units checks in Topology.to_file, update docstring (#1207)

commit 46893b0
Author: Matt Thompson <mattwthompson@protonmail.com>
Date:   Fri Mar 11 16:15:22 2022 -0600

    Add Electrostatics tag to `test_forcefields/tip3p.offxml` (#1188)

    * Add Electrostatics section to data/test_forcefields/tip3p.offxml

    * Update release history

commit 0c42148
Author: Jeff Wagner <jwagnerjpl@gmail.com>
Date:   Fri Mar 11 13:43:59 2022 -0800

    fix #837 (#1214)

commit 0cb3a72
Author: Matt Thompson <mattwthompson@protonmail.com>
Date:   Thu Mar 10 14:34:37 2022 -0600

    Fix formatting in a `.assign_partial_charges` docstring (#1212)

commit b8a5793
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Wed Feb 9 11:58:02 2022 -0600

    Remove old mendeleev import

commit 373262a
Merge: 31c7755 0beef75
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Wed Feb 9 11:38:27 2022 -0600

    Merge remote-tracking branch 'upstream/topology-biopolymer-refactor' into add-topology

commit 31c7755
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Wed Feb 9 11:30:23 2022 -0600

    Update Topology.__add__/__iadd__, add tests, fix annotations

commit fc12de1
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Tue Feb 8 15:33:41 2022 -0600

    Add first implementation of Topoogy.__add__

commit 0321d99
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Thu Jan 27 12:30:12 2022 -0600

    Remove Atom.element

commit a2e7bf9
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Thu Jan 27 12:25:03 2022 -0600

    Fix virtual site creation

commit a383a0a
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Thu Jan 27 11:26:19 2022 -0600

    Fix setting masses while adding OpenMM particles

commit 37e86db
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Thu Jan 27 10:20:30 2022 -0600

    Fix more typos

commit 6555475
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Thu Jan 27 09:33:13 2022 -0600

    Fix typos, tests

commit c529ee0
Author: Matthew W. Thompson <mattwthompson@protonmail.com>
Date:   Wed Jan 26 18:49:04 2022 -0600

    Draft a refactor to openff.units.elements

* Preserve constraints in `Topology.__add__`

* Update release history
# 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