TfaModel¶
Add thermodynamic constraints to a XbaModel instance to generate TFA, TGECKO or TRBA models.
- class f2xba.TfaModel(xba_model)[source]¶
Extend a XbaModel instance by adding thermodynamic constraints.
The extended XbaModel can be used to create a TFA model, thermodynamics enabled enzyme constraint (e.g. TGECKO) and resource balance constraint (TRBA) models.
Optimization of models might produce infeasible results, when adding thermodynamic constraints. In such cases, parameter relaxation of the TD constrain model might be required. Relaxation would adjust bounds of ∆rG’˚ (standard transformed Gibbs energy of reaction) optimization variables. The adjusted bounds can be included in the TFA configuration file. See tutorial.
The implementation is based on Python package pyTFA (Salvy et al., 2019).
Ref: Salvy, P., Fengos, G., Ataman, M., Pathier, T., Soh, K. C., & Hatzimanikatis, V. (2019). pyTFA and matTFA: a Python package and a Matlab toolbox for Thermodynamics-based Flux Analysis. Bioinformatics, 35(1), 167-169. https://doi.org/10.1093/bioinformatics/bty499
Example 1: Create a TFA model by extending an existing genome scale metabolic model. The spreadsheet file tfa_parameters.xlsx contains configuration data. See tutorials.
xba_model = XbaModel('iML1515.xml') xba_model.configure() tfa_model = TfaModel(xba_model) tfa_model.configure('tfa_parameters.xlsx') if tfa_model.validate(): tfa_model.export('iML1515_TFA.xml')
Example 2: Create a TGECKO model. The spreadsheet files xba_parameters.xlsx, tfa_parameters.xlsx and ecm_parameters.xlsx contain configuration data.
xba_model = XbaModel('iML1515.xml') xba_model.configure('xba_parameters.xlsx') tfa_model = TfaModel(xba_model) tfa_model.configure('tfa_parameters.xlsx') ec_model = EcModel(xba_model) ec_model.configure('ecm_parameters.xlsx') ec_model.export('iML1515_TGECKO.xml')
- model¶
Reference to the XbaModel instance.
- td_params¶
General parameters extracted from TFA configuration file, sheet general.
- td_compartments¶
TD compartments as per TFA configuration file.
- td_metabolites¶
TD metabolites extracted from the TD database.
- td_cues¶
TD data of TD cues (components of TD species), extracted from the TD database.
- td_reactants¶
TD data related to model species.
- td_reactions¶
TD data related to model reactions.
- configure(tfa_config_data)[source]¶
Configure the TfaModel instance with information provided in the TFA configuration data (file or dict).
f2xba can determine standard transformed Gibbs reaction energies using a formulation aligned with pyTFA. It is however possbile to supply standard transformed Gibbs reaction energies and related errors, which have been determined by different formulations, e.g. using equilibrator.
User provided standard transformed Gibbs reaction energies can be provided in an Excel spreadsheet with file name provided in the optional parameter ‘drg0trs_fname’ in the ‘general’ table of the TFA configuration data. In this case a thermo database needs not to be provided.
The table ‘td_compartments’ is mandatory and tables ‘mid2tdmid’, ‘modify_thermo_data’, ‘modify_drg0_bounds’ are optional
xba_model = XbaModel('iML1515.xml') xba_model.configure() tfa_model = TfaModel(xba_model) tfa_model.configure('tfa_parameters.xlsx')
- Parameters:
tfa_config_data (str or dict) – filename of TFA configuration file (.xlsx) or dict with config data.
- Returns:
success status of operation
- Return type:
bool
- validate()[source]¶
Validate compliance with SBML standards, including units configuration.
Validation is an optional task taking time. Validation could be skipped once model configuration is stable.
Information on non-compliance is printed. Details are written to tmp/tmp.txt. In case of an unsuccessful validation, it is recommended to review tmp/tmp.txt and improve on the model configuration.
Example: Ensure compliance with SBML standards for a TfaModel instance prior to its export to file.
if tfa_model.validate(): tfa_model.export('iML1515_TFA.xml')
- Returns:
success status
- Return type:
bool
- export(fname)[source]¶
Export TfaModel to SBML encoded file (.xml) or spreadsheet (.xlsx).
The spreadsheet (.xlsx) is helpful to inspect model configuration.
Example: Export TfaModel to SBML encoded file and to spreadsheet format.
if tfa_model.validate(): tfa_model.export('iML1515_TFA.xml') tfa_model.export('iML1515_TFA.xlsx')
- Parameters:
fname (str) – filename with extension ‘.xml’ or ‘.xlsx’
- Returns:
success status
- Return type:
bool
- export_drg0_tr(fname)[source]¶
Export standard transformed Gibbs reaction energies and errors to file (Excel spreadsheet).
Export Gibbs reaction data from a TFA model instance, after values have been determined by f2xba formulation (based on pyTFA)
The file can be used as a template to supply standard transformed Gibbs reaction energies and errors calculated by different methods.
xba_model = XbaModel('iML1515.xml') xba_model.configure('xba_parameters.xlsx') tfa_model = TfaModel(xba_model) tfa_model.configure('tfa_parameters.xlsx') tfa_model.export_drg0_tr('drgotrs.xlsx')
- Parameters:
fname (str) – filename with extension ‘.xlsx’
- export_slack_model(fname)[source]¶
Export a TFA model with slack variables to perform TFA parameter relaxation.
The slack model can be used for model parameter relaxation to adjust bounds of ∆rG’˚ variables and create/update the sheet ‘modify_drg0_bounds’ in the TFA configuration file.
Example: Create TFA model with slack variables.
xba_model = XbaModel('iML1515.xml') xba_model.configure() tfa_model = TfaModel(xba_model) tfa_model.configure('tfa_parameters.xlsx') tfa_model.export_slack_model('iML1515_TFA_slack.xml')
Subsequently, load and optimize the slack model. Determine adjustments of variable bounds, update the TFA configuration file and generate a TFA model with relaxed bounds. See tutorial related to TFA model creation.
- Parameters:
fname (str) – filename with extension ‘.xml’
- Returns:
success status of operation
- Return type:
bool