Skip to content

Commit

Permalink
TrimGdel folder is added to ~/src/design/
Browse files Browse the repository at this point in the history
  • Loading branch information
MetNetComp committed Feb 10, 2025
1 parent 0216fec commit cbfa3f1
Show file tree
Hide file tree
Showing 18 changed files with 1,090 additions and 0 deletions.
90 changes: 90 additions & 0 deletions src/design/TrimGdel/GRPRchecker.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
function [GR ,PR] = GRPRchecker(model, targetMet, givenGvalue)
% GRPRchecker calculates the maximum GR and the minimu PR
% under the GR maximization when a constraint-based model, a target
% metabolite, and a gene deletion stratety are given.
%
% function [GR, PR]
% = GRPRchecker(model, targetMet, givenGvalue)
%
% INPUTS
% model COBRA model structure containing the following required fields to perform gDel_minRN.
% rxns Rxns in the model
% mets Metabolites in the model
% genes Genes in the model
% grRules Gene-protein-reaction relations in the model
% S Stoichiometric matrix (sparse)
% b RHS of Sv = b (usually zeros)
% c Objective coefficients
% lb Lower bounds for fluxes
% ub Upper bounds for fluxes
% rev Reversibility of fluxes
%
% targetMet target metabolites
% (e.g., 'btn_c')
% givenGvalue The first column is the list of genes in the original model.
% The second column contains a 0/1 vector indicating which genes should be deleted.
% 0 indicates genes to be deleted.
% 1 indecates genes to be remained.
%
% OUTPUTS
% GR the growth rate obained when the gene deletion strategy is
% applied and the growth rate is maximized.
% PR the minimum target metabolite production rate obained
% when the gene deletion strategy is applied and the growth rate is maximized.
%
% Feb. 10, 2025 Takeyuki TAMURA
%


[model, targetRID, extype] = modelSetting(model, targetMet);

m = size(model.mets, 1);
n = size(model.rxns, 1);
g = size(model.genes, 1);
gid = find(model.c);
pid = targetRID;


model2 = model;
[grRules0] = calculateGR(model, givenGvalue);
lb2 = model.lb;
ub2 = model.ub;

for i=1:n
if grRules0{i, 4} == 0
lb2(i) = 0;
ub2(i) = 0;
end
end

gm.A = sparse(model.S);
gm.obj = -model.c;
gm.modelsense = 'Min';
gm.sense = repmat('=', 1, size(model.S, 1));
gm.lb = lb2;
gm.ub = ub2;
opt0 = gurobi(gm);

[opt0.x(gid) opt0.x(pid)]

GR0 = -opt0.objval;
lb2(gid) = GR0;
ub2(gid) = GR0;
model2.c(gid) = 0;
model2.c(pid) = 1;

gm2.A = sparse(model.S);
gm2.obj = model2.c;
gm2.modelsense = 'Min';
gm2.sense = repmat('=', 1, size(model.S, 1));
gm2.lb = lb2;
gm2.ub = ub2;
opt1 = gurobi(gm2);

GR = GR0
PR = opt1.x(pid)
[GR PR]

return;
end

Binary file added src/design/TrimGdel/README.pdf
Binary file not shown.
86 changes: 86 additions & 0 deletions src/design/TrimGdel/TrimGdel.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
function [gvalue, GR, PR, size1, size2, size3, success] = TrimGdel(model, targetMet, maxLoop, PRLB, GRLB)
%
% TrimGdel appropriately considers GPR rules and determines
% a minimal gene deletion strategies to achieve growth-coupled production
% for a given target metabolite and a genome-scale model.
% even in the worst-case analysis (ensures the weak-growth-coupled production).
%
% Gurobi is required for this version.
% The CPLEX version is available on https://github.com/MetNetComp/TrimGdel
%
% function [gvalue, GR, PR, size1, size2, size3, success]
% = TrimGdel(model, targetMet, maxLoop, PRLB, GRLB)
%
% INPUTS
% model COBRA model structure containing the following required fields to perform gDel_minRN.
% rxns Rxns in the model
% mets Metabolites in the model
% genes Genes in the model
% grRules Gene-protein-reaction relations in the model
% S Stoichiometric matrix (sparse)
% b RHS of Sv = b (usually zeros)
% c Objective coefficients
% lb Lower bounds for fluxes
% ub Upper bounds for fluxes
% rev Reversibility of fluxes
%
% targetMet target metabolites
% (e.g., 'btn_c')
% maxLoop the maximum number of iterations in gDel_minRN
% PRLB the minimum required production rates of the target metabolites
% when gDel-minRN searches the gene deletion
% strategy candidates.
% (But it is not ensured to achieve this minimum required value
% when GR is maximized withoug PRLB.)
% GRLB the minimum required growth rate
% when gDel-minRN searches the gene deletion
% strategy candidates.
%
% OUTPUTS
% gvalue a small gene deletion strategy (obtained by TrimGdel).
% The first column is the list of genes.
% The second column is a 0/1 vector indicating which genes should be deleted.
% 0 indicates genes to be deleted.
% 1 indecates genes to be remained.
% GR the maximum growth rate when the obtained gene deletion
% strategy represented by gvalue is applied.
% PR the minimum production rate of the target metabolite under
% the maximization of the growth rate when the obtained gene deletion
% strategy represented by gvalue is applied.
% size1 the number of gene deletions after Step1.
% size2 the number of gene deletions after Step2.
% size3 the number of gene deletions after Step3.
% success indicates whether TrimGdel obained an appropriate gene
% deletion strategy. (1:success, 0:failure)
%
% T. Tamura, "Trimming Gene Deletion Strategies for Growth-Coupled
% Production in Constraint-Based Metabolic Networks: TrimGdel,"
% in IEEE/ACM Transactions on Computational Biology and Bioinformatics,
% vol. 20, no. 2, pp. 1540-1549, 2023.
%
% Comprehensive computational results are accumulated in MetNetComp
% database.
% https://metnetcomp.github.io/database1/indexFiles/index.html
%
% T. Tamura, "MetNetComp: Database for Minimal and Maximal Gene-Deletion Strategies
% for Growth-Coupled Production of Genome-Scale Metabolic Networks,"
% in IEEE/ACM Transactions on Computational Biology and Bioinformatics,
% vol. 20, no. 6, pp. 3748-3758, 2023,
%
% Feb. 6, 2025 Takeyuki TAMURA
%

