def checkKisaoIntegrator(self, inline_omex, kisao, name): """ Helper function for checking kisao integrator. """ omex_file = os.path.join(self.test_dir, "test.omex") te.exportInlineOmex(inline_omex, omex_file) omex.extractCombineArchive(omex_file, directory=self.test_dir, method="zip") locations = omex.getLocationsByFormat(omex_file, "sed-ml") sedml_files = [os.path.join(self.test_dir, loc) for loc in locations] sedml_file = sedml_files[0] # check the SED-ML doc = libsedml.readSedMLFromFile(sedml_file) # test_str = libsedml.writeSedMLToString(doc) # print(test_str) simulation = doc.getSimulation('sim0') algorithm = simulation.getAlgorithm() assert algorithm.getKisaoID() == kisao # check the generated code pystr = tesedml.sedmlToPython(sedml_file, workingDir=self.test_dir) # is integrator/solver set in python code if simulation.getTypeCode() is libsedml.SEDML_SIMULATION_STEADYSTATE: assert ".setSteadyStateSolver('{}')".format(name) in pystr else: assert ".setIntegrator('{}')".format(name) in pystr
def test_getLocationsByFormat4_zip(): locations = omex.getLocationsByFormat(omexPath=OMEX_SHOWCASE, formatKey="sed-ml", method="zip") assert len(locations) == 2 # in case of zip files no master file exists, so the order of the entries depends on # filenames and how they are returned from the zip assert "experiment/Calzone2007-simulation-figure-1B.xml" in locations assert "experiment/Calzone2007-default-simulation.xml" in locations
def test_getLocationsByFormat4(): locations = omex.getLocationsByFormat(omexPath=OMEX_SHOWCASE, formatKey="sed-ml") assert len(locations) == 2 # master=True file first assert locations[0].endswith("Calzone2007-simulation-figure-1B.xml") # master=False afterwards assert locations[1].endswith("Calzone2007-default-simulation.xml")
def checkKisaoIntegrator(self, inline_omex, kisao, name): """ Helper function for checking kisao integrator. """ omex_file = os.path.join(self.test_dir, "test.omex") te.exportInlineOmex(inline_omex, omex_file) omex.extractCombineArchive(omex_file, directory=self.test_dir, method="zip") locations = omex.getLocationsByFormat(omex_file, "sed-ml") sedml_files = [os.path.join(self.test_dir, loc) for loc in locations] sedml_file = sedml_files[0] # check the SED-ML doc = libsedml.readSedMLFromFile(sedml_file) # test_str = libsedml.writeSedMLToString(doc) # print(test_str) simulation = doc.getSimulation('sim0') algorithm = simulation.getAlgorithm() assert algorithm.getKisaoID() == kisao # check the generated code pystr = tesedml.sedmlToPython(sedml_file, workingDir=self.test_dir) # is integrator/solver set in python code if simulation.getTypeCode() is libsedml.SEDML_SIMULATION_STEADYSTATE: assert ".setSteadyStateSolver('{}')".format(name) in pystr else: assert ".setIntegrator('{}')".format(name) in pystr
def checkKisaoAlgorithmParameter(self, inline_omex, kisao, name, value): """ Helper function for checking kisao parameter. """ # check that set AlgorithmParameter set correctly in SED-ML omex_file = os.path.join(self.test_dir, "test.omex") te.exportInlineOmex(inline_omex, omex_file) omex.extractCombineArchive(omex_file, directory=self.test_dir, method="zip") locations = omex.getLocationsByFormat(omex_file, "sed-ml") sedml_files = [os.path.join(self.test_dir, loc) for loc in locations] sedml_file = sedml_files[0] doc = libsedml.readSedMLFromFile(sedml_file) simulation = doc.getSimulation('sim0') algorithm = simulation.getAlgorithm() pdict = { p.getKisaoID(): p for p in algorithm.getListOfAlgorithmParameters() } self.assertTrue(kisao in pdict) pkey = tesedml.SEDMLCodeFactory.algorithmParameterToParameterKey( pdict[kisao]) if pkey.dtype == str: self.assertEqual(pkey.value, value) else: # numerical parameter self.assertAlmostEqual(float(pkey.value), value) # check that integrator is set in python code pystr = tesedml.sedmlToPython(sedml_file, workingDir=self.test_dir) print(simulation.getElementName()) print(pystr) if simulation.getTypeCode() is libsedml.SEDML_SIMULATION_STEADYSTATE: if pkey.dtype == str: self.assertTrue( ".steadyStateSolver.setValue('{}', '{}')".format( name, value) in pystr) else: # numerical parameter self.assertTrue(".steadyStateSolver.setValue('{}', {})".format( name, value) in pystr) else: if pkey.dtype == str: self.assertTrue(".integrator.setValue('{}', '{}')".format( name, value) in pystr) else: # numerical parameter self.assertTrue(".integrator.setValue('{}', {})".format( name, value) in pystr)
def checkKisaoAlgorithmParameter(self, inline_omex, kisao, name, value): """ Helper function for checking kisao parameter. """ # check that set AlgorithmParameter set correctly in SED-ML omex_file = os.path.join(self.test_dir, "test.omex") te.exportInlineOmex(inline_omex, omex_file) omex.extractCombineArchive(omex_file, directory=self.test_dir, method="zip") locations = omex.getLocationsByFormat(omex_file, "sed-ml") sedml_files = [os.path.join(self.test_dir, loc) for loc in locations] sedml_file = sedml_files[0] doc = libsedml.readSedMLFromFile(sedml_file) simulation = doc.getSimulation('sim0') algorithm = simulation.getAlgorithm() pdict = {p.getKisaoID(): p for p in algorithm.getListOfAlgorithmParameters()} self.assertTrue(kisao in pdict) pkey = tesedml.SEDMLCodeFactory.algorithmParameterToParameterKey(pdict[kisao]) if pkey.dtype == str: self.assertEqual(pkey.value, value) else: # numerical parameter self.assertAlmostEqual(float(pkey.value), value) # check that integrator is set in python code pystr = tesedml.sedmlToPython(sedml_file, workingDir=self.test_dir) print(simulation.getElementName()) print(pystr) if simulation.getTypeCode() is libsedml.SEDML_SIMULATION_STEADYSTATE: if pkey.dtype == str: self.assertTrue(".steadyStateSolver.setValue('{}', '{}')".format(name, value) in pystr) else: # numerical parameter self.assertTrue(".steadyStateSolver.setValue('{}', {})".format(name, value) in pystr) else: if pkey.dtype == str: self.assertTrue(".integrator.setValue('{}', '{}')".format(name, value) in pystr) else: # numerical parameter self.assertTrue(".integrator.setValue('{}', {})".format(name, value) in pystr)
def test_getLocationsByFormat3_zip(): locations = omex.getLocationsByFormat(omexPath=OMEX_SHOWCASE, formatKey="cellml", method="zip") assert len(locations) == 1
def test_getLocationsByFormat2(): locations = omex.getLocationsByFormat(omexPath=OMEX_SHOWCASE, formatKey="sbml") assert len(locations) == 1