Skip to content

Commit

Permalink
add docs dependencies and skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
exaexa committed Sep 13, 2023
1 parent bb51737 commit d33fcd0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/Project.toml
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"
33 changes: 33 additions & 0 deletions docs/src/metabolic-modeling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,36 @@ import JuMP, SBML

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

0 comments on commit d33fcd0

Please sign in to comment.