Mercurial > repos > sybila > ebcsgen_generate_transition_system
comparison ebcsgen_generate_ts.py @ 0:f13bdc5f4409 draft
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit e26adecc1caf5c8fe966a5c891cc7941324d73bb
author | sybila |
---|---|
date | Fri, 09 Sep 2022 13:22:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f13bdc5f4409 |
---|---|
1 import argparse | |
2 | |
3 from eBCSgen.Errors.ModelParsingError import ModelParsingError | |
4 from eBCSgen.Errors.UnspecifiedParsingError import UnspecifiedParsingError | |
5 from eBCSgen.Parsing.ParseBCSL import Parser | |
6 | |
7 import numpy as np | |
8 | |
9 | |
10 args_parser = argparse.ArgumentParser(description='Transition system generating') | |
11 | |
12 args_parser._action_groups.pop() | |
13 required = args_parser.add_argument_group('required arguments') | |
14 optional = args_parser.add_argument_group('optional arguments') | |
15 | |
16 required.add_argument('--model', type=str, required=True) | |
17 required.add_argument('--output', type=str, required=True) | |
18 required.add_argument('--direct', required=True) | |
19 | |
20 optional.add_argument('--max_time', type=float, default=np.inf) | |
21 optional.add_argument('--max_size', type=float, default=np.inf) | |
22 optional.add_argument('--bound', type=int, default=None) | |
23 | |
24 args = args_parser.parse_args() | |
25 | |
26 model_parser = Parser("model") | |
27 model_str = open(args.model, "r").read() | |
28 | |
29 model = model_parser.parse(model_str) | |
30 if model.success: | |
31 if eval(args.direct): | |
32 ts = model.data.generate_direct_transition_system(args.max_time, | |
33 args.max_size, | |
34 args.bound) | |
35 ts.change_to_vector_backend() | |
36 else: | |
37 vm = model.data.to_vector_model(args.bound) | |
38 ts = vm.generate_transition_system(None, args.max_time, args.max_size) | |
39 ts.save_to_json(args.output, model.data.params) | |
40 else: | |
41 if "error" in model.data: | |
42 raise UnspecifiedParsingError(model.data["error"]) | |
43 raise ModelParsingError(model.data, model_str) |