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. IfconnectSSH
istrue
, 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 theCOBRA
package installation folder)printLevel
: Verbose level (default: 1). Mute all output withprintLevel = 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()
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
OPTIONAL INPUTS
printLevel
: Verbose level (default: 1). Mute all output withprintLevel = 0
.
OUTPUTS
(bool): A boolean that indicates whether a package is installed properly
See also: using
, isdir()
checkSysConfig
— Function.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 withprintLevel = 0
.
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, 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 theloadModel
function. All fields ofmodel
must be available.solver
: A::SolverConfig
object that contains a validhandle
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 withprintLevel = 0
.
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, 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 theloadModel
function. All fields ofmodel
must 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
printLevel
: Verbose level (default: 1). Mute all output withprintLevel = 0
.
OUTPUTS
rxnsKey
: Structure with vector for workerp
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()
loopFBA
— Function.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 withinner
fieldsolver
: A::SolverConfig
object that contains a validhandle
to 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 processresultsDir
: Path to results folder (default is aresults
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 forfvamin
,fvamax
,statussolmin
, orstatussolmax
(applicable for quick checks of large models, default: false)printLevel
: Verbose level (default: 1). Mute all output withprintLevel = 0
.
OUTPUTS
retObj
: Vector with optimal (eithermin
ormax
) solutions (objective values)retFlux
: Array of solution vectors corresponding to the vector with the optimal objective values (eithermin
ormax
)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
distributedFBA
— Function.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 theloadModel
function. All fields ofmodel
must be available.solver
: A::SolverConfig
object that contains a validhandle
to 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: 0%).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:false
). Set totrue
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 aresults
folder in the Julia package directory)logFiles
: Boolean to write a solver logfile of each optimization (folderresultsDir/logs
is automatically created. default: false)onlyFluxes
: Save only minFlux and maxFlux if true and will return placeholders forfvamin
,fvamax
,statussolmin
, orstatussolmax
(applicable for quick checks of large models, default: false)printLevel
: Verbose level (default: 1). Mute all output withprintLevel = 0
.
OUTPUTS
minFlux
: Minimum flux for each reactionmaxFlux
: Maximum flux for each reactionoptSol
: Optimal solution of the initial FBA (ifpreFBA
set totrue
)fbaSol
: Solution vector of the initial FBA (ifpreFBA
set totrue
)fvamin
: Array with flux values for the considered reactions (minimization) (ifonlyFluxes
set tofalse
) Note:fvamin
is saved in individual.mat
files whensaveChunks
istrue
.fvamax
: Array with flux values for the considered reactions (maximization) (ifonlyFluxes
set tofalse
) Note:fvamax
is saved in individual.mat
files whensaveChunks
istrue
.statussolmin
: Vector of solution status for each reaction (minimization) (ifonlyFluxes
set tofalse
)statussolmax
: Vector of solution status for each reaction (maximization) (ifonlyFluxes
set tofalse
)
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()
printSolSummary
— Function.printSolSummary(testFile, optSol, maxFlux, minFlux, solTime, nWorkers, solverName, strategy, saveChunks, printLevel)
Output a solution summary
INPUTS
testFile
: Name of the.mat
test 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, vars, printLevel)
Output a file with all the output variables of distributedFBA()
and rxnsList
INPUTS
fileName
: Filename of the outputvars
: 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"])
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::SolverConfig
object that contains a validhandle
to the solver
loadModel
— Function.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 withprintLevel = 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 defaultAll entries of
A
,b
,c
,lb
,ub
are of type float
See also: MAT.jl
, matopen()
, matread()
PALM.jl
shareLoad
— Function.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 withprintLevel = 0
.dryRun
: Test load sharing without changing the parpool (default: false)
OUTPUTS
nWorkers
: Number of effective workers in the parallel pool; corresponds tonMatlab
ifnMatlab
<nModels
and tonModels
otherwisequotientModels
: Rounded number of models to be run by all MATLAB sessions apart from the last oneremainderModels
: 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
loopModels
— Function.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 numberscriptName
: 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 indirContent
to be used on workerp
endIndex
: Index of the last model indirContent
to be used on workerp
varsCharact
: Array with the names of variables to be retrieved from the MATLAB session on workerp
OPTIONAL INPUTS
printLevel
: Verbose level (default: 1). Mute all output withprintLevel = 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 tovarsCharact
.
EXAMPLES
Minimum working example
julia> loopModels(dir, p, scriptName, dirContent, startIndex, endIndex, varsCharact)
See also: PALM()
PALM
— Function.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 withprintLevel = 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()
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::LPproblem
object that has been built using theloadModel
function. All fields ofmodel
must be available.solver
: A::SolverConfig
object that contains a validhandle
to the solver
OUTPUTS
m
: A MathProgBase.LinearQuadraticModel object withinner
field
EXAMPLES
julia> m = buildCobraLP(model, solver)
See also: MathProgBase.LinearQuadraticModel()
, MathProgBase.HighLevelInterface.buildlp()
changeCobraSolver
— Function.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 tuplesprintLevel
: Verbose level (default: 1). Mute all output withprintLevel = 0
.
OUTPUT
solver
: Solver object with ahandle
field
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 ⩽ u
INPUTS
model
: An::LPproblem
object that has been built using theloadModel
function. All fields ofmodel
must be available.solver
: A::SolverConfig
object that contains a validhandle
to the solver
OUTPUTS
solutionLP
: Solution object of typeLPproblem
EXAMPLES
Minimum working example
julia> solveCobraLP(model, solver)
See also: MathProgBase.linprog()
,
tools.jl
findRxnIDS
— Function.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 theloadModel
function. All fields ofmodel
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 inrxnsList
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()
convertUnitRange
— Function.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