Core Tests

Annotation

Tests performed on the annotations of an instance of cobra.Model.

test_annotation.test_gene_product_annotation_overview(model, db)[source]

Expect all genes to have annotations from common databases.

Specific database cross-references are paramount to mapping information. To provide references to as many databases as possible helps to make the metabolic model more accessible to other researchers. This does not only facilitate the use of a model in a broad array of computational pipelines, it also promotes the metabolic model itself to become an organism-specific knowledge base.

For this test to pass, each gene annotation should contain cross-references to a number of databases. The currently selection is listed in annotation.py, but an ongoing discussion can be found at https://github.com/opencobra/memote/issues/332. For each database this test checks for the presence of its corresponding namespace ID to comply with the MIRIAM guidelines i.e. they have to match those defined on https://identifiers.org/.

Since each database is quite different and some potentially incomplete, it may not be feasible to achieve 100% coverage for each of them. Generally it should be possible, however, to obtain cross-references to at least one of the databases for all gene products consistently.

Implementation: Check if the keys of the annotation attribute of each cobra.Gene of the model match with a selection of common genome databases. The annotation attribute of cobrapy components is a dictionary of key:value pairs.

test_annotation.test_gene_product_annotation_presence(model)[source]

Expect all genes to have a non-empty annotation attribute.

This test checks if any annotations at all are present in the SBML annotations field (extended by FBC package) for each gene product, irrespective of the type of annotation i.e. specific database, cross-references, ontology terms, additional information. For this test to pass the model is expected to have genes and each of them should have some form of annotation.

Implementation: Check if the annotation attribute of each cobra.Gene object of the model is unset or empty.

test_annotation.test_gene_product_annotation_wrong_ids(model, db)[source]

Expect all annotations of genes/gene-products to be in the correct format.

To identify databases and the identifiers belonging to them, computational tools rely on the presence of specific patterns. Only when these patterns can be identified consistently is an ID truly machine-readable. This test checks if the database cross-references in reaction annotations conform to patterns defined according to the MIRIAM guidelines, i.e. matching those that are defined at https://identifiers.org/.

The required formats, i.e., regex patterns are further outlined in annotation.py. This test does not carry out a web query for the composed URI, it merely controls that the regex patterns match the identifiers.

Implementation: For those genes whose annotation keys match any of the tested databases, check if the corresponding values match the identifier pattern of each database.

test_annotation.test_metabolite_annotation_overview(model, db)[source]

Expect all metabolites to have annotations from common databases.

Specific database cross-references are paramount to mapping information. To provide references to as many databases as possible helps to make the metabolic model more accessible to other researchers. This does not only facilitate the use of a model in a broad array of computational pipelines, it also promotes the metabolic model itself to become an organism-specific knowledge base.

For this test to pass, each metabolite annotation should contain cross-references to a number of databases. The currently selection is listed in annotation.py, but an ongoing discussion can be found at https://github.com/opencobra/memote/issues/332. For each database this test checks for the presence of its corresponding namespace ID to comply with the MIRIAM guidelines i.e. they have to match those defined on https://identifiers.org/.

Since each database is quite different and some potentially incomplete, it may not be feasible to achieve 100% coverage for each of them. Generally it should be possible, however, to obtain cross-references to at least one of the databases for all metabolites consistently.

Implementation: Check if the keys of the annotation attribute of each cobra.Metabolite of the model match with a selection of common biochemical databases. The annotation attribute of cobrapy components is a dictionary of key:value pairs.

test_annotation.test_metabolite_annotation_presence(model)[source]

Expect all metabolites to have a non-empty annotation attribute.

This test checks if any annotations at all are present in the SBML annotations field for each metabolite, irrespective of the type of annotation i.e. specific database cross-references, ontology terms, additional information. For this test to pass the model is expected to have metabolites and each of them should have some form of annotation.

Implementation: Check if the annotation attribute of each cobra.Metabolite object of the model is unset or empty.

test_annotation.test_metabolite_annotation_wrong_ids(model, db)[source]

Expect all annotations of metabolites to be in the correct format.

To identify databases and the identifiers belonging to them, computational tools rely on the presence of specific patterns. Only when these patterns can be identified consistently is an ID truly machine-readable. This test checks if the database cross-references in metabolite annotations conform to patterns defined according to the MIRIAM guidelines, i.e. matching those that are defined at https://identifiers.org/.

The required formats, i.e., regex patterns are further outlined in annotation.py. This test does not carry out a web query for the composed URI, it merely controls that the regex patterns match the identifiers.

Implementation: For those metabolites whose annotation keys match any of the tested databases, check if the corresponding values match the identifier pattern of each database.

test_annotation.test_metabolite_id_namespace_consistency(model)[source]

Expect metabolite identifiers to be from the same namespace.

In well-annotated models it is no problem if the pool of main identifiers for metabolites consists of identifiers from several databases. However, in models that lack appropriate annotations, it may hamper the ability of other researchers to use it. Running the model through a computational pipeline may be difficult without first consolidating the namespace.

Hence, this test checks if the main metabolite identifiers can be attributed to one single namespace based on the regex patterns defined at https://identifiers.org/

Implementation: Generate a table with each column corresponding to one database from the selection and each row to a metabolite identifier. A Boolean entry indicates whether the identifier matches the regular expression of the corresponding database. Since the Biocyc pattern matches broadly, we assume that any instance of an identifier matching to Biocyc AND any other database pattern is a false positive match for Biocyc and thus set it to false. Sum the positive matches for each database and assume that the largest set is the ‘main’ identifier namespace.

test_annotation.test_reaction_annotation_overview(model, db)[source]

Expect all reactions to have annotations from common databases.

Specific database cross-references are paramount to mapping information. To provide references to as many databases as possible helps to make the metabolic model more accessible to other researchers. This does not only facilitate the use of a model in a broad array of computational pipelines, it also promotes the metabolic model itself to become an organism-specific knowledge base.

For this test to pass, each reaction annotation should contain cross-references to a number of databases. The currently selection is listed in annotation.py, but an ongoing discussion can be found at https://github.com/opencobra/memote/issues/332. For each database this test checks for the presence of its corresponding namespace ID to comply with the MIRIAM guidelines i.e. they have to match those defined on https://identifiers.org/.

Since each database is quite different and some potentially incomplete, it may not be feasible to achieve 100% coverage for each of them. Generally it should be possible, however, to obtain cross-references to at least one of the databases for all reactions consistently.

