memote - the genome-scale metabolic model test suite

Our goal in promoting this tool is to achieve two major shifts in the metabolic model building community:

  1. Models should be version-controlled such that changes can be tracked and if necessary reverted. Ideally, they should be available through a public repository such as GitHub that will allow other researchers to inspect, share, and contribute to the model.
  2. Models should, for the benefit of the community and for research gain, live up to certain standards and minimal functionality.

The memote tool therefore performs four subfunctions:

  1. Create a skeleton git repository for the model.
  2. Run the current model through a test suite that represents the community standard.
  3. Generate an informative report which details the results of the test suite in a visually appealing manner.
  4. (Re-)compute test statistics for an existing version controlled history of a metabolic model.

And in order to make this process as easy as possible the generated repository can easily be integrated with continuous integration testing providers such as Travis CI, which means that anytime you push a model change to GitHub, the test suite will be run automatically and a report will be available for you to look at via GitHub pages for your repository.

Contact

For comments and questions get in touch via

Are you excited about this project? Consider contributing by adding novel tests, reporting or fixing bugs, and generally help us make this a better software for everyone.

Contents

Getting Started

Installation

We highly recommend creating a Python virtualenv for your model testing purposes.

Stable release

To install memote, run this command in your terminal:

$ pip install memote

This is the preferred method to install memote, as it will always install the most recent stable release.

If you don’t have pip installed, this Python installation guide can guide you through the process.

From sources

The sources for memote can be downloaded from the Github repo.

You can either clone the public repository:

$ git clone https://github.com/opencobra/memote.git

Or download the tarball or zip archive:

$ curl  -OL https://github.com/opencobra/memote/archive/master.zip

Once you have a copy of the source files, you can install it with:

$ pip install .

After installation, memote can be employed in two different ways: As a benchmarking tool for ad hoc model assessment and as an automated testing suite to aid with the reconstruction of metabolic models. When using memote to benchmark a model, the tests are run once and a report is generated which describes the status-quo. As an automated testing suite, memote facilitates tracking incremental model changes in a version controlled repository and can enable continuous testing and reporting if desired.

Here, we explain step-by-step the necessary commands to pursue either workflow. Users that have already followed this tutorial once may want to refer to the cheat-sheet flowchart to refresh their memory.

Benchmark

Single Model

To benchmark the performance of a single model, run this command in your terminal:

$ memote report snapshot path/to/model.xml

This will generate the performance report as index.html.

The output filename can be changed by adding the following option. To illustrate here it is changed to report.html.

$ memote report snapshot --filename "report.html" path/to/model.xml

While the html report is still a work in progress, we recommend relying on the verbose output of the command line tool above. Users can tweak the console output by passing additional arguments directly to pytest through the --pytest-args or simply -a option. This can be done by writing the pytest arguments as one continuous string.

For a more detailed traceback try:

$ memote report snapshot -a "--tb long" --filename "report.html" path/to/model.xml

For a full list of possible arguments please refer to the pytest documentation.

Comparative

This functionality is coming soon.

Comparing two models against each other and quickly identify the differences.

Reconstruction

When starting a memote repository, users need to provide an SBMLv3-FBC formatted file. Automatic draft reconstruction tools such as Pathway Tools, Model SEED, The RAVEN Toolbox and others are able to output files in this format. Model repositories such as BiGG or BioModels further serve as a great resource for models in the correct format.

With this in mind, starting a local, version-controlled model repository is as simple as running the following command:

$ memote new
CI tested, online and public workflow:

After this, the user will be prompted with a few questions regarding details of the project. If the project is to be kept strictly locally, the user does not need to supply GitHub (or GitLab - not implemented yet) credentials. However, these are a requirement if the project is to use the full benefits of distributed version control such as cloud-based development, remote collaboration and community feedback. It is important to note that furthermore a public repository is needed to set up automatic testing through continuous integration, one of the key features of memote.

Once all the questions following memote new have been answered, a public repository has been created under either the user’s GitHub or GitLab account. To enable continuous integration via Travis CI the following command is executed:

This functionality is coming soon. A manual workaround is outlined in the cookiecutter-memote readme.

$ memote online

Now, after each edit to the model in the repository, the user can generate an update to the continuous model report shown at the project’s gh-pages branch by saving the changes with the following command:

This functionality is coming soon, for now please utilize the steps outlined for advanced users.

$ memote save

For advanced users: memote save is the equivalent of executing git add ., git commit and git push in sequence.

Offline, local or private workflow:

Users that have decided to not to use GitHub (or GitLab Not implemented yet) or those that have decided to set the model repository to private, will need to execute:

$ memote run

to run the testing suite on their commit history followed by:

$ memote report history

to generate the same type of report that would be shown automatically with continuous integration. After this it is crucial to save the generated test results by running memote save again.

We recommend the public workflow not only to promote open, collaborative science but also to benefit from the full functionality of memote.

Flowchart

This cheat-sheet flowchart servers as a visual guide on how to get up and running with memote! It is essentially the pictographic form of the section Getting Started.

_images/MemoteFlowchart.png

Custom Tests

Memote can be configured to include custom test modules from any other directory in addition to the tests that are included in the package.

Custom Test Setup

All custom test modules and the tests defined inside of them have to adhere to the same standard design for the results to be generated and displayed correctly. Optionally, a user may specify a configuration file which can be used to change how individual tests are displayed in the snapshot report.

A Custom Test Module

At its core, a memote test module is a collection of specific python code in a text file with the file ending .py. Since, memote uses pytest for discovery and execution of model tests, the conditions for memote test modules and pytest test modules are identical.

The module name has to match either test_*.py or *_test.py:

your_custom_directory/
    test_module1.py
    module2_test.py
    ...
Minimal Test Module & Simple Test Function Template

The minimal content of a custom test module should look like this:

import pytest
from memote.utils import annotate, wrapper, truncate

import path.to.your_support_module as your_support_module


@annotate(
    title="Some human-readable descriptive title for the report",
    type="Single keyword describing how the data ought to be displayed."
)
def test_your_custom_case(read_only_model):
"""
Docstring that briefly outlines the test function.

A more elaborate explanation of why this test is important, how it works,
and the assumptions/ theory behind it. This can be more than one line.
"""
ann = test_your_custom_case.annotation
ann["data"] = list(your_support_module.specific_model_quality(read_only_model))
ann["metric"] = len(ann["data"]) / len(read_only_model.reactions)
ann["message"] = wrapper.fill(
    """A concise message that displays and explains the test results.
    For instance, if data is a list of items the amount: {} and
    percentage ({:.2%}) values can be recorded here, as well as an
    excerpt of the list itself: {}""".format(
    len(ann["data"]), ann['metric'], truncate(ann['data'])
    ))
)
assert len(ann["data"]) == 0, ann["message"]

