Set up GRASP models

Set up models

set_up_grasp_models.set_up_models.set_up_model.get_stoic(file_in)

From a text file with the reactions in the model, set up a dataframe with the transposed stoichiometric matrix.

Parameters

file_in (str) – path to plain text file with the model reactions.

Return type

tuple

Returns

A pandas dataframe with transposed stoichiometric matrix, a list with reaction strings, a list with metabolites order, and a list with reactions order.

set_up_grasp_models.set_up_models.set_up_model.set_up_model(model_name, file_in_stoic, base_excel_file, file_out, use_equilibrator=False, pH=7.0, ionic_strength=0.1, file_bigg_kegg_ids=None, file_in_mets_conc=None, mets_orient='columns', file_in_meas_fluxes=None, fluxes_orient='columns', file_in_prot_ranges=None)

Sets up the excel input model file template. A base excel file must be given. This file must contain at least the general sheet, for that one can use the file ‘GRASP_general.xlsx’ in base_files. In this case an excel file with all fields to be filled is generated.

If a base excel file with some of the sheets already filled or partially filled is available then whatever fields are already filled will be copied to the output model file.

For thermoRxns, if use_equilibrator is set to True, it gets the standard Gibbs energies from eQuilibrator.

If file_in_mets_conc is specified, it takes the metabolite concentrations from that file to fill in thermoMets and metsData. Metabolite names must have the form metBiggID_compartmentBiggID. The file must have either:

  • the metabolite names in the rows and two columns named average and stdev (set mets_orient to ‘rows’)

  • the metabolite names in the columns and two rows named average and stdev (set mets_orient to ‘columns’, the default)

Parameters
  • model_name (str) – name for the model.

  • file_in_stoic (str) – path to plain text file with reactions in the model.

  • base_excel_file (str) – path to the excel file to be used as a base.

  • file_out (str) – path to the output file.

  • use_equilibrator (bool) – flag determining whether or not to get the standard Gibbs energies from eQuilibrator.

  • pH (float) – pH value to use to get the standard Gibbs energies from eQuilibrator.

  • ionic_strength (float) – ionic strength value to use to get the standard Gibbs energies from eQuilibrator.

  • file_bigg_kegg_ids (Optional[str]) – path to the file containing the metabolites mapping from BiGG to KEGG ids.

  • file_in_mets_conc (Optional[str]) – path to excel file containing metabolites concentrations.

  • mets_orient (str) – string specifying the orientation of metabolite concentrations, either ‘rows’ or ‘columns’.

  • file_in_meas_fluxes (Optional[str]) – path to excel file containing measured fluxes (not in use atm).

  • fluxes_orient (str) – string specifying the orientation of measured fluxes, either ‘rows’ or ‘columns’.

  • file_in_prot_ranges (Optional[str]) – path to excel file containing protein concentrations (not in use atm).

Returns

None

set_up_grasp_models.set_up_models.set_up_model.update_stoic(stoic_df, ex_rxns, ex_mets, non_ex_mets_order)

Updates the stoichiometry matrix dataframe by removing the exchange reactions that are not used and the external metabolites no longer involved in the model.

Parameters
  • stoic_df (DataFrame) – pandas dataframe with stoichiometry matrix

  • ex_rxns (list) – list with exchange reactions active in the model

  • ex_mets (list) – list with exchange metabolites active in the model

  • non_ex_mets_order (list) – list with the order of non-external metabolites

Return type

tuple

Returns

A pandas dataframe with tranposed stoichiometric matrix, a list with metabolites order, a list with reactions order, a list with exchange reactions to remove, and a list with external metabolites to remove.

Convert mechanisms

The purpose of this module is to convert an enzyme mechanism given in terms of elementary reactions into the pattern format currently accepted by GRASP.

set_up_grasp_models.set_up_models.convert_mechanisms.convert_er_mech_to_grasp_pattern(file_in, file_out, promiscuous=False, inhib_list=None, activ_list=None)

Given an input file with a mechanism in the form of elementary reactions, converts it to a GRASP pattern file.

Parameters
  • file_in (str) – path to the input file with elementary reactions mechanism.

  • file_out (str) – path to the output file with GRASP pattern.

  • promiscuous (bool) – to indicate whether reaction is promiscuous or not.

  • inhib_list (Optional[list]) – list of inhibiting metabolites.

  • activ_list (Optional[list]) – list of activating metabolites.

Returns

None

set_up_grasp_models.set_up_models.convert_mechanisms.generate_mechanisms(file_in_model, mech_in_dir, pattern_out_dir, hard_coded_mechs=None)

Given the GRASP input excel file, goes through the mechanisms defined in the kinetics sheet and checks if a .txt file with the same name exists in the pattern_out_dir, if not it checks the mech_in_dir for a .txt file with the mechanism name and converts it to a patter file to be stored in the pattern_out_dir.

Parameters
  • file_in_model (str) – path to GRASP input excel file.

  • mech_in_dir (str) – path to folder with the mechanism files in terms of elementary reactions.

  • pattern_out_dir (str) – path to folder with pattern files used by GRASP.

  • hard_coded_mechs (Optional[list]) – list with mechanisms that are hardcoded in GRASP.

Returns

None

Get standard Gibbs energies from eQuilibrator

The aim of this module is to get standard Gibbs energies for reactions given in a plain text file with the format “R_FBA: m_g3p_c + m_dhap_c <-> m_fdp_c”. BiGG IDs must be used for metabolites.

set_up_grasp_models.set_up_models.set_up_thermo_rxns.convert_rxns_to_kegg(rxn_list, map_bigg_to_kegg_ids)

Given a plain text file with a list of reactions in the form: R_FBA: m_g3p_c + m_dhap_c <-> m_fdp_c, where metabolite ids are bigg ids, it converts the metabolite IDs to KEEG ids: R_FBA: C00118 + C00111 = C00354. To do the conversion it uses a dataframe with BiGG IDs on the index and respective KEEG ids on the column “id_kegg”. It skips exchange reactions, which should start with ‘R_EX_’.

Parameters
  • file_rxns – path to file with plain text reactions.

  • map_bigg_to_kegg_ids (DataFrame) – dataframe with bigg IDs and corresponding KEGG ids.

Return type

dict

Returns

A dictionary where the keys are the reaction IDs (e.g. R_FBA) and the values the reaction in terms of KEGG IDs (e.g. C00118 + C00111 = C00354).

set_up_grasp_models.set_up_models.set_up_thermo_rxns.get_dGs(rxn_list, file_bigg_kegg_ids, pH=7.0, ionic_strength=0.1, digits=2)

Given a plain text file with reactions in the form R_FBA: m_g3p_c + m_dhap_c <-> m_fdp_c and a file with a mapping between bigg and kegg ids, returns the standard gibbs energy and respective uncertainty for each reaction. It skips exchange reactions, which should start with ‘R_EX_’.

Parameters
  • file_rxns – path to file with plain text reactions.

  • file_bigg_kegg_ids (str) – path to file with mapping between bigg and kegg ids.

  • pH (float) – pH value to use to calculate standard Gibbs energies.

  • ionic_strength (float) – ionic strength value to use to calculate standard Gibbs energies.

  • digits (int) – number of digits to round standard gibbs energies and respective uncertainty.

Return type

dict

Returns

Dictionary with bigg reaction ids as keys and (standard Gibbs energy, uncertainty) as values.