Skip to content

Commit

Permalink
refactor: copy added metabolites from other models (#677)
Browse files Browse the repository at this point in the history
  • Loading branch information
pstjohn authored and Midnighter committed Mar 13, 2018
1 parent 51cd74d commit 542b0e8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cobra/core/reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,14 @@ def add_metabolites(self, metabolites_to_add, combine=True,
_id_to_metabolites = dict([(x.id, x) for x in self._metabolites])

for metabolite, coefficient in iteritems(metabolites_to_add):

# 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
(metabolite.model is not self._model)):
metabolite = metabolite.copy()

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

0 comments on commit 542b0e8

Please sign in to comment.