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

[Feature] Equality of metabolites and reactions #1414

Open
1 task done
oxinabox opened this issue Nov 26, 2024 · 0 comments
Open
1 task done

[Feature] Equality of metabolites and reactions #1414

oxinabox opened this issue Nov 26, 2024 · 0 comments

Comments

@oxinabox
Copy link
Contributor

oxinabox commented Nov 26, 2024

Checklist

Problem

I want to be able to detect if metabolites or reactions are equal so i can avoid adding duplicates to my model.

Consider:

In [1]: from cobra import Model, Reaction, Metabolite

In [2]: m_o2 = Metabolite("o2", "O2", "oxygen")

In [3]: m_o2 == m_o2.copy()
Out[3]: False

In [4]:     ex_o2 = Reaction("EX_o2", lower_bound=-100, upper_bound=100)
    ...:     ex_o2.add_metabolites({m_o2: -1})
    ...: 

In [5]: ex_o2 == ex_o2.copy()
Out[5]: False

Solution

The exact details of how this would work is unclear to me.
In terms of should it require that the metabolites have same id, or should it require a deeper check that they are equal in all fields.
Should it allow different id if name is the same?

In general though we should be be able to detect if reactions are the same.

Alternatives

In general it seems like sometimes reactions are considered equal if they have the same identifier.
Except the equality operator is not implemented.
E.g. model.add_reactions will ignore requests to add things with same id

In [29]: model.add_reactions([ex_o2])

In [30]: model.add_reactions([ex_o2])
Ignoring reaction 'EX_o2' since it already exists.

Anything else?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant