getExchangeRxns Retrieves the exchange reactions from a model. Exchange reactions are identified by having either no substrates or products. Input: model a model structure reactionType which exchange reactions should be returned 'all' all reactions, irrespective of reaction bounds 'uptake' reactions with bounds that imply that only uptake are allowed. Reaction direction, upper and lower bounds are all considered 'excrete' reactions with bounds that imply that only excretion are allowed. Reaction direction, upper and lower bounds are all considered 'reverse' reactions with non-zero upper and lower bounds that imply that both uptake and excretion are allowed 'blocked' reactions that have zero upper and lower bounds, not allowing any flux 'in' reactions where the boundary metabolite is the substrate of the reaction, a positive flux value would imply uptake, but reaction bounds are not considered 'out' reactions where the boundary metabolite is the substrate of the reaction, a positive flux value would imply uptake, but reaction bounds are not considered. Output: exchangeRxns cell array with the IDs of the exchange reactions exchangeRxnsIndexes vector with the indexes of the exchange reactions Note: The union of 'in' and 'out' equals 'all'. Also, the union of 'uptake', 'excrete', 'reverse' and 'blocked' equals all. Usage: [exchangeRxns,exchangeRxnsIndexes]=getExchangeRxns(model,reactionType)
0001 function [exchangeRxns, exchangeRxnsIndexes]=getExchangeRxns(model,reactionType) 0002 % getExchangeRxns 0003 % Retrieves the exchange reactions from a model. Exchange reactions are 0004 % identified by having either no substrates or products. 0005 % 0006 % Input: 0007 % model a model structure 0008 % reactionType which exchange reactions should be returned 0009 % 'all' all reactions, irrespective of reaction 0010 % bounds 0011 % 'uptake' reactions with bounds that imply that 0012 % only uptake are allowed. Reaction 0013 % direction, upper and lower bounds are 0014 % all considered 0015 % 'excrete' reactions with bounds that imply that 0016 % only excretion are allowed. Reaction 0017 % direction, upper and lower bounds are 0018 % all considered 0019 % 'reverse' reactions with non-zero upper and lower 0020 % bounds that imply that both uptake and 0021 % excretion are allowed 0022 % 'blocked' reactions that have zero upper and lower 0023 % bounds, not allowing any flux 0024 % 'in' reactions where the boundary metabolite 0025 % is the substrate of the reaction, a 0026 % positive flux value would imply uptake, 0027 % but reaction bounds are not considered 0028 % 'out' reactions where the boundary metabolite 0029 % is the substrate of the reaction, a 0030 % positive flux value would imply uptake, 0031 % but reaction bounds are not considered. 0032 % 0033 % Output: 0034 % exchangeRxns cell array with the IDs of the exchange reactions 0035 % exchangeRxnsIndexes vector with the indexes of the exchange reactions 0036 % 0037 % Note: 0038 % The union of 'in' and 'out' equals 'all'. Also, the union of 'uptake', 0039 % 'excrete', 'reverse' and 'blocked' equals all. 0040 % 0041 % Usage: [exchangeRxns,exchangeRxnsIndexes]=getExchangeRxns(model,reactionType) 0042 0043 if nargin<2 0044 reactionType='all'; 0045 else 0046 reactionType=char(reactionType); 0047 end 0048 0049 % Find exchange reactions 0050 if isfield(model, 'unconstrained') 0051 [~, I]=find(model.S(model.unconstrained~=0,:)>0); 0052 hasNoProd(I)=true; 0053 [~, I]=find(model.S(model.unconstrained~=0,:)<0); 0054 hasNoSubs(I)=true; 0055 else 0056 hasNoProd = transpose(find(sum(model.S>0)==0)); 0057 hasNoSubs = transpose(find(sum(model.S<0)==0)); 0058 end 0059 allExch = [hasNoProd; hasNoSubs]; 0060 0061 switch reactionType 0062 case {'both','all'} % For legacy reasons, 'both' is also allowed 0063 exchangeRxnsIndexes = allExch; 0064 case 'in' 0065 exchangeRxnsIndexes = hasNoSubs; 0066 case 'out' 0067 exchangeRxnsIndexes = hasNoProd; 0068 case 'blocked' 0069 exchangeRxnsIndexes = allExch(model.lb(allExch) == 0 & model.ub(allExch) == 0); 0070 case 'reverse' 0071 exchangeRxnsIndexes = allExch(model.lb(allExch) < 0 & model.ub(allExch) > 0); 0072 case 'uptake' 0073 0074 exchangeRxnsIndexes = allExch([(model.lb(hasNoProd) < 0 & model.ub(hasNoProd) <= 0); ... 0075 (model.lb(hasNoSubs) >= 0 & model.ub(hasNoSubs) > 0)]); 0076 case 'excrete' 0077 exchangeRxnsIndexes = allExch([(model.lb(hasNoProd) >= 0 & model.ub(hasNoProd) > 0); ... 0078 (model.lb(hasNoSubs) < 0 & model.ub(hasNoSubs) <= 0)]); 0079 otherwise 0080 error('Invalid reactionType specified') 0081 end 0082 exchangeRxnsIndexes = sort(exchangeRxnsIndexes); 0083 exchangeRxns = model.rxns(exchangeRxnsIndexes); 0084 end