Commit 5f330f73 authored by St. Elmo's avatar St. Elmo
Browse files

test update

parent e5eb9304
......@@ -24,6 +24,7 @@ SBML_jll = "bb12108a-f4ef-5f88-8ef3-0b33ff7017f1"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StringDistances = "88034a9c-02f8-509d-84a9-84ec65e18404"
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Tulip = "6dd1b50a-3aae-11e9-10b5-ef983d2400fa"
......
......@@ -22,8 +22,8 @@
| [![docs-img]][docs-url] | [![CI][ci-img]][ci-url] | [![codecov][cov-img]][cov-url] |
This is package aims to provide constraint based reconstruction and analysis (COBRA) tools in the Julia environment, similar to Cobrapy in Python and the Cobra Toolbox in Matlab.
This package provides basic convenience functions, e.g. model IO, construction, modification, FBA, pFBA, sampling, etc. It can also be used to interface with [Equilibrator](http://equilibrator.weizmann.ac.il/) and [BRENDA](https://www.brenda-enzymes.org/).
More importantly, it also exposes the user to the core structures used in COBRA, e.g. the stoichiometric matrix, etc., so that custom optimization routines can be written as painlessly as possible (due in large part to JuMP). An alternative Julia package hosted by OpenCobra, [COBRA.jl](https://github.com/opencobra/COBRA.jl), also exists, but its scope is more restricted than `CobraTools.jl`.
This package provides basic convenience functions, e.g. model IO, construction, modification, and FBA, pFBA, sampling, etc. It can also be used to interface with [Equilibrator](http://equilibrator.weizmann.ac.il/) and [BRENDA](https://www.brenda-enzymes.org/).
More importantly, it also exposes the user to the core structures used in COBRA, e.g. the stoichiometric matrix, etc., so that custom optimization routines can be written as painlessly as possible (due in large part to [JuMP](https://jump.dev/)). An alternative Julia package hosted by openCOBRA, [COBRA.jl](https://github.com/opencobra/COBRA.jl), also exists, but its scope is more restricted than `CobraTools.jl`.
## Installation
......@@ -43,10 +43,10 @@ model = read_model("iJO1366.json") # models have pretty printing
# choose objective to maximize
biomass = findfirst(model.reactions, "BIOMASS_Ec_iJO1366_WT_53p95M")
# Use convenience functions
# FBA - use convenience functions
sol = fba(model, biomass, GLPK.Optimizer; solver_attributes=Dict("msg_lev" => GLPK.GLP_MSG_OFF)) # classic flux balance analysis
# DIY - automatically construct basic JuMP model from a constraint based model
# FBA DIY - automatically construct basic JuMP model from a constraint based model
cbm, v, mb, ubs, lbs = build_cbm(model) # get the constraint based model (cbm) in JuMP format: S*v=b (mb: mass balance constraints) with lbs <= v <= ubs.
set_optimizer(cbm, GLPK.Optimizer) # use JuMP functions to set optimizer
set_optimizer_attribute(cbm, "msg_lev", GLPK.GLP_MSG_OFF) # use JuMP functions to set optimizer attributes
......@@ -54,8 +54,8 @@ set_optimizer_attribute(cbm, "msg_lev", GLPK.GLP_MSG_OFF) # use JuMP functions t
optimize!(cbm)
sol = map_fluxes(v, model) # map fluxes to reaction ids.
# Really DIY - manually construct a JuMP model from constraint based model
S, b, ubvec, lbvec = get_core_model(model) # S*v = b with lbvec <= v <= ubvec from model
# FBA really DIY - manually construct a JuMP model from constraint based model
S, b, ubvec, lbvec = get_core_model(model) # get S*v = b with lbvec <= v <= ubvec from model
cbm = JuMP.Model()
nvars = size(S, 2) # number of variables in model
v = @variable(cbmodel, v[1:nvars]) # flux variables
......
......@@ -24,8 +24,13 @@ Some of the features used in this package require external programs to be instal
* The Equilibrator interface requires that the Equilibrator-API has been installed and can be accessed through Julia's PyCall package. Refer to the [Equilibrator-API website](https://gitlab.com/equilibrator/equilibrator-api) for installation instructions. Within Julia, if you can call `pyimport("equilibrator_api")` successfully, then you will be able to use the functions exposed here. To actually use the functions insert `using PyCall` in your main level script (before or after `using CobraTools`).
* To extract turnover numbers, Km, Kcat/Km and Ki from the Brenda database, you will need to download the database as a txt file [available here](https://www.brenda-enzymes.org/download_brenda_without_registration.php) (~250 MB).
The optimization solvers are implemented through `JuMP` and thus this package should be solver agnostic. All tests are conducted using `GLPK.jl` but other solvers should work (I use `Gurobi.jl` mostly).
The optimization solvers are implemented through `JuMP` and thus this package should be solver agnostic. All tests are conducted using `Tulip.jl` and `OSQP.jl`, but other solvers should also work (I mostly use `Gurobi.jl`).
## Quick Example
```@example
using CobraTools
```
......@@ -38,7 +38,7 @@ export
,
# base
Model, Gene, Reaction, Metabolite, check_duplicate_annotations, get_atoms, check_same_formula, is_mass_balanced, check_duplicate_reaction,
Model, Gene, Reaction, Metabolite, check_duplicate_annotations, get_atoms, check_same_formula, is_mass_balanced, check_duplicate_reaction,
# construction
, , , , , , add!, rm!, fix_model!,
......
......@@ -3,6 +3,7 @@ using CobraTools
using JuMP
using Tulip
using OSQP
using Suppressor
include("testfuncs.jl")
......
......@@ -66,13 +66,15 @@ function test_gene()
g.notes = Dict("notes"=>["blah", "blah"])
g.annotation = Dict("sboterm" => "sbo", "ncbigene" => ["ads", "asds"])
repr(show(g)) # test IO
@suppress_out begin
g
end
g2 = Gene("gene2")
genes = [g, g2]
repr(show(genes)) # test IO
# repr(show(genes)) # test IO
ind = genes[g]
if ind != 1
......@@ -108,7 +110,7 @@ function test_metabolite()
m1.notes = Dict("notes"=>["blah", "blah"])
m1.annotation = Dict("sboterm" => "sbo", "kegg.compound" => ["ads", "asds"])
repr(show(m1)) # test IO
# repr(show(m1)) # test IO
m2 = Metabolite("met2")
m2.formula = "C6H12O6N"
......@@ -119,7 +121,7 @@ function test_metabolite()
mets = [m1, m2, m3]
repr(show(mets)) # test IO
# repr(show(mets)) # test IO
ind = mets[m2]
if ind != 2
......@@ -176,7 +178,7 @@ function test_reaction()
r1.annotation = Dict("sboterm" => "sbo", "biocyc" => ["ads", "asds"])
r1.objective_coefficient = 1.0
repr(show(r1)) # test IO
# repr(show(r1)) # test IO
r2 = Reaction("r2", Dict(m1 => -2.0, m4 => 1.0), "rev")
if r2.lb != -1000.0 && r2.ub != 0.0
......@@ -190,7 +192,7 @@ function test_reaction()
rxns = [r1, r2, r3]
repr(show(rxns)) # test IO
# repr(show(rxns)) # test IO
ind = rxns[r3]
if ind != 3
......@@ -268,7 +270,7 @@ function test_model()
model.metabolites = mets
model.genes = genes
repr(show(model)) # test IO
# repr(show(model)) # test IO
ind = model[r2]
if ind != 2
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment