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

reaction is incorrectly added #94

Closed
jotech opened this issue May 28, 2014 · 1 comment
Closed

reaction is incorrectly added #94

jotech opened this issue May 28, 2014 · 1 comment

Comments

@jotech
Copy link

jotech commented May 28, 2014

I have noticed some strange behaviour when adding a reaction that
contains the same metabolite on both sides:

from cobra import Model, Reaction, Metabolite

model = Model("test")

A = Metabolite("A", formula="C1", name="Substance A", compartment="c")
B = Metabolite("B", formula="C2", name="Substance B", compartment="c")
C = Metabolite("C", formula="C3", name="Substance C", compartment="c")

reaction = Reaction("new_reaction")
reaction.name = "Test reaction"

reaction.add_metabolites({A: -1.0,
                          B: -1.0,
                          A: 1.0,
                          C: 1.0})

print reaction.reaction
model.add_reaction(reaction)

output is

B --> C + A

instead of

A + B --> C + A

I'm working with cobra 0.3.0.dev.

@aebrahim
Copy link
Member

aebrahim commented Jun 4, 2014

A python dict requires unique keys. If you include A twice in the dict as you define it, it will only keep the second definition.

>>> {"a": -1, "a": 1}
{'a': 1}

So cobrapy is handling what it is being given correctly.

@aebrahim aebrahim closed this as completed Jun 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants