Code Monkey home page Code Monkey logo

sys-bio / roadrunner Goto Github PK

View Code? Open in Web Editor NEW

This project forked from andysomogyi/sbmlsolver

37.0 17.0 24.0 278.83 MB

libRoadRunner: A high-performance SBML simulator

Home Page: http://libroadrunner.org/

License: Other

CMake 0.80% C++ 67.97% Python 3.62% Inno Setup 0.07% Shell 0.07% C 1.07% Pascal 0.21% Java 0.02% Batchfile 0.01% SWIG 0.60% Mathematica 13.18% M 0.05% AMPL 0.03% Dockerfile 0.02% Starlark 0.09% HTML 10.13% CSS 0.29% TeX 0.08% Makefile 0.02% JavaScript 1.68%
sbml sbml-simulation

roadrunner's Introduction

libRoadRunner

GitHub version Build Status Documentation Status PyPI version

Licence PyPI - Downloads Funding Funding

Summary

libRoadRunner is a C/C++ library that supports simulation of SBML based models. It uses LLVM to generate extremely high performance code and is the fastest SBML-based simulator currently available (ref). Its main purpose is for use as a reusable library that can be hosted by other applications, particularly on large compute clusters for doing parameter optimization where performance is critical. It also has a set of python bindings that allow it to be easily used from python.

We provide C/C++, Python and Julia bindings.

Documentation

Full Documentation

Local Documentation (May be used if above link is failing.)

C API Documention

Installation

Binaries for Windows, MacOS (including universal binaries for the M1 processor), and Linux

Python wheels are available at the above binaries link, and can also be installed via pip:

pip install libroadrunner

Google Colab

libroadrunner can be used entirely in a browser using Google Colab. Ideally, it will work with the following steps (updated May 2023)

  1. run a cell with !apt-get install libncurses5
  2. run a cell with !pip install libroadrunner
  3. (Vert important) Restart the runtime (From the menu: 'Runtime / Restart runtime')
  4. Test by running import roadrunner

The Python version behind Colab is reasonably stable but can change. This issue to changes in how colab handles packages. we try to keep abreast of changes at colab.

Example Python usage

Once installed in Python (using pip or using the wheels directly), the following simple example script should demonstrate the basics of a roadrunner simulation:

import roadrunner
rr = roadrunner.RoadRunner("https://www.ebi.ac.uk/biomodels/model/download/BIOMD0000000010.2?filename=BIOMD0000000010_url.xml")
results = rr.simulate(0, 2000, 200)
rr.plot()
print(results)

This simple script downloads BioModels 10 (the Kholodenko model of MAPK oscillation) and runs a simulation for 2000 seconds, storing the results in results. If your system is set up to display figures, it will display a plot of the simulation, then print the numerical values obtained.

Dependencies

All libRoadRunner binaries are self-contained, and should include all libraries it depends on. When building libRoadRunner from source, its dependencies may either be downloaded en masse from the libroadrunner-deps repository, may be obtained directly from their respective sources, or the libraries may be installed directly on your operating system. Compilation requires a C++17 compiler.

The one exception to the above is that the libRoadRunner binaries depend on the 'ncurses' library on linux.

Copyright

Copyright 2013-2022

E. T. Somogyi 1, J. K. Medley 3, M. T. Karlsson 2, M. Swat 1, M. Galdzicki 3, K. Choi 3, W. Copeland 3, L. Smith 3, C. Welsh 3 and H. M. Sauro 3

  1. Biocomplexity Institute, Indiana University, Simon Hall MSB1, Bloomington, IN 47405
  2. Dune Scientific, 10522 Lake City Way NE, #302 Seattle WA
  3. Department of Bioengineering, University of Washington, Seattle, WA, 98195

The current (2021-present) developer is Lucian Smith.

Contributing

Contributors may submit pull requests at any time, and are asked to follow some general contribution guidelines. Bug requests and feature suggestions are also welcomed on the issues page.

