C API Documentation
RoadRunner C wrappers Library

Introduction

RoadRunner is a SBML compliant high performance and portable simulation engine for systems and synthetic biology. To run a simple SBML model and generate time series data we would write the following code:

If you're building this on Windows Visual Studio, you don't need the first two lines of code and make sure you save this code as a C file not as a CPP file.

#undef __cplusplus
#define STATIC_RRC
#include <stdio.h>
#include <stdlib.h>
#include "rrc_api.h"
#include "rrc_types.h"
#include "rrc_utilities.h"
int main (int argc, char *argv[]) {
RRHandle rrHandle;
RRCDataPtr result;
printf ("Starting Test Program %s\n", argv[0]);
rrHandle = createRRInstance();
if (!loadSBMLFromFile (rrHandle, "feedback.xml")) {
printf ("Failed to load model: %s\n", getLastError ());
getchar ();
exit (0);
}
result = simulateEx (rrHandle, 0, 10, 100);
printf ("Number of rows = %d\n", getRRDataNumRows (result));
printf ("Number of cols = %d\n", getRRDataNumCols (result));
freeRRCData(result);
getchar ();
exit (0);
}
C_DECL_SPEC char *rrcCallConv getLastError(void)
Retrieve the current error string.
C_DECL_SPEC int rrcCallConv freeRRCData(RRCDataPtr handle)
Free the memory associated to a RRCData object.
C_DECL_SPEC int rrcCallConv getRRDataNumCols(RRCDataPtr rrData)
Retrieve the number of columns in the given rrData data (returned form simulate(RRHandle handle))
C_DECL_SPEC int rrcCallConv getRRDataNumRows(RRCDataPtr rrData)
Retrieve the number of rows in the given RoadRunner numerical data (returned from simulate(RRHandle h...
C_DECL_SPEC RRHandle rrcCallConv createRRInstance(void)
Initialize a new roadRunner instance and return a handle to it.
C_DECL_SPEC bool rrcCallConv loadSBMLFromFile(RRHandle handle, const char *fileName)
Load a model from a SBML file.
C_DECL_SPEC RRCDataPtr rrcCallConv simulateEx(RRHandle handle, const double timeStart, const double timeEnd, const int numberOfPoints)
Carry out a time-course simulation based on the given arguments, time start, time end and number of p...
libRoadRunner C wrappers 2012-2013
roadRunner C wrappers 2012

More complex example, using C wrappers:

#undef __cplusplus
#define STATIC_RRC
#include <stdio.h>
#include <stdlib.h>
#include "rrc_api.h"
#include "rrc_types.h"
#include "rrc_utilities.h"
int main (int argc, char *argv[]) {
RRHandle rrHandle;
RRCDataPtr result;
int index;
int col;
int row;
printf ("Starting Test Program %s\n", argv[0]);
rrHandle = createRRInstance();
if (!loadSBML (rrHandle, "feedback.xml")) {
printf ("Error while loading SBML file\n");
printf ("Error message: %s\n", getLastError());
getchar ();
exit (0);
}
result = simulateEx (rrHandle, 0, 10, 10); // start time, end time, and number of points
index = 0;
// Print out column headers... typically time and species.
for (col = 0; col < result->CSize; col++)
{
printf ("%10s", result->ColumnHeaders[index++]);
if (col < result->CSize - 1)
{
printf ("\t");
}
}
printf ("\n");
index = 0;
// Print out the data
for (row = 0; row < result->RSize; row++)
{
for (col = 0; col < result->CSize; col++)
{
printf ("%10f", result->Data[index++]);
if (col < result->CSize -1)
{
printf ("\t");
}
}
printf ("\n");
}
//Cleanup
freeRRCData (result);
freeRRInstance (rrHandle);
getchar ();
exit (0);
}
C_DECL_SPEC bool rrcCallConv freeRRInstance(RRHandle handle)
Free the roadRunner instance.
C_DECL_SPEC bool rrcCallConv loadSBML(RRHandle handle, const char *sbml)
Load a model from an SBML string.

Would create output as shown below:

Starting Test Program: <File path Here>
Notice: Creating C based model generator using ..\compilers\tcc\tcc.exe compiler.
time [S1] [S2] [S3] [S4]
0.000000 0.000000 0.000000 0.000000 0.000000
1.111111 3.295975 1.677255 1.121418 1.074708
2.222222 0.971810 1.658970 1.841065 2.192728
3.333333 0.137340 0.501854 1.295138 2.444883
4.444445 0.141470 0.200937 0.549172 1.505662
5.555556 1.831017 1.317792 1.129982 1.351300
6.666667 0.306310 0.775477 1.304950 1.952076
7.777778 0.193459 0.268986 0.628542 1.483161
8.888889 1.566864 1.219950 1.105718 1.370199
10.000000 0.269437 0.678127 1.199353 1.868247

Installation

Installation documentation is provided at libRoadRunner.org.

License

Copyright (C) 2012-2021 University of Washington, Seattle, WA, USA

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;