seed2lp 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- seed2lp/__init__.py +12 -0
- seed2lp/__main__.py +837 -0
- seed2lp/_version.py +2 -0
- seed2lp/argument.py +717 -0
- seed2lp/asp/atom_for_transfers.lp +7 -0
- seed2lp/asp/community_heuristic.lp +3 -0
- seed2lp/asp/community_search.lp +14 -0
- seed2lp/asp/constraints_targets.lp +15 -0
- seed2lp/asp/definition_atoms.lp +87 -0
- seed2lp/asp/enum-cc.lp +50 -0
- seed2lp/asp/flux.lp +70 -0
- seed2lp/asp/limit_transfers.lp +9 -0
- seed2lp/asp/maximize_flux.lp +2 -0
- seed2lp/asp/maximize_produced_target.lp +7 -0
- seed2lp/asp/minimize.lp +8 -0
- seed2lp/asp/seed-solving.lp +116 -0
- seed2lp/asp/seed_external.lp +1 -0
- seed2lp/asp/show_seeds.lp +2 -0
- seed2lp/asp/show_tranfers.lp +1 -0
- seed2lp/asp/test.lp +61 -0
- seed2lp/clingo_lpx.py +236 -0
- seed2lp/color.py +34 -0
- seed2lp/config.yaml +56 -0
- seed2lp/description.py +424 -0
- seed2lp/file.py +151 -0
- seed2lp/flux.py +365 -0
- seed2lp/linear.py +431 -0
- seed2lp/log_conf.yaml +25 -0
- seed2lp/logger.py +112 -0
- seed2lp/metabolite.py +46 -0
- seed2lp/network.py +1921 -0
- seed2lp/reaction.py +207 -0
- seed2lp/reasoning.py +459 -0
- seed2lp/reasoningcom.py +753 -0
- seed2lp/reasoninghybrid.py +791 -0
- seed2lp/resmod.py +74 -0
- seed2lp/sbml.py +307 -0
- seed2lp/scope.py +124 -0
- seed2lp/solver.py +333 -0
- seed2lp/temp_flux_com.py +74 -0
- seed2lp/utils.py +237 -0
- seed2lp-2.0.0.dist-info/METADATA +404 -0
- seed2lp-2.0.0.dist-info/RECORD +53 -0
- seed2lp-2.0.0.dist-info/WHEEL +5 -0
- seed2lp-2.0.0.dist-info/entry_points.txt +2 -0
- seed2lp-2.0.0.dist-info/licenses/LICENCE.txt +145 -0
- seed2lp-2.0.0.dist-info/top_level.txt +2 -0
- tests/__init__.py +0 -0
- tests/fba.py +147 -0
- tests/full_network.py +166 -0
- tests/normalization.py +188 -0
- tests/target.py +286 -0
- tests/utils.py +181 -0
seed2lp/argument.py
ADDED
|
@@ -0,0 +1,717 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import yaml
|
|
3
|
+
from sys import argv
|
|
4
|
+
from os import path
|
|
5
|
+
from ._version import __version__
|
|
6
|
+
from .file import existant_path, is_valid_dir
|
|
7
|
+
|
|
8
|
+
DESCRIPTION = """
|
|
9
|
+
Seed detection in metabolic networks.
|
|
10
|
+
"""
|
|
11
|
+
LICENSE = """
|
|
12
|
+
GNU GENERAL PUBLIC LICENSE
|
|
13
|
+
Version 3, 29 June 2007
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
DICT_CHECK = {"--verbose" : "-v",
|
|
17
|
+
"--mode" : "-m",
|
|
18
|
+
"--community_mode" : "-cm",
|
|
19
|
+
"--solve" : "-so",
|
|
20
|
+
"--intersection" : "-i",
|
|
21
|
+
"--union" : "-u",
|
|
22
|
+
"--targets-as-seeds" : "-tas",
|
|
23
|
+
"--topological-injection" : "-ti",
|
|
24
|
+
"--keep-import-reactions" : "-kir",
|
|
25
|
+
"--check-flux" : "-cf",
|
|
26
|
+
"--maximize-flux" : "-max",
|
|
27
|
+
"--equality-flux" : "-ef",
|
|
28
|
+
"--clingo-configuration" : "-cc",
|
|
29
|
+
"--clingo-strategy" : "-cs",
|
|
30
|
+
"--time-limit" : "-tl",
|
|
31
|
+
"--number-solution" : "-nbs",
|
|
32
|
+
"--temp" : "-tmp",
|
|
33
|
+
"--accumulation" : "-accu"}
|
|
34
|
+
|
|
35
|
+
############################################################
|
|
36
|
+
##################### COMMAND PARSER #######################
|
|
37
|
+
############################################################
|
|
38
|
+
|
|
39
|
+
def cli_parser() -> argparse.ArgumentParser:
|
|
40
|
+
parser = argparse.ArgumentParser(
|
|
41
|
+
"Seed2LP",
|
|
42
|
+
description=DESCRIPTION,
|
|
43
|
+
formatter_class=argparse.RawTextHelpFormatter
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
parser.add_argument(
|
|
47
|
+
"-v",
|
|
48
|
+
"--version",
|
|
49
|
+
action="version",
|
|
50
|
+
version="%(prog)s " + f"{__version__} \n{LICENSE}")
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
pp_verbose = argparse.ArgumentParser(add_help=False)
|
|
54
|
+
pp_verbose.add_argument(
|
|
55
|
+
'--verbose', '-v', action='store_true',
|
|
56
|
+
help="Print every process steps. Debug mode."
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
#----------------------- POSITIONNAL ---------------------------
|
|
60
|
+
|
|
61
|
+
# run / Calculate flux / Network representations
|
|
62
|
+
pp_network = argparse.ArgumentParser(add_help=False)
|
|
63
|
+
pp_network.add_argument(
|
|
64
|
+
dest="infile",
|
|
65
|
+
help="SBML or ASP file containing the graph data.",
|
|
66
|
+
type=existant_path
|
|
67
|
+
)
|
|
68
|
+
pp_community = argparse.ArgumentParser(add_help=False)
|
|
69
|
+
pp_community.add_argument(
|
|
70
|
+
dest="comfile",
|
|
71
|
+
help="Text file contianing name of species.",
|
|
72
|
+
type=existant_path
|
|
73
|
+
)
|
|
74
|
+
pp_sbml_dir = argparse.ArgumentParser(add_help=False)
|
|
75
|
+
pp_sbml_dir.add_argument(
|
|
76
|
+
dest="sbmldir",
|
|
77
|
+
type=existant_path, default=None,
|
|
78
|
+
help="Directory containing all SBML File."
|
|
79
|
+
)
|
|
80
|
+
# Calculate flux
|
|
81
|
+
pp_result = argparse.ArgumentParser(add_help=False)
|
|
82
|
+
pp_result.add_argument(
|
|
83
|
+
dest="result_file",
|
|
84
|
+
help="Seed2lp result file containing results.",
|
|
85
|
+
type=existant_path
|
|
86
|
+
)
|
|
87
|
+
# Network representations
|
|
88
|
+
pp_output_dir = argparse.ArgumentParser(add_help=False)
|
|
89
|
+
pp_output_dir.add_argument(
|
|
90
|
+
dest="output_dir",
|
|
91
|
+
help="Output directory path",
|
|
92
|
+
type=is_valid_dir
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
#--------------------- PARSERS -------------------------
|
|
98
|
+
|
|
99
|
+
#-------------------------------------------------------
|
|
100
|
+
# Supplementary data given by user
|
|
101
|
+
#-------------------------------------------------------
|
|
102
|
+
pp_targets_file = argparse.ArgumentParser(add_help=False)
|
|
103
|
+
pp_targets_file.add_argument(
|
|
104
|
+
"-tf", "--targets-file", dest="targets_file",
|
|
105
|
+
type=existant_path, default=None,
|
|
106
|
+
help="file containing one target per line",
|
|
107
|
+
required=False
|
|
108
|
+
)
|
|
109
|
+
pp_seeds_file = argparse.ArgumentParser(add_help=False)
|
|
110
|
+
pp_seeds_file.add_argument(
|
|
111
|
+
"-sf","--seeds-file", dest="seeds_file",
|
|
112
|
+
type=existant_path, default=None,
|
|
113
|
+
help="file containing one seed per line",
|
|
114
|
+
required=False
|
|
115
|
+
)
|
|
116
|
+
pp_possible_seeds_file = argparse.ArgumentParser(add_help=False)
|
|
117
|
+
pp_possible_seeds_file.add_argument(
|
|
118
|
+
'-psf', '--possible-seeds-file', dest="possible_seeds_file",
|
|
119
|
+
type=existant_path, default=None,
|
|
120
|
+
help="file containing a set of compounds in which seed selection will be performed (greedy mode only)",
|
|
121
|
+
required=False
|
|
122
|
+
)
|
|
123
|
+
pp_forbidden_seeds_file = argparse.ArgumentParser(add_help=False)
|
|
124
|
+
pp_forbidden_seeds_file.add_argument(
|
|
125
|
+
'-fsf', '--forbidden-seeds-file', dest="forbidden_seeds_file",
|
|
126
|
+
type=existant_path, default=None,
|
|
127
|
+
help="file containing one forbidden seed per line",
|
|
128
|
+
required=False
|
|
129
|
+
)
|
|
130
|
+
pp_objective = argparse.ArgumentParser(add_help=False)
|
|
131
|
+
pp_objective.add_argument(
|
|
132
|
+
"-o","--objective", dest="objective",
|
|
133
|
+
type=str, default=[],
|
|
134
|
+
help="objective reaction to activate in the graph",
|
|
135
|
+
required=False
|
|
136
|
+
)
|
|
137
|
+
pp_forbidden_transfers_file = argparse.ArgumentParser(add_help=False)
|
|
138
|
+
pp_forbidden_transfers_file.add_argument(
|
|
139
|
+
'-ftf', '--forbidden-transfers-file', dest="forbidden_transfers_file",
|
|
140
|
+
type=existant_path, default=None,
|
|
141
|
+
help="file containing one forbidden transfer per line",
|
|
142
|
+
required=False
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
#-------------------------------------------------------
|
|
146
|
+
# Set mode
|
|
147
|
+
#-------------------------------------------------------
|
|
148
|
+
pp_mode = argparse.ArgumentParser(add_help=False, formatter_class=argparse.RawTextHelpFormatter)
|
|
149
|
+
pp_mode.add_argument(
|
|
150
|
+
'-m', '--mode', dest="mode",
|
|
151
|
+
type=str, default='subsetmin', choices=['minimize', 'subsetmin', 'all'],
|
|
152
|
+
help="""Choose a mode for comuting solutions: \n \
|
|
153
|
+
- minimize : The smallest set of seed \n \
|
|
154
|
+
- subsetmin : All the minimal solution included into solutions (subset minimal)\n \
|
|
155
|
+
- all: Compute subsetmin then minimize""",
|
|
156
|
+
required=False
|
|
157
|
+
)
|
|
158
|
+
pp_solve = argparse.ArgumentParser(add_help=False, formatter_class=argparse.RawTextHelpFormatter)
|
|
159
|
+
pp_solve.add_argument(
|
|
160
|
+
'-so', '--solve', dest="solve",
|
|
161
|
+
type=str, default='reasoning', choices=['reasoning', 'filter', 'guess_check', 'guess_check_div', 'hybrid', 'all'],
|
|
162
|
+
help="Select the solving mode\n \
|
|
163
|
+
- reasoning : Only reasoning, no linear calcul \n \
|
|
164
|
+
- hybrid : Reasoning and linar calcul\n \
|
|
165
|
+
- guess_check : Only reasoning with guess and check results using cobra (adapts rules) \n \
|
|
166
|
+
- guess_check_div : Only reasoning with guess and check results using cobra (adapts rules) and add diversity \n \
|
|
167
|
+
- filter : Only reasoning with a cobra filter validation during search (do not adapt rules) \n \
|
|
168
|
+
- all : Compute reasoning then hybrid then fba",
|
|
169
|
+
required=False
|
|
170
|
+
)
|
|
171
|
+
pp_solve_com = argparse.ArgumentParser(add_help=False, formatter_class=argparse.RawTextHelpFormatter)
|
|
172
|
+
pp_solve_com.add_argument(
|
|
173
|
+
'-so', '--solve', dest="solve",
|
|
174
|
+
type=str, default='reasoning', choices=['reasoning', 'filter', 'guess_check', 'guess_check_div'],
|
|
175
|
+
help="Select the solving mode\n \
|
|
176
|
+
- reasoning : Only reasoning, no linear calcul \n \
|
|
177
|
+
- guess_check : Only reasoning with guess and check results using cobra (adapts rules) \n \
|
|
178
|
+
- guess_check_div : Only reasoning with guess and check results using cobra (adapts rules) and add diversity \n \
|
|
179
|
+
- filter : Only reasoning with a cobra filter validation during search (do not adapt rules) \n \
|
|
180
|
+
- all : Compute reasoning then hybrid then fba",
|
|
181
|
+
required=False
|
|
182
|
+
)
|
|
183
|
+
pp_intersection = argparse.ArgumentParser(add_help=False)
|
|
184
|
+
pp_intersection.add_argument(
|
|
185
|
+
'-i', '--intersection', dest="intersection",
|
|
186
|
+
action='store_true',
|
|
187
|
+
help="Compute intersection of solutions",
|
|
188
|
+
required=False
|
|
189
|
+
)
|
|
190
|
+
pp_union = argparse.ArgumentParser(add_help=False)
|
|
191
|
+
pp_union.add_argument(
|
|
192
|
+
'-u', '--union', dest="union",
|
|
193
|
+
action='store_true',
|
|
194
|
+
help="Compute union of solutions",
|
|
195
|
+
required=False
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
#-------------------------------------------------------
|
|
199
|
+
# Community options
|
|
200
|
+
#-------------------------------------------------------
|
|
201
|
+
pp_com_mode = argparse.ArgumentParser(add_help=False, formatter_class=argparse.RawTextHelpFormatter)
|
|
202
|
+
pp_com_mode.add_argument(
|
|
203
|
+
'-cm', '--community_mode', dest="community_mode",
|
|
204
|
+
type=str, default='bisteps', choices=['bisteps', 'global', 'delsupset'],
|
|
205
|
+
help="""Choose a mode for computing solutions (default bisteps): \n \
|
|
206
|
+
- bisteps : First subset minimal on seeds then subset minimal on transfers\n \
|
|
207
|
+
- global : subset minimal on union seeds and transfers \n \
|
|
208
|
+
- delsupset : Delete superset of solutions """,
|
|
209
|
+
required=False
|
|
210
|
+
)
|
|
211
|
+
pp_del_supset_mode = argparse.ArgumentParser(add_help=False, formatter_class=argparse.RawTextHelpFormatter)
|
|
212
|
+
pp_del_supset_mode.add_argument(
|
|
213
|
+
'-pd', '--partial_delete_superset', dest="partial_delete_superset",
|
|
214
|
+
action='store_true',
|
|
215
|
+
help="""For delete superset mode, the post filter with pyhton is not executed, only a delete sueperset
|
|
216
|
+
via ASP is done. That's implies some solution founded before can be supserset on seeds of other solutions""",
|
|
217
|
+
required=False
|
|
218
|
+
)
|
|
219
|
+
pp_all_transfers = argparse.ArgumentParser(add_help=False, formatter_class=argparse.RawTextHelpFormatter)
|
|
220
|
+
pp_all_transfers.add_argument(
|
|
221
|
+
'-at', '--all_transfers', dest="all_transfers",
|
|
222
|
+
action='store_true',
|
|
223
|
+
help="""For bistesps mode and delete superset mode.
|
|
224
|
+
Allows to find all exchanged of one set of seeds solutions and not only the first one before
|
|
225
|
+
finding the next set of seeds solutions. This may give less different set of seeds.
|
|
226
|
+
""",
|
|
227
|
+
required=False
|
|
228
|
+
)
|
|
229
|
+
pp_not_shown_transfers = argparse.ArgumentParser(add_help=False, formatter_class=argparse.RawTextHelpFormatter)
|
|
230
|
+
pp_not_shown_transfers.add_argument(
|
|
231
|
+
'-nst', '--not_shown_transfers', dest="not_shown_transfers",
|
|
232
|
+
action='store_true',
|
|
233
|
+
help="""Do global method or delete superset methods without showing transfers
|
|
234
|
+
""",
|
|
235
|
+
required=False
|
|
236
|
+
)
|
|
237
|
+
pp_limit_transfers = argparse.ArgumentParser(add_help=False, formatter_class=argparse.RawTextHelpFormatter)
|
|
238
|
+
pp_limit_transfers.add_argument(
|
|
239
|
+
'-lt', '--limit_transfers', dest="limit_transfers",
|
|
240
|
+
type=int, default=-1,
|
|
241
|
+
help="""Limit the maximum number of transfers in set. By default -1, meaning no limit.
|
|
242
|
+
""",
|
|
243
|
+
required=False
|
|
244
|
+
)
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
#-------------------------------------------------------
|
|
248
|
+
# Set of seed restrictions
|
|
249
|
+
#-------------------------------------------------------
|
|
250
|
+
pp_targets_as_seeds = argparse.ArgumentParser(add_help=False)
|
|
251
|
+
pp_targets_as_seeds.add_argument(
|
|
252
|
+
'-tas', '--targets-as-seeds', dest="targets_as_seeds",
|
|
253
|
+
action='store_true',
|
|
254
|
+
help="Targets are allowed as seeds",
|
|
255
|
+
required=False
|
|
256
|
+
)
|
|
257
|
+
pp_topological_injection = argparse.ArgumentParser(add_help=False)
|
|
258
|
+
pp_topological_injection.add_argument(
|
|
259
|
+
'-ti', '--topological-injection', dest="topological_injection",
|
|
260
|
+
action='store_true',
|
|
261
|
+
help="Use topological injection found in sbml data",
|
|
262
|
+
required=False
|
|
263
|
+
)
|
|
264
|
+
pp_keep_import_reactions = argparse.ArgumentParser(add_help=False)
|
|
265
|
+
pp_keep_import_reactions.add_argument(
|
|
266
|
+
'-kir', '--keep-import-reactions', dest="keep_import_reactions",
|
|
267
|
+
action='store_true',
|
|
268
|
+
help="Keep import reactions found in sbml file",
|
|
269
|
+
required=False
|
|
270
|
+
)
|
|
271
|
+
pp_accumulation = argparse.ArgumentParser(add_help=False)
|
|
272
|
+
pp_accumulation.add_argument(
|
|
273
|
+
'-accu', '--accumulation', dest="accumulation",
|
|
274
|
+
action='store_true',
|
|
275
|
+
help="Accumulation allowed",
|
|
276
|
+
required=False
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
#-------------------------------------------------------
|
|
281
|
+
# Flux options
|
|
282
|
+
#-------------------------------------------------------
|
|
283
|
+
pp_check_flux= argparse.ArgumentParser(add_help=False)
|
|
284
|
+
pp_check_flux.add_argument(
|
|
285
|
+
'-cf', '--check-flux', dest="check_flux",
|
|
286
|
+
action='store_true',
|
|
287
|
+
help="Run a flux check on a resulted set of seeds using cobra.py",
|
|
288
|
+
required=False
|
|
289
|
+
)
|
|
290
|
+
pp_maximize_flux = argparse.ArgumentParser(add_help=False)
|
|
291
|
+
pp_maximize_flux.add_argument(
|
|
292
|
+
'-max', '--maximize-flux', dest="maximize_flux",
|
|
293
|
+
action='store_true',
|
|
294
|
+
help="Maximize the flux of objective reaction",
|
|
295
|
+
required=False
|
|
296
|
+
)
|
|
297
|
+
pp_com_equality_flux = argparse.ArgumentParser(add_help=False)
|
|
298
|
+
pp_com_equality_flux.add_argument(
|
|
299
|
+
'-ef', '--equality-flux', dest="equality_flux",
|
|
300
|
+
action='store_true',
|
|
301
|
+
help="""Forces flux equality between species biomass in community using cobra.py
|
|
302
|
+
while check_flux is used or while sovling in Filter, Guess-Check or Guess-Check with Diversity modes.
|
|
303
|
+
If not used, the tool ensures a minimum flux into species biomass.""",
|
|
304
|
+
required=False
|
|
305
|
+
)
|
|
306
|
+
pp_check_flux_parallel = argparse.ArgumentParser(add_help=False)
|
|
307
|
+
pp_check_flux_parallel.add_argument(
|
|
308
|
+
'-fp', '--flux-parallel', dest="flux_parallel",
|
|
309
|
+
type=int, default=-1,
|
|
310
|
+
help="""Parallelise check flux.""",
|
|
311
|
+
required=False
|
|
312
|
+
)
|
|
313
|
+
|
|
314
|
+
#-------------------------------------------------------
|
|
315
|
+
# clingo parameters for solving
|
|
316
|
+
#-------------------------------------------------------
|
|
317
|
+
pp_clingo_configuration = argparse.ArgumentParser(add_help=False)
|
|
318
|
+
pp_clingo_configuration.add_argument(
|
|
319
|
+
'-cc', '--clingo-configuration', dest="clingo_configuration",
|
|
320
|
+
type=str, default='jumpy', choices=['jumpy', 'none'],
|
|
321
|
+
help="Changing clingo configuration: jumpy / none",
|
|
322
|
+
required=False
|
|
323
|
+
)
|
|
324
|
+
pp_clingo_strategy = argparse.ArgumentParser(add_help=False)
|
|
325
|
+
pp_clingo_strategy.add_argument(
|
|
326
|
+
'-cs', '--clingo-strategy', dest="clingo_strategy",
|
|
327
|
+
type=str, default='none', choices=['usc,oll', 'none'],
|
|
328
|
+
help="Changing clingo strategy: usc,oll / none",
|
|
329
|
+
required=False
|
|
330
|
+
)
|
|
331
|
+
pp_time_limit = argparse.ArgumentParser(add_help=False)
|
|
332
|
+
pp_time_limit.add_argument(
|
|
333
|
+
'-tl', '--time-limit', dest="time_limit",
|
|
334
|
+
type=float, default=0,
|
|
335
|
+
help="Add a time limit in minutes for finding seeds. By default 0, meaning no limit",
|
|
336
|
+
required=False
|
|
337
|
+
)
|
|
338
|
+
pp_number_solution = argparse.ArgumentParser(add_help=False)
|
|
339
|
+
pp_number_solution.add_argument(
|
|
340
|
+
'-nbs', '--number-solution', dest="number_solution",
|
|
341
|
+
type=int, default=10,
|
|
342
|
+
help="Change the number of solution limit. By default:10. \
|
|
343
|
+
\n0 solution means no limit. \
|
|
344
|
+
\n-1 means no enumeration",
|
|
345
|
+
required=False
|
|
346
|
+
)
|
|
347
|
+
|
|
348
|
+
#-------------------------------------------------------
|
|
349
|
+
# ASP Facts storage
|
|
350
|
+
#-------------------------------------------------------
|
|
351
|
+
pp_instance = argparse.ArgumentParser(add_help=False)
|
|
352
|
+
pp_instance.add_argument(
|
|
353
|
+
'-in', '--instance', dest="instance",
|
|
354
|
+
type=str, default=None,
|
|
355
|
+
help="export the ASP instance of input data and quit",
|
|
356
|
+
required=False
|
|
357
|
+
)
|
|
358
|
+
pp_temp = argparse.ArgumentParser(add_help=False)
|
|
359
|
+
pp_temp.add_argument(
|
|
360
|
+
'-tmp', '--temp', dest="temp",
|
|
361
|
+
type=str,
|
|
362
|
+
help="Temporary directory for hybrid or fba mode.",
|
|
363
|
+
required=False
|
|
364
|
+
)
|
|
365
|
+
|
|
366
|
+
#-------------------------------------------------------
|
|
367
|
+
# Network description
|
|
368
|
+
#-------------------------------------------------------
|
|
369
|
+
pp_visualize = argparse.ArgumentParser(add_help=False)
|
|
370
|
+
pp_visualize.add_argument(
|
|
371
|
+
'-vi', '--visualize', dest="visualize",
|
|
372
|
+
action='store_true',
|
|
373
|
+
help="Render the input graph in png (default: don't render)",
|
|
374
|
+
required=False
|
|
375
|
+
)
|
|
376
|
+
|
|
377
|
+
pp_visualize_without_reactions = argparse.ArgumentParser(add_help=False)
|
|
378
|
+
pp_visualize_without_reactions.add_argument(
|
|
379
|
+
'-vir', '--visualize-without-reactions', dest="visualize_without_reactions",
|
|
380
|
+
action='store_true',
|
|
381
|
+
help="Render the input graph without reactions in png (default: don't render)",
|
|
382
|
+
required=False
|
|
383
|
+
)
|
|
384
|
+
pp_network_details = argparse.ArgumentParser(add_help=False)
|
|
385
|
+
pp_network_details.add_argument(
|
|
386
|
+
'-nd', '--network-details', dest="network_details",
|
|
387
|
+
action='store_true',
|
|
388
|
+
help="Render the description fo the network from lp and with cobra",
|
|
389
|
+
required=False
|
|
390
|
+
)
|
|
391
|
+
pp_write_file = argparse.ArgumentParser(add_help=False)
|
|
392
|
+
pp_write_file.add_argument(
|
|
393
|
+
'-wf', '--write-file', dest="write_file",
|
|
394
|
+
action='store_true',
|
|
395
|
+
help="Write the network into a sbml file after applying modifications on it for simplifying reasoning.",
|
|
396
|
+
required=False
|
|
397
|
+
)
|
|
398
|
+
|
|
399
|
+
#-------------------------------------------------------
|
|
400
|
+
# Config file
|
|
401
|
+
#-------------------------------------------------------
|
|
402
|
+
pp_config = argparse.ArgumentParser(add_help=False)
|
|
403
|
+
pp_config.add_argument(
|
|
404
|
+
'-conf', '--config-file', dest="config_file",
|
|
405
|
+
type=str,
|
|
406
|
+
help="Configuration file to use.",
|
|
407
|
+
required=False
|
|
408
|
+
)
|
|
409
|
+
|
|
410
|
+
#-------------------------------------------------------
|
|
411
|
+
# Commands commposition
|
|
412
|
+
#-------------------------------------------------------
|
|
413
|
+
subparsers = parser.add_subparsers(
|
|
414
|
+
title='subcommands',
|
|
415
|
+
description='valid subcommands:',
|
|
416
|
+
dest="cmd",)
|
|
417
|
+
|
|
418
|
+
subparsers.add_parser(
|
|
419
|
+
"target",
|
|
420
|
+
help="Run seeds detection focusing on targets.",
|
|
421
|
+
parents=[
|
|
422
|
+
pp_verbose,
|
|
423
|
+
pp_network, pp_output_dir,
|
|
424
|
+
pp_targets_file,
|
|
425
|
+
pp_seeds_file,
|
|
426
|
+
pp_possible_seeds_file,
|
|
427
|
+
pp_forbidden_seeds_file,
|
|
428
|
+
pp_mode, pp_solve, pp_intersection, pp_union,
|
|
429
|
+
pp_targets_as_seeds, pp_topological_injection, pp_keep_import_reactions,
|
|
430
|
+
pp_clingo_configuration, pp_clingo_strategy, pp_time_limit, pp_number_solution,
|
|
431
|
+
pp_instance, pp_temp, pp_check_flux, pp_maximize_flux,
|
|
432
|
+
pp_config, pp_accumulation
|
|
433
|
+
],
|
|
434
|
+
description=
|
|
435
|
+
"""
|
|
436
|
+
Seed Searching mode focusing on reachability of targetted metabolites (reactants of objective reaction).
|
|
437
|
+
It is possible to add targets or change the objective reaction by using the option -tf/--targets-file.
|
|
438
|
+
Multiple solving mode (-so/--solve) are available:
|
|
439
|
+
- reasoning: Only focus in reachability of metabolites using Network Expanion
|
|
440
|
+
- filter: First uses Network Expanion, then check the flux with COBRApy inferred by seeds
|
|
441
|
+
- guess_check: Uses Network Expanion, check flux with COBRApy and return results to solver to dismiss superset of results
|
|
442
|
+
- guess_check_div: Guess check but also forbids subset of seed as next result in order to reduce intersection of solutions
|
|
443
|
+
- hybrid: First uses Network Expansion then calculate FBA constraints with clingo-lpx
|
|
444
|
+
""",
|
|
445
|
+
usage="""
|
|
446
|
+
seed2lp target [network_file] [output_dir] \n
|
|
447
|
+
"""
|
|
448
|
+
)
|
|
449
|
+
|
|
450
|
+
subparsers.add_parser(
|
|
451
|
+
"full",
|
|
452
|
+
help="Run seeds detection focusing on full network.",
|
|
453
|
+
parents=[
|
|
454
|
+
pp_verbose,
|
|
455
|
+
pp_network, pp_output_dir,
|
|
456
|
+
pp_objective,
|
|
457
|
+
pp_seeds_file,
|
|
458
|
+
pp_possible_seeds_file,
|
|
459
|
+
pp_forbidden_seeds_file,
|
|
460
|
+
pp_mode, pp_solve, pp_intersection, pp_union,
|
|
461
|
+
pp_topological_injection, pp_keep_import_reactions,
|
|
462
|
+
pp_clingo_configuration, pp_clingo_strategy, pp_time_limit, pp_number_solution,
|
|
463
|
+
pp_instance, pp_temp, pp_check_flux, pp_maximize_flux,
|
|
464
|
+
pp_config, pp_accumulation
|
|
465
|
+
],
|
|
466
|
+
description=
|
|
467
|
+
"""
|
|
468
|
+
Seed Searching mode focusing on reachability of all metabolites of the GSMN.
|
|
469
|
+
It is possible to change the objective reaction by using the option -o/--objective for flux checking.
|
|
470
|
+
Multiple solving mode (-so/--solve) are available:
|
|
471
|
+
- reasoning: Only focus in reachability of metabolites using Network Expanion
|
|
472
|
+
- filter: First uses Network Expanion, then check the flux with COBRApy inferred by seeds
|
|
473
|
+
- guess_check: Uses Network Expanion, check flux with COBRApy and return results to solver to dismiss superset of results
|
|
474
|
+
- guess_check_div: Guess check but also forbids subset of seed as next result in order to reduce intersection of solutions
|
|
475
|
+
- hybrid: First uses Network Expansion then calculate FBA constraints with clingo-lpx
|
|
476
|
+
""",
|
|
477
|
+
usage="""
|
|
478
|
+
seed2lp full [network_file] [output_dir] \n
|
|
479
|
+
"""
|
|
480
|
+
)
|
|
481
|
+
|
|
482
|
+
subparsers.add_parser(
|
|
483
|
+
"fba",
|
|
484
|
+
help="Run seeds detection in aleatory way focusing on fba.",
|
|
485
|
+
parents=[
|
|
486
|
+
pp_verbose,
|
|
487
|
+
pp_network, pp_output_dir,
|
|
488
|
+
pp_objective,
|
|
489
|
+
pp_seeds_file,
|
|
490
|
+
pp_possible_seeds_file,
|
|
491
|
+
pp_forbidden_seeds_file,
|
|
492
|
+
pp_mode, pp_intersection, pp_union,
|
|
493
|
+
pp_targets_as_seeds, pp_topological_injection, pp_keep_import_reactions,
|
|
494
|
+
pp_clingo_configuration, pp_clingo_strategy, pp_time_limit, pp_number_solution,
|
|
495
|
+
pp_instance, pp_temp, pp_check_flux, pp_maximize_flux,
|
|
496
|
+
pp_config
|
|
497
|
+
],
|
|
498
|
+
description=
|
|
499
|
+
"""
|
|
500
|
+
Random Seed Searching mode focusing in FBA constraints using clingo-lpx solver.
|
|
501
|
+
It is possible to change the objective reaction by using the option -o/--objective for flux checking.
|
|
502
|
+
""",
|
|
503
|
+
usage="""
|
|
504
|
+
seed2lp fba [network_file] [output_dir] \n
|
|
505
|
+
"""
|
|
506
|
+
)
|
|
507
|
+
|
|
508
|
+
subparsers.add_parser(
|
|
509
|
+
"network",
|
|
510
|
+
help="Give Network Details with reactions, create graph of Network, rewrite network sbml file",
|
|
511
|
+
parents=[
|
|
512
|
+
pp_verbose,
|
|
513
|
+
pp_network, pp_output_dir,
|
|
514
|
+
pp_keep_import_reactions,
|
|
515
|
+
pp_visualize, pp_visualize_without_reactions,
|
|
516
|
+
pp_network_details, pp_write_file
|
|
517
|
+
],
|
|
518
|
+
description=
|
|
519
|
+
"""
|
|
520
|
+
This functionnality aims to help people with the networks by:
|
|
521
|
+
- Creating a graph with or without the reactions boxes (-vi/--visualize or -vir/--visualize-without-reaction)
|
|
522
|
+
- Creating a file with list and formula of reactions from original GSMN, the normalized one and a diff file (-nd/--network-details)
|
|
523
|
+
- Writing the normalized sbml file (-wf/--write-file)
|
|
524
|
+
""",
|
|
525
|
+
usage="""
|
|
526
|
+
seed2lp network [network_file] [output_dir] --visualize \n
|
|
527
|
+
"""
|
|
528
|
+
)
|
|
529
|
+
|
|
530
|
+
subparsers.add_parser(
|
|
531
|
+
"flux",
|
|
532
|
+
help="Calculate cobra flux from seed2lp result file, using sbml file",
|
|
533
|
+
parents=[
|
|
534
|
+
pp_verbose, pp_network, pp_result, pp_output_dir, pp_check_flux_parallel
|
|
535
|
+
],
|
|
536
|
+
description=
|
|
537
|
+
"""
|
|
538
|
+
From Seed2lp seed searching results json file, this functionnality calculate fluxes inferred by seeds for all models using COBRApy.
|
|
539
|
+
Can be used for other tool results if the results file has the same json structure.
|
|
540
|
+
""",
|
|
541
|
+
usage="""
|
|
542
|
+
seed2lp flux [sbml_file] [seed2lp_result_file] [output_directory] \n
|
|
543
|
+
"""
|
|
544
|
+
)
|
|
545
|
+
|
|
546
|
+
subparsers.add_parser(
|
|
547
|
+
"scope",
|
|
548
|
+
help="From seeds determine scope of the network. ",
|
|
549
|
+
parents=[
|
|
550
|
+
pp_verbose, pp_network, pp_result, pp_output_dir, pp_temp
|
|
551
|
+
],
|
|
552
|
+
description=
|
|
553
|
+
"""
|
|
554
|
+
From Seed2lp seed searching results json file, this functionnality detemine scope inferred by seeeds using Network Expansion.
|
|
555
|
+
Can be used for other tool results if the results file has the same json structure.
|
|
556
|
+
The scope calculation is done with MeneTools.
|
|
557
|
+
""",
|
|
558
|
+
usage="""
|
|
559
|
+
seed2lp scope [sbml_file] [seed2lp_result_file] [output_directory] \n
|
|
560
|
+
"""
|
|
561
|
+
)
|
|
562
|
+
|
|
563
|
+
subparsers.add_parser(
|
|
564
|
+
"conf",
|
|
565
|
+
help="Copy and save a conf file. ",
|
|
566
|
+
parents=[
|
|
567
|
+
pp_output_dir
|
|
568
|
+
],
|
|
569
|
+
description=
|
|
570
|
+
"""
|
|
571
|
+
Copy the internal configuration fil an dsave it.
|
|
572
|
+
The configuration file saved can be modified and reused for all seed searching methods with the option -tmp/--temp
|
|
573
|
+
""",
|
|
574
|
+
usage="""
|
|
575
|
+
seed2lp conf [output_directory] \n
|
|
576
|
+
"""
|
|
577
|
+
)
|
|
578
|
+
|
|
579
|
+
subparsers.add_parser(
|
|
580
|
+
"objective_targets",
|
|
581
|
+
help="Get the objective reaction reactants metabolites and write them into a file",
|
|
582
|
+
parents=[
|
|
583
|
+
pp_verbose, pp_network, pp_objective, pp_output_dir
|
|
584
|
+
],
|
|
585
|
+
description=
|
|
586
|
+
"""
|
|
587
|
+
From an sbml file, either :
|
|
588
|
+
- Find the objective and write the reactants into a file
|
|
589
|
+
- Write the reactants of the given objectve (-o/--objective) into a file
|
|
590
|
+
""",
|
|
591
|
+
usage="""
|
|
592
|
+
seed2lp conf [output_directory] \n
|
|
593
|
+
"""
|
|
594
|
+
)
|
|
595
|
+
|
|
596
|
+
subparsers.add_parser(
|
|
597
|
+
"community",
|
|
598
|
+
help="Run seeds detection for a comunity of species ",
|
|
599
|
+
parents=[
|
|
600
|
+
pp_verbose,
|
|
601
|
+
pp_community, pp_sbml_dir,
|
|
602
|
+
pp_output_dir,
|
|
603
|
+
pp_targets_file,
|
|
604
|
+
pp_seeds_file,
|
|
605
|
+
pp_possible_seeds_file,
|
|
606
|
+
pp_forbidden_seeds_file, pp_forbidden_transfers_file,
|
|
607
|
+
pp_com_mode, pp_solve_com, pp_intersection, pp_union,
|
|
608
|
+
pp_targets_as_seeds, pp_topological_injection, pp_keep_import_reactions,
|
|
609
|
+
pp_clingo_configuration, pp_clingo_strategy, pp_time_limit, pp_number_solution,
|
|
610
|
+
pp_instance, pp_temp, pp_check_flux, pp_com_equality_flux,
|
|
611
|
+
pp_del_supset_mode, pp_all_transfers,
|
|
612
|
+
pp_config, pp_accumulation,
|
|
613
|
+
pp_not_shown_transfers, pp_limit_transfers
|
|
614
|
+
],
|
|
615
|
+
#TODO: Target file ? changing objective ? transfers forbidden file ?
|
|
616
|
+
description=
|
|
617
|
+
"""
|
|
618
|
+
Seed Searching mode adapted to comunity focusing on reachability of targetted metabolites.
|
|
619
|
+
The targetted metabolites are reactants of each objective reaction by GSMN.
|
|
620
|
+
Multiple solving mode (-so/--solve) are available:
|
|
621
|
+
- reasoning: Only focus in reachability of metabolites using Network Expanion
|
|
622
|
+
- filter: First uses Network Expanion, then check the flux with COBRApy inferred by seeds
|
|
623
|
+
- guess_check: Uses Network Expanion, check flux with COBRApy and return results to solver to dismiss superset of results
|
|
624
|
+
- guess_check_div: Guess check but also forbids subset of seed as next result in order to reduce intersection of solutions
|
|
625
|
+
""",
|
|
626
|
+
usage="""
|
|
627
|
+
seed2lp community community_file_text sbml_directory result directory \n
|
|
628
|
+
"""
|
|
629
|
+
)
|
|
630
|
+
|
|
631
|
+
subparsers.add_parser(
|
|
632
|
+
"fluxcom",
|
|
633
|
+
help="Calculate cobra flux from seed2lp result file, using a community file and sbml directory",
|
|
634
|
+
parents=[
|
|
635
|
+
pp_verbose,
|
|
636
|
+
pp_community, pp_sbml_dir,
|
|
637
|
+
pp_result, pp_output_dir, pp_com_equality_flux,
|
|
638
|
+
pp_config, pp_temp, pp_check_flux_parallel
|
|
639
|
+
],
|
|
640
|
+
description=
|
|
641
|
+
"""
|
|
642
|
+
From Seed2lp seed searching results json file, this functionnality calculate fluxes inferred by seeds for all models for the community using COBRApy.
|
|
643
|
+
Can be used for other tool results if the results file has the same json structure.
|
|
644
|
+
""",
|
|
645
|
+
usage="""
|
|
646
|
+
seed2lp fluxcom community_file_text sbml_directory seed2lp_result_file output_directory \n
|
|
647
|
+
"""
|
|
648
|
+
)
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
#-------------------------------------------------------
|
|
652
|
+
# Commands commposition
|
|
653
|
+
#-------------------------------------------------------
|
|
654
|
+
#sub_community.add_argument(
|
|
655
|
+
#dest="sbmldir",
|
|
656
|
+
#type=existant_path, default=None,
|
|
657
|
+
#help="Directory containing all SBML File."
|
|
658
|
+
#)
|
|
659
|
+
|
|
660
|
+
return parser
|
|
661
|
+
|
|
662
|
+
def parse_args(args: iter = None) -> dict:
|
|
663
|
+
return cli_parser().parse_args(args)
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
####################### FUNCTIONS ##########################
|
|
667
|
+
|
|
668
|
+
def review_conf(conf_argparse:dict, cfg:dict):
|
|
669
|
+
"""Review the configuration from congif file with argument given by user
|
|
670
|
+
|
|
671
|
+
Args:
|
|
672
|
+
conf_argparse (dict): Configuration for argument
|
|
673
|
+
cfg (dict): Configuration from config file
|
|
674
|
+
|
|
675
|
+
Returns:
|
|
676
|
+
dict: cfg
|
|
677
|
+
"""
|
|
678
|
+
for key, value in conf_argparse.items():
|
|
679
|
+
if key not in cfg:
|
|
680
|
+
cfg[key] = value
|
|
681
|
+
else:
|
|
682
|
+
for long , short in DICT_CHECK.items():
|
|
683
|
+
if long in argv or short in argv:
|
|
684
|
+
long = long.lstrip("-")
|
|
685
|
+
long = long.replace("-","_")
|
|
686
|
+
cfg[long] = conf_argparse[long]
|
|
687
|
+
return cfg
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
def get_config(args:argparse.Namespace, project_source):
|
|
691
|
+
conf_argparse = vars(args)
|
|
692
|
+
conf_file=None
|
|
693
|
+
# Get config file path
|
|
694
|
+
if "config_file" not in args:
|
|
695
|
+
cfg = conf_argparse
|
|
696
|
+
elif args.config_file == None:
|
|
697
|
+
conf_file = path.join(project_source,'config.yaml')
|
|
698
|
+
else:
|
|
699
|
+
conf_file = args.config_file
|
|
700
|
+
|
|
701
|
+
# Get configs from file
|
|
702
|
+
if conf_file is not None:
|
|
703
|
+
with open(conf_file, "r") as ymlfile:
|
|
704
|
+
cfg_file = yaml.load(ymlfile, Loader=yaml.FullLoader)
|
|
705
|
+
|
|
706
|
+
# Overwrite configs with cli argument
|
|
707
|
+
match args.cmd:
|
|
708
|
+
case "target" | "full" | "fba":
|
|
709
|
+
cfg = cfg_file['seed2lp']
|
|
710
|
+
cfg = review_conf(conf_argparse, cfg)
|
|
711
|
+
case "community":
|
|
712
|
+
cfg = cfg_file['seed2lp_com']
|
|
713
|
+
cfg = review_conf(conf_argparse, cfg)
|
|
714
|
+
case "fluxcom":
|
|
715
|
+
cfg = cfg_file['flux_com']
|
|
716
|
+
cfg = review_conf(conf_argparse, cfg)
|
|
717
|
+
return cfg
|