Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: readYAMLmodel builds correct ec.rxnEnzMat #568

Merged
merged 5 commits into from
Oct 19, 2024
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
355 changes: 180 additions & 175 deletions doc/installation/checkInstallation.html

Large diffs are not rendered by default.

270 changes: 133 additions & 137 deletions doc/io/exportForGit.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/io/exportModel.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^
<li><a href="checkFileExistence.html" class="code" title="function files=checkFileExistence(files,fullOrTemp,allowSpace,checkExist)">checkFileExistence</a> checkFileExistence</li><li><a href="exportModel.html" class="code" title="function exportModel(model,fileName,neverPrefix,supressWarnings,sortIds)">exportModel</a> exportModel</li><li><a href="sortIdentifiers.html" class="code" title="function newModel = sortIdentifiers(model)">sortIdentifiers</a> exportModel</li></ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="SBMLFromExcel.html" class="code" title="function SBMLFromExcel(fileName, outputFileName,toCOBRA,printWarnings)">SBMLFromExcel</a> SBMLFromExcel</li><li><a href="exportForGit.html" class="code" title="function out=exportForGit(model,prefix,path,formats,mainBranchFlag,subDirs,COBRAtext,COBRAstyle)">exportForGit</a> exportForGit</li><li><a href="exportModel.html" class="code" title="function exportModel(model,fileName,neverPrefix,supressWarnings,sortIds)">exportModel</a> exportModel</li></ul>
<li><a href="SBMLFromExcel.html" class="code" title="function SBMLFromExcel(fileName, outputFileName,toCOBRA,printWarnings)">SBMLFromExcel</a> SBMLFromExcel</li><li><a href="exportForGit.html" class="code" title="function out=exportForGit(model,prefix,path,formats,mainBranchFlag,subDirs,COBRAtext,neverPrefixIDs)">exportForGit</a> exportForGit</li><li><a href="exportModel.html" class="code" title="function exportModel(model,fileName,neverPrefix,supressWarnings,sortIds)">exportModel</a> exportModel</li></ul>
<!-- crossreference -->

<h2><a name="_subfunctions"></a>SUBFUNCTIONS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
Expand Down
2 changes: 1 addition & 1 deletion doc/io/exportToExcelFormat.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^
<li><a href="exportToTabDelimited.html" class="code" title="function exportToTabDelimited(model,path,sortIds)">exportToTabDelimited</a> exportToTabDelimited</li><li><a href="loadWorkbook.html" class="code" title="function workbook=loadWorkbook(fileName,createEmpty)">loadWorkbook</a> loadWorkbook</li><li><a href="sortIdentifiers.html" class="code" title="function newModel = sortIdentifiers(model)">sortIdentifiers</a> exportModel</li><li><a href="writeSheet.html" class="code" title="function wb=writeSheet(wb,sheetName,sheetPosition,captions,units,raw,isIntegers)">writeSheet</a> writeSheet</li></ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="exportForGit.html" class="code" title="function out=exportForGit(model,prefix,path,formats,mainBranchFlag,subDirs,COBRAtext,COBRAstyle)">exportForGit</a> exportForGit</li></ul>
<li><a href="exportForGit.html" class="code" title="function out=exportForGit(model,prefix,path,formats,mainBranchFlag,subDirs,COBRAtext,neverPrefixIDs)">exportForGit</a> exportForGit</li></ul>
<!-- crossreference -->


Expand Down
2 changes: 1 addition & 1 deletion doc/io/getToolboxVersion.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,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="exportForGit.html" class="code" title="function out=exportForGit(model,prefix,path,formats,mainBranchFlag,subDirs,COBRAtext,COBRAstyle)">exportForGit</a> exportForGit</li></ul>
<li><a href="exportForGit.html" class="code" title="function out=exportForGit(model,prefix,path,formats,mainBranchFlag,subDirs,COBRAtext,neverPrefixIDs)">exportForGit</a> exportForGit</li></ul>
<!-- crossreference -->

