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