Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecated syntax for Pkg.dir in docs and tests #55

Merged
merged 4 commits into from
Sep 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ Shall no solvers be detected on your system, error messages may be thrown when t

The code has been benchmarked against the `fastFVA` implementation [[3](#References-1)]. A test model `ecoli_core_model.mat` [[4](#References-1)] can be used to pre-compile the code and can be downloaded using
```Julia
julia> using Requests
julia> include("$(Pkg.dir("COBRA"))/test/getTestModel.jl")
julia> using HTTP, COBRA
julia> pkgDir = joinpath(dirname(pathof(COBRA)), "..")
julia> include(pkgDir*"/test/getTestModel.jl")
julia> getTestModel()
```

Expand Down
6 changes: 4 additions & 2 deletions docs/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

In order to load currently defined solver parameters, the following file may be included in the script, which defines the `solParams` array:
```julia
include("$(Pkg.dir("COBRA"))/config/solverCfg.jl")
pkgDir = joinpath(dirname(pathof(COBRA)), "..")
include(pkgDir*"/config/solverCfg.jl")
```
Then, the `COBRA` solver can be set with:
```julia
Expand Down Expand Up @@ -49,7 +50,8 @@ solParams = [

A parallel pool with workers on SSH nodes can be created using:
```julia
include("$(Pkg.dir("COBRA"))/src/connect.jl")
pkgDir = joinpath(dirname(pathof(COBRA)), "..")
include(pkgDir*"/src/connect.jl")
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.
Expand Down
4 changes: 2 additions & 2 deletions src/distributedFBA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ See also: `distributeFBA()`, `MathProgBase.HighLevelInterface`
"""

function loopFBA(m, rxnsList, nRxns::Int, rxnsOptMode=2 .+ zeros(Int, length(rxnsList)), iRound::Int=0, pid::Int=1,
resultsDir::String="$(Pkg.dir("COBRA"))/results", logFiles::Bool=false, onlyFluxes::Bool=false, printLevel::Int=1)
resultsDir::String=joinpath(dirname(pathof(COBRA)), "..")*"/results", logFiles::Bool=false, onlyFluxes::Bool=false, printLevel::Int=1)

# initialize vectors and counters
retObj = zeros(nRxns)
Expand Down Expand Up @@ -524,7 +524,7 @@ See also: `preFBA!()`, `splitRange()`, `buildCobraLP()`, `loopFBA()`, or `fetch(

function distributedFBA(model, solver; nWorkers::Int=1, optPercentage::Union{Float64, Int64}=0.0, objective::String="max",
rxnsList=1:length(model.rxns), strategy::Int=0, rxnsOptMode=2 .+ zeros(Int, length(model.rxns)),
preFBA::Bool=false, saveChunks::Bool=false, resultsDir::String="$(Pkg.dir("COBRA"))/results",
preFBA::Bool=false, saveChunks::Bool=false, resultsDir::String=joinpath(dirname(pathof(COBRA)), "..")*"/results",
logFiles::Bool=false, onlyFluxes::Bool=false, printLevel::Int=1)

# convert type of optPercentage
Expand Down
34 changes: 17 additions & 17 deletions test/p_all.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if !@isdefined includeCOBRA
includeCOBRA = true
end

pkgDir = joinpath(dirname(pathof(COBRA)))
pkgDir = joinpath(dirname(pathof(COBRA)), "..")

# output information
testFile = @__FILE__
Expand All @@ -25,7 +25,7 @@ if includeCOBRA
# define the name of the default solver
solverName = :GLPKMathProgInterface
connectSSHWorkers = false
include(pkgDir*"/connect.jl")
include(pkgDir*"/src/connect.jl")

# create a parallel pool and determine its size
if isdefined(:nWorkers) && isdefined(:connectSSHWorkers)
Expand Down Expand Up @@ -336,24 +336,24 @@ printSolSummary(testFile, optSol, maxFlux, minFlux, solTime, nWorkers, solverNam

# remove the results folder to clean up
try
rm("$(Pkg.dir("COBRA"))/results", recursive=true, force=true)
rm(pkgDir*"/results", recursive=true, force=true)
catch
@info "The directory $(Pkg.dir("COBRA"))/results cannot be removed. Please check permissions.\n"
end

# create folders if they are not present
if !isdir("$(Pkg.dir("COBRA"))/results")
mkdir("$(Pkg.dir("COBRA"))/results")
if !isdir(pkgDir*"/results")
mkdir(pkgDir*"/results")
printstyled("Directory `results` created.\n\n"; color=:green)

# create a folder for storing the chunks of the fluxes of each minimization
if !isdir("$(Pkg.dir("COBRA"))/results/fvamin")
mkdir("$(Pkg.dir("COBRA"))/results/fvamin")
if !isdir(pkgDir*"/results/fvamin")
mkdir(pkgDir*"/results/fvamin")
end

# create a folder for storing the chunks of the fluxes of each maximization
if !isdir("$(Pkg.dir("COBRA"))/results/fvamax")
mkdir("$(Pkg.dir("COBRA"))/results/fvamax")
if !isdir(pkgDir*"/results/fvamax")
mkdir(pkgDir*"/results/fvamax")
end
else
printstyled("Directory `results` already exists.\n\n", color=:green)
Expand Down Expand Up @@ -391,13 +391,13 @@ run(`rm testFile.mat`)

# remove the results folder to clean up
try
rm("$(Pkg.dir("COBRA"))/results", recursive=true, force=true)
rm(pkgDir*"/results", recursive=true, force=true)
catch
@info "The directory $(Pkg.dir("COBRA"))/results cannot be removed. Please check permissions.\n"
end

# create the logs folder
resultsDir = "$(Pkg.dir("COBRA"))/results"
# create the pkgDir*"/
resultsDir = pkgDir*"/results"

if isdir("$resultsDir/logs")
try
Expand All @@ -416,7 +416,7 @@ minFlux, maxFlux, optSol, fbaSol, fvamin, fvamax, statussolmin, statussolmax = d

# remove the results folder to clean up
try
rm("$(Pkg.dir("COBRA"))/results", recursive=true, force=true)
rm(pkgDir*"/results", recursive=true, force=true)
catch
@info "The directory $(Pkg.dir("COBRA"))/results cannot be removed. Please check permissions.\n"
end
Expand All @@ -430,12 +430,12 @@ minFlux, maxFlux, optSol, fbaSol, fvamin, fvamax, statussolmin, statussolmax = d
# call to write logFiles with onlyFluxes
minFlux, maxFlux, optSol, fbaSol, fvamin, fvamax, statussolmin, statussolmax = distributedFBA(model, solver, nWorkers=nWorkers, onlyFluxes=true, rxnsList=1:10, logFiles=true)

# test if the /logs folder has been created
@test isdir("$(Pkg.dir("COBRA"))/results/logs")
# test if thpkgDir*"/en created
@test isdir(pkgDir*"/results/logs")

# remove the results folder to clean up
try
rm("$(Pkg.dir("COBRA"))/results", recursive=true, force=true)
trypkgDir*"/
rm(pkgDir*"/results", recursive=true, force=true)
catch
@info "The directory $(Pkg.dir("COBRA"))/results cannot be removed. Please check permissions.\n"
end
8 changes: 5 additions & 3 deletions test/p_distinct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ testFile = @__FILE__
# number of workers
nWorkers = 4

pkgDir = joinpath(dirname(pathof(COBRA)), "..")

# create a pool and use the COBRA module if the testfile is run in a loop
if includeCOBRA
connectSSHWorkers = false
include("$(Pkg.dir("COBRA"))/src/connect.jl")
include(pkgDir*"/src/connect.jl")

# create a parallel pool and determine its size
if isdefined(:nWorkers) && isdefined(:connectSSHWorkers)
Expand All @@ -37,13 +39,13 @@ end
getTestModel()

# include the solver configuration file
include("$(Pkg.dir("COBRA"))/config/solverCfg.jl")
include(pkgDir*"/config/solverCfg.jl")

# change the COBRA solver
solver = changeCobraSolver(solverName, solParams)

# load an external mat file
model = loadModel("$(Pkg.dir("COBRA"))/test/ecoli_core_model.mat", "S", "model")
model = loadModel(pkgDir*"/test/ecoli_core_model.mat", "S", "model")

# define an optPercentage value
optPercentage = 90.0
Expand Down
8 changes: 5 additions & 3 deletions test/p_range.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ testFile = @__FILE__
# number of workers
nWorkers = 4

pkgDir = joinpath(dirname(pathof(COBRA)), "..")

# create a pool and use the COBRA module if the testfile is run in a loop
if includeCOBRA
connectSSHWorkers = false
include("$(Pkg.dir("COBRA"))/src/connect.jl")
include(pkgDir*"/src/connect.jl")

# create a parallel pool and determine its size
if isdefined(:nWorkers) && isdefined(:connectSSHWorkers)
Expand All @@ -37,13 +39,13 @@ end
getTestModel()

# include a common deck for running tests
include("$(Pkg.dir("COBRA"))/config/solverCfg.jl")
include(pkgDir*"/config/solverCfg.jl")

# change the COBRA solver
solver = changeCobraSolver(solverName, solParams)

# load an external mat file
model = loadModel("$(Pkg.dir("COBRA"))/test/ecoli_core_model.mat", "S", "model")
model = loadModel(pkgDir*"/test/ecoli_core_model.mat", "S", "model")

# select the number of reactions
rxnsList = 1:30
Expand Down
8 changes: 4 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@

using Pkg, Distributed, LinearAlgebra, COBRA

pkgDir = joinpath(dirname(pathof(COBRA)))
pkgDir = joinpath(dirname(pathof(COBRA)), "..")

# retrieve all packages that are installed on the system
include(pkgDir*"/checkSetup.jl")
include(pkgDir*"/src/checkSetup.jl")
packages = checkSysConfig()

# configure for runnint the tests in batch
solverName = :GLPKMathProgInterface
nWorkers = 4
connectSSHWorkers = false
include(pkgDir*"/connect.jl")
TESTDIR = pkgDir*"/../test"
include(pkgDir*"/src/connect.jl")
TESTDIR = pkgDir*"/test"

# create a parallel pool and determine its size
if (@isdefined nWorkers) && (@isdefined connectSSHWorkers)
Expand Down
8 changes: 4 additions & 4 deletions test/s_all.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if !@isdefined includeCOBRA
includeCOBRA = true
end

pkgDir = joinpath(dirname(pathof(COBRA)))
pkgDir = joinpath(dirname(pathof(COBRA)), "..")

# output information
testFile = @__FILE__
Expand All @@ -23,7 +23,7 @@ nWorkers = 1
# create a pool and use the COBRA module if the testfile is run in a loop
if includeCOBRA
connectSSHWorkers = false
include(pkgDir*"/connect.jl")
include(pkgDir*"/src//connect.jl")

# create a parallel pool and determine its size
if isdefined(:nWorkers) && isdefined(:connectSSHWorkers)
Expand All @@ -39,13 +39,13 @@ end
getTestModel()

# include a common deck for running tests
include(pkgDir*"/../config/solverCfg.jl")
include(pkgDir*"/config/solverCfg.jl")

# change the COBRA solver
solver = changeCobraSolver(solverName, solParams)

# load an external mat file
model = loadModel(pkgDir*"/../test/ecoli_core_model.mat", "S", "model")
model = loadModel(pkgDir*"/test/ecoli_core_model.mat", "S", "model")

# select the number of reactions
rxnsList = 1:length(model.rxns)
Expand Down
8 changes: 5 additions & 3 deletions test/s_core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ testFile = @__FILE__
# number of workers
nWorkers = 1

pkgDir = joinpath(dirname(pathof(COBRA)), "..")

# create a pool and use the COBRA module if the testfile is run in a loop
if includeCOBRA
connectSSHWorkers = false
include("$(Pkg.dir("COBRA"))/src/connect.jl")
include(pkgDir*"/src/connect.jl")

# create a parallel pool and determine its size
if isdefined(:nWorkers) && isdefined(:connectSSHWorkers)
Expand All @@ -37,13 +39,13 @@ end
getTestModel()

# include a common deck for running tests
include("$(Pkg.dir("COBRA"))/config/solverCfg.jl")
include(pkgDir*"/config/solverCfg.jl")

# change the COBRA solver
solver = changeCobraSolver(solverName, solParams)

# load an external mat file
model = loadModel("$(Pkg.dir("COBRA"))/test/ecoli_core_model.mat", "S", "model")
model = loadModel(pkgDir*"/test/ecoli_core_model.mat", "S", "model")

# select the number of reactions
rxnsList = 1:length(model.rxns)
Expand Down
8 changes: 5 additions & 3 deletions test/s_distinct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ testFile = @__FILE__
# number of workers
nWorkers = 1

pkgDir = joinpath(dirname(pathof(COBRA)), "..")

# create a pool and use the COBRA module if the testfile is run in a loop
if includeCOBRA
connectSSHWorkers = false
include("$(Pkg.dir("COBRA"))/src/connect.jl")
include(pkgDir*"/src/connect.jl")

# create a parallel pool and determine its size
if isdefined(:nWorkers) && isdefined(:connectSSHWorkers)
Expand All @@ -37,13 +39,13 @@ end
getTestModel()

# include a common deck for running tests
include("$(Pkg.dir("COBRA"))/config/solverCfg.jl")
include(pkgDir*"/config/solverCfg.jl")

# change the COBRA solver
solver = changeCobraSolver(solverName, solParams)

# load an external mat file
model = loadModel("$(Pkg.dir("COBRA"))/test/ecoli_core_model.mat", "S", "model")
model = loadModel(pkgDir*"/test/ecoli_core_model.mat", "S", "model")

# define an optPercentage value
optPercentage = 90.0
Expand Down
8 changes: 5 additions & 3 deletions test/s_fba.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ testFile = @__FILE__
# number of workers
nWorkers = 1

pkgDir = joinpath(dirname(pathof(COBRA)), "..")

# create a pool and use the COBRA module if the testfile is run in a loop
if includeCOBRA
connectSSHWorkers = false
include("$(Pkg.dir("COBRA"))/src/connect.jl")
include(pkgDir*"/src/connect.jl")

# create a parallel pool and determine its size
if isdefined(:nWorkers) && isdefined(:connectSSHWorkers)
Expand All @@ -37,13 +39,13 @@ end
getTestModel()

# include a common deck for running tests
include("$(Pkg.dir("COBRA"))/config/solverCfg.jl")
include(pkgDir*"/config/solverCfg.jl")

# change the COBRA solver
solver = changeCobraSolver(solverName, solParams)

# load an external mat file
model = loadModel("$(Pkg.dir("COBRA"))/test/ecoli_core_model.mat", "S", "model")
model = loadModel(pkgDir*"/test/ecoli_core_model.mat", "S", "model")

modelOrig = model

Expand Down
8 changes: 5 additions & 3 deletions test/s_tools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ testFile = @__FILE__
# number of workers
nWorkers = 1

pkgDir = joinpath(dirname(pathof(COBRA)), "..")

# create a pool and use the COBRA module if the testfile is run in a loop
if includeCOBRA
connectSSHWorkers = false
include("$(Pkg.dir("COBRA"))/src/connect.jl")
include(pkgDir*"/src/connect.jl")

# create a parallel pool and determine its size
if isdefined(:nWorkers) && isdefined(:connectSSHWorkers)
Expand All @@ -32,13 +34,13 @@ if includeCOBRA
end

# include a common deck for running tests
include("$(Pkg.dir("COBRA"))/config/solverCfg.jl")
include(pkgDir*"/config/solverCfg.jl")

# change the COBRA solver
solver = changeCobraSolver(solverName, solParams)

# load an external mat file
model = loadModel("$(Pkg.dir("COBRA"))/test/ecoli_core_model.mat", "S", "model")
model = loadModel(pkgDir*"/test/ecoli_core_model.mat", "S", "model")

# find the reaction ID of one reaction
rxnIDs, rxnIDsNE = findRxnIDS(model, ["PPC"])
Expand Down
Loading