forked from opencobra/cobratoolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
findExcRxns.m
72 lines (62 loc) · 1.97 KB
/
findExcRxns.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
function [selExc,selUpt] = findExcRxns(model,inclObjFlag,irrevFlag)
%findExcRxns Find exchange and uptake rxns
%
% [selExc,selUpt] = findExcRxns(model,inclObjFlag,irrevFlag)
%
%INPUT
% model COBRA model structure
%
%OPTIONAL INPUTS
% inclObjFlag Include objective rxns in the exchange rxn set (1) or not (0)
% (Default = false)
% irrevFlag Model is in irreversible format (1) or not
% (Default = false)
%
%OUTPUTS
% selExc Boolean vector indicating whether each reaction in
% model is exchange or not
% selUpt Boolean vector indicating whether each reaction in
% model is nutrient uptake or not
%
% Exchange reactions only have one non-zero (+1/-1) element in the
% corresponding column of the stoichiometric matrix. Uptake reactions are
% exchange reactions are exchange reactions with negative lower bounds.
%
% 10/14/05 Markus Herrgard
if (nargin < 2)
inclObjFlag = false;
end
if (nargin < 3)
irrevFlag = false;
end
if (~irrevFlag)
% Find exchange rxns
selExc = full((sum(model.S==-1,1) ==1) & (sum(model.S~=0) == 1))' | full((sum(model.S==1,1) ==1) & (sum(model.S~=0) == 1))';
if (isfield(model,'c'))
% Remove obj rxns
if (~inclObjFlag)
selExc(model.c ~= 0) = false;
else
selExc(model.c ~= 0) = true;
end
end
if (isfield(model,'lb'))
% Find uptake rxns
selUpt = full(model.lb < 0 & selExc);
else
selUpt = [];
end
else
% Find exchange rxns
selExc = full((sum(abs(model.S)==1,1) ==1) & (sum(model.S~=0) == 1))';
if (isfield(model,'c'))
% Remove obj rxns
if (~inclObjFlag)
selExc(model.c ~= 0) = false;
else
selExc(model.c ~= 0) = true;
end
end
% Find uptake rxns
selUpt = full((sum(model.S==1,1) ==1) & (sum(model.S~=0) == 1))';
end