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) Rasmus Agren, 2011-05-17
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 % Rasmus Agren, 2011-05-17 0020 % 0021 0022 if nargin<2 0023 reactionType='both'; 0024 end 0025 0026 hasNoProducts=sparse(numel(model.rxns),1); 0027 hasNoReactants=sparse(numel(model.rxns),1); 0028 0029 if isfield(model,'unconstrained') 0030 if strcmpi(reactionType,'both') || strcmpi(reactionType,'out') 0031 [crap I]=find(model.S(model.unconstrained~=0,:)>0); 0032 hasNoProducts(I)=true; 0033 end 0034 if strcmpi(reactionType,'both') || strcmpi(reactionType,'in') 0035 [crap I]=find(model.S(model.unconstrained~=0,:)<0); 0036 hasNoReactants(I)=true; 0037 end 0038 else 0039 if strcmpi(reactionType,'both') || strcmpi(reactionType,'out') 0040 hasNoProducts=sum((model.S>0))==0; 0041 end 0042 if strcmpi(reactionType,'both') || strcmpi(reactionType,'in') 0043 hasNoReactants=sum((model.S<0))==0; 0044 end 0045 end 0046 exchangeRxnsIndexes=find(hasNoProducts(:) | hasNoReactants(:)); 0047 exchangeRxns=model.rxns(exchangeRxnsIndexes); 0048 end