-
Notifications
You must be signed in to change notification settings - Fork 0
/
call_build_expanded_input_model.m
79 lines (70 loc) · 3.15 KB
/
call_build_expanded_input_model.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
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
75
76
77
78
79
function [Expanded_Input_model]=call_build_expanded_input_model(generic_input_reconstruction,number_of_cluster,run_toy_model)
% (c) Maria Pires Pacheco 2022 et al -University of Luxembourg
fields_to_keep={'S','rxns', 'mets', 'metFormulas','genes', 'rules', 'grRules', 'b', 'rxnGeneMat','c', 'lb', 'ub', 'rev', 'subSystems','metFormulas'};
[Expanded_Input_model]= build_expanded_input_model(generic_input_reconstruction, number_of_cluster,run_toy_model,fields_to_keep);
%% sanity check
[Expanded_Input_model]=fixIrr_rFASTCORMICS(Expanded_Input_model);
if ~isfield(Expanded_Input_model,'description')
Expanded_Input_model.description = {'Expanded model'}; % this line should be added into the model builder script
end
%% fix new Exchangers to be secretion only, TS 14.6.24
mmm=generic_input_reconstruction;
temp=findEX_Rxns(mmm,'biomass');
temp=find(ismember(mmm.rxns,temp));
selExc=temp;
tempM=nonzeros(mmm.S(:,temp));
selUpt=selExc((tempM.*mmm.ub(temp)>0) | (tempM.*mmm.lb(temp)>0));
temp2=selUpt;
% T=table(mmm.rxns(temp2),mmm.lb(temp2),mmm.ub(temp2),printRxnFormula(mmm,mmm.rxns(temp2)))
disp(' ')
disp(['Number of uptakes in generic_input_reconstruction: ' num2str(numel(temp2))])
prevUpt=mmm.rxns(temp2);
prevUpt=strrep(prevUpt,'EX_','Ex_');
mmm=Expanded_Input_model;
temp=findEX_Rxns(mmm,'biomass');
temp=find(ismember(mmm.rxns,temp));
selExc=temp;
tempM=nonzeros(mmm.S(:,temp));
selUpt=selExc((tempM.*mmm.ub(temp)>0) | (tempM.*mmm.lb(temp)>0));
temp2=selUpt;
% T=table(mmm.rxns(temp2),mmm.lb(temp2),mmm.ub(temp2),printRxnFormula(mmm,mmm.rxns(temp2)))
disp(['Number of uptakes in Expanded_Input_model: ' num2str(numel(temp2))])
expUpt=mmm.rxns(temp2);
newUpt=setdiff(expUpt,prevUpt);
disp(['Number of additional uptakes in Expanded_Input_model: ' num2str(numel(newUpt))])
lostUpt=setdiff(prevUpt,expUpt);
disp(['Number of lost uptakes in Expanded_Input_model: ' num2str(numel(lostUpt))])
disp('... fixing new exchangers ...')
for counter=1:numel(newUpt)
temp=find(ismember(mmm.rxns,newUpt(counter)));
if mmm.lb(temp)==0 & mmm.ub(temp)>0 & nonzeros(mmm.S(:,temp))>0
mmm.lb(temp)=-mmm.ub(temp);
mmm.ub(temp)=0;
end
% if mmm.lb(temp)<0 & mmm.ub(temp)==0 & nonzeros(mmm.S(:,temp))<0
% mmm.ub(temp)=-mmm.lb(temp);
% mmm.lb(temp)=0;
% end
end
% T=table(mmm.rxns(temp2),mmm.lb(temp2),mmm.ub(temp2),printRxnFormula(mmm,mmm.rxns(temp2)))
% adding lost uptakes back
disp('... adding lost uptakes back ...')
for counter=1:numel(lostUpt)
temp=find(ismember(mmm.rxns,lostUpt(counter)));
mmm.lb(temp)=-1000;
end
temp=findEX_Rxns(mmm,'biomass');
temp=find(ismember(mmm.rxns,temp));
selExc=temp;
tempM=nonzeros(mmm.S(:,temp));
selUpt=selExc((tempM.*mmm.ub(temp)>0) | (tempM.*mmm.lb(temp)>0));
temp2=selUpt;
% T=table(mmm.rxns(temp2),mmm.lb(temp2),mmm.ub(temp2),printRxnFormula(mmm,mmm.rxns(temp2)))
disp(['Number of uptakes in Expanded_Input_model: ' num2str(numel(temp2))])
expUpt=mmm.rxns(temp2);
newUpt=setdiff(expUpt,prevUpt);
disp(['Number of additional uptakes in Expanded_Input_model: ' num2str(numel(newUpt))])
lostUpt=setdiff(prevUpt,expUpt);
disp(['Number of lost uptakes in Expanded_Input_model: ' num2str(numel(lostUpt))])
Expanded_Input_model=mmm;
end