Skip to main content

A Python implementation of flux balance analysis

Project description

A python implementation of flux balance analysis to model microbial metabolism

About PyFBA

PyFBA is a Python flux-balance-analysis package that allows you to build models from genomes, gapfill models, and run flux-balance-analysis on that model. The aim of PyFBA is to provide an extensible, python-based platform for FBA work.

PyFBA is being developed by Daniel Cuevas, Taylor O’Connell, and Rob Edwards in Rob’s bioinformatics group at Flinders University, together with help from Janaka Edirisinghe, Chris Henry, Ross Overbeek and others at Argonne National Labs.

Installing PyFBA

We recommend that you install PyFBA using conda:

conda create -n pyfba -c bioconda pyfba

You can also install PyFBA from PyPi using pip and you will need Python 3 or greater, and you need to install the GNU GLPK and a Python wrapper for that program, pyGLPK available from GitHub.

Our installation page has detailed instructions on installing PyFBA and getting everything running.

Getting Started with PyFBA

Once you have installed GLPK, PyGLPK, and PyFBA, you will most likely want to build a model from a genome, gap fill that model, and test it for growth on different media. We have detailed instructions that walk you through the step-by-step procedures that you need to use to run flux balance analysis on your own genome.

Copyright and License

PyFBA is copyright Daniel Cuevas, Taylor O’Connell, and Rob Edwards, and is released under the MIT license.


Crucial edit to file

Adding PyFBA.model package to list.


Updated all the code to work with Python 3.

However, this breaks compatibility with Python 2 because of the “errors” keyword in open.

The main changes include relative imports, a new class in the tests/ package to allow deep assertions, and using this type of construct with the open command to ignore unicode errors in ModelData:

with open(ssfile, ‘r’, errors=’replace’) as sin:

Added function to obtain Model SEED complexes from a set of roles

  • PyFBA/filters/

Added gap-fill step to add reactions based on existent EC numbers

  • PyFBA/gapfill/

Optimized and fixed bugs during gap-fill reaction minimization process

  • PyFBA/gapfill/

New Model class objects

Model object contains functionality to make common processes easier to facilitate.

  • Generate model from RAST annotations
  • Save model to hard disk location
  • Load model from hard disk location
  • Run FBA
  • Run FBA and obtain flux values
  • Run FBA and obtain flux values according to SEED subsystems
  • Run gap-fill
  • Remember which reactions were gap-filled reactions and which media

New iPython Notebooks

  • Find a metabolite.ipynb
  • PATRIC to FBA.ipynb
  • Gap-fill_a_model.ipynb
  • Saving_and_loading_a_model.ipynb


Added a

Please cite us if you use PyFBA

Added the iPython Notebook directory

Example code showing:

importing an SBML file and running FBA

  • iPythonNotebooks/Using_an_SBML_model.ipynb

how to build your model from functional roles and how to gap-fill that model on a media

  • iPythonNotebook/From_functional_roles_to_gap-filling.ipynb

Added minimization by accuracy

Removed PyFBA/gapfill/ and created

Example gap-fill pipeline

  • example_code/


Removed the author tag

It is superflous, that is what versioning is for.


Several changes to files:

Updated the subsystem functions and changed the name to a generic name. The date is handled by versioning!

  • PyFBA/Biochemistry/SEED/Subsystems/SS_functions.txt
  • PyFBA/Biochemistry/SEED/Subsystems/SS_functions_Oct_2015.txt

Changing the version number

  • PyFBA/

Adding reaction flux information that can be pulled after the sm has been solved

  • PyFBA/fba/
  • PyFBA/fba/

External reactions

Fixed an issue where we were over-incorporating reactions based on things in the media

  • PyFBA/fba/
  • PyFBA/parse/

Adding verboseness

  • PyFBA/fba/
  • PyFBA/gapfill/
  • PyFBA/parse/

Reduced complexity

We only test the right half of the reactions if the left half do not grow, and once we have <10 reactions to search through we just iterate and knock out each reaction sequentially. It is faster than the shuffle approach.

  • PyFBA/gapfill/

Changed the way we read roles

SEED has a notion of multifunctional roles, and we added splitting those functions into roles

  • PyFBA/gapfill/

Gap generation code

Testing each of the individual reactions in a model

  • PyFBA/gapgeneration/
  • example_code/

Shifted the order of gapfilling

This order makes more logical sense!

  • example_code/

Updated the tests

With all these changes, the tests were not right

  • PyFBA/tests/reaction_list.txt
  • PyFBA/tests/
  • PyFBA/tests/


Refactored separating roles to functions. SEED has a concept of multifunctional roles and this separates out our roles before we search for them.




  • Removed installation dependencies from because they break installation! You need to install the dependencies manually
  • Refactored the code to remove the os.environ dependencies


  • Initial release

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 PyFBA, version 2.59
Filename, size File type Python version Upload date Hashes
Filename, size PyFBA-2.59.tar.gz (12.5 MB) 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