Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feat/cobraFields
Browse files Browse the repository at this point in the history
# Conflicts:
#	doc/io/exportModel.html
#	doc/io/importModel.html
#	doc/io/readYAMLmodel.html
  • Loading branch information
edkerk committed Oct 2, 2024
2 parents 6ace8f8 + 943fe1c commit 7a82677
Show file tree
Hide file tree
Showing 23 changed files with 2,714 additions and 2,721 deletions.
35 changes: 24 additions & 11 deletions core/checkModelStruct.m
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,25 @@ function checkModelStruct(model,throwErrors,trimWarnings)
end
end

%Validate format of ids
fields={'rxns';'mets';'comps';'genes'};
fieldNames = {'reaction';'metabolite';'compartment';'gene'};
for i=1:numel(fields)
try
numIDs = startsWith(model.(fields{i}),digitsPattern(1));
if any(numIDs)
EM = ['The following ' fieldNames{i} ' IDs start with a digit, ' ...
'which does not comply with SBML specifications. This does '...
'not impact RAVEN functionality, but before exporting the ' ...
'model to SBML you should either correct these ' ...
'incompatibilities, or you can run exportModel with ' ...
'COBRAstyle as true: exportModel(model, ''filename.xml'', true); '];
dispEM(EM,throwErrors,{model.(fields{i}){numIDs}},trimWarnings);
end
catch
end
end

%Duplicates
EM='The following reaction IDs are duplicates:';
dispEM(EM,throwErrors,model.rxns(duplicates(model.rxns)),trimWarnings);
Expand Down Expand Up @@ -274,13 +293,10 @@ function checkModelStruct(model,throwErrors,trimWarnings)
dispEM(EM,false,model.comps(I),trimWarnings);

%Contradicting bounds
EM='The following reactions have contradicting bounds:';
EM='The following reactions have contradicting bounds (lower bound is higher than upper bound):';
dispEM(EM,throwErrors,model.rxns(model.lb>model.ub),trimWarnings);
EM='The following reactions have bounds contradicting their reversibility:';
contradictBound = (model.lb < 0 & model.ub > 0 & model.rev==0) | ... % Reversible bounds, irreversible label
(model.lb < 0 & model.ub <= 0 & model.rev==1) | ... % Negative bounds, reversible label
(model.lb >= 0 & model.ub > 0 & model.rev==1); % Positive bounds, reversible label
dispEM(EM,throwErrors,model.rxns(contradictBound),trimWarnings);
EM='The following reactions have lower and upper bounds that indicate reversibility, but are indicated as irreversible in model.rev:';
dispEM(EM,false,model.rxns(model.lb < 0 & model.ub > 0 & model.rev==0),trimWarnings);

%Multiple or no objective functions not allowed in SBML L3V1 FBCv2
if numel(find(model.c))>1
Expand All @@ -290,9 +306,6 @@ function checkModelStruct(model,throwErrors,trimWarnings)
EM='No objective function found. This might be intended, but results in FBCv2 non-compliant SBML file when exported';
dispEM(EM,false);
end

EM='The following reactions have contradicting bounds:';
dispEM(EM,throwErrors,model.rxns(model.lb>model.ub),trimWarnings);

%Mapping of compartments
if isfield(model,'compOutside')
Expand All @@ -310,8 +323,8 @@ function checkModelStruct(model,throwErrors,trimWarnings)
end
end
end
EM='The following metabolite IDs begin with a number directly followed by space:';
dispEM(EM,throwErrors,model.mets(I),trimWarnings);
EM='The following metabolite names begin with a number directly followed by space, which could potentially cause problems:';
dispEM(EM,false,model.metNames(I),trimWarnings);

%Non-parseable composition
if isfield(model,'metFormulas')
Expand Down
4 changes: 4 additions & 0 deletions core/dispEM.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ function dispEM(string,throwErrors,toList,trimWarnings)
end
if throwErrors==false
errorText=['WARNING: ' string '\n'];
% Wrap text to command window size
sz = get(0, 'CommandWindowSize');
errorText = textwrap({errorText},sz(1));
errorText = strjoin(errorText,'\n');
else
errorText=[string '\n'];
end
Expand Down
14 changes: 11 additions & 3 deletions core/printOrange.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function printOrange(stringToPrint)
function orangeString = printOrange(stringToPrint)
% printOrange
% Print orange-colored stringToPrint to the MATLAB Command Window. Only
% if MATLAB is open with GUI, does not work with command-line MATLAB.
Expand All @@ -7,10 +7,18 @@ function printOrange(stringToPrint)
% stringToPrint string that should be printed in orange color
%
% Usage: printOrange(stringToPrint)

try useDesktop = usejava('desktop'); catch, useDesktop = false; end
if useDesktop
fprintf(['[\b' stringToPrint,']\b'])
orangeString = ['[\b' stringToPrint,']\b'];
else
fprintf(stringToPrint)
orangeString = stringToPrint;
end
if nargout < 1
% Wrap text to command window size
sz = get(0, 'CommandWindowSize');
orangeString = textwrap({orangeString},sz(1));
orangeString = strjoin(orangeString,'\n');
fprintf(orangeString)
end
end
385 changes: 199 additions & 186 deletions doc/core/checkModelStruct.html

Large diffs are not rendered by default.

36 changes: 20 additions & 16 deletions doc/core/dispEM.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,26 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0033 <span class="keyword">end</span>
0034 <span class="keyword">if</span> throwErrors==false
0035 errorText=[<span class="string">'WARNING: '</span> string <span class="string">'\n'</span>];
0036 <span class="keyword">else</span>
0037 errorText=[string <span class="string">'\n'</span>];
0038 <span class="keyword">end</span>
0039 <span class="keyword">if</span> ~isempty(toList)
0040 <span class="keyword">for</span> i=1:numel(toList)
0041 errorText=[errorText <span class="string">'\t'</span> toList{i} <span class="string">'\n'</span>];
0042 <span class="keyword">end</span>
0043 <span class="keyword">end</span>
0044 <span class="keyword">if</span> throwErrors==false
0045 <span class="comment">%Escape special characters, required for fprintf</span>
0046 errorText=regexprep(errorText,<span class="string">'(\\|\%|'')(\\n)$'</span>,<span class="string">'\\$0'</span>);
0047 fprintf([errorText <span class="string">'\n'</span>]);
0048 <span class="keyword">else</span>
0049 throw(MException(<span class="string">''</span>,errorText));
0050 <span class="keyword">end</span>
0051 <span class="keyword">end</span></pre></div>
0036 <span class="comment">% Wrap text to command window size</span>
0037 sz = get(0, <span class="string">'CommandWindowSize'</span>);
0038 errorText = textwrap({errorText},sz(1));
0039 errorText = strjoin(errorText,<span class="string">'\n'</span>);
0040 <span class="keyword">else</span>
0041 errorText=[string <span class="string">'\n'</span>];
0042 <span class="keyword">end</span>
0043 <span class="keyword">if</span> ~isempty(toList)
0044 <span class="keyword">for</span> i=1:numel(toList)
0045 errorText=[errorText <span class="string">'\t'</span> toList{i} <span class="string">'\n'</span>];
0046 <span class="keyword">end</span>
0047 <span class="keyword">end</span>
0048 <span class="keyword">if</span> throwErrors==false
0049 <span class="comment">%Escape special characters, required for fprintf</span>
0050 errorText=regexprep(errorText,<span class="string">'(\\|\%|'')(\\n)$'</span>,<span class="string">'\\$0'</span>);
0051 fprintf([errorText <span class="string">'\n'</span>]);
0052 <span class="keyword">else</span>
0053 throw(MException(<span class="string">''</span>,errorText));
0054 <span class="keyword">end</span>
0055 <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>
26 changes: 17 additions & 9 deletions doc/core/printOrange.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../
<div class="box"><strong>printOrange</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function printOrange(stringToPrint) </strong></div>
<div class="box"><strong>function orangeString = printOrange(stringToPrint) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> printOrange
Expand All @@ -49,7 +49,7 @@ <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^