Implementation: Check if the keys of the annotation attribute of each cobra.Reaction of the model match with a selection of common biochemical databases. The annotation attribute of cobrapy components is a dictionary of key:value pairs.

test_annotation.test_reaction_annotation_presence(model)[source]

Expect all reactions to have a non-empty annotation attribute.

This test checks if any annotations at all are present in the SBML annotations field for each reaction, irrespective of the type of annotation i.e. specific database cross-references, ontology terms, additional information. For this test to pass the model is expected to have reactions and each of them should have some form of annotation.

Implementation: Check if the annotation attribute of each cobra.Reaction object of the model is unset or empty.

test_annotation.test_reaction_annotation_wrong_ids(model, db)[source]

Expect all annotations of reactions to be in the correct format.

To identify databases and the identifiers belonging to them, computational tools rely on the presence of specific patterns. Only when these patterns can be identified consistently is an ID truly machine-readable. This test checks if the database cross-references in reaction annotations conform to patterns defined according to the MIRIAM guidelines, i.e. matching those that are defined at https://identifiers.org/.

The required formats, i.e., regex patterns are further outlined in annotation.py. This test does not carry out a web query for the composed URI, it merely controls that the regex patterns match the identifiers.

Implementation: For those reaction whose annotation keys match any of the tested databases, check if the corresponding values match the identifier pattern of each database.

test_annotation.test_reaction_id_namespace_consistency(model)[source]

Expect reaction identifiers to be from the same namespace.

In well-annotated models it is no problem if the pool of main identifiers for reactions consists of identifiers from several databases. However, in models that lack appropriate annotations, it may hamper the ability of other researchers to use it. Running the model through a computational pipeline may be difficult without first consolidating the namespace.

Hence, this test checks if the main reaction identifiers can be attributed to one single namespace based on the regex patterns defined at https://identifiers.org/

Implementation: Generate a pandas.DataFrame with each column corresponding to one database from the selection and each row to the reaction ID. A boolean entry indicates whether the metabolite ID matches the regex pattern of the corresponding database. Since the Biocyc pattern matches quite, assume that any instance of an identifier matching to Biocyc AND any other DB pattern is a false positive match for Biocyc and then set the boolean to false. Sum the positive matches for each database and assume that the largest set is the ‘main’ identifier namespace.

Basic

Perform basic tests on an instance of cobra.Model.

test_basic.test_compartments_presence(model)[source]

Expect that two or more compartments are defined in the model.

While simplified metabolic models may be perfectly viable, generally across the tree of life organisms contain at least one distinct compartment: the cytosol or cytoplasm. In the case of prokaryotes there is usually a periplasm, and eurkaryotes are more complex. In addition to the internal compartment, a metabolic model also reflects the extracellular environment i.e. the medium/ metabolic context in which the modelled cells grow. Hence, in total, at least two compartments can be expected from a metabolic model.

Implementation: Check if the cobra.Model object has a non-empty “compartments” attribute, this list is populated from the list of sbml:listOfCompartments which should contain at least two sbml:compartment elements.

test_basic.test_find_constrained_pure_metabolic_reactions(model)[source]

Expect zero or more purely metabolic reactions to have fixed constraints.

If a reaction is neither a transport reaction, a biomass reaction nor a boundary reaction, it is counted as a purely metabolic reaction. This test requires the presence of metabolite formula to be able to identify transport reactions. This test simply reports the number of purely metabolic reactions that have fixed constraints and does not have any mandatory ‘pass’ criteria.

Implementation: From the pool of pure metabolic reactions identify reactions which are constrained to values other than the model’s minimal or maximal possible bounds.

test_basic.test_find_constrained_transport_reactions(model)[source]

Expect zero or more transport reactions to have fixed constraints.

Cellular metabolism in any organism usually involves the transport of metabolites across a lipid bi-layer. Hence, this test reports how many of these reactions, which transports metabolites from one compartment to another, have fixed constraints. This test does not have any mandatory ‘pass’ criteria.

Implementation: Please refer to “Transport Reactions” for details on how memote identifies transport reactions. From the pool of transport reactions identify reactions which are constrained to values other than the model’s median lower and upper bounds.

test_basic.test_find_duplicate_metabolites_in_compartments(model)[source]

Expect there to be zero duplicate metabolites in the same compartments.

The main reason for having this test is to help cleaning up merged models or models from automated reconstruction pipelines as these are prone to having identical metabolites from different namespaces (hence different IDs). This test therefore expects that every metabolite in any particular compartment has unique inchikey values.

Implementation: Identifies duplicate metabolites in each compartment by determining if any two metabolites have identical InChI-key annotations. For instance, this function would find compounds with IDs ATP1 and ATP2 in the cytosolic compartment, with both having the same InChI annotations.

test_basic.test_find_duplicate_reactions(model)[source]

Expect there to be zero duplicate reactions.

Identify reactions in a pairwise manner that use the same set of metabolites including potentially duplicate metabolites. Moreover, it will take a reaction’s directionality and compartment into account.

The main reason for having this test is to help cleaning up merged models or models from automated reconstruction pipelines as these are prone to having identical reactions with identifiers from different namespaces.

Implementation:

Compare reactions in a pairwise manner. For each reaction, the metabolite annotations are checked for a description of the structure (via InChI and InChIKey).If they exist, substrates and products as well as the stoichiometries of any reaction pair are compared. Only reactions where the substrates, products, stoichiometry and reversibility are identical are considered to be duplicates. This test will not be able to identify duplicate reactions if there are no structure annotations. Further, it will report reactions with differing bounds as equal if they otherwise match the above conditions.

test_basic.test_find_medium_metabolites(model)[source]

Expect zero or more metabolites to be set as medium.

This test checks all boundary reactions in the model that permit flux towards creating a metabolite, and reports those metabolites. This test does not have any mandatory ‘pass’ criteria.

Implementation: Identify the metabolite IDs of each reaction in the method cobra.Model.medium. Model.medium returns exchange reactions whose bounds permit the uptake of metabolites.

test_basic.test_find_pure_metabolic_reactions(model)[source]

Expect at least one pure metabolic reaction to be defined in the model.

If a reaction is neither a transport reaction, a biomass reaction nor a boundary reaction, it is counted as a purely metabolic reaction. This test requires the presence of metabolite formula to be able to identify transport reactions. This test is passed when the model contains at least one purely metabolic reaction i.e. a conversion of one metabolite into another.

Implementation: From the list of all reactions, those that are boundary, transport and biomass reactions are removed and the remainder assumed to be pure metabolic reactions. Boundary reactions are identified using the attribute cobra.Model.boundary. Please read the description of “Transport Reactions” and “Biomass Reaction Identified” to learn how they are identified.

test_basic.test_find_reactions_with_identical_genes(model)[source]

Expect there to be zero duplicate reactions.

Identify reactions in a pairwise manner that use identical sets of genes. It does not take into account a reaction’s directionality, compartment, metabolites or annotations.

The main reason for having this test is to help cleaning up merged models or models from automated reconstruction pipelines as these are prone to having identical reactions with identifiers from different namespaces.

Implementation:

Compare reactions in a pairwise manner and group reactions whose genes are identical. Skip reactions with missing genes.

test_basic.test_find_reactions_with_partially_identical_annotations(model)[source]

Expect there to be zero duplicate reactions.

Identify reactions in a pairwise manner that are annotated with identical database references. This does not take into account a reaction’s directionality or compartment.

The main reason for having this test is to help cleaning up merged models or models from automated reconstruction pipelines as these are prone to having identical reactions with identifiers from different namespaces. It could also be useful to identify a ‘type’ of reaction that occurs in several compartments.

Implementation:

Identify duplicate reactions globally by checking if any two metabolic reactions have the same entries in their annotation attributes. The heuristic looks at annotations with the keys “metanetx.reaction”, “kegg.reaction”, “brenda”, “rhea”, “biocyc”, “bigg.reaction” only.

test_basic.test_find_reversible_oxygen_reactions(model)[source]

Expect zero or more oxygen-containing reactions to be reversible.

The directionality of oxygen-producing/-consuming reactions affects the model’s ability to grow anaerobically i.e. create faux-anaerobic organisms. This test reports how many of these oxygen-containing reactions are reversible. This test does not have any mandatory ‘pass’ criteria.

Implementation: First, find the metabolite representing atmospheric oxygen in the model on the basis of an internal mapping table or by specifically looking for the formula “O2”. Then, find all reactions that produce or consume oxygen and report those that are reversible.

test_basic.test_find_transport_reactions(model)[source]

Expect >= 1 transport reactions are present in the model.

Cellular metabolism in any organism usually involves the transport of metabolites across a lipid bi-layer. This test reports how many of these reactions, which transports metabolites from one compartment to another, are present in the model, as at least one transport reaction must be present for cells to take up nutrients and/or excrete waste.

Implementation: A transport reaction is defined as follows: 1. It contains metabolites from at least 2 compartments and 2. at least 1 metabolite undergoes no chemical reaction, i.e., the formula and/or annotation stays the same on both sides of the equation.

A notable exception is transport via PTS, which also contains the following restriction: 3. The transported metabolite(s) are transported into a compartment through the exchange of a phosphate.

An example of transport via PTS would be pep(c) + glucose(e) -> glucose-6-phosphate(c) + pyr(c)

Reactions similar to transport via PTS (referred to as “modified transport reactions”) follow a similar pattern: A(x) + B-R(y) -> A-R(y) + B(y)

Such modified transport reactions can be detected, but only when the formula is defined for all metabolites in a particular reaction. If this is not the case, transport reactions are identified through annotations, which cannot detect modified transport reactions.

test_basic.test_find_unique_metabolites(model)[source]

Expect there to be less metabolites when removing compartment tag.

Metabolites may be transported into different compartments, which means that in a compartimentalized model the number of metabolites may be much higher than in a model with no compartments. This test counts only one occurrence of each metabolite and returns this as the number of unique metabolites. The test expects that the model is compartimentalized, and thus, that the number of unique metabolites is generally lower than the total number of metabolites.

Implementation: Reduce the list of metabolites to a unique set by removing the compartment tag. The cobrapy SBML parser adds compartment tags to each metabolite ID.

test_basic.test_gene_protein_reaction_rule_presence(model)[source]

Expect all non-exchange reactions to have a GPR rule.

Gene-Protein-Reaction rules express which gene has what function. The presence of this annotation is important to justify the existence of reactions in the model, and is required to conduct in silico gene deletion studies. However, reactions without GPR may also be valid: Spontaneous reactions, or known reactions with yet undiscovered genes likely lack GPR.

Implementation: Check if each cobra.Reaction has a non-empty “gene_reaction_rule” attribute, which is set by the parser if there is an fbc:geneProductAssociation defined for the corresponding reaction in the SBML.

test_basic.test_genes_presence(model)[source]

Expect that at least one gene is defined in the model.

A metabolic model can still be a useful tool without any genes, however there are certain methods which rely on the presence of genes and, more importantly, the corresponding gene-protein-reaction rules. This test requires that there is at least one gene defined.

Implementation: Check if the cobra.Model object has non-empty “genes” attribute, this list is populated from the list of fbc:listOfGeneProducts which should contain at least one fbc:geneProduct.

test_basic.test_metabolic_coverage(model)[source]

Expect a model to have a metabolic coverage >= 1.

The degree of metabolic coverage indicates the modeling detail of a given reconstruction calculated by dividing the total amount of reactions by the amount of genes. Models with a ‘high level of modeling detail have ratios >1, and models with a low level of detail have ratios <1. This difference arises as models with basic or intermediate levels of detail are assumed to include many reactions in which several gene products and their enzymatic transformations are ‘lumped’.

Implementation: Divides the amount reactions by the amount of genes. Raises an error if the model does not contain either reactions or genes.

test_basic.test_metabolites_charge_presence(model)[source]

Expect all metabolites to have charge information.

To be able to ensure that reactions are charge-balanced, all model metabolites ought to be provided with a charge. Since it may be difficult to obtain charges for certain metabolites this test serves as a mere report. Models can still be stoichiometrically consistent even when charge information is not defined for each metabolite.

Implementation: Check if each cobra.Metabolite has a non-empty “charge” attribute. This attribute is set by the parser if there is an fbc:charge attribute for the corresponding species in the SBML.

test_basic.test_metabolites_formula_presence(model)[source]

Expect all metabolites to have a formula.

