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

Viewing differential equations in SBML report (ODE viewer) #392

Open
DeepaMahm opened this issue Mar 19, 2022 · 6 comments
Open

Viewing differential equations in SBML report (ODE viewer) #392

DeepaMahm opened this issue Mar 19, 2022 · 6 comments
Labels
feature sbml4humans related to webapp and report

Comments

@DeepaMahm
Copy link

Hi @matthiaskoenig,

Could you please let me know if we can view the differential equations in the report that is generated via SBML4HUMANS?
I could view the fluxes in the report but not the differential equations expressed as a function of fluxes.

Thank you,
Deepa

@matthiaskoenig
Copy link
Owner

Hi Deepa,
this is not supported at the moment, but multiple users asked for the functionality.
This will be supported in the next version.
Best Matthias

@DeepaMahm
Copy link
Author

DeepaMahm commented Apr 23, 2022

Hi Matthias,

Could you please let me know if this feature has been added now?

I tried to view the differential equations by importing the file in COPASI.
All the rate expressions are divided by volume (this gives rise to inconsistent units). i.e the RHS of the differential equation is not in amounts (moles/s).

image.

The same rate expression, when viewed in SBML4Humans, doesn't have a volume factor in the denominator.

@matthiaskoenig matthiaskoenig self-assigned this Jun 17, 2022
@matthiaskoenig matthiaskoenig added the sbml4humans related to webapp and report label Jun 17, 2022
@matthiaskoenig matthiaskoenig removed their assignment Jul 15, 2022
@matthiaskoenig matthiaskoenig self-assigned this Nov 3, 2022
@matthiaskoenig matthiaskoenig changed the title Viewing differential equations in SBML report Viewing differential equations in SBML report (ODE viewer) Nov 3, 2022
@lmandl
Copy link

lmandl commented Nov 3, 2022

Hello Matthias,

I would be interested in this feature as well. Do you think this will be implemented in the near future?

Best regards and Thank You
Luis

@DeepaMahm
Copy link
Author

Hello @lmandl ,

I hope the following is useful for you.

"""Print ODEs."""
from pathlib import Path
from typing import Dict

from sbmlutils.console import console
import libsbml


def print_odes(sbmlpath: Path) -> None:
    """Prints ODS in given model.

    Converts reaction to rate rules.
    """
    print(sbmlpath)
    doc = libsbml.readSBMLFromFile(str(sbmlpath))

    # inline function definitions
    props = libsbml.ConversionProperties()
    props.addOption('expandFunctionDefinitions', True)
    doc.convert(props)

    # convert reactions to ODEs
    props = libsbml.ConversionProperties()
    props.addOption('replaceReactions', True)
    doc.convert(props)

    mod = doc.getModel()

    # print list of odes
    odes: Dict[str, str] = {}
    for rule in mod.getListOfRules():
        if not isinstance(rule, libsbml.RateRule):
            continue
        variable_id = rule.getVariable()
        left_side: str = f"d{variable_id}/dt"
        right_side: str = rule.getFormula()
        odes[left_side] = right_side
        # console.print(f"{left_side:10} = {right_side}")

    console.print(odes)


if __name__ == "__main__":

    print_odes('model.xml')

@lmandl
Copy link

lmandl commented Nov 3, 2022

Awesome! Thanks for the quick and great reply.

@matthiaskoenig
Copy link
Owner

matthiaskoenig commented Jun 13, 2023

  • markdown serialization
  • support units
  • accessibility via GUI
  • documentation

@matthiaskoenig matthiaskoenig removed their assignment Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature sbml4humans related to webapp and report
Projects
None yet
Development

No branches or pull requests

3 participants