forked from opencobra/cobratoolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extractCompModel.m
51 lines (40 loc) · 1.24 KB
/
extractCompModel.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
function compModel = extractCompModel(model,compSymbol,intOnlyFlag)
%extractCompModel Create model for a cellular compartment
%
% compModel = extractCompModel(model,compSymbol,intOnlyFlag)
%
%INPUTS
% model COBRA model structure
% compSymbol Compartment symbol
%
%OPTIONAL INPUT
% intOnlyFlag Include only non-transport reactions (Default = true)
%
%OUTPUT
% compModel COBRA model for a cellular compartment
%
% Markus Herrgard 3/1/06
if (nargin < 3)
intOnlyFlag = true;
end
[baseMetNames,compSymbols] = parseMetNames(model.mets);
selMets = strcmp(compSymbols,compSymbol);
if (sum(selMets) == 0)
warning('Compartment symbol not found');
compModel = [];
return;
end
if (intOnlyFlag)
% Include only non-transport reactions
selRxns = (sum(model.S(selMets,:) ~= 0)' == sum(model.S ~= 0)') & any(model.S(selMets,:) ~= 0,1)';
rxnList = model.rxns(selRxns);
else
% Include transporters
selRxns = any(model.S(selMets,:) ~= 0,1)';
rxnList = model.rxns(selRxns);
end
% Extract subnetwork model
compModel = extractSubNetwork(model,rxnList);
if (isfield(compModel,'description'))
compModel.description = [compModel.description ' Compartment:' compSymbol'];
end