Skip to main content

MetEvolSim (Metabolome Evolution Simulator) Python Package

Project description

A Python package to simulate the long-term evolution of metabolic levels.

MetEvolSim is a Python package providing numerical tools to simulate the long-term evolution of metabolic abundances. MetEvolSim takes as an input any SBML metabolic network model, as soon as the kinetic model is fully specified, and a stable steady-state exists. Steady-state concentrations are computed thanks to Copasi software.

MetEvolSim is being developed by Charles Rocabert, Gábor Boross and Balázs Papp.


Table of contents


Project cited in O’Shea & Misra (2020) (


  • Python ≥ 3,
  • Numpy ≥ 1.15 (automatically installed when using pip),
  • Python-libsbml ≥ 5.17 (automatically installed when using pip),
  • NetworkX ≥ 2.2 (automatically installed when using pip),
  • CopasiSE ≥ 4.27 (to be installed separately),
  • pip ≥ 19.1 (optional).


• To install Copasi software, visit You will need the command line version named CopasiSE.

• To install the latest release of MetEvolSim:

pip install MetEvolSim

Alternatively, download the latest release in the folder of your choice and unzip it. Then follow the instructions below:

# Navigate to the MetEvolSim folder
cd /path/to/MetEvolSim

# Install MetEvolSim Python package
python3 install

First usage

MetEvolSim takes as an input any SBML metabolic network model, as soon as kinetic parameters and initial metabolic concentrations are specified, and a stable steady-state exists. The package provides a class to manipulate SBML models: the class Model. It is also necessary to define an objective function (a list of reactions and their coefficients), and to provide the path of CopasiSE software. Please note that coefficients are not functional in the current version of MetEvolSim.

# Import MetEvolSim package
import metevolsim

# Create an objective function
target_fluxes = [['ATPase', 1.0], ['PDC', 1.0]]

# Load the SBML metabolic model
model = metevolsim.Model(sbml_filename='glycolysis.xml', objective_function=target_fluxes, copasi_path='/Applications/COPASI/CopasiSE')

# Print some informations on the metabolic model

# Get a kinetic parameter at random
param = model.get_random_parameter()

# Mutate this kinetic parameter with a log-scale mutation size 0.01
model.random_parameter_mutation(param, sigma=0.01)

# Compute wild-type and mutant steady-states

# Run a metabolic control analysis on the wild-type
# This function will output two datasets:
# - output/wild_type_MCA_unscaled.txt containing unscaled control coefficients,
# - output/wild_type_MCA_scaled.txt containing scaled control coefficients.

# Compute all pairwise metabolite shortest paths

MetEvolSim offers two specific numerical approaches to analyze the evolution of metabolic abundances:

  • Evolution experiments, based on a Markov Chain Monte Carlo (MCMC) algorithm,
  • Sensitivity analysis, either by exploring every kinetic parameters in a given range and recording associated fluxes and metabolic abundances changes (One-At-a-Time sensitivity analysis), or by exploring the kinetic parameters space at random, by mutating a single kinetic parameter at random many times (random sensitivity analysis).

All numerical analyses output files are saved in a subfolder output.

Evolution experiments:

Algorithm overview: A. The model of interest is loaded as a wild-type from a SBML file (kinetic equations, kinetic parameter values and initial metabolic concentrations must be specified). B. At each iteration t, a single kinetic parameter is selected at random and mutated through a log10-normal distribution of standard deviation σ. C. The new steady-state is computed using Copasi software, and the MOMA distance z between the mutant and the wild-type target fluxes is computed. D. If z is under a given selection threshold ω, the mutation is accepted. Else, the mutation is discarded. E. A new iteration t+1 is computed.

Six types of selection are available:
  • MUTATION_ACCUMULATION: Run a mutation accumulation experiment by accepting all new mutations without any selection threshold,
  • ABSOLUTE_METABOLIC_SUM_SELECTION: Run an evolution experiment by applying a stabilizing selection on the sum of absolute metabolic abundances,
  • ABSOLUTE_TARGET_FLUXES_SELECTION: Run an evolution experiment by applying a stabilizing selection on the MOMA distance of absolute target fluxes,
  • RELATIVE_TARGET_FLUXES_SELECTION: Run an evolution experiment by applying a stabilizing selection on the MOMA distance of relative target fluxes.
# Load a Markov Chain Monte Carlo (MCMC) instance
mcmc = metevolsim.MCMC(sbml_filename='glycolysis.xml', objective_function=target_fluxes, total_iterations=10000, sigma=0.01, selection_scheme="MUTATION_ACCUMULATION", selection_threshold=1e-4, copasi_path='/Applications/COPASI/CopasiSE')

# Initialize the MCMC instance

# Compute the successive iterations and write output files
stop_MCMC = False
while not stop_MCMC:
    stop_mcmc = mcmc.iterate()

One-At-a-Time (OAT) sensitivity analysis:

For each kinetic parameter p, each metabolic abundance [Xi] and each flux νj, the algorithm numerically computes relative derivatives and control coefficients.

# Load a sensitivity analysis instance
sa = metevolsim.SensitivityAnalysis(sbml_filename='glycolysis.xml', copasi_path='/Applications/COPASI/CopasiSE')

# Run the full OAT sensitivity analysis
sa.run_OAT_analysis(factor_range=1.0, factor_step=0.01)

Random sensitivity analysis:

At each iteration, a single kinetic parameter p is mutated at random in a log10-normal distribution of size σ, and relative derivatives and control coefficients are computed.

# Load a sensitivity analysis instance
sa = metevolsim.SensitivityAnalysis(sbml_filename='glycolysis.xml', copasi_path='/Applications/COPASI/CopasiSE')

# Run the full OAT sensitivity analysis
sa.run_random_analysis(sigma=0.01, nb_iterations=1000)


To get some help on a MetEvolSim class or method, use the Python help function:


to obtain a quick description and the list of parameters and outputs:

Help on function set_species_initial_value in module metevolsim:

set_species_initial_value(self, species_id, value)
    Set the initial concentration of the species 'species_id' in the
    mutant model.

    species_id: str
            Species identifier (as defined in the SBML model).
    value: float >= 0.0
            Species abundance.


Ready-to-use examples

Ready-to-use examples are included in the Python package. They can also be downloaded here:


Copyright © 2018-2021 Charles Rocabert, Gábor Boross and Balázs Papp. All rights reserved.


This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for metevolsim, version 0.5.6
Filename, size File type Python version Upload date Hashes
Filename, size MetEvolSim-0.5.6-py3-none-any.whl (32.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size MetEvolSim-0.5.6.tar.gz (56.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page