-
Notifications
You must be signed in to change notification settings - Fork 12
/
optram.py
74 lines (59 loc) · 2.58 KB
/
optram.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Copyright (C) 2019- Centre of Biological Engineering,
# University of Minho, Portugal
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
Author: Vitor Pereira
"""
import os
from time import time
from mewpy.optimization import EA
from mewpy.optimization.evaluation import BPCY, WYIELD
from mewpy.problems.optram import OptRamProblem, load_optram
from mewpy.simulation import SimulationMethod
def test():
""" An example on to use OptRAM optimization problems to find
regulatory modification for the increased production of tryptophan.
"""
dir_path = os.path.dirname(os.path.realpath(__file__))
PATH = os.path.join(dir_path, '../../../examples/models/optram/')
gene_file = os.path.join(PATH, 'mgene.csv')
ft_file = os.path.join(PATH, 'TFnames.csv')
matrix_file = os.path.join(PATH, 'regnet.csv')
model_file = os.path.join(PATH, 'yeast_7.6-optram.xml')
BIOMASS_ID = 'r_2111'
PRODUCT_ID = 'r_1912'
GLC = 'r_1714'
envcond = {GLC: (-10, 0)}
# adds the prefix 'G_' to genes. Only for REFRAMED models
regnet = load_optram(gene_file, ft_file, matrix_file, gene_prefix='G_')
# the general objective is to maximize the target
from reframed.io.sbml import load_cbmodel
model = load_cbmodel(model_file)
model.set_objective({BIOMASS_ID: 1})
evaluator_1 = BPCY(BIOMASS_ID, PRODUCT_ID, method=SimulationMethod.lMOMA)
evaluator_2 = WYIELD(BIOMASS_ID, PRODUCT_ID, parsimonious=True)
# OptRAM problem
problem = OptRamProblem(model, [evaluator_1, evaluator_2],
regnet, envcond=envcond, candidate_min_size=10, candidate_max_size=30)
print('Target List:', problem.target_list)
print("\n\n")
print('Metabolic Genes', problem.simulator.genes)
print("\n\n")
ea = EA(problem, max_generations=3, mp=True)
ea.run()
millis = int(round(time() * 1000))
filename = "OPTRAM{}_OU_{}.csv".format('TRP', millis)
df = ea.dataframe()
df.to_csv(filename)
if __name__ == "__main__":
for _ in range(1):
test()