Coder Social home page Coder Social logo

paulflang / sbmlinterface.jl Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 2.0 310 KB

Interface between the Systems Biology Markup Language and Julia

Home Page: https://paulflang.github.io/SbmlInterface.jl/dev/

License: MIT License

Julia 100.00%
systems-biology modelling sbml sbml-model julia ode differential-equations ordinary-differential-equations

sbmlinterface.jl's Introduction

SbmlInterface

Dev Build Status Coverage

⚠️ SbmlInterface will soon be deprecated. Please use SBMLToolkit.jl for dynamic SBML models.

SbmlInterface.jl is a lightweight tool to import models specified in the Systems Biology Markup Language (SBML) into Julia. More specifically, SbmlInterface.jl uses the Python libsbml library to extract ordinary differential equations, initial conditions and parameter values from SBML files. Events and constraints and several other SBML components are not yet supported. There are several ways to specify the same model in SBML and SbmlInterface. Please help us improving SbmlInterface.jl by creating a GitHub issue if you experience errors when converting your SBML model to Julia.

Installation

SbmlInterface.jl is not yet available on the Julia package managing system. To install SbmlInterface please first clone this repository:

$ git clone https://github.com/paulflang/SbmlInterface.jl.git

As SbmlInterface.jl relies on the Python libsbml library, please make sure your version of Julia can communicate with a Python environment were libsbml is installed. Please follow the PyCall installation instructions or:

  • create a Python virtual environment in the SbmlInterface.jl directory and activate it:
    $ cd SbmlInterface.jl/
    $ python3 -m venv venv
    $ source venv/bin/activate
    
  • install python-libsbml to the python environment:
    $ pip install python-libsbml
    
  • start the Julia REPL:
    $ julia
    
  • and activate the Julia virtual environment:
    julia> ]
    (v1.5) pkg> activate .

When using SbmlInterface Julia will be able to communicate with the python virtual environment where you have installed libsbml.

Tutorial

SBML models can be simulated with the following steps:

  using SbmlInterface

  model = getmodel("mymodel.sbml")
  p = getparameters(model)
  u0 = getinitialconditions(model)
  rxs = getreactions(model)
  rs  = ReactionSystem(rxs, t, [item.first for item in u0], [item.first for item in p])
  odesys = convert(ODESystem, rs)
  prob = ODEProblem(odesys,u0,(0.0,10.0),p)
  sol = solve(prob,Tsit5())

If you want to create an ODESystem, ODEProblem or solution Array directly from an SBML file use sbml2odesystem("mymodel.sbml"), sbml2odeproblem("mymodel.sbml",(tstart,tend)) and simulatesbml("mymodel.sbml",(tstart,tend)), respectively.

License

The package is released under the MIT license.

Development team

This package was developed by Paul F. Lang at the University of Oxford, UK and Anand Jain at the University of Chicago, USA.

Questions and comments

Please contact Paul F. Lang or Anand Jain with any questions or comments.

sbmlinterface.jl's People

Contributors

anandijain avatar dlill avatar github-actions[bot] avatar paulflang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

anandijain dlill

sbmlinterface.jl's Issues

Need to avoid conflicting identifier `t`

julia> using SbmlInterface
WARNING: using SbmlInterface.t in module Main conflicts with an existing identifier.

I'm actually not sure if this is a big deal, so feel free to close.

using SbmlInterface functions with SciMLBase.tmap

I was getting limited by speed testing on the sbml test suite so I wanted to multithread.

SciMLBase has a threaded map here. MWE here.

This is the nefarious line.

SciMLBase.tmap(getmodel, all_files)

This could be a PyCall, a SciMLBase, or an SbmlInterface issue. I'm opening it here for @paulflang to weigh in.
We can move it later, just want ur eyes since you know PyCall better than me.

trace

signal (11): Segmentation fault
in expression starting at REPL[14]:1

