Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/checkModelStruct.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ function checkModelStruct(model,throwErrors,trimWarnings)
EM='If "grRules" field exists, the model should also contain a "genes" field';
dispEM(EM,throwErrors);
else
%Erroneous grRules that start/end with OR/AND
EM='The following reaction(s) have grRules that start or end with ''OR'' or ''AND'':';
dispEM(EM,throwErrors,model.rxns(startsWith(model.grRules,{'or ','and '}) | endsWith(model.grRules,{' or',' and'})),trimWarnings);
%grRules that are not in genes field
geneList = getGenesFromGrRules(model.grRules);
geneList = setdiff(unique(geneList),model.genes);
if ~isempty(geneList)
Expand Down
4 changes: 2 additions & 2 deletions core/getExchangeRxns.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
% positive flux value would imply uptake,
% but reaction bounds are not considered
% 'out' reactions where the boundary metabolite
% is the substrate of the reaction, a
% positive flux value would imply uptake,
% is the product of the reaction, a
% negative flux value would imply uptake,
% but reaction bounds are not considered.
%
% Output:
Expand Down
24 changes: 10 additions & 14 deletions core/setParam.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
642 changes: 323 additions & 319 deletions doc/core/checkModelStruct.html

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions doc/core/getExchangeRxns.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ <h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="
positive flux value would imply uptake,
but reaction bounds are not considered
'out' reactions where the boundary metabolite
is the substrate of the reaction, a
positive flux value would imply uptake,
is the product of the reaction, a
negative flux value would imply uptake,
but reaction bounds are not considered.

