BioOpt Classes (API)

Model

class model.Bounds(lb=-inf, ub=inf)

Bases: object

Bounds holds description of reactions constraints

Parameters:
  • lb – Minimal amount of of flux that can go through a reaction (Lower bound). Negative numbers denote reverse direction.
  • ub – Maximal amount of of flux that can go through a reaction (Upper bound). Negative numbers denote reverse direction.
Returns:

Bounds

copy()

Create a deep copy of current object

Return type:Bounds
direction

Suggested reaction direction. If lower bound is negative the reaction is suggested to be reversible. Otherwise irreversibility is implied. This is only a suggestion to Reaction class and this suggestion can be broken by enabling reaction reversibility through Reaction.direction

Return type:Direction
static inf()

Returns infinity

Returns:float
lb

Minimal amount of of flux that can go through a reaction (Lower bound). Negative numbers denote reverse direction.

lb_is_finite

Returns inf False if lower bound is -infinity or +infinity

ub

Maximal amount of of flux that can go through a reaction (Upper bound). Negative numbers denote reverse direction.

ub_is_finite

Returns inf False if upper bound is -infinity or +infinity

class model.Direction(type)

Bases: object

Describe reaction directionality. Don’t use this class directly! Use factory constructors Direction.forward() and Direction.reversible()

Parameters:type – f - Irreversible (f orward); r - Reversible (r eversible)
Returns:Direction
copy()

Create a deep copy of current object

Return type:Direction
static forward()

Returns irreversible directionality descriptor singleton of type Direction

Returns:Direction
static reversible()

Returns reversible directionality descriptor singleton of type Direction

Returns:Direction
class model.Metabolite(name, boundary=False)

Bases: object

Metabolite holds information about metabolite. Currently only supported information is metabolite name and whether metabolite satisfies boundary condition (imported/exported)

Parameters:
  • name – Metabolite name. Metabolite name should be a non-empty string.
  • boundary – Boundary condition (imported/exported - True; otherwise - false)
Returns:

Metabolite

boundary

Boundary condition (imported/exported - True; otherwise - false)

copy()

Create a deep copy of current object

Return type:Metabolite
name

Metabolite name. Metabolite name should be a non-empty string.

order_boundary

Priority of displaying this metabolite. Metabolites with higher priority (lower numbers) are displayed earlier in “-External Metabolites” section

class model.Model

Bases: object

BioOpt model is a main class in package. It contains list of reactions in the model and other additional information.

static commune(models, model_prefix='ML{0:04d}_', env_prefix='ENV_', block=[])

Merge two or more models into community model. Community model allows organisms represented by models to share metabolites. Briefly, the algorithm first appends reaction and metabolite names in original models with ML****_ prefix. Then for every metabolite exported in original models boundary condition is set to False and new export reaction is created. This export reactions allows metabolites to travel from joined models into shared environment and back. This setup allows organisms to exchange metabolites through common environment.

Originally this merging framework was described in “OptCom: A Multi-Level Optimization Framework for the Metabolic Modeling and Analysis of Microbial Communities” by Ali R. Zomorrodi and Costas D. Maranas.

Parameters:
  • models – List of Model to join
  • model_prefix – Model prefix, Model prefix is added to all reaction names to avoid name collision in joined model.
  • env_prefix – Prefix of metabolites in shared environment.
  • block – List of names (in original models) of metabolites which should be not allowed to be exchanged between organisms. An obvious example of such metabolite is biomass.
Return type:

Model

design_objective

Design optimization target (i.e. Ethanol)

Return type:list of MathExpression
find_boundary_metabolites()

Searches for imported/exported metabolites

Return type:list of Metabolite
find_boundary_reactions()

Searches for reactions exporting or importing metabolites

Return type:list of Reaction
find_metabolite(names=None, regex=False)

Searches model for metabolites with specified names (patterns). If multiple metabolites are found this function returns only the first one.

Parameters:
  • names – name or list of names of metabolites
  • regex – If True names argument is assumed to be a regular expression
Return type:

Metabolite

find_metabolites(names=None, regex=False)

Searches model for metabolites with specified names (patterns). This function is capable of returning multiple metabolites.

Parameters:
  • names – name or list of names of metabolites
  • regex – If True names argument is assumed to be a regular expression
Return type:

list of Metabolite

find_reaction(names=None, regex=False)

Searches model for reactions with specified names (patterns). If multiple reactions are found this function returns only the first one.

Parameters:
  • names – name or list of names of reactions
  • regex – If True names argument is assumed to be a regular expression
Return type:

Reaction

find_reactions(names=None, regex=False)

Searches model for reactions with specified names (patterns). This function is capable of returning multiple reactions.

Parameters:
  • names – name or list of names of reactions
  • regex – If True names argument is assumed to be a regular expression
Return type:

list of Reaction

objective

Optimization target (i.e. Biomass)

Return type:class:MathExpression
reactions

List of reactions in the model

Return type:list of Reaction
save(path=None, inf=1000)

Save model on disc in bioopt format

Parameters:
  • path – The name or full pathname of the file where the BioOpt model is to be written.
  • inf – Number which would be used for constraints with infinite bounds
