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¶
Helper class that provides a standard way to create an ABC using |
|
A class representing the thermodynamic values of a enzyme |
|
Class to represent a simultaneous use constraint on reaction variables |
|
Class to represent thermodynamics constraints. |
|
Class to represent thermodynamics coupling: DeltaG of reactions has to be |
|
Class to represent thermodynamics coupling: DeltaG of reactions has to be |
|
Class to represent a backward directionality coupling with thermodynamics on |
|
Class to represent a forward directionality coupling with thermodynamics on |
|
Class to represent a variable attached to a reaction |
|
Class to represent a variable attached to a enzyme |
|
Class to represent the coupling to the thermodynamic displacement |
|
Class to represent a forbidden net flux directionality profile |
|
Class to rep couple DG to potential variable |
|
Class to represent the thermodynamic displacement of a reaction |
|
Class to represent a DeltaG^o (naught) - standard conditions |
|
Class to represent a DeltaG |
|
Class to represent a forward use variable, a type of binary variable used to |
|
Class to represent a backward use variable, a type of binary variable used |
|
Class to represent a log concentration of a enzyme |
|
Class to represent a variable attached to a reaction |
|
Class to represent a variable attached to a enzyme |
|
Class to represent a DeltaG |
|
Class to represent a DeltaGstf of formation |
|
A class representing a cobra_model with thermodynamics information |
|
A class representing the thermodynamic values of a enzyme |
6.1.1.6.2.2. Functions¶
|
Calculates the RHS of the deltaG constraint, i.e. the sum of the |
|
Calculates the deltaG reaction and error of the reaction using the |
The Debye-Huckel A and B do depend on the temperature |
|
|
Check the balance of a reaction, and eventually add protons to balance |
|
Check if a reaction is a transport reaction |
|
Get a list of the transported metabolites of the reaction. |
|
Sets up a logger that outputs INFO+ messages on stdout and DEBUG+ messages |
6.1.1.6.2.3. Attributes¶
- class pytfa.thermo.LCSBModel(model, name, sloppy=False)¶
Bases:
abc.ABC
Helper class that provides a standard way to create an ABC using inheritance.
- abstract copy(self)¶
Needs to be reimplemented, as our objects have complicated hierarchy :return:
- print_info(self)¶
Print information and counts for the cobra_model :return:
- add_variable(self, kind, hook, queue=False, **kwargs)¶
Add a new variable to a COBRApy cobra_model.
- Parameters
kind –
hook (string,cobra.Reaction) – Either a string representing the name of the variable to add to the cobra_model, or a reaction object if the kind allows it
- Returns
The created variable
- Return type
- add_constraint(self, kind, hook, expr, queue=False, **kwargs)¶
Add a new constraint to a COBRApy cobra_model
- Parameters
kind –
hook (string,cobra.Reaction) – Either a string representing the name of the variable to add to the cobra_model, or a reaction object if the kind allows it
expr (sympy.thermo.expr.Expr) – The expression of the constraint
- Returns
The created constraint
- Return type
- remove_reactions(self, reactions, remove_orphans=False)¶
- remove_metabolites(self, metabolite_list, destructive=False)¶
- _remove_associated_consvar(self, all_cons_subclasses, all_var_subclasses, collection)¶
Removes both the constraints and variables associated to an element, as long as it was used as a hook in the cons/var declaration. For example, upon removing a reaction, also removes its associated deltaG variables and coupling constraints
- remove_variable(self, var)¶
Removes a variable
- Parameters
var –
- Returns
- remove_constraint(self, cons)¶
Removes a constraint
- Parameters
cons –
- Returns
- _push_queue(self)¶
updates the constraints and variables of the model with what’s in the queue :return:
- regenerate_variables(self)¶
Generates references to the cobra_model’s constraints in self._var_dict as tab-searchable attributes of the thermo cobra_model :return:
- regenerate_constraints(self)¶
Generates references to the cobra_model’s constraints in self._cons_dict as tab-searchable attributes of the thermo cobra_model :return:
- repair(self)¶
Updates references to variables and constraints :return:
- get_primal(self, vartype, index_by_reactions=False)¶
Returns the primal value of the cobra_model for variables of a given type
- Parameters
index_by_reactions –
vartype – Class of variable. Ex: pytfa.optim.variables.ThermoDisplacement
- Returns
- get_solution(self)¶
Overrides the cobra.thermo.solution method, to also get the supplementary variables we added to the cobra_model
solution.fluxes
in cobrapy is a transformed version of the solver output, as it actually calculates the _net_ flux of each reaction by substracting the reverse variable value to the forward variable value. This should be used anytime one needs the actual flux valuesolution.raw
is a clear copy of the solver output. From there one can access the value at solution for all the variables of the problem. However, looking for a reaction ID in there will only give the _forward_ flux. This should be used for any other variable than fluxes.solution.values
yields variables multiplied by their scaling factor (1 by default). Useful if you operated scaling on your equations for numerical reasons. This does _not_ include fluxes
- Returns
- optimize(self, objective_sense=None, **kwargs)¶
Call the Model.optimize function (which really is but an interface to the solver’s. Catches SolverError in the case of no solutions. Passes down supplementary keyword arguments (see cobra.thermo.Model.optimize) :type objective_sense: ‘min’ or ‘max’
- slim_optimize(self, *args, **kwargs)¶
- get_constraints_of_type(self, constraint_type)¶
Convenience function that takes as input a constraint class and returns all its instances within the cobra_model
- Parameters
constraint_type –
- Returns
- get_variables_of_type(self, variable_type)¶
Convenience function that takes as input a variable class and returns all its instances within the cobra_model
- Parameters
variable_type –
- Returns
- 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
- 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
- calc_potential(self)¶
Calculate the binding polynomial of a specie, with pK values
- Returns
The potential of the enzyme
- Return type
- _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.
- 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
- Returns
deltaG_tpt and the breakdown of deltaG_tpt
- Return type
- 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
- 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 :
- Return type
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 theproton
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
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
- coeff (
- reactant (
cobra.thermo.enzyme.Metabolite
): The reactant of the reaction corresponding to the transported enzyme
- reactant (
- product (
cobra.thermo.enzyme.Metabolite
): The product of the reaction corresponding to the transported enzyme
- product (
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.
- 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.PotentialConstraint(metabolite, expr, **kwargs)¶
Bases:
MetaboliteConstraint
Class to represent a forbidden net flux directionality profile Looks like: DG_rxn_1 + DG_rxn_2 + … + DG_rxn_n == 0
- prefix = PC_¶
- class pytfa.thermo.PotentialCoupling(reaction, expr, **kwargs)¶
Bases:
ReactionConstraint
Class to rep couple DG to potential variable
- prefix = PPC_¶
- 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)¶
- class pytfa.thermo.ThermoPotential(metabolite, **kwargs)¶
Bases:
MetaboliteVariable
Class to represent a DeltaG
- prefix = P_¶
- class pytfa.thermo.DeltaGFormstd(metabolite, **kwargs)¶
Bases:
MetaboliteVariable
Class to represent a DeltaGstf of formation
- prefix = DGoF_¶
- 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
- 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)¶
- prepare(self)¶
Prepares a COBRA toolbox cobra_model for TFBA analysis by doing the following:
checks if a reaction is a transport reaction
checks the ReactionDB for Gibbs energies of formation of metabolites
computes the Gibbs energies of reactions
- _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
- 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
- calc_potential(self)¶
Calculate the binding polynomial of a specie, with pK values
- Returns
The potential of the enzyme
- Return type
- _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.