Output:
Expand Down Expand Up @@ -109,8 +109,8 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0026 <span class="comment">% positive flux value would imply uptake,</span>
0027 <span class="comment">% but reaction bounds are not considered</span>
0028 <span class="comment">% 'out' reactions where the boundary metabolite</span>
0029 <span class="comment">% is the substrate of the reaction, a</span>
0030 <span class="comment">% positive flux value would imply uptake,</span>
0029 <span class="comment">% is the product of the reaction, a</span>
0030 <span class="comment">% negative flux value would imply uptake,</span>
0031 <span class="comment">% but reaction bounds are not considered.</span>
0032 <span class="comment">%</span>
0033 <span class="comment">% Output:</span>
Expand Down
170 changes: 83 additions & 87 deletions doc/core/setParam.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,96 +111,92 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0039 <span class="keyword">else</span>
0040 rxnList=<a href="convertCharArray.html" class="code" title="function inputConverted = convertCharArray(funcInput)">convertCharArray</a>(rxnList);
0041 <span class="keyword">end</span>
0042
0043 <span class="comment">%Allow to set several parameters to the same value</span>
0044 <span class="keyword">if</span> numel(rxnList)~=numel(params) &amp;&amp; numel(params)~=1
0045 EM=<span class="string">'The number of parameter values and the number of reactions must be the same'</span>;
0046 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM);
0047 <span class="keyword">end</span>
0048
0049 <span class="keyword">if</span> length(rxnList)&gt;1
0050 <span class="keyword">if</span> length(paramType)==1
0051 paramType(1:length(rxnList))=paramType;
0052 <span class="keyword">end</span>
0053 <span class="keyword">if</span> length(params)==1
0054 params(1:length(rxnList))=params;
0042 <span class="keyword">if</span> isempty(rxnList)
0043 <span class="keyword">return</span>;
0044 <span class="keyword">end</span>
0045
0046 <span class="comment">%Allow to set several parameters to the same value</span>
0047 <span class="keyword">if</span> numel(rxnList)~=numel(params) &amp;&amp; numel(params)~=1
0048 EM=<span class="string">'The number of parameter values and the number of reactions must be the same'</span>;
0049 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM);
0050 <span class="keyword">end</span>
0051
0052 <span class="keyword">if</span> length(rxnList)&gt;1
0053 <span class="keyword">if</span> length(paramType)==1
0054 paramType(1:length(rxnList))=paramType;
0055 <span class="keyword">end</span>
0056 <span class="keyword">end</span>
0057
0058 <span class="comment">%Find the indexes for the reactions in rxnList. Do not use getIndexes</span>
0059 <span class="comment">%as we do not want to throw errors if matches fail</span>
0060 indexes=zeros(numel(rxnList),1);
0061
0062 <span class="keyword">for</span> i=1:numel(rxnList)
0063 index=find(strcmp(rxnList{i},model.rxns),1);
0064 <span class="keyword">if</span> ~isempty(index)
0065 indexes(i)=index;
0066 <span class="keyword">else</span>
0067 indexes(i)=-1;
0068 EM=[<span class="string">'Reaction '</span> rxnList{i} <span class="string">' is not present in the reaction list'</span>];
0069 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,false);
0070 <span class="keyword">end</span>
0071 <span class="keyword">end</span>
0072
0073 <span class="comment">%Remove the reactions that were not found</span>
0074 params(indexes==-1)=[];
0075 indexes(indexes==-1)=[];
0076 paramType(indexes==-1)=[];
0077 <span class="comment">%Change the parameters</span>
0078
0079 <span class="keyword">if</span> ~isempty(indexes)
0080 <span class="keyword">if</span> contains(paramType,<span class="string">'obj'</span>)
0081 model.c=zeros(numel(model.c),1); <span class="comment">% parameter is changed, not added</span>
0082 <span class="keyword">end</span>
0083 <span class="keyword">for</span> j=1:length(paramType)
0084 <span class="keyword">if</span> strcmpi(paramType{j},<span class="string">'eq'</span>)
0056 <span class="keyword">if</span> length(params)==1
0057 params(1:length(rxnList))=params;
0058 <span class="keyword">end</span>
0059 <span class="keyword">end</span>
0060
0061 <span class="comment">%Find the indexes for the reactions in rxnList. Do not use getIndexes</span>
0062 <span class="comment">%as we do not want to throw errors if matches fail</span>
0063 indexes=zeros(numel(rxnList),1);
0064
0065 [Lia,Locb] = ismember(rxnList,model.rxns);
0066 indexes(Lia) = Locb;
0067 <span class="keyword">if</span> any(~Lia)
0068 params(~Lia)=[];
0069 indexes(~Lia)=[];
0070 paramType(~Lia)=[];
0071 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(<span class="string">'Reactions not present in model, will be ignored:'</span>,false,rxnLise(~Lia));
0072 <span class="keyword">end</span>
0073
0074 <span class="comment">%Change the parameters</span>
0075 <span class="keyword">if</span> ~isempty(indexes)
0076 <span class="keyword">if</span> contains(paramType,<span class="string">'obj'</span>)
0077 model.c=zeros(numel(model.c),1); <span class="comment">% parameter is changed, not added</span>
0078 <span class="keyword">end</span>
0079 <span class="keyword">for</span> j=1:length(paramType)
0080 <span class="keyword">if</span> strcmpi(paramType{j},<span class="string">'eq'</span>)
0081 model.lb(indexes(j))=params(j);
0082 model.ub(indexes(j))=params(j);
0083 <span class="keyword">end</span>
0084 <span class="keyword">if</span> strcmpi(paramType{j},<span class="string">'lb'</span>)
0085 model.lb(indexes(j))=params(j);
0086 model.ub(indexes(j))=params(j);
0087 <span class="keyword">end</span>
0088 <span class="keyword">if</span> strcmpi(paramType{j},<span class="string">'lb'</span>)
0089 model.lb(indexes(j))=params(j);
0090 <span class="keyword">end</span>
0091 <span class="keyword">if</span> strcmpi(paramType{j},<span class="string">'ub'</span>)
0092 model.ub(indexes(j))=params(j);
0093 <span class="keyword">end</span>
0094 <span class="keyword">if</span> strcmpi(paramType{j},<span class="string">'obj'</span>)
0095 model.c(indexes(j))=params(j);
0086 <span class="keyword">end</span>
0087 <span class="keyword">if</span> strcmpi(paramType{j},<span class="string">'ub'</span>)
0088 model.ub(indexes(j))=params(j);
0089 <span class="keyword">end</span>
0090 <span class="keyword">if</span> strcmpi(paramType{j},<span class="string">'obj'</span>)
0091 model.c(indexes(j))=params(j);
0092 <span class="keyword">end</span>
0093 <span class="keyword">if</span> strcmpi(paramType{j},<span class="string">'rev'</span>)
0094 <span class="comment">%Non-zero values are interpreted as reversible</span>
0095 model.rev(indexes(j))=params(j)~=0;
0096 <span class="keyword">end</span>
0097 <span class="keyword">if</span> strcmpi(paramType{j},<span class="string">'rev'</span>)
0098 <span class="comment">%Non-zero values are interpreted as reversible</span>
0099 model.rev(indexes(j))=params(j)~=0;
0100 <span class="keyword">end</span>
0101 <span class="keyword">if</span> strcmpi(paramType{j},<span class="string">'var'</span>)
0102 <span class="keyword">if</span> params(j) &lt; 0
0103 model.lb(indexes(j)) = params(j) * (1+var/200);
0104 model.ub(indexes(j)) = params(j) * (1-var/200);
0105 <span class="keyword">else</span>
0106 model.lb(indexes(j)) = params(j) * (1-var/200);
0107 model.ub(indexes(j)) = params(j) * (1+var/200);
0108 <span class="keyword">end</span>
0109 <span class="keyword">end</span>
0110 <span class="keyword">if</span> strcmpi(paramType{j},<span class="string">'unc'</span>)
0111 <span class="keyword">if</span> isfield(model.annotation,<span class="string">'defaultLB'</span>)
0112 lb = model.annotation.defaultLB;
0113 <span class="keyword">else</span>
0114 lb = -1000;
0115 <span class="keyword">end</span>
0116 <span class="keyword">if</span> isfield(model.annotation,<span class="string">'defaultUB'</span>)
0117 ub = model.annotation.defaultUB;
0118 <span class="keyword">else</span>
0119 ub = 1000;
0120 <span class="keyword">end</span>
0121 model.lb(indexes(j)) = lb;
0122 model.ub(indexes(j)) = ub;
0123 <span class="keyword">end</span>
0124 <span class="keyword">end</span>
0125 <span class="keyword">end</span>
0126 <span class="keyword">if</span> any(ismember(paramType,{<span class="string">'lb'</span>,<span class="string">'ub'</span>,<span class="string">'unc'</span>}))
0127 invalidBound = model.lb(indexes) &gt; model.ub(indexes);
0128 <span class="keyword">if</span> any(invalidBound)
0129 error([<span class="string">'Invalid set of bounds for reaction(s): '</span>, strjoin(model.rxns(indexes(invalidBound)),<span class="string">', '</span>), <span class="string">'.'</span>])
0130 <span class="keyword">end</span>
0131 <span class="keyword">end</span></pre></div>
0097 <span class="keyword">if</span> strcmpi(paramType{j},<span class="string">'var'</span>)
0098 <span class="keyword">if</span> params(j) &lt; 0
0099 model.lb(indexes(j)) = params(j) * (1+var/200);
0100 model.ub(indexes(j)) = params(j) * (1-var/200);
0101 <span class="keyword">else</span>
0102 model.lb(indexes(j)) = params(j) * (1-var/200);
0103 model.ub(indexes(j)) = params(j) * (1+var/200);
0104 <span class="keyword">end</span>
0105 <span class="keyword">end</span>
0106 <span class="keyword">if</span> strcmpi(paramType{j},<span class="string">'unc'</span>)
0107 <span class="keyword">if</span> isfield(model.annotation,<span class="string">'defaultLB'</span>)
0108 lb = model.annotation.defaultLB;
0109 <span class="keyword">else</span>
0110 lb = -1000;
0111 <span class="keyword">end</span>
0112 <span class="keyword">if</span> isfield(model.annotation,<span class="string">'defaultUB'</span>)
0113 ub = model.annotation.defaultUB;
0114 <span class="keyword">else</span>
0115 ub = 1000;
0116 <span class="keyword">end</span>
0117 model.lb(indexes(j)) = lb;
0118 model.ub(indexes(j)) = ub;
0119 <span class="keyword">end</span>
0120 <span class="keyword">end</span>
0121 <span class="keyword">end</span>
0122 <span class="keyword">if</span> any(ismember(paramType,{<span class="string">'lb'</span>,<span class="string">'ub'</span>,<span class="string">'unc'</span>}))
0123 invalidBound = model.lb(indexes) &gt; model.ub(indexes);
0124 <span class="keyword">if</span> any(invalidBound)
0125 error([<span class="string">'Invalid set of bounds for reaction(s): '</span>, strjoin(model.rxns(indexes(invalidBound)),<span class="string">', '</span>), <span class="string">'.'</span>])
0126 <span class="keyword">end</span>
0127 <span class="keyword">end</span></pre></div>
<hr><address>Generated by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>
Loading
Loading