forked from SysBioChalmers/RAVEN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getAllowedBounds.m
executable file
·55 lines (50 loc) · 1.55 KB
/
getAllowedBounds.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
function [minFluxes, maxFluxes, exitFlags]=getAllowedBounds(model,rxns)
% getAllowedBounds
% Returns the minimal and maximal fluxes through each reaction.
%
% model a model structure
% rxns either a cell array of reaction IDs, a logical vector with the
% same number of elements as reactions in the model, or a vector
% of reaction indexes (opt, default model.rxns)
%
% minFluxes minimal allowed fluxes
% maxFluxes maximal allowed fluxes
% exitFlags exit flags for min/max for each of the reactions. True if
% it was possible to calculate a flux
%
% NOTE: In cases where no solution can be calculated, NaN is returned.
%
% Usage: [minFluxes, maxFluxes, exitFlags]=getAllowedBounds(model,rxns)
if nargin<2
rxns=1:numel(model.rxns);
else
rxns=getIndexes(model,rxns, 'rxns');
end
minFluxes=zeros(numel(rxns),1);
maxFluxes=zeros(numel(rxns),1);
exitFlags=zeros(numel(rxns),2);
c=zeros(numel(model.rxns),1);
hsSolMin=[];
hsSolMax=[];
for i=1:numel(rxns)
model.c=c;
%Get minimal flux
model.c(rxns(i))=-1;
[solution, hsSolMin]=solveLP(model,0,[],hsSolMin);
exitFlags(i,1)=solution.stat;
if ~isempty(solution.f)
minFluxes(i)=solution.x(rxns(i));
else
minFluxes(i)=NaN;
end
%Get maximal flux
model.c(rxns(i))=1;
[solution, hsSolMax]=solveLP(model,0,[],hsSolMax);
exitFlags(i,2)=solution.stat;
if ~isempty(solution.f)
maxFluxes(i)=solution.x(rxns(i));
else
maxFluxes(i)=NaN;
end
end
end