def test_apply_subfuncs(): mol2 = pmd.load_file(get_fn('ethane.mol2'), structure=True) oplsaa = Forcefield(name='oplsaa') ethane = oplsaa.apply(mol2) typemap = oplsaa.run_atomtyping(mol2, use_residue_map=False) oplsaa._apply_typemap(mol2, typemap) ethane2 = oplsaa.parametrize_system(mol2) # Note: Check ParmEd issue #1067 to see if __eq__ is implemented # assert ethane == ethane2 assert ethane.box == ethane2.box assert ethane.positions == ethane2.positions for a1, a2 in zip(ethane.atoms, ethane2.atoms): assert a1.name == a2.name assert a1.idx == a2.idx assert a1.atom_type == a2.atom_type for b1, b2 in zip(ethane.bonds, ethane2.bonds): assert b1.atom1.atom_type == b2.atom1.atom_type assert b1.atom2.atom_type == b2.atom2.atom_type assert b1.type == b2.type for ang1, ang2 in zip(ethane.angles, ethane2.angles): assert ang1.type == ang2.type
def test_residue_map(): ethane = pmd.load_file(get_fn('ethane.mol2'), structure=True) ethane *= 2 oplsaa = Forcefield(name='oplsaa') map_with = oplsaa.run_atomtyping(ethane, use_residue_map=True) map_without = oplsaa.run_atomtyping(ethane, use_residue_map=False) assert all([a['atomtype'] for a in map_with.values()]) assert all([a['atomtype'] for a in map_without.values()]) struct_with = ethane struct_without = ethane oplsaa._apply_typemap(struct_with, map_with) oplsaa._apply_typemap(struct_without, map_without) for atom_with, atom_without in zip(struct_with.atoms, struct_without.atoms): assert atom_with.type == atom_without.type b_with = atom_with.bond_partners b_without = atom_without.bond_partners assert [a0.type for a0 in b_with] == [a1.type for a1 in b_without] assert [a0.idx for a0 in b_with] == [a1.idx for a1 in b_without]
def test_residue_map(): ethane = pmd.load_file(get_fn('ethane.mol2'), structure=True) ethane *= 2 oplsaa = Forcefield(name='oplsaa') topo, NULL = generate_topology(ethane) map_with = oplsaa.run_atomtyping(topo, use_residue_map=True) map_without = oplsaa.run_atomtyping(topo, use_residue_map=False) assert all([a['atomtype'] for a in map_with.values()][0]) assert all([a['atomtype'] for a in map_without.values()][0]) topo_with = topo topo_without = topo oplsaa._apply_typemap(topo_with, map_with) oplsaa._apply_typemap(topo_without, map_without) struct_with = pmd.openmm.load_topology(topo_with, oplsaa.createSystem(topo_with)) struct_without = pmd.openmm.load_topology(topo_without, oplsaa.createSystem(topo_without)) for atom_with, atom_without in zip(struct_with.atoms, struct_without.atoms): assert atom_with.type == atom_without.type b_with = atom_with.bond_partners b_without = atom_without.bond_partners assert [a0.type for a0 in b_with] == [a1.type for a1 in b_without] assert [a0.idx for a0 in b_with] == [a1.idx for a1 in b_without]