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