6.1.1.6. pytfa.thermo

Thermodynamic analysis for Flux-Based Analysis

6.1.1.6.1. Submodules

6.1.1.6.2. Package Contents

6.1.1.6.2.1. Classes

MetaboliteThermo

A class representing the thermodynamic values of a enzyme

SimultaneousUse

Class to represent a simultaneous use constraint on reaction variables

NegativeDeltaG

Class to represent thermodynamics constraints.

BackwardDeltaGCoupling

Class to represent thermodynamics coupling: DeltaG of reactions has to be

ForwardDeltaGCoupling

Class to represent thermodynamics coupling: DeltaG of reactions has to be

BackwardDirectionCoupling

Class to represent a backward directionality coupling with thermodynamics on

ForwardDirectionCoupling

Class to represent a forward directionality coupling with thermodynamics on

ReactionConstraint

Class to represent a variable attached to a reaction

MetaboliteConstraint

Class to represent a variable attached to a enzyme

DisplacementCoupling

Class to represent the coupling to the thermodynamic displacement

ThermoDisplacement

Class to represent the thermodynamic displacement of a reaction

DeltaGstd

Class to represent a DeltaG^o (naught) - standard conditions

DeltaG

Class to represent a DeltaG

ForwardUseVariable

Class to represent a forward use variable, a type of binary variable used to

BackwardUseVariable

Class to represent a backward use variable, a type of binary variable used

LogConcentration

Class to represent a log concentration of a enzyme

ReactionVariable

Class to represent a variable attached to a reaction

MetaboliteVariable

Class to represent a variable attached to a enzyme

ThermoModel

A class representing a cobra_model with thermodynamics information

MetaboliteThermo

A class representing the thermodynamic values of a enzyme

6.1.1.6.2.2. Functions

calcDGtpt_rhs(reaction, compartmentsData, thermo_units)

Calculates the RHS of the deltaG constraint, i.e. the sum of the

calcDGR_cues(reaction, reaction_cues_data)

Calculates the deltaG reaction and error of the reaction using the

get_debye_huckel_b(T)

The Debye-Huckel A and B do depend on the temperature

check_reaction_balance(reaction, proton=None)

Check the balance of a reaction, and eventually add protons to balance

check_transport_reaction(reaction)

Check if a reaction is a transport reaction

find_transported_mets(reaction)

Get a list of the transported metabolites of the reaction.

get_reaction_compartment(reaction)

Get the compartment of a reaction to then prepare it for conversion.

get_bistream_logger(name)

Sets up a logger that outputs INFO+ messages on stdout and DEBUG+ messages

6.1.1.6.2.3. Attributes

BIGM

BIGM_THERMO

BIGM_DG

BIGM_P

EPSILON

MAX_STOICH

class pytfa.thermo.MetaboliteThermo(metData, pH, ionicStr, temperature=std.TEMPERATURE_0, min_ph=std.MIN_PH, max_ph=std.MAX_PH, debye_huckel_b=std.DEBYE_HUCKEL_B_0, thermo_unit='kJ/mol', debug=False)

A class representing the thermodynamic values of a enzyme

Parameters
  • metData (dict) – A dictionary containing the values for the enzyme, from the thermodynamic database

  • pH (float) – The pH of the enzyme’s compartment

  • ionicStr (float) – The ionic strength of the enzyme’s compartment

  • temperature

  • min_ph

  • max_ph

  • debye_huckel_b

  • thermo_unit (string) – The unit used in metData’s values

  • debug (bool) – Optional If set to True, some debugging values will be printed. This is only useful for development or debugging purposes.

Note

The values are automatically computed on class creation. Usually you don’t have to call any methods defined by this class, but only to access the attributes you need.

The available attributes are :

Since the reactions expose similar values through a dictionnary, it is better to access the attributes aforementionned of this class as if it was a dictionnary : enzyme.thermo['pH'].

__getitem__(self, key)
__repr__(self)

Return repr(self).

keys(self)
values(self)
items(self)
__cmp__(self, dict_)
__contains__(self, item)
__iter__(self)
__unicode__(self)
calcDGis(self)

Calculate the transformed Gibbs energy of formation of specie with given pH and ionic strength using formula given by Goldberg and Tewari, 1991

Equation 4.5-6 in Alberty’s book

Returns

DG_is for the enzyme

Return type

float

calcDGsp(self)

Calculate the transformed Gibbs energy of formation of specie with given pH and ionic strength using formula given by Goldberg and Tewari, 1991

Equation 4.4-10 in Alberty’s book

Returns

DG_sp for the enzyme

Return type

float

calc_potential(self)

Calculate the binding polynomial of a specie, with pK values

Returns

The potential of the enzyme

Return type

float

get_pka(self)

Get the pKas of the enzyme

Returns

The pKas of the enzyme

Return type

list(float)

_calc_pka(self, pka, sigmanusq)
calcDGspA(self)

Calculates deltaGf, charge and nH of the specie when it is at least protonated state based on MFAToolkit compound data for the pKa values within the range considered (MIN_pH to MAX_pH).

These values are used as the starting point for Alberty’s calculations.

Returns

deltaGspA, sp_charge and sp_nH

Return type

tuple(float, float, int)

pytfa.thermo.calcDGtpt_rhs(reaction, compartmentsData, thermo_units)

Calculates the RHS of the deltaG constraint, i.e. the sum of the non-concentration terms

Parameters
  • reaction (cobra.thermo.reaction.Reaction) – The reaction to compute the data for

  • compartmentsData (dict(float)) – Data of the compartments of the cobra_model

  • thermo_units (str) – The thermodynamic database of the cobra_model

Returns

deltaG_tpt and the breakdown of deltaG_tpt

Return type

tuple(float, dict(float))

Example:

ATP Synthase reaction:

reaction = cpd00008 + 4 cpd00067 + cpd00009 <=> cpd00002 + 3 cpd00067 + cpd00001
compartments =  'c'       'e'        'c'           'c'         'c'         'c'
If there are any metabolites with unknown energies then returns

(0, None).

pytfa.thermo.calcDGR_cues(reaction, reaction_cues_data)

Calculates the deltaG reaction and error of the reaction using the constituent structural cues changes and returns also the error if any.

Parameters
  • reaction (cobra.thermo.reaction.Reaction) – The reaction to compute deltaG for

  • reaction_cues_data (dict) –

Returns

deltaGR, error on deltaGR, the cues in the reaction (keys of the dictionnary) and their indices (values of the dictionnary), and the error code if any.

If everything went right, the error code is an empty string

Return type

tuple(float, float, dict(float), str)

pytfa.thermo.get_debye_huckel_b(T)

The Debye-Huckel A and B do depend on the temperature As for now though they are returned as a constant (value at 298.15K)

Parameters

T – Temperature in Kelvin

Returns

Debye_Huckel_B

pytfa.thermo.check_reaction_balance(reaction, proton=None)

Check the balance of a reaction, and eventually add protons to balance it

Parameters
  • reaction (cobra.thermo.reaction.Reaction) – The reaction to check the balance of.

  • proton (cobra.thermo.metabolite.Metabolite) – Optional The proton to add to the reaction to balance it.

Returns

The balance of the reaction :

  • drain flux

  • missing structures

  • balanced

  • N protons added to reactants with N a float

  • N protons added to products with N a float

  • missing atoms

Return type

str

If proton is provided, this function will try to balance the equation with it, and return the result.

If no proton is provided, this function will not try to balance the equation.

Warning

This function does not verify if proton is in the correct compartment, so make sure you provide the proton belonging to the correct compartment !

pytfa.thermo.check_transport_reaction(reaction)

Check if a reaction is a transport reaction

Parameters

reaction (cobra.thermo.reaction.Reaction) – The reaction to check

Returns

Whether the reaction is a transport reaction or not

Return type

bool

A transport reaction is defined as a reaction that has the same compound as a reactant and a product. We can distinguish them thanks to their seed_ids. If they have one If not, use met_ids and check if they are the same, minus compartment

pytfa.thermo.find_transported_mets(reaction)

Get a list of the transported metabolites of the reaction.

Parameters

reaction (cobra.thermo.reaction.Reaction) – The reaction to get the transported metabolites of

Returns

A dictionnary of the transported metabolites. The index corresponds to the seed_id of the transported enzyme

The value is a dictionnairy with the following values:

  • coeff (float):

    The stoechiomectric coefficient of the enzyme

  • reactant (cobra.thermo.enzyme.Metabolite):

    The reactant of the reaction corresponding to the transported enzyme

  • product (cobra.thermo.enzyme.Metabolite):

    The product of the reaction corresponding to the transported enzyme

A transported enzyme is defined as a enzyme which is a product and a reactant of a reaction. We can distinguish them thanks to their seed_ids.

pytfa.thermo.get_reaction_compartment(reaction)

Get the compartment of a reaction to then prepare it for conversion.

class pytfa.thermo.SimultaneousUse(reaction, expr, **kwargs)

Bases: ReactionConstraint

Class to represent a simultaneous use constraint on reaction variables Looks like: SU_rxn: FU_rxn + BU_rxn <= 1

prefix = SU_
class pytfa.thermo.NegativeDeltaG(reaction, expr, **kwargs)

