-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathrunDLKcat.m
61 lines (52 loc) · 2.59 KB
/
runDLKcat.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
function runDLKcat(modelAdapter,filePath)
% runDLKcat
% Runs DLKcat to predict kcat values from a Docker image. Once DLKcat is succesfully
% run, the DLKcatFile will be overwritten with the DLKcat
% output in the model-specific 'data' sub-folder taken from modelAdapter
% (e.g. GECKO/tutorials/tutorial_yeast-GEM/data/DLKcat.tsv)
%
% Input
% modelAdapter a loaded model adapter. (Optional, will otherwise use
% the default model adapter)
% filePath path to the DLKcat.tsv file. (Optional, will otherwise
% assume data/DLKcat.tsv)
%
% NOTE: 1. Requires Docker to be installed, and Docker Desktop running. Visit "https://www.docker.com"
% 2. Runtime will depend on whether the image is to be downloaded or not.
if nargin < 1 || isempty(modelAdapter)
modelAdapter = ModelAdapterManager.getDefault();
if isempty(modelAdapter)
error('Either send in a modelAdapter or set the default model adapter in the ModelAdapterManager.')
end
end
params = modelAdapter.params;
% Make sure path is full, not relative
[~, params.path] = fileattrib(params.path);
params.path=params.path.Name;
if nargin < 2 || isempty(filePath)
filePath = fullfile(params.path,'data','DLKcat.tsv');
elseif strcmp(filePath(end),{'\','/'})
filePath = fullfile(filePath,'DLKcat.tsv');
end
filePath = checkFileExistence(filePath,1);
copyfile(filePath, fullfile(params.path,'data','tempDLKcat.tsv'));
%% Check and install requirements
% On macOS, Docker might not be properly loaded if MATLAB is started via
% launcher and not terminal.
if ismac
setenv('PATH', strcat('/usr/local/bin', ':', getenv("PATH")));
end
% Check if Docker is installed
[checks.docker.status, checks.docker.out] = system('docker --version');
if checks.docker.status ~= 0
error('Cannot find Docker, make sure it is installed. If it is, it might be required to start Matlab from the command-line instead of the launcher in order for Docker to be detected and used.')
end
disp('Running DLKcat prediction, this may take many minutes, especially the first time.')
status = system(['docker run --rm -v "' fullfile(params.path,'/data') '":/data ghcr.io/sysbiochalmers/dlkcat-gecko:0.1 /bin/bash -c "python DLKcat.py /data/tempDLKcat.tsv /data/tempDLKcatOutput.tsv"']);
delete(fullfile(params.path,'/data/tempDLKcat.tsv'));
if status == 0 && exist(fullfile(params.path,'data/tempDLKcatOutput.tsv'))
movefile(fullfile(params.path,'/data/tempDLKcatOutput.tsv'), filePath);
disp('DKLcat prediction completed.');
else
error('DLKcat encountered an error or it did not create any output file.')
end