Beispiel #1
0
    def test_write_xml_parameters_amber_write_unused(self):
        """Test the write_unused argument in writing XML files"""
        params = openmm.OpenMMParameterSet.from_parameterset(
            pmd.amber.AmberParameterSet(
                get_fn('amino12.lib'),
                os.path.join(get_fn('parm'), 'parm10.dat'),
                os.path.join(get_fn('parm'), 'frcmod.ff14SB')))
        ffxml = StringIO()
        params.write(ffxml)
        ffxml.seek(0)
        self.assertEqual(len(ffxml.readlines()), 2178)
        ffxml = StringIO()
        params.write(ffxml, write_unused=False)
        ffxml.seek(0)
        self.assertEqual(len(ffxml.readlines()), 1646)

        params = openmm.OpenMMParameterSet.from_parameterset(
            pmd.amber.AmberParameterSet(
                get_fn('atomic_ions.lib'),
                os.path.join(get_fn('parm'), 'frcmod.ionsjc_tip3p')))
        ffxml = StringIO()
        warnings.filterwarnings('ignore', category=exceptions.ParameterWarning)
        params.write(ffxml)
        ffxml.seek(0)
        self.assertEqual(len(ffxml.readlines()), 222)
        ffxml = StringIO()
        params.write(ffxml, write_unused=False)
        ffxml.seek(0)
        self.assertEqual(len(ffxml.readlines()), 57)
    def test_write_xml_parameters_amber_write_unused(self):
        """Test the write_unused argument in writing XML files"""
        params = openmm.OpenMMParameterSet.from_parameterset(
                pmd.amber.AmberParameterSet(get_fn('amino12.lib'),
                os.path.join(get_fn('parm'), 'parm10.dat'),
                os.path.join(get_fn('parm'), 'frcmod.ff14SB'))
        )
        ffxml = StringIO()
        params.write(ffxml)
        ffxml.seek(0)
        self.assertEqual(len(ffxml.readlines()), 2178)
        ffxml = StringIO()
        params.write(ffxml, write_unused=False)
        ffxml.seek(0)
        self.assertEqual(len(ffxml.readlines()), 1646)

        params = openmm.OpenMMParameterSet.from_parameterset(
                  pmd.amber.AmberParameterSet(get_fn('atomic_ions.lib'),
                  os.path.join(get_fn('parm'), 'frcmod.ionsjc_tip3p'))
        )
        ffxml = StringIO()
        warnings.filterwarnings('ignore', category=exceptions.ParameterWarning)
        params.write(ffxml)
        ffxml.seek(0)
        self.assertEqual(len(ffxml.readlines()), 222)
        ffxml = StringIO()
        params.write(ffxml, write_unused=False)
        ffxml.seek(0)
        self.assertEqual(len(ffxml.readlines()), 57)
 def test_write_xml_parameters_amber_write_unused(self):
     """ Test writing XML parameters loaded from part of the ff14SB forcefield
     files, using the write_unused argument"""
     params = openmm.OpenMMParameterSet.from_parameterset(
         pmd.amber.AmberParameterSet(
             get_fn('amino12.lib'),
             os.path.join(get_fn('parm'), 'parm10.dat'),
             os.path.join(get_fn('parm'), 'frcmod.ff14SB')))
     ffxml = StringIO()
     params.write(ffxml)
     ffxml.seek(0)
     self.assertEqual(len(ffxml.readlines()), 2178)
     ffxml = StringIO()
     params.write(ffxml, write_unused=False)
     ffxml.seek(0)
     self.assertEqual(len(ffxml.readlines()), 1646)
Beispiel #4
0
 def test_write_xml_parameters_amber_write_unused(self):
     """ Test writing XML parameters loaded from part of the ff14SB forcefield
     files, using the write_unused argument"""
     params = openmm.OpenMMParameterSet.from_parameterset(
         pmd.amber.AmberParameterSet(
             get_fn("amino12.lib"),
             os.path.join(get_fn("parm"), "parm10.dat"),
             os.path.join(get_fn("parm"), "frcmod.ff14SB"),
         )
     )
     ffxml = StringIO()
     params.write(ffxml)
     ffxml.seek(0)
     self.assertEqual(len(ffxml.readlines()), 2178)
     ffxml = StringIO()
     params.write(ffxml, write_unused=False)
     ffxml.seek(0)
     self.assertEqual(len(ffxml.readlines()), 1646)
Beispiel #5
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')))
     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)
     ffxml.seek(0)
     self.assertEqual(len(ffxml.readlines()), 16)
 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'))
              )
     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)
     ffxml.seek(0)
     self.assertEqual(len(ffxml.readlines()), 16)
Beispiel #7
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')))
     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)
     output_lines = ffxml.readlines()
     control_line1 = '  <Residue name="K" override="1">\n'
     control_line2 = '  <Residue name="NA">\n'
     self.assertEqual(output_lines[5], control_line1)
     self.assertEqual(output_lines[8], control_line2)
 def test_overload_level(self):
     """Test correct support for the overload_level attribute of
        ResidueTemplates and correct writing to XML tag"""
     params = openmm.OpenMMParameterSet.from_parameterset(
              pmd.amber.AmberParameterSet(get_fn('atomic_ions.lib'))
              )
     new_residues = OrderedDict()
     new_residues['K'] = params.residues['K']
     new_residues['NA'] = params.residues['NA']
     new_residues['K'].overload_level = 1
     params.residues = new_residues
     ffxml = StringIO()
     params.write(ffxml)
     ffxml.seek(0)
     output_lines = ffxml.readlines()
     control_line1 = '  <Residue name="K" overload="1">\n'
     control_line2 = '  <Residue name="NA">\n'
     self.assertEqual(output_lines[5], control_line1)
     self.assertEqual(output_lines[8], control_line2)