From 3538d8f6d7cafd57766ff14c2d2a185bd1600568 Mon Sep 17 00:00:00 2001 From: Eduard Kerkhoven Date: Wed, 16 Oct 2024 14:21:34 +0200 Subject: [PATCH 1/5] fix: exportForGit correct neverPrefix option --- doc/io/exportForGit.html | 270 ++++++++++++++++---------------- doc/io/exportModel.html | 2 +- doc/io/exportToExcelFormat.html | 2 +- doc/io/getToolboxVersion.html | 2 +- doc/io/sortIdentifiers.html | 2 +- doc/io/writeYAMLmodel.html | 2 +- io/exportForGit.m | 15 +- 7 files changed, 143 insertions(+), 152 deletions(-) diff --git a/doc/io/exportForGit.html b/doc/io/exportForGit.html index 74a90f62..f833f5d1 100644 --- a/doc/io/exportForGit.html +++ b/doc/io/exportForGit.html @@ -24,7 +24,7 @@

PURPOSE ^exportForGit

SYNOPSIS ^

-
function out=exportForGit(model,prefix,path,formats,mainBranchFlag,subDirs,COBRAtext,COBRAstyle)
+
function out=exportForGit(model,prefix,path,formats,mainBranchFlag,subDirs,COBRAtext,neverPrefixIDs)

DESCRIPTION ^

 exportForGit
@@ -56,12 +56,9 @@ 

DESCRIPTION ^CROSS-REFERENCE INFORMATION ^
 
 
 <h2><a name=SOURCE CODE ^

-
0001 function out=exportForGit(model,prefix,path,formats,mainBranchFlag,subDirs,COBRAtext,COBRAstyle)
+
0001 function out=exportForGit(model,prefix,path,formats,mainBranchFlag,subDirs,COBRAtext,neverPrefixIDs)
 0002 % exportForGit
 0003 %   Generates a directory structure and populates this with model files, ready
 0004 %   to be commited to a Git(Hub) maintained model repository. Writes the model
@@ -108,140 +105,137 @@ 

SOURCE CODE ^% Toolbox format using metabolite IDs, instead of 0029 % metabolite names and compartments. (optional, 0030 % default false) -0031 % COBRAstyle true if COBRA-style prefixes should be added to all -0032 % identifiers in the SBML file: R_ for reactions, M_ -0033 % for metabolites, G_ for genes and C_ for -0034 % compartments. If all identifiers of a particular -0035 % field already have the prefix, then no additional -0036 % prefixes are added. (optional, default false) -0037 % -0038 % Usage: exportForGit(model,prefix,path,formats,mainBranchFlag,subDirs,COBRAtext,COBRAstyle) -0039 if nargin<8 -0040 COBRAstyle=false; +0031 % neverPrefixIDs true if prefixes are never added to identifiers, +0032 % even if start with e.g. digits. This might result +0033 % in invalid SBML files (optional, default false) +0034 % +0035 % Usage: exportForGit(model,prefix,path,formats,mainBranchFlag,subDirs,COBRAtext,COBRAstyle) +0036 if nargin<8 +0037 neverPrefixIDs=false; +0038 end +0039 if nargin<7 || isempty(COBRAtext) +0040 COBRAtext=false; 0041 end -0042 if nargin<7 || isempty(COBRAtext) -0043 COBRAtext=false; +0042 if nargin<6 || isempty(subDirs) +0043 subDirs=true; 0044 end -0045 if nargin<6 || isempty(subDirs) -0046 subDirs=true; +0045 if nargin<5 || isempty(mainBranchFlag) +0046 mainBranchFlag=false; 0047 end -0048 if nargin<5 || isempty(mainBranchFlag) -0049 mainBranchFlag=false; -0050 end -0051 if nargin<4 || isempty(formats) -0052 formats={'mat', 'txt', 'xlsx', 'xml', 'yml'}; -0053 else -0054 formats=convertCharArray(formats); -0055 end -0056 if any(~ismember(formats, {'mat', 'txt', 'xlsx', 'xml', 'yml'})) -0057 EM='Unknown file format defined. Only mat, txt, xlsx, xml and yml are allowed file formats.'; -0058 error(EM) -0059 end -0060 if nargin<3 || isempty(path) -0061 path='.'; -0062 else -0063 path=char(path); -0064 end -0065 if nargin<2 || isempty(prefix) -0066 prefix='model'; -0067 else -0068 prefix=char(prefix); -0069 end +0048 if nargin<4 || isempty(formats) +0049 formats={'mat', 'txt', 'xlsx', 'xml', 'yml'}; +0050 else +0051 formats=convertCharArray(formats); +0052 end +0053 if any(~ismember(formats, {'mat', 'txt', 'xlsx', 'xml', 'yml'})) +0054 EM='Unknown file format defined. Only mat, txt, xlsx, xml and yml are allowed file formats.'; +0055 error(EM) +0056 end +0057 if nargin<3 || isempty(path) +0058 path='.'; +0059 else +0060 path=char(path); +0061 end +0062 if nargin<2 || isempty(prefix) +0063 prefix='model'; +0064 else +0065 prefix=char(prefix); +0066 end +0067 +0068 %Sort reactions, metabolites and genes alphabetically +0069 model=sortIdentifiers(model); 0070 -0071 %Sort reactions, metabolites and genes alphabetically -0072 model=sortIdentifiers(model); -0073 -0074 %Get versions or commits of toolboxes: -0075 RAVENver = getToolboxVersion('RAVEN','ravenCobraWrapper.m',mainBranchFlag); -0076 COBRAver = getToolboxVersion('COBRA','initCobraToolbox.m',mainBranchFlag); -0077 -0078 %Retrieve libSBML version: -0079 [ravenDir,prevDir]=findRAVENroot(); -0080 try % 5.17.0 and newer -0081 libSBMLver=OutputSBML_RAVEN; -0082 libSBMLver=libSBMLver.libSBML_version_string; -0083 catch % before 5.17.0 -0084 fid = fopen('tempModelForLibSBMLversion.xml','w+'); -0085 fclose(fid); -0086 evalc('[~,~,libSBMLver]=TranslateSBML_RAVEN(''tempModelForLibSBMLversion.xml'',0,0)'); -0087 libSBMLver=libSBMLver.libSBML_version_string; -0088 delete('tempModelForLibSBMLversion.xml'); -0089 end -0090 -0091 % Make models folder, no warnings if folder already exists -0092 if subDirs -0093 path=fullfile(path,'model'); -0094 filePath=strcat(path,filesep,{'txt','yml','mat','xlsx','xml'}); -0095 [~,~,~]=mkdir(path); -0096 for i = 1:length(formats) -0097 [~,~,~]=mkdir(fullfile(path,formats{i})); -0098 end -0099 else -0100 filePath=cell(1,5); filePath(:)={path}; -0101 end -0102 -0103 -0104 % Write TXT format -0105 if ismember('txt', formats) -0106 fid=fopen(fullfile(filePath{1},strcat(prefix,'.txt')),'w'); -0107 if COBRAtext==true -0108 eqns=constructEquations(model,model.rxns,false,false,false); -0109 eqns=strrep(eqns,' => ',' -> '); -0110 eqns=strrep(eqns,' <=> ',' <=> '); -0111 eqns=regexprep(eqns,'> $','>'); -0112 grRules=regexprep(model.grRules,'\((?!\()','( '); -0113 grRules=regexprep(grRules,'(?<!\))\)',' )'); -0114 else -0115 eqns=constructEquations(model,model.rxns); -0116 grRules=model.grRules; -0117 end -0118 fprintf(fid, 'Rxn name\tFormula\tGene-reaction association\tLB\tUB\tObjective\n'); -0119 for i = 1:numel(model.rxns) -0120 fprintf(fid, '%s\t', model.rxns{i}); -0121 fprintf(fid, '%s \t', eqns{i}); -0122 fprintf(fid, '%s\t', grRules{i}); -0123 fprintf(fid, '%6.2f\t%6.2f\t%6.2f\n', model.lb(i), model.ub(i), model.c(i)); -0124 end -0125 fclose(fid); -0126 end -0127 -0128 % Write YML format -0129 if ismember('yml', formats) -0130 writeYAMLmodel(model,fullfile(filePath{2},strcat(prefix,'.yml'))); -0131 end -0132 -0133 % Write MAT format -0134 if ismember('mat', formats) -0135 save(fullfile(filePath{3},strcat(prefix,'.mat')),'model'); -0136 end -0137 -0138 % Write XLSX format -0139 if ismember('xlsx', formats) -0140 exportToExcelFormat(model,fullfile(filePath{4},strcat(prefix,'.xlsx'))); -0141 end -0142 -0143 % Write XML format -0144 if ismember('xml', formats) -0145 exportModel(model,fullfile(filePath{5},strcat(prefix,'.xml')),COBRAstyle); -0146 end -0147 -0148 %Save file with versions: -0149 fid = fopen(fullfile(path,'dependencies.txt'),'wt'); -0150 fprintf(fid,['MATLAB\t' version '\n']); -0151 fprintf(fid,['libSBML\t' libSBMLver '\n']); -0152 fprintf(fid,['RAVEN_toolbox\t' RAVENver '\n']); -0153 if ~isempty(COBRAver) -0154 fprintf(fid,['COBRA_toolbox\t' COBRAver '\n']); -0155 end -0156 if isfield(model,'modelVersion') -0157 fields = fieldnames(model.modelVersion); -0158 for i = 1:length(fields) -0159 value = model.modelVersion.(fields{i}); -0160 fprintf(fid,[fields{i} '\t' num2str(value) '\n']); -0161 end -0162 end -0163 fclose(fid); -0164 end