unify_references()

Find metabolite with identical names which are stored as different instances and unify instances.

class model.Operation(operation, is_unary)

Bases: object

Object describing operation type. Don’t use this class directly! Instead use factory constructors:

Parameters:
  • operation – String describing the operation (binary operations: +-/*, unary operations: -)
  • is_unary – Describes what type of operation is created. Unary operations support only one argument, while binary support two.
Returns:

Operation

static addition()

Returns addition operation singleton

Return type:Operation
static division()

Returns division operation singleton

Return type:Operation
is_unary

Is operation unary. True - unary; otherwise False :return: bool

static multiplication()

Returns multiplication operation singleton

Return type:Operation
static negation()

Returns negation operation (unary) singleton

Return type:Operation
priority

Operation priority. Operations with higher priority (lower numbers) are executed before lower priority operations

Return type:Operation
static subtraction()

Returns subtraction operation singleton

Return type:Operation
symbol

Short description of operation

    • Addition
    • Subtraction
  • / Division
    • Multiplication
    • Negation
Return type:Operation
class model.Reaction(name, reactants=, products=, direction=None, bounds=None)

Bases: object

Reaction class holds information about reaction including reaction name, members, directionality and constraints

Parameters:
  • name – Reaction name. Reaction name should be non-empty string
  • reactants – Reaction left-hand-side. Object of class ReactionMemberList.
  • products – Reaction right-hand-side. Object of class ReactionMemberList.
  • direction – Reaction direction. Object of class Direction.
  • bounds – Reaction constraints. Object of class Bounds.
Return type:

Reaction

bounds

Reaction constraints

Return type:Bounds
bounds_reset()

Reset bounds to predefined default. For reversible reaction defaults bounds are [-inf, +inf]. For forward reactions it is [0, +inf]

copy()

Create a deep copy of current object

Return type:Reaction
direction

Reaction direction

Return type:Direction
find_effective_bounds()

Find effective bounds. For example if reaction is described as irreversible but constraints are [-10, 10] the effective bounds would be [0, 10]

Return type:Bounds
name

Reaction name

products

Products

Return type:ReactionMemberList
reactants

Reactants

Return type:ReactionMemberList
reverse()

Reverse reactions. This functions change reactants and products places and inverses constraints so that reaction would go other way

class model.ReactionMember(metabolite, coefficient=1)

Bases: object

Bounds is a wrapper for Metabolite object when used in reaction reactants or products. It contains reference to the metabolite itself and to it’s coefficient in the reaction.

Parameters:
  • metabolite – Reference to Metabolite object
  • coefficient – Multiplier associated with metabolite
Returns:

ReactionMember

coefficient

Multiplier associated with metabolite

copy()

Create a deep copy of current object

Return type:ReactionMember
metabolite

Reference to metabolite

Return type:Metabolite
class model.ReactionMemberList

Bases: list

ReactionMemberList is a list of ReactionMember instances. ReactionMemberList inherits from list all the usual functions to manage a list

copy()

Create a deep copy of current object

Return type:ReactionMemberList
find_member(name)

Find metabolite by name in the list

Return type:ReactionMember

Converter

class converter.Bioopt2CobraPyConverter(description=None)

Bioopt model object to COBRApy model object converter. More details on COBRApy library can be found online

Return type:Bioopt2COBRApyConverter
convert(bioopt_model)

Convert BioOpt model to COBRApy model instance

Parameters:bioopt_model – BioOpt model of type :class;`model.Model`
Return type:cobra.Model
class converter.Bioopt2SbmlConverter(level=2, version=3, inf=1000, reaction_id='auto', metabolite_id='auto', compartment_id='auto', compartment_suffix=True, compartment_pattern='_(\w+)$', simulate_boundary=False, metabolite_map={})

Bioopt model object to libSBML document object converter. More details on SBML specification can be found online

Parameters:
  • level – SBML level from 1 to 3 (default: 2)
  • version – SBML version number (default: 3). Check SBML specification for details
  • inf – A number to substitute __infinity__ values. SBML doesn’t have number __infinity__ so everywhere infinity is used in BioOpt it will be replaced with this number (default: 1000)
  • reaction_id – Reaction id pattern. “name” - reaction name will be used as id. “auto” - an auto-incremental “R_XXXX” value will be used for reaction id (default: “auto”)
  • metabolite_id – Metabolite id pattern. “name” - metabolite name will be used as id. “auto” - an auto-incremental “M_XXXX” value will be used for metabolite id (default: “auto”)
  • compartment_id – Compartment id pattern. “name” - compartment name will be used as id. “auto” - an auto-incremental “C_XXXX” value will be used for compartment id (default: “auto”)
  • compartment_suffix – Specifies whether metabolite names should be appended with compartment name
  • compartment_pattern – Regular expression pattern describing how to extract compartment information from metabolite name. By default everything after last underscore _ character is considered a compartment. i.e., metabolite_e - is from compartment “e”
Return type:

Bioopt2SbmlConverter

convert(bioopt_model)

Convert BioOpt model to libSBML document instance

Parameters:bioopt_model – BioOpt model of type :class;`model.Model`
Return type:libsbml.SBMLDocument