parsemod: Parses a biological model to C code.

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Given as input the reaction rates, stochastic constants and model constants, the function outputs the C code of the underlying ODEs. The system of odes express the macroscopic approximation (ODE) as well as the estimates for the instantaneous mean and covariance of the linear SDE from the LNA approximation.

Usage

1
parsemod(y,rfun,thetas,species,constants=NA)

Arguments

y

The stoichiometry matrix, note that the dimensions are assumed to be: (# Species)*(# Reactions).

rfun

A character vector with each elements expressing the reaction rates.

thetas

A character vector which denotes the stochastic constant names associated with each reaction.

species

A character vector which denotes the species names.

constants

Not supported yet.

Details

The derivation of the ODEs is accomplished with the help of Deriv package and some symbolic algebra routines written in R. The derived ODEs are joined together, i.e. treated as a single system, and are expressed as C code. In particular, they are expressed as a C function of the following form:

1
double * name (double * t, double * y, double * fout, double * vthetas)

Value

Returns a list with the following elements:

ccode

The actual C code as text.

cspecies

A character vector of the species names in the C code and their corresponding model names are given in the names attribute.

cthetas

A character vector of the names of the stochastic constants in the C code and their corresponding model names are given in the names attribute.

Cov

A character vector of the functions names that corresponds the upper triangular matrix (given as the names attribute) of the instantaneous variance-covariance matrix.

Means

A character vector of the functions names that corresponds to the instantaneous means (given as the names attribute).

Orders

A numerical vector indicating the order of each reaction.

Author(s)

Vasileios Giagos

See Also

After parsing you need to compile the model with compmod.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
##Parses the Lotka-Volterra Model.

#Stoichiometry matrix
tt <- matrix(c(1,-1,0,0,1,-1),nrow=2,ncol=3,byrow=TRUE)
#The reaction rates
rfun <- c("con1 * Prey","con2 * Prey * Predator","con3 * Predator")
#Parameters
thetas <- paste("con",1:3,sep="")
#Species
species <- c("Prey","Predator")
## Not run: 
cout <- parsemod(tt,rfun,thetas,species)
## End(Not run)

lnar documentation built on May 2, 2019, 4:51 p.m.