annotate ebcsgen_pctl_model_checking.py @ 2:141b9c2bc816 draft

planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 83232805a8721c48078c88367e3480a5553f0182
author sybila
date Fri, 14 Oct 2022 16:24:36 +0000
parents ea5108514910
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ea5108514910 planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff changeset
1 import argparse
ea5108514910 planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff changeset
2
ea5108514910 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
ea5108514910 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
ea5108514910 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
ea5108514910 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
ea5108514910 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
ea5108514910 planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff changeset
8
ea5108514910 planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff changeset
9
ea5108514910 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')
ea5108514910 planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff changeset
11
ea5108514910 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()
ea5108514910 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')
ea5108514910 planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff changeset
14
ea5108514910 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)
ea5108514910 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)
ea5108514910 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)
ea5108514910 planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff changeset
18
ea5108514910 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()
ea5108514910 planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff changeset
20
ea5108514910 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)
ea5108514910 planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff changeset
22
ea5108514910 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:
ea5108514910 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.")
ea5108514910 planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff changeset
25
ea5108514910 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)
ea5108514910 planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff changeset
27 if formula.success:
2
141b9c2bc816 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
ea5108514910 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")
ea5108514910 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"))
ea5108514910 planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff changeset
31 f.close()
ea5108514910 planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit d80d8e9710cba50aab3e6a1e10a527d26fc7e72b
sybila
parents:
diff changeset
32 else:
ea5108514910 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)