Mercurial > repos > sybila > ebcsgen_pctl_model_checking
annotate ebcsgen_pctl_model_checking.py @ 3:d0502df4d22c 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:18:15 +0000 |
parents | 4a006ef60d31 |
children |
rev | line source |
---|---|
0
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
1 import argparse |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
2 |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
3 from eBCSgen.Analysis.PCTL import PCTL |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
4 from eBCSgen.Errors.FormulaParsingError import FormulaParsingError |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
5 from eBCSgen.Errors.InvalidInputError import InvalidInputError |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
6 from eBCSgen.Parsing.ParseBCSL import load_TS_from_json |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
7 from eBCSgen.Parsing.ParsePCTLformula import PCTLparser |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
8 |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
9 |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
10 args_parser = argparse.ArgumentParser(description='Model checking') |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
11 |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
12 args_parser._action_groups.pop() |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
13 required = args_parser.add_argument_group('required arguments') |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
14 |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
15 required.add_argument('--transition_file', required=True) |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
16 required.add_argument('--output', type=str, required=True) |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
17 required.add_argument('--formula', type=str, required=True) |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
18 |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
19 args = args_parser.parse_args() |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
20 |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
21 ts = load_TS_from_json(args.transition_file) |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
22 |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
23 if len(ts.params) != 0: |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
24 raise InvalidInputError("Provided transition system is parametrised - model checking cannot be executed.") |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
25 |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
26 formula = PCTLparser().parse(args.formula) |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
27 if formula.success: |
2
4a006ef60d31
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 83232805a8721c48078c88367e3480a5553f0182
sybila
parents:
0
diff
changeset
|
28 result = PCTL.model_checking(ts, formula) |
0
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
29 f = open(args.output, "w") |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
30 f.write(result.decode("utf-8")) |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
31 f.close() |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
32 else: |
f9908f1109f9
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff
changeset
|
33 raise FormulaParsingError(formula.data, args.formula) |