Exemplo n.º 1
0
 def test_override_level(self):
     """Test correct support for the override_level attribute of ResidueTemplates and correct writing to XML tag"""
     params = openmm.OpenMMParameterSet.from_parameterset(
         pmd.amber.AmberParameterSet(
             get_fn('atomic_ions.lib'),
             os.path.join(get_fn('parm'), 'frcmod.ionsjc_tip3p')))
     new_residues = OrderedDict()
     new_residues['K'] = params.residues['K']
     new_residues['NA'] = params.residues['NA']
     new_residues['K'].override_level = 1
     params.residues = new_residues
     ffxml = StringIO()
     params.write(ffxml)
     ffxml.seek(0)
     # TODO: Overhaul tests with lxml (xpath?) queries to eliminate dependence on file order
     output_lines = ffxml.readlines()
     control_line1 = '  <Residue name="K" override="1">\n'
     control_line2 = '  <Residue name="NA">\n'
     self.assertEqual(output_lines[16].strip(), control_line1.strip(),
                      'File contents:\n{}'.format(ffxml.getvalue()))
     self.assertEqual(output_lines[19].strip(), control_line2.strip(),
                      'File contents:\n{}'.format(ffxml.getvalue()))
Exemplo n.º 2
0
 def test_not_write_residues_with_same_templhash(self):
     """Test that no identical residues are written to XML, using the templhasher function."""
     # TODO add testing for multiatomic residues when support for those added
     params = openmm.OpenMMParameterSet.from_parameterset(
         pmd.amber.AmberParameterSet(
             get_fn('atomic_ions.lib'),
             os.path.join(get_fn('parm'), 'frcmod.ionsjc_tip3p')))
     new_residues = OrderedDict()
     for name in ('K', 'K+', 'NA', 'Na+', 'CL', 'Cl-'):
         new_residues[name] = params.residues[name]
     params.residues = new_residues
     ffxml = StringIO()
     params.write(ffxml)
     # TODO: Overhaul tests with lxml (xpath?) queries to eliminate dependence on file order
     ffxml.seek(0)
     nlines = len(ffxml.readlines())
     self.assertEqual(
         nlines, 39, 'File contents:\n{}\nActual length: {} lines.'.format(
             ffxml.getvalue(), nlines))
Exemplo n.º 3
0
 def test_override_level(self):
     """Test correct support for the override_level attribute of ResidueTemplates and correct writing to XML tag"""
     params = openmm.OpenMMParameterSet.from_parameterset(
               pmd.amber.AmberParameterSet(get_fn('atomic_ions.lib'),
               os.path.join(get_fn('parm'), 'frcmod.ionsjc_tip3p'))
     )
     new_residues = OrderedDict()
     new_residues['K'] = params.residues['K']
     new_residues['NA'] = params.residues['NA']
     new_residues['K'].override_level = 1
     params.residues = new_residues
     ffxml = StringIO()
     params.write(ffxml)
     ffxml.seek(0)
     # TODO: Overhaul tests with lxml (xpath?) queries to eliminate dependence on file order
     output_lines = ffxml.readlines()
     control_line1 = '  <Residue name="K" override="1">\n'
     control_line2 = '  <Residue name="NA">\n'
     self.assertEqual(output_lines[16].strip(), control_line1.strip(), 'File contents:\n{}'.format(ffxml.getvalue()))
     self.assertEqual(output_lines[19].strip(), control_line2.strip(), 'File contents:\n{}'.format(ffxml.getvalue()))
Exemplo n.º 4
0
 def test_not_write_residues_with_same_templhash(self):
     """Test that no identical residues are written to XML, using the templhasher function."""
     # TODO add testing for multiatomic residues when support for those added
     params = openmm.OpenMMParameterSet.from_parameterset(
               pmd.amber.AmberParameterSet(get_fn('atomic_ions.lib'),
               os.path.join(get_fn('parm'), 'frcmod.ionsjc_tip3p'))
     )
     new_residues = OrderedDict()
     for name in ('K', 'K+', 'NA', 'Na+', 'CL', 'Cl-'):
         new_residues[name] = params.residues[name]
     params.residues = new_residues
     ffxml = StringIO()
     params.write(ffxml)
     # TODO: Overhaul tests with lxml (xpath?) queries to eliminate dependence on file order
     ffxml.seek(0)
     nlines = len(ffxml.readlines())
     self.assertEqual(nlines, 39, 'File contents:\n{}\nActual length: {} lines.'.format(ffxml.getvalue(), nlines))