comparison ebcsgen_ctl_model_checking.py @ 0:213df1fd884f draft

planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit ab45353a4e518f67057a1789aa527fb3bf1e74d5
author sybila
date Thu, 06 Oct 2022 14:39:48 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:213df1fd884f
1 import argparse
2
3 from eBCSgen.Analysis.CTL import CTL
4 from eBCSgen.Errors.FormulaParsingError import FormulaParsingError
5 from eBCSgen.Errors.InvalidInputError import InvalidInputError
6 from eBCSgen.Parsing.ParseBCSL import load_TS_from_json
7 from eBCSgen.Parsing.ParseCTLformula import CTLparser
8
9 args_parser = argparse.ArgumentParser(description='Model checking')
10
11 args_parser._action_groups.pop()
12 required = args_parser.add_argument_group('required arguments')
13
14 required.add_argument('--transition_file', required=True)
15 required.add_argument('--output', type=str, required=True)
16 required.add_argument('--formula', type=str, required=True)
17
18 args = args_parser.parse_args()
19
20 ts = load_TS_from_json(args.transition_file)
21
22 if len(ts.params) != 0:
23 raise InvalidInputError("Provided transition system is parametrised - model checking cannot be executed.")
24
25 formula = CTLparser().parse(args.formula)
26 if formula.success:
27 result, states = CTL.model_checking(ts, formula)
28 output = 'Result: {}\nNumber of satisfying states: {}'.format(result, len(states))
29 f = open(args.output, "w")
30 f.write(output)
31 f.close()
32 else:
33 raise FormulaParsingError(formula.data, args.formula)