Tellurium Tutorial

Using Tellurium

The combination of libraries in Tellurium allow you to write python scripts that define, simulate, and analyze models. Models are defined using the Antimony syntax, which are loaded for simulation and analysis in libRoadRunner. The roadrunner tutorial is an excellent reference for available functionality.

Tellurium Tutorials YouTube Channel

We have created a Youtube channel called TelluriumTutorials which provide demonstrations of how to use Tellurium.

The following are sample Python scripts that perform such analyses. Additional examples are provided with your installed application. Check the folder Tellurium is installed at or go to Tellurium github.

Simple UniUni reaction that uses first-order mass-action kinetics

import tellurium as te
# Simple UniUni reaction with first-order mass-action kinetics
r = te.loada ('''
     S1 -> S2; k1*S1

     # Initialize values
     S1 = 10; S2 = 0
     k1 = 1

''')

# Carry out a time course simulation results returned in array result.
# Arguments are: time start, time end, number of points
result = r.simulate (0, 10, 100)

# Plot the results
r.plot (result)

Consecutive UniUni reactions using first-order mass-action kinetics

import tellurium as te
# Consecutive UniUni reactions using first-order mass-action kinetics
r = te.loada ('''
    S1 -> S2; k1*S1
    S2 -> S3; k2*S2
    S3 -> S4; k3*S3

    # Initialize values
    S1 = 5; S2 = 0; S3 = 0; S4 = 0;
    k1 = 0.1;  k2 = 0.55; k3 = 0.76
''')

result = r.simulate (0, 20, 50)
r.plot (result)

Setting boundary species in a model

import tellurium as te
# Setting boundary species in a model
r = te.loada ('''
    # The $ character is used to indicate that a particular species is FIXED
    $S1 -> S2; k1*S1
     S2 -> S3; k2*S2 - k3*S3
     S3 -> $S4; Vm*S3/(Km + S3)

    # Initialize values
    S1 = 1.0; S2 = 0; S3 = 0; S4 = 0.0
    k1 = 0.2; k2 = 0.67; k3 = 0.04
    Vm = 5.6; Km = 0.5
''')

result = r.simulate (0, 10, 200)
r.plot (result)

Single gene expressing protein and protein undergoing degradation

import tellurium as te
# Single gene expressing protein and protein undergoing degradation
r = te.loada ('''
      # Reactions: 
      J1:   -> P; Vm*T^4/(K+T^4)
      J2: P ->  ; k1*P; 

      # Species initializations: 
      P = 0;   T = 5; Vm = 10
      K = 0.5; k1 = 4.5;   
''')

result = r.simulate(0, 2, 50)
r.plot (result)

Example of Non-unit Stoichiometries

# Example of Non-unit Stoichiometries
r = te.loada ('''
     S1 + S2 -> 2 S3; k1*S1*S2
        3 S3 -> 4 S4 + 6 S5; k2*S3^3
''')

Computing the Steady State

import tellurium as te
r = te.loada ('''
     $Xo -> S1; k1*Xo - k2*S1
      S1 -> S2; k3*S2
      S2 -> $X1; k4*S2

     Xo = 1;   X1 = 0
     S1 = 0;   S2 = 0
     k1 = 0.1; k2 = 0.56
     k3 = 1.2; k4 = 0.9
''')

# Compute the steady state
r.getSteadyStateValues()

print "S1 =", r.model.S1, "S2 =", r.model.S2

How can I create different wave forms?

import tellurium as te

# Generating different waveforms
r = te.loada ('''
  model waveforms()
     # All waves have the following amplitude and period
     amplitude = 1
     period = 10

     # These events set the 'UpDown' variable to 1 or 0 according to the period.
     UpDown=0
     at sin(2*pi*time/period) >  0, t0=false: UpDown = 1
     at sin(2*pi*time/period) <= 0, t0=false: UpDown = 0

     # Simple Sine wave with y displaced by 3
     SineWave := amplitude/2*sin(2*pi*time/period) + 3

     # Square wave with y displaced by 1.5
     SquareWave := amplitude*UpDown + 1.5

     # Triangle waveform with given period and y displaced by 1
     TriangleWave = 1
     TriangleWave' = amplitude*2*(UpDown - 0.5)/period

     # Saw tooth wave form with given period
     SawTooth = amplitude/2
     SawTooth' = amplitude/period
     at UpDown==0: SawTooth = 0

     # Simple ramp
     Ramp := 0.03*time
  end
''')

r.selections = ['time', 'SineWave', 'SquareWave', 'SawTooth', 'TriangleWave', 'Ramp']
result = r.simulate (0, 90, 500)

r.plot (result)

You can also load SBML models directly from BioModelsDB

r = te.loadSBMLModel("http://www.ebi.ac.uk/biomodels-main/download?mid=BIOMD0000000010")
result = r.simulate(0, 3000, 5000)
r.plot (result)

biomodels