-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
162 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import pytest | ||
from importlib import resources | ||
import gzip | ||
|
||
|
||
@pytest.fixture | ||
def afe_solv_transformation_json() -> str: | ||
""" | ||
ASFE results object as created by quickrun. | ||
generated with devtools/gent-serialized-results.py | ||
""" | ||
d = resources.files("pontibus.tests.data.solvation_protocol") | ||
fname = "ASFEProtocol_json_results.gz" | ||
|
||
with gzip.open((d / fname).as_posix(), "r") as f: | ||
return f.read().decode() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
src/pontibus/tests/protocols/solvation/test_tokenization.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# This code is part of OpenFE and is licensed under the MIT license. | ||
# For details, see https://github.com/OpenFreeEnergy/openfe | ||
import json | ||
import pytest | ||
|
||
import gufe | ||
from gufe.tests.test_tokenization import GufeTokenizableTestsMixin | ||
import openfe | ||
from pontibus.protocols.solvation import ( | ||
ASFEProtocol, | ||
ASFEProtocolResult, | ||
ASFESolventUnit, | ||
ASFEVacuumUnit, | ||
) | ||
from pontibus.components import ExtendedSolventComponent | ||
|
||
|
||
@pytest.fixture | ||
def protocol(): | ||
return ASFEProtocol(ASFEProtocol.default_settings()) | ||
|
||
|
||
@pytest.fixture | ||
def protocol_units(protocol, benzene_modifications): | ||
pus = protocol.create( | ||
stateA=openfe.ChemicalSystem( | ||
{ | ||
"solute": benzene_modifications["benzene"], | ||
"solvent": ExtendedSolventComponent(), | ||
} | ||
), | ||
stateB=openfe.ChemicalSystem({"solvent": ExtendedSolventComponent()}), | ||
mapping=None, | ||
) | ||
return list(pus.protocol_units) | ||
|
||
|
||
@pytest.fixture | ||
def solvent_protocol_unit(protocol_units): | ||
for pu in protocol_units: | ||
if isinstance(pu, ASFESolventUnit): | ||
return pu | ||
|
||
|
||
@pytest.fixture | ||
def vacuum_protocol_unit(protocol_units): | ||
for pu in protocol_units: | ||
if isinstance(pu, ASFEVacuumUnit): | ||
return pu | ||
|
||
|
||
@pytest.fixture | ||
def protocol_result(afe_solv_transformation_json): | ||
d = json.loads( | ||
afe_solv_transformation_json, cls=gufe.tokenization.JSON_HANDLER.decoder | ||
) | ||
pr = ASFEProtocolResult.from_dict(d["protocol_result"]) | ||
return pr | ||
|
||
|
||
class TestProtocol(GufeTokenizableTestsMixin): | ||
cls = ASFEProtocol | ||
key = "ASFEProtocol-798d96f939ae6898c385e31e48caae6d" | ||
repr = f"<{key}>" | ||
|
||
@pytest.fixture() | ||
def instance(self, protocol): | ||
return protocol | ||
|
||
|
||
class TestSolventUnit(GufeTokenizableTestsMixin): | ||
cls = ASFESolventUnit | ||
repr = "ASFESolventUnit(Absolute Solvation, benzene solvent leg: repeat 2 generation 0)" | ||
key = None | ||
|
||
@pytest.fixture() | ||
def instance(self, solvent_protocol_unit): | ||
return solvent_protocol_unit | ||
|
||
def test_key_stable(self): | ||
pytest.skip() | ||
|
||
|
||
class TestVacuumUnit(GufeTokenizableTestsMixin): | ||
cls = ASFEVacuumUnit | ||
repr = ( | ||
"ASFEVacuumUnit(Absolute Solvation, benzene vacuum leg: repeat 2 generation 0)" | ||
) | ||
key = None | ||
|
||
@pytest.fixture() | ||
def instance(self, vacuum_protocol_unit): | ||
return vacuum_protocol_unit | ||
|
||
def test_key_stable(self): | ||
pytest.skip() | ||
|
||
|
||
class TestProtocolResult(GufeTokenizableTestsMixin): | ||
cls = ASFEProtocolResult | ||
key = "ASFEProtocolResult-f1172ed96a55d778bdfcc8d9ce0299f2" | ||
repr = f"<{key}>" | ||
|
||
@pytest.fixture() | ||
def instance(self, protocol_result): | ||
return protocol_result |