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

Issues with Community Modeling and SteadyCom Function in MEWpy #46

Open
wtscott31 opened this issue May 29, 2024 · 1 comment
Open

Issues with Community Modeling and SteadyCom Function in MEWpy #46

wtscott31 opened this issue May 29, 2024 · 1 comment

Comments

@wtscott31
Copy link

Hello @vvvieira, @jorgemlferreira and the MEWpy team,

First, I'd like to express my appreciation for the tool your group has developed for in-silico metabolic modeling and engineering. It appears to be a fine tool for researchers in the field.

I have been following the tutorial to perform modeling analysis on a community of twelve microbes. However, I am encountering several issues that I hope you can help me resolve. Despite referring to the documentation, I find it limited for community analysis.

Issues Encountered:
Difficulty Constraining the Community Model:
After building a community model of the twelve GEMs, I am unable to effectively constrain the model. The new model seems to lack bounds or reaction IDs as seen in COBRA models. Consequently, the community model exhibits unrealistically high growth rates since virtually all reactions have infinite bounds. How can I properly set bounds and identify reactions within the community model?

AttributeError in SteadyCom Function:
When attempting to run the SteadyCom function, I encounter the following error:

AttributeError: 'Simulation' object has no attribute 'get_community_model'

I am unsure how to troubleshoot this issue. Any guidance on properly running SteadyCom would be greatly appreciated.

Here is the code I am using:

import mewpy
from cobra.io import read_sbml_model
from mewpy import get_simulator

# Load the twelve GEMs
models = []
model_paths = [
    '~/Dehalobacter_restrictus_cur.xml',
    '/~Dehalobacter_sp004343605_cur.xml',
    '~/`Acetobacterium_sp003260995.xml',
    '~/f__Cloacimonadaceae_g__Cloacimonas_s__.xml',
 '~/g__Methanothrix_s__.xml',
    '~/Methanobacterium_C_congolense.xml', 
  '~/o__Bacteroidales_f__TTA-H9_g__TTA-H9_s__TTA-H9_sp002418865.xml',
   '~/o__Bacteroidales_f__VadinHA17_g__LD21_s__.xml',
    '~/o__Bacteroidales_f__VadinHA17_g__SR-FBR-E99_s__.xml',
    '~/Rectinema_sp002441395.xml',
    '~/Rectinema_sp015657395.xml',
    '~/Rectinema_subterraneum.xml'
]

for path in model_paths:
    model = read_sbml_model(path)
    models.append(get_simulator(model))

# Set medium composition
new_medium = {
    'EX_cpd00001_e0': 1000.0,
    'EX_cpd00011_e0': 50.0, # CO2
    'EX_cpd11640_e0': 100.0,
    'EX_cpd00009_e0': 100.0,
    'EX_cpd00030_e0': 100.0,
    'EX_cpd00034_e0': 100.0,
    'EX_cpd00048_e0': 100.0,
    'EX_cpd00058_e0': 100.0,
    'EX_cpd00063_e0': 100.0,
    'EX_cpd00067_e0': 0.1,
    'EX_cpd00099_e0': 100.0,
    'EX_cpd00149_e0': 100.0,
    'EX_cpd00205_e0': 100.0,
    'EX_cpd00254_e0': 100.0,
    'EX_cpd00971_e0': 100.0,
    'EX_cpd10515_e0': 100.0,
    'EX_cpd10516_e0': 0.01,
    'EX_cpd00013_e0': 100.0,
    'EX_cpd00244_e0': 100.0,
    'EX_cpd03998_e0': 25.0, # TCB
    'EX_cpd00116_e0': 25.0, # Methanol
    'EX_cpd00007_e0': 0.0, # O2
}

# Build community model
from mewpy.model import CommunityModel

community = CommunityModel([sim.model for sim in models], flavor='cobra')

# Set bounds for reactions in the community model
for reaction in sim.reactions:
    if hasattr(reaction, 'lower_bound') and hasattr(reaction, 'upper_bound'):
        lb = max(reaction.lower_bound, -1000)
        ub = min(reaction.upper_bound, 1000)
        # Using set_reaction_bounds method to set the bounds
        sim.set_reaction_bounds(reaction.id, lb, ub, track=True)
    else:
        print(f"Skipping non-reaction object: {reaction}")

# Perform pFBA simulation
from mewpy.simulation import SimulationMethod

solution = sim.simulate(method=SimulationMethod.pFBA)
solution

# Run SteadyCom
from mewpy.cobra.com import SteadyCom

solution = SteadyCom(sim, constraints=new_medium)
print("Community growth rate:", solution.community_growth)
print("Species abundances:", solution.abundances)

Could you please provide guidance on how to properly constrain the community model and troubleshoot the AttributeError in the SteadyCom function? Any additional documentation or examples specific to community analysis would be greatly appreciated.

Thank you for your assistance!

@wtscott31
Copy link
Author

@vmspereira

Can you or anyone else help me with this? I can also provide the accompanying files if needed.

Thanks in advance!

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

1 participant