micom-dev / micom

Python package to study microbial communities using metabolic modeling.
https://micom-dev.github.io/micom
Apache License 2.0
82 stars 17 forks source link

Error occurs when joining two models after changing their metabolite IDs #12

Closed wintermute221 closed 3 years ago

wintermute221 commented 3 years ago

Hi, I am trying to build a community for two models and I've already changed the metabolite IDs for each model. I renamed the metabolite IDs as + such as C12145cytoplasm ('C12145' is KEGG ID and 'cytoplasm' is the name of the compartment). Firstly one thing I'd like to double-check is that do I need to change the compartment ID as well even though I didn't use the compartment ID for matching models?

Secondly, when I tried to join the two renamed models an error occurred:

File "/Users/wintermute/opt/anaconda3/lib/python3.7/urllib/parse.py", line 107, in <genexpr>
    return tuple(x.decode(encoding, errors) if x else '' for x in args)
AttributeError: 'Model' object has no attribute 'decode'

Here is my code:

sc = micom.util.load_model('/Users/wintermute/OneDrive - University of Cambridge/cambridge/during_cam/Department/work/code/coculture/yeast7.6_changeID_final.xml')

kp = micom.util.load_model('/Users/wintermute/OneDrive - University of Cambridge/cambridge/during_cam/Department/work/code/coculture/KP_changeID_final3.xml')

community = [sc,kp]

micom.util.join_models(community)

Does anyone have any idea about that? Thanks.

cdiener commented 3 years ago

join_models expects a list of filepaths or urls as models and not loaded models. It will figure out how to load the models itself. So just skip the load_model step and use the filepaths. However, I'm wondering if that is want you want to do. This will essentially build a pangenome model of the two models. If you want a community model where both species grow in a shared growth medium this should be done with micom.Community.

wintermute221 commented 3 years ago

Yeah, actually you're right that the community model is what I want, but when I looked though micom.util module it doesn't talk about building a pangenome model so I thought it would just help me join the models together and then let them grow in one shared environment. Is there any command in micom.Community that could make the two .XML files with same metabolite ID a new model? Thanks.

cdiener commented 3 years ago

micom.Community does exactly that :smile: For general usage the official docs are probably more informative than the docstrings. For instance have a look at https://micom-dev.github.io/micom/community.html.

wintermute221 commented 3 years ago

Thank you! I've successfully built a community model with that! Appreciate your help!