Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
uri.akavia committed Aug 7, 2022
1 parent 0b10a81 commit 01c6c3a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/cobra/core/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ def existing_filter(new_group: Group) -> bool:
"""
if new_group.id in self.groups:
logger.warning(
f"Ignoring group '{new_group.id}'" f" since it already exists."
f"Ignoring group '{new_group.id}' since it already exists."
)
return False
return True
Expand Down
19 changes: 9 additions & 10 deletions src/cobra/core/reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,8 @@ def metabolites(self, value: Dict[Metabolite, float]) -> None:
"""Set metabolites to a dictionary of metabolites and coefficients.
Parameters
-------
metabolites: Dict[Metabolite, float]
----------
value: Dict[Metabolite, float]
A dictionary of cobra.Metabolite for keys and floats for coeffecieints.
Positive coefficient means the reaction produces this metabolite, while
negative coefficient means the reaction consumes this metabolite.
Expand Down Expand Up @@ -1014,7 +1014,7 @@ def __iadd__(self, other: "Reaction") -> "Reaction":
rule2 = other.gene_reaction_rule.strip()
if rule1 != "" and rule2 != "":
self.gene_reaction_rule = (
f"({self.gene_reaction_rule}) and " f"({other.gene_reaction_rule})"
f"({self.gene_reaction_rule}) and ({other.gene_reaction_rule})"
)
elif rule1 != "" and rule2 == "":
self.gene_reaction_rule = rule1
Expand Down Expand Up @@ -1227,13 +1227,12 @@ def add_metabolites(

# Make sure metabolites being added belong to the same model, or
# else copy them.
if isinstance(metabolite, Metabolite):
if (
(metabolite.model is not None)
and self.model
and (metabolite.model is not self._model)
):
metabolite = metabolite.copy()
if isinstance(metabolite, Metabolite) and (
(metabolite.model is not None)
and self.model
and (metabolite.model is not self._model)
):
metabolite = metabolite.copy()

met_id = str(metabolite)
# If a metabolite already exists in the reaction then
Expand Down

0 comments on commit 01c6c3a

Please sign in to comment.