Skip to content

Commit f6567ea

Browse files
authored
Support CARVEME and GAPSEQ external IDs (#1404)
* add more external ID patterns * add RNs * add tests * fix isort * yes isort, I will add some random spaces here, makes perfect sense * of course black, please join the party * you drunk black, go home
1 parent 9d580d6 commit f6567ea

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

release-notes/next-release.md

+3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
* Fixed a bug with SBML group parsing that affects the Debian package.
1010

1111
## Other
12+
1213
* Adding a duplicate boundary reaction (with `add_boundary`) no longer errors, but instead just returns the existing reaction.
14+
* Automatic detection of the external comprtment now recognizes CARVEME and GAPSEQ ids and will no longer
15+
show a warning for models generated with those tools.
1316

1417
## Deprecated features
1518

src/cobra/medium/annotations.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
"intracellular",
5656
"intracellular region",
5757
"intracellular space",
58+
"c0", # GAPSEQ
59+
"C_c", # CARVEME
5860
],
5961
"er": ["endoplasmic reticulum"],
6062
"erm": ["endoplasmic reticulum membrane"],
@@ -68,6 +70,8 @@
6870
"extra-organism",
6971
"external",
7072
"external medium",
73+
"e0", # GAPSEQ
74+
"C_e", # CARVEME
7175
],
7276
"f": ["flagellum", "bacterial-type flagellum"],
7377
"g": ["golgi", "golgi apparatus"],
@@ -78,7 +82,7 @@
7882
"mm": ["mitochondrial membrane"],
7983
"m": ["mitochondrion", "mitochondria"],
8084
"n": ["nucleus"],
81-
"p": ["periplasm", "periplasmic space"],
85+
"p": ["periplasm", "periplasmic space", "p0", "C_p"], # GAPSEQ # CARVEME
8286
"x": ["peroxisome", "glyoxysome"],
8387
"u": ["thylakoid"],
8488
"vm": ["vacuolar membrane"],

src/cobra/medium/boundary_types.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def find_external_compartment(model: "Model") -> str:
9494
"Consider renaming your compartments using "
9595
"`Model.compartments` to fix this."
9696
)
97-
return most[0]
97+
return most.iloc[0]
9898

9999
# No info in the model, so give up
100100
raise RuntimeError(

tests/test_medium/test_boundary_types.py

+15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Test functionalities of boundary type detection functions."""
22

3+
import logging
4+
35
import pytest
46

57
from cobra.core import Metabolite, Model, Reaction
@@ -40,6 +42,19 @@ def test_find_external_compartment_multi(model: Model) -> None:
4042
find_external_compartment(model)
4143

4244

45+
@pytest.mark.parametrize("compartment", ["C_e", "e0"])
46+
def test_find_external_popular_reconstructions(
47+
model: Model, compartment, caplog
48+
) -> None:
49+
"""Test some additional id formats."""
50+
for ex in model.exchanges:
51+
ex.reactants[0].compartment = compartment
52+
with caplog.at_level(logging.WARNING):
53+
external = find_external_compartment(model)
54+
assert external == compartment
55+
assert "complete nonsense" not in caplog.text
56+
57+
4358
def test_no_names_or_boundary_reactions(empty_model: Model) -> None:
4459
"""Test absence of name or boundary reactions."""
4560
with pytest.raises(RuntimeError):

0 commit comments

Comments
 (0)