-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgenes_redGEM.m
40 lines (29 loc) · 1.14 KB
/
genes_redGEM.m
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
% OBTAIN GENES FROM ORIGINAL MODEL
function model = genes_redGEM(model,gem)
if nargin<2
gem = model.OriginalGEM;
end
model.lb(find(model.c)) = 0;
% model.var_lb(find(model.f)+1) = 0;
[~,ind_rxns] = ismember(model.rxns, gem.rxns);
ind_rxns = ind_rxns(find(ind_rxns)); % because of the lumps
rxnGeneMatrix = gem.rxnGeneMat(ind_rxns,:);
ind_genes = find(sum(rxnGeneMatrix,1));
model.rxnGeneMat = rxnGeneMatrix(:,ind_genes);
model.genes = gem.genes(ind_genes);
model.rules = gem.rules(ind_rxns);
model.grRules = gem.grRules(ind_rxns);
rules = model.rules;
for i = 1:length(ind_genes)
rules = strrep(rules,['(',num2str(ind_genes(i)),')'],['(_',num2str(ind_genes(i)),'_)']);
end
for i = 1:length(ind_genes)
rules = strrep(rules,['(_',num2str(ind_genes(i)),'_)'],['(',num2str(i),')']);
end
model.rules = rules;
% include the lumps (zeros everywhere)
ind_lumps = find(contains(model.rxns,'LMPD_'));
model.rules(ind_lumps) = {''};
model.grRules(ind_lumps) = {''};
model.rxnGeneMat(ind_lumps,:) = zeros(length(ind_lumps),length(model.genes));
end