findRootNPmets Find the root no production (and no consumption) metabolites in a model, used by gapFind gaps = findRootNPmets(model,findNCmets) INPUT model a COBRA model OPTIONAL INPUT findNCmets find no consumption mets as well as no production (default false) OUTPUT gaps all root no production metabolites Jeff Orth 7/15/09
0001 function gaps = findRootNPmets(model,findNCmets) 0002 %findRootNPmets Find the root no production (and no consumption) 0003 %metabolites in a model, used by gapFind 0004 % 0005 % gaps = findRootNPmets(model,findNCmets) 0006 % 0007 %INPUT 0008 % model a COBRA model 0009 % 0010 %OPTIONAL INPUT 0011 % findNCmets find no consumption mets as well as no production (default 0012 % false) 0013 % 0014 %OUTPUT 0015 % gaps all root no production metabolites 0016 % 0017 % Jeff Orth 7/15/09 0018 0019 if nargin < 2 0020 findNCmets = false; 0021 end 0022 0023 isRootNPmet = zeros(length(model.mets),1); 0024 0025 for i = 1:length(model.mets) 0026 row = find(model.S(i,:)); %which rxns this met participates in 0027 rowR = ismember(row,find(model.rev)); %reversible rxns 0028 if any(model.S(i,row) > 0) %if met is produced by any reaction 0029 %don't do anything 0030 elseif any(rowR) %if met is in any reverible rxns 0031 %don't do anything 0032 else 0033 isRootNPmet(i) = 1; 0034 end 0035 end 0036 0037 if findNCmets 0038 0039 isRootNCmet = zeros(length(model.mets),1); 0040 0041 for i = 1:length(model.mets) 0042 row = find(model.S(i,:)); %which rxns this met participates in 0043 rowR = ismember(row,find(model.rev)); %reversible rxns 0044 if any(model.S(i,row) < 0) %if met is consumed by any reaction 0045 %don't do anything 0046 elseif any(rowR) %if met is in any reverible rxns 0047 %don't do anything 0048 else 0049 isRootNCmet(i) = 1; 0050 end 0051 end 0052 end 0053 0054 if findNCmets 0055 gaps = model.mets((isRootNPmet+isRootNCmet)>=1); 0056 else 0057 gaps = model.mets(isRootNPmet==1); 0058 end 0059 0060 0061 0062