To be able to ensure that reactions are mass-balanced, all model metabolites ought to be provided with a chemical formula. Since it may be difficult to obtain formulas for certain metabolites this test serves as a mere report. Models can still be stoichiometrically consistent even when chemical formulas are not defined for each metabolite.

Implementation: Check if each cobra.Metabolite has a non-empty “formula” attribute. This attribute is set by the parser if there is an fbc:chemicalFormula attribute for the corresponding species in the SBML.

test_basic.test_metabolites_presence(model)[source]

Expect that at least one metabolite is defined in the model.

To be useful a metabolic model should consist at least of a few metabolites that are converted by reactions. This test simply checks if there are more than zero metabolites.

Implementation: Check if the cobra.Model object has non-empty “metabolites” attribute, this list is populated from the list of sbml:listOfSpecies which should contain at least one sbml:species.

test_basic.test_model_id_presence(model)[source]

Expect that the model has an identifier.

The MIRIAM guidelines require a model to be identified via an ID. Further, the ID will be displayed on the memote snapshot report, which helps to distinguish the output clearly.

Implementation: Check if the cobra.Model object has a non-empty “id” attribute, this value is parsed from the “id” attribute of the <model> tag in the SBML file e.g. <model fbc:strict=”true” id=”iJO1366”>.

test_basic.test_ngam_presence(model)[source]

Expect a single non growth-associated maintenance reaction.

The Non-Growth Associated Maintenance reaction (NGAM) is an ATP-hydrolysis reaction added to metabolic models to represent energy expenses that the cell invests in continuous processes independent of the growth rate. Memote tries to infer this reaction from a list of buzzwords, and the stoichiometry and components of a simple ATP-hydrolysis reaction.

Implementation: From the list of all reactions that convert ATP to ADP select the reactions that match the irreversible reaction “ATP + H2O -> ADP + HO4P + H+”, whose metabolites are situated within the main model compartment. The main model compartment is assumed to be the cytosol, yet, if that cannot be identified, it is assumed to be the compartment with the most metabolites. The resulting list of reactions is then filtered further by attempting to match the reaction name with any of the following buzzwords (‘maintenance’, ‘atpm’, ‘requirement’, ‘ngam’, ‘non-growth’, ‘associated’). If this is possible only the filtered reactions are returned, if not the list is returned as is.

test_basic.test_protein_complex_presence(model)[source]

Expect that more than one enzyme complex is present in the model.

