6.1.1.2. pytfa.core

6.1.1.2.1. Submodules

6.1.1.2.2. Package Contents

6.1.1.2.2.1. Classes

LCSBModel

Helper class that provides a standard way to create an ABC using

class pytfa.core.LCSBModel(model, name, sloppy=False)[source]

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

optlang.interface.Variable

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

optlang.interface.Constraint

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 value

  • solution.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