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
tests/fba.py
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
Description:
|
|
6
|
+
Test seed2lp
|
|
7
|
+
"""
|
|
8
|
+
from os import path
|
|
9
|
+
from .utils import search_seed
|
|
10
|
+
|
|
11
|
+
##### ###### ##### DIRECTORIES AND FILES ###################
|
|
12
|
+
TEST_DIR = path.dirname(path.abspath(__file__))
|
|
13
|
+
|
|
14
|
+
# All reaction are not reversible
|
|
15
|
+
# except import/export reaction for exchange metabolite S1, S2 C and G
|
|
16
|
+
INFILE = path.join(TEST_DIR,'network/sbml/toy_paper_no_reversible.sbml')
|
|
17
|
+
########################################################
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
################### FIXED VARIABLES ####################
|
|
21
|
+
RUN_MODE="fba"
|
|
22
|
+
########################################################
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
################# EXPECTED SOLUTIONS ###################
|
|
26
|
+
|
|
27
|
+
# Seeds for Reasoning, filter, Gues-Check, Guess-Check Diversty and Hybrid
|
|
28
|
+
SEEDS_SUBMIN_TAF= [{"M_B_c", "M_D_c", "M_E_c"},
|
|
29
|
+
{"M_B_c", "M_D_c", "M_I_c"},
|
|
30
|
+
{"M_B_c", "M_D_c", "M_H_c"},
|
|
31
|
+
{"M_B_c", "M_I_c", "M_S2_e"},
|
|
32
|
+
{"M_B_c", "M_E_c", "M_S2_e"},
|
|
33
|
+
{"M_B_c", "M_H_c", "M_S2_e"},
|
|
34
|
+
{"M_A_c", "M_D_c", "M_I_c", "M_S1_e"},
|
|
35
|
+
{"M_D_c", "M_I_c", "M_J_c", "M_S1_e"},
|
|
36
|
+
{"M_A_c", "M_D_c", "M_E_c", "M_S1_e"},
|
|
37
|
+
{"M_A_c", "M_D_c", "M_H_c", "M_S1_e"},
|
|
38
|
+
{"M_A_c", "M_E_c", "M_S1_e", "M_S2_e"},
|
|
39
|
+
{"M_A_c", "M_H_c", "M_S1_e", "M_S2_e"},
|
|
40
|
+
{"M_H_c", "M_J_c", "M_S1_e", "M_S2_e"},
|
|
41
|
+
{"M_E_c", "M_J_c", "M_S1_e", "M_S2_e"},
|
|
42
|
+
{"M_A_c", "M_I_c", "M_S1_e", "M_S2_e"},
|
|
43
|
+
{"M_I_c", "M_J_c", "M_S1_e", "M_S2_e"},
|
|
44
|
+
{"M_D_c", "M_H_c", "M_J_c", "M_S1_e"},
|
|
45
|
+
{"M_D_c", "M_E_c", "M_J_c", "M_S1_e"}
|
|
46
|
+
]
|
|
47
|
+
SIZE_SUBMIN_TAF=len(SEEDS_SUBMIN_TAF)
|
|
48
|
+
|
|
49
|
+
SEEDS_MIN_TAF = [{"M_B_c", "M_D_c", "M_E_c"} ,
|
|
50
|
+
{"M_B_c", "M_D_c", "M_I_c"} ,
|
|
51
|
+
{"M_B_c", "M_D_c", "M_H_c"} ,
|
|
52
|
+
{"M_B_c", "M_I_c", "M_S2_e"} ,
|
|
53
|
+
{"M_B_c", "M_E_c", "M_S2_e"} ,
|
|
54
|
+
{"M_B_c", "M_H_c", "M_S2_e"}
|
|
55
|
+
]
|
|
56
|
+
SIZE_MIN_TAF=len(SEEDS_MIN_TAF)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
SEEDS_SUBMIN_TAS= [{"M_F_c"},
|
|
60
|
+
{"M_B_c", "M_D_c", "M_E_c"},
|
|
61
|
+
{"M_B_c", "M_D_c", "M_I_c"},
|
|
62
|
+
{"M_B_c", "M_D_c", "M_H_c"},
|
|
63
|
+
{"M_B_c", "M_I_c", "M_S2_e"},
|
|
64
|
+
{"M_B_c", "M_E_c", "M_S2_e"},
|
|
65
|
+
{"M_B_c", "M_H_c", "M_S2_e"},
|
|
66
|
+
{"M_A_c", "M_D_c", "M_I_c", "M_S1_e"},
|
|
67
|
+
{"M_D_c", "M_I_c", "M_J_c", "M_S1_e"},
|
|
68
|
+
{"M_A_c", "M_D_c", "M_E_c", "M_S1_e"},
|
|
69
|
+
{"M_A_c", "M_D_c", "M_H_c", "M_S1_e"},
|
|
70
|
+
{"M_A_c", "M_E_c", "M_S1_e", "M_S2_e"},
|
|
71
|
+
{"M_A_c", "M_H_c", "M_S1_e", "M_S2_e"},
|
|
72
|
+
{"M_H_c", "M_J_c", "M_S1_e", "M_S2_e"},
|
|
73
|
+
{"M_E_c", "M_J_c", "M_S1_e", "M_S2_e"},
|
|
74
|
+
{"M_A_c", "M_I_c", "M_S1_e", "M_S2_e"},
|
|
75
|
+
{"M_I_c", "M_J_c", "M_S1_e", "M_S2_e"},
|
|
76
|
+
{"M_D_c", "M_H_c", "M_J_c", "M_S1_e"},
|
|
77
|
+
{"M_D_c", "M_E_c", "M_J_c", "M_S1_e"}
|
|
78
|
+
]
|
|
79
|
+
SIZE_SUBMIN_TAS=len(SEEDS_SUBMIN_TAS)
|
|
80
|
+
|
|
81
|
+
SEEDS_MIN_TAS = [{"M_F_c"}]
|
|
82
|
+
SIZE_MIN_TAS=len(SEEDS_MIN_TAS)
|
|
83
|
+
|
|
84
|
+
########################################################
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
######################### TESTS ########################
|
|
92
|
+
#TODO:
|
|
93
|
+
# - test with accumulation
|
|
94
|
+
# - test keep import reaction and topological injection
|
|
95
|
+
# - find Network to have different value in Reasoning / Filter / Gues_check / Guess_Check_Div
|
|
96
|
+
# - find Network to have different value with accumulation authorized
|
|
97
|
+
# - test without maximization for hybrid
|
|
98
|
+
# - test unsat
|
|
99
|
+
# - test possible_seeds (subset of seed that maximize number of producible targets)
|
|
100
|
+
# - test changing objective
|
|
101
|
+
# - test target file
|
|
102
|
+
|
|
103
|
+
# solve values: 'all'
|
|
104
|
+
# optim values: 'submin', 'min'
|
|
105
|
+
|
|
106
|
+
# ---------------------- TARGET ARE FORBIDDEN ----------------------
|
|
107
|
+
# ----------- SUBSETMIN -----------
|
|
108
|
+
def test_submin_taf():
|
|
109
|
+
solve="all"
|
|
110
|
+
optim="submin"
|
|
111
|
+
list_solution=search_seed(INFILE, RUN_MODE, solve, optim)
|
|
112
|
+
for solution in list_solution:
|
|
113
|
+
assert set(solution) in SEEDS_SUBMIN_TAF
|
|
114
|
+
assert len(list_solution) == SIZE_SUBMIN_TAF
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
# ----------- MINIMIZE -----------
|
|
118
|
+
def test_min_taf():
|
|
119
|
+
solve="all"
|
|
120
|
+
optim="min"
|
|
121
|
+
list_solution=search_seed(INFILE, RUN_MODE, solve, optim)
|
|
122
|
+
for solution in list_solution:
|
|
123
|
+
assert set(solution) in SEEDS_MIN_TAF
|
|
124
|
+
assert len(list_solution) == SIZE_MIN_TAF
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
# ---------------------- TARGET AS SEEDS ----------------------
|
|
128
|
+
# ----------- SUBSETMIN -----------
|
|
129
|
+
def test_submin_tas():
|
|
130
|
+
solve="all"
|
|
131
|
+
optim="submin"
|
|
132
|
+
targets_as_seeds=True
|
|
133
|
+
list_solution=search_seed(INFILE, RUN_MODE, solve, optim, targets_as_seeds)
|
|
134
|
+
for solution in list_solution:
|
|
135
|
+
assert set(solution) in SEEDS_SUBMIN_TAS
|
|
136
|
+
assert len(list_solution) == SIZE_SUBMIN_TAS
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
# ----------- MINIMIZE -----------
|
|
140
|
+
def test_min_tas():
|
|
141
|
+
solve="all"
|
|
142
|
+
optim="min"
|
|
143
|
+
targets_as_seeds=True
|
|
144
|
+
list_solution=search_seed(INFILE, RUN_MODE, solve, optim, targets_as_seeds)
|
|
145
|
+
for solution in list_solution:
|
|
146
|
+
assert set(solution) in SEEDS_MIN_TAS
|
|
147
|
+
assert len(list_solution) == SIZE_MIN_TAS
|
tests/full_network.py
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
Description:
|
|
6
|
+
Test seed2lp
|
|
7
|
+
"""
|
|
8
|
+
from os import path
|
|
9
|
+
from .utils import search_seed
|
|
10
|
+
|
|
11
|
+
################ DIRECTORIES AND FILES ###################
|
|
12
|
+
TEST_DIR = path.dirname(path.abspath(__file__))
|
|
13
|
+
|
|
14
|
+
# In This Network, The reaction R2 J + A -> C is deleted
|
|
15
|
+
# C is alone in the network, with an import/export reaction,
|
|
16
|
+
# therefore C is always a seed by design in Full Network
|
|
17
|
+
# J is alone never involved in any reaction, J is never a seed
|
|
18
|
+
# All reaction are not reversible
|
|
19
|
+
# except import/export reaction for exchange metabolite S1, S2 C and G
|
|
20
|
+
INFILE = path.join(TEST_DIR,'network/sbml/toy_paper_no_rev_rm_R2.sbml')
|
|
21
|
+
########################################################
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
################### FIXED VARIABLES ####################
|
|
25
|
+
RUN_MODE="full"
|
|
26
|
+
########################################################
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
################ EXPECTED SOLUTIONS ##################
|
|
30
|
+
# Same results for subset minimal and minimize
|
|
31
|
+
SEEDS_REASONING = [{'M_C_c', 'M_F_c', 'M_S1_e', 'M_S2_e'},
|
|
32
|
+
{'M_C_c', 'M_I_c', 'M_S1_e', 'M_S2_e'},
|
|
33
|
+
{'M_C_c', 'M_H_c', 'M_S1_e', 'M_S2_e'},
|
|
34
|
+
{'M_C_c', 'M_E_c', 'M_S1_e', 'M_S2_e'}
|
|
35
|
+
]
|
|
36
|
+
SIZE_REASONING=len(SEEDS_REASONING)
|
|
37
|
+
|
|
38
|
+
# Same results for Filter, Guess-Check and Guess-Check Diversity
|
|
39
|
+
# Same results for subset minimal and minimize
|
|
40
|
+
# F is an objective reactant (therefore a target), and it is choosen
|
|
41
|
+
# event if target is forbidden because in Full Network mode,
|
|
42
|
+
# all metabolite are Target and can't be forbidden
|
|
43
|
+
SEEDS_HYB_COBRA = [{'M_C_c', 'M_F_c', 'M_S1_e', 'M_S2_e'}]
|
|
44
|
+
SIZE_HYB_COBRA=len(SEEDS_HYB_COBRA)
|
|
45
|
+
|
|
46
|
+
# metabolite A is a seed for hybrid only to create an export reaction
|
|
47
|
+
# When B is a seed, The reaction S1 -> A+B is not activated in FBA
|
|
48
|
+
# A is therefore not accumlated
|
|
49
|
+
SEEDS_SUBMIN_HYBRID = [{'M_C_c', 'M_F_c', 'M_S1_e', 'M_S2_e'},
|
|
50
|
+
{'M_A_c', 'M_C_c', 'M_I_c', 'M_S1_e', 'M_S2_e'},
|
|
51
|
+
{'M_B_c', 'M_C_c', 'M_I_c', 'M_S1_e', 'M_S2_e'},
|
|
52
|
+
{'M_A_c', 'M_C_c', 'M_H_c', 'M_S1_e', 'M_S2_e'},
|
|
53
|
+
{'M_B_c', 'M_C_c', 'M_H_c', 'M_S1_e', 'M_S2_e'},
|
|
54
|
+
{'M_A_c', 'M_C_c', 'M_E_c', 'M_S1_e', 'M_S2_e'},
|
|
55
|
+
{'M_B_c', 'M_C_c', 'M_E_c', 'M_S1_e', 'M_S2_e'}
|
|
56
|
+
]
|
|
57
|
+
SIZE_SUBMIN_HYBRID=len(SEEDS_SUBMIN_HYBRID)
|
|
58
|
+
|
|
59
|
+
# F is an objective reactant (therefore a target), and it is choosen
|
|
60
|
+
# event if target is forbidden because in Full Network mode,
|
|
61
|
+
# all metabolite are Target and can't be forbidden
|
|
62
|
+
SEEDS_MIN_HYBRID = [{'M_C_c', 'M_F_c', 'M_S1_e', 'M_S2_e'}]
|
|
63
|
+
SIZE_MIN_HYBRID=len(SEEDS_MIN_HYBRID)
|
|
64
|
+
|
|
65
|
+
########################################################
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
######################### TESTS ########################
|
|
70
|
+
#TODO:
|
|
71
|
+
# - test with accumulation
|
|
72
|
+
# - test keep import reaction and topological injection
|
|
73
|
+
# - find Network to have different value in Filter / Gues_check / Guess_Check_Div
|
|
74
|
+
# - find Network to have different value with accumulation authorized
|
|
75
|
+
# - test without maximization for hybrid
|
|
76
|
+
# - test unsat
|
|
77
|
+
# - test possible_seeds (subset of seed that maximize number of producible targets)
|
|
78
|
+
# - test changing objective
|
|
79
|
+
|
|
80
|
+
# solve values: 'reasoning', 'filter', 'guess_check', 'guess_check_div', 'hybrid'
|
|
81
|
+
# optim values: 'submin', 'min'
|
|
82
|
+
|
|
83
|
+
# ----------- SUBSETMIN -----------
|
|
84
|
+
def test_reasoning_submin():
|
|
85
|
+
solve="reasoning"
|
|
86
|
+
optim="submin"
|
|
87
|
+
list_solution=search_seed(INFILE, RUN_MODE, solve, optim)
|
|
88
|
+
for solution in list_solution:
|
|
89
|
+
assert set(solution) in SEEDS_REASONING
|
|
90
|
+
assert len(list_solution) == SIZE_REASONING
|
|
91
|
+
|
|
92
|
+
def test_filter_submin():
|
|
93
|
+
solve="filter"
|
|
94
|
+
optim="submin"
|
|
95
|
+
list_solution=search_seed(INFILE, RUN_MODE, solve, optim)
|
|
96
|
+
for solution in list_solution:
|
|
97
|
+
assert set(solution) in SEEDS_HYB_COBRA
|
|
98
|
+
assert len(list_solution) == SIZE_HYB_COBRA
|
|
99
|
+
|
|
100
|
+
def test_gc_submin():
|
|
101
|
+
solve="guess_check"
|
|
102
|
+
optim="submin"
|
|
103
|
+
list_solution=search_seed(INFILE, RUN_MODE, solve, optim)
|
|
104
|
+
for solution in list_solution:
|
|
105
|
+
assert set(solution) in SEEDS_HYB_COBRA
|
|
106
|
+
assert len(list_solution) == SIZE_HYB_COBRA
|
|
107
|
+
|
|
108
|
+
def test_gcd_submin():
|
|
109
|
+
solve="guess_check_div"
|
|
110
|
+
optim="submin"
|
|
111
|
+
list_solution=search_seed(INFILE, RUN_MODE, solve, optim)
|
|
112
|
+
for solution in list_solution:
|
|
113
|
+
assert set(solution) in SEEDS_HYB_COBRA
|
|
114
|
+
assert len(list_solution) == SIZE_HYB_COBRA
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def test_hybrid_submin():
|
|
118
|
+
solve="hybrid"
|
|
119
|
+
optim="submin"
|
|
120
|
+
list_solution=search_seed(INFILE, RUN_MODE, solve, optim)
|
|
121
|
+
for solution in list_solution:
|
|
122
|
+
assert set(solution) in SEEDS_SUBMIN_HYBRID
|
|
123
|
+
assert len(list_solution) == SIZE_SUBMIN_HYBRID
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
# ----------- MINIMIZE -----------
|
|
127
|
+
def test_reasoning_min():
|
|
128
|
+
solve="reasoning"
|
|
129
|
+
optim="min"
|
|
130
|
+
list_solution=search_seed(INFILE, RUN_MODE, solve, optim)
|
|
131
|
+
for solution in list_solution:
|
|
132
|
+
assert set(solution) in SEEDS_REASONING
|
|
133
|
+
assert len(list_solution) == SIZE_REASONING
|
|
134
|
+
|
|
135
|
+
def test_filter_min():
|
|
136
|
+
solve="filter"
|
|
137
|
+
optim="min"
|
|
138
|
+
list_solution=search_seed(INFILE, RUN_MODE, solve, optim)
|
|
139
|
+
for solution in list_solution:
|
|
140
|
+
assert set(solution) in SEEDS_HYB_COBRA
|
|
141
|
+
assert len(list_solution) == SIZE_HYB_COBRA
|
|
142
|
+
|
|
143
|
+
def test_gc_min():
|
|
144
|
+
solve="guess_check"
|
|
145
|
+
optim="min"
|
|
146
|
+
list_solution=search_seed(INFILE, RUN_MODE, solve, optim)
|
|
147
|
+
for solution in list_solution:
|
|
148
|
+
assert set(solution) in SEEDS_HYB_COBRA
|
|
149
|
+
assert len(list_solution) == SIZE_HYB_COBRA
|
|
150
|
+
|
|
151
|
+
def test_gcd_min():
|
|
152
|
+
solve="guess_check_div"
|
|
153
|
+
optim="min"
|
|
154
|
+
list_solution=search_seed(INFILE, RUN_MODE, solve, optim)
|
|
155
|
+
for solution in list_solution:
|
|
156
|
+
assert set(solution) in SEEDS_HYB_COBRA
|
|
157
|
+
assert len(list_solution) == SIZE_HYB_COBRA
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def test_hybrid_min():
|
|
161
|
+
solve="hybrid"
|
|
162
|
+
optim="min"
|
|
163
|
+
list_solution=search_seed(INFILE, RUN_MODE, solve, optim)
|
|
164
|
+
for solution in list_solution:
|
|
165
|
+
assert set(solution) in SEEDS_MIN_HYBRID
|
|
166
|
+
assert len(list_solution) == SIZE_MIN_HYBRID
|
tests/normalization.py
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
Description:
|
|
6
|
+
Test seed2lp
|
|
7
|
+
"""
|
|
8
|
+
from os import path
|
|
9
|
+
from .utils import get_network
|
|
10
|
+
import re
|
|
11
|
+
|
|
12
|
+
##### ###### ##### DIRECTORIES AND FILES ###################
|
|
13
|
+
TEST_DIR = path.dirname(path.abspath(__file__))
|
|
14
|
+
|
|
15
|
+
# All reaction are not reversible
|
|
16
|
+
# except import/export reaction for exchange metabolite S1, S2 C and G
|
|
17
|
+
INFILE = path.join(TEST_DIR,'network/sbml/toy_paper.sbml')
|
|
18
|
+
########################################################
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
################### FIXED VARIABLES ####################
|
|
22
|
+
|
|
23
|
+
########################################################
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
################# EXPECTED SOLUTIONS ###################
|
|
28
|
+
EXCH = {"R_EX_S1", "R_EX_S2", "R_EX_C", "R_EX_G"}
|
|
29
|
+
|
|
30
|
+
DEL = {"R_R2"}
|
|
31
|
+
|
|
32
|
+
# For exchange reaction when import reaction deleted
|
|
33
|
+
# The deletion is on ASP facts with atom reaction and bounds prefixed with "rm_"
|
|
34
|
+
# and product or reactant prefixed with "rm_"
|
|
35
|
+
REV = {'R_BIOMASS', 'R_EX_S1', 'R_EX_S2', 'R_EX_C', 'R_EX_G'}
|
|
36
|
+
|
|
37
|
+
META_EXCH = {"R_R7"}
|
|
38
|
+
|
|
39
|
+
FORBID_TAF = {"M_F_c"}
|
|
40
|
+
|
|
41
|
+
RM_RXN = ['rm_reaction("rev_R_EX_S1").',
|
|
42
|
+
'rm_reaction("rev_R_EX_S2").',
|
|
43
|
+
'rm_reaction("rev_R_EX_C").',
|
|
44
|
+
'rm_reaction("rev_R_EX_G").',
|
|
45
|
+
'rm_bounds("rev_R_EX_S1","0.0000000000","1000.0000000000").',
|
|
46
|
+
'rm_bounds("rev_R_EX_S2","0.0000000000","1000.0000000000").',
|
|
47
|
+
'rm_bounds("rev_R_EX_C","0.0000000000","1000.0000000000").',
|
|
48
|
+
'rm_bounds("rev_R_EX_G","0.0000000000","1000.0000000000").',
|
|
49
|
+
'rm_product("M_S1_e","1.0000000000","rev_R_EX_S1","exchange","M_S1_e","toy_paper").',
|
|
50
|
+
'rm_product("M_S2_e","1.0000000000","rev_R_EX_S2","exchange","M_S2_e","toy_paper").',
|
|
51
|
+
'rm_product("M_C_c","1.0000000000","rev_R_EX_C","exchange","M_C_c","toy_paper").',
|
|
52
|
+
'rm_product("M_G_c","1.0000000000","rev_R_EX_G","exchange","M_G_c","toy_paper").'
|
|
53
|
+
]
|
|
54
|
+
SIZE_RM_RXN=len(RM_RXN)
|
|
55
|
+
|
|
56
|
+
SEED_TI = ['seed("M_S1_e","exchange","M_S1_e").',
|
|
57
|
+
'seed("M_S2_e","exchange","M_S2_e").',
|
|
58
|
+
'seed("M_C_c","exchange","M_C_c").',
|
|
59
|
+
'seed("M_G_c","exchange","M_G_c").'
|
|
60
|
+
]
|
|
61
|
+
SIZE_SEED_TI=len(SEED_TI)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
MATCH_RM = 'rm_'
|
|
65
|
+
MATCH_SEED = 'seed\('
|
|
66
|
+
|
|
67
|
+
########################################################
|
|
68
|
+
|
|
69
|
+
def test_exchange():
|
|
70
|
+
run_mode = "full"
|
|
71
|
+
targets_as_seeds = False
|
|
72
|
+
topological_injection = False
|
|
73
|
+
keep_import_reactions = False
|
|
74
|
+
|
|
75
|
+
network = get_network(INFILE, run_mode, targets_as_seeds,
|
|
76
|
+
topological_injection, keep_import_reactions)
|
|
77
|
+
assert set(network.exchanged_reactions) == EXCH
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def test_delete():
|
|
81
|
+
run_mode = "full"
|
|
82
|
+
targets_as_seeds = False
|
|
83
|
+
topological_injection = False
|
|
84
|
+
keep_import_reactions = False
|
|
85
|
+
|
|
86
|
+
network = get_network(INFILE, run_mode, targets_as_seeds,
|
|
87
|
+
topological_injection, keep_import_reactions)
|
|
88
|
+
assert set(network.deleted_reactions) == DEL
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def test_rev_modified():
|
|
92
|
+
run_mode = "full"
|
|
93
|
+
targets_as_seeds = False
|
|
94
|
+
topological_injection = False
|
|
95
|
+
keep_import_reactions = False
|
|
96
|
+
|
|
97
|
+
network = get_network(INFILE, run_mode, targets_as_seeds,
|
|
98
|
+
topological_injection, keep_import_reactions)
|
|
99
|
+
assert set(network.reversible_modified_reactions.keys()) == REV
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
# import reaction removed, prefixed by "rm_" on atom
|
|
103
|
+
# reaction reaction and bounds
|
|
104
|
+
# and
|
|
105
|
+
def test_rm_rxn():
|
|
106
|
+
run_mode = "full"
|
|
107
|
+
targets_as_seeds = False
|
|
108
|
+
topological_injection = False
|
|
109
|
+
keep_import_reactions = False
|
|
110
|
+
|
|
111
|
+
network = get_network(INFILE, run_mode, targets_as_seeds,
|
|
112
|
+
topological_injection, keep_import_reactions)
|
|
113
|
+
network.convert_to_facts()
|
|
114
|
+
|
|
115
|
+
rm_list_found=re.findall(MATCH_RM, network.facts)
|
|
116
|
+
size_rm_found=len(rm_list_found)
|
|
117
|
+
assert size_rm_found == SIZE_RM_RXN
|
|
118
|
+
|
|
119
|
+
seed_list_found=re.findall(MATCH_SEED, network.facts)
|
|
120
|
+
size_seed_found=len(seed_list_found)
|
|
121
|
+
assert size_seed_found == 0
|
|
122
|
+
|
|
123
|
+
for rm in RM_RXN:
|
|
124
|
+
assert rm in network.facts
|
|
125
|
+
|
|
126
|
+
# import reaction kept, no prefix on atom reaction
|
|
127
|
+
def test_kir():
|
|
128
|
+
run_mode = "full"
|
|
129
|
+
targets_as_seeds = False
|
|
130
|
+
topological_injection = False
|
|
131
|
+
keep_import_reactions = True
|
|
132
|
+
|
|
133
|
+
network = get_network(INFILE, run_mode, targets_as_seeds,
|
|
134
|
+
topological_injection, keep_import_reactions)
|
|
135
|
+
network.convert_to_facts()
|
|
136
|
+
|
|
137
|
+
rm_list_found=re.findall(MATCH_RM, network.facts)
|
|
138
|
+
size_rm_found=len(rm_list_found)
|
|
139
|
+
assert size_rm_found == 0
|
|
140
|
+
|
|
141
|
+
seed_list_found=re.findall(MATCH_SEED, network.facts)
|
|
142
|
+
size_seed_found=len(seed_list_found)
|
|
143
|
+
assert size_seed_found == 0
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
# import reaction kept, no prefix on atom reaction
|
|
147
|
+
# atom seed added product or reactant (dependeing way it is written on sbml)
|
|
148
|
+
def test_ti():
|
|
149
|
+
run_mode = "full"
|
|
150
|
+
targets_as_seeds = False
|
|
151
|
+
topological_injection = True
|
|
152
|
+
keep_import_reactions = True
|
|
153
|
+
|
|
154
|
+
network = get_network(INFILE, run_mode, targets_as_seeds,
|
|
155
|
+
topological_injection, keep_import_reactions)
|
|
156
|
+
network.convert_to_facts()
|
|
157
|
+
|
|
158
|
+
rm_list_found=re.findall(MATCH_RM, network.facts)
|
|
159
|
+
size_rm_found=len(rm_list_found)
|
|
160
|
+
assert size_rm_found == 0
|
|
161
|
+
|
|
162
|
+
seed_list_found=re.findall(MATCH_SEED, network.facts)
|
|
163
|
+
size_seed_found=len(seed_list_found)
|
|
164
|
+
assert size_seed_found == SIZE_SEED_TI
|
|
165
|
+
for seed in SEED_TI:
|
|
166
|
+
assert seed in network.facts
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def test_taf():
|
|
171
|
+
run_mode = "target"
|
|
172
|
+
targets_as_seeds = False
|
|
173
|
+
topological_injection = False
|
|
174
|
+
keep_import_reactions = False
|
|
175
|
+
network = get_network(INFILE, run_mode, targets_as_seeds,
|
|
176
|
+
topological_injection, keep_import_reactions)
|
|
177
|
+
assert set(network.forbidden_seeds) == FORBID_TAF
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def test_tas():
|
|
181
|
+
run_mode = "target"
|
|
182
|
+
targets_as_seeds = True
|
|
183
|
+
topological_injection = False
|
|
184
|
+
keep_import_reactions = False
|
|
185
|
+
network = get_network(INFILE, run_mode, targets_as_seeds,
|
|
186
|
+
topological_injection, keep_import_reactions)
|
|
187
|
+
# check if list is empty
|
|
188
|
+
assert not network.forbidden_seeds
|