[gvalue gr pr it success] = gDel_minRN(model, targetMet, maxLoop, PRLB, GRLB) % Step 1
if success
[gvalue, GR, PR, size1, size2, size3] = step2and3(model, targetMet, gvalue) % Step 2 and 3
else
gvalue = [];
GR = 0;
PR = 0;
size1 = 0;
size2 = 0;
size3 = 0;
end

end

36 changes: 36 additions & 0 deletions src/design/TrimGdel/calculateGR.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
function [grRules] = calculateGR(model, xname)

grRules = cell(size(model.rxns));
for i=1:size(model.grRules, 1)
grRules{i, 1} = model.grRules{i,1};
end
for i = 1:size(model.rxns, 1)
if isempty(grRules{i, 1})==1
grRules{i,1} = '1';
end
end
grRules(:, 2) = strrep(grRules, 'or', '+');
grRules(:,2) = strrep(grRules(:,2), 'and', '*');

[xname2, index] = sortrows(xname(:,1), 'descend');
for i=1:size(index, 1)
sorted_gvalue(i, 1) = xname{index(i, 1), 2};
end
for i = 1:size(model.genes, 1)
grRules(:, 2) = strrep(grRules(:, 2), xname2{i, 1},num2str(sorted_gvalue(i, 1)));
end
for i = 1:size(grRules, 1)
%i
if isempty(grRules{i, 2}) == 0
grRules{i, 3} = eval(grRules{i, 2});
if grRules{i, 3} > 0.9
grRules{i, 4} = 1;
else
grRules{i, 4} = 0;
end
else
grRules{i, 4} = -1;
end
end
end

Binary file added src/design/TrimGdel/e_coli_core.mat
Binary file not shown.
14 changes: 14 additions & 0 deletions src/design/TrimGdel/example1.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function [outputArg1, outputArg2] = example1()
% example1 calculates the gene deletion strategy for growth coupling
% for succinate in e_coli_core.
%
% Feb. 6, 2025 Takeyuki TAMURA
%

load('e_coli_core.mat');
model = e_coli_core;

[gvalue, GR, PR, size1, size2, size3, success] = TrimGdel(model, 'succ_e', 10, 0.1, 0.1)

end

13 changes: 13 additions & 0 deletions src/design/TrimGdel/example2.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function [outputArg1, outputArg2] = example2()
% example2 calculates the gene deletion strategy for growth coupling
% for biotin in iML1515.
%
% Feb. 6, 2025 Takeyuki TAMURA
%

load('iML1515.mat');
model = iML1515;
[gvalue, GR, PR, size1, size2, size3, success] = TrimGdel(model, 'btn_c', 10, 0.1, 0.1)

end

14 changes: 14 additions & 0 deletions src/design/TrimGdel/example3.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function [outputArg1, outputArg2] = example3()
% example3 calculates the gene deletion strategy for growth coupling
% for riboflavin in iML1515.
%
% Feb. 6, 2025 Takeyuki TAMURA
%

load('iML1515.mat');
model = iML1515;

[gvalue, GR, PR, size1, size2, size3, success] = TrimGdel(model, 'ribflv_c', 10, 0.1, 0.1)

end

14 changes: 14 additions & 0 deletions src/design/TrimGdel/example4.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function [outputArg1, outputArg2] = exampl4()
% example4 calculates the gene deletion strategy for growth coupling
% for pantothenate in iML1515.
%
% Feb. 6, 2025 Takeyuki TAMURA
%

load('iML1515.mat');
model = iML1515;

[gvalue, GR, PR, size1, size2, size3, success] = TrimGdel(model, 'pnto__R_c', 10, 0.1, 0.1)

end

14 changes: 14 additions & 0 deletions src/design/TrimGdel/example5.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function [outputArg1, outputArg2] = example5()
% example5 calculates the gene deletion strategy for growth coupling
% for succinate in iMM904.
%
% Feb. 6, 2025 Takeyuki TAMURA
%

load('iMM904.mat');
model = iMM904;

[gvalue, GR, PR, size1, size2, size3, success] = TrimGdel(model, 'succ_e', 10, 0.1, 0.1)

end

Loading

0 comments on commit cbfa3f1

Please sign in to comment.