Modules and Functions

Functions

connect.jl

createPoolFunction.
createPool(localWorkers, connectSSHWorkers, connectionFile)

Function used to create a pool of parallel workers that are either local or connected via SSH.

INPUTS

  • localWorkers: Number of local workers to connect. If connectSSH is true, the number of localWorkers is 1 (host).

OPTIONAL INPUTS

  • connectSSH: Boolean that indicates whether additional nodes should be connected via SSH. (default: false)

  • connectionFile Name of the file with the SSH connection details (default: config/sshCfg.jl in the COBRA package installation folder)

  • printLevel: Verbose level (default: 1). Mute all output with printLevel = 0.

OUTPUTS

  • workers(): Array of IDs of the connected workers (local and SSH workers)

  • nWorkers: Total number of connect workers (local and SSH workers)

EXAMPLES

Minimum working example:

julia> createPool(localWorkers)

Local workers and workers on SSH nodes can be connected as follows:

workersPool, nWorkers = createPool(12, true, "mySSHCfg.jl")

which will connect 12 local workers, and all workers defined in mySSHCfg.jl. An example connection file is provided in the config/ folder of the COBRA package installation folder.

See also: workers(), nprocs(), addprocs(), gethostname()

source

checkSetup.jl

checkPackageFunction.
checkPackage(pkgName)

Function checks whether a package is installed properly or not and returns a boolean value.

INPUTS

  • pkgName: A string that contains the name of the package to be checked

OPTIONAL INPUTS

  • printLevel: Verbose level (default: 1). Mute all output with printLevel = 0.

OUTPUTS

  • (bool): A boolean that indicates whether a package is installed properly

See also: using, isdir()

source
checkSysConfigFunction.
checkSysConfig(printLevel)

Function evaluates whether the LP solvers of MathProgBase are installed on the system or not and returns a list of these packages. MathProgBase.jl must be installed.

OPTIONAL INPUTS

  • printLevel: Verbose level (default: 1). Mute all output with printLevel = 0.

OUTPUTS

  • packages: A list of solver packages installed on the system

See also: MathProgBase, checkPackage()

source

distributedFBA.jl

preFBA!Function.
preFBA!(model, solver, optPercentage, osenseStr, rxnsList, printLevel)

Function that solves the original FBA, adds the objective value as a constraint to the stoichiometric matrix of the model, and changes the RHS vector b. Note that the model object is changed.

INPUTS

  • model: An ::LPproblem object that has been built using the loadModel function. All fields of model must be available.

  • solver: A ::SolverConfig object that contains a valid handle to the solver

OPTIONAL INPUTS

  • optPercentage: Only consider solutions that give you at least a certain percentage of the optimal solution (default: 0%)

  • osenseStr: Sets the optimization mode of the original FBA ("max" or "min", default: "max")

  • rxnsList: List of reactions to analyze (default: all reactions)

  • printLevel: Verbose level (default: 1). Mute all output with printLevel = 0.

OUTPUTS

  • objValue: Optimal objective value of the original FBA problem

  • fbaSol: Solution vector that corresponds to the optimal objective value

EXAMPLES

  • Minimum working example:

julia> preFBA!(model, solver)
  • Full input/output example

julia> optSol, fbaSol = preFBA!(model, solver, optPercentage, objective)

See also: solveCobraLP(), distributedFBA()

source
splitRangeFunction.
splitRange(model, rxnsList, nWorkers, strategy, printLevel)

Function splits a reaction list in blocks for a certain number of workers according to a selected strategy. Generally , splitRange() is called before the FBAs are distributed.

INPUTS

  • model: An ::LPproblem object that has been built using the loadModel function. All fields of model must be available.

  • rxnsList: List of reactions to analyze (default: all reactions)

OPTIONAL INPUTS

  • nWorkers: Number of workers as initialized using createPool() or similar

  • strategy: Number of the splitting strategy

    • 0: Blind splitting: default random distribution

    • 1: Extremal dense-and-sparse splitting: every worker receives dense and sparse reactions, starting from both extremal indices of the sorted column density vector

    • 2: Central dense-and-sparse splitting: every worker receives dense and sparse reactions, starting from the beginning and center indices of the sorted column density vector

  • printLevel: Verbose level (default: 1). Mute all output with printLevel = 0.