libRoadRunner supports the following features:

  • Time Dependent Simulation (with optional conservation law reduction) using CVODE
  • Supports SBML Level 2 to 3 but currently excludes algebraic rules and delay differential equations
  • Uses latest libSBML distribution
  • Defaults to LLVM code generation on the backend, resulting is very fast simulation times
  • Optional generation of model C code and linking at run-time
  • Add plugins, distribution comes with Levenberg-Marquardt optimizer plugin
  • Compute steady state
  • Metabolic Control Analysis
  • Frequency Domain Analysis
  • Access to:
    • Eigenvalues and Eigenvectors
    • Jacobian, full and reduced
    • Structural Matrices of the stoichiometry matrix

Availability

RoadRunner is licensed for free as an open source programmatic library for use in other applications and as a standalone command line driven application. Its C++ API, C API, and Python APIs have comprehensive documentation. On Windows, OS X, and Linux binary files can be downloaded from the Releases page, and the Python bindings can additionally be downloaded via pip.

Docker images

Currently we have a manylinux2014 build docker image. The base provides the environment you need to be able to build roadrunner yourself on manylinux2014 (centos 8).

To get the base image:

docker pull sysbiouw/roadrunner-manylinux2014-base:llvm-13.x

Docker build scripts can be found under the docker directory from the roadrunner root directory.

We can also build roadrunner in alternative docker environments (ubuntu etc.) on request.

Citing

If you use RoadRunner in your research, we would appreciate following citations in any works you publish:

Ciaran Welsh, Jin Xu, Lucian Smith, Matthias König, Kiri Choi, Herbert M Sauro, libRoadRunner 2.0: a high performance SBML simulation and analysis library, Bioinformatics, Volume 39, Issue 1, January 2023, btac770, https://doi.org/10.1093/bioinformatics/btac770

Endre T. Somogyi, Jean-Marie Bouteiller, James A. Glazier, Matthias König, J. Kyle Medley, Maciej H. Swat, Herbert M. Sauro, libRoadRunner: a high performance SBML simulation and analysis library, Bioinformatics, Volume 31, Issue 20, 15 October 2015, Pages 3315–3321, https://doi.org/10.1093/bioinformatics/btv363

Acknowledgements

This work is funded by NIGMS grant: GM081070

License

Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS-IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

In plain english this means:

You CAN freely download and use this software, in whole or in part, for personal, company internal, or commercial purposes;

You CAN use the software in packages or distributions that you create.

You SHOULD include a copy of the license in any redistribution you may make;

You are NOT required include the source of software, or of any modifications you may have made to it, in any redistribution you may assemble that includes it.

YOU CANNOT: redistribute any piece of this software without proper attribution;

libRoadRunner logo

The libroadrunner logo is an adaptation of the image originally posted to Flickr by El Brujo+ at http://flickr.com/photos/11039104@N08/2954808342. It was reviewed on 9 August 2009 by the FlickreviewR robot and was confirmed to be licensed under the terms of the cc-by-sa-2.0.

roadrunner's People

Contributors

0u812 avatar adelhpour avatar alexdarling avatar andrewbriand avatar andrewhu-uw avatar andysomogyi avatar basie12 avatar benjaminrodenberg avatar ciaranwelsh avatar crvineeth97 avatar debashish05 avatar evilnose avatar hsauro avatar katekaseth avatar luciansmith avatar matthiaskoenig avatar mgaldzic avatar penavon avatar samuels342 avatar setcover avatar ssandrews avatar tottekarlsson avatar wcopeland avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

roadrunner's Issues

getTempDir is broken

Tried the following:

  • Added TEMP_DIR_PATH=/tmp to my config file

Result: No effect:

$ rr ... 2>&1 | grep -i temp
Debug: Temp data folder: /home/jkm/devel/install/roadrunner/bin
Debug: rr::RoadRunner::RoadRunner(const string &, const string &, const string &)compiler: GPUSIM, tempDir:/home/jkm/devel/install/roadrunner/bin, supportCodeDir: 
Debug: getTempDir(): /home/jkm/devel/install/roadrunner/bin/
Debug: getTempDir(): /home/jkm/devel/install/roadrunner/bin/
  • Passed -u to the rr exe (this should be the default behavior IMO)

Result: Sort of recognized but not used:

