Skip to content

Commit 0b10a81

Browse files
author
uri.akavia
committed
fixed some bugs I introduced
1 parent b7d746b commit 0b10a81

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

release-notes/next-release.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
of SBO:0000633 (see https://sourceforge.net/p/sbo/term-request/113/)
1010
* Correct reading and writing of subsystem in mat.
1111
* General cleanup of code in mat.py
12+
* Fixed issue 673 (problem when copying reaction from a different model)
1213

1314
## Other
1415

src/cobra/core/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -863,13 +863,13 @@ def remove_reactions(
863863
reaction._model = None
864864

865865
for met in reaction.metabolites:
866-
if reaction in met.reactions:
866+
if reaction in met._reaction:
867867
met.reaction_remove(reaction, context)
868868
if remove_orphans and len(met.reactions) == 0:
869869
self.remove_metabolites(met)
870870

871871
for gene in reaction.genes:
872-
if reaction in gene.reactions:
872+
if reaction in gene._reaction:
873873
gene.reaction_remove(reaction, context)
874874

875875
if remove_orphans and len(gene.reactions) == 0:

src/cobra/core/species.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,15 @@ def reactions(self) -> FrozenSet:
5858
A frozenset that includes the reactions of the species.
5959
"""
6060
if self.model and self.__class__.__name__ == "Gene":
61-
return self.model.reactions.query(lambda x: self in x, "genes")
61+
return frozenset(self.model.reactions.query(lambda x: self in x, "genes"))
6262
elif self.model and self.__class__.__name__ == "Metabolite":
63-
return self.model.reactions.query(lambda x: self in x, "metabolites")
63+
return frozenset(
64+
self.model.reactions.query(lambda x: self in x, "metabolites")
65+
)
6466
return frozenset(self._reaction)
6567

6668
def reaction_add(
67-
self, reaction: Reaction, context: Optional[HistoryManager] = None
69+
self, reaction: "Reaction", context: Optional[HistoryManager] = None
6870
) -> None:
6971
"""Add reaction to .reaction field, with context.
7072
@@ -81,7 +83,7 @@ def reaction_add(
8183
context(partial(self._reaction.remove, reaction))
8284

8385
def reaction_remove(
84-
self, reaction: Reaction, context: Optional[HistoryManager] = None
86+
self, reaction: "Reaction", context: Optional[HistoryManager] = None
8587
) -> None:
8688
"""Remove reaction from .reaction field, with context.
8789

0 commit comments

Comments
 (0)