<h2><a name="_subfunctions"></a>SUBFUNCTIONS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
Expand Down
2 changes: 1 addition & 1 deletion doc/io/readYAMLmodel.html
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0625 [~,enzIdx] = ismember(enzStoich(:,2),model.ec.enzymes);
0626 coeffs = cell2mat(enzStoich(:,3));
0627 model.ec.rxnEnzMat = zeros(numel(model.ec.rxns), numel(model.ec.genes));
0628 linearIndices = sub2ind([max(rxnIdx), max(enzIdx)], rxnIdx, enzIdx);
0628 linearIndices = sub2ind([numel(model.ec.rxns), numel(model.ec.genes)], rxnIdx, enzIdx);
0629 model.ec.rxnEnzMat(linearIndices) = coeffs;
0630 <span class="comment">%Parse ec-codes</span>
0631 <span class="keyword">if</span> ~isempty(ecGecko)
Expand Down
2 changes: 1 addition & 1 deletion doc/io/sortIdentifiers.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,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="exportForGit.html" class="code" title="function out=exportForGit(model,prefix,path,formats,mainBranchFlag,subDirs,COBRAtext,COBRAstyle)">exportForGit</a> exportForGit</li><li><a href="exportModel.html" class="code" title="function exportModel(model,fileName,neverPrefix,supressWarnings,sortIds)">exportModel</a> exportModel</li><li><a href="exportToExcelFormat.html" class="code" title="function exportToExcelFormat(model,fileName,sortIds)">exportToExcelFormat</a> exportToExcelFormat</li><li><a href="exportToTabDelimited.html" class="code" title="function exportToTabDelimited(model,path,sortIds)">exportToTabDelimited</a> exportToTabDelimited</li><li><a href="writeYAMLmodel.html" class="code" title="function writeYAMLmodel(model,fileName,preserveQuotes,sortIds)">writeYAMLmodel</a> writeYAMLmodel</li></ul>
<li><a href="exportForGit.html" class="code" title="function out=exportForGit(model,prefix,path,formats,mainBranchFlag,subDirs,COBRAtext,neverPrefixIDs)">exportForGit</a> exportForGit</li><li><a href="exportModel.html" class="code" title="function exportModel(model,fileName,neverPrefix,supressWarnings,sortIds)">exportModel</a> exportModel</li><li><a href="exportToExcelFormat.html" class="code" title="function exportToExcelFormat(model,fileName,sortIds)">exportToExcelFormat</a> exportToExcelFormat</li><li><a href="exportToTabDelimited.html" class="code" title="function exportToTabDelimited(model,path,sortIds)">exportToTabDelimited</a> exportToTabDelimited</li><li><a href="writeYAMLmodel.html" class="code" title="function writeYAMLmodel(model,fileName,preserveQuotes,sortIds)">writeYAMLmodel</a> writeYAMLmodel</li></ul>
<!-- crossreference -->


Expand Down
2 changes: 1 addition & 1 deletion doc/io/writeYAMLmodel.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^
<li><a href="sortIdentifiers.html" class="code" title="function newModel = sortIdentifiers(model)">sortIdentifiers</a> exportModel</li></ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="exportForGit.html" class="code" title="function out=exportForGit(model,prefix,path,formats,mainBranchFlag,subDirs,COBRAtext,COBRAstyle)">exportForGit</a> exportForGit</li></ul>
<li><a href="exportForGit.html" class="code" title="function out=exportForGit(model,prefix,path,formats,mainBranchFlag,subDirs,COBRAtext,neverPrefixIDs)">exportForGit</a> exportForGit</li></ul>
<!-- crossreference -->

<h2><a name="_subfunctions"></a>SUBFUNCTIONS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
Expand Down
71 changes: 46 additions & 25 deletions doc/testing/unit_tests/importExportTests.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^

<h2><a name="_subfunctions"></a>SUBFUNCTIONS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="#_sub1" class="code">function testExcelImport(testCase)</a></li><li><a href="#_sub2" class="code">function testSBMLImport(testCase)</a></li><li><a href="#_sub3" class="code">function testExcelExport(testCase)</a></li><li><a href="#_sub4" class="code">function testSBMLExport(testCase)</a></li></ul>
<li><a href="#_sub1" class="code">function testExcelImport(testCase)</a></li><li><a href="#_sub2" class="code">function testSBMLImport(testCase)</a></li><li><a href="#_sub3" class="code">function testYAMLimport(testCase)</a></li><li><a href="#_sub4" class="code">function testExcelExport(testCase)</a></li><li><a href="#_sub5" class="code">function testSBMLExport(testCase)</a></li><li><a href="#_sub6" class="code">function testYAMLexport(testCase)</a></li></ul>