This is a minimal test module template containing a test function called test_your_custom_case. There can be additional lines of code, but you should keep in mind that any logic is best put into a separate support module, which is imported above as your_support_module. The functions of this support module are called by the test function. This will simplify debugging, error handling and allows for dedicated unit testing on the code in the support module.

The following components are requirements of test_your_custom_case:

  • Each test has to be decoreated with the annotate() decorator, which collects:
    • The data that the test is run on. Can be of the following type: list, set, tuple, string, float, integer and boolean. It can be of type dictionary, but this is only supported for parametrized tests (see example below).
    • The type of data. This is not the actual python type of data! Choose it according to how you’d like the results to be displayed in the reports. For example: In the case above data is a list, for instance it could be list of unbalanced reactions. If you choose type="length", the report will display its length. With type="array" it will display the individual items of the list. If data is a single string then type="string" is best. In case, you’d rather display the metric as opposed to the contents of data use type="number". type="object" is only supported for parametrized tests (see example below).
    • A human-readable, descriptive title that will be displayed in the report as opposed to the test function name test_your_custom_case which will only serve as the test’s ID internally.
    • metric can be any fraction relating to the quality that is tested. In memote’s core tests the metrics of each scored tests are used to calculate the overall score.
    • The message is a brief summary of the results displayed only on the command line. There are no restrictions on what it should include. We’ve generally tried to keep this short and concise to avoid spamming the command line.
  • The prefix ‘test_’ is required by pytest for automatic test discovery. Every function with this prefix will be executed when later running memote with the configuration to find custom tests.
  • read_only_model is the required parameter to access the loaded metabolic model.
  • In the report the docstring is taken as a tooltip for each test. It should generally adhere to the conventions of the NumPy/SciPy documentation. It suffices to write a brief one-sentence outline of the test function optionally followed by a more elaborate explanation that helps the user to understand the test’s purpose and function.
  • The assert statement works just like the assert statement in pytest.
Parametrized Test Function Template

Pytest allows us to run one test function with multiple sets of arguments by simply using the pytest.mark.paremtrize decorator. This is quite useful when the same underlying assertion logic can be applied to several parameters. In the following example taken from memote.suite.tests.test_annotation we test that there are no metabolites that lack annotations from any of the databases listed in annotation.METABOLITE_ANNOTATIONS. Without parametrization we would have had to copy the entire test function below to specifically check the metabolite annotations for each database.

@pytest.mark.parametrize("db", list(annotation.METABOLITE_ANNOTATIONS))
@annotate(title="Missing Metabolite Annotations Per Database",
          type="object", message=dict(), data=dict(), metric=dict())
def test_metabolite_annotation_overview(read_only_model, db):
    """
    Expect all metabolites to have annotations from common databases.

    The required databases are outlined in `annotation.py`.
    """
    ann = test_metabolite_annotation_overview.annotation
    ann["data"][db] = get_ids(annotation.generate_component_annotation_overview(
        read_only_model.metabolites, db))
    ann["metric"][db] = len(ann["data"][db]) / len(read_only_model.metabolites)
    ann["message"][db] = wrapper.fill(
        """The following {} metabolites ({:.2%}) lack annotation for {}:
        {}""".format(len(ann["data"][db]), ann["metric"][db], db,
                     truncate(ann["data"][db])))
    assert len(ann["data"][db]) == 0, ann["message"][db]

Custom Test Configuration

Finally, there are two ways of configuring memote to find custom tests. The first involves the --custom option of the memote CLI and requires the user to provide a corresponding config file with the custom test modules, while the second involves passing arguments directly to pytest through the use of the --pytest-args option, which can be abbreviated to -a. This option only requires the user to set up the custom test module. No config file is needed here.

The Custom Option

When invoking the memote run or memote report snapshot commands in the terminal, it is possible to add the --custom option. This option takes two parameters in a fixed order:

  1. The absolute path to any directory in which pytest is to check for custom tests modules. By default test discovery is recursive. More information is provided here.
  2. The absolute path to a valid configuration file.
$ memote report snapshot --custom path/to/dir/ path/to/config.yml --filename "report.html" path/to/model.xml
The Pytest Option

In case you want to avoid setting up a configuration file, it is possible to pass any number of absolute paths to custom test directories directly to pytest, as long as they are placed behind any other parameters that you might want to pass in. For instance here we want to get a list of the ten slowest running tests while including two custom test module directories:

$ memote run -a "--durations=10 path/to/dir1/ path/to/dir2/" --filename "report.html" path/to/model.xml

Test Suite

Core Tests

Basic

Perform basic tests on an instance of cobra.Model.

test_basic.test_compartments_presence(read_only_model)[source]

Expect that more than two 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.

