Home > core > 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 (optional, 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 "metName exchange (OUT/IN/BOTH)" while reaction
   ids are formatted as "EXC_OUT/IN/BOTH_METID".

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

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 (optional, 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 "metName exchange (OUT/IN/BOTH)" while reaction
0020 %   ids are formatted as "EXC_OUT/IN/BOTH_METID".
0021 %
0022 % Usage: [model, addedRxns]=addExchangeRxns(model,reactionType,mets)
0023 
0024 if nargin<3
0025     mets=model.mets;
0026 elseif ~islogical(mets) && ~isnumeric(mets)
0027     mets=convertCharArray(mets);
0028 end
0029 J=getIndexes(model,mets,'mets',false);
0030 mets=model.mets(J);
0031 
0032 reactionType=char(upper(reactionType));
0033 
0034 %Production is positive for OUT and BOTH
0035 if strcmp(reactionType,'IN')
0036     I=speye(numel(model.mets));
0037 else
0038     I=speye(numel(model.mets))*-1;
0039 end
0040 I=I(:,J);
0041 
0042 %Add an I matrix which corresponds to production of all metabolites
0043 model.S=[model.S I];
0044 if strcmp(reactionType,'BOTH')
0045     model.lb=[model.lb;ones(numel(J),1)*-1000];
0046     model.rev=[model.rev;ones(numel(J),1)];
0047 else
0048     model.lb=[model.lb;zeros(numel(J),1)];
0049     model.rev=[model.rev;zeros(numel(J),1)];
0050 end
0051 model.ub=[model.ub;ones(numel(J),1)*1000];
0052 model.c=[model.c;zeros(numel(J),1)];
0053 
0054 filler=cell(numel(J),1);
0055 filler(:)={''};
0056 addedRxns=strcat('EXC_',reactionType,'_',mets);
0057 addedRxnNames=strcat(model.metNames(J),' exchange (',reactionType,')');
0058 model.rxns=[model.rxns;addedRxns];
0059 model.rxnNames=[model.rxnNames;addedRxnNames];
0060 
0061 if isfield(model,'eccodes')
0062     model.eccodes=[model.eccodes;filler];
0063 end
0064 if isfield(model,'subSystems')
0065     fillerSub = filler;
0066     if iscell(model.subSystems(1,1))
0067         fillerSub = repmat({fillerSub},numel(J),1);
0068     end
0069     model.subSystems=[model.subSystems;fillerSub];
0070 end
0071 if isfield(model,'grRules')
0072     model.grRules=[model.grRules;filler];
0073 end
0074 if isfield(model,'rxnFrom')
0075     model.rxnFrom=[model.rxnFrom;filler];
0076 end
0077 if isfield(model,'rxnMiriams')
0078     model.rxnMiriams=[model.rxnMiriams;filler];
0079 end
0080 if isfield(model,'rxnGeneMat')
0081     model.rxnGeneMat=[model.rxnGeneMat;sparse(numel(J),numel(model.genes))];
0082 end
0083 if isfield(model,'rxnComps')
0084     model.rxnComps=[model.rxnComps;ones(numel(J),1)];
0085     fprintf('NOTE: The exchange reactions are assigned to the first compartment\n');
0086 end
0087 if isfield(model,'rxnNotes')
0088     model.rxnNotes=[model.rxnNotes;filler];
0089 end
0090 if isfield(model,'rxnReferences')
0091     model.rxnReferences=[model.rxnReferences;filler];
0092 end
0093 if isfield(model,'rxnConfidenceScores')
0094     model.rxnConfidenceScores=[model.rxnConfidenceScores;NaN(numel(J),1)];
0095 end
0096 if isfield(model,'rxnDeltaG')
0097     model.rxnDeltaG=[model.rxnDeltaG;NaN(numel(J),1)];
0098 end
0099 end

Generated by m2html © 2005