Bases: ReactionConstraint

Class to represent thermodynamics constraints.

G: - DGR_rxn + DGoRerr_Rxn + RT * StoichCoefProd1 * LC_prod1
  • RT * StoichCoefProd2 * LC_prod2

  • RT * StoichCoefSub1 * LC_subs1

  • RT * StoichCoefSub2 * LC_subs2

= 0

prefix = G_
class pytfa.thermo.BackwardDeltaGCoupling(reaction, expr, **kwargs)

Bases: ReactionConstraint

Class to represent thermodynamics coupling: DeltaG of reactions has to be DGR > 0 for the reaction to proceed backwards Looks like: BU_rxn: 1000 BU_rxn - DGR_rxn < 1000

prefix = BU_
class pytfa.thermo.ForwardDeltaGCoupling(reaction, expr, **kwargs)

Bases: ReactionConstraint

Class to represent thermodynamics coupling: DeltaG of reactions has to be DGR < 0 for the reaction to proceed forwards Looks like: FU_rxn: 1000 FU_rxn + DGR_rxn < 1000

prefix = FU_
class pytfa.thermo.BackwardDirectionCoupling(reaction, expr, **kwargs)

Bases: ReactionConstraint

Class to represent a backward directionality coupling with thermodynamics on reaction variables Looks like : UR_rxn: R_rxn - M RU_rxn < 0

prefix = UR_
class pytfa.thermo.ForwardDirectionCoupling(reaction, expr, **kwargs)

Bases: ReactionConstraint

Class to represent a forward directionality coupling with thermodynamics on reaction variables Looks like : UF_rxn: F_rxn - M FU_rxn < 0

prefix = UF_
class pytfa.thermo.ReactionConstraint(reaction, expr, **kwargs)

Bases: GenericConstraint

Class to represent a variable attached to a reaction

prefix = RC_
property reaction(self)
property id(self)

for cobra.thermo.DictList compatibility :return:

property model(self)
class pytfa.thermo.MetaboliteConstraint(metabolite, expr, **kwargs)

Bases: GenericConstraint

Class to represent a variable attached to a enzyme

prefix = MC_
property metabolite(self)
property id(self)

for cobra.thermo.DictList compatibility :return:

property model(self)
class pytfa.thermo.DisplacementCoupling(reaction, expr, **kwargs)

Bases: ReactionConstraint

Class to represent the coupling to the thermodynamic displacement Looks like: Ln(Gamma) - (1/RT)*DGR_rxn = 0

prefix = DC_
class pytfa.thermo.ThermoDisplacement(reaction, **kwargs)

Bases: ReactionVariable

Class to represent the thermodynamic displacement of a reaction Gamma = -DeltaG/RT

prefix = LnGamma_
class pytfa.thermo.DeltaGstd(reaction, **kwargs)

Bases: ReactionVariable

Class to represent a DeltaG^o (naught) - standard conditions

prefix = DGo_
class pytfa.thermo.DeltaG(reaction, **kwargs)

Bases: ReactionVariable

Class to represent a DeltaG

prefix = DG_
class pytfa.thermo.ForwardUseVariable(reaction, **kwargs)

Bases: ReactionVariable, BinaryVariable

Class to represent a forward use variable, a type of binary variable used to enforce forward directionality in reaction net fluxes

prefix = FU_
class pytfa.thermo.BackwardUseVariable(reaction, **kwargs)

Bases: ReactionVariable, BinaryVariable

Class to represent a backward use variable, a type of binary variable used to enforce backward directionality in reaction net fluxes

prefix = BU_
class pytfa.thermo.LogConcentration(metabolite, **kwargs)

Bases: MetaboliteVariable

Class to represent a log concentration of a enzyme

prefix = LC_
class pytfa.thermo.ReactionVariable(reaction, **kwargs)

Bases: GenericVariable

Class to represent a variable attached to a reaction

prefix = RV_
property reaction(self)
property id(self)

for cobra.thermo.DictList compatibility :return:

property model(self)
class pytfa.thermo.MetaboliteVariable(metabolite, **kwargs)

Bases: GenericVariable

Class to represent a variable attached to a enzyme

prefix = MV_
property metabolite(self)
property id(self)

for cobra.thermo.DictList compatibility :return:

property model(self)
pytfa.thermo.get_bistream_logger(name)

Sets up a logger that outputs INFO+ messages on stdout and DEBUG+ messages in the log file

Parameters

name – a class __name__ attribute

Returns

