CycleBreaker
This module implements breaking thermodynamically infeasible cycles (TICs, here called cycles) using EFM enumeration and MILP.
- pycomo.helper.cyclebreaker.add_cycle_breaker_constraint(com_model, cycle, eps=None, no_enforce_activity_constraint=True, name=None)
Adds a sum constraint for a given cycle. The constraint specifies, that the reactions of this cycle cannot be active at the same time. This is implemented by binary variables for reaction activity. The constraint is set so the sum of these binary variables must be lower than the number of reactions in the cycle (thus at least one is inactive).
- Parameters:
com_model – The model to add the constraint
cycle – The cycle to form the constraint for. A dictionairy of reaction ids and flux values.
eps – A small, greater than 0 threshold, above which the reaction is considered active (default is solver tolerance)
- pycomo.helper.cyclebreaker.add_cycle_breaker_constraints_for_all_cycles(com_model, cycle_df, eps=None, no_enforce_activity_constraint=True)
Adds sum constraint for all cycles in the dataframe. The constraints specify, that the reactions of a cycle cannot be active at the same time. This is implemented by binary variables for reaction activity. The constraint is set so the sum of these binary variables must be lower than the number of reactions in the cycle (thus at least one is inactive).
- Parameters:
com_model – The model to add the constraints
cycle_df – A dataframe of reaction ids (columns) and cycles (rows) with corresponding flux values as cell values
eps – A small, greater than 0 threshold, above which the reaction is considered active (default is solver tolerance)
- pycomo.helper.cyclebreaker.get_free_cycle_constraint_base_name(com_model, basename='cb_cycle')
Create a name for cycle constraints in the form of cb_cycle_[number] with [number] being the lowest integer where this name is not yet in the model constraints.
- Parameters:
com_model – Community model where the constraint should be added
- Returns:
A name that is not yet used in the model
- pycomo.helper.cyclebreaker.get_free_cycle_constraint_name(com_model)
Create a name for cycle constraints in the form of cb_cycle_[number] with [number] being the lowest integer where this name is not yet in the model constraints.
- Parameters:
com_model – Community model where the constraint should be added
- Returns:
A name that is not yet used in the model
- pycomo.helper.cyclebreaker.prepare_model_for_cycle_enumeration(com_model)
Prepare a community model for cycle enumeration.
- Parameters:
com_model – the community model
- Returns:
A prepared model (simplified and bound-free structure removed)
- pycomo.helper.cyclebreaker.remove_blocked_reactions(model)
Finds and removes blocked reactions.
- Parameters:
model – model where blocked reactions should be removed
- Returns:
model without blocked reactions