$ rr -u ... 2>&1 | grep -i temp
Debug: Temp data folder: /tmp
Debug: rr::RoadRunner::RoadRunner(const string &, const string &, const string &)compiler: GPUSIM, tempDir:/tmp, supportCodeDir: 
Debug: getTempDir(): /home/jkm/devel/install/roadrunner/bin/
Debug: getTempDir(): /home/jkm/devel/install/roadrunner/bin/
  • Passed -t /tmp to rr exe

Result: same as above

Insert, don't copy additionalEvents into firedEvents

Line 1119 in rrCompiledExecutableModel.cpp:
std::copy (additionalEvents.begin(), additionalEvents.end(), firedEvents.end());

will crash in some situations on Windows, such as when running model 952. It needs to change to:

            firedEvents.insert(firedEvents.end(), additionalEvents.begin(), additionalEvents.end());

No tr1 on Mavericks

So I was trying to build roadrunner on OSX Mavericks. Apparently the tr1 headers no longer have the tr1 prefix, even in non-c++11 mode (e.g. tr1/memory -> memory). Rather than add even more #ifdefs to each site where the headers are included, I suggest making proxy headers and including those instead. Example: replace

#include <tr1/unordered_map>

with

#include <rr_unordered_map>

which contains:

// usual headers & guards...
#if __APPLE__
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 // is Mavericks
#include <unordered_map>
#else
#include <tr1/unordered_map>
#endif // OSX ver
#endif // Apple

// additional #ifdef zoo as necessary

I could implement this fix if desired.

Ref: https://code.google.com/p/alembic/issues/detail?id=322

BUILD_PYTHON ignored

Even if you uncheck 'BUILD_PYTHON' in CMake, it still tries to build the python bindings.

rr.model.getConservedMoietyValues() bug

rr.model.getConservedMoietyValues() returns empty for models with conserved moieties. Try this model.

model = '''
J1: A -> B; k1_A - k2_B;
J2: B -> C; k3_B - k4_C;

k1 = 0.1; k2 = 0.02;
k3 = 0.3; k4 = 0.04;
A = 10; B = 0; C = 0;
'''

rr = te.loadAntimonyModel (model)

Properly flatten and simulate 'comp' tests

The models in the test suite that use hierarchical model composition will run in roadrunner if they are flattened, which can happen when importing the model. The model will need to know its filename at that point, so that external model definitions can be read in.

NOTE: libsbml provides functions on a document that will say whether the comp namespace is enabled, and can validate it, etc. These should be used in lieu of regexp tests for the namespace.

Bug in getCurrentSBML()

Run this script:

import tellurium as te

model = '''
S1 -> S2; k1_S1;
S2 -> S3; k2_S2;
S1 = 10; k1 = 0.1; k2 = 0.2;
'''
rr = te.loadAntimonyModel (model)

Save the SBML

str = rr.getCurrentSBML()

and you'll get:

return _roadrunner.RoadRunner_getCurrentSBML(self)

RuntimeError: Unknown exception

Bug rr.model.getStoichiometryMatrix()

Bug rr.model.getStoichiometryMatrix(), returns the unordered matrix for models with moiety cycles and moiety conservation is on.

model = '''
J1: A -> B; k1_A - k2_B;
J2: B -> C; k3_B - k4_C;

k1 = 0.1; k2 = 0.02;
k3 = 0.3; k4 = 0.04;
A = 10; B = 0; C = 0;
'''

rr = te.loadAntimonyModel (model)
print rr.getFullStoichiometryMatrix()

Skipped tests in python testing

A variety of tests were commented out of the python testing module (roadrunner\wrappers\Python\roadrunner\testing\tester.py, line 916 and onward) because roadrunner changed its interface. If commented back in, those tests fail due to syntax errors. They need to be re-instated.

[CLOSED] Compartmental systems with moiety conservation on given incorrect results

Issue by hsauro
Tuesday Jul 08, 2014 at 23:29 GMT
Originally opened as https://github.com/AndySomogyi/roadrunner-backup/issues/8


Compartmental systems with moiety conservation on given incorrect results. this is most likely due to the fact that the conservation laws are computed using concentrations rather than amounts. eg when computing

