Skip to main content
GitHub commit activity Read the Docs PyPI - Downloads GitHub issues PyPI - Python Version

teUtils: Additional Utilities for Tellurium

teUtils is a collection of utilities for Tellurium users that we have found useful in our own modeling work. It adds functions for:

  • Generating test models: linear pathways and random mass-action networks, returned as Antimony
  • Printing a model as its rate equations and ODEs
  • Extra plots: control coefficient heat maps and 3D plots, phase portrait grids, ASCII bar charts and more
  • Showing concentrations and fluxes as neat text tables
  • Simple time course parameter scans
  • Reading CSV files into arrays ready for plotting

Installation

Install teUtils from PyPI with pip:

pip install teUtils

To upgrade an existing installation:

pip install --upgrade teUtils

teUtils requires Python 3.7 or later. pip installs its dependencies automatically: tellurium, libroadrunner, python-libsbml, numpy, pandas, matplotlib, seaborn and tabulate.

Quick start

import tellurium as te
import teUtils as tu

# Build a three-step linear pathway with mass-action kinetics
model = tu.buildNetworks.getLinearChain(3, rateLawType='MassAction')
r = te.loada(model)

r.simulate(0, 50, 100)
r.steadyState()

# Show the steady-state fluxes as a table
print(tu.prettyTabular.tabulateFluxes(r))

# Plot the flux control coefficients as a heat map
tu.plotting.plotFluxControlHeatMap(r)

Output from the table:

+------+------------------+
| Id   |   Reaction Rates |
|------+------------------|
| J1   |          4.04079 |
| J2   |          4.04079 |
| J3   |          4.04079 |
+------+------------------+

Documentation

Full API documentation is at: http://teUtils.readthedocs.io/en/latest/

The sections below give an overview of each module. All functions that take r expect a roadrunner instance, for example one created by te.loada(...).

buildNetworks

Generates models as Antimony strings that can be loaded with te.loada.

Function Description
getLinearChain(lengthOfChain, rateLawType='MassAction', keqRatio=5) A linear pathway Xo -> S1 -> ... -> X1 with boundary species at each end and random parameter values.
getRandomNetwork(nSpecies, nReactions, isReversible=False, randomSeed=-1, ...) A random network built from uni-uni, bi-uni, uni-bi and bi-bi mass-action reactions. Returns an empty string if the network has no floating species.
getRandomNetworkDataStructure(nSpecies, nReactions, ...) The same random network as a Python data structure (floating ids, boundary ids, reaction list) instead of Antimony.

getLinearChain supports three rate laws through rateLawType:

rateLawType Rate law for each step
'MassAction' (default) e1*(k10*S1 - k11*S2)
'ModifiedMassAction' k1*S1*(1 - (S2/S1)/Keq1)
'Michaelis' Vm1/Km10*(S1 - S2/Keq1)/(1 + S1/Km10 + S2/Km11)

The e terms in the mass-action rate laws make it easy to compute control coefficients with respect to enzyme level. The modified mass-action form makes it easy to control each reaction's equilibrium constant.

model = tu.buildNetworks.getLinearChain(10, rateLawType='ModifiedMassAction')

# Random network with 6 species and 9 reactions, repeatable with a seed
model = tu.buildNetworks.getRandomNetwork(6, 9, randomSeed=42)
r = te.loada(model)
r.simulate(0, 10, 100)

Random network generation can be configured through tu.buildNetworks.Settings:

Setting Default Meaning
rateConstantScale 1.0 Rate constants are drawn between 0 and this value
allowMassViolatingReactions False Allow reactions such as A + B -> A
addDegradationSteps False Add a degradation step to every floating species
removeBoundarySpecies True Turn pure sources and sinks into boundary species
ReactionProbabilities.UniUni / BiUni / UniBi / BiBi 0.3 / 0.3 / 0.3 / 0.1 Probability of picking each reaction type

Call tu.buildNetworks.Settings.restoreDefaultProbabilities() to reset the reaction probabilities.

odePrint

Converts a model into readable rate equations and ODEs.

Function Description
getODEsFromModel(r) ODEs for a roadrunner instance
getODEsFromSBMLString(sbmlStr) ODEs for an SBML string
getODEsFromSBMLFile(fileName) ODEs for an SBML file
r = te.loada('S1 -> S2; k1*S1; k1 = 1; S1 = 10')
print(tu.odePrint.getODEsFromModel(r))
v_J0 = k1*S1

dS1/dt = -v_J0
dS2/dt = v_J0

plotting

