Home > RAVEN > addExchangeRxns.m

addExchangeRxns

PURPOSE ^

addExchangeRxns

SYNOPSIS ^

function [model addedRxns]=addExchangeRxns(model,reactionType,mets)

DESCRIPTION ^

 addExchangeRxns
   Adds exchange reactions for some metabolites

   model           a model structure
   reactionType    the type of reactions to add
                   'in'    input reactions
                   'out'   output reactions
                   'both'  reversible input/output reactions. Positive
                   direction corresponds to output
   mets            either a cell array of metabolite IDs, a logical vector 
                   with the same number of elements as metabolites in the model,
                   or a vector of indexes to add for (opt, default model.mets)

   model           updated model structure
   addedRxns       ids of the added reactions

   This is a faster version than addRxns when adding exchange reactions.
   New reactions are named "EXC_OUT/IN/BOTH_METID".

   Usage: [model addedRxns]=addExchangeRxns(model,reactionType,mets)

   Rasmus Agren, 2013-08-01

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [model addedRxns]=addExchangeRxns(model,reactionType,mets)
0002 % addExchangeRxns
0003 %   Adds exchange reactions for some metabolites
0004 %
0005 %   model           a model structure
0006 %   reactionType    the type of reactions to add
0007 %                   'in'    input reactions
0008 %                   'out'   output reactions
0009 %                   'both'  reversible input/output reactions. Positive
0010 %                   direction corresponds to output
0011 %   mets            either a cell array of metabolite IDs, a logical vector
0012 %                   with the same number of elements as metabolites in the model,
0013 %                   or a vector of indexes to add for (opt, default model.mets)
0014 %
0015 %   model           updated model structure
0016 %   addedRxns       ids of the added reactions
0017 %
0018 %   This is a faster version than addRxns when adding exchange reactions.
0019 %   New reactions are named "EXC_OUT/IN/BOTH_METID".
0020 %
0021 %   Usage: [model addedRxns]=addExchangeRxns(model,reactionType,mets)
0022 %
0023 %   Rasmus Agren, 2013-08-01
0024 %
0025 
0026 if nargin<3
0027     mets=model.mets;
0028 end
0029 reactionType=upper(reactionType);
0030 J=getIndexes(model,mets,'mets',false);
0031 mets=model.mets(J);
0032 
0033 %Production is positive for OUT and BOTH
0034 if strcmp(reactionType,'IN')
0035     I=speye(numel(model.mets));
0036 else
0037     I=speye(numel(model.mets))*-1;
0038 end
0039 I=I(:,J);
0040 
0041 %Add an I matrix which corresponds to production of all metabolites
0042 model.S=[model.S I];
0043 if strcmp(reactionType,'BOTH')
0044     model.lb=[model.lb;ones(numel(J),1)*-1000];
0045     model.rev=[model.rev;ones(numel(J),1)];
0046 else
0047     model.lb=[model.lb;zeros(numel(J),1)];
0048     model.rev=[model.rev;zeros(numel(J),1)];
0049 end
0050 model.ub=[model.ub;ones(numel(J),1)*1000];
0051 model.c=[model.c;zeros(numel(J),1)];
0052 
0053 filler=cell(numel(J),1);
0054 filler(:)={''};
0055 addedRxns=strcat({['EXC_' reactionType '_']},mets);
0056 model.rxns=[model.rxns;addedRxns];
0057 model.rxnNames=[model.rxnNames;addedRxns];
0058 
0059 if isfield(model,'eccodes')
0060     model.eccodes=[model.eccodes;filler];
0061 end
0062 if isfield(model,'subSystems')
0063     model.subSystems=[model.subSystems;filler];
0064 end
0065 if isfield(model,'grRules')
0066     model.grRules=[model.grRules;filler];
0067 end
0068 if isfield(model,'rxnFrom')
0069     model.rxnFrom=[model.rxnFrom;filler];
0070 end
0071 if isfield(model,'rxnMiriams')
0072     model.rxnMiriams=[model.rxnMiriams;cell(numel(J),1)];
0073 end
0074 if isfield(model,'rxnGeneMat')
0075     model.rxnGeneMat=[model.rxnGeneMat;sparse(numel(J),numel(model.genes))];
0076 end
0077 if isfield(model,'rxnComps')
0078    model.rxnComps=[model.rxnComps;ones(numel(J),1)];
0079    fprintf('NOTE: The exchange reactions are assigned to the first compartment\n');
0080 end
0081 end

Generated on Mon 06-Jan-2014 14:58:12 by m2html © 2005