Install

adaptMacPath()[source]

Adapts the path for binaries on a mac with Sierra/High Sierra or higher and Anything below.

Usage

adaptMacPath();
addCOBRABinaryPathToSystemPath()[source]

Sets up the path to system executables shipped by the toolbox.

Usage

addCOBRABinaryPathToSystemPath()
addKeyToKnownHosts(siteName)[source]

Checks if the public key to site.ext exists If the public key of the site.ext does not exist, adds the public key to the known hosts

Usage

keyAdded = addKeyToKnownHosts()

Input

  • siteName – Name of the site for which the public key shall be added (default: github.com)

Output

  • keyAdded – Boolean (true if key has been added successfully or exists)

set the default site name

checkCNAinstallation(printLevel)[source]

checks the installation of CellNetAnalyzer

Usage

status = checkCNAinstallation(printLevel)

Input

  • printLevel – verbose level (default: 1)

Output

  • status – Boolean if CellNetAnalyzer is installed properly
getFilesInDir(varargin)[source]

List all files in the supplied (git tracked) Directory with their absolute path name based on the git ls-file command. If the directory is not git controlled, the type is assumed to be ‘all’ and all files (except for .git files will be returned).

Usage

files = getFilesInDir(varargin)

Optional input

  • varargin – Options as ‘ParameterName’ value pairs with the following options:

    • dirToList: the directory to list the files for (default: the current working directory)

    • type: Git type of files to return

      • tracked: Only tracked files
      • ignored: Only git ignored files excluding files that are tracked but ignored (specified in .gitignore). If the folder is not controlled by git, all will be used.
      • untracked: anything that is not ignored and not tracked (new files)
      • all: all files except for the git specific files (e.g. .git, .gitignore etc).
      • ignoredByCOBRA: use the COBRA Toolbox .gitignore file. Only return those files that match patterns specified there. Slower than ignored since all files have to be manually checked against the expressions specified in the .gitignore file, but available on all folders (default: all)
    • restrictToPattern - give a regexp pattern to filter the files, this option is ignored if empty (default: ‘’, i.e. ignored)

    • checkSubFolders - check the subfolders of the current directory (default: `true)

    • printLevel

      • 0: No print out (default)
      • 1: print Information

Output

  • files – A Cell Array of files with absolute file pathes. present in this folder matching the options choosen.

Example

% get all m files in the source folder:
files = getFilesInDir('dirToList', [CBTDIR filesep 'src'], 'restrictToPattern', '\.m$');

% Get the git tracked files in the test Directory.
files = getFilesInDir('dirToList', [CBTDIR filesep 'test'], 'type', 'tracked');

% get all git tracked files  which start with "MyFile" in the current directory
files = getFilesInDir('type', 'tracked', 'restrictToPattern', '^MyFile');

% get only the gitIgnored files in the current folder
files = getFilesInDir('type', 'ignored');
getGitBashVersion()[source]

On Windows, this function determines the version of gitBash. This function can only be run on Windows, and throws an error when run on a UNIX system.

Usage

[installedVersion, installedVersionNum] = getGitBashVersion()

Outputs

  • installedVersion – String of installed version of gitBash in the form 2.13.2
  • installedVersionNum – Integer of installedVersion, e.g. 2132
getIgnoredFiles(ignorepatterns, filterpatterns)[source]

Get all files/patterns which are ignored by git in the COBRA Toolbox directory.. Usage

ignoreFiles = getIgnoredFiles()

Optional inputs

  • ignorePatterns – A cell array of regexp patterns indicating files which are not to be listed
  • filterpatterns – A cell array of regexp patterns identifying those files which should be returned after ignoring.

Output

  • ignoredFiles – All files (and patterns) indicated as ignored in the gitignore file.
installDevTools(repoName)[source]

checks if the MATLAB.devTools are already present and installs the MATLAB.devTools next to the cloned folder cobratoolbox (if not present yet)

Usage

installDevTools(repoName)

Optional input

  • repoName – Name of the repository (default: ‘opencobra/cobratoolbox’)

Note

In order to install the devTools, please make sure that the SSH key is configured properly as explained here. The full documentation of the MATLAB.devTools is here.

installGitBash()[source]

This function wraps the installer for PortableGit and checks for available updates. This function can only be run on Windows, and throws an error when run on a UNIX system.

Usage

installGitBash()
portableGitSetup(gitBashVersion, removeFlag)[source]

This function downloads the latest version of PortableGit on Windows (archive), extracts the folder and moves the contents to the hidden .tmp folder in a folder called PortableGit-a.bc.c This function can only be run on Windows, and throws an error when run on a UNIX system.

Usage

portableGitSetup(gitBashVersion, removeFlag)

Input

  • removeFlag – Flag to remove old versions from the path or not
    • 0: install, don’t remove anything
    • 1: install, remove paths in registry
    • 2: don’t install gitBash, remove .exe file and paths in registry
    • 3: don’t install gitBash, remove everything including unpacked archives (to be implemented)
prepareTest(varargin)[source]

Checks the prerequisites of the test, and returns solvers depending on the input parameters. If the requirements are NOT met, a COBRA:RequirementsNotMet error is thrown.

Usage

[solversToUse] = prepareTest(varargin)

Optional input

  • varaginParameterName value pairs with the following options:
    • toolboxes or requiredToolboxes: Names of required toolboxes (the license feature name).(default: {})
    • minimalMatlabSolverVersion: Minimal version of the optimization toolbox required to use the matlab solver.(default: 0)
    • requiredSolvers: Names of all solvers that MUST be available. If not empty, the resulting solvers struct will contain cell arrays (default: {})
    • useSolversIfAvailable: Names of solvers that should be used if available. If not empty, the resulting solvers struct will contain cell arrays (will not throw an error if not). (default: {})
    • requireOneSolverOf: Names of solvers, at least one of which has to be available
    • excludeSolvers: Names of solvers which should never be used for the test (because they fail)
    • useMinimalNumberOfSolvers: Always use only one solver. This option allows tests which only use FBA to generate input, but where no expicit linear programming code is present, to only validate on one solver (default: false).
    • needsLP: Whether a LP solver is required (default: false)
    • needsMILP: Whether a MILP solver is required (default: false)
    • needsQP: Whether a QP solver is required (default: false)
    • needsMIQP: Whether a MIQP solver is required (default: false)
    • needsNLP: Whether a NLP solver is required (default: false)
    • needsUnix: Whether the test only works on a Unix system (macOS or Linux) (default: false)
    • needsWindows: Whether the test only works on a Windows system (default: false)
    • needsMac: Whether the test only works on a Mac system (default: false)
    • needsLinux: Whether the test only works on a Linux system (default: false)
    • needsWebAddress: Tests, whether the supplied url exists (default: ‘’)
    • needsWebRead: Tests, whether webread can be used with the given url

Output

  • solversToUse – A struct with one field per solver type listing the solvers to use for that type of problem in a cell array. If neither of the ‘useIfAvailable’ nor the ‘reqSolvers’ parameter is provided, only at most one solver per type will be returned (i.e. the default solver for that type). See the examples below

Example

% request a check for the parallel processing toolbox
>> solvers = prepareTest('requiredToolboxes', {'distrib_computing_toolbox'})
solvers =

          struct with fields:

                LP: {'gurobi'}
              MILP: {'gurobi'}
                QP: {'gurobi'}
              MIQP: {'gurobi'}
               NLP: {'matlab'}

% request gurobi, ibm_cplex and tomlab if available
>> solvers = prepareTest('useIfAvailable', {'tomlab', 'ibm_cplex', 'gurobi'})
solvers =

          struct with fields:

                LP: {2×1 cell}
              MILP: {2×1 cell}
                QP: {2×1 cell}
              MIQP: {'gurobi'}
               NLP: {'matlab'}
removeTempFiles(directory, oldcontent, varargin)[source]

Removes all files that are in the specified directory but not part of the oldcontent. By default only removes those files which match files mentioned in the COBRA .gitignore file.

Usage

status = removeTempFiles(directory, oldcontent, varargin)

Inputs

  • directory – The directory which should be checked for changing files.
  • content – Absolute file names of the original conten in a cell array.

Optional input

  • varargin – Additional options as ParameterName, value pairs with the following options:

    • COBRAGitIgnoredOnly: only remove files which are listed by the COBRA gitignore file (default: true)
    • checkSubFolders: check subFolder (default: true)

Output

  • status – status of the deletion (true if successful)
updateCobraToolbox(fetchAndCheckOnly)[source]

Checks new commits exist on the master branch of the openCOBRA repository and asks the user to update The COBRA Toolbox (updates the develop and master branches)

Usage

updateCobraToolbox()

Input

  • fetchAndCheckOnly – if set to true, the repository is not updated but only new commits are fetched (default: false)
updateGitBash(fetchAndCheckOnly)[source]

On windows, this function updates the already existing version of gitBash. This function can only be run on Windows, and throws an error when run on a UNIX system.

Usage

updateGitBash(fetchAndCheckOnly)

Input

  • fetchAndCheckOnly – if set to true, gitBash is not updated, but only a check is made (default: false)