|
1 |
| -from gufe.tests.conftest import * |
| 1 | +import pytest |
| 2 | +from openff.units import unit |
| 3 | +import gufe |
| 4 | +from gufe import SolventComponent, ChemicalSystem |
| 5 | +from gufe.tests.test_protocol import DummyProtocol |
| 6 | + |
| 7 | + |
| 8 | +@pytest.fixture |
| 9 | +def solv_comp(): |
| 10 | + yield SolventComponent(positive_ion="K", negative_ion="Cl", |
| 11 | + ion_concentration=0.0 * unit.molar) |
| 12 | + |
| 13 | +@pytest.fixture |
| 14 | +def solvated_complex(T4_protein_component, benzene_transforms, solv_comp): |
| 15 | + return ChemicalSystem( |
| 16 | + {"ligand": benzene_transforms['toluene'], |
| 17 | + "protein": T4_protein_component, "solvent": solv_comp,} |
| 18 | + ) |
| 19 | + |
| 20 | + |
| 21 | +@pytest.fixture |
| 22 | +def solvated_ligand(benzene_transforms, solv_comp): |
| 23 | + return ChemicalSystem( |
| 24 | + {"ligand": benzene_transforms['toluene'], |
| 25 | + "solvent": solv_comp,} |
| 26 | + ) |
| 27 | + |
| 28 | + |
| 29 | +@pytest.fixture |
| 30 | +def absolute_transformation(solvated_ligand, solvated_complex): |
| 31 | + return gufe.Transformation( |
| 32 | + solvated_ligand, |
| 33 | + solvated_complex, |
| 34 | + protocol=DummyProtocol(settings=None), |
| 35 | + mapping=None, |
| 36 | + ) |
| 37 | + |
| 38 | + |
| 39 | +@pytest.fixture |
| 40 | +def complex_equilibrium(solvated_complex): |
| 41 | + return gufe.NonTransformation( |
| 42 | + solvated_complex, |
| 43 | + protocol=DummyProtocol(settings=None), |
| 44 | + ) |
| 45 | + |
| 46 | + |
| 47 | +@pytest.fixture |
| 48 | +def benzene_variants_star_map(benzene_transforms, solv_comp, |
| 49 | + T4_protein_component): |
| 50 | + variants = ['toluene', 'phenol', 'benzonitrile', 'anisole', |
| 51 | + 'benzaldehyde', 'styrene'] |
| 52 | + |
| 53 | + # define the solvent chemical systems and transformations between |
| 54 | + # benzene and the others |
| 55 | + solvated_ligands = {} |
| 56 | + solvated_ligand_transformations = {} |
| 57 | + |
| 58 | + solvated_ligands['benzene'] = ChemicalSystem( |
| 59 | + {"solvent": solv_comp, "ligand": benzene_transforms['benzene'],}, |
| 60 | + name="benzene-solvent", |
| 61 | + ) |
| 62 | + |
| 63 | + for ligand in variants: |
| 64 | + solvated_ligands[ligand] = ChemicalSystem( |
| 65 | + {"solvent": solv_comp, "ligand": benzene_transforms[ligand],}, |
| 66 | + name=f"{ligand}-solvent" |
| 67 | + ) |
| 68 | + |
| 69 | + solvated_ligand_transformations[("benzene", ligand)] = gufe.Transformation( |
| 70 | + solvated_ligands['benzene'], solvated_ligands[ligand], |
| 71 | + protocol=DummyProtocol(settings=None), |
| 72 | + mapping=None, |
| 73 | + ) |
| 74 | + |
| 75 | + # define the complex chemical systems and transformations between |
| 76 | + # benzene and the others |
| 77 | + solvated_complexes = {} |
| 78 | + solvated_complex_transformations = {} |
| 79 | + |
| 80 | + solvated_complexes["benzene"] = gufe.ChemicalSystem( |
| 81 | + {"protein": T4_protein_component, "solvent": solv_comp, |
| 82 | + "ligand": benzene_transforms['benzene']}, |
| 83 | + name="benzene-complex", |
| 84 | + ) |
| 85 | + |
| 86 | + for ligand in variants: |
| 87 | + solvated_complexes[ligand] = gufe.ChemicalSystem( |
| 88 | + {"protein": T4_protein_component, "solvent": solv_comp, |
| 89 | + "ligand": benzene_transforms[ligand]}, |
| 90 | + name=f"{ligand}-complex", |
| 91 | + ) |
| 92 | + solvated_complex_transformations[("benzene", ligand)] = gufe.Transformation( |
| 93 | + solvated_complexes["benzene"], |
| 94 | + solvated_complexes[ligand], |
| 95 | + protocol=DummyProtocol(settings=None), |
| 96 | + mapping=None, |
| 97 | + ) |
| 98 | + |
| 99 | + return gufe.AlchemicalNetwork( |
| 100 | + list(solvated_ligand_transformations.values()) |
| 101 | + + list(solvated_complex_transformations.values()) |
| 102 | + ) |
0 commit comments