forked from opencobra/cobratoolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
removeDeadEnds.m
41 lines (32 loc) · 1008 Bytes
/
removeDeadEnds.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
function [model,removedMets,removedRxns] = removeDeadEnds(model)
%removeDeadEnds Remove all dead end metabolites and reactions from the
%model
%
% [model,removedMets,removedRxns] = removeDeadEnds(model)
%
%INPUT
% model COBRA model structure
%
%OUTPUTS
% model COBRA model structure w/o dead end metabolites and
% reactions
% removedMets List of removed metabolites
% removedRxns List of removed reactions
%
% Markus Herrgard 8/29/06
removedMets = {};
removedRxns = {};
while (1)
deadEnd = detectDeadEnds(model);
if (length(deadEnd) == 0)
break;
end
removedMets = union(removedMets,model.mets(deadEnd));
if (length(deadEnd) > 1)
deadRxns = model.rxns(find(sum(model.S(deadEnd,:) ~= 0) > 0));
else
deadRxns = model.rxns(find(model.S(deadEnd,:) ~= 0));
end
model = removeRxns(model,deadRxns);
removedRxns = union(removedRxns,deadRxns);
end