Reference

Types

AbstractFBCModels.AbstractFBCModelType
abstract type AbstractFBCModel

A supertype of all Flux-balance-Based Constrained metabolic models that share the common interface defined by AbstractFBCModels.jl.

To use the interface for your type, make it a subtype of AbstractFBCModel and provide methods for various functions used with the model. Use accessors to find the current list of methods, and utilize run_fbcmodel_type_tests and run_fbcmodel_file_tests to test the completeness and compatibility of your implementation with the assumptions of the interface.

AbstractFBCModels.AnnotationsType
Annotations = Dict{String,Vector{String}}

Dictionary used to store (possible multiple) standardized annotations of something, such as a metabolite or a reaction (as listed by metabolites and reactions).

Example

Annotations("PubChem" => ["CID12345", "CID54321"])
AbstractFBCModels.GeneAssociationDNFType
GeneAssociationDNF = Vector{Vector{String}}

Disjunctive normal form of simple gene associations. For example, [[A, B], [B]] represents two possibilities to run a given reaction, where the first requires both gene products A and B, while the second possibility only requires gene product C.

AbstractFBCModels.NotesType
Notes = Dict{String,Vector{String}}

Free-form notes about something (e.g. a gene listed by genes), categorized by "topic".

Model content accessors

AbstractFBCModels.balanceMethod
balance(
    a::AbstractFBCModels.AbstractFBCModel
) -> SparseArrays.SparseVector{Float64, Int64}

Get the sparse balance vector of a model, which usually corresponds to the accumulation term associated with stoichiometric matrix.

By default, the balance is assumed to be exactly zero.

AbstractFBCModels.boundsMethod
bounds(
    a::AbstractFBCModels.AbstractFBCModel
) -> Tuple{Vector{Float64}, Vector{Float64}}

Lower and upper bounds of all reactions in the model.

AbstractFBCModels.couplingMethod
coupling(
    a::AbstractFBCModels.AbstractFBCModel
) -> SparseArrays.SparseMatrixCSC{Float64, Int64}

Sparse matrix that describes the coupling of a given model.

This usually corresponds to all additional constraints in the model, such as the ones used for split-direction reactions and community modeling. The matrix must be of size n_couplings by n_reactions.

AbstractFBCModels.coupling_annotationsMethod
coupling_annotations(
    _::AbstractFBCModels.AbstractFBCModel,
    coupling_id::String
) -> Dict{String, Vector{String}}

A dictionary of standardized names that may help to identify the corresponding coupling.

AbstractFBCModels.coupling_boundsMethod
coupling_bounds(
    a::AbstractFBCModels.AbstractFBCModel
) -> Tuple{Vector{Float64}, Vector{Float64}}

Lower and upper bounds of all couplings in the model.

AbstractFBCModels.coupling_nameMethod
coupling_name(
    _::AbstractFBCModels.AbstractFBCModel,
    coupling_id::String
) -> Union{Nothing, String}

The name of the given coupling in the model, if recorded.

AbstractFBCModels.coupling_notesMethod
coupling_notes(
    _::AbstractFBCModels.AbstractFBCModel,
    coupling_id::String
) -> Dict{String, Vector{String}}

Free-text notes organized in a dictionary by topics about the given coupling in the model.

AbstractFBCModels.coupling_weightsMethod
coupling_weights(
    a::AbstractFBCModels.AbstractFBCModel,
    coupling_id::String
) -> Dict{String, Float64}

The weights of reactions in the given coupling bound. Returns a dictionary that maps the reaction IDs to their weights.

Using this function may be more efficient in cases than loading the whole coupling.

AbstractFBCModels.couplingsMethod
couplings(
    a::AbstractFBCModels.AbstractFBCModel
) -> Vector{String}

Return identifiers of all coupling bounds contained in the model. Empty if none.

Coupling bounds are typically not named in models, but should be.

COMPATIBILITY NOTE: Couplings currently default to empty to prevent breakage. This behavior will change with next major version.

AbstractFBCModels.gene_annotationsMethod
gene_annotations(
    _::AbstractFBCModels.AbstractFBCModel,
    gene_id::String
) -> Dict{String, Vector{String}}