<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <span class="comment">%run this test case with the command</span>
Expand Down Expand Up @@ -72,31 +72,52 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0025 verifyEqual(testCase,model,modelSBML)
0026 <span class="keyword">end</span>
0027
0028 <a name="_sub3" href="#_subfunctions" class="code">function testExcelExport(testCase)</a>
0028 <a name="_sub3" href="#_subfunctions" class="code">function testYAMLimport(testCase)</a>
0029 sourceDir=fileparts(fileparts(fileparts(which(mfilename))));
0030 load(fullfile(sourceDir,<span class="string">'testing'</span>,<span class="string">'unit_tests'</span>,<span class="string">'test_data'</span>,<span class="string">'ecoli_textbook.mat'</span>), <span class="string">'model'</span>);
0031 exportToExcelFormat(model,fullfile(sourceDir,<span class="string">'testing'</span>,<span class="string">'unit_tests'</span>,<span class="string">'test_data'</span>,<span class="string">'_test.xlsx'</span>));
0032 <span class="comment">%File will not be exactly equal as it contains the current date and time,</span>
0033 <span class="comment">%so md5 or similar would not work. Just check whether file is reasonably</span>
0034 <span class="comment">%sized.</span>
0035 s = dir(fullfile(sourceDir,<span class="string">'testing'</span>,<span class="string">'unit_tests'</span>,<span class="string">'test_data'</span>,<span class="string">'_test.xlsx'</span>));
0036 filesize = s.bytes;
0037 verifyTrue(testCase,filesize&gt;17000);
0038 delete(fullfile(sourceDir,<span class="string">'testing'</span>,<span class="string">'unit_tests'</span>,<span class="string">'test_data'</span>,<span class="string">'_test.xlsx'</span>));
0039 <span class="keyword">end</span>
0040
0041 <a name="_sub4" href="#_subfunctions" class="code">function testSBMLExport(testCase)</a>
0042 sourceDir=fileparts(fileparts(fileparts(which(mfilename))));
0043 load(fullfile(sourceDir,<span class="string">'testing'</span>,<span class="string">'unit_tests'</span>,<span class="string">'test_data'</span>,<span class="string">'ecoli_textbook.mat'</span>), <span class="string">'model'</span>);
0044 evalc(<span class="string">'exportModel(model,fullfile(sourceDir,''testing'',''unit_tests'',''test_data'',''_test.xml''))'</span>);
0045 <span class="comment">%File will not be exactly equal as it contains the current date and time,</span>
0046 <span class="comment">%so md5 or similar would not work. Just check whether file is reasonably</span>
0047 <span class="comment">%sized.</span>
0048 s = dir(fullfile(sourceDir,<span class="string">'testing'</span>,<span class="string">'unit_tests'</span>,<span class="string">'test_data'</span>,<span class="string">'_test.xml'</span>));
0049 filesize = s.bytes;
0050 verifyTrue(testCase,filesize&gt;18500);
0051 delete(fullfile(sourceDir,<span class="string">'testing'</span>,<span class="string">'unit_tests'</span>,<span class="string">'test_data'</span>,<span class="string">'_test.xml'</span>));
0052 <span class="keyword">end</span></pre></div>
0030 yamlFile=fullfile(sourceDir,<span class="string">'tutorial'</span>,<span class="string">'empty.yml'</span>);
0031 evalc(<span class="string">'model=readYAMLmodel(yamlFile)'</span>); <span class="comment">% Repress warnings</span>
0032 load(fullfile(sourceDir,<span class="string">'testing'</span>,<span class="string">'unit_tests'</span>,<span class="string">'test_data'</span>,<span class="string">'importExportResults.mat'</span>), <span class="string">'modelYAML'</span>);
0033 verifyEqual(testCase,model,modelYAML)
0034 <span class="keyword">end</span>
0035
0036 <a name="_sub4" href="#_subfunctions" class="code">function testExcelExport(testCase)</a>
0037 sourceDir=fileparts(fileparts(fileparts(which(mfilename))));
0038 load(fullfile(sourceDir,<span class="string">'testing'</span>,<span class="string">'unit_tests'</span>,<span class="string">'test_data'</span>,<span class="string">'ecoli_textbook.mat'</span>), <span class="string">'model'</span>);
0039 exportToExcelFormat(model,fullfile(sourceDir,<span class="string">'testing'</span>,<span class="string">'unit_tests'</span>,<span class="string">'test_data'</span>,<span class="string">'_test.xlsx'</span>));
0040 <span class="comment">%File will not be exactly equal as it contains the current date and time,</span>
0041 <span class="comment">%so md5 or similar would not work. Just check whether file is reasonably</span>
0042 <span class="comment">%sized.</span>
0043 s = dir(fullfile(sourceDir,<span class="string">'testing'</span>,<span class="string">'unit_tests'</span>,<span class="string">'test_data'</span>,<span class="string">'_test.xlsx'</span>));
0044 filesize = s.bytes;
0045 verifyTrue(testCase,filesize&gt;17000);
0046 delete(fullfile(sourceDir,<span class="string">'testing'</span>,<span class="string">'unit_tests'</span>,<span class="string">'test_data'</span>,<span class="string">'_test.xlsx'</span>));
0047 <span class="keyword">end</span>
0048
0049 <a name="_sub5" href="#_subfunctions" class="code">function testSBMLExport(testCase)</a>
0050 sourceDir=fileparts(fileparts(fileparts(which(mfilename))));
0051 load(fullfile(sourceDir,<span class="string">'testing'</span>,<span class="string">'unit_tests'</span>,<span class="string">'test_data'</span>,<span class="string">'ecoli_textbook.mat'</span>), <span class="string">'model'</span>);
0052 evalc(<span class="string">'exportModel(model,fullfile(sourceDir,''testing'',''unit_tests'',''test_data'',''_test.xml''))'</span>);
0053 <span class="comment">%File will not be exactly equal as it contains the current date and time,</span>
0054 <span class="comment">%so md5 or similar would not work. Just check whether file is reasonably</span>
0055 <span class="comment">%sized.</span>
0056 s = dir(fullfile(sourceDir,<span class="string">'testing'</span>,<span class="string">'unit_tests'</span>,<span class="string">'test_data'</span>,<span class="string">'_test.xml'</span>));
0057 filesize = s.bytes;
0058 verifyTrue(testCase,filesize&gt;18500);
0059 delete(fullfile(sourceDir,<span class="string">'testing'</span>,<span class="string">'unit_tests'</span>,<span class="string">'test_data'</span>,<span class="string">'_test.xml'</span>));
0060 <span class="keyword">end</span>
0061
0062 <a name="_sub6" href="#_subfunctions" class="code">function testYAMLexport(testCase)</a>
0063 sourceDir=fileparts(fileparts(fileparts(which(mfilename))));
0064 load(fullfile(sourceDir,<span class="string">'tutorial'</span>,<span class="string">'empty.mat'</span>), <span class="string">'emptyModel'</span>);
0065 evalc(<span class="string">'writeYAMLmodel(emptyModel,fullfile(sourceDir,''testing'',''unit_tests'',''test_data'',''_test.yml''))'</span>);
0066 <span class="comment">%File will not be exactly equal as it contains the current date and time,</span>
0067 <span class="comment">%so md5 or similar would not work. Just check whether file is reasonably</span>
0068 <span class="comment">%sized.</span>
0069 s = dir(fullfile(sourceDir,<span class="string">'testing'</span>,<span class="string">'unit_tests'</span>,<span class="string">'test_data'</span>,<span class="string">'_test.yml'</span>));
0070 filesize = s.bytes;
0071 verifyTrue(testCase,filesize&gt;1290);
0072 delete(fullfile(sourceDir,<span class="string">'testing'</span>,<span class="string">'unit_tests'</span>,<span class="string">'test_data'</span>,<span class="string">'_test.yml'</span>));
0073 <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>
25 changes: 15 additions & 10 deletions installation/checkInstallation.m
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
end

