Skip to content

Commit

Permalink
fixed some bugs I introduced
Browse files Browse the repository at this point in the history
  • Loading branch information
uri.akavia committed Aug 7, 2022
1 parent b7d746b commit 0b10a81
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions release-notes/next-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
of SBO:0000633 (see https://sourceforge.net/p/sbo/term-request/113/)
* Correct reading and writing of subsystem in mat.
* General cleanup of code in mat.py
* Fixed issue 673 (problem when copying reaction from a different model)

## Other

Expand Down
4 changes: 2 additions & 2 deletions src/cobra/core/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -863,13 +863,13 @@ def remove_reactions(
reaction._model = None

for met in reaction.metabolites:
if reaction in met.reactions:
if reaction in met._reaction:
met.reaction_remove(reaction, context)
if remove_orphans and len(met.reactions) == 0:
self.remove_metabolites(met)

for gene in reaction.genes:
if reaction in gene.reactions:
if reaction in gene._reaction:
gene.reaction_remove(reaction, context)

if remove_orphans and len(gene.reactions) == 0:
Expand Down
10 changes: 6 additions & 4 deletions src/cobra/core/species.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,15 @@ def reactions(self) -> FrozenSet:
A frozenset that includes the reactions of the species.
"""
if self.model and self.__class__.__name__ == "Gene":
return self.model.reactions.query(lambda x: self in x, "genes")
return frozenset(self.model.reactions.query(lambda x: self in x, "genes"))
elif self.model and self.__class__.__name__ == "Metabolite":
return self.model.reactions.query(lambda x: self in x, "metabolites")
return frozenset(
self.model.reactions.query(lambda x: self in x, "metabolites")
)
return frozenset(self._reaction)

def reaction_add(
self, reaction: Reaction, context: Optional[HistoryManager] = None
self, reaction: "Reaction", context: Optional[HistoryManager] = None
) -> None:
"""Add reaction to .reaction field, with context.
Expand All @@ -81,7 +83,7 @@ def reaction_add(
context(partial(self._reaction.remove, reaction))

def reaction_remove(
self, reaction: Reaction, context: Optional[HistoryManager] = None
self, reaction: "Reaction", context: Optional[HistoryManager] = None
) -> None:
"""Remove reaction from .reaction field, with context.
Expand Down

0 comments on commit 0b10a81

Please sign in to comment.