OUTPUTS

  • rxnsKey: Structure with vector for worker p with start and end indices of each block

EXAMPLES

  • Minimum working example

julia> splitRange(model, rxnsList, 2)
  • Selection of the splitting strategy 2 for 4 workers

julia> splitRange(model, rxnsList, 4, 2)

See also: distributeFBA()

source
loopFBAFunction.
loopFBA(m, rxnsList, nRxns, rxnsOptMode, iRound, pid, resultsDir, logFiles, onlyFluxes, printLevel)

Function used to perform a loop of a series of FBA problems using the CPLEX solver Generally, loopFBA is called in a loop over multiple workers and makes use of the CPLEX.jl module.

INPUTS

  • m: A MathProgBase.LinearQuadraticModel object with inner field

  • solver: A ::SolverConfig object that contains a valid handleto the solver

  • rxnsList: List of reactions to analyze (default: all reactions)

  • nRxns: Total number of reaction in the model m.inner

OPTIONAL INPUTS

  • rxnsOptMode: List of min/max optimizations to perform:

    • 0: only minimization

    • 1: only maximization

    • 2: minimization & maximization [default: all reactions are minimized and maximized, i.e. 2+zeros(Int,length(model.rxns))]

  • iRound: Index of optimization round

    • 0: minimization

    • 1: maximization

  • pid: Julia ID of launched process

  • resultsDir: Path to results folder (default is a results folder in the Julia package directory)

  • logFiles: (only available for CPLEX) Boolean to write a solver logfile of each optimization (default: false)

  • onlyFluxes: Save only minFlux and maxFlux if true and will return placeholders for fvamin, fvamax, statussolmin, or statussolmax (applicable for quick checks of large models, default: false)

  • printLevel: Verbose level (default: 1). Mute all output with printLevel = 0.

OUTPUTS

  • retObj: Vector with optimal (either min or max) solutions (objective values)

  • retFlux: Array of solution vectors corresponding to the vector with the optimal objective values (either min or max)

  • retStat: Vector with the status of the solver of each FBA (default: initialized with -1)

    • 0: LP problem is infeasible

    • 1: LP problem is optimal

    • 2: LP problem is unbounded

    • 3: Solver for the LP problem has hit a user limit

    • 4: LP problem is infeasible or unbounded

    • 5: LP problem has a non-documented solution status

    • < 0: returned original solution status of solver (only CPLEX supported)

EXAMPLES

  • Minimum working example

julia> loopFBA(m, rxnsList, nRxns)

See also: distributeFBA(), MathProgBase.HighLevelInterface

source
distributedFBAFunction.
distributedFBA(model, solver, nWorkers, optPercentage, objective, rxnsList, strategy, rxnsOptMode, preFBA, saveChunks, resultsDir, logFiles, onlyFluxes, printLevel)

Function to distribute a series of FBA problems across one or more workers that have been initialized using the createPool function (or similar).

INPUTS

  • model: An ::LPproblem object that has been built using the loadModel function. All fields of model must be available.

  • solver: A ::SolverConfig object that contains a valid handle to the solver

  • nWorkers: Number of workers as initialized using createPool() or similar

OPTIONAL INPUTS

  • optPercentage: Only consider solutions that give you at least a certain percentage of the optimal solution (default: 0%).

  • objective: Objective ("min" or "max") (default: "max")

  • rxnsList: List of reactions to analyze (default: all reactions)

  • strategy: Number of the splitting strategy

    • 0: Blind splitting: default random distribution

    • 1: Extremal dense-and-sparse splitting: every worker receives dense and sparse reactions, starting from both extremal indices of the sorted column density vector

    • 2: Central dense-and-sparse splitting: every worker receives dense and sparse reactions, starting from the beginning and center indices of the sorted column density vector

  • rxnsOptMode: List of min/max optimizations to perform:

    • 0: only minimization

    • 1: only maximization

    • 2: minimization & maximization [default: all reactions are minimized and maximized, i.e. 2+zeros(Int,length(model.rxns))]

  • preFBA: Solve the original FBA and add a percentage condition (Boolean variable, default: false). Set to true for flux variability analysis.

  • saveChunks: Save the fluxes of the minimizations and maximizations in individual files on each worker (applicable for large models, default: false)

  • resultsDir: Path to results folder (default is a results folder in the Julia package directory)

  • logFiles: Boolean to write a solver logfile of each optimization (folder resultsDir/logs is automatically created. default: false)

  • onlyFluxes: Save only minFlux and maxFlux if true and will return placeholders for fvamin, fvamax, statussolmin, or statussolmax (applicable for quick checks of large models, default: false)

  • printLevel: Verbose level (default: 1). Mute all output with printLevel = 0.