A dictionary of standardized names that identify the corresponding gene or product. The dictionary assigns vectors of possible identifiers to identifier system names, such as "PDB" => ["PROT01"].

AbstractFBCModels.gene_nameMethod
gene_name(
    _::AbstractFBCModels.AbstractFBCModel,
    gene_id::String
) -> Union{Nothing, String}

The name of the given gene in the model, if recorded.

AbstractFBCModels.gene_notesMethod
gene_notes(
    _::AbstractFBCModels.AbstractFBCModel,
    gene_id::String
) -> Dict{String, Vector{String}}

Free-text notes organized in a dictionary by topics about the given gene in the model.

AbstractFBCModels.genesMethod
genes(
    a::AbstractFBCModels.AbstractFBCModel
) -> Vector{String}

Return identifiers of all genes contained in the model. Empty if none.

Genes are also sometimes called "gene products" but we write genes for simplicity.

AbstractFBCModels.metabolite_annotationsMethod
metabolite_annotations(
    _::AbstractFBCModels.AbstractFBCModel,
    metabolite_id::String
) -> Dict{String, Vector{String}}

A dictionary of standardized names that may help to identify the metabolite. The dictionary should assigns vectors of possible identifiers to identifier system names, such as "ChEMBL" => ["123"] or "PubChem" => ["CID123", "CID654645645"].

AbstractFBCModels.metabolite_chargeMethod
metabolite_charge(
    _::AbstractFBCModels.AbstractFBCModel,
    metabolite_id::String
) -> Union{Nothing, Int64}

The charge of the given metabolite in the model, or nothing in case the charge is not recorded.

AbstractFBCModels.metabolite_compartmentMethod
metabolite_compartment(
    _::AbstractFBCModels.AbstractFBCModel,
    metabolite_id::String
) -> Union{Nothing, String}

The compartment of the given metabolite in the model. nothing if no compartment is assigned.

AbstractFBCModels.metabolite_formulaMethod
metabolite_formula(
    _::AbstractFBCModels.AbstractFBCModel,
    metabolite_id::String
) -> Union{Nothing, Dict{String, Int64}}

The formula of the given metabolite in the model, or nothing in case the formula is not recorded.

AbstractFBCModels.metabolite_nameMethod
metabolite_name(
    _::AbstractFBCModels.AbstractFBCModel,
    metabolite_id::String
) -> Union{Nothing, String}

The name of the given metabolite, if assigned.

AbstractFBCModels.metabolite_notesMethod
metabolite_notes(
    _::AbstractFBCModels.AbstractFBCModel,
    metabolite_id::String
) -> Dict{String, Vector{String}}

Free-text notes organized in a dictionary by topics about the given metabolite in the model.

AbstractFBCModels.metabolitesMethod
metabolites(
    a::AbstractFBCModels.AbstractFBCModel
) -> Vector{String}

Return a vector of metabolite identifiers in a model.

As with reactions, some metabolites in models may be virtual, representing purely technical equality constraints.

AbstractFBCModels.n_couplingsMethod
n_couplings(a::AbstractFBCModels.AbstractFBCModel) -> Int64

The number of coupling bounds in the model (must be equal to the length of vector given by couplings).

This may be more efficient than calling couplings and measuring the array.

AbstractFBCModels.n_genesMethod
n_genes(a::AbstractFBCModels.AbstractFBCModel) -> Int64

The number of genes in the model (must be equal to the length of vector given by genes).

This may be more efficient than calling genes and measuring the array.

AbstractFBCModels.n_metabolitesFunction

The number of metabolites in the given model. Must be equal to the length of the vector returned by metabolites, and may be more efficient for just determining the size.

AbstractFBCModels.n_reactionsMethod
n_reactions(a::AbstractFBCModels.AbstractFBCModel) -> Int64

The number of reactions in the given model. Must be equal to the length of the vector returned by reactions, and may be more efficient for just determining the size.

AbstractFBCModels.objectiveMethod
objective(
    a::AbstractFBCModels.AbstractFBCModel
) -> SparseArrays.SparseVector{Float64, Int64}

The objective vector of the model.

