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

Support for merging sbml models #65

Open
idlip opened this issue Mar 13, 2025 · 7 comments
Open

Support for merging sbml models #65

idlip opened this issue Mar 13, 2025 · 7 comments

Comments

@idlip
Copy link

idlip commented Mar 13, 2025

Hi fbergmann,

Thank you for extending basico, its simple and makes copasi workflow even better.
The API is straight forward and easy to use.

May I know if there is a recommended way to merge sbml models.

I have found one paper explaining on merging models using copasi (add to model) option
https://www.mdpi.com/2079-7737/12/8/1133#app1-biology-12-01133

Under 2.3. Merging the SBML Files heading

There is https://github.com/matthiaskoenig/sbmlutils/ (sbmlutils) which has merge option (https://sbmlutils.readthedocs.io/en/stable/notebooks/sbml_merge.html)

But that again gives lots of validation errors.

or would it be same if we simulate same input in multiple models each separately and add or average the resulting report together?

Thank you

@fbergmann
Copy link
Member

There is not yet an API that would make model merging easier. But i verified that it would work, just as in the COPASI graphical userinterface. The key idea is

  • you open a first model (Copasi / SBML)
  • then you add to it the elements of a second model (in the gui via File\Add to model)
  • then you choose and merge those elements that should be considered to be the same (in the gui via Tools\Merge added model)

So i would invite you to try that out in COPASI first.

in basico you could either do that yourself (merging the dictionaries / dataframes obtained from get_species / get_reactions) or use the underlying C++ API that has now been exposed. If you have an example of which models you would like to see merged, and a list of what in the model you would like to have treated the same, then i can produce one.

@idlip
Copy link
Author

idlip commented Mar 14, 2025

So i would invite you to try that out in COPASI first.

Sure, I will it give a brief try on it.
But one major issue I can think of is the mismatch in naming scheme.

in basico you could either do that yourself (merging the dictionaries / dataframes obtained from get_species / get_reactions) or use the underlying C++ API that has now been exposed.

This also seems sensible to do, I will try this method as well.

Thank you for suggesting and offering help.

@fbergmann
Copy link
Member

I've created a colab notebook, that shows how it would currently be done in basico:

https://colab.research.google.com/drive/1XhiF1NzeEZ8ZLR1TNnUhzVPVj3EoHSMv?usp=sharing

If you have an idea how that API should be simplified please let me know, i can certainly hide the calls better and combine them perhaps using the element names to simplify the merging. Any feedback would be appreciated.

@idlip
Copy link
Author

idlip commented Mar 14, 2025

I've created a colab notebook, that shows how it would currently be done in basico:

https://colab.research.google.com/drive/1XhiF1NzeEZ8ZLR1TNnUhzVPVj3EoHSMv?usp=sharing

I cannot thank you enough for this support. The note is comprehensive and is very helpful.
You just made my thinking easier and simple. I understood the approach/idea.

API looks really extensive, I love to explore and play with this.
Compared to cobrapy on parsing and operating on models, basico is just better.

Just that COPASI.* classes seems new to me, although its a good learning skill for me.

Thank you for taking your time and efforts on this.

This issue can be closed i guess.

@idlip
Copy link
Author

idlip commented Mar 18, 2025

Hi @fbergmann

I have a doubt, sorry that I'm novice in systems biology.

I was trying to run genome-scale metabolic model for accessing flux and concentration levels.
But I notice with these models, time-course simulations gives same concentration levels for any days run.

Eg: https://www.ebi.ac.uk/biomodels/MODEL1402200001#Files
or https://www.ebi.ac.uk/biomodels/MODEL1603150001#Files

Maybe I know the reason why it does seem to change in time course?
Am sure I lack understanding on this part.

Edit: Code to reproduce

from basico import *
adipo = load_model("MODEL1402200001_url.xml")
tc = run_time_course(100)
print(tc)
# all values are unchanged

https://colab.research.google.com/drive/1Gi4Py0nfBetiBtAxX6_6pzV9CU57bqLh?usp=sharing

colab notebook for reference

@fbergmann
Copy link
Member

For genome scale models that is entirely expected. Those models mainly define the network structure, meaning what species takes part in what reaction. As compared to ODE based modelling, where for each reaction you will have a mechanistic kinetic law, for genome scale networks you mainly have the model structure. instead of getting information about time trajectories, you can only get information about the steady state behavior.

While the specific model contains some kinetic, they are of the form, that it describes the network structure, with a fixed flux value for each reaction.

For genome scale models I would suggest, that you use another python package for simulation for example cobrapy or cbmpy.

For this specific model, with the initial concentrations of the species all being 0, and the constraints on the reaction (lower bound, upper bound, value) also 0. I don't think you will be able to get any other answer.

@idlip
Copy link
Author

idlip commented Mar 18, 2025

Okay that explains it.
Thank you for providing insights.

As I deep dive I realize the logic. Wish I knew calculus and ODE more.

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