Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support CARVEME and GAPSEQ external IDs #1404

Merged
merged 7 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions release-notes/next-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
* Fixed a bug with SBML group parsing that affects the Debian package.

## Other

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

## Deprecated features

Expand Down
11 changes: 10 additions & 1 deletion src/cobra/medium/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
"intracellular",
"intracellular region",
"intracellular space",
"c0", # GAPSEQ
"C_c" # CARVEME
],
"er": ["endoplasmic reticulum"],
"erm": ["endoplasmic reticulum membrane"],
Expand All @@ -68,6 +70,8 @@
"extra-organism",
"external",
"external medium",
"e0", # GAPSEQ
"C_e" # CARVEME
],
"f": ["flagellum", "bacterial-type flagellum"],
"g": ["golgi", "golgi apparatus"],
Expand All @@ -78,7 +82,12 @@
"mm": ["mitochondrial membrane"],
"m": ["mitochondrion", "mitochondria"],
"n": ["nucleus"],
"p": ["periplasm", "periplasmic space"],
"p": [
"periplasm",
"periplasmic space",
"p0", # GAPSEQ
"C_p" # CARVEME
],
"x": ["peroxisome", "glyoxysome"],
"u": ["thylakoid"],
"vm": ["vacuolar membrane"],
Expand Down
2 changes: 1 addition & 1 deletion src/cobra/medium/boundary_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def find_external_compartment(model: "Model") -> str:
"Consider renaming your compartments using "
"`Model.compartments` to fix this."
)
return most[0]
return most.iloc[0]

# No info in the model, so give up
raise RuntimeError(
Expand Down
12 changes: 12 additions & 0 deletions tests/test_medium/test_boundary_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
find_external_compartment,
is_boundary_type,
)
import logging


def test_find_external_compartment_single(model: Model) -> None:
Expand Down Expand Up @@ -40,6 +41,17 @@ def test_find_external_compartment_multi(model: Model) -> None:
find_external_compartment(model)


@pytest.mark.parametrize("compartment", ["C_e", "e0"])
def test_find_external_popular_reconstructions(model: Model, compartment, caplog) -> None:
"""Test some additional id formats."""
for ex in model.exchanges:
ex.reactants[0].compartment = compartment
with caplog.at_level(logging.WARNING):
external = find_external_compartment(model)
assert external == compartment
assert "complete nonsense" not in caplog.text


def test_no_names_or_boundary_reactions(empty_model: Model) -> None:
"""Test absence of name or boundary reactions."""
with pytest.raises(RuntimeError):
Expand Down
Loading