BioOpt Classes (API)¶
Model¶
-
class
model.Bounds(lb=-inf, ub=inf)¶ Bases:
objectBoundsholds description of reactions constraintsParameters: - 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: -
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
Reactionclass and this suggestion can be broken by enabling reaction reversibility throughReaction.directionReturn 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:
objectDescribe reaction directionality. Don’t use this class directly! Use factory constructors
Direction.forward()andDirection.reversible()Parameters: type – f - Irreversible (f orward); r - Reversible (r eversible) Returns: Direction
-
class
model.Metabolite(name, boundary=False)¶ Bases:
objectMetaboliteholds 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: -
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:
objectBioOpt 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
Falseand 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
Modelto 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: - models – List of
-
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:
-
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:
-
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
-
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.
-
static
-
class
model.Operation(operation, is_unary)¶ Bases:
objectObject describing operation type. Don’t use this class directly! Instead use factory constructors:
Operation.addition()Operation.subtraction()Operation.multiplication()Operation.division()Operation.negation()(Unary operation)
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: -
is_unary¶ Is operation unary. True - unary; otherwise False :return:
bool
-
class
model.Reaction(name, reactants=, products=, direction=None, bounds=None)¶ Bases:
objectReactionclass holds information about reaction including reaction name, members, directionality and constraintsParameters: - 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: -
bounds_reset()¶ Reset bounds to predefined default. For reversible reaction defaults bounds are [-inf, +inf]. For forward reactions it is [0, +inf]
-
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:
objectBoundsis a wrapper forMetaboliteobject 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
Metaboliteobject - coefficient – Multiplier associated with metabolite
Returns: -
coefficient¶ Multiplier associated with metabolite
-
copy()¶ Create a deep copy of current object
Return type: ReactionMember
-
metabolite¶ Reference to metabolite
Return type: Metabolite
- metabolite – Reference to
-
class
model.ReactionMemberList¶ Bases:
listReactionMemberListis a list ofReactionMemberinstances.ReactionMemberListinherits fromlistall 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: -
convert(bioopt_model)¶ Convert BioOpt model to libSBML document instance
Parameters: bioopt_model – BioOpt model of type :class;`model.Model` Return type: libsbml.SBMLDocument