Additional plotting functions built on matplotlib and seaborn. Most heat map and grid functions accept pdfExport='file.pdf' to save the figure, and figsize=(width, height) to set its size.

Function Description
plotFluxControlHeatMap(r) Flux control coefficients as a heat map
plotConcentrationControlHeatMap(r) Concentration control coefficients as a heat map
plotArrayHeatMap(data) Any 2D array as a heat map
plotFluxControlIn3D(r) Flux control coefficients as a 3D bar plot
plotConcentrationControlIn3D(r) Concentration control coefficients as a 3D bar plot
plotFluxControlBar(r, reactionId) Bar chart of the control coefficients for one flux
plotConcentrationControlBar(r, speciesId) Bar chart of the control coefficients for one species
plotReactionRates(r) Bar chart of the current reaction rates
plotFloatingSpecies(r) Bar chart of the current floating species concentrations
plotPhasePortraitGrid(r) Grid of phase portraits for every pair of floating species
plotRandSimGrid(r) Grid of time courses, each using randomly drawn parameter values
plotAsciiConcentrationsBar(r, scale=5) Text-only bar chart of the concentrations
plotAsciiReactionRatesBar(r, scale=5) Text-only bar chart of the reaction rates
plotArray(result, ...) Plot an array whose first column is the x-axis
plotWithLegend(r, result) Plot a simulation result with a legend

prettyTabular

Displays model values as text tables, using the tabulate package.

Function Description
tabulateConcentrations(r, fmt='psql') Table of the floating species concentrations
tabulateFluxes(r, fmt='psql') Table of the reaction rates

fmt can be any tabulate table format, such as 'psql', 'grid', 'github' or 'plain'.

parameterScanning

Function Description
simpleTimeCourseScan(r, parameter, variable, lowRange, highRange, numberOfScans, timeEnd=10, numberOfPoints=100) Runs a time course at evenly spaced values of one parameter and plots one variable from each run on a single graph
r = te.loada('S1 -> S2; k1*S1; k1 = 0.1; S1 = 10')
tu.parameterScanning.simpleTimeCourseScan(r, 'k1', 'S1', 0.1, 1.0, 5)

fileUtils

Function Description
readCsvFile(fileName, includeFirstColumnLabel=False) Reads a CSV file with a header row and returns the data as a numpy array plus the list of column names
data, header = tu.fileUtils.readCsvFile('mydata.csv')
tu.plotting.plotArray(data, labels=header)

Release history

3.2.3 Expanded Sphinx documentation on Read the Docs; adds a docstring to plotting.plotWithLegend.

3.2.2 Expanded README documentation, now shown on PyPI.

3.2.1 Package dependencies now include matplotlib, seaborn and libroadrunner. Removes the deprecated license classifier.

3.2 Fixes invalid Antimony from getRandomNetwork (boundary species are now declared with const) and other buildNetworks bugs. Adds pyproject.toml so pip no longer warns about the legacy setup.py build.

3.0 Updates matplotlib support and fixes some typos in the docs.

2.9 Adds e terms to mass-action rate laws, for example S1 -> S2; e1*(k1*S1 - k2*S2), which makes it easier to compute control coefficients with respect to e. Also adds the modified mass-action rate law v = k1*A*(1 - (B/A)/Keq1), generated with getLinearChain(10, rateLawType='ModifiedMassAction').

License

MIT

Metadata

Release files for teUtils 3.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for teUtils 3.2.3
File Size Uploaded Provenance Actions
teutils-3.2.3.tar.gz 36.2 kB Without provenance Details for teutils-3.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for teUtils 3.2.3
File Interpreter ABI Platform Actions
teutils-3.2.3-py3-none-any.whl Python 3 none any Details for teutils-3.2.3-py3-none-any.whl

Total release size: 60.0 kB

Release files / teutils-3.2.3.tar.gz

Download URL teutils-3.2.3.tar.gz
Size 36.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4de0c4963347978503b6473807ba0f657fc30522ccccb24461f1417d126c0ed8
BLAKE2b-256 checksum
How to use checksums
4d4816cb35e7d23d560b18a73ebc181b61ba6b3235bd5513908aac69d216c4a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / teutils-3.2.3-py3-none-any.whl

Download URL teutils-3.2.3-py3-none-any.whl
Size 23.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3868e2b25f54d24bdc73a1a8f4e2d7fcd786c3b638e061d70eb3e175e81eb9c3
BLAKE2b-256 checksum
How to use checksums
92b658c916bce5e55cf19aa4b97a4eef21bc098eb6a83370cd1af18aa79281e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Security for teUtils 3.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

3.2.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page