Mercurial > repos > sybila > ebcsgen_sbml_export
annotate ebcsgen_sbml_export.py @ 0:2f3f67415022 draft
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
author | sybila |
---|---|
date | Sat, 08 Oct 2022 12:55:26 +0000 |
parents | |
children |
rev | line source |
---|---|
0
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
1 import argparse |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
2 |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
3 from eBCSgen.Errors.ModelParsingError import ModelParsingError |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
4 from eBCSgen.Errors.UnspecifiedParsingError import UnspecifiedParsingError |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
5 from eBCSgen.Parsing.ParseBCSL import Parser |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
6 |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
7 import libsbml |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
8 |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
9 |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
10 args_parser = argparse.ArgumentParser(description='Export SBML model with usage of SBML-multi package') |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
11 |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
12 args_parser._action_groups.pop() |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
13 required = args_parser.add_argument_group('required arguments') |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
14 |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
15 required.add_argument('--model', type=str, required=True) |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
16 required.add_argument('--output', type=str, required=True) |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
17 |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
18 args = args_parser.parse_args() |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
19 |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
20 model_parser = Parser("model") |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
21 model_str = open(args.model, "r").read() |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
22 |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
23 model = model_parser.parse(model_str) |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
24 if model.success: |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
25 document = model.data.export_sbml() |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
26 libsbml.writeSBMLToFile(document, args.output) |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
27 else: |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
28 if "error" in model.data: |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
29 raise UnspecifiedParsingError(model.data["error"]) |
2f3f67415022
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit 74a375c33936106a892dafb042be953a943af026
sybila
parents:
diff
changeset
|
30 raise ModelParsingError(model.data, model_str) |