Tellurium Modeling Platform

repository·develop·Indexed 40 days ago

https://github.com/sys-bio/tellurium

An SBML-compliant Python modeling platform for biochemical reaction systems. It features a high-performance simulation engine (libroadrunner) and supports model description languages such as Antimony and PhrasedML, as well as Combine Archive formats like OMEX and SEDX.

Tokens
57.2K
Snippets
205
Records
261
Agent score
100%

What's inside Tellurium

  1. Explore the tellurium.notebooks package submodules

    develop

    The tellurium.notebooks package provides specialized tools designed for use within interactive notebook environments (like Jupyter). It is organized into several functional submodules:

    • tellurium.notebooks.notebooktools: General utility tools for notebook interaction.
    • tellurium.notebooks.ontologysearch: Tools for searching biological ontologies.
    • tellurium.notebooks.parameterslider: Interactive UI components (sliders) for adjusting model parameters dynamically.
    • tellurium.notebooks.speciessearch: Tools for searching biological species information.
  2. Explore the tellurium package structure

    develop

    The tellurium package is organized into several specialized subpackages for systems biology modeling and simulation. Depending on your task, you may need to import from one of the following:

    • tellurium.analysis: Tools for analyzing model behavior.
    • tellurium.roadrunner: Interface for the RoadRunner simulation engine.
    • tellurium.sedml: Support for Systems Entity Description Markup Language.
    • tellurium.teio: Input/Output utilities for model files.
    • tellurium.teconverters: Converters for different model formats.
    • tellurium.visualization & tellurium.plotting: Tools for generating visual representations of models and data.
    • tellurium.utils: General utility functions.
    • tellurium.notebooks: Support for Jupyter notebook workflows.
  3. Explore the tellurium.sedml package structure

    develop

    The tellurium.sedml package provides tools for working with Systems Biology Evaluation Markup Language (SBML) and related formats. It is organized into several specialized submodules:

    • tellurium.sedml.data: Handles data structures and information related to SED-ML.
    • tellurium.sedml.mathml: Provides functionality for MathML (Mathematical Markup Language) integration.
    • tellurium.sedml.tesedml: Supports TES-EDML (Time-course Experiment Simulation Exchange Data Markup Language).
    • tellurium.sedml.utils: Contains utility functions for SED-ML operations.
    • tellurium.sedml.xpath: Provides XPath-related utilities for navigating XML-based biological models.
    • tellurium.sedml.templates: A subpackage containing templates for generating SED-ML files.
  4. System requirements and platform support for Tellurium

    develop

    Tellurium supports the following platforms and Python versions:

    • Supported Platforms: Windows, Mac, and Linux.
    • Supported Python Versions: Python 3.7, 3.8, and 3.9.

    Note: New versions of Tellurium do not support Python 2.7. If you require Python 2.7, you must install a previous version of Tellurium.

  5. Explore the tellurium.analysis package submodules

    develop

    The tellurium.analysis package provides a suite of tools for performing various biological model analyses. It is organized into specialized submodules, each targeting a specific type of mathematical or biological investigation:

    • tellurium.analysis.annotations: Tools for handling model annotations.
    • tellurium.analysis.bifurcation: Tools for bifurcation analysis (studying how system behavior changes as parameters vary).
    • tellurium.analysis.parameterestimation: Tools for fitting model parameters to experimental data.
    • tellurium.analysis.parameterscan: Tools for scanning parameter ranges to observe model responses.
    • tellurium.analysis.sensitivityanalysis: Tools for determining how sensitive model outputs are to changes in inputs or parameters.
    • tellurium.analysis.simulator: Tools for advanced simulation tasks.
    • tellurium.analysis.stochasticmodel: Tools for analyzing models using stochastic simulation methods.
    • tellurium.analysis.test: Utilities for testing analysis implementations.
  6. Use the tellurium.plotting package for visualization

    develop

    The tellurium.plotting package provides a unified interface for visualizing biological models and simulation data. It uses a factory pattern to support multiple plotting backends, allowing you to switch between different rendering engines without changing your high-level plotting code.

    Available Plotting Engines

    Depending on your requirements, you can use different engine implementations:

    • engine_mpl: Uses Matplotlib for high-quality, static, or publication-ready plots.
    • engine_plotly: Uses Plotly for interactive, web-ready visualizations.
    • engine_null: A null engine that performs no plotting (useful for headless environments or testing where visualization is not required).

    To use the package, you typically interact with the high-level API provided in tellurium.plotting.api or the main tellurium.plotting module, which abstracts the underlying engine selection.

  7. What is Antimony and how is it used in Tellurium

    develop

    Antimony is a human-readable, text-based modeling language designed to interconvert between the SBML (Systems Biology Markup Language) standard and a shorthand form. It allows users to define biological models (species, reactions, compartments, events, etc.) without the overhead of working directly with XML.

    In Tellurium, Antimony is the primary method for building models. It is particularly useful for:

    • Defining reaction networks where processes consume and create elements.
    • Packaging and reusing models as modules with defined or implied interfaces.
    • Automating model generation from templates (e.g., using TemplateSB).
  8. Understand the Tellurium ecosystem and constituent packages

    develop

    Tellurium is an integration module that connects several specialized Python packages for systems biology simulation and model handling. When working with Tellurium, you are interacting with a suite of tools that includes:

    • tellurium: The main integration module.
    • libroadrunner: The SBML ODE / stochastic simulator.
    • antimony: Provides a human-readable representation of SBML.
    • phrasedml: Provides a human-readable representation of SED-ML.
    • libcombine: For reading/writing COMBINE archives.
    • sbml2matlab: Utility for converting SBML models to MATLAB ODE simulations.
    • simplesbml: Utility for creating SBML models without the complexity of libSBML.
    • libsbml: Core library for reading/writing SBML.
    • libsedml: Core library for reading/writing SED-ML.
  9. Reset model values using reset, resetAll, and resetToOrigin

    develop

    Tellurium provides three levels of resetting for a RoadRunner instance to manage simulation states, initial concentrations, and parameter values:

    1. reset(): Resets system variables (typically species concentrations) to their respective initial values. This does not affect parameters that have been manually changed during the session.
    2. resetAll(): Resets system variables to their CURRENT initial values and resets parameters to their current initial values. If you have used setValue('init(parameter)', value) to redefine what the 'initial' value is, resetAll() will use that new value.
    3. resetToOrigin(): Completely resets the model to the state it was in when it was first loaded, clearing all manual changes to both variables and parameters.
    import tellurium as te
    
    r = te.loada('S1 -> S2; k1*S1; k1 = 0.1; S1 = 10')
    
    # 1. reset(): Resets concentrations to initial, keeps changed parameters
    r.k1 = 2.0
    r.reset()
    
    # 2. resetAll(): Resets concentrations and parameters to their CURRENT initial values
    r.setValue('init(k1)', 0.3)
    r.resetAll()
    
    # 3. resetToOrigin(): Resets everything to the original loaded state
    r.resetToOrigin()
  10. Create modular models

    develop

    Antimony supports modularity. You can define a reusable module with the model syntax and parentheses to expose specific variables. These modules are then imported into other models.

    When a module is imported, its internal species are scoped to that module instance (e.g., A.E and B.E are distinct even if they share the same name in the module definition).

    model side_reaction(S, k1)
      J0: S + E -> ES; k1*k2*S*E - k2*ES;
      E = 3;
      ES = E+S;
      k2 = 0.4;
    end
    
    model full_pathway
      A: side_reaction(S1, k4)
      S1 = 0
    end
  11. How to use ParameterScan for advanced simulations and plotting

    develop

    The ParameterScan package provides an alternative to standard Tellurium simulation syntax. Instead of passing simulation arguments (like startTime or endTime) directly into a function call, you instantiate a ParameterScan object with a loaded model and set these values as properties. This approach is designed to simplify complex 3D plotting and multi-parameter scans that would otherwise require cumbersome argument handling.

    To use it, import it from tellurium after importing the main library.

    import tellurium as te
    from tellurium import ParameterScan
    
    # Load your model using standard Tellurium methods
    rr = te.loadAntimonyModel('...') 
    
    # Initialize ParameterScan with the model
    p = ParameterScan(rr)
    
    # Set simulation parameters as properties
    p.startTime = 0
    p.endTime = 20
    
    # Run a plot
    p.plotArray()
  12. Understand the exported MATLAB model structure

    develop

    When a Tellurium model is exported to MATLAB, it generates a function (typically named __main) that can be called with specific inputs and returns simulation results.

    Function Signature

    [t x rInfo] = __main(tspan, solver, options)

    Inputs

    • tspan: The time vector for the simulation. Can be a full vector (e.g., [0 1 2 3]) or just start/end points (e.g., [0 100]).
    • solver: A MATLAB function handle for an ODE solver (e.g., @ode23s).
    • options: An options structure returned from the MATLAB odeset function (used for setting tolerances).

    Outputs

    • t: The time vector corresponding to the solution.
    • x: The simulation results (species concentrations/amounts).
    • rInfo: A structure containing model metadata, including:
      • stoich: The stoichiometry matrix.
      • floatingSpecies: Cell array of [name, initial_value, isAmount].
      • compartments: Cell array of [name, volume].
      • params: Cell array of [name, value].
      • boundarySpecies: Cell array of boundary species info.
      • rateRules: Cell array of rate rule variable names.

    Example MATLAB Call

    options = odeset('RelTol',1e-12,'AbsTol',1e-9);
    [t x rInfo] = __main(linspace(0,100,100), @ode23s, options);