forked from EPFL-LCSB/redgem
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextract_drains.m
More file actions
35 lines (32 loc) · 816 Bytes
/
extract_drains.m
File metadata and controls
35 lines (32 loc) · 816 Bytes
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
function [drains,drain_mets]=extract_drains(model,drains_medium)
if nargin<2
drains_medium={};
end
drain_mets={};
drains={};
for i=1:length(model.rxns)
no_of_mets=length(find(model.S(:, i)));
if no_of_mets==1
drains=[drains; model.rxns(i)];
sto=model.S(:, i);
drain_mets=[drain_mets; model.mets(find(sto))];
sto=sto(find(sto));
if sto==1
model.S(:, i)=-model.S(:, i);
ub=model.ub(i);
lb=model.lb(i);
model.ub(i)=-lb;
model.lb(i)=-ub;
end
end
end
if ~isempty(drains_medium)
drains_aux=drains;
drains={};
for i=1:length(drains_aux)
if ismember(drains_aux(i),drains_medium)
drains=[drains;drains_aux(i)];
end
end
end
end