AbstractFBCModels.reaction_annotationsMethod
reaction_annotations(
    _::AbstractFBCModels.AbstractFBCModel,
    reaction_id::String
) -> Dict{String, Vector{String}}

A dictionary of standardized names that may help identifying the reaction. The dictionary assigns vectors of possible identifiers to identifier system names, e.g. "Reactome" => ["reactomeID123"].

AbstractFBCModels.reaction_gene_association_dnfMethod
reaction_gene_association_dnf(
    _::AbstractFBCModels.AbstractFBCModel,
    reaction_id::String
) -> Union{Nothing, Vector{Vector{String}}}

Returns the sets of genes that need to be present for the reaction to work in a DNF formula. This helps for constructively using the reaction-gene-association information.

If a model overloads this function, it must also properly overload reaction_gene_products_available. You can use reaction_gene_products_available_from_dnf as a helper for computing the availability from an existing overload of reaction_gene_association_dnf.

AbstractFBCModels.reaction_gene_products_availableMethod
reaction_gene_products_available(
    _::AbstractFBCModels.AbstractFBCModel,
    reaction_id::String,
    gene_product_available::Function
) -> Union{Nothing, Bool}

Evaluate whether the reaction can work given in a conditions given by the current availability of gene products, or nothing if the information is not recorded. The availability us queried via gene_products_available, which must be a function of a single String argument that returns Bool.

Generally it may be simpler to use reaction_gene_association_dnf, but in many models the complexity of the conversion to DNF is prohibitive.

For generality reasons, this must be properly overloaded for all models that overload reaction_gene_association_dnf. Implementations may define reaction_gene_products_available_from_dnf to derive a valid implementation from an existing overload of reaction_gene_association_dnf.

AbstractFBCModels.reaction_nameMethod
reaction_name(
    _::AbstractFBCModels.AbstractFBCModel,
    reaction_id::String
) -> Union{Nothing, String}

Name of the given reaction.

AbstractFBCModels.reaction_notesMethod
reaction_notes(
    _::AbstractFBCModels.AbstractFBCModel,
    reaction_id::String
) -> Dict{String, Vector{String}}

Free-text notes organized in a dictionary by topics about the given reaction in the model.

AbstractFBCModels.reaction_stoichiometryMethod
reaction_stoichiometry(
    a::AbstractFBCModels.AbstractFBCModel,
    reaction_id::String
) -> Dict{String, Float64}

The stoichiometry of the given reaction as a dictionary maps the metabolite IDs to their stoichiometric coefficients.

Using this function may be more efficient in cases than loading the whole stoichiometry.

AbstractFBCModels.reactionsMethod
reactions(
    a::AbstractFBCModels.AbstractFBCModel
) -> Vector{String}

Return a vector of reaction identifiers in a model.

For technical reasons, the "reactions" may sometimes not be true reactions but various virtual and helper pseudo-reactions that are used in the metabolic modeling, such as metabolite exchanges, separated forward and reverse reaction directions, supplies of enzymatic and genetic material and virtual cell volume, etc.

AbstractFBCModels.stoichiometryMethod
stoichiometry(
    a::AbstractFBCModels.AbstractFBCModel
) -> SparseArrays.SparseMatrixCSC{Float64, Int64}

The sparse stoichiometric matrix of a given model.

This usually corresponds to all the equality constraints in the model. The matrix must be of size n_metabolites by n_reactions.

IO functions

AbstractFBCModels.filename_extensionsMethod
filename_extensions(
    _::Type{A<:AbstractFBCModels.AbstractFBCModel}
) -> Vector{String}

A vector of filename extensions that are common for files that contain the given metabolic model type. This is used by load to guess the type of the model that should be loaded.

AbstractFBCModels.loadMethod
load(path::String) -> Any

Load a model from path. The type of the model is automatically guessed based on the filename extension. The guessing inspects all subtypes of AbstractFBCModel, thus always requires compilation – if possible, specify the proper type using the 2-parameter version of load to save time.

AbstractFBCModels.loadMethod
load(
    _::Type{A<:AbstractFBCModels.AbstractFBCModel},
    path::String
) -> Any

Load a model from path.