fprintf(myStr(' > Export Excel format',40))
if res(3).Passed == 1
if res(4).Passed == 1
fprintf('Pass\n')
else
printOrange('Fail\n')
Expand All @@ -193,20 +193,25 @@
end

fprintf(myStr(' > Export SBML format',40))
if res(4).Passed == 1
if res(5).Passed == 1
fprintf('Pass\n')
else
printOrange('Fail\n')
end

%Check if it is possible to import an YAML model
% fprintf(' > Checking import of model in YAML format:\t\t\t');
% try
% readYaml(ymlFile,true);
% fprintf('Pass\n');
% catch
% printOrange('Fail\n');
% end
fprintf(myStr(' > Import YAML format',40))
if res(3).Passed == 1
fprintf('Pass\n')
else
printOrange('Fail\n')
end

fprintf(myStr(' > Export YAML format',40))
if res(6).Passed == 1
fprintf('Pass\n')
else
printOrange('Fail\n')
end

fprintf('\n=== Model solvers ===\n');

Expand Down
19 changes: 9 additions & 10 deletions io/exportForGit.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function out=exportForGit(model,prefix,path,formats,mainBranchFlag,subDirs,COBRAtext,COBRAstyle)
function out=exportForGit(model,prefix,path,formats,mainBranchFlag,subDirs,COBRAtext,neverPrefixIDs)
% exportForGit
% Generates a directory structure and populates this with model files, ready
% to be commited to a Git(Hub) maintained model repository. Writes the model
Expand Down Expand Up @@ -28,16 +28,13 @@
% Toolbox format using metabolite IDs, instead of
% metabolite names and compartments. (optional,
% default false)
% COBRAstyle true if COBRA-style prefixes should be added to all
% identifiers in the SBML file: R_ for reactions, M_
% for metabolites, G_ for genes and C_ for
% compartments. If all identifiers of a particular
% field already have the prefix, then no additional
% prefixes are added. (optional, default false)
% neverPrefixIDs true if prefixes are never added to identifiers,
% even if start with e.g. digits. This might result
% in invalid SBML files (optional, default false)
%
% Usage: exportForGit(model,prefix,path,formats,mainBranchFlag,subDirs,COBRAtext,COBRAstyle)
if nargin<8
COBRAstyle=false;
neverPrefixIDs=false;
end
if nargin<7 || isempty(COBRAtext)
COBRAtext=false;
Expand Down Expand Up @@ -73,7 +70,9 @@