Based on the gene-protein-reaction (GPR) rules, it is possible to infer whether a reaction is catalyzed by a single gene product, isozymes or by a heteromeric protein complex. This test checks that at least one such heteromeric protein complex is defined in any GPR of the model. For S. cerevisiae it could be shown that “essential proteins tend to [cluster] together in essential complexes” (https://doi.org/10.1074%2Fmcp.M800490-MCP200).

This might also be a relevant metric for other organisms.

Implementation: Identify GPRs which contain at least one logical AND that combines two different gene products.

test_basic.test_reactions_presence(model)[source]

Expect that at least one reaction is defined in the model.

To be useful a metabolic model should consist at least of a few reactions. This test simply checks if there are more than zero reactions.

Implementation: Check if the cobra.Model object has non-empty “reactions” attribute, this list is populated from the list of sbml:listOfReactions which should contain at least one sbml:reaction.

test_basic.test_transport_reaction_gpr_presence(model)[source]

Expect a small fraction of transport reactions not to have a GPR rule.

As it is hard to identify the exact transport processes within a cell, transport reactions are often added purely for modeling purposes. Highlighting where assumptions have been made versus where there is proof may help direct the efforts to improve transport and transport energetics of the tested metabolic model. However, transport reactions without GPR may also be valid: Diffusion, or known reactions with yet undiscovered genes likely lack GPR.

Implementation: Check which cobra.Reactions classified as transport reactions have a non-empty “gene_reaction_rule” attribute.

Biomass

Biomass tests performed on an instance of cobra.Model.

N.B.: We parametrize each function here with the identified biomass reactions. In the storage of test results we rely on the order of the biomass fixtures to remain the same as the parametrized test cases.

test_biomass.test_biomass_consistency(model, reaction_id)[source]

Expect biomass components to sum up to 1 g[CDW].

This test only yields sensible results if all biomass precursor metabolites have chemical formulas assigned to them. The molecular weight of the biomass reaction in metabolic models is defined to be equal to 1 g/mmol. Conforming to this is essential in order to be able to reliably calculate growth yields, to cross-compare models, and to obtain valid predictions when simulating microbial consortia. A deviation from 1 - 1E-03 to 1 + 1E-06 is accepted.

Implementation: Multiplies the coefficient of each metabolite of the biomass reaction with its molecular weight calculated from the formula, then divides the overall sum of all the products by 1000.

test_biomass.test_biomass_default_production(model, reaction_id)[source]

Expect biomass production in default medium.

Using flux balance analysis this test optimizes the model for growth in the medium that is set by default. Any non-zero growth rate is accepted to pass this test.

Implementation: Calculate the solution of FBA with the biomass reaction set as objective function and the model’s default constraints.

test_biomass.test_biomass_open_production(model, reaction_id)[source]

Expect biomass production in complete medium.

Using flux balance analysis this test optimizes the model for growth using a complete medium i.e. unconstrained boundary reactions. Any non-zero growth rate is accepted to pass this test.

Implementation: Calculate the solution of FBA with the biomass reaction set as objective function and after removing any constraints from all boundary reactions.

test_biomass.test_biomass_precursors_default_production(model, reaction_id)[source]

Expect production of all biomass precursors in default medium.

Using flux balance analysis this test optimizes for the production of each metabolite that is a substrate of the biomass reaction with the exception of atp and h2o. Optimizations are carried out using the default conditions. This is useful when reconstructing the precursor biosynthesis pathways of a metabolic model. To pass this test, the model should be able to synthesis all the precursors.

Implementation: For each biomass precursor (except ATP and H2O) add a temporary demand reaction, then carry out FBA with this reaction as the objective. Collect all metabolites for which this optimization is equal to zero or infeasible.

test_biomass.test_biomass_precursors_open_production(model, reaction_id)[source]

Expect precursor production in complete medium.

Using flux balance analysis this test optimizes for the production of each metabolite that is a substrate of the biomass reaction with the exception of atp and h2o. Optimizations are carried out using a complete medium i.e. unconstrained boundary reactions. This is useful when reconstructing the precursor biosynthesis pathways of a metabolic model. To pass this test, the model should be able to synthesis all the precursors.

Implementation: First remove any constraints from all boundary reactions, then for each biomass precursor (except ATP and H2O) add a temporary demand reaction, then carry out FBA with this reaction as the objective. Collect all metabolites for which this optimization is below or equal to zero or is infeasible.

test_biomass.test_biomass_presence(model)[source]

Expect the model to contain at least one biomass reaction.

The biomass composition aka biomass formulation aka biomass reaction is a common pseudo-reaction accounting for biomass synthesis in constraints-based modelling. It describes the stoichiometry of intracellular compounds that are required for cell growth. While this reaction may not be relevant to modeling the metabolism of higher organisms, it is essential for single-cell modeling.

Implementation: Identifies possible biomass reactions using two principal steps:

1. Return reactions that include the SBO annotation “SBO:0000629” for biomass.
If no reactions can be identifies this way:
1. Look for the buzzwords “biomass”, “growth” and “bof” in reaction IDs. 2. Look for metabolite IDs or names that contain the buzzword “biomass” and obtain the set of reactions they are involved in. 3. Remove boundary reactions from this set. 4. Return the union of reactions that match the buzzwords and of the reactions that metabolites are involved in that match the buzzword.

This test checks if at least one biomass reaction is present.

test_biomass.test_direct_metabolites_in_biomass(model, reaction_id)[source]

Expect the ratio of direct metabolites to be below 0.5.

Some biomass precursors are taken from the media and directly consumed by the biomass reaction. It might not be a problem for ions or metabolites for which the organism in question is auxotrophic. However, too many of these metabolites may be artifacts of automated gap-filling procedures. Many gap-filling algorithms attempt to minimise the number of added reactions. This can lead to many biomass precursors being “direct metabolites”.

This test reports the ratio of direct metabolites to the total amount of precursors to a given biomass reaction. It specifically looks for metabolites that are only in either exchange, transport or biomass reactions. Bear in mind that this may lead to false positives in heavily compartimentalized models.

To pass this test, the ratio of direct metabolites should be less than 50% of all biomass precursors. This is an arbitrary threshold but it takes into account that while certain ions do not serve a relevant metabolic function, it may still be important to include them in the biomass reaction to account for the impact of their uptake energy costs.

This threshold is subject to change in the future.

Implementation: Identify biomass precursors (excluding ATP and H+), identify cytosol and extracellular compartment from an internal mapping table. Then, determine which precursors is only involved in transport, boundary and biomass reactions. Using FBA with the biomass function as the objective then determine whether the metabolite is taken up only to be consumed by the biomass reaction.

test_biomass.test_essential_precursors_not_in_biomass(model, reaction_id)[source]

Expect the biomass reaction to contain all essential precursors.

There are universal components of life that make up the biomass of all known organisms. These include all proteinogenic amino acids, deoxy- and ribonucleotides, water and a range of metabolic cofactors.

This test reports the amount of biomass precursors that have been reported to be essential constituents of the biomass equation. All of the following precursors need to be included in the biomass reaction to pass the test:

Aminoacids: trp__L, cys__L, his__L, tyr__L, met__L, phe__L, ser__L, pro__L, asp__L, thr__L, gln__L, glu__L, ile__L, arg__L, lys__L, val__L, leu__L, ala__L, gly, asn__L DNA: datp, dctp, dttp, dgtp RNA: atp, ctp, utp, gtp Cofactors: nad, nadp, amet, fad, pydx5p, coa, thmpp, fmn and h2o

These metabolites were selected based on the results presented by DOI:10.1016/j.ymben.2016.12.002

Please note, that the authors also suggest to count C1 carriers (derivatives of tetrahydrofolate(B9) or tetrahydromethanopterin) as universal cofactors. We have omitted these from this check because there are many individual compounds that classify as C1 carriers, and it is not clear a priori which one should be preferred. In a future update, we may consider identifying these using a chemical ontology.

Implementation: Determine whether the model employs a lumped or split biomass reaction. Then, using an internal mapping table, try to identify the above list of essential precursors in list of precursor metabolites of either type of biomass reaction. List IDs in the models namespace if the metabolite exists, else use the MetaNetX namespace if the metabolite does not exist in the model. Identifies the cytosol from an internal mapping table, and assumes that all precursors exist in that compartment.

test_biomass.test_fast_growth_default(model, reaction_id)[source]

Expect the predicted growth rate for each BOF to be below 2.81.

The growth rate of a metabolic model should not be faster than that of the fastest growing organism. This is based on a doubling time of Vibrio natriegens which was reported to be 14.8 minutes by: Henry H. Lee, Nili Ostrov, Brandon G. Wong, Michaela A. Gold, Ahmad S. Khalil, George M. Church in https://www.biorxiv.org/content/biorxiv/early/2016/06/12/058487.full.pdf

The calculation ln(2)/(14.8/60) ~ 2.81 yields the corresponding growth rate.

Implementation: Calculate the solution of FBA with the biomass reaction set as objective function and a model’s default constraints. Then check if the objective value is higher than 2.81.

test_biomass.test_gam_in_biomass(model, reaction_id)[source]

Expect the biomass reactions to contain ATP and ADP.

The growth-associated maintenance (GAM) term accounts for the energy in the form of ATP that is required to synthesize macromolecules such as Proteins, DNA and RNA, and other processes during growth. A GAM term is therefore a requirement for any well-defined biomass reaction. There are different ways to implement this term depending on what kind of experimental data is available and the preferred way of implementing the biomass reaction: - Chemostat growth experiments yield a single GAM value representing the

required energy per gram of biomass (Figure 6 of [Rd215e49c2e91-1]). This can be implemented in a lumped biomass reaction or in the final term of a split biomass reaction.
  • Experimentally delineating or estimating the GAM requirements for each macromolecule separately is possible, yet requires either data from multi-omics experiments [2] or detailed resources [Rd215e49c2e91-1] , respectively. Individual energy requirements can either be implemented in a split biomass equation on the term for each macromolecule, or, on the basis of the biomass composition, they can be summed into a single GAM value for growth and treated as mentioned above.

This test is only able to detect if a lumped biomass reaction or the final term of a split biomass reaction contains this term. Hence, it will only detect the use of a single GAM value as opposed to individual energy requirements of each macromolecule. Both approaches, however, have its merits.

Implementation: Determines the metabolite identifiers of ATP, ADP, H2O, HO4P and H+ based on an internal mapping table. Checks if ATP and H2O are a subset of the reactants and ADP, HO4P and H+ a subset of the products of the biomass reaction.

References: .. [Rd215e49c2e91-1] Thiele, I., & Palsson, B. Ø. (2010, January). A protocol for

generating a high-quality genome-scale metabolic reconstruction. Nature protocols. Nature Publishing Group. http://doi.org/10.1038/nprot.2009.203
[2]Hackett, S. R., Zanotelli, V. R. T., Xu, W., Goya, J., Park, J. O., Perlman, D. H., Gibney, P. A., Botstein, D., Storey, J. D., Rabinowitz, J. D. (2010, January). Systems-level analysis of mechanisms regulating yeast metabolic flux Science http://doi.org/10.1126/science.aaf2786

Consistency

Stoichiometric consistency tests for an instance of cobra.Model.

test_consistency.test_blocked_reactions(model)[source]

Expect all reactions to be able to carry flux in complete medium.

Universally blocked reactions are reactions that during Flux Variability Analysis cannot carry any flux while all model boundaries are open. Generally blocked reactions are caused by network gaps, which can be attributed to scope or knowledge gaps.

Implementation: Use flux variability analysis (FVA) implemented in cobra.flux_analysis.find_blocked_reactions with open_exchanges=True. Please refer to the cobrapy documentation for more information: https://cobrapy.readthedocs.io/en/stable/autoapi/cobra/flux_analysis/ variability/index.html#cobra.flux_analysis.variability. find_blocked_reactions

test_consistency.test_detect_energy_generating_cycles(model, met)[source]

Expect that no energy metabolite can be produced out of nothing.

When a model is not sufficiently constrained to account for the thermodynamics of reactions, flux cycles may form which provide reduced metabolites to the model without requiring nutrient uptake. These cycles are referred to as erroneous energy-generating cycles. Their effect on the predicted growth rate in FBA may account for an increase of up to 25%, which makes studies involving the growth rates predicted from such models unreliable.

Implementation: This test uses an implementation of the algorithm presented by: Fritzemeier, C. J., Hartleb, D., Szappanos, B., Papp, B., & Lercher, M. J. (2017). Erroneous energy-generating cycles in published genome scale metabolic networks: Identification and removal. PLoS Computational Biology, 13(4), 1–14. http://doi.org/10.1371/journal.pcbi.1005494

First attempt to identify the main compartment (cytosol), then attempt to identify each metabolite of the referenced list of energy couples via an internal mapping table. Construct a dissipation reaction for each couple. Carry out FBA with each dissipation reaction as the objective and report those reactions that non-zero carry flux.

test_consistency.test_find_deadends(model)[source]

Expect no dead-ends to be present.

Dead-ends are metabolites that can only be produced but not consumed by reactions in the model. They may indicate the presence of network and knowledge gaps.

Implementation: Find dead-end metabolites structurally by considering only reaction equations and reversibility. FBA is not carried out.

test_consistency.test_find_disconnected(model)[source]

Expect no disconnected metabolites to be present.

Disconnected metabolites are not part of any reaction in the model. They are most likely left-over from the reconstruction process, but may also point to network and knowledge gaps.

Implementation: Check for any metabolites of the cobra.Model object with emtpy reaction attribute.

test_consistency.test_find_metabolites_not_consumed_with_open_bounds(model)[source]

Expect metabolites to be consumable in complete medium.

In complete medium, a model should be able to divert flux from every metabolite. This test opens all the boundary reactions i.e. simulates a complete medium and checks if any metabolite cannot be consumed individually using flux balance analysis. Metabolites that cannot be consumed this way are likely dead-end metabolites or upstream of reactions with fixed constraints. To pass this test all metabolites should be consumable.

Implementation: Open all model boundary reactions, then for each metabolite in the model add a boundary reaction and minimize it with FBA.

test_consistency.test_find_metabolites_not_produced_with_open_bounds(model)[source]

Expect metabolites to be producible in complete medium.

In complete medium, a model should be able to divert flux to every metabolite. This test opens all the boundary reactions i.e. simulates a complete medium and checks if any metabolite cannot be produced individually using flux balance analysis. Metabolites that cannot be produced this way are likely orphan metabolites, downstream of reactions with fixed constraints, or blocked by a cofactor imbalance. To pass this test all metabolites should be producible.

Implementation: Open all model boundary reactions, then for each metabolite in the model add a boundary reaction and maximize it with FBA.

test_consistency.test_find_orphans(model)[source]

Expect no orphans to be present.

Orphans are metabolites that are only consumed but not produced by reactions in the model. They may indicate the presence of network and knowledge gaps.

Implementation: Find orphan metabolites structurally by considering only reaction equations and reversibility. FBA is not carried out.

test_consistency.test_find_reactions_unbounded_flux_default_condition(model)[source]

Expect the fraction of unbounded reactions to be low.

A large fraction of model reactions able to carry unlimited flux under default conditions indicates problems with reaction directionality, missing cofactors, incorrectly defined transport reactions and more.

Implementation: Without changing the default constraints run flux variability analysis. From the FVA results identify those reactions that carry flux equal to the model’s maximal or minimal flux.

test_consistency.test_find_stoichiometrically_balanced_cycles(model)[source]

Expect no stoichiometrically balanced loops to be present.

Stoichiometrically Balanced Cycles are artifacts of insufficiently constrained networks resulting in reactions that can carry flux when all the boundaries have been closed.

Implementation: Close all model boundary reactions and then use flux variability analysis (FVA) to identify reactions that carry flux.

test_consistency.test_reaction_charge_balance(model)[source]

Expect all reactions to be charge balanced.

This will exclude biomass, exchange and demand reactions as they are unbalanced by definition. It will also fail all reactions where at least one metabolite does not have a charge defined.

In steady state, for each metabolite the sum of influx equals the sum of efflux. Hence the net charges of both sides of any model reaction have to be equal. Reactions where at least one metabolite does not have a charge are not considered to be balanced, even though the remaining metabolites participating in the reaction might be.

Implementation: For each reaction that isn’t a boundary or biomass reaction check if each metabolite has a non-zero charge attribute and if so calculate if the overall sum of charges of reactants and products is equal to zero.

test_consistency.test_reaction_mass_balance(model)[source]

Expect all reactions to be mass balanced.

This will exclude biomass, exchange and demand reactions as they are unbalanced by definition. It will also fail all reactions where at least one metabolite does not have a formula defined.

In steady state, for each metabolite the sum of influx equals the sum of efflux. Hence the net masses of both sides of any model reaction have to be equal. Reactions where at least one metabolite does not have a formula are not considered to be balanced, even though the remaining metabolites participating in the reaction might be.

Implementation: For each reaction that isn’t a boundary or biomass reaction check if each metabolite has a non-zero elements attribute and if so calculate if the overall element balance of reactants and products is equal to zero.

test_consistency.test_stoichiometric_consistency(model)[source]

Expect that the stoichiometry is consistent.

Stoichiometric inconsistency violates universal constraints: 1. Molecular masses are always positive, and 2. On each side of a reaction the mass is conserved. A single incorrectly defined reaction can lead to stoichiometric inconsistency in the model, and consequently to unconserved metabolites. Similar to insufficient constraints, this may give rise to cycles which either produce mass from nothing or consume mass from the model.

Implementation: This test first uses an implementation of the algorithm presented in section 3.1 by Gevorgyan, A., M. G Poolman, and D. A Fell. “Detection of Stoichiometric Inconsistencies in Biomolecular Models.” Bioinformatics 24, no. 19 (2008): 2245. doi: 10.1093/bioinformatics/btn425 Should the model be inconsistent, then the list of unconserved metabolites is computed using the algorithm described in section 3.2 of the same publication.

Matrix

Tests for matrix properties performed on an instance of cobra.Model.

test_matrix.test_absolute_extreme_coefficient_ratio(model, threshold=1000000000.0)[source]

Show the ratio of the absolute largest and smallest non-zero coefficients.

This test will return the absolute largest and smallest, non-zero coefficients of the stoichiometric matrix. A large ratio of these values may point to potential numerical issues when trying to solve different mathematical optimization problems such as flux-balance analysis.

To pass this test the ratio should not exceed 10^9. This threshold has been selected based on experience, and is likely to be adapted when more data on solver performance becomes available.

Implementation: Compose the stoichiometric matrix, then calculate absolute coefficients and lastly use the maximal value and minimal non-zero value to calculate the ratio.

test_matrix.test_degrees_of_freedom(model)[source]

Show the degrees of freedom of the stoichiometric matrix.

The degrees of freedom of the stoichiometric matrix, i.e., the number of ‘free variables’ is system specific and corresponds to the dimension of the (right) null space of the matrix.

Implementation: Compose the stoichiometric matrix, then calculate the dimensionality of the null space using the rank-nullity theorem outlined by Alama, J. The Rank+Nullity Theorem. Formalized Mathematics 15, (2007).

test_matrix.test_matrix_rank(model)[source]

Show the rank of the stoichiometric matrix.

The rank of the stoichiometric matrix is system specific. It is calculated using singular value decomposition (SVD).

Implementation: Compose the stoichiometric matrix, then estimate the rank, i.e. the dimension of the column space, of a matrix. The algorithm used by this function is based on the singular value decomposition of the matrix.

test_matrix.test_number_independent_conservation_relations(model)[source]

Show the number of independent conservation relations in the model.

This test will return the number of conservation relations, i.e., conservation pools through the left null space of the stoichiometric matrix. This test is not scored, as the dimension of the left null space is system-specific.

Implementation: Calculate the left null space, i.e., the null space of the transposed stoichiometric matrix, using an algorithm based on the singular value decomposition adapted from https://scipy.github.io/old-wiki/pages/Cookbook/RankNullspace.html Then, return the estimated dimension of that null space.

SBO

Tests for SBO terms performed on an instance of cobra.Model.

test_sbo.test_biomass_specific_sbo_presence(model)[source]

Expect all biomass reactions to be annotated with SBO:0000629.

SBO:0000629 represents the term ‘biomass production’. The Systems Biology Ontology defines an exchange reaction as follows: ‘Biomass production, often represented ‘R_BIOMASS_’, is usually the optimization target reaction of constraint-based models, and can consume multiple reactants to produce multiple products. It is also assumed that parts of the reactants are also consumed in unrepresented processes and hence products do not have to reflect all the atom composition of the reactants. Formulation of a biomass production process entails definition of the macromolecular content (eg. cellular protein fraction), metabolic constitution of each fraction (eg. amino acids), and subsequently the atomic composition (eg. nitrogen atoms). More complex biomass functions can additionally incorporate details of essential vitamins and cofactors required for growth.’ Every reaction representing the biomass production should be annotated with this.

Implementation: Check if each biomass reaction has a non-zero “annotation” attribute that contains the key “sbo” with the associated value being one of the SBO terms above.

test_sbo.test_demand_specific_sbo_presence(model)[source]

Expect all demand reactions to be annotated with SBO:0000627.

SBO:0000628 represents the term ‘demand reaction’. The Systems Biology Ontology defines a demand reaction as follows: ‘A modeling process analogous to exchange reaction, but which operates upon “internal” metabolites. Metabolites that are consumed by these reactions are assumed to be used in intra-cellular processes that are not part of the model. Demand reactions, often represented ‘R_DM_’, can also deliver metabolites (from intra-cellular processes that are not considered in the model).’ Every demand reaction should be annotated with this. Demand reactions differ from exchange reactions in that the metabolites are not removed from the extracellular environment, but from any of the organism’s compartments. Demand reactions differ from sink reactions in that they are designated as irreversible.

Implementation: Check if each demand reaction has a non-zero “annotation” attribute that contains the key “sbo” with the associated value being one of the SBO terms above.

test_sbo.test_exchange_specific_sbo_presence(model)[source]

Expect all exchange reactions to be annotated with SBO:0000627.

SBO:0000627 represents the term ‘exchange reaction’. The Systems Biology Ontology defines an exchange reaction as follows: ‘A modeling process to provide matter influx or efflux to a model, for example to replenish a metabolic network with raw materials (eg carbon / energy sources). Such reactions are conceptual, created solely for modeling purposes, and do not have a physical correspondence. Exchange reactions, often represented as ‘R_EX_’, can operate in the negative (uptake) direction or positive (secretion) direction. By convention, a negative flux through an exchange reaction represents uptake of the corresponding metabolite, and a positive flux represent discharge.’ Every exchange reaction should be annotated with this. Exchange reactions differ from demand reactions in that the metabolites are removed from or added to the extracellular environment only.

Implementation: Check if each exchange reaction has a non-zero “annotation” attribute that contains the key “sbo” with the associated value being one of the SBO terms above.

test_sbo.test_gene_sbo_presence(model)[source]

Expect all genes to have a some form of SBO-Term annotation.

The Systems Biology Ontology (SBO) allows researchers to annotate a model with terms which indicate the intended function of its individual components. The available terms are controlled and relational and can be viewed here http://www.ebi.ac.uk/sbo/main/tree.

Check if each cobra.Gene has a non-zero “annotation” attribute that contains the key “sbo”.

test_sbo.test_gene_specific_sbo_presence(model)[source]

Expect all genes to be annotated with SBO:0000243.

SBO:0000243 represents the term ‘gene’. Every gene should be annotated with this.

Implementation: Check if each cobra.Gene has a non-zero “annotation” attribute that contains the key “sbo” with the associated value being one of the SBO terms above.

test_sbo.test_metabolic_reaction_specific_sbo_presence(model)[source]

Expect all metabolic reactions to be annotated with SBO:0000176.

SBO:0000176 represents the term ‘biochemical reaction’. Every metabolic reaction that is not a transport or boundary reaction should be annotated with this. The results shown are relative to the total amount of pure metabolic reactions.

Implementation: Check if each pure metabolic reaction has a non-zero “annotation” attribute that contains the key “sbo” with the associated value being the SBO term above.

test_sbo.test_metabolite_sbo_presence(model)[source]

Expect all metabolites to have a some form of SBO-Term annotation.

The Systems Biology Ontology (SBO) allows researchers to annotate a model with terms which indicate the intended function of its individual components. The available terms are controlled and relational and can be viewed here http://www.ebi.ac.uk/sbo/main/tree.

Implementation: Check if each cobra.Metabolite has a non-zero “annotation” attribute that contains the key “sbo”.

test_sbo.test_metabolite_specific_sbo_presence(model)[source]

Expect all metabolites to be annotated with SBO:0000247.

SBO:0000247 represents the term ‘simple chemical’. Every metabolite should be annotated with this.

Implementation: Check if each cobra.Metabolite has a non-zero “annotation” attribute that contains the key “sbo” with the associated value being one of the SBO terms above.

test_sbo.test_reaction_sbo_presence(model)[source]

Expect all reactions to have a some form of SBO-Term annotation.

The Systems Biology Ontology (SBO) allows researchers to annotate a model with terms which indicate the intended function of its individual components. The available terms are controlled and relational and can be viewed here http://www.ebi.ac.uk/sbo/main/tree.

Implementation: Check if each cobra.Reaction has a non-zero “annotation” attribute that contains the key “sbo”.

test_sbo.test_sink_specific_sbo_presence(model)[source]

Expect all sink reactions to be annotated with SBO:0000632.

SBO:0000632 represents the term ‘sink reaction’. The Systems Biology Ontology defines a sink reaction as follows: ‘A modeling process to provide matter influx or efflux to a model, for example to replenish a metabolic network with raw materials (eg carbon / energy sources). Such reactions are conceptual, created solely for modeling purposes, and do not have a physical correspondence. Unlike the analogous demand (SBO:….) reactions, which are usually designated as irreversible, sink reactions always represent a reversible uptake/secretion processes, and act as a metabolite source with no cost to the cell. Sink reactions, also referred to as R_SINK_, are generally used for compounds that are metabolized by the cell but are produced by non-metabolic, un-modeled cellular processes.’ Every sink reaction should be annotated with this. Sink reactions differ from exchange reactions in that the metabolites are not removed from the extracellular environment, but from any of the organism’s compartments.

Implementation: Check if each sink reaction has a non-zero “annotation” attribute that contains the key “sbo” with the associated value being one of the SBO terms above.

test_sbo.test_transport_reaction_specific_sbo_presence(model)[source]

Expect all transport reactions to be annotated properly.

‘SBO:0000185’, ‘SBO:0000588’, ‘SBO:0000587’, ‘SBO:0000655’, ‘SBO:0000654’, ‘SBO:0000660’, ‘SBO:0000659’, ‘SBO:0000657’, and ‘SBO:0000658’ represent the terms ‘transport reaction’ and ‘translocation reaction’, in addition to their children (more specific transport reaction labels). Every transport reaction that is not a pure metabolic or boundary reaction should be annotated with one of these terms. The results shown are relative to the total of all transport reactions.

Implementation: Check if each transport reaction has a non-zero “annotation” attribute that contains the key “sbo” with the associated value being one of the SBO terms above.

Thermodynamics

Perform tests using eQuilibrator API on an instance of cobra.Model.

test_thermodynamics.test_find_candidate_irreversible_reactions(model)[source]

Identify reversible reactions that could be irreversible.

If a reaction is neither a transport reaction, a biomass reaction nor a boundary reaction, it is counted as a purely metabolic reaction. This test checks if the reversibility attribute of each reaction agrees with a thermodynamics-based calculation of reversibility.

Implementation: To determine reversibility we calculate the reversibility index ln_gamma (natural logarithm of gamma) of each reaction using the eQuilibrator API. We consider reactions, whose reactants’ concentrations would need to change by more than three orders of magnitude for the reaction flux to reverse direction, to be likely candidates of irreversible reactions. This assume default concentrations around 100 μM (~3 μM—3 mM) at pH = 7, I = 0.1 M and T = 298 K. The corresponding reversibility index is approximately 7. For further information on the thermodynamic and implementation details please refer to https://doi.org/10.1093/bioinformatics/bts317 and https://pypi.org/project/equilibrator-api/.

Please note that currently eQuilibrator can only determine the reversibility index for chemically and redox balanced reactions whose metabolites can be mapped to KEGG compound identifiers (e.g. C00001). In addition to not being mappable to KEGG or the reaction not being balanced, there is a possibility that the metabolite cannot be broken down into chemical groups which is essential for the calculation of Gibbs energy using group contributions. This test collects each erroneous reaction and returns them as a tuple containing each list in the following order:

  1. Reactions with reversibility index
  2. Reactions with incomplete mapping to KEGG
  3. Reactions with metabolites that are problematic during calculation
  4. Chemically or redox unbalanced Reactions (after mapping to KEGG)

This test simply reports the number of reversible reactions that, according to the reversibility index, are likely to be irreversible.