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. This can be done by writing the pytest arguments as one continuous string.

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

Test Suite

Core Tests

Basic

Perform basic tests on an instance of cobra.Model.

test_basic.test_compartments_presence(read_only_model, store)[source]

Expect that >= 3 compartments are defined in the model.

test_basic.test_enzyme_complex_presence(read_only_model, store)[source]

Expect that >= 1 enzyme complexes are present in the model.

test_basic.test_find_pure_metabolic_reactions(read_only_model, store)[source]

Expect >= 1 pure metabolic reactions are present in the model.

test_basic.test_find_transport_reactions(read_only_model, store)[source]

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

test_basic.test_find_unique_metabolites(read_only_model, store)[source]

Expect there to be less metabolites when removing compartment tag.

test_basic.test_gene_protein_reaction_rule_presence(read_only_model, store)[source]

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

test_basic.test_genes_presence(read_only_model, store)[source]

Expect that >= 1 genes are present in the model.

test_basic.test_metabolic_coverage(read_only_model, store)[source]

Expect a model to have high metabolic coverage.

test_basic.test_metabolites_charge_presence(read_only_model, store)[source]

Expect all metabolites to have charge information.

test_basic.test_metabolites_formula_presence(read_only_model, store)[source]

Expect all metabolites to have a formula.

test_basic.test_metabolites_presence(read_only_model, store)[source]

Expect that >= 1 metabolites are present in the model.

test_basic.test_model_id_presence(read_only_model, store)[source]

Expect that the model has an identifier.

test_basic.test_ngam_presence(read_only_model, store)[source]

Expect a single non growth-associated maintenance reaction.

test_basic.test_reactions_presence(read_only_model, store)[source]

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

test_basic.test_transport_reaction_presence(read_only_model, store)[source]

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

Consistency

Stoichiometric consistency tests for an instance of cobra.Model.

test_consistency.test_blocked_reactions(read_only_model, store)[source]

Expect all reactions to be able to carry flux.

test_consistency.test_find_stoichiometrically_balanced_cycles(read_only_model, store)[source]

Expect no stoichiometrically balanced loops to be present.

test_consistency.test_imbalanced_reactions(read_only_model, store)[source]

Expect all reactions to be mass and charge balanced.

test_consistency.test_production_of_atp_closed_bounds(read_only_model, store)[source]

Expect that ATP cannot be produced when all the bounds are closed.

test_consistency.test_stoichiometric_consistency(read_only_model, store)[source]

Expect that the stoichiometry is mass-balanced.

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(read_only_model, reaction_id, store)[source]

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

test_biomass.test_biomass_default_production(model, reaction_id, store)[source]

Expect biomass production in default medium.

test_biomass.test_biomass_precursors_default_production(read_only_model, reaction_id, store)[source]

Expect production of all biomass precursors in default medium.

test_biomass.test_biomass_precursors_open_production(model, reaction_id, store)[source]

Expect precursor production in complete medium.

test_biomass.test_biomass_presence(store)[source]

Expect the model to contain at least one biomass reaction.

test_biomass.test_fast_growth_default(model, reaction_id)[source]

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

This is based on lowest doubling time reported here http://www.pnnl.gov/science/highlights/highlight.asp?id=879

test_biomass.test_gam_in_biomass(model, reaction_id, store)[source]

Expect the biomass reactions to contain atp and adp.

Annotation

Annotation tests performed on an instance of cobra.Model.

test_annotation.test_metabolite_annotation_overview(read_only_model, store)[source]

Expect all metabolites to have annotations from common databases.

The required databases are outlined in annotation.py.

test_annotation.test_metabolite_annotation_presence(read_only_model, store)[source]

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

test_annotation.test_metabolite_annotation_wrong_ids(read_only_model, store)[source]

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

The required formats, i.e., regex patterns are outlined in annotation.py.

test_annotation.test_metabolite_id_namespace_consistency(read_only_model, store)[source]

Expect metabolite IDs to be from the same namespace.

test_annotation.test_reaction_annotation_overview(read_only_model, store)[source]

Expect all reactions to have annotations from common databases.

The required databases are outlined in annotation.py.

test_annotation.test_reaction_annotation_presence(read_only_model, store)[source]

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

test_annotation.test_reaction_annotation_wrong_ids(read_only_model, store)[source]

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

The required formats, i.e., regex patterns are outlined in annotation.py.

test_annotation.test_reaction_id_namespace_consistency(read_only_model, store)[source]

Expect reaction IDs to be from the same namespace.

Syntax

Syntax tests performed on an instance of cobra.Model.

test_syntax.non_cytosolic(read_only_model, store)[source]

Provide all non-cytosolic compartments.

test_syntax.test_abc_transp_rxn_tag_match(read_only_model, store)[source]

Expect all abc transport reactions to be tagged with abc.

test_syntax.test_demand_reaction_tag_match(read_only_model, store)[source]

Expect all demand reaction IDs to be prefixed with DM_.

test_syntax.test_exchange_reaction_tag_match(read_only_model, store)[source]

Expect all exchange reaction IDs to be prefixed with EX_.

test_syntax.test_false_demand_reaction(read_only_model, store)[source]

Expect all rxns that are tagged with DM_ to be true demand rxns.

test_syntax.test_false_exchange_reaction(read_only_model, store)[source]

Expect all rxns that are tagged with EX_ to be true exchange rxns.

test_syntax.test_false_sink_reaction(read_only_model, store)[source]

Expect all rxns that are tagged with SK_ to be true sink rxns.

test_syntax.test_non_abc_transp_rxn_tag_match(read_only_model, store)[source]

Expect all non-abc transport reactions to be tagged with a t.

test_syntax.test_non_transp_rxn_id_compartment_suffix_match(read_only_model, store, non_cytosolic)[source]

Expect all reactions outside of the cytosol to be tagged accordingly.

test_syntax.test_non_transp_rxn_id_suffix_compartment_match(read_only_model, store, non_cytosolic)[source]

Expect compartment-tagged reactions to involve fitting metabolites.

test_syntax.test_sink_reaction_tag_match(read_only_model, store)[source]

Expect all sink reaction IDs to be prefixed with SK_.

test_syntax.test_upper_case_mets(read_only_model, store)[source]

Expect all metabolites to be lower case with accepted exceptions.

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_directory(context, param, value)[source]

Load directory from different locations.

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

Load model path from different locations.

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>
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']
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.basic_report module

Render a basic one-time report.

class memote.suite.reporting.reports.basic_report.BasicReport(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.

memote.suite.reporting.reports.diff_report module

Compare two models with one another.

class memote.suite.reporting.reports.diff_report.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_report module

Render results into pretty HTML.

class memote.suite.reporting.reports.history_report.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.

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.

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)[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.

Returns:

int

The return code of the pytest suite.

dict, optional

A nested dictionary structure that contains the complete test results.

memote.suite.api.basic_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, **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.

read_only_model()[source]

Provide the model for the complete test session.

results

Return the test results as a nested dictionary.

store(request)[source]

Expose a dict to store values on.

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(model, components)[source]

Tabulate which MIRIAM databases the component’s annotation match.

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.annotation.generate_component_annotation_overview(model, components)[source]

Tabulate which MIRIAM databases the component’s annotation match.

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.annotation.generate_component_id_namespace_overview(model, components)[source]

Tabulate which MIRIAM databases the component’s annotation match.

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 [R15] section 3.1 for a complete description of the algorithm.

[R15]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_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.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 [R26] section 3.4 for a complete description of the algorithm.

References

[R26](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_imbalanced_reactions(model)[source]

Find metabolic reactions that not mass and/or charge balanced.

This will exclude biomass, exchange and demand reactions as they are unbalanced by definition.

Parameters:

model : cobra.Model

The metabolic model under investigation.

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 [R37] section 3.3 for a complete description of the algorithm.

[R37]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_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) [R48].” They are defined by internal reactions that carry flux in spite of closed exchange reactions.

References

[R48](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 [R59] section 3.2 for a complete description of the algorithm.

[R59]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.produce_atp_closed_exchanges(model)[source]

Close the model’s exchanges and tries to optimize the production of atp_c.

Parameters:

model : cobra.Model

The metabolic model under investigation.

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.df2dict(df)[source]

Turn a pandas.DataFrame into a dict of lists.

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

Find reactions which interact with ATP and ADP.

Parameters:

model : cobra.Model

The metabolic model under investigation.

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_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

[R1113]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

[R1214]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

[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_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.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.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.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