%Get versions or commits of toolboxes:
RAVENver = getToolboxVersion('RAVEN','ravenCobraWrapper.m',mainBranchFlag);
COBRAver = getToolboxVersion('COBRA','initCobraToolbox.m',mainBranchFlag);
if exist('initCobraToolbox.m','file')
COBRAver = getToolboxVersion('COBRA','initCobraToolbox.m',mainBranchFlag);
end

%Retrieve libSBML version:
[ravenDir,prevDir]=findRAVENroot();
Expand Down Expand Up @@ -142,7 +141,7 @@

% Write XML format
if ismember('xml', formats)
exportModel(model,fullfile(filePath{5},strcat(prefix,'.xml')),COBRAstyle);
exportModel(model,fullfile(filePath{5},strcat(prefix,'.xml')),neverPrefixIDs);
end

%Save file with versions:
Expand Down
2 changes: 1 addition & 1 deletion io/readYAMLmodel.m
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@
[~,enzIdx] = ismember(enzStoich(:,2),model.ec.enzymes);
coeffs = cell2mat(enzStoich(:,3));
model.ec.rxnEnzMat = zeros(numel(model.ec.rxns), numel(model.ec.genes));
linearIndices = sub2ind([max(rxnIdx), max(enzIdx)], rxnIdx, enzIdx);
linearIndices = sub2ind([numel(model.ec.rxns), numel(model.ec.genes)], rxnIdx, enzIdx);
model.ec.rxnEnzMat(linearIndices) = coeffs;
%Parse ec-codes
if ~isempty(ecGecko)
Expand Down
Loading
Loading