+0071 %Get versions or commits of toolboxes: +0072 RAVENver = getToolboxVersion('RAVEN','ravenCobraWrapper.m',mainBranchFlag); +0073 COBRAver = getToolboxVersion('COBRA','initCobraToolbox.m',mainBranchFlag); +0074 +0075 %Retrieve libSBML version: +0076 [ravenDir,prevDir]=findRAVENroot(); +0077 try % 5.17.0 and newer +0078 libSBMLver=OutputSBML_RAVEN; +0079 libSBMLver=libSBMLver.libSBML_version_string; +0080 catch % before 5.17.0 +0081 fid = fopen('tempModelForLibSBMLversion.xml','w+'); +0082 fclose(fid); +0083 evalc('[~,~,libSBMLver]=TranslateSBML_RAVEN(''tempModelForLibSBMLversion.xml'',0,0)'); +0084 libSBMLver=libSBMLver.libSBML_version_string; +0085 delete('tempModelForLibSBMLversion.xml'); +0086 end +0087 +0088 % Make models folder, no warnings if folder already exists +0089 if subDirs +0090 path=fullfile(path,'model'); +0091 filePath=strcat(path,filesep,{'txt','yml','mat','xlsx','xml'}); +0092 [~,~,~]=mkdir(path); +0093 for i = 1:length(formats) +0094 [~,~,~]=mkdir(fullfile(path,formats{i})); +0095 end +0096 else +0097 filePath=cell(1,5); filePath(:)={path}; +0098 end +0099 +0100 +0101 % Write TXT format +0102 if ismember('txt', formats) +0103 fid=fopen(fullfile(filePath{1},strcat(prefix,'.txt')),'w'); +0104 if COBRAtext==true +0105 eqns=constructEquations(model,model.rxns,false,false,false); +0106 eqns=strrep(eqns,' => ',' -> '); +0107 eqns=strrep(eqns,' <=> ',' <=> '); +0108 eqns=regexprep(eqns,'> $','>'); +0109 grRules=regexprep(model.grRules,'\((?!\()','( '); +0110 grRules=regexprep(grRules,'(?<!\))\)',' )'); +0111 else +0112 eqns=constructEquations(model,model.rxns); +0113 grRules=model.grRules; +0114 end +0115 fprintf(fid, 'Rxn name\tFormula\tGene-reaction association\tLB\tUB\tObjective\n'); +0116 for i = 1:numel(model.rxns) +0117 fprintf(fid, '%s\t', model.rxns{i}); +0118 fprintf(fid, '%s \t', eqns{i}); +0119 fprintf(fid, '%s\t', grRules{i}); +0120 fprintf(fid, '%6.2f\t%6.2f\t%6.2f\n', model.lb(i), model.ub(i), model.c(i)); +0121 end +0122 fclose(fid); +0123 end +0124 +0125 % Write YML format +0126 if ismember('yml', formats) +0127 writeYAMLmodel(model,fullfile(filePath{2},strcat(prefix,'.yml'))); +0128 end +0129 +0130 % Write MAT format +0131 if ismember('mat', formats) +0132 save(fullfile(filePath{3},strcat(prefix,'.mat')),'model'); +0133 end +0134 +0135 % Write XLSX format +0136 if ismember('xlsx', formats) +0137 exportToExcelFormat(model,fullfile(filePath{4},strcat(prefix,'.xlsx'))); +0138 end +0139 +0140 % Write XML format +0141 if ismember('xml', formats) +0142 exportModel(model,fullfile(filePath{5},strcat(prefix,'.xml')),neverPrefixIDs); +0143 end +0144 +0145 %Save file with versions: +0146 fid = fopen(fullfile(path,'dependencies.txt'),'wt'); +0147 fprintf(fid,['MATLAB\t' version '\n']); +0148 fprintf(fid,['libSBML\t' libSBMLver '\n']); +0149 fprintf(fid,['RAVEN_toolbox\t' RAVENver '\n']); +0150 if ~isempty(COBRAver) +0151 fprintf(fid,['COBRA_toolbox\t' COBRAver '\n']); +0152 end +0153 if isfield(model,'modelVersion') +0154 fields = fieldnames(model.modelVersion); +0155 for i = 1:length(fields) +0156 value = model.modelVersion.(fields{i}); +0157 fprintf(fid,[fields{i} '\t' num2str(value) '\n']); +0158 end +0159 end +0160 fclose(fid); +0161 end

Generated by m2html © 2005
\ No newline at end of file diff --git a/doc/io/exportModel.html b/doc/io/exportModel.html index 34b6f359..57f67266 100644 --- a/doc/io/exportModel.html +++ b/doc/io/exportModel.html @@ -53,7 +53,7 @@