signal (11): Segmentation fault
in expression starting at REPL[14]:1
unknown function (ip: 0x7fae85834a10)
unknown function (ip: 0x7fae857ec717)
unknown function (ip: 0x7fae85834a10)
unknown function (ip: 0x7fae857ec717)

signal (11): Segmentation fault
in expression starting at REPL[14]:1
unknown function (ip: 0x7fae85834a10)
unknown function (ip: 0x7fae857ec717)

signal (11): Segmentation fault
in expression starting at REPL[14]:1
unknown function (ip: 0x7fae85834a10)
unknown function (ip: 0x7fae857ec717)

signal (11): Segmentation fault

signal (sion starting at REPL[14]:1

signal (11): Segmentation fault
in expression starting at REPL[14]:1
unknown function (ip: 0x7fae85834a10)
unknown function (ip: 0x7fae85834a10)
unknown function (ip: 0x7fae857ec717)
unknown function (ip: 0x7fae857ec717)

signal (11): Segmentation fault
in expression starting at REPL[14]:1
unknown function (ip: 0x7fae85834a10)
unknown function (ip: 0x7fae857ec717)
SWIG_Python_GetSwigThis at /usr/local/lib/python3.8/dist-packages/libsbml/_libsbml.cpython-38-x86_64-linux-gnu.so (unknown line)
SWIG_Python_GetSwigThis at /usr/local/lib/python3.8/dist-packages/libsbml/_libsbml.cpython-38-x86_64-linux-gnu.so (unknown line)

signal (11): Segmentation fault
in expression starting at REPL[14]:1
unknown function (ip: 0x7fae85834a10)
unknown function (ip: 0x7fae857ec717)
SWIG_Python_GetSwigThis at /usr/local/lib/python3.8/dist-packages/libsbml/_libsbml.cpython-38-x86_64-linux-gnu.so (unknown line)
SWIG_Python_GetSwigThis at /usr/local/lib/python3.8/dist-packages/libsbml/_libsbml.cpython-38-x86_64-linux-gnu.so (unknown line)
SWIG_Python_GetSwigThis at /usr/local/lib/python3.8/dist-packages/libsbml/_libsbml.cpython-38-x86_64-linux-gnu.so (unknown line)
SWIG_Python_ConvertPtrAndOwn.constprop.3403 at /usr/local/lib/python3.8/dist-packages/libsbml/_libsbml.cpython-38-x86_64-linux-gnu.so (unknown line)
SWIG_Python_ConvertPtrAndOwn.constprop.3403 at /usr/local/lib/python3.8/dist-packages/libsbml/_libsbml.cpython-38-x86_64-linux-gnu.so (unknown line)
SWIG_Python_GetSwigThis at /usr/local/lib/python3.8/dist-packages/libsbml/_libsbml.cpython-38-x86_64-linux-gnu.so (unknown line)
SWIG_Python_GetSwigThis at /usr/local/lib/python3.8/dist-packages/libsbml/_libsbml.cpython-38-x86_64-linux-gnu.so (unknown line)
SWIG_Python_GetSwigThis at /usr/local/lib/python3.8/dist-packages/libsbml/_libsbml.cpython-38-x86_64-linux-gnu.so (unknown line)
SWIG_Python_ConvertPtrAndOwn.constprop.3403 at /usr/local/lib/python3.8/dist-packages/libsbml/_libsbml.cpython-38-x86_64-linux-gnu.so (unknown line)
SWIG_Python_ConvertPtrAndOwn.constprop.3403 at /usr/local/lib/python3.8/dist-packages/libsbml/_libsbml.cpython-38-x86_64-linux-gnu.so (unknown line)
SWIG_Python_ConvertPtrAndOwn.constprop.3403 at /usr/local/lib/python3.8/dist-packages/libsbml/_libsbml.cpython-38-x86_64-linux-gnu.so (unknown line)
SWIG_Python_ConvertPtrAndOwn.constprop.3403 at /usr/local/lib/python3.8/dist-packages/libsbml/_libsbml.cpython-38-x86_64-linux-gnu.so (unknown line)
SWIG_Python_ConvertPtrAndOwn.constprop.3403 at /usr/local/lib/python3.8/dist-packages/libsbml/_libsbml.cpython-38-x86_64-linux-gnu.so (unknown line)
_wrap_SBMLDocument_getNumErrors at /usr/local/lib/python3.8/dist-packages/libsbml/_libsbml.cpython-38-x86_64-linux-gnu.so (unknown line)
_wrap_SBMLDocument_getNumErrors at /usr/local/lib/python3.8/dist-packages/libsbml/_libsbml.cpython-38-x86_64-linux-gnu.so (unknown line)
unknown function (ip: 0x7fae85850356)
_PyEval_EvalFrameDefault at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0 (unknown line)
_PyEval_EvalCodeWithName at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0 (unknown line)
_PyFunction_Vectorcall at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0 (unknown line)
unknown function (ip: 0x7fae858509e6)
PyVectorcall_Call at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0 (unknown line)
macro expansion at /home/sippycups/.julia/packages/PyCall/tqyST/src/exception.jl:95 [inlined]
nknown function (ip: 0x7fae85850356)
#109 at /home/sippycups/.julia/packages/PyCall/tqyST/src/pyfncall.jl:43 [inlined]
disable_sigint at ./c.jl:458 [inlined]
__pycall! at /home/sippycups/.julia/packages/PyCall/tqyST/src/pyfncall.jl:42 [inlined]
_pycall! at /home/sippycups/.julia/packages/PyCall/tqyST/src/pyfncall.jl:29
_pycall! at /home/sippycups/.julia/packages/PyCall/tqyST/src/pyfncall.jl:11 [inlined]
#_#116 at /home/sippycups/.julia/packages/PyCall/tqyST/src/pyfncall.jl:86 [inlined]
PyObject at /home/sippycups/.julia/packages/PyCall/tqyST/src/pyfncall.jl:86
unknown function (ip: 0x7faf02cd1f26)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2238 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2420
getmodel at /home/sippycups/.julia/dev/SbmlInterface/src/sbml2modelingtoolkit.jl:116
macro expansion at /home/sippycups/.julia/packages/SciMLBase/eghDQ/src/ensemble/basic_ensemble_solve.jl:221 [inlined]
#446#threadsfor_fun at ./threadingconstructs.jl:81
#446#threadsfor_fun at ./threadingconstructs.jl:48
unknown function (ip: 0x7faf02cd01ac)
_PyEval_EvalFrameDefault at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0 (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2238 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2420
_PyEval_EvalCodeWithName at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0 (unknown line)
_PyFunction_Vectorcall at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0 (unknown line)
unknown function (ip: 0x7fae858509e6)
PyVectorcall_Call at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0 (unknown line)
macro expansion at /home/sippycups/.julia/packages/PyCall/tqyST/src/exception.jl:95 [inlined]
#109 at /home/sippycups/.julia/packages/PyCall/tqyST/src/pyfncall.jl:43 [inlined]
disable_sigint at ./c.jl:458 [inlined]
__pycall! at /home/sippycups/.julia/packages/PyCall/tqyST/src/pyfncall.jl:42 [inlined]
_pycall! at /home/sippycups/.julia/packages/PyCall/tqyST/src/pyfncall.jl:29
_pycall! at /home/sippycups/.julia/packages/PyCall/tqyST/src/pyfncall.jl:11 [inlined]
#_#116 at /home/sippycups/.julia/packages/PyCall/tqyST/src/pyfncall.jl:86 [inlined]
PyObject at /home/sippycups/.julia/packages/PyCall/tqyST/src/pyfncall.jl:86
unknown function (ip: 0x7faf02cd1f26)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2238 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2420
getmodel at /home/sippycups/.julia/dev/SbmlInterface/src/sbml2modelingtoolkit.jl:116
macro expansion at /home/sippycups/.julia/packages/SciMLBase/eghDQ/src/ensemble/basic_ensemble_solve.jl:221 [inlined]
#446#threadsfor_fun at ./threadingconstructs.jl:81
#446#threadsfor_fun at ./threadingconstructs.jl:48
unknown function (ip: 0x7faf02cd01ac)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2238 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2420
_wrap_SBMLDocument_getErrorLog at /usr/local/lib/python3.8/dist-packages/libsbml/_libsbml.cpython-38-x86_64-linux-gnu.so (unknown line)
unknown function (ip: 0x7fae85850356)
_PyEval_EvalFrameDefault at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0 (unknown line)
_PyEval_EvalCodeWithName at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0 (unknown line)
_PyFunction_Vectorcall at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0 (unknown line)
unknown function (ip: 0x7fae85850aea)
PyVectorcall_Call at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0 (unknown line)
macro expansion at /home/sippycups/.julia/packages/PyCall/tqyST/src/exception.jl:95 [inlined]
#109 at /home/sippycups/.julia/packages/PyCall/tqyST/src/pyfncall.jl:43 [inlined]
disable_sigint at ./c.jl:458 [inlined]
__pycall! at /home/sippycups/.julia/packages/PyCall/tqyST/src/pyfncall.jl:42 [inlined]
_pycall! at /home/sippycups/.julia/packages/PyCall/tqyST/src/pyfncall.jl:29
_pycall! at /home/sippycups/.julia/packages/PyCall/tqyST/src/pyfncall.jl:11 [inlined]
SWIG_Python_ConvertPtrAndOwn.constprop.3403 at l/tqyST/src/pyfncall.jl:86 [inlined]
SWIG_Python_ConvertPtrAndOwn.constprop.3403 at /usr/local/lib/python3.8/dist-packages/libsbml/_libsbml.cpython-38-x86_64-linux-gnu.so (unknown line)
PyObject at /home/sippycups/.julia/packages/PyCall/tqyST/src/pyfncall.jl:86
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2238 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2420
getmodel at /home/sippycups/.julia/dev/SbmlInterface/src/sbml2modelingtoolkit.jl:122
macro expansion at /home/sippycups/.julia/packages/SciMLBase/eghDQ/src/ensemble/basic_ensemble_solve.jl:221 [inlined]
#446#threadsfor_fun at ./threadingconstructs.jl:81
#446#threadsfor_fun at ./threadingconstructs.jl:48
unknown function (ip: 0x7faf02cd01ac)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2238 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2420
_wrap_SBMLDocument_getNumErrors at /usr/local/lib/python3.8/dist-packages/libsbml/_libsbml.cpython-38-x86_64-linux-gnu.so (unknown line)
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1703 [inlined]
start_task at /buildworker/worker/package_linux64/build/src/task.c:839
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1703 [inlined]
start_task at /buildworker/worker/package_linux64/build/src/task.c:839
unknown function (ip: 0x7fae85850356)
_PyEval_EvalFrameDefault at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0 (unknown line)
unknown function (ip: (nil))
Allocations: 19003754 (Pool: 18999326; Big: 4428); GC: 19
fish: '/home/sippycups/julia-1.6.0-rc1…' terminated by signal SIGSEGV (Address boundary error)

Testing SbmlInterface on the sbml test suite.

Hello, thanks for this. This is really cool.

You might be aware of the sbml test suite, which would be great to test how much coverage this package has in converting models to MTK.

This is my experience so far is contained in this gist.

It should be a copy pasteable mwe (modulo file paths).

I basically just cloned the suite, grabbed all the xmls and ran it thru your functions, catching errors along the way.

Assignment rules are not implemented. is the error I got the most, and prevented all of the models in the suite from working with sbml2odesystem.

I'm interested in getting this package up to speed so let me know what I can do, or good places to start!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.