:mod:`memote` ============= .. py:module:: memote .. autoapi-nested-parse:: (me)tabolic (mo)del (te)sts. The memote Python package is a community-driven effort towards a standardized genome-scale metabolic model test suite. .. !! processed by numpydoc !! Subpackages ----------- .. toctree:: :titlesonly: :maxdepth: 3 experimental/index.rst suite/index.rst support/index.rst Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 _version/index.rst jinja2_extension/index.rst utils/index.rst Package Contents ---------------- Classes ~~~~~~~ .. autoapisummary:: memote.MemoteResult memote.ResultManager memote.RepoResultManager memote.SQLResultManager memote.HistoryManager memote.ReportConfiguration memote.Report memote.SnapshotReport memote.HistoryReport memote.DiffReport memote.MemoteExtension Functions ~~~~~~~~~ .. autoapisummary:: memote.get_versions memote.show_versions memote.validate_model memote.test_model memote.snapshot_report memote.diff_report memote.history_report .. data:: __author__ :annotation: = Moritz E. Beber .. data:: __email__ :annotation: = midnighter@posteo.net .. function:: get_versions() Get version information or return default if unable to do so. .. !! processed by numpydoc !! .. data:: __version__ .. function:: show_versions() Print formatted dependency information to stdout. .. !! processed by numpydoc !! .. function:: validate_model(path) 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. .. !! processed by numpydoc !! .. function:: 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. :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. .. !! processed by numpydoc !! .. function:: snapshot_report(result, config=None, html=True) 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). .. !! processed by numpydoc !! .. function:: diff_report(diff_results, config=None, html=True) 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). .. !! processed by numpydoc !! .. function:: history_report(history, config=None, html=True) 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). .. !! processed by numpydoc !! .. py:class:: MemoteResult(*args, **kwargs) Bases: :class:`dict` Collect the metabolic model test suite results. .. !! processed by numpydoc !! .. staticmethod:: add_environment_information(meta) Record environment information. .. !! processed by numpydoc !! .. py:class:: ResultManager(**kwargs) Bases: :class:`object` Manage storage of results to JSON files. .. !! processed by numpydoc !! .. method:: 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. .. !! processed by numpydoc !! .. method:: load(self, filename) Load a result from the given JSON file. .. !! processed by numpydoc !! .. py:class:: RepoResultManager(repository, location, **kwargs) Bases: :class:`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. .. !! processed by numpydoc !! .. method:: 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. .. !! processed by numpydoc !! .. method:: 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. .. !! processed by numpydoc !! .. staticmethod:: add_git(meta, git_info) Enrich the result meta information with commit data. .. !! processed by numpydoc !! .. method:: 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. .. !! processed by numpydoc !! .. method:: load(self, commit=None) Load a result from the storage directory. .. !! processed by numpydoc !! .. py:class:: SQLResultManager(**kwargs) Bases: :class:`memote.suite.results.repo_result_manager.RepoResultManager` Manage storage of results to a database. .. !! processed by numpydoc !! .. method:: 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. .. !! processed by numpydoc !! .. method:: load(self, commit=None) Load a result from the database. .. !! processed by numpydoc !! .. py:class:: HistoryManager(repository, manager, **kwargs) Bases: :class:`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. .. !! processed by numpydoc !! .. method:: build_branch_structure(self, model, skip) Inspect and record the repo's branches and their history. .. !! processed by numpydoc !! .. method:: iter_branches(self) Iterate over branch names and their commit histories. .. !! processed by numpydoc !! .. method:: iter_commits(self) Iterate over all commit hashes in the repository. .. !! processed by numpydoc !! .. method:: load_history(self, model, skip=('gh-pages', )) Load the entire results history into memory. Could be a bad idea in a far future. .. !! processed by numpydoc !! .. method:: get_result(self, commit, default=None) Return an individual result from the history if it exists. .. !! processed by numpydoc !! .. method:: __contains__(self, commit) Test for the existence of a result for a commit. .. !! processed by numpydoc !! .. py:class:: ReportConfiguration(*args, **kwargs) Bases: :class:`dict` Collect the metabolic model test suite results. .. !! processed by numpydoc !! .. classmethod:: load(cls, filename=None) Load a test report configuration. .. !! processed by numpydoc !! .. method:: merge(self, other) Merge a custom configuration. .. !! processed by numpydoc !! .. py:class:: Report(result, configuration, **kwargs) Bases: :class:`object` Determine the abstract report interface. :Attributes: **result** : memote.MemoteResult The dictionary structure of results. **configuration** : memote.MemoteConfiguration A memote configuration structure. .. !! processed by numpydoc !! .. method:: 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). .. !! processed by numpydoc !! .. method:: render_html(self) Render an HTML report. .. !! processed by numpydoc !! .. method:: get_configured_tests(self) Get tests explicitly configured. .. !! processed by numpydoc !! .. method:: 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. .. !! processed by numpydoc !! .. method:: compute_score(self) Calculate the overall test score using the configuration. .. !! processed by numpydoc !! .. data:: LOGGER .. py:class:: SnapshotReport(**kwargs) Bases: :class:`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. .. !! processed by numpydoc !! .. py:class:: HistoryReport(history, configuration, **kwargs) Bases: :class:`memote.suite.reporting.report.Report` Render a rich report using the git repository history. :Attributes: **configuration** : memote.MemoteConfiguration A memote configuration structure. .. !! processed by numpydoc !! .. method:: collect_history(self) Build the structure of results in terms of a commit history. .. !! processed by numpydoc !! .. py:class:: DiffReport(diff_results, configuration, **kwargs) Bases: :class:`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. .. !! processed by numpydoc !! .. method:: format_and_score_diff_data(self, diff_results) Reformat the api results to work with the front-end. .. !! processed by numpydoc !! .. py:class:: MemoteExtension(environment) Bases: :class:`jinja2.ext.Extension` Provide an absolute path to a file. .. !! processed by numpydoc !! .. attribute:: tags .. staticmethod:: normalize(filename) Return an absolute path of the given file name. .. !! processed by numpydoc !!