test_basic.test_find_pure_metabolic_reactions(read_only_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.

test_basic.test_find_transport_reactions(read_only_model)[source]

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

test_basic.test_find_unique_metabolites(read_only_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.

test_basic.test_gene_protein_reaction_rule_presence(read_only_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.

test_basic.test_genes_presence(read_only_model)[source]

Expect that more than 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.

test_basic.test_metabolic_coverage(read_only_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’.

test_basic.test_metabolites_charge_presence(read_only_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.

test_basic.test_metabolites_formula_presence(read_only_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.

test_basic.test_metabolites_presence(read_only_model)[source]

Expect that more than 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 one metabolites defined.

test_basic.test_model_id_presence(read_only_model)[source]

Expect that the model has an identifier.

The MIRIAM guidelines require a model to be named. While it is not required, the ID will be displayed on the memote reports, which helps to distinguish the output clearly.

test_basic.test_ngam_presence(read_only_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.

test_basic.test_protein_complex_presence(read_only_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 protein complex is defined in the 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.

test_basic.test_reactions_presence(read_only_model)[source]

Expect that more than 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 one.

test_basic.test_transport_reaction_gpr_presence(read_only_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 vs 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.

test_basic.test_transport_reaction_presence(read_only_model)[source]

Expect more than one transport reaction to be defined in the model.

Cellular metabolism in any organism usually involves the transport of metabolites across a lipid bi-layer. Hence, this test checks that there is at least one reaction, which transports metabolites from one compartment to another.

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

This test will not be able to identify transport via the PTS System.

Consistency

Stoichiometric consistency tests for an instance of cobra.Model.

test_consistency.test_blocked_reactions(read_only_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.

test_consistency.test_detect_energy_generating_cycles(read_only_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.

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

test_consistency.test_find_deadends(read_only_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 gaps.

test_consistency.test_find_disconnected(read_only_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 gaps.

test_consistency.test_find_metabolites_consumed_with_closed_bounds(read_only_model)[source]

Expect no metabolites to be consumed without product removal.

Just like metabolites should not be produced from nothing, mass should not simply be removed from the model. This test disables all the boundary reactions and checks if each metabolite can be consumed individually using flux balance analysis. To pass this test no metabolite outside of specific boundary reactions should be consumed without product leaving the system.

test_consistency.test_find_metabolites_produced_with_closed_bounds(read_only_model)[source]

Expect no metabolites to be produced without substrate consumption.

It should not be possible for the model to produce metabolites without consuming substrate from the medium. This test disables all the boundary reactions and checks if each metabolite can be produced individually using flux balance analysis. To pass this test no metabolite outside of specific boundary reactions should be produced without the consumption of substrate.

test_consistency.test_find_orphans(read_only_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 gaps.

test_consistency.test_find_reactions_unbounded_flux_default_condition(read_only_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.

test_consistency.test_find_stoichiometrically_balanced_cycles(read_only_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.

test_consistency.test_reaction_charge_balance(read_only_model)[source]

Expect all reactions to be charge balanced.

In steady state, for each metabolite the sum of influx equals the sum of outflux. Hence the net charges of both sides of any model reaction have to be equal.

test_consistency.test_reaction_mass_balance(read_only_model)[source]

Expect all reactions to be mass balanced.

In steady state, for each metabolite the sum of influx equals the sum of outflux. Hence the net masses of both sides of any model reaction have to be equal.

test_consistency.test_stoichiometric_consistency(read_only_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.

This test uses an implementation of the algorithm presented 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

Biomass
Annotation

Annotation tests performed on an instance of cobra.Model.

test_annotation.test_metabolite_annotation_overview(read_only_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 (listed in annotation.py). 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.

test_annotation.test_metabolite_annotation_presence(read_only_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.

test_annotation.test_metabolite_annotation_wrong_ids(read_only_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.

test_annotation.test_metabolite_id_namespace_consistency(read_only_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/

test_annotation.test_reaction_annotation_overview(read_only_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 (listed in annotation.py). 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.

test_annotation.test_reaction_annotation_presence(read_only_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.

test_annotation.test_reaction_annotation_wrong_ids(read_only_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.

test_annotation.test_reaction_id_namespace_consistency(read_only_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/

Syntax

API Reference

memote package

Subpackages
memote.suite package
Subpackages
memote.suite.cli package
Submodules
memote.suite.cli.callbacks module

Callbacks for command line parameters.

memote.suite.cli.callbacks.abort_if_false(ctx, param, value)[source]

Require confirmation.

memote.suite.cli.callbacks.probe_git()[source]

Return a git repository instance if it exists.

memote.suite.cli.callbacks.validate_collect(context, param, value)[source]

Handle the report collection flag.

memote.suite.cli.callbacks.validate_model(context, param, value)[source]

Load model from path if it exists.

memote.suite.cli.callbacks.validate_pytest_args(context, param, value)[source]

Handle additional arguments to pytest.

memote.suite.cli.callbacks.validate_repository(context, param, value)[source]

Load repository slug from different locations.

memote.suite.cli.callbacks.validate_username(context, param, value)[source]

Load username from different locations.

memote.suite.cli.config module

Define and make parseable the memote configuration file.

class memote.suite.cli.config.ConfigFileProcessor[source]

Bases: click_configfile.ConfigFileReader

Determine which files to look for and what sections.

config_files = ['memote.ini', 'setup.cfg']
config_section_schemas = [<class 'memote.suite.cli.config.ConfigSectionSchema.Memote'>]
config_sections = ['memote']
class memote.suite.cli.config.ConfigSectionSchema[source]

Bases: object

Describes all sections of the memote configuration file.

class Memote[source]

Bases: click_configfile.SectionSchema

Describes the memote configuration keys and values.

addargs = <click_configfile.Param object>
collect = <click_configfile.Param object>
directory = <click_configfile.Param object>
exclusive = <click_configfile.Param object>
git = <click_configfile.Param object>
github_repository = <click_configfile.Param object>
github_username = <click_configfile.Param object>
model = <click_configfile.Param object>
section_names = ['memote']
skip = <click_configfile.Param object>
solver = <click_configfile.Param object>
memote.suite.cli.reports module

Provide commands for generating report files.

memote.suite.cli.runner module

Provide commands for running the test suite on a metabolic model.

Module contents

memote command line interface.

memote.suite.reporting package
Subpackages
memote.suite.reporting.reports package
Submodules
memote.suite.reporting.reports.diff module

Compare two models with one another.

class memote.suite.reporting.reports.diff.DiffReport(**kwargs)[source]

Bases: memote.suite.reporting.reports.report.Report

Render a report from the comparison of two models.

render_html()[source]

Render an HTML report for a model.

memote.suite.reporting.reports.history module

Render results into pretty HTML.

class memote.suite.reporting.reports.history.HistoryReport(repository, directory, index='time', **kwargs)[source]

Bases: memote.suite.reporting.reports.report.Report

Render a rich report using the git repository history.

render_html()[source]

Render a rich report for the repository.

This is currently a stub while we convert from jinja2 templates to a full Angular based report.

memote.suite.reporting.reports.report module

Render results into pretty HTML.

class memote.suite.reporting.reports.report.Report(**kwargs)[source]

Bases: object

Render a model report.

render_html()[source]

Render an HTML report for a model.

memote.suite.reporting.reports.snapshot module

Render a basic one-time report.

class memote.suite.reporting.reports.snapshot.SnapshotReport(data, **kwargs)[source]

Bases: memote.suite.reporting.reports.report.Report

Render a basic report from the given data.

render_html()[source]

Render a one-shot report for a model.

This is currently a stub while we convert from jinja2 templates to a full Angular based report.

Module contents

Subpackage for creating visually pleasing reports of test results.

There are three types of reports that we support:

  1. A one-time report of a model giving a good insight into its current state.
  2. A more elaborate report that makes use of the model development over time (aka git history).
  3. A comparison report between two different versions of the same model or across different models (similar to a diff).
Submodules
memote.suite.reporting.bag module

Utilities that handle a dask.bag.

class memote.suite.reporting.bag.ResultBagWrapper(files, **kwargs)[source]

Bases: object

Report-specific wrapper around a dask.bag.

build_index()[source]

Build a data index either from timestamps and commit hashes.

get_basic_dataframe()[source]

Create basic information data frame.

get_biomass_dataframe()[source]

Create biomass information data frame.

get_consistency_dataframe()[source]

Create consistency information data frame.

get_model_ids()[source]

Get unique model IDs. Should typically be of length one.

get_syntax_dataframe()[source]

Create syntax information data frame.

memote.suite.reporting.plot module

Templates for plotly figures.

memote.suite.reporting.plot.boolean_chart(df, y_title)[source]

Generate a reproducible plotly scatter and line plot.

memote.suite.reporting.plot.scatter_line_chart(df, y_title)[source]

Generate a reproducible plotly scatter and line plot.

Module contents

Subpackage for gathering information and creating reports.

Submodules
memote.suite.api module

Programmatically interact with the memote test suite.

memote.suite.api.test_model(model, filename=None, results=False, pytest_args=None, exclusive=None, skip=None, solver=None, custom=(None, None))[source]

Test a model and optionally store results as JSON.

Parameters:

model : cobra.Model

The metabolic model under investigation.

filename : str or pathlib.Path, optional

A filename if JSON output of the results is desired.

results : bool, optional

Whether to return the results in addition to the return code.

pytest_args : list, optional

Additional arguments for the pytest suite.

exclusive : iterable, optional

Names of test cases or modules to run and exclude all others. Takes precedence over skip.

skip : iterable, optional

Names of test cases or modules to skip.

custom : tuple, optional

A tuple with the absolute path to a directory that contains custom test modules at index 0 and the absolute path to the corresponding config file at index 1.

Returns:

int

The return code of the pytest suite.

dict, optional

A nested dictionary structure that contains the complete test results.

memote.suite.api.snapshot_report(results, filename)[source]

Test a model and save a basic report.

Parameters:

results : dict

Nested dictionary structure as returned from the test suite.

filename : str or pathlib.Path

A filename for the HTML report.

memote.suite.api.diff_report()[source]

Coming soon™.

memote.suite.api.history_report(repository, directory, filename, index='hash')[source]

Test a model and save a history report.

Parameters:

repository : git.Repo, optional

An instance of the working directory git repository.

directory : str or pathlib.Path

Use the JSON files in the directory that correspond to this git branch’s commit history to generate the report.

filename : str or pathlib.Path

A filename for the HTML report.

index : {“hash”, “time”}, optional

The default horizontal axis type for all plots.

memote.suite.collect module

Collect results for reporting model quality.

class memote.suite.collect.ResultCollectionPlugin(model, repository=None, branch=None, commit=None, exclusive=None, skip=None, custom_config=None, **kwargs)[source]

Bases: object

Provide functionality for complex test result collection.

The plugin exposes the fixture store which can be used in test functions to store values in a dictionary. The dictionary is namespaced to the module so within a module the same keys should not be re-used (unless intended).

model(read_only_model)[source]

Provide a pristine model for a test unit.

pytest_namespace()[source]

Insert model information into the pytest namespace.

pytest_report_teststatus(report)[source]

Log pytest results for each test.

The categories are passed, failed, error, skipped and marked to fail.

Parameters:

report : TestReport

A test report object from pytest with test case result.

pytest_runtest_call(item)[source]

Either run a test exclusively or skip it.

pytest_runtest_teardown(item)[source]

Collect the annotation from each test case and store it.

read_only_model()[source]

Provide the model for the complete test session.

results

Return the test results as a nested dictionary.

Module contents

(Me)tabolic (Mo)del (Te)st Suite.

Test suite for an instance of cobra.Model.

memote.support package
Submodules
memote.support.annotation module

Supporting functions for annotation checks performed on the model object.

memote.support.annotation.find_components_without_annotation(model, components)[source]

Find model components with empty annotation attributes.

Parameters:

model : cobra.Model

A cobrapy metabolic model.

components : {“metabolites”, “reactions”, “genes”}

A string denoting cobra.Model components.

Returns:

list

The components without any annotation.

memote.support.annotation.generate_component_annotation_miriam_match(elements, component, db)[source]

Tabulate which MIRIAM databases the element’s annotation match.

If the relevant MIRIAM identifier is not in an element’s annotation it is ignored.

Parameters:

elements : list

Elements of a model, either metabolites or reactions.

component : {“metabolites”, “reactions”}

A string denoting a type of cobra.Model component.

db : str

One of the MIRIAM database identifiers.

Returns:

list

The components whose annotation does not match the pattern for the MIRIAM database.

memote.support.annotation.generate_component_annotation_overview(elements, db)[source]

Tabulate which MIRIAM databases the component’s annotation match.

Parameters:

elements : list

Elements of a model, either metabolites, reactions, or genes.

db : str

One of the MIRIAM database identifiers.

Returns:

list

The components that are not annotated with the specified MIRIAM database.

memote.support.annotation.generate_component_id_namespace_overview(model, components)[source]

Tabulate which MIRIAM databases the component’s identifier matches.

Parameters:

model : cobra.Model

A cobrapy metabolic model.

components : {“metabolites”, “reactions”, “genes”}

A string denoting cobra.Model components.

Returns:

pandas.DataFrame

The index of the table is given by the component identifiers. Each column corresponds to one MIRIAM database and a Boolean entry determines whether the annotation matches.

memote.support.basic module

Supporting functions for basic checks performed on the model object.

memote.support.basic.check_metabolites_formula_presence(model)[source]

Return the list of model metabolites that have no associated formula.

memote.support.biomass module

Supporting functions for biomass consistency checks.

memote.support.biomass.sum_biomass_weight(reaction)[source]

Compute the sum of all reaction compounds.

Parameters:

reaction : cobra.core.reaction.Reaction

The biomass reaction of the model under investigation.

memote.support.biomass.find_biomass_precursors(reaction)[source]

Return a list of all biomass precursors excluding ATP and H2O.

Parameters:

reaction : cobra.core.reaction.Reaction

The biomass reaction of the model under investigation.

memote.support.biomass.find_blocked_biomass_precursors(reaction, model)[source]

Return a list of all biomass precursors that cannot be produced.

Parameters:

reaction : cobra.core.reaction.Reaction

The biomass reaction of the model under investigation.

model : cobra.Model

The metabolic model under investigation.

memote.support.consistency module

Supporting functions for stoichiometric consistency checks.

memote.support.consistency.check_stoichiometric_consistency(model)[source]

Verify the consistency of the model stoichiometry.

Parameters:

model : cobra.Model

The metabolic model under investigation.

Notes

See [R16] section 3.1 for a complete description of the algorithm.

[R16]Gevorgyan, A., M. G Poolman, and D. A Fell. “Detection of Stoichiometric Inconsistencies in Biomolecular Models.” Bioinformatics 24, no. 19 (2008): 2245.
memote.support.consistency.detect_energy_generating_cycles(model, metabolite_id)[source]

Detect erroneous energy-generating cycles for a a single metabolite.

The function will first build a dissipation reaction corresponding to the input metabolite. This reaction is then set as the objective for optimization, after closing all exchanges. If the reaction was able to carry flux, an erroneous energy-generating cycle must be present. In this case a list of reactions with a flux greater than zero is returned. Otherwise, the function returns False.

Parameters:

model : cobra.Model

The metabolic model under investigation.

metabolite_id : str

The identifier of an energy metabolite.

Notes

“[…] energy generating cycles (EGC) […] charge energy metabolites without a source of energy. […] To efficiently identify the existence of diverse EGCs, we first add a dissipation reaction to the metabolic network for each metabolite used to transmit cellular energy; e.g., for ATP, the irreversible reaction ATP + H2O → ADP + P + H+ is added. These dissipation reactions close any existing energy-generating cycles, thereby converting them to type-III pathways. Fluxes through any of the dissipation reactions at steady state indicate the generation of energy through the metabolic network. Second, all uptake reactions are constrained to zero. The sum of the fluxes through the energy dissipation reactions is now maximized using FBA. For a model without EGCs, these reactions cannot carry any flux without the uptake of nutrients. [R27].”

References

[R27](1, 2) 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
memote.support.consistency.find_charge_imbalanced_reactions(model)[source]

Find metabolic reactions that are not 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.

Parameters:

model : cobra.Model

The metabolic model under investigation.

memote.support.consistency.find_deadends(model)[source]

Return metabolites that are only produced in reactions.

Parameters:

model : cobra.Model

The metabolic model under investigation.

memote.support.consistency.find_disconnected(model)[source]

Return metabolites that are not in any of the reactions.

Parameters:

model : cobra.Model

The metabolic model under investigation.

memote.support.consistency.find_elementary_leakage_modes(model, atol=1e-13)[source]

Detect elementary leakage modes.

Parameters:

model : cobra.Model

The metabolic model under investigation.

atol : float, optional

Values below the absolute tolerance are treated as zero. Expected to be very small but larger than zero.

Notes

See [R38] section 3.4 for a complete description of the algorithm.

References

[R38](1, 2) Gevorgyan, A., M. G Poolman, and D. A Fell. “Detection of Stoichiometric Inconsistencies in Biomolecular Models.” Bioinformatics 24, no. 19 (2008): 2245.
memote.support.consistency.find_inconsistent_min_stoichiometry(model, atol=1e-13)[source]

Detect inconsistent minimal net stoichiometries.

Parameters:

model : cobra.Model

The metabolic model under investigation.

atol : float, optional

Values below the absolute tolerance are treated as zero. Expected to be very small but larger than zero.

Notes

See [R49] section 3.3 for a complete description of the algorithm.

[R49]Gevorgyan, A., M. G Poolman, and D. A Fell. “Detection of Stoichiometric Inconsistencies in Biomolecular Models.” Bioinformatics 24, no. 19 (2008): 2245.
memote.support.consistency.find_mass_imbalanced_reactions(model)[source]

Find metabolic reactions that are not 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.

Parameters:

model : cobra.Model

The metabolic model under investigation.

memote.support.consistency.find_metabolites_consumed_with_closed_bounds(model)[source]

Return metabolites that can be consumed when boundary reactions are closed.

Reverse case from ‘find_metabolites_produced_with_closed_bounds’, just like metabolites should not be produced from nothing, mass should not simply be removed from the model.

Parameters:

model : cobra.Model

The metabolic model under investigation.

memote.support.consistency.find_metabolites_produced_with_closed_bounds(model)[source]

Return metabolites that can be produced when boundary reactions are closed.

Parameters:

model : cobra.Model

The metabolic model under investigation.

memote.support.consistency.find_orphans(model)[source]

Return metabolites that are only consumed in reactions.

Parameters:

model : cobra.Model

The metabolic model under investigation.

memote.support.consistency.find_reactions_with_unbounded_flux_default_condition(model)[source]

Return list of reactions whose flux is unbounded in the default condition.

Parameters:

model : cobra.Model

The metabolic model under investigation.

memote.support.consistency.find_stoichiometrically_balanced_cycles(model)[source]

Find metabolic rxns in stoichiometrically balanced cycles (SBCs).

The flux distribution of nominal FVA is compared with loopless FVA (loopless=True) to determine reactions that participate in loops, as participation in loops would increase the flux through a given reactions to the maximal bounds. This function then returns reactions where the flux differs between the two FVA calculations.

Parameters:

model : cobra.Model

The metabolic model under investigation.

Notes

“SBCs are artifacts of metabolic reconstructions due to insufficient constraints (e.g., thermodynamic constraints and regulatory constraints) [R510].” They are defined by internal reactions that carry flux in spite of closed exchange reactions.

References

[R510](1, 2) 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
memote.support.consistency.find_unconserved_metabolites(model)[source]

Detect unconserved metabolites.

Parameters:

model : cobra.Model

The metabolic model under investigation.

Notes

See [R611] section 3.2 for a complete description of the algorithm.

[R611]Gevorgyan, A., M. G Poolman, and D. A Fell. “Detection of Stoichiometric Inconsistencies in Biomolecular Models.” Bioinformatics 24, no. 19 (2008): 2245.
memote.support.consistency.find_universally_blocked_reactions(model)[source]

Find metabolic reactions that are blocked.

Parameters:

model : cobra.Model

The metabolic model under investigation.

Notes

Blocked reactions are those reactions that when optimized for cannot carry any flux while all exchanges are open.

memote.support.consistency_helpers module

Helper functions for stoichiometric consistency checks.

memote.support.consistency_helpers.stoichiometry_matrix(metabolites, reactions)[source]

Return the stoichiometry matrix representation of a set of reactions.

The reactions and metabolites order is respected. All metabolites are expected to be contained and complete in terms of the reactions.

Parameters:

reactions : iterable

A somehow ordered list of unique reactions.

metabolites : iterable

A somehow ordered list of unique metabolites.

Returns:

numpy.array

The 2D array that represents the stoichiometry matrix.

dict

A dictionary mapping metabolites to row indexes.

dict

A dictionary mapping reactions to column indexes.

memote.support.consistency_helpers.nullspace(matrix, atol=1e-13, rtol=0.0)[source]

Compute the nullspace of a 2D numpy.array.

Notes

Adapted from: https://scipy.github.io/old-wiki/pages/Cookbook/RankNullspace.html

memote.support.helpers module

Helper functions that are used all over the memote package.

memote.support.helpers.close_boundaries_sensibly(model)[source]

Return a cobra model with all boundaries closed and changed constraints.

In the returned model previously fixed reactions are no longer constrained as such. Instead reactions are constrained according to their reversibility. This is to prevent the FBA from becoming infeasible when trying to solve a model with closed exchanges and one fixed reaction.

Parameters:

model : cobra.Model

A cobrapy metabolic model

Returns:

cobra.Model

A cobra model with all boundary reactions closed and the constraints of each reaction set according to their reversibility.

memote.support.helpers.df2dict(df)[source]

Turn a pandas.DataFrame into a dict of lists.

memote.support.helpers.find_biomass_reaction(model)[source]

Return a list of the biomass reaction(s) of the model.

Parameters:

model : cobra.Model

The metabolic model under investigation.

memote.support.helpers.find_converting_reactions(model, pair)[source]

Find reactions which convert a given metabolite pair.

Parameters:

model : cobra.Model

The metabolic model under investigation.

pair: tuple or list

A pair of metabolite identifiers without compartment suffix.

Returns:

frozenset

The set of reactions that have one of the pair on their left-hand side and the other on the right-hand side.

memote.support.helpers.find_demand_reactions(model)[source]

Return a list of demand reactions.

Parameters:

model : cobra.Model

A cobrapy metabolic model

Notes

[1] defines demand reactions as: – ‘unbalanced network reactions that allow the accumulation of a compound’ – reactions that are chiefly added during the gap-filling process – as a means of dealing with ‘compounds that are known to be produced by the organism [..] (i) for which no information is available about their fractional distribution to the biomass or (ii) which may only be produced in some environmental conditions – reactions with a formula such as: ‘met_c -> ‘

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.

References

[R1315]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
memote.support.helpers.find_exchange_rxns(model)[source]

Return a list of exchange reactions.

Parameters:

model : cobra.Model

A cobrapy metabolic model

Notes

[1] defines exchange reactions as: – reactions that ‘define the extracellular environment’ – ‘unbalanced, extra-organism reactions that represent the supply to or removal of metabolites from the extra-organism “space”’ – reactions with a formula such as: ‘met_e -> ‘ or ‘ -> met_e’ or ‘met_e <=> ‘

Exchange reactions differ from demand reactions in that the metabolites are removed from or added to the extracellular environment only. With this the uptake or secretion of a metabolite is modeled, respectively.

References

[R1416]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
memote.support.helpers.find_functional_units(gpr_str)[source]

Return an iterator of gene IDs grouped by boolean rules from the gpr_str.

The gpr_str is first transformed into an algebraic expression, replacing the boolean operators ‘or’ with ‘+’ and ‘and’ with ‘*’. Treating the gene IDs as sympy.symbols this allows a mathematical expansion of the algebraic expression. The expanded form is then split again producing sets of gene IDs that in the gpr_str had an ‘and’ relationship.

Parameters:

gpr_str : string

A string consisting of gene ids and the boolean expressions ‘and’ and ‘or’

memote.support.helpers.find_sink_reactions(model)[source]

Return a list of sink reactions.

Parameters:

model : cobra.Model

A cobrapy metabolic model

Notes

[1] defines sink reactions as: – ‘similar to demand reactions’ but reversible, thus able to supply the model with metabolites – reactions that are chiefly added during the gap-filling process – as a means of dealing with ‘compounds that are produced by nonmetabolic cellular processes but that need to be metabolized’ – reactions with a formula such as: ‘met_c <-> ‘

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.

References

[R1517]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
memote.support.helpers.find_transport_reactions(model)[source]

Return a list of all transport reactions.

Parameters:

model : cobra.Model

The metabolic model under investigation.

Notes

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 stays the same on both sides of the equation.

This function will not identify transport via the PTS System.

memote.support.helpers.find_transported_elements(rxn)[source]

Return a dictionary showing the amount of transported elements of a rxn.

Collects the elements for each metabolite participating in a reaction, multiplies the amount by the metabolite’s stoichiometry in the reaction and bins the result according to the compartment that metabolite is in. This produces a dictionary of dictionaries such as this {'p': {'C': -1, 'H': -4}, c: {'C': 1, 'H': 4}} which shows the transported entities. This dictionary is then simplified to only include the non-zero elements of one single compartment i.e. showing the precise elements that are transported.

Parameters:

rxn : cobra.Reaction

Any cobra.Reaction containing metabolites.

memote.support.helpers.run_fba(model, rxn_id, direction='max', single_value=True)[source]

Return the solution of an FBA to a set objective function.

Parameters:

model : cobra.Model

A cobrapy metabolic model

rxn_id : string

A string containing the reaction ID of the desired FBA objective

direction: string

A string containing either “max” or “min” to specify the direction of the desired FBA objective function

single_value: boolean

Indicates whether the results for all reactions are gathered from the solver, or only the result for the objective value.

Returns:

cobra.solution

The cobra solution object for the corresponding FBA problem

memote.support.syntax module

Supporting functions for syntax checks performed on the model object.

memote.support.syntax.find_abc_tag_transporter(model)[source]

Find Atp-binding cassette transport rxns without ‘abc’ tag.

Parameters:

model : cobra.Model

A cobrapy metabolic model

Notes

An ABC transport reaction is defined as follows: 1. It contains metabolites from at least 2 compartments, 2. at least 1 metabolite undergoes no chemical reaction, i.e., the formula stays the same on both sides of the equation, and 3. ATP is converted to ADP (+ Pi + H, yet this isn’t checked for explicitly).

Reactions that only transport protons (‘H’) across the membrane are excluded, as well as reactions with redox cofactors whose formula is either ‘X’ or ‘XH2’

memote.support.syntax.find_false_demand_rxns(model)[source]

Find reactions which are tagged with DM_ but which are not demand rxns.

Parameters:

model : cobra.Model

A cobrapy metabolic model

memote.support.syntax.find_false_exchange_rxns(model)[source]

Find reactions that are tagged with EX_ but are not exchange reactions.

Parameters:

model : cobra.Model

A cobrapy metabolic model

memote.support.syntax.find_false_sink_rxns(model)[source]

Find reactions which are tagged with SK_ but which are not sink rxns.

Parameters:

model : cobra.Model

A cobrapy metabolic model

memote.support.syntax.find_reaction_tag_transporter(model)[source]

Return incorrectly tagged transport reactions.

Make an exception for the ATP synthase reaction (ATPS) which a unique case for a transport reaction and thus does not get the tag.

Parameters:

model : cobra.Model

A cobrapy metabolic model

Notes

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 stays the same on both sides of the equation.

Reactions that only transport protons (‘H’) across the membrane are excluded, as well as reactions with redox cofactors whose formula is either ‘X’ or ‘XH2’

memote.support.syntax.find_rxn_id_compartment_suffix(model, suffix)[source]

Find un-tagged non-transport reactions.

Find non-transport reactions with metabolites in the given compartment whose ID is not tagged accordingly.

Parameters:

model : cobra.Model

A cobrapy metabolic model.

suffix : str

The suffix of the compartment to be checked.

Returns:

list

Non-transport reactions that have at least one metabolite in the compartment given by suffix but whose IDs do not have the suffix appended.

memote.support.syntax.find_rxn_id_suffix_compartment(model, suffix)[source]

Find mis-tagged non-transport reactions.

Find non-transport reactions whose ID bear a compartment tag but which do not contain any metabolites in the given compartment.

Parameters:

model : cobra.Model

A cobrapy metabolic model.

suffix : str

The suffix of the compartment to be checked.

Returns:

list

Non-transport reactions that have at least one metabolite in the compartment given by suffix but whose IDs do not have the suffix appended.

memote.support.syntax.find_untagged_demand_rxns(model)[source]

Find demand reactions whose IDs do not begin with DM_.

Parameters:

model : cobra.Model

A cobrapy metabolic model

memote.support.syntax.find_untagged_exchange_rxns(model)[source]

Find exchange reactions whose identifiers do not begin with EX_.

Parameters:

model : cobra.Model

A cobrapy metabolic model

memote.support.syntax.find_untagged_sink_rxns(model)[source]

Find demand reactions whose IDs do not begin with SK_.

Parameters:

model : cobra.Model

A cobrapy metabolic model

memote.support.syntax.find_upper_case_mets(model)[source]

Find metabolites whose ID roots contain uppercase characters.

Parameters:

model : cobra.Model

A cobrapy metabolic model

Notes

In metabolite names, individual uppercase exceptions are allowed: – Dextorotary prefix: ‘D’ – Levorotary prefix: ‘L’ – Prefixes for the absolute configuration of a stereocenter: ‘R’ and ‘S’ – Prefixes for the absolute stereochemistry of double bonds ‘E’ and ‘Z’ – Acyl carrier proteins can be labeled as ‘ACP’

Module contents

Helper functions for the metabolic model test suite.

Submodules
memote.utils module

Utility functions used by memote and its tests.

memote.utils.register_with(registry)[source]

Register a passed in object.

Intended to be used as a decorator on model building functions with a dict as a registry.

Examples

REGISTRY = dict() @register_with(REGISTRY) def build_empty(base):

return base
memote.utils.annotate(title, type, message=None, data=None, metric=1.0)[source]

Annotate a test case.

Parameters:

title : str

A human-readable descriptive title of the test case.

type : str

A sting that determines how the result data is formatted in the report. - ‘array’ : The tested quality is represented as a list, e.g. all

biomass reactions in the model. In the angular report, ‘data’ is interpreted as a list. It is expected not to be None.

  • ‘length’ : The tested quality is represented as the length of a list, set or tuple, e.g. number of metabolites without formula. In the angular report, ‘data’ is interpreted as a list. It is expected not to be None.
  • ‘number’ : The tested quality is represented as a percentage, e.g. percentage of metabolites without charge. In the angular report, ‘metric’ is used and expected to be a floating point number.
  • ‘object’ : Use only if the test case is parametrized i.e. if the same basic test logic can be applied to several tested components, such as testing for the presence of annotations for specific databases for all metabolites. In the angular report, ‘data’ is interpreted as a dictionary whose values can be dictionaries, lists, strings, floats and integers. It is expected not to be None.
  • ‘string’ : The tested quality is represented as a single string, e.g. the ID of the model. In the angular report, ‘data’ is interpreted as a string. It is expected not to be None.

message : str

A short written explanation that states and possibly explains the test result.

data

Raw data which the test case generates and assesses. Can be of the following types: list, set, tuple, string, float, integer, boolean and dictionary.

metric: float

A value x in the range of 0 <= x <= 1 which represents the fraction of ‘data’ to the total in the model. For example, if ‘data’ are all metabolites without formula, ‘metric’ should be the fraction of metabolites without formula from the total of metabolites in the model.

Returns:

function

The decorated function, now extended by the attribute ‘annotation’.

Notes

Adds “annotation” attribute to the function object, which stores values for predefined keys as a dictionary.

memote.utils.get_ids(iterable)[source]

Retrieve the identifier of a number of objects.

memote.utils.truncate(sequence)[source]

Create a potentially shortened text display of a list.

Parameters:

sequence : list

An indexable sequence of elements.

Returns:

str

The list as a formatted string.

memote.version_info module

Provide a single function for a user to capture important dependencies.

memote.version_info.show_versions()[source]

Print the formatted information to standard out.

Module contents

(Me)tabolic (Mo)del (Te)sts.

The memote Python package provides a number of hard and soft expectations about genome-scale metabolic models.

Contributing

Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.

You can contribute in many ways:

Report Bugs

Report bugs at https://github.com/opencobra/memote/issues.

If you are reporting a bug, please include:

  • Your operating system name and version.
  • Any details about your local setup that might be helpful in troubleshooting.
  • Detailed steps to reproduce the bug.

Fix Bugs

Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants to implement it.

Implement Features

Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to whoever wants to implement it.

Write Documentation

memote could always use more documentation, whether as part of the official memote docs, in docstrings, or even on the web in blog posts, articles, and such.

Submit Feedback

The best way to send feedback is to file an issue at https://github.com/opencobra/memote/issues.

If you are proposing a feature:

  • Explain in detail how it would work.
  • Keep the scope as narrow as possible, to make it easier to implement.
  • Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!

Ready to contribute? Here’s how to set up memote for local development.

  1. Fork the memote repo on GitHub.

  2. Clone your fork locally:

    git clone git@github.com:your_name_here/memote.git
    
  3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:

    mkvirtualenv memote
    cd memote/
    pip install -e .
    
  4. Create a branch for local development using fix or feat as a prefix:

    git checkout -b fix-name-of-your-bugfix
    

    Now you can make your changes locally.

  5. When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions. This is all included with tox:

    tox
    

    You can run all tests in parallel using detox. To get tox and detox, just pip install them into your virtualenv.

  6. Commit your changes and push your branch to GitHub. Please use semantic commit messages:

    git add .
    git commit -m "fix: Your detailed description of your changes."
    git push origin fix-name-of-your-bugfix
    
  7. Submit a pull request through the GitHub website.

Pull Request Guidelines

Before you submit a pull request, check that it meets these guidelines:

  1. The pull request should include tests.
  2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring.
  3. The pull request should work for Python 2.7, 3.4, 3.5 and 3.6. Check https://travis-ci.org/opencobra/memote/pull_requests and make sure that the tests pass for all supported Python versions.

Credits

Development Lead

History

Next Release

0.5.0 (2018-01-16)

  • Enable test result and meta-data collection.
  • Allow command line option and configuration of exclusive test cases and modules skipping all others (--exclusive test_biomass).
  • Allow command line option and configuration to skip test cases and modules (--skip test_model_id_presence).
  • Introduce a dummy configuration file for the report organization and test scoring weights.
  • Sort unconfigured tests into the card ‘Misc. Tests’ in the snapshot report.
  • Handle skipped tests better in the snapshot report.
  • Bundle the Angular report javascript libraries in the snapshot template
  • Pass results into the report as JSON
  • Fixed/ changed a lot of visuals on the angular report:
    • Indent the rows of the parametrized test results
    • Color the header text of the parametrized test results in pure black
    • Remove the horizontal lines in the parametrized test results
    • Display all results regardless of scored/ unscored inside of buttons to force a uniform line height and a more consistent look
    • Add logic to correctly display errored tests
    • Give skipped and errored test results a distinct look
    • Explicitly handle boolean results, and add boolean as an option for the ‘type’ attribute.
    • Fix the raw data output in the textboxes so that they are formatted python code.
  • Allow command line option to enable the definition of a custom test directory in combination with a corresponding config file.
  • Extend test descriptions to make it more clear how a user can satisfy the test conditions.
  • Remove duplicate test for the presence of transport reactions.
  • Implement a test for unbounded flux through reactions in the default condition.
  • Implement a test for detecting metabolites that can either be produced or removed from the model when all system boundaries are closed.
  • Implement a test for ‘direct’ metabolites, i.e. the detection of biomass precursors that are not involved in any metabolic reactions; only in exchange reactions, transporters and the biomass reaction itself.
  • Implement a test that checks for a low ratio of transport reactions without GPR relative to the total amount of transport reactions.

0.4.6 (2017-10-31)

  • Improve the automated release pipeline. It now creates pumpkins.
  • Provide a new decorator @register_with that can be used in all test_for* modules and replaces the model_builder function.
  • Temporarily change the links to readthedocs to point to latest instead of stable.
  • Provide angular2 app for the snapshot report instead of the jinja template

0.4.5 (2017-10-09)

  • Correctly account for reversibility when testing for dead-end and orphan metabolites.

0.4.4 (2017-09-26)

  • Fix a bunch of bugs:
    • Remove false positive detection of Biocyc annotation
    • Allow memote to identify CTP or GTP driven transport reactions
    • Refactor how memote detects GAM in the biomass reaction
  • Add tests to find deadend, orphan and disconnected metabolites.
  • Extend and improve algorithm to find energy-generating cycles
  • Remove the print statement from memote.support.annotation .generate_component_annotation_miriam_match.
  • Fix the bug in the assertion output of memote.memote.suite.tests.test_basic .test_gene_protein_reaction_rule_presence.
  • Split mass-charge-balance test into two separate tests for more clarity
  • Fix a bug in memote.support.consistency_helpers.get_internals that did not exclude the (by definition) imbalanced biomass reactions.

0.4.3 (2017-09-25)

  • Fix documentation building and add auto-generation of docs.
  • Make the command line output of pytest more verbose until the report is up to speed.
  • Temporarily skip test_find_stoichiometrically_balanced_cycles
  • Catch errors when testing for compartments and loops.

0.4.2 (2017-08-22)

  • Push all branches with memote online.

0.4.1 (2017-08-22)

  • Fix JSON serialization of test results.

0.4.0 (2017-08-21)

  • Add a programmatic API in module memote.suite.api (#162).
  • Reorganize the structure and build process for auto-documenting memote (#172).
  • Add a new command memote online (#95, #153).
  • Add more basic tests.

0.3.6 (2017-08-15)

  • Improve GitHub support.
  • Update the readthedocs and gitter badge.
  • Add a function memote.show_versions() for easy dependency checking.

0.3.4 (2017-08-12)

  • Properly configure Travis deployment.

0.3.3 (2017-08-12)

  • Build tags.

0.3.2 (2017-08-12)

  • Enable automatic deployment to PyPi.

0.3.0 (2017-08-12)

  • Greatly extend the core test modules: * basic * consistency * biomass * annotation * syntax
  • Add an Angular-material based report with plotly.
  • Add documentation on readthedocs.io.
  • Make the first release on PyPi.

0.2.0 (2017-02-09)

  • Yet another package structure for supporting functions, their tests, and the model test suite.

0.1.0 (2017-01-30)

  • New package structure and start of joint development

Indices and tables