CROSS-REFERENCE INFORMATION ^
 <li><a href=checkFileExistence checkFileExistence
  • exportModel exportModel
  • sortIdentifiers exportModel
  • This function is called by: +
  • SBMLFromExcel SBMLFromExcel
  • exportForGit exportForGit
  • exportModel exportModel
  • SUBFUNCTIONS ^

    diff --git a/doc/io/exportToExcelFormat.html b/doc/io/exportToExcelFormat.html index b23c701e..bbb64211 100644 --- a/doc/io/exportToExcelFormat.html +++ b/doc/io/exportToExcelFormat.html @@ -53,7 +53,7 @@

    CROSS-REFERENCE INFORMATION ^
 <li><a href=exportToTabDelimited exportToTabDelimited
  • loadWorkbook loadWorkbook
  • sortIdentifiers exportModel
  • writeSheet writeSheet
  • This function is called by: +
  • exportForGit exportForGit
  • diff --git a/doc/io/getToolboxVersion.html b/doc/io/getToolboxVersion.html index 73335a08..54e1744b 100644 --- a/doc/io/getToolboxVersion.html +++ b/doc/io/getToolboxVersion.html @@ -49,7 +49,7 @@

    CROSS-REFERENCE INFORMATION ^
 </ul>
 This function is called by:
 <ul style= -
  • exportForGit exportForGit
  • +
  • exportForGit exportForGit
  • SUBFUNCTIONS ^

    diff --git a/doc/io/sortIdentifiers.html b/doc/io/sortIdentifiers.html index 71563563..1198cb31 100644 --- a/doc/io/sortIdentifiers.html +++ b/doc/io/sortIdentifiers.html @@ -47,7 +47,7 @@

    CROSS-REFERENCE INFORMATION ^
 </ul>
 This function is called by:
 <ul style= -
  • exportForGit exportForGit
  • exportModel exportModel
  • exportToExcelFormat exportToExcelFormat
  • exportToTabDelimited exportToTabDelimited
  • writeYAMLmodel writeYAMLmodel
  • +
  • exportForGit exportForGit
  • exportModel exportModel
  • exportToExcelFormat exportToExcelFormat
  • exportToTabDelimited exportToTabDelimited
  • writeYAMLmodel writeYAMLmodel
  • diff --git a/doc/io/writeYAMLmodel.html b/doc/io/writeYAMLmodel.html index 77164d47..8aafb9ee 100644 --- a/doc/io/writeYAMLmodel.html +++ b/doc/io/writeYAMLmodel.html @@ -49,7 +49,7 @@

    CROSS-REFERENCE INFORMATION ^
 <li><a href=sortIdentifiers exportModel This function is called by: +
  • exportForGit exportForGit
  • SUBFUNCTIONS ^

    diff --git a/io/exportForGit.m b/io/exportForGit.m index d90f5b04..0f04406d 100755 --- a/io/exportForGit.m +++ b/io/exportForGit.m @@ -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 @@ -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; @@ -142,7 +139,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: From d091b89ab8da0b677d67cca7781a9e1f124852d7 Mon Sep 17 00:00:00 2001 From: Eduard Kerkhoven Date: Thu, 17 Oct 2024 20:10:43 +0200 Subject: [PATCH 2/5] feat: YAML I/O tests --- doc/installation/checkInstallation.html | 355 +++++++++--------- doc/testing/unit_tests/importExportTests.html | 71 ++-- installation/checkInstallation.m | 25 +- testing/unit_tests/importExportTests.m | 21 ++ .../test_data/importExportResults.mat | Bin 1400 -> 2219 bytes tutorial/empty.mat | Bin 711 -> 890 bytes tutorial/empty.yml | 64 ++++ 7 files changed, 326 insertions(+), 210 deletions(-) create mode 100644 tutorial/empty.yml diff --git a/doc/installation/checkInstallation.html b/doc/installation/checkInstallation.html index 3804091d..3f5370a0 100644 --- a/doc/installation/checkInstallation.html +++ b/doc/installation/checkInstallation.html @@ -248,7 +248,7 @@

    SOURCE CODE ^end 0180 0181 fprintf(myStr(' > Export Excel format',40)) -0182 if res(3).Passed == 1 +0182 if res(4).Passed == 1 0183 fprintf('Pass\n') 0184 else 0185 printOrange('Fail\n') @@ -262,186 +262,191 @@

    SOURCE CODE ^end 0194 0195 fprintf(myStr(' > Export SBML format',40)) -0196 if res(4).Passed == 1 +0196 if res(5).Passed == 1 0197 fprintf('Pass\n') 0198 else 0199 printOrange('Fail\n') 0200 end 0201 -0202 %Check if it is possible to import an YAML model -0203 % fprintf(' > Checking import of model in YAML format:\t\t\t'); -0204 % try -0205 % readYaml(ymlFile,true); -0206 % fprintf('Pass\n'); -0207 % catch -0208 % printOrange('Fail\n'); -0209 % end -0210 -0211 fprintf('\n=== Model solvers ===\n'); -0212 -0213 %Get current solver. Set it to 'none', if it is not set -0214 fprintf(' > Checking for LP solvers\n') -0215 [~,res]=evalc("runtests('solverTests.m');"); -0216 -0217 fprintf(myStr(' > glpk',40)) -0218 if res(1).Passed == 1 -0219 fprintf('Pass\n') -0220 else -0221 printOrange('Fail\n') -0222 end -0223 -0224 fprintf(myStr(' > gurobi',40)) -0225 if res(2).Passed == 1 -0226 fprintf('Pass\n') -0227 else -0228 printOrange('Fail\n') -0229 end -0230 -0231 fprintf(myStr(' > scip',40)) -0232 if res(3).Passed == 1 -0233 fprintf('Pass\n') -0234 else -0235 printOrange('Fail\n') -0236 end -0237 -0238 fprintf(myStr(' > cobra',40)) -0239 if res(4).Passed == 1 -0240 fprintf('Pass\n') -0241 else -0242 printOrange('Fail\n') -0243 end -0244 fprintf(myStr(' > Set RAVEN solver',40)) -0245 try -0246 oldSolver=getpref('RAVEN','solver'); -0247 solverIdx=find(strcmp(oldSolver,{'glpk','gurobi','scip','cobra'})); -0248 catch -0249 solverIdx=0; -0250 end -0251 % Do not change old solver if functional -0252 if solverIdx~=0 && res(solverIdx).Passed == 1 -0253 fprintf([oldSolver '\n']) -0254 % Order of preference: gurobi > glpk > scip > cobra -0255 elseif res(2).Passed == 1 -0256 fprintf('gurobi\n') -0257 setRavenSolver('gurobi'); -0258 elseif res(1).Passed == 1 -0259 fprintf('glpk\n') -0260 setRavenSolver('glpk'); -0261 elseif res(3).Passed == 1 -0262 fprintf('scip\n') -0263 setRavenSolver('scip'); -0264 elseif res(4).Passed == 1 -0265 fprintf('cobra\n') -0266 setRavenSolver('cobra'); -0267 else -0268 fprintf('None, no functional solvers\n') -0269 fprintf(' The glpk should always be working, check your RAVEN installation to make sure all files are present\n') -0270 end -0271 -0272 fprintf('\n=== Essential binary executables ===\n'); -0273 fprintf(myStr(' > Checking BLAST+',40)) -0274 [~,res]=evalc("runtests('blastPlusTests.m');"); -0275 res=interpretResults(res); -0276 if res==false -0277 fprintf(' This is essential to run getBlast()\n') -0278 end -0279 -0280 fprintf(myStr(' > Checking DIAMOND',40)) -0281 [~,res]=evalc("runtests('diamondTests.m');"); -0282 res=interpretResults(res); -0283 if res==false -0284 fprintf(' This is essential to run the getDiamond()\n') -0285 end -0286 -0287 fprintf(myStr(' > Checking HMMER',40)) -0288 [~,res]=evalc("runtests('hmmerTests.m')"); -0289 res=interpretResults(res); -0290 if res==false -0291 fprintf([' This is essential to run getKEGGModelFromHomology()\n'... -0292 ' when using a FASTA file as input\n']) -0293 end -0294 -0295 if developMode -0296 fprintf('\n=== Development binary executables ===\n'); -0297 fprintf('NOTE: These binaries are only required when using KEGG FTP dump files in getKEGGModelForOrganism\n'); -0298 -0299 fprintf(myStr(' > Checking CD-HIT',40)) -0300 [~,res]=evalc("runtests('cdhitTests.m');"); -0301 interpretResults(res); -0302 -0303 fprintf(myStr(' > Checking MAFFT',40)) -0304 [~,res]=evalc("runtests('mafftTests.m');"); -0305 interpretResults(res); -0306 end +0202 fprintf(myStr(' > Import YAML format',40)) +0203 if res(3).Passed == 1 +0204 fprintf('Pass\n') +0205 else +0206 printOrange('Fail\n') +0207 end +0208 +0209 fprintf(myStr(' > Export YAML format',40)) +0210 if res(6).Passed == 1 +0211 fprintf('Pass\n') +0212 else +0213 printOrange('Fail\n') +0214 end +0215 +0216 fprintf('\n=== Model solvers ===\n'); +0217 +0218 %Get current solver. Set it to 'none', if it is not set +0219 fprintf(' > Checking for LP solvers\n') +0220 [~,res]=evalc("runtests('solverTests.m');"); +0221 +0222 fprintf(myStr(' > glpk',40)) +0223 if res(1).Passed == 1 +0224 fprintf('Pass\n') +0225 else +0226 printOrange('Fail\n') +0227 end +0228 +0229 fprintf(myStr(' > gurobi',40)) +0230 if res(2).Passed == 1 +0231 fprintf('Pass\n') +0232 else +0233 printOrange('Fail\n') +0234 end +0235 +0236 fprintf(myStr(' > scip',40)) +0237 if res(3).Passed == 1 +0238 fprintf('Pass\n') +0239 else +0240 printOrange('Fail\n') +0241 end +0242 +0243 fprintf(myStr(' > cobra',40)) +0244 if res(4).Passed == 1 +0245 fprintf('Pass\n') +0246 else +0247 printOrange('Fail\n') +0248 end +0249 fprintf(myStr(' > Set RAVEN solver',40)) +0250 try +0251 oldSolver=getpref('RAVEN','solver'); +0252 solverIdx=find(strcmp(oldSolver,{'glpk','gurobi','scip','cobra'})); +0253 catch +0254 solverIdx=0; +0255 end +0256 % Do not change old solver if functional +0257 if solverIdx~=0 && res(solverIdx).Passed == 1 +0258 fprintf([oldSolver '\n']) +0259 % Order of preference: gurobi > glpk > scip > cobra +0260 elseif res(2).Passed == 1 +0261 fprintf('gurobi\n') +0262 setRavenSolver('gurobi'); +0263 elseif res(1).Passed == 1 +0264 fprintf('glpk\n') +0265 setRavenSolver('glpk'); +0266 elseif res(3).Passed == 1 +0267 fprintf('scip\n') +0268 setRavenSolver('scip'); +0269 elseif res(4).Passed == 1 +0270 fprintf('cobra\n') +0271 setRavenSolver('cobra'); +0272 else +0273 fprintf('None, no functional solvers\n') +0274 fprintf(' The glpk should always be working, check your RAVEN installation to make sure all files are present\n') +0275 end +0276 +0277 fprintf('\n=== Essential binary executables ===\n'); +0278 fprintf(myStr(' > Checking BLAST+',40)) +0279 [~,res]=evalc("runtests('blastPlusTests.m');"); +0280 res=interpretResults(res); +0281 if res==false +0282 fprintf(' This is essential to run getBlast()\n') +0283 end +0284 +0285 fprintf(myStr(' > Checking DIAMOND',40)) +0286 [~,res]=evalc("runtests('diamondTests.m');"); +0287 res=interpretResults(res); +0288 if res==false +0289 fprintf(' This is essential to run the getDiamond()\n') +0290 end +0291 +0292 fprintf(myStr(' > Checking HMMER',40)) +0293 [~,res]=evalc("runtests('hmmerTests.m')"); +0294 res=interpretResults(res); +0295 if res==false +0296 fprintf([' This is essential to run getKEGGModelFromHomology()\n'... +0297 ' when using a FASTA file as input\n']) +0298 end +0299 +0300 if developMode +0301 fprintf('\n=== Development binary executables ===\n'); +0302 fprintf('NOTE: These binaries are only required when using KEGG FTP dump files in getKEGGModelForOrganism\n'); +0303 +0304 fprintf(myStr(' > Checking CD-HIT',40)) +0305 [~,res]=evalc("runtests('cdhitTests.m');"); +0306 interpretResults(res); 0307 -0308 fprintf('\n=== Compatibility ===\n'); -0309 fprintf(myStr(' > Checking function uniqueness',40)) -0310 checkFunctionUniqueness(); -0311 -0312 fprintf('\n*** checkInstallation complete ***\n\n'); -0313 end -0314 -0315 function res = interpretResults(results) -0316 if results.Failed==0 && results.Incomplete==0 -0317 fprintf('Pass\n'); -0318 res=true; -0319 else -0320 printOrange('Fail\n') -0321 fprintf(' Download/compile the binary and rerun checkInstallation\n'); -0322 res=false; -0323 end -0324 end -0325 -0326 function str = myStr(InputStr,len) -0327 str=InputStr; -0328 lenDiff = len - length(str); -0329 if lenDiff < 0 -0330 warning('String too long'); -0331 else -0332 str = [str blanks(lenDiff)]; -0333 end -0334 end -0335 -0336 function status = makeBinaryExecutable(ravenDir) -0337 % This function is required to run when RAVEN is downloaded as MATLAB -0338 % Add-On, in which case the file permissions are not correctly set -0339 if ispc -0340 status = 0; % No need to run on Windows -0341 return; -0342 end -0343 binDir = fullfile(ravenDir,'software'); -0344 -0345 binList = {fullfile(binDir,'blast+','blastp'); fullfile(binDir,'blast+','blastp.mac'); -0346 fullfile(binDir,'blast+','makeblastdb'); fullfile(binDir,'blast+','makeblastdb.mac'); -0347 fullfile(binDir,'cd-hit','cd-hit'); fullfile(binDir,'cd-hit','cd-hit.mac'); -0348 fullfile(binDir,'diamond','diamond'); fullfile(binDir,'diamond','diamond.mac'); -0349 fullfile(binDir,'hmmer','hmmbuild'); fullfile(binDir,'hmmer','hmmbuild.mac'); -0350 fullfile(binDir,'hmmer','hmmsearch'); fullfile(binDir,'hmmer','hmmsearch.mac'); -0351 fullfile(binDir,'GLPKmex','glpkcc.mexa64'); fullfile(binDir,'GLPKmex','glpkcc.mexglx'); fullfile(binDir,'GLPKmex','glpkcc.mexmaci64'); fullfile(binDir,'GLPKmex','glpkcc.mexmaca64'); -0352 fullfile(binDir,'libSBML','TranslateSBML_RAVEN.mexa64'); fullfile(binDir,'libSBML','TranslateSBML_RAVEN.mexglx'); fullfile(binDir,'libSBML','TranslateSBML_RAVEN.mexmaci64'); fullfile(binDir,'libSBML','TranslateSBML_RAVEN.mexmaca64'); -0353 fullfile(binDir,'libSBML','OutputSBML_RAVEN.mexa64'); fullfile(binDir,'libSBML','OutputSBML_RAVEN.mexglx'); fullfile(binDir,'libSBML','OutputSBML_RAVEN.mexmaci64'); fullfile(binDir,'libSBML','OutputSBML_RAVEN.mexmaca64'); -0354 fullfile(binDir,'mafft','mafft-linux64','mafft.bat'); -0355 fullfile(binDir,'mafft','mafft-mac','mafft.bat');}; -0356 -0357 for i=1:numel(binList) -0358 [status,cmdout] = system(['chmod +x "' binList{i} '"']); -0359 if status ~= 0 -0360 warning('Failed to make %s executable: %s ',binList{i},strip(cmdout)) -0361 end -0362 end -0363 end -0364 -0365 function printOrange(stringToPrint) -0366 % printOrange -0367 % Duplicate of RAVEN/core/printOrange is also kept here, as this function -0368 % should be able to run before adding RAVEN to the MATLAB path. -0369 try useDesktop = usejava('desktop'); catch, useDesktop = false; end -0370 if useDesktop -0371 fprintf(['[\b' stringToPrint,']\b']) -0372 else -0373 fprintf(stringToPrint) -0374 end -0375 end

    +0308 fprintf(myStr(' > Checking MAFFT',40)) +0309 [~,res]=evalc("runtests('mafftTests.m');"); +0310 interpretResults(res); +0311 end +0312 +0313 fprintf('\n=== Compatibility ===\n'); +0314 fprintf(myStr(' > Checking function uniqueness',40)) +0315 checkFunctionUniqueness(); +0316 +0317 fprintf('\n*** checkInstallation complete ***\n\n'); +0318 end +0319 +0320 function res = interpretResults(results) +0321 if results.Failed==0 && results.Incomplete==0 +0322 fprintf('Pass\n'); +0323 res=true; +0324 else +0325 printOrange('Fail\n') +0326 fprintf(' Download/compile the binary and rerun checkInstallation\n'); +0327 res=false; +0328 end +0329 end +0330 +0331 function str = myStr(InputStr,len) +0332 str=InputStr; +0333 lenDiff = len - length(str); +0334 if lenDiff < 0 +0335 warning('String too long'); +0336 else +0337 str = [str blanks(lenDiff)]; +0338 end +0339 end +0340 +0341 function status = makeBinaryExecutable(ravenDir) +0342 % This function is required to run when RAVEN is downloaded as MATLAB +0343 % Add-On, in which case the file permissions are not correctly set +0344 if ispc +0345 status = 0; % No need to run on Windows +0346 return; +0347 end +0348 binDir = fullfile(ravenDir,'software'); +0349 +0350 binList = {fullfile(binDir,'blast+','blastp'); fullfile(binDir,'blast+','blastp.mac'); +0351 fullfile(binDir,'blast+','makeblastdb'); fullfile(binDir,'blast+','makeblastdb.mac'); +0352 fullfile(binDir,'cd-hit','cd-hit'); fullfile(binDir,'cd-hit','cd-hit.mac'); +0353 fullfile(binDir,'diamond','diamond'); fullfile(binDir,'diamond','diamond.mac'); +0354 fullfile(binDir,'hmmer','hmmbuild'); fullfile(binDir,'hmmer','hmmbuild.mac'); +0355 fullfile(binDir,'hmmer','hmmsearch'); fullfile(binDir,'hmmer','hmmsearch.mac'); +0356 fullfile(binDir,'GLPKmex','glpkcc.mexa64'); fullfile(binDir,'GLPKmex','glpkcc.mexglx'); fullfile(binDir,'GLPKmex','glpkcc.mexmaci64'); fullfile(binDir,'GLPKmex','glpkcc.mexmaca64'); +0357 fullfile(binDir,'libSBML','TranslateSBML_RAVEN.mexa64'); fullfile(binDir,'libSBML','TranslateSBML_RAVEN.mexglx'); fullfile(binDir,'libSBML','TranslateSBML_RAVEN.mexmaci64'); fullfile(binDir,'libSBML','TranslateSBML_RAVEN.mexmaca64'); +0358 fullfile(binDir,'libSBML','OutputSBML_RAVEN.mexa64'); fullfile(binDir,'libSBML','OutputSBML_RAVEN.mexglx'); fullfile(binDir,'libSBML','OutputSBML_RAVEN.mexmaci64'); fullfile(binDir,'libSBML','OutputSBML_RAVEN.mexmaca64'); +0359 fullfile(binDir,'mafft','mafft-linux64','mafft.bat'); +0360 fullfile(binDir,'mafft','mafft-mac','mafft.bat');}; +0361 +0362 for i=1:numel(binList) +0363 [status,cmdout] = system(['chmod +x "' binList{i} '"']); +0364 if status ~= 0 +0365 warning('Failed to make %s executable: %s ',binList{i},strip(cmdout)) +0366 end +0367 end +0368 end +0369 +0370 function printOrange(stringToPrint) +0371 % printOrange +0372 % Duplicate of RAVEN/core/printOrange is also kept here, as this function +0373 % should be able to run before adding RAVEN to the MATLAB path. +0374 try useDesktop = usejava('desktop'); catch, useDesktop = false; end +0375 if useDesktop +0376 fprintf(['[\b' stringToPrint,']\b']) +0377 else +0378 fprintf(stringToPrint) +0379 end +0380 end
    Generated by m2html © 2005
    \ No newline at end of file diff --git a/doc/testing/unit_tests/importExportTests.html b/doc/testing/unit_tests/importExportTests.html index ed2c527e..9e9df366 100644 --- a/doc/testing/unit_tests/importExportTests.html +++ b/doc/testing/unit_tests/importExportTests.html @@ -42,7 +42,7 @@

    CROSS-REFERENCE INFORMATION ^
 
 <h2><a name=SUBFUNCTIONS ^

    +
  • function testExcelImport(testCase)
  • function testSBMLImport(testCase)
  • function testYAMLimport(testCase)
  • function testExcelExport(testCase)
  • function testSBMLExport(testCase)
  • function testYAMLexport(testCase)
  • SOURCE CODE ^

    0001 %run this test case with the command
    @@ -72,31 +72,52 @@ 

    SOURCE CODE ^end 0027 -0028 function testExcelExport(testCase) +0028 function testYAMLimport(testCase) 0029 sourceDir=fileparts(fileparts(fileparts(which(mfilename)))); -0030 load(fullfile(sourceDir,'testing','unit_tests','test_data','ecoli_textbook.mat'), 'model'); -0031 exportToExcelFormat(model,fullfile(sourceDir,'testing','unit_tests','test_data','_test.xlsx')); -0032 %File will not be exactly equal as it contains the current date and time, -0033 %so md5 or similar would not work. Just check whether file is reasonably -0034 %sized. -0035 s = dir(fullfile(sourceDir,'testing','unit_tests','test_data','_test.xlsx')); -0036 filesize = s.bytes; -0037 verifyTrue(testCase,filesize>17000); -0038 delete(fullfile(sourceDir,'testing','unit_tests','test_data','_test.xlsx')); -0039 end -0040 -0041 function testSBMLExport(testCase) -0042 sourceDir=fileparts(fileparts(fileparts(which(mfilename)))); -0043 load(fullfile(sourceDir,'testing','unit_tests','test_data','ecoli_textbook.mat'), 'model'); -0044 evalc('exportModel(model,fullfile(sourceDir,''testing'',''unit_tests'',''test_data'',''_test.xml''))'); -0045 %File will not be exactly equal as it contains the current date and time, -0046 %so md5 or similar would not work. Just check whether file is reasonably -0047 %sized. -0048 s = dir(fullfile(sourceDir,'testing','unit_tests','test_data','_test.xml')); -0049 filesize = s.bytes; -0050 verifyTrue(testCase,filesize>18500); -0051 delete(fullfile(sourceDir,'testing','unit_tests','test_data','_test.xml')); -0052 end

    +0030 yamlFile=fullfile(sourceDir,'tutorial','empty.yml'); +0031 evalc('model=readYAMLmodel(yamlFile)'); % Repress warnings +0032 load(fullfile(sourceDir,'testing','unit_tests','test_data','importExportResults.mat'), 'modelYAML'); +0033 verifyEqual(testCase,model,modelYAML) +0034 end +0035 +0036 function testExcelExport(testCase) +0037 sourceDir=fileparts(fileparts(fileparts(which(mfilename)))); +0038 load(fullfile(sourceDir,'testing','unit_tests','test_data','ecoli_textbook.mat'), 'model'); +0039 exportToExcelFormat(model,fullfile(sourceDir,'testing','unit_tests','test_data','_test.xlsx')); +0040 %File will not be exactly equal as it contains the current date and time, +0041 %so md5 or similar would not work. Just check whether file is reasonably +0042 %sized. +0043 s = dir(fullfile(sourceDir,'testing','unit_tests','test_data','_test.xlsx')); +0044 filesize = s.bytes; +0045 verifyTrue(testCase,filesize>17000); +0046 delete(fullfile(sourceDir,'testing','unit_tests','test_data','_test.xlsx')); +0047 end +0048 +0049 function testSBMLExport(testCase) +0050 sourceDir=fileparts(fileparts(fileparts(which(mfilename)))); +0051 load(fullfile(sourceDir,'testing','unit_tests','test_data','ecoli_textbook.mat'), 'model'); +0052 evalc('exportModel(model,fullfile(sourceDir,''testing'',''unit_tests'',''test_data'',''_test.xml''))'); +0053 %File will not be exactly equal as it contains the current date and time, +0054 %so md5 or similar would not work. Just check whether file is reasonably +0055 %sized. +0056 s = dir(fullfile(sourceDir,'testing','unit_tests','test_data','_test.xml')); +0057 filesize = s.bytes; +0058 verifyTrue(testCase,filesize>18500); +0059 delete(fullfile(sourceDir,'testing','unit_tests','test_data','_test.xml')); +0060 end +0061 +0062 function testYAMLexport(testCase) +0063 sourceDir=fileparts(fileparts(fileparts(which(mfilename)))); +0064 load(fullfile(sourceDir,'tutorial','empty.mat'), 'emptyModel'); +0065 evalc('writeYAMLmodel(emptyModel,fullfile(sourceDir,''testing'',''unit_tests'',''test_data'',''_test.yml''))'); +0066 %File will not be exactly equal as it contains the current date and time, +0067 %so md5 or similar would not work. Just check whether file is reasonably +0068 %sized. +0069 s = dir(fullfile(sourceDir,'testing','unit_tests','test_data','_test.yml')); +0070 filesize = s.bytes; +0071 verifyTrue(testCase,filesize>1350); +0072 delete(fullfile(sourceDir,'testing','unit_tests','test_data','_test.yml')); +0073 end
    Generated by m2html © 2005
    \ No newline at end of file diff --git a/installation/checkInstallation.m b/installation/checkInstallation.m index 68b73601..4a1784fa 100755 --- a/installation/checkInstallation.m +++ b/installation/checkInstallation.m @@ -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') @@ -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'); diff --git a/testing/unit_tests/importExportTests.m b/testing/unit_tests/importExportTests.m index f50cb79b..92165374 100755 --- a/testing/unit_tests/importExportTests.m +++ b/testing/unit_tests/importExportTests.m @@ -25,6 +25,14 @@ function testSBMLImport(testCase) verifyEqual(testCase,model,modelSBML) end +function testYAMLimport(testCase) +sourceDir=fileparts(fileparts(fileparts(which(mfilename)))); +yamlFile=fullfile(sourceDir,'tutorial','empty.yml'); +evalc('model=readYAMLmodel(yamlFile)'); % Repress warnings +load(fullfile(sourceDir,'testing','unit_tests','test_data','importExportResults.mat'), 'modelYAML'); +verifyEqual(testCase,model,modelYAML) +end + function testExcelExport(testCase) sourceDir=fileparts(fileparts(fileparts(which(mfilename)))); load(fullfile(sourceDir,'testing','unit_tests','test_data','ecoli_textbook.mat'), 'model'); @@ -50,3 +58,16 @@ function testSBMLExport(testCase) verifyTrue(testCase,filesize>18500); delete(fullfile(sourceDir,'testing','unit_tests','test_data','_test.xml')); end + +function testYAMLexport(testCase) +sourceDir=fileparts(fileparts(fileparts(which(mfilename)))); +load(fullfile(sourceDir,'tutorial','empty.mat'), 'emptyModel'); +evalc('writeYAMLmodel(emptyModel,fullfile(sourceDir,''testing'',''unit_tests'',''test_data'',''_test.yml''))'); +%File will not be exactly equal as it contains the current date and time, +%so md5 or similar would not work. Just check whether file is reasonably +%sized. +s = dir(fullfile(sourceDir,'testing','unit_tests','test_data','_test.yml')); +filesize = s.bytes; +verifyTrue(testCase,filesize>1350); +delete(fullfile(sourceDir,'testing','unit_tests','test_data','_test.yml')); +end \ No newline at end of file diff --git a/testing/unit_tests/test_data/importExportResults.mat b/testing/unit_tests/test_data/importExportResults.mat index 0a5df5ef1977e6c2d780509b52c8d408c8d71bf9..83f86ac8cbb213413f9c9f4229228d3f86a94e76 100644 GIT binary patch delta 833 zcmV-H1HSzD3ab&Ycm;nC0000h0{{ScoZVN=Qrj>PmJ^3UJEiHNhaTF|kse^MVQ6na zGL#(n=>Y9aZ@98ZJh7!zmPz2$L!Y7Nz6r0;$LNtqs1(aYHUT>>NoT5wV}Fvq-PLNn zS}y_sem)0aPTc3kRRM9UDQsxhg17?eV*m5@{@%?z6FgJneer+ixj=8k39trT93tlR zxJQYE=a_}+aX9L5eX>Ic1b zZh9_gV}dosZFUs-qYh!@u9&dz@WiSn4SJf*?BGZAd|F4N}o@hcdM;oH1)r zT<^eWA5GP-?_+;W-DRsQjDsG(Q2bU7|3!u`@s8xfVN}47vk38sVI^<%9(hUA<$=HC zZRObiIKz|JUbWYkt<`1g?MMzZioFkUzj-6~wYWscsu*_hnG^YZuaP``Y$*93a_oGS zu~T9ZC@=~!^a$h~43D-y?Hs^9W!}Imt%KDJxzbgGX?W^HRhdaJR^sfx37ls z^=RD{z^s_}Z9+YH{)HL;O59-B>AJK}AU%U&gcudhUh;@YQQQgf8!30*xZ4i%0oEH> zC3$v9-daiC`tA3mh(Gf3)1%D3NUXM^G{5afs3?Cv!rZgd-h@Yw{eigLr!=c`R z#;et1?p=R=s)12XOMG7i>HH@-@+^iRY1dckzL~jS{foRX3w@Gj6yRn3TTweVi~QBL zW~)cfdos?9d-T+lWIe8u8gF#YUT>E1uOXV`ElrpowsO|JkXm<)o0i?O?L*7b z+Y^Pq16gLHF5UCm9j&GWk-twf=?5{p-;4=(PRJ#?&cA^7TuluQQ>2WzOx8JH&OEJB@f> z%;-6j_@v{7Q2ZPyVuDX+o#XP3wPLTVt*rl7=UK00e7Rsc_L)Gp&ji~i&D}Eg{TQRK LXr1#1sfOI`>Z7dS delta 7 OcmZ22_=9Uh1uFmz9|G(E diff --git a/tutorial/empty.mat b/tutorial/empty.mat index 9529981fa53a9e84b643da7dd8c9180df38836be..936aead10021aa4ba5d135f22d305238eecc2904 100644 GIT binary patch delta 770 zcmV+d1O5ER1^Nb%gn#k^004NL-B!N>yJzwi6`Z@x_cz;z3N z4N*5lF+pl|g$=Dd76nIRetAee9M1b$;F)UwEdBxy=tkTKYk$xsgmRY$l*}NTl2~hv zFxTNp#uEs?WMGno3}5IFWx3hD0MTe1XW@|$s$L0I8j`T1^&hh1BwRGg)&orNq07@& z@vM24@WiK#rw+vcbRu{z>0k3w^Q{`vK3#^|3(L%bYHW#f-ru#xNj| z`xqYYf9f8=31y?$r(@-Jp!qeH_|^5v{;vykm>C@=V0OxD7`MlRvV-KhF)u7AGC>)u$RTaRz5r?NatFn`v{ z^Qy*^JYxl3etu20a_cw`djFPqn%@iKl5zG5;ylg7Nim*s<{})1;@V`&&vnVTMfVQO z#g+IS!|uqV69VZOj1$DDxP-O>a)B9lWBlqa>pCc@zwG%O+JBE*o=@W+aq7ymeja68 zQ^WH7J%6PBhl&GB-s?r*=SLvBpCndWs4{;TCTLZDBgdEcOn%aZgH`6Kmf_bx&*@jX zj|^dww^ed}_X_kibK{e^V>>;^>D#vEr^-Bcc6+wd-@O-p)p`D5mCLuDDEt*<5>zew z9wC*#ij7DUhSHo}=4Pq~Mo6T7v7&X!)hyw~~WvKy~JhL87xi4u;e-?_Br?X-q>Adj9tHCYz@XPbeEOQ zH`pQlC3KO__4h+L7Rhp*$KIIvFYq%PGupB!6$D0ECUvA|GJm^+YLVq+HWiw}6HAFD z-z-?zP>D+lW1DNQWwA`>xebrNsCfmh2tqg@>nG~CNbVt&^fCo~gMG_H(b?6`1@A`P=J*|&#Mr?h9@9Jdu!y5iZg^ze2`8>r!^IWSU z)`b#A@0zXly?>PNy?cK+LjA>ZUteo{ZB~3Ch79o{7krj+Jr(@;)9L;Zzmn=ApUSz> zJtMl#1G>~7uHUZl;aWairh<~!bsmr7Jwco_Xvqs(^4_)Ny)StS!t?tj_pyBVtgI;` znjNy98BPy6XUq2M#*7~;<4x7~+5^66eAhfR<$1vT*?(!yYa0)F&I-J0eqB?!|8XAZ z`aV1@?}d58IJ-4*UR!ZWEEZZtu}BiQCY90o(J*e^y~8VU5$`DxU5w>b#^pKBi&#mx zgtlhcrBFJ`#oK?W>sdqpP0!~f_;cTQKApeB@r^P)k2u#O7|-8x`hTuCyy3lG_y7EY z+20dl^G6A_=1-C$UX|ai@DZQmUpfe^lBbTv@33JwYIPqu(2%#)Fu%Js{(6=DAsz(b cFbqdQKy=#Vd9X7K!qLu?@Z0417S{Td&1qpV(EtDd diff --git a/tutorial/empty.yml b/tutorial/empty.yml new file mode 100644 index 00000000..aa0e9684 --- /dev/null +++ b/tutorial/empty.yml @@ -0,0 +1,64 @@ +--- +!!omap +- metaData: + id: "empty" + name: "Empty model structure" + date: "2024-10-17" + note: "For use in the RAVEN workshop" + geckoLight: "false" +- metabolites: + - !!omap + - id: "m1" + - name: "sucrose" + - compartment: "e" + - formula: "C12H22O11" + - !!omap + - id: "m2" + - name: "glucose" + - compartment: "e" + - formula: "C6H12O6" + - !!omap + - id: "m3" + - name: "fructose" + - compartment: "e" + - formula: "C6H12O6" + - !!omap + - id: "m4" + - name: "H2O" + - compartment: "e" + - formula: "H2O" +- reactions: + - !!omap + - id: "r1" + - name: "Breakdown of sucrose (invertase)" + - metabolites: !!omap + - m1: -1 + - m2: 1 + - m3: 1 + - m4: -1 + - lower_bound: 0 + - upper_bound: 1000 + - gene_reaction_rule: "g1" + - objective_coefficient: 1 +- genes: + - !!omap + - id: "g1" + - name: "g1" +- compartments: !!omap + - e: "extracellular" +- ec-rxns: + - !!omap + - id: "r1" + - kcat: 25 + - source: "standard" + - notes: "This is a test" + - eccodes: "1.2.3.4" + - enzymes: !!omap + - p1: 1 +- ec-enzymes: + - !!omap + - genes: "g1" + - enzymes: "p1" + - mw: 100 + - sequence: "ATCG" + - concs: 150 From 0e45b13ed19d568cc1122bb96931bcc9b03d2eec Mon Sep 17 00:00:00 2001 From: Eduard Kerkhoven Date: Thu, 17 Oct 2024 20:11:04 +0200 Subject: [PATCH 3/5] fix: exportForGit do not test COBRA if not exist --- doc/io/exportForGit.html | 180 ++++++++++++++++++++------------------- io/exportForGit.m | 4 +- 2 files changed, 94 insertions(+), 90 deletions(-) diff --git a/doc/io/exportForGit.html b/doc/io/exportForGit.html index f833f5d1..df04c927 100644 --- a/doc/io/exportForGit.html +++ b/doc/io/exportForGit.html @@ -147,95 +147,97 @@

    SOURCE CODE ^%Get versions or commits of toolboxes: 0072 RAVENver = getToolboxVersion('RAVEN','ravenCobraWrapper.m',mainBranchFlag); -0073 COBRAver = getToolboxVersion('COBRA','initCobraToolbox.m',mainBranchFlag); -0074 -0075 %Retrieve libSBML version: -0076 [ravenDir,prevDir]=findRAVENroot(); -0077 try % 5.17.0 and newer -0078 libSBMLver=OutputSBML_RAVEN; -0079 libSBMLver=libSBMLver.libSBML_version_string; -0080 catch % before 5.17.0 -0081 fid = fopen('tempModelForLibSBMLversion.xml','w+'); -0082 fclose(fid); -0083 evalc('[~,~,libSBMLver]=TranslateSBML_RAVEN(''tempModelForLibSBMLversion.xml'',0,0)'); -0084 libSBMLver=libSBMLver.libSBML_version_string; -0085 delete('tempModelForLibSBMLversion.xml'); -0086 end -0087 -0088 % Make models folder, no warnings if folder already exists -0089 if subDirs -0090 path=fullfile(path,'model'); -0091 filePath=strcat(path,filesep,{'txt','yml','mat','xlsx','xml'}); -0092 [~,~,~]=mkdir(path); -0093 for i = 1:length(formats) -0094 [~,~,~]=mkdir(fullfile(path,formats{i})); -0095 end -0096 else -0097 filePath=cell(1,5); filePath(:)={path}; -0098 end -0099 -0100 -0101 % Write TXT format -0102 if ismember('txt', formats) -0103 fid=fopen(fullfile(filePath{1},strcat(prefix,'.txt')),'w'); -0104 if COBRAtext==true -0105 eqns=constructEquations(model,model.rxns,false,false,false); -0106 eqns=strrep(eqns,' => ',' -> '); -0107 eqns=strrep(eqns,' <=> ',' <=> '); -0108 eqns=regexprep(eqns,'> $','>'); -0109 grRules=regexprep(model.grRules,'\((?!\()','( '); -0110 grRules=regexprep(grRules,'(?<!\))\)',' )'); -0111 else -0112 eqns=constructEquations(model,model.rxns); -0113 grRules=model.grRules; -0114 end -0115 fprintf(fid, 'Rxn name\tFormula\tGene-reaction association\tLB\tUB\tObjective\n'); -0116 for i = 1:numel(model.rxns) -0117 fprintf(fid, '%s\t', model.rxns{i}); -0118 fprintf(fid, '%s \t', eqns{i}); -0119 fprintf(fid, '%s\t', grRules{i}); -0120 fprintf(fid, '%6.2f\t%6.2f\t%6.2f\n', model.lb(i), model.ub(i), model.c(i)); -0121 end -0122 fclose(fid); -0123 end -0124 -0125 % Write YML format -0126 if ismember('yml', formats) -0127 writeYAMLmodel(model,fullfile(filePath{2},strcat(prefix,'.yml'))); -0128 end -0129 -0130 % Write MAT format -0131 if ismember('mat', formats) -0132 save(fullfile(filePath{3},strcat(prefix,'.mat')),'model'); -0133 end -0134 -0135 % Write XLSX format -0136 if ismember('xlsx', formats) -0137 exportToExcelFormat(model,fullfile(filePath{4},strcat(prefix,'.xlsx'))); -0138 end -0139 -0140 % Write XML format -0141 if ismember('xml', formats) -0142 exportModel(model,fullfile(filePath{5},strcat(prefix,'.xml')),neverPrefixIDs); -0143 end -0144 -0145 %Save file with versions: -0146 fid = fopen(fullfile(path,'dependencies.txt'),'wt'); -0147 fprintf(fid,['MATLAB\t' version '\n']); -0148 fprintf(fid,['libSBML\t' libSBMLver '\n']); -0149 fprintf(fid,['RAVEN_toolbox\t' RAVENver '\n']); -0150 if ~isempty(COBRAver) -0151 fprintf(fid,['COBRA_toolbox\t' COBRAver '\n']); -0152 end -0153 if isfield(model,'modelVersion') -0154 fields = fieldnames(model.modelVersion); -0155 for i = 1:length(fields) -0156 value = model.modelVersion.(fields{i}); -0157 fprintf(fid,[fields{i} '\t' num2str(value) '\n']); -0158 end -0159 end -0160 fclose(fid); -0161 end +0073 if exist('initCobraToolbox.m','file') +0074 COBRAver = getToolboxVersion('COBRA','initCobraToolbox.m',mainBranchFlag); +0075 end +0076 +0077 %Retrieve libSBML version: +0078 [ravenDir,prevDir]=findRAVENroot(); +0079 try % 5.17.0 and newer +0080 libSBMLver=OutputSBML_RAVEN; +0081 libSBMLver=libSBMLver.libSBML_version_string; +0082 catch % before 5.17.0 +0083 fid = fopen('tempModelForLibSBMLversion.xml','w+'); +0084 fclose(fid); +0085 evalc('[~,~,libSBMLver]=TranslateSBML_RAVEN(''tempModelForLibSBMLversion.xml'',0,0)'); +0086 libSBMLver=libSBMLver.libSBML_version_string; +0087 delete('tempModelForLibSBMLversion.xml'); +0088 end +0089 +0090 % Make models folder, no warnings if folder already exists +0091 if subDirs +0092 path=fullfile(path,'model'); +0093 filePath=strcat(path,filesep,{'txt','yml','mat','xlsx','xml'}); +0094 [~,~,~]=mkdir(path); +0095 for i = 1:length(formats) +0096 [~,~,~]=mkdir(fullfile(path,formats{i})); +0097 end +0098 else +0099 filePath=cell(1,5); filePath(:)={path}; +0100 end +0101 +0102 +0103 % Write TXT format +0104 if ismember('txt', formats) +0105 fid=fopen(fullfile(filePath{1},strcat(prefix,'.txt')),'w'); +0106 if COBRAtext==true +0107 eqns=constructEquations(model,model.rxns,false,false,false); +0108 eqns=strrep(eqns,' => ',' -> '); +0109 eqns=strrep(eqns,' <=> ',' <=> '); +0110 eqns=regexprep(eqns,'> $','>'); +0111 grRules=regexprep(model.grRules,'\((?!\()','( '); +0112 grRules=regexprep(grRules,'(?<!\))\)',' )'); +0113 else +0114 eqns=constructEquations(model,model.rxns); +0115 grRules=model.grRules; +0116 end +0117 fprintf(fid, 'Rxn name\tFormula\tGene-reaction association\tLB\tUB\tObjective\n'); +0118 for i = 1:numel(model.rxns) +0119 fprintf(fid, '%s\t', model.rxns{i}); +0120 fprintf(fid, '%s \t', eqns{i}); +0121 fprintf(fid, '%s\t', grRules{i}); +0122 fprintf(fid, '%6.2f\t%6.2f\t%6.2f\n', model.lb(i), model.ub(i), model.c(i)); +0123 end +0124 fclose(fid); +0125 end +0126 +0127 % Write YML format +0128 if ismember('yml', formats) +0129 writeYAMLmodel(model,fullfile(filePath{2},strcat(prefix,'.yml'))); +0130 end +0131 +0132 % Write MAT format +0133 if ismember('mat', formats) +0134 save(fullfile(filePath{3},strcat(prefix,'.mat')),'model'); +0135 end +0136 +0137 % Write XLSX format +0138 if ismember('xlsx', formats) +0139 exportToExcelFormat(model,fullfile(filePath{4},strcat(prefix,'.xlsx'))); +0140 end +0141 +0142 % Write XML format +0143 if ismember('xml', formats) +0144 exportModel(model,fullfile(filePath{5},strcat(prefix,'.xml')),neverPrefixIDs); +0145 end +0146 +0147 %Save file with versions: +0148 fid = fopen(fullfile(path,'dependencies.txt'),'wt'); +0149 fprintf(fid,['MATLAB\t' version '\n']); +0150 fprintf(fid,['libSBML\t' libSBMLver '\n']); +0151 fprintf(fid,['RAVEN_toolbox\t' RAVENver '\n']); +0152 if ~isempty(COBRAver) +0153 fprintf(fid,['COBRA_toolbox\t' COBRAver '\n']); +0154 end +0155 if isfield(model,'modelVersion') +0156 fields = fieldnames(model.modelVersion); +0157 for i = 1:length(fields) +0158 value = model.modelVersion.(fields{i}); +0159 fprintf(fid,[fields{i} '\t' num2str(value) '\n']); +0160 end +0161 end +0162 fclose(fid); +0163 end
    Generated by m2html © 2005
    \ No newline at end of file diff --git a/io/exportForGit.m b/io/exportForGit.m index 0f04406d..ad5ea1a4 100755 --- a/io/exportForGit.m +++ b/io/exportForGit.m @@ -70,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(); From 58f4ef2fde45e1670a6eda046907d06c743277d3 Mon Sep 17 00:00:00 2001 From: Eduard Kerkhoven Date: Thu, 17 Oct 2024 20:12:46 +0200 Subject: [PATCH 4/5] fix: readYAMLmodel correct rxnEnzMat --- doc/io/readYAMLmodel.html | 2 +- io/readYAMLmodel.m | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/io/readYAMLmodel.html b/doc/io/readYAMLmodel.html index a76b6b12..348b94b7 100644 --- a/doc/io/readYAMLmodel.html +++ b/doc/io/readYAMLmodel.html @@ -682,7 +682,7 @@

    SOURCE CODE ^%Parse ec-codes 0631 if ~isempty(ecGecko) diff --git a/io/readYAMLmodel.m b/io/readYAMLmodel.m index 19095d6c..dd5e692f 100755 --- a/io/readYAMLmodel.m +++ b/io/readYAMLmodel.m @@ -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) From 7a52e32afa8c1a795210612c75780b4bde3b1fc5 Mon Sep 17 00:00:00 2001 From: Eduard Kerkhoven Date: Thu, 17 Oct 2024 23:33:22 +0200 Subject: [PATCH 5/5] fix: importExportTests less strict filesize test --- doc/testing/unit_tests/importExportTests.html | 2 +- testing/unit_tests/importExportTests.m | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/testing/unit_tests/importExportTests.html b/doc/testing/unit_tests/importExportTests.html index 9e9df366..6e32b08f 100644 --- a/doc/testing/unit_tests/importExportTests.html +++ b/doc/testing/unit_tests/importExportTests.html @@ -115,7 +115,7 @@

    SOURCE CODE ^%sized. 0069 s = dir(fullfile(sourceDir,'testing','unit_tests','test_data','_test.yml')); 0070 filesize = s.bytes; -0071 verifyTrue(testCase,filesize>1350); +0071 verifyTrue(testCase,filesize>1290); 0072 delete(fullfile(sourceDir,'testing','unit_tests','test_data','_test.yml')); 0073 end
    Generated by m2html © 2005
    diff --git a/testing/unit_tests/importExportTests.m b/testing/unit_tests/importExportTests.m index 92165374..4db6eb9f 100755 --- a/testing/unit_tests/importExportTests.m +++ b/testing/unit_tests/importExportTests.m @@ -68,6 +68,6 @@ function testYAMLexport(testCase) %sized. s = dir(fullfile(sourceDir,'testing','unit_tests','test_data','_test.yml')); filesize = s.bytes; -verifyTrue(testCase,filesize>1350); +verifyTrue(testCase,filesize>1290); delete(fullfile(sourceDir,'testing','unit_tests','test_data','_test.yml')); end \ No newline at end of file