Reference
Types
AbstractFBCModels.Maybe — TypeA nice name for a "nullable" type.
AbstractFBCModels.AbstractFBCModel — Typeabstract type AbstractFBCModelA 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.Annotations — TypeAnnotations = 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.GeneAssociationDNF — TypeGeneAssociationDNF = 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.MetaboliteFormula — TypeMetaboliteFormula = Dict{String,Int}Dictionary of atoms and their abundances in a molecule.
AbstractFBCModels.Notes — TypeNotes = Dict{String,Vector{String}}Free-form notes about something (e.g. a gene listed by genes), categorized by "topic".
AbstractFBCModels.SparseMat — TypeA shortname for a sparse matrix.
AbstractFBCModels.SparseVec — TypeA shortname for a sparse vector.
Model content accessors
AbstractFBCModels.balance — Methodbalance(
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.bounds — FunctionLower and upper bounds of all reactions in the model.
AbstractFBCModels.coupling — Methodcoupling(
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_annotations — Methodcoupling_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_bounds — Methodcoupling_bounds(
a::AbstractFBCModels.AbstractFBCModel
) -> Tuple{Vector{Float64}, Vector{Float64}}
Lower and upper bounds of all couplings in the model.
AbstractFBCModels.coupling_name — Methodcoupling_name(
_::AbstractFBCModels.AbstractFBCModel,
coupling_id::String
) -> Union{Nothing, String}
The name of the given coupling in the model, if recorded.
AbstractFBCModels.coupling_notes — Methodcoupling_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_weights — Methodcoupling_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.couplings — Methodcouplings(
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_annotations — Methodgene_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_name — Methodgene_name(
_::AbstractFBCModels.AbstractFBCModel,
gene_id::String
) -> Union{Nothing, String}
The name of the given gene in the model, if recorded.
AbstractFBCModels.gene_notes — Methodgene_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.genes — FunctionReturn 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_annotations — Methodmetabolite_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_charge — Methodmetabolite_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_compartment — Methodmetabolite_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_formula — Methodmetabolite_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_name — Methodmetabolite_name(
_::AbstractFBCModels.AbstractFBCModel,
metabolite_id::String
) -> Union{Nothing, String}
The name of the given metabolite, if assigned.
AbstractFBCModels.metabolite_notes — Methodmetabolite_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.metabolites — FunctionReturn 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_couplings — Methodn_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_genes — FunctionThe 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_metabolites — FunctionThe 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_reactions — FunctionThe 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.objective — FunctionThe objective vector of the model.
AbstractFBCModels.reaction_annotations — Methodreaction_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_dnf — Methodreaction_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_available — Methodreaction_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_name — Methodreaction_name(
_::AbstractFBCModels.AbstractFBCModel,
reaction_id::String
) -> Union{Nothing, String}
Name of the given reaction.
AbstractFBCModels.reaction_notes — Methodreaction_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_stoichiometry — FunctionThe 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.reaction_subsystem — Methodreaction_subsystem(
_::AbstractFBCModels.AbstractFBCModel,
reaction_id::String
) -> Vector{String}
Optional string labels that may be used to categorize the reaction.
AbstractFBCModels.reactions — FunctionReturn 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.stoichiometry — FunctionThe 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.eligible_model_types_for_filename — Methodeligible_model_types_for_filename(path::String) -> Vector
Find which of the known subtypes of AbstractFBCModel would typically be able to open the file at path, using information in filename_extensions.
AbstractFBCModels.filename_extensions — Methodfilename_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.guess_model_type_from_filename — Methodguess_model_type_from_filename(path::String) -> Any
Guess which of the known subtypes of AbstractFBCModel would typically open the path (internally using eligible_model_types_for_filename for the purpose). Throws an error if the match is ambiguous or missing.
AbstractFBCModels.load — Methodload(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.load — Methodload(
_::Type{A<:AbstractFBCModels.AbstractFBCModel},
path::String
) -> Any
Load a model from path.
AbstractFBCModels.pretty_print_kwdef — Methodpretty_print_kwdef(io::IO, x)
Helper for nicely showing the contents of possibly complicated model structures.
AbstractFBCModels.save — FunctionSave a model to the given path.
Testing of model implementations
AbstractFBCModels.run_fbcmodel_file_tests — Methodrun_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_tests — Methodrun_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.
AbstractFBCModels.@atest — MacroInternal helper macro for rendering easily interpretable test failures.
Miscellaneous utilities
AbstractFBCModels.accessors — Methodaccessors() -> Vector{Method}
Provide a methodswith-style listing of accessors that the model implementors may implement.
AbstractFBCModels.check_cached_file_hash — Methodcheck_cached_file_hash(path, expected_checksum)
Check if the file at path has the expected hash.
At this point, the hash is always SHA256.
AbstractFBCModels.download_data_file — Methoddownload_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.
AbstractFBCModels.reaction_gene_products_available_from_dnf — Methodreaction_gene_products_available_from_dnf(
m::AbstractFBCModels.AbstractFBCModel,
reaction_id::String,
available::Function
) -> Union{Nothing, Bool}
Utility function to compute the value of reaction_gene_products_available for models that already implement reaction_gene_association_dnf.
AbstractFBCModels.required_accessors — Methodrequired_accessors() -> Vector{Method}
Provide a methodswith-style listing of functions that the model implementors must implement to have a functional AbstractFBCModel.
The output listing is a subset of the longer list returned by accessors. Some of the accessors may have sensible defaults – e.g., it is safe to assume an empty default coupling if the functions are not defined. The accessors which do not possess a natural default and thus must be defined (and trying to use a model without them will almost certainly cause runtime errors) are exactly the ones listed by this function.
Canonical model implementation
AbstractFBCModels.CanonicalModel.Coupling — Typemutable struct CouplingA 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::Float64upper_bound::Float64annotations::Dict{String, Vector{String}}notes::Dict{String, Vector{String}}
AbstractFBCModels.CanonicalModel.Gene — Typemutable struct GeneA 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.Metabolite — Typemutable struct MetaboliteA 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::Float64annotations::Dict{String, Vector{String}}notes::Dict{String, Vector{String}}
AbstractFBCModels.CanonicalModel.Model — Typemutable struct Model <: AbstractFBCModels.AbstractFBCModelA 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.Reaction — Typemutable struct ReactionA canonical Julia representation of a reaction in the AbstractFBCModels interface.
Fields
name::Union{Nothing, String}lower_bound::Float64upper_bound::Float64stoichiometry::Dict{String, Float64}objective_coefficient::Float64gene_association_dnf::Union{Nothing, Vector{Vector{String}}}annotations::Dict{String, Vector{String}}notes::Dict{String, Vector{String}}
Utilities for canonical models
AbstractFBCModels.CanonicalModel.identifier_map — Methodidentifier_map(
m::AbstractFBCModels.CanonicalModel.Model;
reaction_map,
metabolite_map,
gene_map,
coupling_map,
compartment_map
) -> AbstractFBCModels.CanonicalModel.Model
Rebuild the given Model with all identifiers changed accordingly to the given individual identifier-mapping functions in arguments. These take a single String identifier as an argument, and return a new String identifier. By default, the identifier maps are identity, i.e., no identifiers are changed.
The identifier maps must be injective and pure within identifier_map, i.e., they must not create identifier name conflicts, and the results returned for a given argument must be the same during the whole call of identifier_map. Errors stemming from use of non-injective and impure identifier maps are not handled.
Internal data structures are copied only by reference wherever possible.