diff --git a/solventmapcreator/io/solventxmlreader.py b/solventmapcreator/io/solventxmlreader.py index c4adb70e08923a511dae83aff367246320518be6..1ef1bec91c2d445cea772242eff52a185be9dfe0 100644 --- a/solventmapcreator/io/solventxmlreader.py +++ b/solventmapcreator/io/solventxmlreader.py @@ -23,6 +23,13 @@ PHASE_NAMESPACE_DICT = {"phase":"http://www-hunter.ch.cam.ac.uk/PhaseSchema", IDEAL_MAX_SSIP_CONCENTRATION_MOLAR = 300.0 +def get_fractional_occupancy_for_solvent_from_file(solvent_filename, solvent_id): + """This reads inthe file and extracts the solvent information, and returns + the fractional occupancy contribution from the solvent. + """ + solvent_list_element = read_element_tree(solvent_filename) + return get_fractional_occupancy_for_solvent(solvent_list_element, solvent_id) + def get_fractional_occupancy_for_solvent(solvent_list_element, solvent_id): """This extracts the solvent XML, and calculates the fractional occupancy contribution for the solvent. diff --git a/solventmapcreator/test/iotest/solventxmlreadertest.py b/solventmapcreator/test/iotest/solventxmlreadertest.py index 2b900a793ff561d663f27f8b7c4c2b6a5e6086b1..bb685f44353529a6dfbf98715c097ec8cf27170b 100644 --- a/solventmapcreator/test/iotest/solventxmlreadertest.py +++ b/solventmapcreator/test/iotest/solventxmlreadertest.py @@ -31,6 +31,12 @@ class SolventXMLReaderTestCase(unittest.TestCase): del self.solvent_list_xml del self.water_solvent_element del self.water_molecule_element + def test_get_fractional_occupancy_for_solvent_from_file(self): + """Test to see if expected value is returned. + """ + expected_value = 55.35 * 4.0 /300.0 + actual_value = solventxmlreader.get_fractional_occupancy_for_solvent_from_file("resources/watersolvent.xml", "water") + self.assertAlmostEqual(expected_value, actual_value) def test_get_fractional_occupancy_for_solvent(self): """Test to see if expected fractional occupancy is returned. """