diff --git a/core/setParam.m b/core/setParam.m
index e24ad2ca..734853b7 100755
--- a/core/setParam.m
+++ b/core/setParam.m
@@ -39,6 +39,9 @@
else
rxnList=convertCharArray(rxnList);
end
+if isempty(rxnList)
+ return;
+end
%Allow to set several parameters to the same value
if numel(rxnList)~=numel(params) && numel(params)~=1
@@ -59,23 +62,16 @@
%as we do not want to throw errors if matches fail
indexes=zeros(numel(rxnList),1);
-for i=1:numel(rxnList)
- index=find(strcmp(rxnList{i},model.rxns),1);
- if ~isempty(index)
- indexes(i)=index;
- else
- indexes(i)=-1;
- EM=['Reaction ' rxnList{i} ' is not present in the reaction list'];
- dispEM(EM,false);
- end
+[Lia,Locb] = ismember(rxnList,model.rxns);
+indexes(Lia) = Locb;
+if any(~Lia)
+ params(~Lia)=[];
+ indexes(~Lia)=[];
+ paramType(~Lia)=[];
+ dispEM('Reactions not present in model, will be ignored:',false,rxnLise(~Lia));
end
-%Remove the reactions that were not found
-params(indexes==-1)=[];
-indexes(indexes==-1)=[];
-paramType(indexes==-1)=[];
%Change the parameters
-
if ~isempty(indexes)
if contains(paramType,'obj')
model.c=zeros(numel(model.c),1); % parameter is changed, not added
diff --git a/doc/core/setParam.html b/doc/core/setParam.html
index 73b63b7e..96f0a107 100644
--- a/doc/core/setParam.html
+++ b/doc/core/setParam.html
@@ -111,96 +111,92 @@
SOURCE CODE
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;
+0042 if isempty(rxnList)
+0043 return;
+0044 end
+0045
+0046
+0047 if numel(rxnList)~=numel(params) && numel(params)~=1
+0048 EM='The number of parameter values and the number of reactions must be the same';
+0049 dispEM(EM);
+0050 end
+0051
+0052 if length(rxnList)>1
+0053 if length(paramType)==1
+0054 paramType(1:length(rxnList))=paramType;
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')
+0056 if length(params)==1
+0057 params(1:length(rxnList))=params;
+0058 end
+0059 end
+0060
+0061
+0062
+0063 indexes=zeros(numel(rxnList),1);
+0064
+0065 [Lia,Locb] = ismember(rxnList,model.rxns);
+0066 indexes(Lia) = Locb;
+0067 if any(~Lia)
+0068 params(~Lia)=[];
+0069 indexes(~Lia)=[];
+0070 paramType(~Lia)=[];
+0071 dispEM('Reactions not present in model, will be ignored:',false,rxnLise(~Lia));
+0072 end
+0073
+0074
+0075 if ~isempty(indexes)
+0076 if contains(paramType,'obj')
+0077 model.c=zeros(numel(model.c),1);
+0078 end
+0079 for j=1:length(paramType)
+0080 if strcmpi(paramType{j},'eq')
+0081 model.lb(indexes(j))=params(j);
+0082 model.ub(indexes(j))=params(j);
+0083 end
+0084 if strcmpi(paramType{j},'lb')
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);
+0086 end
+0087 if strcmpi(paramType{j},'ub')
+0088 model.ub(indexes(j))=params(j);
+0089 end
+0090 if strcmpi(paramType{j},'obj')
+0091 model.c(indexes(j))=params(j);
+0092 end
+0093 if strcmpi(paramType{j},'rev')
+0094
+0095 model.rev(indexes(j))=params(j)~=0;
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 if any(ismember(paramType,{'lb','ub','unc'}))
-0127 invalidBound = model.lb(indexes) > model.ub(indexes);
-0128 if any(invalidBound)
-0129 error(['Invalid set of bounds for reaction(s): ', strjoin(model.rxns(indexes(invalidBound)),', '), '.'])
-0130 end
-0131 end
+0097 if strcmpi(paramType{j},'var')
+0098 if params(j) < 0
+0099 model.lb(indexes(j)) = params(j) * (1+var/200);
+0100 model.ub(indexes(j)) = params(j) * (1-var/200);
+0101 else
+0102 model.lb(indexes(j)) = params(j) * (1-var/200);
+0103 model.ub(indexes(j)) = params(j) * (1+var/200);
+0104 end
+0105 end
+0106 if strcmpi(paramType{j},'unc')
+0107 if isfield(model.annotation,'defaultLB')
+0108 lb = model.annotation.defaultLB;
+0109 else
+0110 lb = -1000;
+0111 end
+0112 if isfield(model.annotation,'defaultUB')
+0113 ub = model.annotation.defaultUB;
+0114 else
+0115 ub = 1000;
+0116 end
+0117 model.lb(indexes(j)) = lb;
+0118 model.ub(indexes(j)) = ub;
+0119 end
+0120 end
+0121 end
+0122 if any(ismember(paramType,{'lb','ub','unc'}))
+0123 invalidBound = model.lb(indexes) > model.ub(indexes);
+0124 if any(invalidBound)
+0125 error(['Invalid set of bounds for reaction(s): ', strjoin(model.rxns(indexes(invalidBound)),', '), '.'])
+0126 end
+0127 end
Generated by m2html © 2005