0001 function model=setParam(model, paramType, rxnList, params, var)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 paramType=convertCharArray(paramType);
0033 if ~any(strcmpi(paramType,{'lb','ub','eq','obj','rev','var','unc'}))
0034 EM=['Incorrect parameter type: "' paramType{1} '"'];
0035 dispEM(EM);
0036 end
0037 if isnumeric(rxnList) || islogical(rxnList)
0038 rxnList=model.rxns(rxnList);
0039 else
0040 rxnList=convertCharArray(rxnList);
0041 end
0042
0043
0044 if numel(rxnList)~=numel(params) && numel(params)~=1
0045 EM='The number of parameter values and the number of reactions must be the same';
0046 dispEM(EM);
0047 end
0048
0049 if length(rxnList)>1
0050 if length(paramType)==1
0051 paramType(1:length(rxnList))=paramType;
0052 end
0053 if length(params)==1
0054 params(1:length(rxnList))=params;
0055 end
0056 end
0057
0058
0059
0060 indexes=zeros(numel(rxnList),1);
0061
0062 for i=1:numel(rxnList)
0063 index=find(strcmp(rxnList{i},model.rxns),1);
0064 if ~isempty(index)
0065 indexes(i)=index;
0066 else
0067 indexes(i)=-1;
0068 EM=['Reaction ' rxnList{i} ' is not present in the reaction list'];
0069 dispEM(EM,false);
0070 end
0071 end
0072
0073
0074 params(indexes==-1)=[];
0075 indexes(indexes==-1)=[];
0076 paramType(indexes==-1)=[];
0077
0078
0079 if ~isempty(indexes)
0080 if contains(paramType,'obj')
0081 model.c=zeros(numel(model.c),1);
0082 end
0083 for j=1:length(paramType)
0084 if strcmpi(paramType{j},'eq')
0085 model.lb(indexes(j))=params(j);
0086 model.ub(indexes(j))=params(j);
0087 end
0088 if strcmpi(paramType{j},'lb')
0089 model.lb(indexes(j))=params(j);
0090 end
0091 if strcmpi(paramType{j},'ub')
0092 model.ub(indexes(j))=params(j);
0093 end
0094 if strcmpi(paramType{j},'obj')
0095 model.c(indexes(j))=params(j);
0096 end
0097 if strcmpi(paramType{j},'rev')
0098
0099 model.rev(indexes(j))=params(j)~=0;
0100 end
0101 if strcmpi(paramType{j},'var')
0102 if params(j) < 0
0103 model.lb(indexes(j)) = params(j) * (1+var/200);
0104 model.ub(indexes(j)) = params(j) * (1-var/200);
0105 else
0106 model.lb(indexes(j)) = params(j) * (1-var/200);
0107 model.ub(indexes(j)) = params(j) * (1+var/200);
0108 end
0109 end
0110 if strcmpi(paramType{j},'unc')
0111 if isfield(model.annotation,'defaultLB')
0112 lb = model.annotation.defaultLB;
0113 else
0114 lb = -1000;
0115 end
0116 if isfield(model.annotation,'defaultUB')
0117 ub = model.annotation.defaultUB;
0118 else
0119 ub = 1000;
0120 end
0121 model.lb(indexes(j)) = lb;
0122 model.ub(indexes(j)) = ub;
0123 end
0124 end
0125 end
0126 end