Пример #1
0
 def test_simple(self):
     """ Tests converting standard Gromacs system into Amber prmtop """
     top = load_file(get_fn(os.path.join('03.AlaGlu', 'topol.top')))
     self.assertEqual(top.combining_rule, 'lorentz')
     parm = amber.AmberParm.from_structure(top)
     parm.write_parm(get_fn('ala_glu.parm7', written=True))
     parm = load_file(get_fn('ala_glu.parm7', written=True))
     self.assertIsInstance(parm, amber.AmberParm)
     self.assertEqual(len(top.atoms), len(parm.atoms))
     self.assertEqual(len(top.bonds), len(parm.bonds))
     self.assertEqual(len(top.angles), len(parm.angles))
     self.assertEqual(len(top.residues), len(parm.residues))
     for a1, a2 in zip(top.atoms, parm.atoms):
         self.assertEqual(a1.name, a2.name)
         self.assertEqual(a1.type, a2.type)
         self.assertEqual(a1.atomic_number, a2.atomic_number)
         self.assertEqual(a1.residue.name, a2.residue.name)
         self.assertEqual(a1.residue.idx, a2.residue.idx)
         self.assertAlmostEqual(a1.mass, a2.mass)
         self.assertIs(type(a1), type(a2))
         self.assertAlmostEqual(a1.charge, a2.charge)
         self.assertEqual(set([a.idx for a in a1.bond_partners]),
                          set([a.idx for a in a2.bond_partners]))
         self.assertEqual(set([a.idx for a in a1.angle_partners]),
                          set([a.idx for a in a2.angle_partners]))
         self.assertEqual(set([a.idx for a in a1.dihedral_partners]),
                          set([a.idx for a in a2.dihedral_partners]))
     # Make sure that assign_nbidx_from_types compresses maximally. First
     # add a new, equivalent L-J type. Then call assign_nbidx_from_types
     # again, which should recompress
     before_nbidx = [a.nb_idx for a in parm.atoms]
     addLJType(parm, '@1').execute()
     after_nbidx = [a.nb_idx for a in parm.atoms]
     self.assertEqual(before_nbidx[1:], after_nbidx[1:])
     self.assertEqual(after_nbidx[0], max(before_nbidx) + 1)
     parm.atoms.assign_nbidx_from_types()
     # Should recompress
     self.assertEqual(before_nbidx, [a.nb_idx for a in parm.atoms])
 def test_simple(self):
     """ Tests converting standard Gromacs system into Amber prmtop """
     top = load_file(get_fn(os.path.join('03.AlaGlu', 'topol.top')))
     self.assertEqual(top.combining_rule, 'lorentz')
     parm = amber.AmberParm.from_structure(top)
     parm.write_parm(get_fn('ala_glu.parm7', written=True))
     parm = load_file(get_fn('ala_glu.parm7', written=True))
     self.assertIsInstance(parm, amber.AmberParm)
     self.assertEqual(len(top.atoms), len(parm.atoms))
     self.assertEqual(len(top.bonds), len(parm.bonds))
     self.assertEqual(len(top.angles), len(parm.angles))
     self.assertEqual(len(top.residues), len(parm.residues))
     for a1, a2 in zip(top.atoms, parm.atoms):
         self.assertEqual(a1.name, a2.name)
         self.assertEqual(a1.type, a2.type)
         self.assertEqual(a1.atomic_number, a2.atomic_number)
         self.assertEqual(a1.residue.name, a2.residue.name)
         self.assertEqual(a1.residue.idx, a2.residue.idx)
         self.assertAlmostEqual(a1.mass, a2.mass)
         self.assertIs(type(a1), type(a2))
         self.assertAlmostEqual(a1.charge, a2.charge)
         self.assertEqual(set([a.idx for a in a1.bond_partners]),
                          set([a.idx for a in a2.bond_partners]))
         self.assertEqual(set([a.idx for a in a1.angle_partners]),
                          set([a.idx for a in a2.angle_partners]))
         self.assertEqual(set([a.idx for a in a1.dihedral_partners]),
                          set([a.idx for a in a2.dihedral_partners]))
     # Make sure that assign_nbidx_from_types compresses maximally. First
     # add a new, equivalent L-J type. Then call assign_nbidx_from_types
     # again, which should recompress
     before_nbidx = [a.nb_idx for a in parm.atoms]
     addLJType(parm, '@1').execute()
     after_nbidx = [a.nb_idx for a in parm.atoms]
     self.assertEqual(before_nbidx[1:], after_nbidx[1:])
     self.assertEqual(after_nbidx[0], max(before_nbidx)+1)
     parm.atoms.assign_nbidx_from_types()
     # Should recompress
     self.assertEqual(before_nbidx, [a.nb_idx for a in parm.atoms])