Utilities#

MATLAB functions in GECKO/src/utilities of the GECKO toolbox.

Functions#

Function

Summary

buildGECKOdoc

Update HTML documentation for all GECKO MATLAB functions.

createGECKOproject

Create a basic project structure for GECKO.

findGECKOroot

Find the root of the GECKO directory.

parseGECKOargs

Resolve optional arguments passed positionally or by name.

upgradeGECKOproject

Bring a GECKO 3 project to the GECKO 4 layout.

Reference#

buildGECKOdoc#

function buildGECKOdoc()

Update HTML documentation for all GECKO MATLAB functions.

Updates HTML documentation files for all GECKO MATLAB functions. Uses the m2html functions that are provided with RAVEN.

Examples

buildGECKOdoc();

createGECKOproject#

function createGECKOproject(varargin)

Create a basic project structure for GECKO.

Creates a basic project structure for GECKO. If a project with the same name exists, the project will not be created.

Name-Value Arguments

name : char

a name for the folder structure used in GECKO. Also creates a basic model adapter, which must be manually adjusted. If not defined, a dialog box will appear.

path : char

a path where to create the folder. If not defined, a dialog box will appear.

adapterFormat : char

'toml' (default) writes model_adapter.toml, which GECKO and geckopy both read (see TomlAdapter); 'class' writes an adapter class Adapter.m instead.

Examples

% optional arguments may be given positionally or as name-value pairs:
createGECKOproject(name, path);
createGECKOproject('name', name);
createGECKOproject('name', name, 'adapterFormat', 'class');

findGECKOroot#

function [geckoPath, prevDir] = findGECKOroot()

Find the root of the GECKO directory.

Finds the root of the GECKO directory, by searching for the path to GECKOInstaller.m. Can also record the current directory, in case a function will use the geckoPath to navigate to a precise folder, and it should return to the previous directory afterwards.

Returns

geckoPath : char

path to the root of the GECKO directory.

prevDir : char

the current directory at the time of the call, recorded so that a function can return to it afterwards.

parseGECKOargs#

function args = parseGECKOargs(rawArgs, spec)

Resolve optional arguments passed positionally or by name.

Helper that lets a GECKO function accept its optional arguments either in the traditional positional order or as name-value pairs, without losing backward compatibility. The required leading arguments stay explicit in the function signature; the optional tail is collected into varargin and passed here together with a specification of the optional parameters.

Parameters

rawArgs : cell

the function's varargin, i.e. whatever was supplied after the required positional arguments.

spec : cell

an N-by-2 or N-by-3 cell array describing the optional parameters, one per row:

  • column 1 : parameter name (char).

  • column 2 : default value, used when the parameter is not supplied.

  • column 3 : optional validator, a function handle that is called with the resolved value and should error on an invalid value. Use [] for no validation.

Returns

args : struct

a struct with one field per parameter name, holding the resolved value.

Notes

The calling convention is detected from rawArgs: it is treated as name- value pairs only when it has an even number of elements AND every element in a name position is a string matching one of the declared parameter names. Otherwise it is treated as positional and assigned in the order of the spec. A call therefore uses either the positional or the name-value form for the optional tail, not a mix of the two. When an optional tail value could itself be a string equal to a parameter name, use the explicit name-value form to remove the ambiguity.

Examples

% inside makeEcModel(model, varargin):
p = parseGECKOargs(varargin, { ...
    'geckoLight',   false; ...
    'modelAdapter', []});
geckoLight   = p.geckoLight;
modelAdapter = p.modelAdapter;

% the caller may then use either form:
makeEcModel(model, true, adapter)                  % positional
makeEcModel(model, 'geckoLight', true)             % named

upgradeGECKOproject#

function report = upgradeGECKOproject(projectPath, varargin)

Bring a GECKO 3 project to the GECKO 4 layout.

Lists, and with 'dryRun', false carries out, the steps that bring a project made with GECKO 3 (or an earlier GECKO 4) to the current layout:

  1. adapter: an adapter class without model_adapter.toml gets one (convertAdapterToToml). Methods the class overrides are listed: they need carrying over by hand. The class itself stays.

  2. custom kcats: data/customKcats.tsv becomes data/kcats/custom.tsv (convertCustomKcats).

  3. stored predictions: data/DLKcat.tsv and stored OpenKineticsPredictor results become kcat source files (kcatsFromDLKcat, kcatsFromOKP with 'useStored'), without running anything. Steps 2 and 3 need the full ecModel the custom kcats and predictions are for ('ecModel'); without it they are listed and skipped.

  4. saved ecModels: models/*.yml ecModels made with GECKO 3 get their protein usage and pool reactions turned forward (upgradeEcModel).

  5. project_format = 4 is written to model_adapter.toml.

  6. scripts: lines of the project's .m files that call renamed or replaced functions are listed, not changed.

A file that is replaced or converted is first moved to legacy// in the project, keeping its place in the folder tree. Steps that are already done are left out, so the function can run again. geckopy has the same as geckopy upgrade (upgrade_project).

Parameters

projectPath : char

the project folder.

Name-Value Arguments

dryRun : logical

only list the steps (default true).

ecModel : struct

the ecModel the stored predictions were made for (step 3).

Returns

report : table

one row per step: step, status ('to do', 'done', 'skipped', 'failed', 'by hand') and note; script lines are listed one per row.

Examples

upgradeGECKOproject(projectPath)                    % see what it would do
upgradeGECKOproject(projectPath, 'dryRun', false, 'ecModel', ecModel)

See also

convertAdapterToToml, convertCustomKcats, upgradeEcModel, createGECKOproject