pytfa.thermo.BIGM[source]
pytfa.thermo.BIGM_THERMO[source]
pytfa.thermo.BIGM_DG[source]
pytfa.thermo.BIGM_P[source]
pytfa.thermo.EPSILON[source]
pytfa.thermo.MAX_STOICH = 10[source]
class pytfa.thermo.ThermoModel(thermo_data=None, model=Model(), name=None, temperature=std.TEMPERATURE_0, min_ph=std.MIN_PH, max_ph=std.MAX_PH)[source]

Bases: pytfa.core.model.LCSBModel, cobra.Model

A class representing a cobra_model with thermodynamics information

_init_thermo(self)
normalize_reactions(self)

Find reactions with important stoichiometry and normalizes them :return:

_prepare_metabolite(self, met)
Parameters

met

Returns

_prepare_reaction(self, reaction, null_error_override=2)
Parameters
  • reaction

  • null_error_override – overrides DeltaG when it is 0 to allow flexibility. 2kcal/mol is standard in estimation frameworks like GCM.

Returns

prepare(self, null_error_override=2)

Prepares a COBRA toolbox cobra_model for TFBA analysis by doing the following:

  1. checks if a reaction is a transport reaction

  2. checks the ReactionDB for Gibbs energies of formation of metabolites

  3. computes the Gibbs energies of reactions

Parameters

null_error_override – overrides DeltaG when it is 0 to allow flexibility. 2kcal/mol is standard in estimation frameworks like GCM.

_convert_metabolite(self, met, add_potentials, verbose)

Given a enzyme, proceeds to create the necessary variables and constraints for thermodynamics-based modeling

Parameters

met

Returns

_convert_reaction(self, rxn, add_potentials, add_displacement, verbose)
Parameters
  • rxn

  • add_potentials

  • add_displacement

  • verbose

Returns

convert(self, add_potentials=False, add_displacement=False, verbose=True)

Converts a cobra_model into a tFBA ready cobra_model by adding the thermodynamic constraints required

Warning

This function requires you to have already called prepare(), otherwise it will raise an Exception !

print_info(self, specific=False)

Print information and counts for the cobra_model :return:

__deepcopy__(self, memo)
Parameters

memo

Returns

copy(self)

Needs to be reimplemented, as our objects have complicated hierarchy :return:

class pytfa.thermo.MetaboliteThermo(metData, pH, ionicStr, temperature=std.TEMPERATURE_0, min_ph=std.MIN_PH, max_ph=std.MAX_PH, debye_huckel_b=std.DEBYE_HUCKEL_B_0, thermo_unit='kJ/mol', debug=False)

A class representing the thermodynamic values of a enzyme

Parameters
  • metData (dict) – A dictionary containing the values for the enzyme, from the thermodynamic database

  • pH (float) – The pH of the enzyme’s compartment

  • ionicStr (float) – The ionic strength of the enzyme’s compartment

  • temperature

  • min_ph

  • max_ph

  • debye_huckel_b

  • thermo_unit (string) – The unit used in metData’s values

  • debug (bool) – Optional If set to True, some debugging values will be printed. This is only useful for development or debugging purposes.

Note

The values are automatically computed on class creation. Usually you don’t have to call any methods defined by this class, but only to access the attributes you need.

The available attributes are :

Since the reactions expose similar values through a dictionnary, it is better to access the attributes aforementionned of this class as if it was a dictionnary : enzyme.thermo['pH'].

__getitem__(self, key)
__repr__(self)

Return repr(self).

keys(self)
values(self)
items(self)
__cmp__(self, dict_)
__contains__(self, item)
__iter__(self)
__unicode__(self)
calcDGis(self)

Calculate the transformed Gibbs energy of formation of specie with given pH and ionic strength using formula given by Goldberg and Tewari, 1991

Equation 4.5-6 in Alberty’s book

Returns

DG_is for the enzyme

Return type

float

calcDGsp(self)

Calculate the transformed Gibbs energy of formation of specie with given pH and ionic strength using formula given by Goldberg and Tewari, 1991

Equation 4.4-10 in Alberty’s book

Returns

DG_sp for the enzyme

Return type

float

calc_potential(self)

Calculate the binding polynomial of a specie, with pK values

Returns

The potential of the enzyme

Return type

float

get_pka(self)

Get the pKas of the enzyme

Returns

The pKas of the enzyme

Return type

list(float)

_calc_pka(self, pka, sigmanusq)
calcDGspA(self)

Calculates deltaGf, charge and nH of the specie when it is at least protonated state based on MFAToolkit compound data for the pKa values within the range considered (MIN_pH to MAX_pH).

These values are used as the starting point for Alberty’s calculations.

Returns

deltaGspA, sp_charge and sp_nH

Return type

tuple(float, float, int)