getExchangeRxns Retrieves the exchange reactions from a model model a model structure reactionType retrieve all reactions ('both'), only production ('out'), or only consumption ('in') (opt, default 'both') exchangeRxns cell array with the IDs of the exchange reactions exchangeRxnsIndexes vector with the indexes of the exchange reactions Exchange reactions are defined as reactions which involve only products or only reactants. If the unconstrained field is present, then that is used instead. Usage: [exchangeRxns,exchangeRxnsIndexes]=getExchangeRxns(model,reactionType)
0001 function [exchangeRxns, exchangeRxnsIndexes]=getExchangeRxns(model,reactionType) 0002 % getExchangeRxns 0003 % Retrieves the exchange reactions from a model 0004 % 0005 % model a model structure 0006 % reactionType retrieve all reactions ('both'), only production 0007 % ('out'), or only consumption ('in') (opt, default 0008 % 'both') 0009 % 0010 % exchangeRxns cell array with the IDs of the exchange reactions 0011 % exchangeRxnsIndexes vector with the indexes of the exchange reactions 0012 % 0013 % Exchange reactions are defined as reactions which involve only products 0014 % or only reactants. If the unconstrained field is present, then that is 0015 % used instead. 0016 % 0017 % Usage: [exchangeRxns,exchangeRxnsIndexes]=getExchangeRxns(model,reactionType) 0018 0019 if nargin<2 0020 reactionType='both'; 0021 else 0022 reactionType=char(reactionType); 0023 end 0024 0025 hasNoProducts=sparse(numel(model.rxns),1); 0026 hasNoReactants=sparse(numel(model.rxns),1); 0027 0028 if isfield(model,'unconstrained') 0029 if strcmpi(reactionType,'both') || strcmpi(reactionType,'out') 0030 [~, I]=find(model.S(model.unconstrained~=0,:)>0); 0031 hasNoProducts(I)=true; 0032 end 0033 if strcmpi(reactionType,'both') || strcmpi(reactionType,'in') 0034 [~, I]=find(model.S(model.unconstrained~=0,:)<0); 0035 hasNoReactants(I)=true; 0036 end 0037 else 0038 if strcmpi(reactionType,'both') || strcmpi(reactionType,'out') 0039 hasNoProducts=sum((model.S>0))==0; 0040 end 0041 if strcmpi(reactionType,'both') || strcmpi(reactionType,'in') 0042 hasNoReactants=sum((model.S<0))==0; 0043 end 0044 end 0045 exchangeRxnsIndexes=find(hasNoProducts(:) | hasNoReactants(:)); 0046 exchangeRxns=model.rxns(exchangeRxnsIndexes); 0047 end