0001 function [model, addedRxns]=addExchangeRxns(model,reactionType,mets)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
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
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
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 model.subSystems=[model.subSystems;filler];
0066 end
0067 if isfield(model,'grRules')
0068 model.grRules=[model.grRules;filler];
0069 end
0070 if isfield(model,'rxnFrom')
0071 model.rxnFrom=[model.rxnFrom;filler];
0072 end
0073 if isfield(model,'rxnMiriams')
0074 model.rxnMiriams=[model.rxnMiriams;filler];
0075 end
0076 if isfield(model,'rxnGeneMat')
0077 model.rxnGeneMat=[model.rxnGeneMat;sparse(numel(J),numel(model.genes))];
0078 end
0079 if isfield(model,'rxnComps')
0080 model.rxnComps=[model.rxnComps;ones(numel(J),1)];
0081 fprintf('NOTE: The exchange reactions are assigned to the first compartment\n');
0082 end
0083 if isfield(model,'rxnNotes')
0084 model.rxnNotes=[model.rxnNotes;filler];
0085 end
0086 if isfield(model,'rxnReferences')
0087 model.rxnReferences=[model.rxnReferences;filler];
0088 end
0089 if isfield(model,'rxnConfidenceScores')
0090 model.rxnConfidenceScores=[model.rxnConfidenceScores;NaN(numel(J),1)];
0091 end
0092 if isfield(model,'rxnDeltaG')
0093 model.rxnDeltaG=[model.rxnDeltaG;NaN(numel(J),1)];
0094 end
0095 end