diff ebcsgen_pctl_model_checking.py @ 0:ea5108514910 draft

planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
author sybila
date Fri, 09 Sep 2022 17:04:25 +0000
parents
children 141b9c2bc816
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ebcsgen_pctl_model_checking.py	Fri Sep 09 17:04:25 2022 +0000
@@ -0,0 +1,34 @@
+import argparse
+
+from eBCSgen.Analysis.PCTL import PCTL
+from eBCSgen.Errors.FormulaParsingError import FormulaParsingError
+from eBCSgen.Errors.InvalidInputError import InvalidInputError
+from eBCSgen.Parsing.ParseBCSL import load_TS_from_json
+from eBCSgen.Parsing.ParsePCTLformula import PCTLparser
+
+
+args_parser = argparse.ArgumentParser(description='Model checking')
+
+args_parser._action_groups.pop()
+required = args_parser.add_argument_group('required arguments')
+optional = args_parser.add_argument_group('optional arguments')
+
+required.add_argument('--transition_file', required=True)
+required.add_argument('--output', type=str, required=True)
+required.add_argument('--formula', type=str, required=True)
+
+args = args_parser.parse_args()
+
+ts = load_TS_from_json(args.transition_file)
+
+if len(ts.params) != 0:
+    raise InvalidInputError("Provided transition system is parametrised - model checking cannot be executed.")
+
+formula = PCTLparser().parse(args.formula)
+if formula.success:
+    result = PCTL.model_checking(ts, formula, storm_local=True)
+    f = open(args.output, "w")
+    f.write(result.decode("utf-8"))
+    f.close()
+else:
+    raise FormulaParsingError(formula.data, args.formula)