S2 = T - S1

The units for T and S1 must be amounts not concentrations. Only amounts are conserved.

Add Level, Version argument to getSBML

Request for feature in the next release. getSBML currently returns Level 3 SBML. However users may require Level 2 in order to run models on older software. Please add an optional argument to getSBML() that specifies the Level and Version for the SBML to be returned. By default getSBML() can return the latest level supported.

Note this change will also need to be added to the C API.

Warning messages about unused variables

There are a variety of places in the code that warn about unused variables, where lines like:

catch(const std::exception& e)

can be changed to

catch(const std::exception&)

when 'e' is never used. Here are the warnings:

2>....\source\rrRoadRunner.cpp(2593): warning C4101: 'e' : unreferenced local variable

4>......\wrappers\C\rrc_api.cpp(1822): warning C4101: 'e' : unreferenced local variable
4>......\wrappers\C\rrc_api.cpp(1835): warning C4101: 'e' : unreferenced local variable
4>......\wrappers\C\rrc_api.cpp(1849): warning C4101: 'e' : unreferenced local variable
4>......\wrappers\C\rrc_api.cpp(1860): warning C4101: 'e' : unreferenced local variable
4>......\wrappers\C\rrc_api.cpp(1874): warning C4101: 'e' : unreferenced local variable
4>......\wrappers\C\rrc_api.cpp(1886): warning C4101: 'e' : unreferenced local variable
4>......\wrappers\C\rrc_api.cpp(1916): warning C4101: 'e' : unreferenced local variable
4>......\wrappers\C\rrc_api.cpp(1948): warning C4101: 'e' : unreferenced local variable

JIT is gone in LLVM 3.6

Must use MCJIT. A sampling of compiler errors:

[  1%] Building CXX object source/CMakeFiles/roadrunner.dir/llvm/ASTNodeCodeGen.cpp.o
In file included from /home/poltergeist/home/devel/src/roadrunner/source/llvm/ASTNodeCodeGen.cpp:13:
In file included from /home/poltergeist/home/devel/src/roadrunner/source/llvm/ASTNodeCodeGen.h:13:
/home/poltergeist/home/devel/src/roadrunner/source/llvm/LLVMIncludes.h:73:10: fatal error: 'llvm/ExecutionEngine/JIT.h' file not found
#include <llvm/ExecutionEngine/JIT.h>

Let us not support Python 2. 'Tis a silly platform.

So I found the cause of the problems Stan and I were running into whenever we tried to use the Python wrapper on arm. It turns out that Python 2 breaks, you know, like basically everything. Anyway I managed to get it working using Python 3 and ctypes. Verified using my perennial decay model.

My purposes for reporting this issue are twofold: to inform the team that IMHO we really should be planning on dropping Python 2 at some point in the future, and to document it to save someone else the trouble of discovering it the hard way. Something like "beware the prehistoric snake" would be a good admonition.

Btw can someone add me as a contrib so I can label these things? This is more of a long-term feature request / enhancement.

Eigenvalues for reducable Jacobian matrices

In a model with a reducable Jacobian matrix such as a simple one with two reactions; S1->S2 and S2->S1, the full Jacobian is 2x2 and the reduced Jacobian is 1x1. This means that there are two potential Eigenvalue matrices; one for the full Jacobian (which will have a row that is '0 0'), and one for the reduced Jacobian (which will have only one row).

However, there does not seem to be a way to get the 'full' Eigenvalue matrix out of roadrunner, merely the reduced one. Furthermore, if you request the Eigenvalue for S2 ("eigen(S2)"), you get 'NaN', instead of '0 0'.

The Copasi API has a way to view either eigenvalue matrix, though I don't know what the underlying API calls are. I also don't know what Copasi would return for 'the eigenvalue of S2' (or even if this is possible), but it does seem reasonable that if a user requests it, they should get '0' instead of 'NaN'.

Small issues in source/llvm_testing/main.cpp

in 'jacobian_test', if the number of arguments is wrong (line 173), the routine should return -1 or a similar error code.

Also, there are a few typos: 'jabobian' -> 'jacobian' in the strings.