<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function printOrange(stringToPrint)</a>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function orangeString = printOrange(stringToPrint)</a>
0002 <span class="comment">% printOrange</span>
0003 <span class="comment">% Print orange-colored stringToPrint to the MATLAB Command Window. Only</span>
0004 <span class="comment">% if MATLAB is open with GUI, does not work with command-line MATLAB.</span>
Expand All @@ -58,13 +58,21 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0007 <span class="comment">% stringToPrint string that should be printed in orange color</span>
0008 <span class="comment">%</span>
0009 <span class="comment">% Usage: printOrange(stringToPrint)</span>
0010 <span class="keyword">try</span> useDesktop = usejava(<span class="string">'desktop'</span>); <span class="keyword">catch</span>, useDesktop = false; <span class="keyword">end</span>
0011 <span class="keyword">if</span> useDesktop
0012 fprintf([<span class="string">'[\b'</span> stringToPrint,<span class="string">']\b'</span>])
0013 <span class="keyword">else</span>
0014 fprintf(stringToPrint)
0015 <span class="keyword">end</span>
0016 <span class="keyword">end</span></pre></div>
0010
0011 <span class="keyword">try</span> useDesktop = usejava(<span class="string">'desktop'</span>); <span class="keyword">catch</span>, useDesktop = false; <span class="keyword">end</span>
0012 <span class="keyword">if</span> useDesktop
0013 orangeString = [<span class="string">'[\b'</span> stringToPrint,<span class="string">']\b'</span>];
0014 <span class="keyword">else</span>
0015 orangeString = stringToPrint;
0016 <span class="keyword">end</span>
0017 <span class="keyword">if</span> nargout &lt; 1
0018 <span class="comment">% Wrap text to command window size</span>
0019 sz = get(0, <span class="string">'CommandWindowSize'</span>);
0020 orangeString = textwrap({orangeString},sz(1));
0021 orangeString = strjoin(orangeString,<span class="string">'\n'</span>);
0022 fprintf(orangeString)
0023 <span class="keyword">end</span>
0024 <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>
4 changes: 2 additions & 2 deletions doc/io/SBMLFromExcel.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ <h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="exportModel.html" class="code" title="function exportModel(model,fileName,exportGeneComplexes,supressWarnings,sortIds)">exportModel</a> exportModel</li><li><a href="importExcelModel.html" class="code" title="function model=importExcelModel(fileName,removeExcMets,printWarnings,ignoreErrors)">importExcelModel</a> importExcelModel</li></ul>
<li><a href="exportModel.html" class="code" title="function exportModel(model,fileName,COBRAstyle,supressWarnings,sortIds)">exportModel</a> exportModel</li><li><a href="importExcelModel.html" class="code" title="function model=importExcelModel(fileName,removeExcMets,printWarnings,ignoreErrors)">importExcelModel</a> importExcelModel</li></ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
Expand Down Expand Up @@ -87,7 +87,7 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0027
0028 model=<a href="importExcelModel.html" class="code" title="function model=importExcelModel(fileName,removeExcMets,printWarnings,ignoreErrors)">importExcelModel</a>(fileName,false,printWarnings);
0029 printModelStats(model,printWarnings,false);
0030 <a href="exportModel.html" class="code" title="function exportModel(model,fileName,exportGeneComplexes,supressWarnings,sortIds)">exportModel</a>(model,outputFileName,toCOBRA,true);
0030 <a href="exportModel.html" class="code" title="function exportModel(model,fileName,COBRAstyle,supressWarnings,sortIds)">exportModel</a>(model,outputFileName,toCOBRA,true);
0031 <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>
Expand Down
2 changes: 1 addition & 1 deletion doc/io/checkFileExistence.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^
</ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="exportModel.html" class="code" title="function exportModel(model,fileName,exportGeneComplexes,supressWarnings,sortIds)">exportModel</a> exportModel</li><li><a href="getMD5Hash.html" class="code" title="function md5Hash=getMD5Hash(inputFile,binEnd)">getMD5Hash</a> getMD5Hash</li><li><a href="importModel.html" class="code" title="function model=importModel(fileName,removeExcMets,isSBML2COBRA,supressWarnings)">importModel</a> importModel</li></ul>
<li><a href="exportModel.html" class="code" title="function exportModel(model,fileName,COBRAstyle,supressWarnings,sortIds)">exportModel</a> exportModel</li><li><a href="getMD5Hash.html" class="code" title="function md5Hash=getMD5Hash(inputFile,binEnd)">getMD5Hash</a> getMD5Hash</li><li><a href="importModel.html" class="code" title="function model=importModel(fileName,removeExcMets,COBRAstyle,supressWarnings)">importModel</a> importModel</li></ul>
<!-- crossreference -->


Expand Down
Loading

0 comments on commit 7a82677

Please sign in to comment.