view ebcsgen_pctl_model_checking.py @ 3:7be535fdf059 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:04 +0000
parents 141b9c2bc816
children
line wrap: on
line source

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')

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)
    f = open(args.output, "w")
    f.write(result.decode("utf-8"))
    f.close()
else:
    raise FormulaParsingError(formula.data, args.formula)