-
Notifications
You must be signed in to change notification settings - Fork 54
/
checkInstallation.m
159 lines (141 loc) · 5.67 KB
/
checkInstallation.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
function checkInstallation()
% checkInstallation
% The purpose of this function is to check if all necessary functions are
% installed and working. It also checks whether there are any functions
% with overlapping names between RAVEN and other toolboxes or
% user-defined functions, which are accessible from MATLAB pathlist
%
% Usage: checkInstallation()
%Check if RAVEN is in the MATLAB path list
paths=textscan(path,'%s','delimiter', pathsep);
paths=paths{1};
%Get the RAVEN path
[ST, I]=dbstack('-completenames');
[ravenDir,~,~]=fileparts(fileparts(ST(I).file));
%Print the RAVEN version if it is not the development version
if exist(fullfile(ravenDir,'version.txt'), 'file') == 2
fprintf(['\n*** THE RAVEN TOOLBOX v.' fgetl(fopen(fullfile(ravenDir,'version.txt'))) ' ***\n\n']);
else
fprintf('\n*** THE RAVEN TOOLBOX - DEVELOPMENT VERSION ***\n\n');
end
fprintf(['MATLAB R' version('-release') ' detected\n\n']);
fprintf('Checking if RAVEN is on the MATLAB path...\t\t\t\t\t\t\t\t\t');
if ismember(ravenDir,paths)
fprintf('OK\n');
else
fprintf('OK (just added)\n');
subpath=regexp(genpath(ravenDir),pathsep,'split'); %List all subdirectories
pathsToKeep=cellfun(@(x) isempty(strfind(x,'.git')),subpath) & cellfun(@(x) isempty(strfind(x,'doc')),subpath);
addpath(strjoin(subpath(pathsToKeep),pathsep));
savepath
end
%Add the required classes to the static Java path if not already added
addJavaPaths();
excelFile=fullfile(ravenDir,'tutorial','empty.xlsx');
xmlFile=fullfile(ravenDir,'tutorial','empty.xml');
matFile=fullfile(ravenDir,'tutorial','empty.mat');
%Check if it is possible to parse an Excel file
fprintf('Checking if it is possible to parse a model in Microsoft Excel format...\t');
try
importExcelModel(excelFile,false,false,true);
fprintf('OK\n');
catch
fprintf('Not OK\n');
end
%Check if it is possible to import an SBML model using libSBML
fprintf('Checking if it is possible to import an SBML model using libSBML...\t\t\t');
try
importModel(xmlFile);
try
libSBMLver=OutputSBML; % Only works in libSBML 5.17.0+
fprintf('OK\n');
catch
fprintf(['Not OK\n\n'...
'An older libSBML version was found, update to version 5.17.0 or higher\n'...
'for a significant improvement of model import\n\n']);
end
catch
fprintf(['Not OK\nTo import SBML models, download libSBML from\n'...
'http://sbml.org/Software/libSBML/Downloading_libSBML and add to MATLAB path\n']);
end
%Define values for keepSolver and workingSolvers, needed for solver
%functionality check
keepSolver=false;
workingSolvers='';
%Get current solver. Set it to 'none', if it is not set
if ~ispref('RAVEN','solver')
fprintf('Solver found in preferences... NONE\n');
setRavenSolver('none');
curSolv=getpref('RAVEN','solver');
else
curSolv=getpref('RAVEN','solver');
fprintf(['Solver found in preferences... ',curSolv,'\n']);
end
%Check if it is possible to solve an LP problem using different solvers
solver={'gurobi','cobra'};
for i=1:numel(solver)
fprintf(['Checking if it is possible to solve an LP problem using ',solver{i},'...\t\t\t']);
try
setRavenSolver(solver{i});
load(matFile);
solveLP(emptyModel);
workingSolvers=strcat(workingSolvers,';',solver{i});
fprintf('OK\n');
if strcmp(curSolv,solver{i})
keepSolver=true;
end
catch
fprintf('Not OK\n');
end
end
if keepSolver
%The solver set in curSolv is functional, so the settings are restored
%to the ones which were set before running checkInstallation
setRavenSolver(curSolv);
fprintf(['Preferred solver... KEPT\nSolver saved as preference... ',curSolv,'\n\n']);
elseif ~isempty(workingSolvers)
%There are working solvers, but the none of them is the solver defined
%by curSolv. The first working solver is therefore set as RAVEN solver
workingSolvers=regexprep(workingSolvers,'^;','');
workingSolvers=regexprep(workingSolvers,';.+$','');
%Only one working solver should be left by now in workingSolvers
setRavenSolver(workingSolvers);
fprintf(['Preferred solver... NEW\nSolver saved as preference... ',workingSolvers,'\n\n']);
else
%No functional solvers were found, so the setting is restored back to
%original
setRavenSolver(curSolv);
fprintf(['WARNING: No working solver was found!\n'...
'Install the solver, set it using setRavenSolver(''solverName'') and run checkInstallation again\n'...
'Available solverName options are ''gurobi'' and ''cobra''\n\n']);
end
fprintf('Checking essential binary executables:\n');
fprintf('NOTE: Broken binary executables <strong>must be fixed</strong> before running RAVEN\n');
fprintf('\tBLAST+... ');
res=runtests('blastPlusTests.m','OutputDetail',0);
interpretResults(res);
fprintf('\tDIAMOND... ');
res=runtests('diamondTests.m','OutputDetail',0);
interpretResults(res);
fprintf('\tHMMER... ');
res=runtests('hmmerTests.m','OutputDetail',0);
interpretResults(res);
fprintf('Checking non-essential/development binary executables:\n');
fprintf('NOTE: Only fix these binaries if planning to use KEGG FTP dump files in getKEGGModelForOrganism\n');
fprintf('\tCD-HIT... ');
res=runtests('cdhitTests.m','OutputDetail',0);
interpretResults(res);
fprintf('\tMAFFT... ');
res=runtests('mafftTests.m','OutputDetail',0);
interpretResults(res);
fprintf('Checking whether RAVEN functions are non-redundant across MATLAB path...\t');
checkFunctionUniqueness();
fprintf('\n*** checkInstallation complete ***\n\n');
end
function interpretResults(results)
if results.Failed==0 && results.Incomplete==0
fprintf('OK\n');
else
fprintf('Not OK! Download/compile the binary and rerun checkInstallation\n');
end
end