def test_load_prmtop(self): struct = readparm.LoadParm(get_pmd_fn("trx.prmtop")) other_struct = readparm.AmberParm(get_pmd_fn("trx.prmtop")) prmtop = Interchange._from_parmed(struct) other_prmtop = Interchange._from_parmed(other_struct) for handler_key in prmtop.handlers: # TODO: Closer inspection of data assert handler_key in other_prmtop.handlers assert not prmtop.box struct.box = [20, 20, 20, 90, 90, 90] prmtop_converted = Interchange._from_parmed(struct) np.testing.assert_allclose(prmtop_converted.box, np.eye(3) * 2.0 * unit.nanometer)
def test_read_box_parm7(self): top = readparm.LoadParm(get_pmd_fn("solv2.parm7")) out = Interchange._from_parmed(top) # pmd.load_file(get_pmd_fn("solv2.rst7"))) # top = readparm.LoadParm(get_pmd_fn("solv2.parm7"), xyz=coords.coordinates) np.testing.assert_allclose(np.diag(out.box.m_as(unit.angstrom)), top.parm_data["BOX_DIMENSIONS"][1:])
def test_parmed_roundtrip(self): original = pmd.load_file(get_test_file_path("ALA_GLY/ALA_GLY.top")) gro = pmd.load_file(get_test_file_path("ALA_GLY/ALA_GLY.gro")) original.box = gro.box original.positions = gro.positions openff_sys = Interchange._from_parmed(original) openff_sys.topology.mdtop = md.Topology.from_openmm(gro.topology) # Some sanity checks, including that residues are stored ... assert openff_sys.topology.mdtop.n_atoms == 29 # TODO: Assert number of topology molecules after refactor assert openff_sys.topology.mdtop.n_residues == 4 # ... and written out openff_sys.to_gro("has_residues.gro", writer="internal") assert len(pmd.load_file("has_residues.gro").residues) == 4 roundtrip = openff_sys._to_parmed() roundtrip.save("conv.gro", overwrite=True) roundtrip.save("conv.top", overwrite=True) original_energy = _run_gmx_energy( top_file=get_test_file_path("ALA_GLY/ALA_GLY.top"), gro_file=get_test_file_path("ALA_GLY/ALA_GLY.gro"), mdp_file=_get_mdp_file("cutoff_hbonds"), ) internal_energy = get_gromacs_energies(openff_sys, mdp="cutoff_hbonds") roundtrip_energy = _run_gmx_energy( top_file="conv.top", gro_file="conv.gro", mdp_file=_get_mdp_file("cutoff_hbonds"), ) # Differences in bond energies appear to be related to ParmEd's rounding # of the force constant and equilibrium bond length original_energy.compare(internal_energy) internal_energy.compare( roundtrip_energy, custom_tolerances={ "Bond": 0.02 * omm_unit.kilojoule_per_mole, }, ) original_energy.compare( roundtrip_energy, custom_tolerances={ "Bond": 0.02 * omm_unit.kilojoule_per_mole, }, )