VirtualMicrobes.event package

Submodules

VirtualMicrobes.event.Molecule module

class VirtualMicrobes.event.Molecule.Molecule(name, toxic_level=None, is_internal=True, pair=True, is_building_block=False, is_gene_product=False, mol_class=None, is_energy=False, environment=None, **kwargs)[source]

Bases: object

Molecule species.

An internally and external variant of each molecule is defined. Molecules can act as metabolites that can be converted in (enzymatic) reactions. Can diffuse over membranes and may be transported into or out of the cell.

class_version = '1.0'
energy_level
environment
index = 0
is_building_block
is_energy
is_gene_product
is_influxed
is_internal
mol_class
pair_up()[source]

Create a paired molecule for self on the other side of the Cell membrane.

When updating a property of self, the property of the paired molecule is automatically updated (if appropriate; e.g. toxic_level or is_energy)

set_building_block(val=True)[source]
short_repr()[source]
toxic_level
classmethod unique_index(increase=None)[source]
upgrade()[source]

Upgrading from older pickled version of class to latest version. Version information is saved as class variable and should be updated when class invariants (e.g. fields) are added.

class VirtualMicrobes.event.Molecule.MoleculeClass(name, molecule_species=None, energy_level=1, is_energy=False, has_building_block=False)[source]

Bases: object

Defines a class of related molecule species.

add_molecule(molecule)[source]

Add a molecule to this molecule class.

Parameters:molecule (VirtualMicrobes.event.Molecule) – a molecule
short_repr()[source]

A short string representation of the molecule class

class VirtualMicrobes.event.Molecule.MoleculeIndexer[source]

Bases: object

VirtualMicrobes.event.Reaction module

exception VirtualMicrobes.event.Reaction.BadStoichiometryException[source]

Bases: exceptions.Exception

class VirtualMicrobes.event.Reaction.ClassConvert(substrate, energy, product)[source]

Bases: VirtualMicrobes.event.Reaction.Convert

Convert molecules within the same molecule class.

Parameters:
init_sub_reaction_dicts()[source]

Write out dictionaries for the sub_reactions generated by sub_reactions()

class VirtualMicrobes.event.Reaction.Convert(reactants, products, stoichiometry)[source]

Bases: VirtualMicrobes.event.Reaction.Reaction

Conversion reaction type.

In a conversion reaction a set of reactants react and a set of products are produced. Both reactants and products are defined as VirtualMicrobes.event.Molecule.MoleculeClass. Therefore, a single Convert reaction represent a set of sub-reactions of sets of reactant- VirtualMicrobes.event.Molecule.Molecule, sets of product- VirtualMicrobes.event.Molecule.Molecule combinations.

A pairing rule governs the exact set of sub-reactions that can take place.

Parameters:
init_sub_reaction_dicts()[source]

Write out dictionaries for the sub_reactions generated by sub_reactions()

prod_species
reac_species
sub_reactions()[source]

Representation of sub-reactions.

Returns a list of all potential reaction schemes in the following form: ([ (reactant, stoichiometry), .. ], [ (product, stoichiometry) ..] ). The general scheme for reactions from and to Molecule Classes maps molecules within a MolClass on lhs to molecules in another class on the rhs as follows:

Reaction scheme as MoleculeClass scheme: A + B -> C , where A :{a0, a1, a2}, B:{b0, b1}, C:{c0, c1, c2*} will be translated into:

a0 + b0 -> c0 a1 + b0 -> c1 a2 + b0 -> c2*

a0 + b1 -> c0 a1 + b1 -> c1 a2 + b1 -> c2*

  • If certain molecule species do not exist (e.g. the c2 in the previous example does not

exist, the reaction is omitted from possible sub-reactions, and will therefor not take place. Note that products on the rhs will always be converted in to the species corresponding to the index of the substrate on the lhs. If there is more product than substrates, e.g. A -> C + D where D:{d0, d1}, then there will be subreactions for every possible species of D:

a0 -> c0 + d0 a0 -> c0 + d1

a1 -> c1 + d0 a1 -> c1 + d1

a2 -> c2 + d0 a2 -> c2 + d1

Example 2: F + G -> H + I , where F :{f0, f1, f2}, G:{g0}, H:{h0, h1} , I:{i0, i2} becomes:

f0 + g0 -> h0 + i0 f1 + g0 -> h1 + i0

.

class VirtualMicrobes.event.Reaction.Degradation(substrate, **kwargs)[source]

Bases: VirtualMicrobes.event.Reaction.Reaction

Degradation type reaction.

Represents degradation of a molecule. The reaction has no products. Thus, when molecules degrade, mass is not strictly conserved.

Parameters:substrate (VirtualMicrobes.event.Molecule.Molecule) – degrading molecule
reaction_scheme()[source]

Reaction scheme dictionary.

sub_reactions()[source]

Representation of sub-reactions.

In the case of Degradation reactions, only a single sub-reaction exists.

class VirtualMicrobes.event.Reaction.Diffusion(substrate, **kwargs)[source]

Bases: VirtualMicrobes.event.Reaction.Reaction

Diffusion type reaction.

A reaction representing diffusion over a barrier (here the cell membrane). No products are defined for this reaction. Methods implementing this reaction type will convert the external/internal variant of a VirtualMicrobes.event.Molecule.Molecule into the linked internal/external molecule type.

Parameters:substrate (VirtualMicrobes.event.Molecule.Molecule) – diffusing molecule
reaction_scheme()[source]

Reaction scheme dictionary.

sub_reactions()[source]

Representation of sub-reactions.

In the case of Diffusion reactions, only a single sub-reaction exists.

class VirtualMicrobes.event.Reaction.Influx(substrate, **kwargs)[source]

Bases: VirtualMicrobes.event.Reaction.Reaction

Influx type reaction.

A reaction representing influx of molecules into the environment.

Parameters:substrate (VirtualMicrobes.event.Molecule.Molecule) – molecule that fluxes in
reaction_scheme()[source]

Reaction scheme dictionary.

class VirtualMicrobes.event.Reaction.Reaction(type_, reactants, products, stoichiometry)[source]

Bases: object

Base class for reactions.

Reactions are rules to convert Molecules to other Molecules, or Transport Molecules from one volume to another volume. A reaction specifies its reactants and products as MoleculeClasses or Molecules. Because a MoleculeClass can hold multiple Molecules, one Reaction is in fact a collection of potential molecular reactions. The actualized reactions depend on the properties (binding affinities for specific Molecules) of the enzymes and the availability of Molecules.

Parameters:
short_repr()[source]

Shorter version of __str__

class VirtualMicrobes.event.Reaction.Transport(substrate_class, energy_source_class, sub_stoi, cost, **kwargs)[source]

Bases: VirtualMicrobes.event.Reaction.Reaction

A transport type reaction.

Substrates are transported over a membrane, typically requiring the consumption of an energy source. The substrate and energy source are defined as VirtualMicrobes.event.Molecule.MoleculeClass. Therefore, a single Transport reaction represent a set of sub-reactions of substrate- VirtualMicrobes.event.Molecule.Molecule, energy- VirtualMicrobes.event.Molecule.Molecule combinations.

Parameters:
init_sub_reaction_dicts()[source]

Write out dictionaries for the sub_reactions generated by sub_reactions()

sub_reactions()[source]

Representation of sub-reactions.

Sub-reactions of Transporters link a specific external substrate to its internal counterpart. Different energy sources yield combinatorial expansion.

VirtualMicrobes.event.Reaction.consumes(reactions)[source]

Set of consumed metabolic species.

Parameters:reactions (iterable of Convert or dict) – set of reactions
Returns:
Return type:set of :class:`VirtualMicrobes.event.Molecule.Molecule`s consumed in the reaction set.
VirtualMicrobes.event.Reaction.find_metabolic_closure(input_set, conversions)[source]

Find the autocatalytic closure of metabolites given a set of inputs and reactions.

Iteratively overlap the produced + influxed and consumed metabolites of the set of conversion reactions, yielding a set of ‘potentially autocatalytic metabolites’. Iterate over the set of ‘potentially autocatalytic reactions’ and require that all substrates of the reaction are in the set of ‘potentially autocatalytic’ metabolites. If not, remove the reaction from the ‘potentially autocatalytic’ reaction set.

Parameters:
  • input_set (iterable of VirtualMicrobes.event.Molecule.Molecule) – initial set to start expansion of metabolic set
  • conversions (iterable of :class:`Conversion`s) – enzymatic reactions that convert metabolites into other metabolites
Returns:

tuple – molecules and reactions in the core autocatalytic cycle.

Return type:

( set of :class:`VirtualMicrobes.event.Molecule.Molecule`s , set of :class:`Conversion`s)

VirtualMicrobes.event.Reaction.find_product_set(input_mols, conversions)[source]

Find metabolites that can be produced from a set of input metabolites, given a set of reactions.

Parameters:
  • input_mols (iterable of VirtualMicrobes.event.Molecule.Molecule) – initial set to start expansion of metabolic set
  • conversions (iterable of :class:`Conversion`s) – enzymatic reactions that convert metabolites into other metabolites
Returns:

Return type:

set of produced :class:`VirtualMicrobes.event.Molecule.Molecule`s

VirtualMicrobes.event.Reaction.produces(reactions)[source]

Set of produced metabolic species.

Parameters:reactions (iterable of Convert or dict) – set of reactions
Returns:
Return type:set of:class:`VirtualMicrobes.event.Molecule.Molecule`s produced in the reaction set.

Module contents

Created on Nov 12, 2013

author:thocu