Home > src > geckomat > gather_kcats > runDLKcat.m

runDLKcat

PURPOSE ^

runDLKcat

SYNOPSIS ^

function runDLKcat(modelAdapter,filePath)

DESCRIPTION ^

 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.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function runDLKcat(modelAdapter,filePath)
0002 % runDLKcat
0003 %   Runs DLKcat to predict kcat values from a Docker image. Once DLKcat is succesfully
0004 %   run, the DLKcatFile will be overwritten with the DLKcat
0005 %   output in the model-specific 'data' sub-folder taken from modelAdapter
0006 %   (e.g. GECKO/tutorials/tutorial_yeast-GEM/data/DLKcat.tsv)
0007 %
0008 % Input
0009 %   modelAdapter    a loaded model adapter. (Optional, will otherwise use
0010 %                   the default model adapter)
0011 %   filePath        path to the DLKcat.tsv file. (Optional, will otherwise
0012 %                   assume data/DLKcat.tsv)
0013 %
0014 %   NOTE: 1. Requires Docker to be installed, and Docker Desktop running. Visit "https://www.docker.com"
0015 %         2. Runtime will depend on whether the image is to be downloaded or not.
0016 
0017 if nargin < 1 || isempty(modelAdapter)
0018     modelAdapter = ModelAdapterManager.getDefault();
0019     if isempty(modelAdapter)
0020         error('Either send in a modelAdapter or set the default model adapter in the ModelAdapterManager.')
0021     end
0022 end
0023 params = modelAdapter.params;
0024 % Make sure path is full, not relative
0025 [~, params.path] = fileattrib(params.path);
0026 params.path=params.path.Name;
0027 
0028 if nargin < 2 || isempty(filePath)
0029     filePath = fullfile(params.path,'data','DLKcat.tsv');
0030 elseif strcmp(filePath(end),{'\','/'})
0031     filePath = fullfile(filePath,'DLKcat.tsv');
0032 end
0033 filePath = checkFileExistence(filePath,1);
0034 
0035 copyfile(filePath, fullfile(params.path,'data','tempDLKcat.tsv'));
0036     
0037 
0038 %% Check and install requirements
0039 % On macOS, Docker might not be properly loaded if MATLAB is started via
0040 % launcher and not terminal.
0041 if ismac
0042     setenv('PATH', strcat('/usr/local/bin', ':', getenv("PATH")));
0043 end
0044 
0045 % Check if Docker is installed
0046 [checks.docker.status, checks.docker.out] = system('docker --version');
0047 if checks.docker.status ~= 0
0048     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.')
0049 end
0050 
0051 disp('Running DLKcat prediction, this may take many minutes, especially the first time.')
0052 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"']);
0053 delete(fullfile(params.path,'/data/tempDLKcat.tsv'));
0054 
0055 if status == 0 && exist(fullfile(params.path,'data/tempDLKcatOutput.tsv'))
0056     movefile(fullfile(params.path,'/data/tempDLKcatOutput.tsv'), filePath);
0057     disp('DKLcat prediction completed.');
0058 else    
0059     error('DLKcat encountered an error or it did not create any output file.')
0060 end
0061

Generated by m2html © 2005