AbstractFBCModels.saveMethod
save(a::AbstractFBCModels.AbstractFBCModel, path::String)

Save a model to the given path.

Testing of model implementations

AbstractFBCModels.run_fbcmodel_file_testsMethod
run_fbcmodel_file_tests(
    ::Type{X<:AbstractFBCModels.AbstractFBCModel},
    path::String;
    name,
    test_save
) -> Union{Test.FallbackTestSet, Test.DefaultTestSet}

Test if the given model type loads properly from a file.

The function uses the testing infrastructure from Test to report problems – it is supposed to be a part of larger test-sets, preferably in all model implementation packages.

AbstractFBCModels.run_fbcmodel_type_testsMethod
run_fbcmodel_type_tests(
    _::Type{X<:AbstractFBCModels.AbstractFBCModel}
) -> Union{Test.FallbackTestSet, Test.DefaultTestSet}

Test if the given model type works right.

The function uses the testing infrastructure from Test to report problems – it is supposed to be a part of larger test-sets, preferably in all model implementation packages.

Miscellaneous utilities

AbstractFBCModels.accessorsMethod
accessors() -> Vector{Method}

Provide a methodswith-style listing of accessors that the model implementors should implement.

For typesystem reasons, the list will not contain methods for save and filename_extensions that dispatch on type objects. You should implement these as well.

AbstractFBCModels.download_data_fileMethod
download_data_file(url, path, hash) -> Any

Download the file at url and save it at path, also check if this file is the expected file by calling check_cached_file_hash. If the file has already been downloaded and stored at path, then it is not downloaded again.

Canonical model implementation

AbstractFBCModels.CanonicalModel.CouplingType
mutable struct Coupling

A canonical Julia representation of a row in a coupling matrix of the AbstractFBCModels interface.

Fields

  • name::Union{Nothing, String}

  • reaction_weights::Dict{String, Float64}

  • lower_bound::Float64

  • upper_bound::Float64

  • annotations::Dict{String, Vector{String}}

  • notes::Dict{String, Vector{String}}

AbstractFBCModels.CanonicalModel.GeneType
mutable struct Gene

A canonical Julia representation of a gene in the AbstractFBCModels interface.

Fields

  • name::Union{Nothing, String}

  • annotations::Dict{String, Vector{String}}

  • notes::Dict{String, Vector{String}}

AbstractFBCModels.CanonicalModel.MetaboliteType
mutable struct Metabolite

A canonical Julia representation of a metabolite in the AbstractFBCModels interface.

Fields

  • name::Union{Nothing, String}

  • compartment::Union{Nothing, String}

  • formula::Union{Nothing, Dict{String, Int64}}

  • charge::Union{Nothing, Int64}

  • balance::Float64

  • annotations::Dict{String, Vector{String}}

  • notes::Dict{String, Vector{String}}

AbstractFBCModels.CanonicalModel.ModelType
struct Model <: AbstractFBCModels.AbstractFBCModel

A canonical Julia representation of a metabolic model that sotres exactly the data represented by AbstractFBCModels accessors.

The implementation is useful for manipulating model data manually without writing new model types, or even for constructing models from base data in many simple cases.

Additionally, you can use the implementation of accessors for this model type in the source code of AbstractFBCModels as a starting point for creating an AbstractFBCModel interface for your own models.

Fields

  • reactions::Dict{String, AbstractFBCModels.CanonicalModel.Reaction}

  • metabolites::Dict{String, AbstractFBCModels.CanonicalModel.Metabolite}

  • genes::Dict{String, AbstractFBCModels.CanonicalModel.Gene}

  • couplings::Dict{String, AbstractFBCModels.CanonicalModel.Coupling}

AbstractFBCModels.CanonicalModel.ReactionType
mutable struct Reaction

A canonical Julia representation of a reaction in the AbstractFBCModels interface.

Fields

  • name::Union{Nothing, String}

  • lower_bound::Float64

  • upper_bound::Float64

  • stoichiometry::Dict{String, Float64}

  • objective_coefficient::Float64

  • gene_association_dnf::Union{Nothing, Vector{Vector{String}}}

  • annotations::Dict{String, Vector{String}}

  • notes::Dict{String, Vector{String}}