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

'set' object has no attribute 'get_by_id' #50

Closed
Harry-Pollitt opened this issue Apr 5, 2023 · 2 comments
Closed

'set' object has no attribute 'get_by_id' #50

Harry-Pollitt opened this issue Apr 5, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@Harry-Pollitt
Copy link

Hi

I've been following along with your test case scenario found here https://cobramod.readthedocs.io/en/latest/homoserine_cycle.html however when I try to visualise the "Homoserine-PWY" group with escher using the code provided I get an AttributeError. I have double checked that I have all the required packages I may be mistaken however.

Using the following code in my jupyter notebook

solution01 = model.optimize()
print(solution01)
model.groups.get_by_id("Homoserine-PWY").color_negative = "red"
model.groups.get_by_id("Homoserine-PWY").color_positive = "green"
model.groups.get_by_id("Homoserine-PWY").visualize(solution_fluxes=solution01)

produces the error:


<Solution 12.330 at 0x7f7858795d60>

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input In [45], in <cell line: 5>()
      3 model.groups.get_by_id("Homoserine-PWY").color_negative = "red"
      4 model.groups.get_by_id("Homoserine-PWY").color_positive = "green"
----> 5 model.groups.get_by_id("Homoserine-PWY").visualize(solution_fluxes=solution01)

File ~/anaconda3/lib/python3.9/site-packages/cobramod/core/pathway.py:276, in Pathway.visualize(self, solution_fluxes, filename)
    274 # Get graph and add to json_dict
    275 json_dict.graph = self.graph.copy()
--> 276 json_dict.reaction_strings = {
    277     reaction: self.members.get_by_id(reaction).reaction
    278     for reaction in json_dict.graph.keys()
    279 }
    281 return json_dict.visualize(
    282     filepath=filename,
    283     vertical=self.vertical,
   (...)
    288     n_steps=self.color_n_steps,
    289 )

File ~/anaconda3/lib/python3.9/site-packages/cobramod/core/pathway.py:277, in <dictcomp>(.0)
    274 # Get graph and add to json_dict
    275 json_dict.graph = self.graph.copy()
    276 json_dict.reaction_strings = {
--> 277     reaction: self.members.get_by_id(reaction).reaction
    278     for reaction in json_dict.graph.keys()
    279 }
    281 return json_dict.visualize(
    282     filepath=filename,
    283     vertical=self.vertical,
   (...)
    288     n_steps=self.color_n_steps,
    289 )

AttributeError: 'set' object has no attribute 'get_by_id'


The group itself exists as model.groups.get_by_id("Homoserine-PWY") produces the expected result.
Any help would be appreciated.

Regards,
Harry

@cambordas
Copy link
Collaborator

Hi @Harry-Pollitt , thank you very much for opening the issue. Indeed, there is a problem with the actual version of COBRApy. In their previous versions, Groups.members was a DictList but they changed it in opencobra/cobrapy#1221
We will update CobraMod soon to be compatible with the latest version of COBRApy. I will notify you soon

@cambordas cambordas added the bug Something isn't working label Apr 11, 2023
@cambordas cambordas self-assigned this Apr 11, 2023
cambordas added a commit that referenced this issue Feb 20, 2024
Added:
Memote example files added to docs
Curation and visualization logs are now separated by date in a 'logs' dir
Usage of credentials for BioCyc database
New structure cobramod.retrieval.Data. It is in charge of parsing into different objects
Extra functions in utils

Changed:
Set object bug fixed [#50]
Escher is an optional dependency
Pre-hooks uses now ruff instead of flake8 and black.
Behaviour to open files if escher is not installed changed to not open browsers
Dropped support for python 3.8 and 3.9
Logging format is more human-friendly
Dropped support of mypy. Black is replaced with ruff
New pyproject.toml
Test data updated (19.02.24)
Function available_databases replaced by cobramod.retrieval.Databases
Structure for retrieval refactored and new parsing sub-packaged created
DataVersion moved to parsing package
Updated structure of test module
Removed multiple "private" methods and functions.
Docs files updated to these new changes
Test updated to uses new changes
Updating functions to not use deprecated pandas functions

Removed:
Deprecated config files
Deprecation warning for SolCyc (Database appears to be shutdown)
@cambordas
Copy link
Collaborator

We are sorry for the very late response!
Nonetheless, the new version of CobraMod #53 should have fix that error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants