-
Notifications
You must be signed in to change notification settings - Fork 100
Implement NAGLChargesHandler #2048
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
Changes from 2 commits
d25a1a3
10db658
5f02826
de0f3df
58e3335
37b6417
47496ae
831bc8b
858d893
4dfe8e1
8153199
d1878fb
787c089
5981249
9b095f9
a16a426
1788c64
706c84c
3b5687f
0df39aa
800c2f1
ec518e7
ae283a8
ad9b5a0
c4a370c
62c0edb
78cfcdd
c37ab5a
fc431e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2722,6 +2722,16 @@ def test_charge_increment_one_ci_missing(self): | |
], | ||
) | ||
|
||
class TestNAGLChargesHandler: | ||
def test_nagl_charges_handler_serialization(self): | ||
from openff.toolkit.typing.engines.smirnoff import NAGLChargesHandler | ||
mattwthompson marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
handler = NAGLChargesHandler(model_file="openff-gnn-am1bcc-0.1.0-rc.3.pt", skip_version_check=True) | ||
assert handler.model_file == "openff-gnn-am1bcc-0.1.0-rc.3.pt" | ||
handler_dict = handler.to_dict() | ||
assert handler_dict["model_file"] == "openff-gnn-am1bcc-0.1.0-rc.3.pt" | ||
|
||
# TODO: test_nagl_charges_handler_are_compatible | ||
|
||
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. (certainly not blocking) the earlier tests looked at combinations of optional arguments missing but in ways that could be combined. A marginal add would be those cases in this test, but not particularly important |
||
|
||
class TestGBSAHandler: | ||
def test_create_default_gbsahandler(self): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ | |
"LibraryChargeHandler", | ||
"LibraryChargeType", | ||
"MappedParameterAttribute", | ||
"NAGLChargesHandler", | ||
"NotEnoughPointsForInterpolationError", | ||
"ParameterAttribute", | ||
"ParameterHandler", | ||
|
@@ -3253,6 +3254,41 @@ def find_matches(self, entity, unique=False): | |
unique=unique, | ||
) | ||
|
||
class NAGLChargesHandler(_NonbondedHandler): | ||
"""ParameterHandler for applying partial charges from a pretrained NAGL model.""" | ||
|
||
_TAGNAME = "NAGLCharges" | ||
_DEPENDENCIES = [vdWHandler, ElectrostaticsHandler, LibraryChargeHandler] | ||
_INFOTYPE = None # No separate parameter types; just a model path | ||
_MAX_SUPPORTED_SECTION_VERSION = Version("0.3") | ||
model_file = ParameterAttribute(converter=str) | ||
|
||
def check_handler_compatibility( | ||
self, | ||
other_handler: "NAGLChargesHandler", | ||
assume_missing_is_default: bool = True, | ||
): | ||
mattwthompson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
Checks whether this ParameterHandler encodes compatible physics as another ParameterHandler. This is | ||
called if a second handler is attempted to be initialized for the same tag. | ||
|
||
Parameters | ||
---------- | ||
other_handler | ||
The handler to compare to. | ||
assume_missing_is_default | ||
|
||
Raises | ||
------ | ||
IncompatibleParameterError if handler_kwargs are incompatible with existing parameters. | ||
""" | ||
if self.model_file != other_handler.model_file: | ||
raise IncompatibleParameterError("Attempted to initialize two NAGLCharges sections with different " | ||
"model_files: " | ||
f"{self.model_file=} is not identical to {other_handler.model_file=}") | ||
|
||
|
||
|
||
|
||
class ToolkitAM1BCCHandler(_NonbondedHandler): | ||
"""Handle SMIRNOFF ``<ToolkitAM1BCC>`` tags | ||
|
@@ -3261,7 +3297,7 @@ class ToolkitAM1BCCHandler(_NonbondedHandler): | |
""" | ||
|
||
_TAGNAME = "ToolkitAM1BCC" # SMIRNOFF tag name to process | ||
_DEPENDENCIES = [vdWHandler, ElectrostaticsHandler, LibraryChargeHandler] | ||
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. For better or worse, Interchange does not use this and I don't think anything else does |
||
_DEPENDENCIES = [vdWHandler, ElectrostaticsHandler, LibraryChargeHandler, NAGLChargesHandler] | ||
_KWARGS = ["toolkit_registry"] # Kwargs to catch when create_force is called | ||
|
||
def check_handler_compatibility( | ||
|
@@ -3382,6 +3418,7 @@ def find_matches(self, entity, unique=False): | |
return matches | ||
|
||
|
||
|
||
class GBSAHandler(ParameterHandler): | ||
"""Handle SMIRNOFF ``<GBSA>`` tags | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.