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/io/exportForGit.html b/doc/io/exportForGit.html index 74a90f62..df04c927 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,139 @@ 

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 +0071 %Get versions or commits of toolboxes: +0072 RAVENver = getToolboxVersion('RAVEN','ravenCobraWrapper.m',mainBranchFlag); +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 -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

+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/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/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/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/doc/testing/unit_tests/importExportTests.html b/doc/testing/unit_tests/importExportTests.html index ed2c527e..6e32b08f 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>1290); +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/io/exportForGit.m b/io/exportForGit.m index d90f5b04..ad5ea1a4 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; @@ -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(); @@ -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: 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) diff --git a/testing/unit_tests/importExportTests.m b/testing/unit_tests/importExportTests.m index f50cb79b..4db6eb9f 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>1290); +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 0a5df5ef..83f86ac8 100644 Binary files a/testing/unit_tests/test_data/importExportResults.mat and b/testing/unit_tests/test_data/importExportResults.mat differ diff --git a/tutorial/empty.mat b/tutorial/empty.mat index 9529981f..936aead1 100644 Binary files a/tutorial/empty.mat and b/tutorial/empty.mat differ 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 diff --git a/version.txt b/version.txt index 10c2c0c3..5cc82157 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -2.10.0 +2.10.1 \ No newline at end of file