by Daniel Cuevas
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:
In [1]:
import sys
import os
import PyFBA
In [2]:
model_functions_file = "data/citrobacter.assigned_functions"
close_genomes_functions_file = "data/close_genomes_functions"
org_name = "Citrobacter sedlakii"
org_id = "Citrobacter sedlakii"
In [3]:
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.
In [4]:
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="")
In [5]:
# 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)
Each model object in PyFBA contains a gapfill()
function that requires two arguments:
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 to stderr
.
In [6]:
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.
In [7]:
for n, rid in enumerate(model.gf_reactions, start=1):
print("({}) {}: {}".format(n, rid, model.reactions[rid].equation))
In [8]:
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.
In [9]:
for f in os.listdir(model_directory):
fp = os.path.join(model_directory, f)
print(f, ": ", os.path.getsize(fp), "B", sep="")