Mercurial > repos > sybila > recetox_aplcms_unsupervised
diff ebcsgen_generate_ts.py @ 0:3bdec3b22152 draft default tip
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 7befebc7a9bc40d8b97f4dac752ad9646aac40de
author | sybila |
---|---|
date | Fri, 09 Sep 2022 13:06:32 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ebcsgen_generate_ts.py Fri Sep 09 13:06:32 2022 +0000 @@ -0,0 +1,43 @@ +import argparse + +from eBCSgen.Errors.ModelParsingError import ModelParsingError +from eBCSgen.Errors.UnspecifiedParsingError import UnspecifiedParsingError +from eBCSgen.Parsing.ParseBCSL import Parser + +import numpy as np + + +args_parser = argparse.ArgumentParser(description='Transition system generating') + +args_parser._action_groups.pop() +required = args_parser.add_argument_group('required arguments') +optional = args_parser.add_argument_group('optional arguments') + +required.add_argument('--model', type=str, required=True) +required.add_argument('--output', type=str, required=True) +required.add_argument('--direct', required=True) + +optional.add_argument('--max_time', type=float, default=np.inf) +optional.add_argument('--max_size', type=float, default=np.inf) +optional.add_argument('--bound', type=int, default=None) + +args = args_parser.parse_args() + +model_parser = Parser("model") +model_str = open(args.model, "r").read() + +model = model_parser.parse(model_str) +if model.success: + if eval(args.direct): + ts = model.data.generate_direct_transition_system(args.max_time, + args.max_size, + args.bound) + ts.change_to_vector_backend() + else: + vm = model.data.to_vector_model(args.bound) + ts = vm.generate_transition_system(None, args.max_time, args.max_size) + ts.save_to_json(args.output, model.data.params) +else: + if "error" in model.data: + raise UnspecifiedParsingError(model.data["error"]) + raise ModelParsingError(model.data, model_str)