References to empty vectors

Visual Studio complains if you take a reference to the first element of an empty vector, if you're compiling in debug mode.

The following lines need to be fixed to accommodate this:

line 1905-6 of LLVMExecutableModel.cpp
unsigned char *p1 = &prevEventState[0];
unsigned char *p2 = &currEventStatus[0];

to
unsigned char *p1 = (prevEventState.size() ==0 ? NULL : &prevEventState[0]);
unsigned char *p2 = (currEventStatus.size()==0 ? NULL : &currEventStatus[0]);

line 1934-6:
getEventTriggers(prevEventState.size(), 0, &prevEventState[0]);

unsigned char *p1 = &prevEventState[0];
unsigned char *p2 = &currEventStatus[0];

to

getEventTriggers(prevEventState.size(), 0, (prevEventState.size()==0 ? NULL : &prevEventState[0]));

unsigned char *p1 = (prevEventState.size() ==0 ? NULL : &prevEventState[0]);
unsigned char *p2 = (currEventStatus.size()==0 ? NULL : &currEventStatus[0]);

Line 117-9 of rrSparse.cpp:
memcpy(mat->rowptr, &mrowptr[0], (mat->m+1)_sizeof(unsigned));
memcpy(mat->colidx, &mcolidx[0], nnz_sizeof(unsigned));
memcpy(mat->values, &mvalues[0], nnz*sizeof(double));

to

memcpy(mat->rowptr, &mrowptr[0], (mat->m+1)*sizeof(unsigned));
if (nnz) {
  memcpy(mat->colidx, &mcolidx[0], nnz*sizeof(unsigned));
  memcpy(mat->values, &mvalues[0], nnz*sizeof(double));
}

line 272 of rrCompiledExecutableModel.cpp
getRateRuleValues(&dTemp[0]);

to
getRateRuleValues(mData.numRateRules==0 ? NULL : &dTemp[0]);

line 644-6
vector currentState(getStateVector(0), 0.0);
getStateVector(&currentState[0]);
cevalEvents(&mData, timeIn, &currentState[0]);

to

    int sv = getStateVector(0);
    vector<double> currentState(sv, 0.0);
    getStateVector(sv==0 ? NULL : &currentState[0]);
    cevalEvents(&mData, timeIn, sv==0 ? NULL : &currentState[0]);

line 614-6:
vector currentState(getStateVector(0), 0.0);
getStateVector(&currentState[0]);
cevalModel(&mData, timein, &currentState[0]);

to
int sv = getStateVector(0);
vector currentState(sv, 0.0);
getStateVector(sv==0 ? NULL : &currentState[0]);
cevalModel(&mData, timein, sv==0 ? NULL : &currentState[0]);

line 419 of CVODEIntegrator.cpp
mModel->getEventTriggers(initialEventStatus.size(), 0, &initialEventStatus[0]);

to

mModel->getEventTriggers(initialEventStatus.size(), 0, (initialEventStatus.size()==0 ? NULL : &initialEventStatus[0]));

line 427:
mModel->applyEvents(timeEnd, &previousEventStatus[0], stateVector, stateVector);

to

mModel->applyEvents(timeEnd, (previousEventStatus.size()==0 ? NULL : &previousEventStatus[0]), stateVector, stateVector);

line 227:
mModel->getEventTriggers(eventStatus.size(), 0, &eventStatus[0]);

to

    mModel->getEventTriggers(eventStatus.size(), 0, (eventStatus.size()==0 ? NULL : &eventStatus[0]));

License inconsistency

I noticed that we have conflicting statements about how the code is licensed. In most of the files we have Apache 2.0, but the doxygen main page (generated from rrRoadRunner.h) has BSD. We do want Apache 2, correct? I can fix this, I just need confirmation from Herbert.

RoadRunner: getTempDir required in tests but is deprecated

Found this when trying to execute run_test_suite. Causes the entire test suite to fail in CORE_TESTS: LOGGING. Problem is that enableLoggingToFile (rrc_logging_api.cpp) tries to get temp folder. Result is "not used/RoadRunner.log" after path join. Throws Poco FileNotFoundException.

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.