Home > src > geckomat > utilities > startGECKOproject.m

startGECKOproject

PURPOSE ^

startGECKOproject

SYNOPSIS ^

function startGECKOproject(name, path)

DESCRIPTION ^

 startGECKOproject
   Function that create a basic project structure for GECKO. If a project
   with the same name exits, the project will not be created

 Input:
   name               an name for the folder struture used in GECKO. Also
                      creates a basic adapter class, which must be manually
                      adjusted. If not defined, a dialog box will appear.
   path               a path where to create the folder. If not defined, a
                      dialog box will appear.

 Usage:
   startGECKOproject(name, path)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function startGECKOproject(name, path)
0002 % startGECKOproject
0003 %   Function that create a basic project structure for GECKO. If a project
0004 %   with the same name exits, the project will not be created
0005 %
0006 % Input:
0007 %   name               an name for the folder struture used in GECKO. Also
0008 %                      creates a basic adapter class, which must be manually
0009 %                      adjusted. If not defined, a dialog box will appear.
0010 %   path               a path where to create the folder. If not defined, a
0011 %                      dialog box will appear.
0012 %
0013 % Usage:
0014 %   startGECKOproject(name, path)
0015 
0016 if nargin < 1 || isempty(name)
0017     prompt = {'Please provide a project name (e.g. ecYeastGEM)'};
0018     dlgtitle = 'Project name';
0019     dims = [1 100];
0020     definput = {'ecModelGEM'};
0021     opts.Interpreter = 'tex';
0022     name = inputdlg(prompt,dlgtitle,dims,definput,opts);
0023     name = char(name);
0024 end
0025 
0026 if nargin < 2 || isempty(path)
0027     path = uigetdir('Project Folder path');
0028 end
0029 
0030 fullPath = fullfile(path, name);
0031 % Validate if the project does not exits
0032 if ~exist(fullPath, 'dir')
0033     % Create the subfolder
0034     dir = {'code', 'data', 'models', 'output'};
0035     for i = 1:length(dir)
0036         status = mkdir(fullPath, dir{i});
0037         fid = fopen(fullfile(fullPath, dir{i}, '.keep'), 'w');
0038         fclose(fid);
0039     end
0040 
0041     % Read the template adapter class
0042     fid = fopen(fullfile(findGECKOroot, 'src', 'geckomat', ...
0043         'model_adapter', 'adapterTemplate.m'));
0044     f = fread(fid, '*char')';
0045     fclose(fid);
0046 
0047     % Replace key values
0048     f = strrep(f, 'KEY_CLASSNAME', [name 'Adapter']);
0049     f = strrep(f, 'KEY_PATH', path);
0050     f = strrep(f, 'KEY_NAME', name);
0051 
0052     % Save the class file
0053     filename = fullfile(path, name, [name 'Adapter.m']);
0054     fid = fopen(filename, 'w');
0055     fwrite(fid, f);
0056     fclose(fid);
0057 else
0058     printOrange('WARNING: A project with the same name exits at the same location. The project was not created.\n');
0059 end
0060 cd(fullPath)
0061 end

Generated by m2html © 2005