OUTPUTS

  • minFlux: Minimum flux for each reaction

  • maxFlux: Maximum flux for each reaction

  • optSol: Optimal solution of the initial FBA (if preFBA set to true)

  • fbaSol: Solution vector of the initial FBA (if preFBA set to true)

  • fvamin: Array with flux values for the considered reactions (minimization) (if onlyFluxes set to false) Note: fvamin is saved in individual .mat files when saveChunks is true.

  • fvamax: Array with flux values for the considered reactions (maximization) (if onlyFluxes set to false) Note: fvamax is saved in individual .mat files when saveChunks is true.

  • statussolmin: Vector of solution status for each reaction (minimization) (if onlyFluxes set to false)

  • statussolmax: Vector of solution status for each reaction (maximization) (if onlyFluxes set to false)

EXAMPLES

  • Minimum working example

julia> minFlux, maxFlux = distributedFBA(model, solver)
  • Flux variability analysis with optPercentage = 90% (on 4 workers)

julia> minFlux, maxFlux = distributedFBA(model, solver, nWorkers=4, optPercentage=90.0, preFBA=true)
  • Full input/output example

julia> minFlux, maxFlux, optSol, fbaSol, fvamin, fvamax, statussolmin, statussolmax = distributedFBA(model, solver, nWorkers=nWorkers, logFiles=true)
  • Save only the fluxes

julia> minFlux, maxFlux = distributedFBA(model, solver, preFBA=true, saveChunks=false, onlyFluxes=true)
  • Save flux vectors in files

julia> minFlux, maxFlux, optSol, fbaSol, fvamin, fvamax, statussolmin, statussolmax = distributedFBA(model, solver)

See also: preFBA!(), splitRange(), buildCobraLP(), loopFBA(), or fetch()

source
printSolSummaryFunction.
printSolSummary(testFile, optSol, maxFlux, minFlux, solTime, nWorkers, solverName, strategy, saveChunks, printLevel)

Output a solution summary

INPUTS

  • testFile: Name of the .mat test file

  • optSol: Optimal solution of the initial FBA

  • minFlux: Minimum flux for each reaction

  • maxFlux: Maximum flux for each reaction

  • solTime: Solution time (in seconds)

  • nWorkers: Number of workers as initialized using createPool() or similar

  • solverName: Name of the solver

  • strategy: Number of the splitting strategy

    • 0: Blind splitting: default random distribution

    • 1: Extremal dense-and-sparse splitting: every worker receives dense and sparse reactions, starting from both extremal indices of the sorted column density vector

    • 2: Central dense-and-sparse splitting: every worker receives dense and sparse reactions, starting from the beginning and center indices of the sorted column density vector

  • saveChunks: Save the fluxes of the minimizations and maximizations in individual files on each worker (applicable for large models)

OUTPUTS

  • (Printed summary)

See also: norm(), maximum(), minimum()

source
saveDistributedFBAFunction.
saveDistributedFBA(fileName::String, vars, printLevel)

Output a file with all the output variables of distributedFBA() and rxnsList

INPUTS

  • fileName: Filename of the output

  • vars: List of variables (default: ["minFlux", "maxFlux", "optSol", "fbaSol", "fvamin", "fvamax", "statussolmin", "statussolmax", "rxnsList"])

OUTPUTS

  • .mat file with the specified output variables

EXAMPLES

  • Minimum working example

julia> saveDistributedFBA("myResults.mat")
  • File location

julia> saveDistributedFBA("myDirectory/myResults.mat")
  • Home location

julia> saveDistributedFBA(ENV["HOME"]*"/myResults.mat")
  • Save minFlux and maxFlux variables

julia> saveDistributedFBA(ENV["HOME"]*"/myResults.mat", ["minFlux", "maxFlux"])
source

load.jl

