FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit a0c87679 authored by M.D. Driver's avatar M.D. Driver
Browse files

added function and corresponding test for getting fractional occupancy from file.

parent b2450529
No related branches found
No related tags found
No related merge requests found
...@@ -23,6 +23,13 @@ PHASE_NAMESPACE_DICT = {"phase":"http://www-hunter.ch.cam.ac.uk/PhaseSchema", ...@@ -23,6 +23,13 @@ PHASE_NAMESPACE_DICT = {"phase":"http://www-hunter.ch.cam.ac.uk/PhaseSchema",
IDEAL_MAX_SSIP_CONCENTRATION_MOLAR = 300.0 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): def get_fractional_occupancy_for_solvent(solvent_list_element, solvent_id):
"""This extracts the solvent XML, and calculates the fractional occupancy """This extracts the solvent XML, and calculates the fractional occupancy
contribution for the solvent. contribution for the solvent.
......
...@@ -31,6 +31,12 @@ class SolventXMLReaderTestCase(unittest.TestCase): ...@@ -31,6 +31,12 @@ class SolventXMLReaderTestCase(unittest.TestCase):
del self.solvent_list_xml del self.solvent_list_xml
del self.water_solvent_element del self.water_solvent_element
del self.water_molecule_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): def test_get_fractional_occupancy_for_solvent(self):
"""Test to see if expected fractional occupancy is returned. """Test to see if expected fractional occupancy is returned.
""" """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment