Utility functions
AbstractFBCModels export several utilities for easier definition of the model contents; here we explore some of them in individual sections.
import AbstractFBCModels as A
Which accessors should I overload?
You can query the current set of accessor functions as follows:
A.accessors()
38-element Vector{Method}:- balance(a::AbstractFBCModels.AbstractFBCModel) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:133
- bounds(a::AbstractFBCModels.AbstractFBCModel) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:115
- coupling(a::AbstractFBCModels.AbstractFBCModel) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:108
- coupling_annotations(::AbstractFBCModels.AbstractFBCModel, coupling_id::String) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:319
- coupling_bounds(a::AbstractFBCModels.AbstractFBCModel) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:122
- coupling_name(::AbstractFBCModels.AbstractFBCModel, coupling_id::String) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:334
- coupling_notes(::AbstractFBCModels.AbstractFBCModel, coupling_id::String) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:327
- coupling_weights(a::AbstractFBCModels.AbstractFBCModel, coupling_id::String) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:311
- couplings(a::AbstractFBCModels.AbstractFBCModel) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:76
- gene_annotations(::AbstractFBCModels.AbstractFBCModel, gene_id::String) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:285
- gene_name(::AbstractFBCModels.AbstractFBCModel, gene_id::String) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:300
- gene_notes(::AbstractFBCModels.AbstractFBCModel, gene_id::String) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:293
- genes(a::AbstractFBCModels.AbstractFBCModel) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:52
- metabolite_annotations(::AbstractFBCModels.AbstractFBCModel, metabolite_id::String) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:261
- metabolite_charge(::AbstractFBCModels.AbstractFBCModel, metabolite_id::String) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:243
- metabolite_compartment(::AbstractFBCModels.AbstractFBCModel, metabolite_id::String) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:251
- metabolite_formula(::AbstractFBCModels.AbstractFBCModel, metabolite_id::String) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:234
- metabolite_name(::AbstractFBCModels.AbstractFBCModel, metabolite_id::String) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:276
- metabolite_notes(::AbstractFBCModels.AbstractFBCModel, metabolite_id::String) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:269
- metabolites(a::AbstractFBCModels.AbstractFBCModel) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:32
- n_couplings(a::AbstractFBCModels.AbstractFBCModel) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:87
- n_genes(a::AbstractFBCModels.AbstractFBCModel) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:63
- n_metabolites(a::AbstractFBCModels.AbstractFBCModel) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:42
- n_reactions(a::AbstractFBCModels.AbstractFBCModel) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:22
- objective(a::AbstractFBCModels.AbstractFBCModel) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:140
- reaction_annotations(::AbstractFBCModels.AbstractFBCModel, reaction_id::String) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:210
- reaction_gene_association_dnf(::AbstractFBCModels.AbstractFBCModel, reaction_id::String) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:177
- reaction_gene_products_available(::AbstractFBCModels.AbstractFBCModel, reaction_id::String, gene_product_available::Function) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:159
- reaction_gene_products_available_from_dnf(m::AbstractFBCModels.AbstractFBCModel, reaction_id::String, available::Function) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/utils.jl:140
- reaction_name(::AbstractFBCModels.AbstractFBCModel, reaction_id::String) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:225
- reaction_notes(::AbstractFBCModels.AbstractFBCModel, reaction_id::String) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:218
- reaction_stoichiometry(a::AbstractFBCModels.AbstractFBCModel, reaction_id::String) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:191
- reaction_subsystem(::AbstractFBCModels.AbstractFBCModel, reaction_id::String) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:201
- reactions(a::AbstractFBCModels.AbstractFBCModel) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:13
- save(a::AbstractFBCModels.AbstractFBCModel, path::String) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/io.jl:16
- stoichiometry(a::AbstractFBCModels.AbstractFBCModel) in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/accessors.jl:97
- load(::Type{A}, path::String) where A<:AbstractFBCModels.AbstractFBCModel in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/io.jl:7
- filename_extensions(::Type{A}) where A<:AbstractFBCModels.AbstractFBCModel in AbstractFBCModels at /home/runner/work/AbstractFBCModels.jl/AbstractFBCModels.jl/src/io.jl:25
You do not need to overload all of them (e.g., if you model does not have any genes you can completely omit all gene-related functions). The main required ones (esp. the reaction- and metabolite-related ones) will throw an error if not implemented, and the automated tests will fail with them.
Why are there 2 representations of gene-reaction associations?
Gene-reaction association is, in general, a Boolean function – you give it a list of genes that are available (or, symmetrically, knocked out) and a reaction, and it tells you whether the reaction can work or not. This representation is captured in accessor reaction_gene_products_available
.
Some model construction methods, on the other hand, require a relatively streamlined view of the gene-reaction associations, roughly describing "ways in which several possible enzymes that catalyze the reaction can be assembled from individual gene products" – these are sometimes dubbed "isozymes". This view is isomorphic to a Boolean formula in a disjunctive normal form (DNF) (put simply, a DNF would be "a big OR of ANDed identifiers", such as (a && b && c) || (a && d)
). The DNF view of the gene association is accessed via reaction_gene_association_dnf
.
Both representations have pros and cons; the main can be summarized as follows:
- DNF may not be able to represent some valid boolean formulas without an exponential explosion in size – in particular, the formula
(a1||b1) && (a2||b2) && (a3||b3) && ... && (aN||bN)
will explode to roughly2^N
terms in DNF. - There's no simple universal format to store and exchange the descriptions of general boolean functions; we thus do not want to enforce a single one.
Your model is primarily supposed to overload the reaction_gene_products_available
accessor. If you are able to reliably convert your Boolean functions to DNF, you should also overload the reaction_gene_association_dnf
.
In some cases when the model directly stores the DNF form, you may also utilize the reaction_gene_products_available_from_dnf
function to easily implement the reactiongeneproducts_available` by just forwarding the arguments.
Downloading models for testing
For reproducibility, it is often viable to check downloaded files for validity, using e.g. checksums. Since this is a common operation, we provide download_data_file
, which is an appropriate wrapper for Downloads.download
:
mktempdir() do dir
origin = joinpath(dir, "origin")
url = "file://$origin"
dest = joinpath(dir, "model")
open(origin, "w") do f
write(f, "hello")
end
A.download_data_file(
url,
dest,
"2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824",
)
end
"/tmp/jl_2CJqBq/model"
This page was generated using Literate.jl.