LPproblemType.
LPproblem(S, b, c, lb, ub, osense, csense, rxns, mets)

General type for storing an LP problem which contains the following fields:

  • S: LHS matrix (m x n)

  • b: RHS vector (m x 1)

  • c: Objective coefficient vector (n x 1)

  • lb: Lower bound vector (n x 1)

  • ub: Upper bound vector (n x 1)

  • osense: Objective sense (scalar; -1 ~ "max", +1 ~ "min")

  • csense: Constraint senses (m x 1, 'E' or '=', 'G' or '>', 'L' ~ '<')

  • solver: A ::SolverConfig object that contains a valid handle to the solver

source
loadModelFunction.
loadModel(fileName, matrixAS, modelName, modelFields, printLevel)

Function used to load a COBRA model from an existing .mat file

INPUTS

  • filename: Name of the .mat file that contains the model structure

OPTIONAL INPUTS

  • matrixAS: String to distinguish the name of stoichiometric matrix ("S" or "A", default: "S")

  • modelName: String with the name of the model structure (default: "model")

  • modelFields: Array with strings of fields of the model structure (default: ["ub", "lb", "osense", "c", "b", "csense", "rxns", "mets"])

  • printLevel: Verbose level (default: 1). Mute all output with printLevel = 0.

OUTPUTS

  • LPproblem() :LPproblem object with filled fields from .mat file

Examples

  • Minimum working example

julia> loadModel("myModel.mat")
  • Full input/output example

julia> model = loadModel("myModel.mat", "A", "myModelName", ["ub","lb","osense","c","b","csense","rxns","mets"]);

Notes

  • osense is set to "max" (osense = -1) by default

  • All entries of A, b, c, lb, ub are of type float

See also: MAT.jl, matopen(), matread()

source

PALM.jl

shareLoadFunction.
shareLoad(nModels, nMatlab, printLevel)

Function shares the number of nModels across nMatlab sessions (Euclidian division)

INPUTS

  • nModels: Number of models to be run

OPTIONAL INPUTS

  • nMatlab: Number of desired MATLAB sessions (default: 2)

  • printLevel: Verbose level (default: 1). Mute all output with printLevel = 0.

  • dryRun: Test load sharing without changing the parpool (default: false)

OUTPUTS

  • nWorkers: Number of effective workers in the parallel pool; corresponds to nMatlab if nMatlab < nModels and to nModels otherwise

  • quotientModels: Rounded number of models to be run by all MATLAB sessions apart from the last one

  • remainderModels: Number of remaining models to be run by the last MATLAB session

EXAMPLES

  • Minimum working example

julia> shareLoad(nModels)
  • Determination of the load of 4 models in 2 MATLAB sessions

julia> shareLoad(4, 2, 1)

See also: createPool() and PALM

source
loopModelsFunction.
loopModels(dir, p, scriptName, dirContent, startIndex, endIndex, varsCharact, printLevel)

Function loopModels is generally called in a loop from PALM() on worker p. Runs scriptName for all models with an index in dirContent between startIndex and endIndex. Retrieves all variables defined in varsCharact. The number of models on worker p is computed as nModels = endIndex - startIndex + 1.

INPUTS

  • dir: Directory that contains the models (model file format: .mat)

  • p: Process or worker number

  • scriptName: Name of MATLAB script to be run (without extension .m)

  • dirContent: Array with file names (commonly read from a directory)

  • startIndex: Index of the first model in dirContent to be used on worker p

  • endIndex: Index of the last model in dirContent to be used on worker p

  • varsCharact: Array with the names of variables to be retrieved from the MATLAB session on worker p

OPTIONAL INPUTS

  • printLevel: Verbose level (default: 1). Mute all output with printLevel = 0.

OUTPUTS

  • data: Mixed array of variables retrieved from worker p (rows: models, columns: variables). First column corresponds to the model name, and first row corresponds to varsCharact.

EXAMPLES

  • Minimum working example

julia> loopModels(dir, p, scriptName, dirContent, startIndex, endIndex, varsCharact)

See also: PALM()

source
PALMFunction.
PALM(dir, scriptName, nMatlab, outputFile, cobraToolboxDir, printLevel)

Function reads the directory dir, and launches nMatlab sessions to run scriptName. Results are saved in the outputFile.

INPUTS

  • dir: Directory that contains the models (model file format: .mat)

  • scriptName: Absolute or relative path MATLAB script to be run

OPTIONAL INPUTS

  • nMatlab: Number of desired MATLAB sessions (default: 2)

  • outputFile: Name of .mat file to save the result table named "summaryData" (default name: "PALM_data.mat")

  • cobraToolboxDir: Directory of the COBRA Toolbox (default: "~/cobratoolbox")

  • printLevel: Verbose level (default: 1). Mute all output with printLevel = 0.

OUTPUTS

File with the name specified in outputFile.

EXAMPLES

  • Minimum working example

julia> PALM("~/models", "characteristics")
  • Running PALM on 12 MATLAB sessions

julia> PALM("~/models", "characteristics", 12, "characteristicsResults.mat")

See also: loopModels() and shareLoad()

source

solve.jl

SolverConfigType.
SolverConfig(name, handle)

Definition of a common solver type, which inclues the name of the solver and other parameters

  • name: Name of the solver (alias)

  • handle: Solver handle used to refer to the solver

source
buildCobraLPFunction.
buildCobraLP(model, solver)

Build a model by interfacing directly with the CPLEX solver

INPUTS

  • model: An ::LPproblem object that has been built using the loadModel function. All fields of model must be available.

  • solver: A ::SolverConfig object that contains a valid handleto the solver

OUTPUTS

  • m: A MathProgBase.LinearQuadraticModel object with inner field

EXAMPLES

julia> m = buildCobraLP(model, solver)

See also: MathProgBase.LinearQuadraticModel(), MathProgBase.HighLevelInterface.buildlp()

source
changeCobraSolverFunction.
changeCobraSolver(name, params, printLevel)

Function used to change the solver and include the respective solver interfaces

INPUT

  • name: Name of the solver (alias)

OPTIONAL INPUT

  • params: Solver parameters as a row vector with tuples

  • printLevel: Verbose level (default: 1). Mute all output with printLevel = 0.

OUTPUT

  • solver: Solver object with a handle field

EXAMPLES

Minimum working example (for the CPLEX solver)

julia> changeCobraSolver("CPLEX", cpxControl)

See also: MathProgBase.jl

source
solveCobraLPFunction.
solveCobraLP(model, solver)

Function used to solve a linear program (LP) with a specified solver. LP problem must have the form:

                                  max/min cᵀv
                                   s.t.  Av = b
                                        l ⩽ v ⩽ u

INPUTS

  • model: An ::LPproblem object that has been built using the loadModel function. All fields of model must be available.

  • solver: A ::SolverConfig object that contains a valid handleto the solver

OUTPUTS

  • solutionLP: Solution object of type LPproblem

EXAMPLES

Minimum working example

julia> solveCobraLP(model, solver)

See also: MathProgBase.linprog(),

source

tools.jl

findRxnIDSFunction.
findRxnIDS(model, rxnsList)

Function that returns a vector of reaction IDs that correspond to an input list of reaction names.

INPUTS

  • model: An ::LPproblem object that has been built using the loadModel function. All fields of model must be available.

OPTIONAL INPUTS

  • rxnsList: List of reaction names (default: all reactions in the model)

OUTPUTS

  • rxnIDs: Vector with the reaction IDs that correspond to the reaction names in rxnsList

EXAMPLES

  • Minimum working example:

julia> findRxnIDS(model)
  • Full input/output example

julia> rxnIDs, rxnIDsNE = findRxnIDS(model, rxnsList)
  • Full input/output example

julia> rxnIDs, rxnIDsNE = findRxnIDS(model, ["reactionName1", "reactionName2"])

See also: loadModel(), distributedFBA()

source
convertUnitRangeFunction.
convertUnitRange(vect)

Converts a unit range vector to an array type vector. If the vector is not of UnitRange{Int64} type, the same vector is returned.

INPUTS

  • vect: Any vector (UnitRange{Int64} will be converted to Array{Int64})

OUTPUTS

  • retVect Converted vector (if type of input vector is UnitRange{Int64})

EXAMPLES

  • Minimum working example

julia> a = 1:4
1:4

julia> convertUnitRange(a)
4-element Array{Int64,1}:
  1
  2
  3
  4
source