Functions
connect.jl
createPool — Function.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. IfconnectSSHistrue, the number of localWorkers is 1 (host).
OPTIONAL INPUTS
connectSSH: Boolean that indicates whether additional nodes should be connected via SSH. (default:false)connectionFileName of the file with the SSH connection details (default: config/sshCfg.jl in theCOBRApackage installation folder)
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()
checkSetup.jl
checkPackage — Function.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
OUTPUTS
(bool): A boolean that indicates whether a package is installed properly
See also: using, isdir()
checkSysConfig — Function.checkSysConfig()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.
OUTPUTS
packages: A list of solver packages installed on the system
See also: MathProgBase, checkPackage()
distributedFBA.jl
preFBA! — Function.preFBA!(model, solver, optPercentage, osenseStr, rxnsList)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::LPproblemobject that has been built using theloadModelfunction. All fields ofmodelmust be available.solver: A::SolverConfigobject that contains a validhandleto the solver
OPTIONAL INPUTS
optPercentage: Only consider solutions that give you at least a certain percentage of the optimal solution (default: 100%)osenseStr: Sets the optimization mode of the original FBA ("max" or "min", default: "max")rxnsList: List of reactions to analyze (default: all reactions)
OUTPUTS
objValue: Optimal objective value of the original FBA problemfbaSol: 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()
splitRange — Function.splitRange(model, rxnsList, nWorkers, strategy)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::LPproblemobject that has been built using theloadModelfunction. All fields ofmodelmust be available.rxnsList: List of reactions to analyze (default: all reactions)
OPTIONAL INPUTS
nWorkers: Number of workers as initialized usingcreatePool()or similarstrategy: Number of the splitting strategy0: 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
OUTPUTS
rxnsKey: Structure with vector for workerpwith 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()
loopFBA — Function.loopFBA(m, rxnsList, nRxns, pid, iRound, rxnsOptMode)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 withinnerfieldsolver: A::SolverConfigobject that contains a validhandleto the solverrxnsList: List of reactions to analyze (default: all reactions)nRxns: Total number of reaction in the modelm.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 round0: minimization
1: maximization
pid: Julia ID of launched process
OUTPUTS
retObj: Vector with optimal (eitherminormax) solutions (objective values)retFlux: Array of solution vectors corresponding to the vector with the optimal objective values (eitherminormax)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
EXAMPLES
Minimum working example
julia> loopFBA(m, rxnsList, nRxns)See also: distributeFBA(), MathProgBase.HighLevelInterface
distributedFBA — Function.distributedFBA(model, solver, nWorkers, optPercentage, objective, rxnsList, strategy, preFBA, rxnsOptMode, saveChunks)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::LPproblemobject that has been built using theloadModelfunction. All fields ofmodelmust be available.solver: A::SolverConfigobject that contains a validhandleto the solvernWorkers: Number of workers as initialized usingcreatePool()or similar
OPTIONAL INPUTS
optPercentage: Only consider solutions that give you at least a certain percentage of the optimal solution (default: 100%)objective: Objective ("min" or "max") (default: "max")rxnsList: List of reactions to analyze (default: all reactions)strategy: Number of the splitting strategy0: 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: true for flux variability analysis FVA)saveChunks: Save the fluxes of the minimizations and maximizations in individual files on each worker (applicable for large models)
OUTPUTS
minFlux: Minimum flux for each reactionmaxFlux: Maximum flux for each reactionoptSol: Optimal solution of the initial FBAfbaSol: Solution vector of the initial FBAfvamin: Array with flux values for the considered reactions (minimization) Note:fvaminis saved in individual.matfiles whensaveChunksistrue.fvamax: Array with flux values for the considered reactions (maximization) Note:fvamaxis saved in individual.matfiles whensaveChunksistrue.statussolmin: Vector of solution status for each reaction (minimization)statussolmax: Vector of solution status for each reaction (maximization)
EXAMPLES
Minimum working example
julia> minFlux, maxFlux = distributedFBA(model, solver)Full input/output example
julia> minFlux, maxFlux, optSol, fbaSol, fvamin, fvamax, statussolmin, statussolmax = distributedFBA(model, solver, optPercentage, objective, rxnsList, strategy, rxnsOptMode, true)See also: preFBA!(), splitRange(), buildCobraLP(), loopFBA(), or fetch()
printSolSummary — Function.printSolSummary(testFile, optSol, maxFlux, minFlux, solTime, nWorkers, solverName, strategy, saveChunks)Output a solution summary
INPUTS
testFile: Name of the.mattest fileoptSol: Optimal solution of the initial FBAminFlux: Minimum flux for each reactionmaxFlux: Maximum flux for each reactionsolTime: Solution time (in seconds)nWorkers: Number of workers as initialized usingcreatePool()or similarsolverName: Name of the solverstrategy: Number of the splitting strategy0: 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()
saveDistributedFBA — Function.saveDistributedFBA(fileName::String)Output a file with all the output variables of distributedFBA() and rxnsList
INPUTS
fileName: Filename of the output
OUTPUTS
.matfile with all output variables ofdistributedFBA()
EXAMPLES
Minimum working example
julia> saveDistributedFBA("myResults.mat")File location
julia> saveDistributedFBA("myDirectory/myResults.mat")Home location
julia> saveDistributedFBA(ENV["HOME"]*"/myResults.mat")load.jl
LPproblem — Type.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::SolverConfigobject that contains a validhandleto the solver
loadModel — Function.loadModel(fileName, matrixAS, modelName, modelFields)Function used to load a COBRA model from an existing .mat file
INPUTS
filename: Name of the.matfile 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"])
OUTPUTS
LPproblem():LPproblemobject with filled fields from.matfile
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
osenseis set to "max" (osense = -1) by defaultAll entries of
A,b,c,lb,ubare of type float
See also: MAT.jl, matopen(), matread()
solve.jl
SolverConfig — Type.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
buildCobraLP — Function.buildCobraLP(model, solver)Build a model by interfacing directly with the CPLEX solver
INPUTS
model: An::LPproblemobject that has been built using theloadModelfunction. All fields ofmodelmust be available.solver: A::SolverConfigobject that contains a validhandleto the solver
OUTPUTS
m: A MathProgBase.LinearQuadraticModel object withinnerfield
EXAMPLES
julia> m = buildCobraLP(model, solver)See also: MathProgBase.LinearQuadraticModel(), MathProgBase.HighLevelInterface.buildlp()
changeCobraSolver — Function.changeCobraSolver(name, params)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
OUTPUT
solver: Solver object with ahandlefield
EXAMPLES
Minimum working example (for the CPLEX solver)
julia> changeCobraSolver("CPLEX", cpxControl)See also: MathProgBase.jl
solveCobraLP — Function.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 ⩽ uINPUTS
model: An::LPproblemobject that has been built using theloadModelfunction. All fields ofmodelmust be available.solver: A::SolverConfigobject that contains a validhandleto the solver
OUTPUTS
solutionLP: Solution object of typeLPproblem
EXAMPLES
Minimum working example
julia> solveCobraLP(model, solver)See also: MathProgBase.linprog(),