memote
¶
(me)tabolic (mo)del (te)sts.
The memote Python package is a community-driven effort towards a standardized genome-scale metabolic model test suite.
Subpackages¶
memote.experimental
memote.suite
memote.support
memote.support.data
memote.support.annotation
memote.support.basic
memote.support.biomass
memote.support.consistency
memote.support.consistency_helpers
memote.support.essentiality
memote.support.gpr_helpers
memote.support.helpers
memote.support.matrix
memote.support.sbo
memote.support.thermodynamics
memote.support.validation
Submodules¶
Package Contents¶
Classes¶
MemoteResult |
Collect the metabolic model test suite results. |
ResultManager |
Manage storage of results to JSON files. |
RepoResultManager |
Manage storage of results to JSON files. |
SQLResultManager |
Manage storage of results to a database. |
HistoryManager |
Manage access to results in the commit history of a git repository. |
ReportConfiguration |
Collect the metabolic model test suite results. |
Report |
Determine the abstract report interface. |
SnapshotReport |
Render a one-time report from the given model results. |
HistoryReport |
Render a rich report using the git repository history. |
DiffReport |
Render a report displaying the results of two or more models side-by-side. |
MemoteExtension |
Provide an absolute path to a file. |
Functions¶
get_versions () |
Get version information or return default if unable to do so. |
show_versions () |
Print formatted dependency information to stdout. |
validate_model (path) |
Validate a model structurally and optionally store results as JSON. |
test_model (model, sbml_version=None, results=False, pytest_args=None, exclusive=None, skip=None, experimental=None, solver_timeout=10) |
Test a model and optionally store results as JSON. |
snapshot_report (result, config=None, html=True) |
Generate a snapshot report from a result set and configuration. |
diff_report (diff_results, config=None, html=True) |
Generate a diff report from a result set and configuration. |
history_report (history, config=None, html=True) |
Test a model and save a history report. |
-
memote.
validate_model
(path)[source]¶ Validate a model structurally and optionally store results as JSON.
Parameters: - path
Path to model file.
Returns: - tuple
- cobra.Model
The metabolic model under investigation.
- tuple
A tuple reporting on the SBML level, version, and FBC package version used (if any) in the SBML document.
- dict
A simple dictionary containing a list of errors and warnings.
-
memote.
test_model
(model, sbml_version=None, results=False, pytest_args=None, exclusive=None, skip=None, experimental=None, solver_timeout=10)[source]¶ Test a model and optionally store results as JSON.
Parameters: - model : cobra.Model
The metabolic model under investigation.
- sbml_version: tuple, optional
A tuple reporting on the level, version, and FBC use of the SBML file.
- 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.
- solver_timeout: int, optional
Timeout in seconds to set on the mathematical optimization solver (default 10).
Returns: - int
The return code of the pytest suite.
- memote.Result, optional
A nested dictionary structure that contains the complete test results.
-
memote.
snapshot_report
(result, config=None, html=True)[source]¶ Generate a snapshot report from a result set and configuration.
Parameters: - result : memote.MemoteResult
Nested dictionary structure as returned from the test suite.
- config : dict, optional
The final test report configuration (default None).
- html : bool, optional
Whether to render the report as full HTML or JSON (default True).
-
memote.
diff_report
(diff_results, config=None, html=True)[source]¶ Generate a diff report from a result set and configuration.
Parameters: - diff_results : iterable of memote.MemoteResult
Nested dictionary structure as returned from the test suite.
- config : dict, optional
The final test report configuration (default None).
- html : bool, optional
Whether to render the report as full HTML or JSON (default True).
-
memote.
history_report
(history, config=None, html=True)[source]¶ Test a model and save a history report.
Parameters: - history : memote.HistoryManager
The manager grants access to previous results.
- config : dict, optional
The final test report configuration.
- html : bool, optional
Whether to render the report as full HTML or JSON (default True).
-
class
memote.
MemoteResult
(*args, **kwargs)¶ Bases:
dict
Collect the metabolic model test suite results.
-
static
add_environment_information
(meta)¶ Record environment information.
-
static
-
class
memote.
ResultManager
(**kwargs)¶ Bases:
object
Manage storage of results to JSON files.
-
store
(self, result, filename, pretty=True)¶ Write a result to the given file.
Parameters: - result : memote.MemoteResult
The dictionary structure of results.
- filename : str or pathlib.Path
Store results directly to the given filename.
- pretty : bool, optional
Whether (default) or not to write JSON in a more legible format.
-
load
(self, filename)¶ Load a result from the given JSON file.
-
-
class
memote.
RepoResultManager
(repository, location, **kwargs)¶ Bases:
memote.suite.results.result_manager.ResultManager
Manage storage of results to JSON files.
Results are stored to and loaded from a specific location (directory) and enriched with git commit meta information.
-
record_git_info
(self, commit=None)¶ Record git meta information.
Parameters: - commit : str, optional
Unique hexsha of the desired commit.
Returns: - GitInfo
Git commit meta information.
-
get_filename
(self, git_info)¶ Create a filename from the storage directory and the commit hash.
Parameters: - git_info : GitInfo
A named tuple with git meta information.
Returns: - str
The path to the file where the result of the current commit is stored.
-
static
add_git
(meta, git_info)¶ Enrich the result meta information with commit data.
-
store
(self, result, commit=None, **kwargs)¶ Store a result in a JSON file attaching git meta information.
Parameters: - result : memote.MemoteResult
The dictionary structure of results.
- commit : str, optional
Unique hexsha of the desired commit.
- kwargs
Passed to parent function.
-
load
(self, commit=None)¶ Load a result from the storage directory.
-
-
class
memote.
SQLResultManager
(**kwargs)¶ Bases:
memote.suite.results.repo_result_manager.RepoResultManager
Manage storage of results to a database.
-
store
(self, result, commit=None, **kwargs)¶ Store a result in a JSON file attaching git meta information.
Parameters: - result : memote.MemoteResult
The dictionary structure of results.
- commit : str, optional
Unique hexsha of the desired commit.
- kwargs
Passed to parent function.
-
load
(self, commit=None)¶ Load a result from the database.
-
-
class
memote.
HistoryManager
(repository, manager, **kwargs)¶ Bases:
object
Manage access to results in the commit history of a git repository.
Attributes: - manager : memote.RepoResultManager
The manager for accessing individual results.
- current : str
The name of the currently active branch.
-
build_branch_structure
(self, model, skip)¶ Inspect and record the repo’s branches and their history.
-
iter_branches
(self)¶ Iterate over branch names and their commit histories.
-
iter_commits
(self)¶ Iterate over all commit hashes in the repository.
-
load_history
(self, model, skip=('gh-pages', ))¶ Load the entire results history into memory.
Could be a bad idea in a far future.
-
get_result
(self, commit, default=None)¶ Return an individual result from the history if it exists.
-
__contains__
(self, commit)¶ Test for the existence of a result for a commit.
-
class
memote.
ReportConfiguration
(*args, **kwargs)¶ Bases:
dict
Collect the metabolic model test suite results.
-
classmethod
load
(cls, filename=None)¶ Load a test report configuration.
-
merge
(self, other)¶ Merge a custom configuration.
-
classmethod
-
class
memote.
Report
(result, configuration, **kwargs)¶ Bases:
object
Determine the abstract report interface.
Attributes: - result : memote.MemoteResult
The dictionary structure of results.
- configuration : memote.MemoteConfiguration
A memote configuration structure.
-
render_json
(self, pretty=False)¶ Render the report results as JSON.
Parameters: - pretty : bool, optional
Whether to format the resulting JSON in a more legible way ( default False).
-
render_html
(self)¶ Render an HTML report.
-
get_configured_tests
(self)¶ Get tests explicitly configured.
-
determine_miscellaneous_tests
(self)¶ Identify tests not explicitly configured in test organization.
List them as an additional card called Misc, which is where they will now appear in the report.
-
compute_score
(self)¶ Calculate the overall test score using the configuration.
-
memote.
LOGGER
¶
-
class
memote.
SnapshotReport
(**kwargs)¶ Bases:
memote.suite.reporting.report.Report
Render a one-time report from the given model results.
Attributes: - result : memote.MemoteResult
The dictionary structure of results.
- configuration : memote.MemoteConfiguration
A memote configuration structure.
-
class
memote.
HistoryReport
(history, configuration, **kwargs)¶ Bases:
memote.suite.reporting.report.Report
Render a rich report using the git repository history.
Attributes: - configuration : memote.MemoteConfiguration
A memote configuration structure.
-
collect_history
(self)¶ Build the structure of results in terms of a commit history.
-
class
memote.
DiffReport
(diff_results, configuration, **kwargs)¶ Bases:
memote.suite.reporting.report.Report
Render a report displaying the results of two or more models side-by-side.
Attributes: - diff_results : python.Dictionary
The dictionary structure of memote.MemoteResult objects.
- configuration : memote.MemoteConfiguration
A memote configuration structure.
-
format_and_score_diff_data
(self, diff_results)¶ Reformat the api results to work with the front-end.