-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from COBREXA/mk-tests-and-docs
tests and docs
- Loading branch information
Showing
7 changed files
with
99 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
[deps] | ||
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" | ||
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" | ||
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6" | ||
JuMP = "4076af6c-e467-56ae-b986-b466b2749572" | ||
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306" | ||
SBML = "e5567a89-2604-4b09-9718-f5f78e97c3bb" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
# # Example: Metabolic modeling | ||
# | ||
# In this example we demonstrate the use of `ConstraintTree` structure for | ||
# solving the metabolic modeling tasks. At the same time, we show how to export | ||
# the structure to JuMP, and use `SolutionTree` to find useful information | ||
# about the result. | ||
# | ||
# First, let's import some packages: | ||
|
||
import ConstraintTrees as C | ||
import JuMP, SBML | ||
|
||
# We will need a constraint-based metabolic model; for this test we will use | ||
# the usual "E. Coli core metabolism" model as available from BiGG: | ||
|
||
import Downloads: download | ||
|
||
download("http://bigg.ucsd.edu/static/models/e_coli_core.xml", "e_coli_core.xml") | ||
|
||
ecoli = SBML.readSBML("e_coli_core.xml") | ||
|
||
# Let's first build the constrained representation of the problem. First, we | ||
# will need a variable for each of the reactions in the model: | ||
|
||
c = C.allocate_variables(keys = Symbol.(keys(ecoli.reactions))); | ||
|
||
@test length(C.elems(c)) == length(ecoli.reactions) #src | ||
|
||
# The above operation returns a `ConstraintTree`. You can browse these as a | ||
# dictionary: | ||
C.elems(c) | ||
|
||
# ...or much more conveniently using the record dot syntax as properties: | ||
c.R_PFK | ||
|
||
# Operator `^` is used to name individual constraints and directories in the | ||
# hierarchy. Let us name our constraints as "fluxes" (which is a common name in | ||
# metabolic modeling) and explore the result: | ||
|
||
c = :fluxes^c; | ||
|
||
# We can see that there is now only a single "top-level directory" in the | ||
# constraint system: | ||
collect(keys(C.elems(c))) | ||
|
||
@test collect(keys(c)) == [:fluxes] #src | ||
@test issetequal(collect(keys(c.fluxes)), sort(Symbol.(collect(keys(ecoli.reactions))))) #src | ||
|
||
# ...which can be explored with the dot access again: | ||
c.fluxes.R_PFK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters