1.3. Using Git to track changes and using Memote

In the following, the changes made to the model are documented using Git and evaluated using Memote [1], a test suite for standardized genome-scale metabolic model testing.

For this we first install Memote.

$ pip install memote

To perform the next steps, we need a local copy of the model in SBML format.

To be able to use Memote with all of its features a new repository needs to be created. This can be done using the following command. (To use the online features of Memote, it is necessary to answer the questions regarding GitHub.)

$ memote new

This command requires questions to be answered interactively. Thus it is not possible to execute this command in this tutorial Jupyter Notebooks.

During the interactions with Memote, the user needs to define the model name and the original location. Memote then creates a folder after a few more questions, in which configuration files for Memote and Git are automatically created and into which the model is copied.

Here we use the default values for all questions.

Next, we change the working directory to the folder created by Memote.

[ ]:
directory = "/home/jan/arbeit/memote_test/memote-model-repository"
%cd $directory

Memote automatically installs GitPython, which enables using the functionalities of Git. Additionally, we import the following functions which will be used later.

[ ]:
from git import Repo
from cobra.io import write_sbml_model, validate_sbml_model
from cobramod import add_reactions

In this folder, we can now work on the model with Memote and CobraMod. After the completed processing of the model, all changes can be saved via git using a commit.

First, we import the model copied into the folder.

[ ]:
model, errors = validate_sbml_model("model.xml")
errors
{'SBML_FATAL': [],
 'SBML_ERROR': [],
 'SBML_SCHEMA_ERROR': [],
 'SBML_WARNING': [],
 'COBRA_FATAL': [],
 'COBRA_ERROR': [],
 'COBRA_WARNING': [],
 'COBRA_CHECK': []}

At this point, we can make changes to the current model, save additional files, such as a summary using CobraMod, special reports using Memote, or files we have created yourselves in the folder.

Once all changes that should be saved have been made, we can save the current model in the previously created folder under the name chosen during memote new. This is done directly using COBRApy.

[ ]:
write_sbml_model(model,"model.xml")

Next, the changes to be saved are passed to git. Using ‘add’, we can individually determine whether all/new/changed files should be added to the repository or not. This can also also be defined systematically via a “.gitignore” file. Finally, we perform a commit to track the changes made to the model. Here we provide a short description to summarize the changes in the model.

[ ]:
from git import Repo
repo = Repo(directory)
repo.git.add(update=True)
repo.index.commit("This is a brief description of the changes.")
<git.Commit "d3bfe23dc7e901ca1db17c049c4d631ec3cce9ab">

If we want to send the changes to a configured Git server, we can execute the following commands. For this, a remote must be set for the repository.

[ ]:
origin = repo.remote(name='origin')
origin.push()

All Git-related commands have been done here using GitPython but can also be replaced by the corresponding command-line commands.

We now have finished preparing the project for the use of Memote and all of its functions can now be used. For those functions that require GitHub, a connection to GitHub must exist.

The easiest way to do this is to answer the questions regarding GitHub during memote new. Alternatively, GitHub can be added as a remote at a later time. However, this will not be discussed here.

Finally, we use memote report snapshot and obtain an HTML file that summarizes the state of the model and lists possible errors as shown in the following:

[ ]:
!memote report snapshot
Scaling...
 A: min|aij| =  1.000e+00  max|aij| =  1.000e+00  ratio =  1.000e+00
Problem data seem to be well scaled
The current solver interface glpk doesn't support setting the optimality tolerance.
============================= test session starts ==============================
platform linux -- Python 3.7.4, pytest-4.6.11, py-1.10.0, pluggy-0.13.1
rootdir: /home/jan
plugins: anyio-3.3.0
collected 146 items / 1 skipped / 145 selected

../../../miniconda3/envs/cobramod/lib/python3.7/site-packages/memote/suite/tests/test_annotation.py F [  0%]
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF..FF..F...F.F..F.F.F..F..FFF...         [ 44%]
../../../miniconda3/envs/cobramod/lib/python3.7/site-packages/memote/suite/tests/test_basic.py . [ 45%]
.....F.F..........F.FF                                                   [ 60%]
../../../miniconda3/envs/cobramod/lib/python3.7/site-packages/memote/suite/tests/test_biomass.py . [ 60%]
F..FF...F                                                                [ 67%]
../../../miniconda3/envs/cobramod/lib/python3.7/site-packages/memote/suite/tests/test_consistency.py . [ 67%]
..ssssssssssssssssF..F.F.FF.                                             [ 86%]
../../../miniconda3/envs/cobramod/lib/python3.7/site-packages/memote/suite/tests/test_essentiality.py s [ 87%]
                                                                         [ 87%]
../../../miniconda3/envs/cobramod/lib/python3.7/site-packages/memote/suite/tests/test_growth.py s [ 88%]
                                                                         [ 88%]
../../../miniconda3/envs/cobramod/lib/python3.7/site-packages/memote/suite/tests/test_matrix.py . [ 89%]
...                                                                      [ 91%]
../../../miniconda3/envs/cobramod/lib/python3.7/site-packages/memote/suite/tests/test_sbml.py . [ 91%]
.                                                                        [ 92%]
../../../miniconda3/envs/cobramod/lib/python3.7/site-packages/memote/suite/tests/test_sbo.py . [ 93%]
F.....FsF.                                                               [100%]

=============== 63 failed, 64 passed, 20 skipped in 2.69 seconds ===============
Writing snapshot report to 'index.html'.
[1]:
from IPython.display import IFrame
IFrame(src='./_static/memote.html', width="100%", height=800)
[1]:
[1]

Christian Lieven et al., MEMOTE for standardized genome-scale metabolic model testing. Nature Biotechnology, 38(3):272–276, March 2020. doi:10.1038/s41587-020-0446-y.

[2]

Sébastien Moretti et al., MetaNetX/MNXref: unified namespace for metabolites and biochemical reactions in the context of metabolic models. Nucleic Acids Research, 49(D1):D570–D574, November 2020. doi:10.1093/nar/gkaa992.

[3]

Sébastien Moretti et al., MetaNetX/MNXref – reconciliation of metabolites and biochemical reactions to bring together genome-scale metabolic networks. Nucleic Acids Research, 44(D1):D523–D526, November 2015. doi:10.1093/nar/gkv1117.

[4]

M. Ganter et al., MetaNetX.org: a website and repository for accessing, analysing and manipulating metabolic networks. Bioinformatics, 29(6):815–816, January 2013. doi:10.1093/bioinformatics/btt036.

[5]

T. Bernard et al., Reconciliation of metabolites and biochemical reactions for metabolic networks. Briefings in Bioinformatics, 15(1):123–135, November 2012. doi:10.1093/bib/bbs058.

[6]

Sunghwan Kim et al., PubChem in 2021: new data content and improved web interfaces. Nucleic Acids Research, 49(D1):D1388–D1395, November 2020. doi:10.1093/nar/gkaa971.

[7]

Antje Chang et al., BRENDA, the ELIXIR core data resource in 2021: new developments and updates. Nucleic Acids Research, 49(D1):D498–D508, November 2020. doi:10.1093/nar/gkaa1025.

[8]

Apache Software Foundation, Apache Arrow Version 6.0.1. , November 2021. URL: https://arrow.apache.org/.