6.1.1.4.1.8. pytfa.optim.variables

Variable declarations

6.1.1.4.1.8.1. Module Contents

6.1.1.4.1.8.1.1. Classes

GenericVariable

Class to represent a generic variable. The purpose is that the interface

ModelVariable

Class to represent a variable attached to the model

GeneVariable

Class to represent a gene variable

BinaryVariable

Class to represent a generic binary variable

ReactionVariable

Class to represent a variable attached to a reaction

MetaboliteVariable

Class to represent a variable attached to a enzyme

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

ForwardBackwardUseVariable

Class to represent a type of binary variable used to tell whether the

LogConcentration

Class to represent a log concentration of a enzyme

DeltaGErr

Class to represent a DeltaGErr

DeltaG

Class to represent a DeltaG

DeltaGstd

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

ThermoDisplacement

Class to represent the thermodynamic displacement of a reaction

PosSlackVariable

Class to represent a positive slack variable for relaxation problems

NegSlackVariable

Class to represent a negative slack variable for relaxation problems

PosSlackLC

Class to represent a variable attached to a enzyme

NegSlackLC

Class to represent a variable attached to a enzyme

LinearizationVariable

Class to represent a product A*B when performing linearization of the

6.1.1.4.1.8.1.2. Functions

get_binary_type()

FIX : We enforce type to be integer instead of binary, else optlang does

6.1.1.4.1.8.1.3. Attributes

op_replace_dict

pytfa.op_replace_dict
class pytfa.GenericVariable(id_='', model=None, hook=None, queue=False, scaling_factor=1, **kwargs)

Class to represent a generic variable. The purpose is that the interface is instantiated on initialization, to follow the type of interface used by the problem, and avoid incompatibilities in optlang

Attributes:

id

Used for DictList comprehension. Usually points back at a

enzyme or reaction id for ease of linking. Should be unique given a variable type. :name: Should be a concatenation of the id and a prefix that is specific to the variable type. will be used to address the variable at the solver level, and hence should be unique in the whole cobra_model :cobra_model: the cobra_model hook. :variable: links directly to the cobra_model representation of tbe variable

prefix
property __attrname__(self)

Name the attribute the instances will have Example: GenericVariable -> generic_variable :return:

get_interface(self, queue)

Called upon completion of __init__, initializes the value of self.var, which is returned upon call, and stores the actual interfaced variable.

Returns

instance of Variable from the problem

make_name(self)
Needs to be overridden by the subclass, concats the id with a

prefix

Returns

None

property name(self)
property id(self)

for cobra.thermo.DictList compatibility :return:

property variable(self)
property scaling_factor(self)
property unscaled(self)

If the scaling factor of quantity X is a, it is represented by the variable X_hat = X/a. This returns X = a.X_hat Useful for nondimensionalisation of variables and constraints

Returns

The variable divided by its scaling factor

property value(self)
property unscaled_value(self)
property model(self)
property type(self)
test_consistency(self, other)

Tests whether a candidate to an operation is of the right type and is from the same problem

Parameters

other – an object

Returns

None

get_operand(self, other)

For operations, choose if the operand is a GenericVariable, in which we return its optlang variable, or something else (presumably a numeric) and we let optlang decide what to do

Parameters

other

Returns

__add__(self, other)

Adding either two variables together or a variable and a numeric results in a new variable :param other: :return: a new Generic Variable

__radd__(self, other)

Take priority on symmetric arithmetic operation :param other: :return:

__sub__(self, other)

Substracting either two variables together or a variable and a numeric results in a new variable :param other: :return: a new Generic Variable

__rsub__(self, other)

Take priority on symmetric arithmetic operation :param other: :return:

__mul__(self, other)

Multiplying either two variables together or a variable and a numeric results in a new variable :param other: :return: a new Generic Variable

__rmul__(self, other)

Take priority on symmetric arithmetic operation :param other: :return:

__truediv__(self, other)

Dividing either two variables together or a variable and a numeric results in a new variable :param other: :return: a new Generic Variable

__rtruediv__(self, other)

Take priority on symmetric arithmetic operation :param other: :return:

make_result(self, new_variable)

Returns a Sympy expression :param new_variable: :return:

__repr__(self)

Return repr(self).

pytfa.get_binary_type()

FIX : We enforce type to be integer instead of binary, else optlang does not allow to set the binary variable bounds to anything other than (0,1) You might want to set it at (0,0) to enforce directionality for example

class pytfa.ModelVariable(model, id_, **kwargs)

Bases: GenericVariable

Class to represent a variable attached to the model

prefix = MODV_
class pytfa.GeneVariable(gene, **kwargs)

Bases: GenericVariable

Class to represent a gene variable

prefix = GV_
property gene(self)
property id(self)

for cobra.thermo.DictList compatibility :return:

property model(self)
class pytfa.BinaryVariable(id_, model, **kwargs)

Bases: GenericVariable

Class to represent a generic binary variable

prefix = B_
class pytfa.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.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.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.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.ForwardBackwardUseVariable(reaction, **kwargs)

Bases: ReactionVariable, BinaryVariable

Class to represent a type of binary variable used to tell whether the reaction is active or not such that:

FU + BU + BFUSE = 1

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

Bases: MetaboliteVariable

Class to represent a log concentration of a enzyme

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

Bases: ReactionVariable

Class to represent a DeltaGErr

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

Bases: ReactionVariable

Class to represent a DeltaG

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

Bases: ReactionVariable

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

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

Bases: ReactionVariable

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

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

Bases: ReactionVariable

Class to represent a positive slack variable for relaxation problems

prefix = PosSlack_
class pytfa.NegSlackVariable(reaction, **kwargs)

Bases: ReactionVariable

Class to represent a negative slack variable for relaxation problems

prefix = NegSlack_
class pytfa.PosSlackLC(metabolite, **kwargs)

Bases: MetaboliteVariable

Class to represent a variable attached to a enzyme

prefix = PosSlackLC_
class pytfa.NegSlackLC(metabolite, **kwargs)

Bases: MetaboliteVariable

Class to represent a variable attached to a enzyme

prefix = NegSlackLC_
class pytfa.LinearizationVariable(model, id_, **kwargs)

Bases: ModelVariable

Class to represent a product A*B when performing linearization of the model

prefix = LZ_