diff --git a/openfe_gromacs/tests/protocols/test_create_systems.py b/openfe_gromacs/tests/protocols/test_create_systems.py index 4b06437..9635ba3 100644 --- a/openfe_gromacs/tests/protocols/test_create_systems.py +++ b/openfe_gromacs/tests/protocols/test_create_systems.py @@ -58,39 +58,39 @@ def test_interchange_gromacs(alanine_dipeptide_component, tmpdir): assert atom_name in interchange_atom_names -# def test_user_charges(CN_molecule, tmpdir): -# solvent = gufe.SolventComponent() -# off_cn = CN_molecule.to_openff() -# off_cn.assign_partial_charges(partial_charge_method="am1-mulliken") -# off_charges = off_cn.partial_charges -# prot_settings = GromacsMDProtocol.default_settings() -# smc_components = {CN_molecule: off_cn} -# omm_system, omm_topology, omm_positions = create_systems.create_openmm_system( -# solvent, -# None, -# smc_components, -# prot_settings.partial_charge_settings, -# prot_settings.forcefield_settings, -# prot_settings.integrator_settings, -# prot_settings.thermo_settings, -# prot_settings.solvation_settings, -# prot_settings.output_settings_em, -# tmpdir, -# ) -# -# interchange = create_systems.create_interchange( -# omm_system, omm_topology, omm_positions, smc_components -# ) -# # Save to Gromacs .top file -# interchange.to_top(f"{tmpdir}/test.top") -# # Load Gromacs .top file back in as OpenMM system -# gromacs_system = GromacsTopFile(f"{tmpdir}/test.top").createSystem() -# # Get the partial charges of the ligand atoms -# nonbonded = [ -# f for f in gromacs_system.getForces() if isinstance(f, NonbondedForce) -# ][0] -# gro_charges = [] -# for i in range(len(off_charges)): -# charge, sigma, epsilon = nonbonded.getParticleParameters(i) -# gro_charges.append(charge._value) -# np.testing.assert_almost_equal(off_charges.m, gro_charges, decimal=5) +def test_user_charges(CN_molecule, tmpdir): + solvent = gufe.SolventComponent() + off_cn = CN_molecule.to_openff() + off_cn.assign_partial_charges(partial_charge_method="am1-mulliken") + off_charges = off_cn.partial_charges + prot_settings = GromacsMDProtocol.default_settings() + smc_components = {CN_molecule: off_cn} + omm_system, omm_topology, omm_positions = create_systems.create_openmm_system( + solvent, + None, + smc_components, + prot_settings.partial_charge_settings, + prot_settings.forcefield_settings, + prot_settings.integrator_settings, + prot_settings.thermo_settings, + prot_settings.solvation_settings, + prot_settings.output_settings_em, + tmpdir, + ) + + interchange = create_systems.create_interchange( + omm_system, omm_topology, omm_positions, smc_components + ) + # Save to Gromacs .top file + interchange.to_top(f"{tmpdir}/test.top") + # Load Gromacs .top file back in as OpenMM system + gromacs_system = GromacsTopFile(f"{tmpdir}/test.top").createSystem() + # Get the partial charges of the ligand atoms + nonbonded = [ + f for f in gromacs_system.getForces() if isinstance(f, NonbondedForce) + ][0] + gro_charges = [] + for i in range(len(off_charges)): + charge, sigma, epsilon = nonbonded.getParticleParameters(i) + gro_charges.append(charge._value) + np.testing.assert_almost_equal(off_charges.m, gro_charges, decimal=5)