https://github.com/brsynth/rpfba
Perform Flux Balance Analysis on a single or collection of SBML files containing heterologous pathways.
https://github.com/brsynth/rpfba
Last synced: about 1 month ago
JSON representation
Perform Flux Balance Analysis on a single or collection of SBML files containing heterologous pathways.
- Host: GitHub
- URL: https://github.com/brsynth/rpfba
- Owner: brsynth
- License: mit
- Created: 2020-12-04T14:03:09.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2026-04-14T12:40:58.000Z (2 months ago)
- Last Synced: 2026-04-14T14:19:08.277Z (2 months ago)
- Language: Python
- Size: 1.4 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rpFBA
Perform FBA on a single or collection of SBML files containing heterologous pathways, as tar.xz archives. The package performs the following steps:
1) it merges a user defined GEM SBML model to a given heterologous pathway.
2) it performs FBA using the [cobrapy](https://opencobra.github.io/cobrapy/) package using a user defined method that includes FBA, parsimonious FBA or fraction of optimum of another reaction. For the first two, the user must know the reaction name that the model will optimise to, while the latter the user must provide the target reaction (default: 'rxn_target') but also another reaction that will be restricted (default: 'biomass'). The first step involves performing FBA using the "source" reaction as the objective. Then the flux of that reaction has its upper and lower bounds set to the same value, determined as a fraction of its FBA flux value. Thereafter the objective is set to the initial target reaction and FBA is performed once again. The tool uses the [FBC](https://co.mbine.org/specifications/sbml.level-3.version-1.fbc.version-2.release-1) package to manage the objective and flux bounds.
NOTE: In order to FBA works correctly, some of chemical species have to be ignored. These species are selected according to the following criteria:
* pathway species has not been found in the model (neither by its ID nor its InChIKey),
* the species is not the target, and
* the species is only consumed or produced with the heterologue pathway.
## Input
Required:
* **pathway_file**: (string) Path to the pathway file (rpSBML)
* **model_file**: (string) Path to the GEM SBML model
* **compartment_id**: (string, e.g. cytoplasm) ID of the compartment that contains the chemical species involved in the heterologous pathway
* **out_file**: (string) Path to the ouput upgraded pathway file
Advanced options:
* **--sim**: (string, default='fraction') Valid options include: 'fraction', 'fba', 'pfba'. The type of constraint based modelling method
* **--objective_rxn_id**: (string, default=rxn_target) Reaction ID to optimise
* **--biomass_rxn_id**: (string, default='biomass') Biomass reaction ID. Note: Only for 'fraction' simulation
* **--fraction_of**: (float, default=0.75) Portion of the maximal flux used to set the maximal and minimal bounds for the source reaction of the 'fraction' simulation type
* **--merge**: (boolean, default=False) Return the merged GEM+heterologous pathway SBML or only the heterologous pathway SBML files
* **--ignore_orphan_species**: (string, default=True) Ignore metabolites that are only consumed or produced
## Output
* **output**: (string) Path to the output file
# Installation Guide
## Overview
`rpthermo` depends on `rplibs`, which depends on `cobra`, which requires `python-libsbml`.
On Apple Silicon (`arm64`) macOS, `python-libsbml` is not available as a native Conda package.
Therefore, installation must be done using an **Intel (`osx-64`) Conda environment under Rosetta**.
---
## General case
```bash
conda install -c conda-forge rpthermo
```
---
## Apple Silicon macOS (M1/M2/M3)
### 1. Install Rosetta 2
```bash
softwareupdate --install-rosetta --agree-to-license
```
### 2. Install
```bash
CONDA_SUBDIR=osx-64 conda install -c conda-forge rpfba
```
Or with mamba:
```bash
CONDA_SUBDIR=osx-64 mamba install -c conda-forge rpfba
```
### 3. Persist platform setting
```bash
conda config --env --set subdir osx-64
```
### 4. Verify installation
```bash
python -c "import rpfba; print('rpfba installed successfully')"
```
### 5. (Optional) Dev installation
```bash
CONDA_SUBDIR=osx-64 conda env create -f environment.yaml
```
---
## Troubleshooting
### Solver fails on Apple Silicon
Make sure you are using:
```bash
CONDA_SUBDIR=osx-64
```
### Wrong architecture environment
Check:
```bash
conda config --show subdir
```
Expected output:
```bash
subdir: osx-64
```
### Run
### rpFBA process
**From Python code**
```python
from rptools.rplibs import rpPathway
from rptools.rpfba import runFBA
pathway = rpPathway(infile='tests/rpfba/data/sets/measured_3/B.xml')
results = runFBA(
pathway=pathway,
gem_sbml_path='tests/rpfba/data/sets/measured_3/e_coli_iJ01366.xml',
compartment_id='MNXC3',
biomass_rxn_id='biomass',
objective_rxn_id='rxn_target',
sim_type='fraction',
fraction_coeff=0.75,
merge=False,
ignore_orphan_species=True
)
pathway.get_fba_biomass().get('value')
0.7638744755010194
pathway.get_fba_biomass()
{'value': 0.7638744755010194, 'units': 'milimole / gDW / hour'}
```
**From CLI**
```sh
python -m rptools.rpfba
```
## Tests
Test can be run with the following commands:
### Natively
```bash
cd tests
pytest -v
```
## CI/CD
For further tests and development tools, a CI toolkit is provided in `ci` folder (see [ci/README.md](ci/README.md)).
## Authors
* **Joan Hérisson**
* **Melchior du Lac**
## Acknowledgments
* Thomas Duigou
## Licence
rpFBA is released under the MIT licence. See the LICENCE file for details.