0001 function model = keepCompartment(model, compartments)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 compartments = regexprep(compartments, '\[','\\\[');
0020 compartments = regexprep(compartments, '\]','\\\]');
0021
0022 mets2keep = zeros(size(model.mets));
0023 for i=1:max(size(compartments))
0024 a(:,i)=regexpi(model.mets,compartments{i});
0025 for j=1:max(size(a(:,i)))
0026 if not(isempty(a{j,i}))
0027 mets2keep(j,1)=1;
0028 end
0029 end
0030 end
0031
0032 k=1;rxns2remove={};
0033 for j=max(size(model.rxns)):-1:1
0034 for i=max(size(mets2keep)):-1:1
0035 if model.S(i,j) ~= 0 && mets2keep(i) == 0
0036 rxns2remove{k}=model.rxns{j};k=k+1;
0037 ID = findRxnIDs(model,model.rxns{j});
0038 printRxnFormula(model,model.rxns{j});
0039 hi=1;
0040 end
0041 end
0042 end
0043
0044 hi = 1;
0045 if ~isempty(rxns2remove)
0046 for i=1:max(size(rxns2remove))
0047 model = removeRxns(model,rxns2remove{i});
0048 end
0049 else display('No Compartments Removed')
0050 end
0051 end