Gap-fill a model in PyFBA
by Daniel Cuevas
Introduction
In this notebook, we will present the steps to generate a genome-scale metabolic model from RAST annotations, gap-fill the model on rich LB type media, and save the model to hard disk.
The required files and information for this notebook:
- List of functional roles from RAST (normally labeled ‘assigned_functions’ from the Genome Directory download).
- Organism name
- Organism ID
- Media file
- Close genomes functional roles file
- Directory on hard disk to store model
import sys
import os
import PyFBA
Generate model
The first step shows how to build the model from RAST functional roles.
model_functions_file = "data/citrobacter.assigned_functions"
close_genomes_functions_file = "data/close_genomes_functions"
org_name = "Citrobacter sedlakii"
org_id = "Citrobacter sedlakii"
model = PyFBA.model.roles_to_model(model_functions_file, org_id, org_name)
The model has been generated and is now ready to use for flux-balance analysis simulations. Running flux-balance analysis will show the model does not contain all required metabolism to grow in the LB media.
Here are the LB media contents. For PyFBA media files are stored in directory indicated by environmental variable ‘PYFBA_MEDIA_DIR’. This step is only to show file contents but is not required for gap-filling.
lb_media_file = os.path.join(os.environ["PYFBA_MEDIA_DIR"], "ArgonneLB.txt")
with open(lb_media_file) as f:
for l in f:
print(l, end="")
# status := optimization status of FBA simplex solver
# flux_value := biomass flux value (objective function)
# growth := boolean whether the model was able to grow or not
status, flux_value, growth = model.run_fba("ArgonneLB.txt")
print("Growth:", growth)
Gap-fill model on LB media
Each model object in PyFBA contains a gapfill()
function that requires two arguments:
- Media file
- Close genomes functional roles file
The other two arguments here, use_flux
and verbose
, are optional.
use_flux
is a boolean flag that will identify which reactions that were added during the first phase of gap-filling have a non-active or zero flux. These reactions are then removed before the second phase of gap-filling occurs. This lowers the number of reactions that must be tested during second phase, thus speeding up the gap-filling process.verbose
is an integer flag that will output status update tostderr
.
success = model.gapfill("ArgonneLB.txt", close_genomes_functions_file, use_flux=True, verbose=1)
if not success:
print("Model was unable to gap-fill!")
We can view the reactions that were gap-filled into the model.
for n, rid in enumerate(model.gf_reactions, start=1):
print("({}) {}: {}".format(n, rid, model.reactions[rid].equation))
Save model
The second step shows how to save the model to hard disk.
model_directory = "save_citrobacter_sedlakii"
PyFBA.model.save_model(model, model_directory)
Model has been stored. Here is a directory listing of the files that were created.
for f in os.listdir(model_directory):
fp = os.path.join(model_directory, f)
print(f, ": ", os.path.getsize(fp), "B", sep="")