bayflux.core.emus
Module Contents
Classes
A class for representing EMUs that cross-references a metabolite object. |
|
A class for representing an EMU reaction. |
Functions
|
Find all reactions which can produce a given metabolite in the forward |
|
Find all EMUTransition objects that directly produce the inputEMU. |
|
Perform a full EMU decomposition of the input EMUs. |
|
Identify which size EMUs are found in a list of EMUtransitions. |
|
Split apart an EMU transition list by size. |
|
Computes human readable and hash versions of the list of internal EMUs |
|
Constructs the A and B zero matrices from the results of constructMatrixCoords. |
|
|
|
|
|
|
|
|
|
Compiles an EMU transition list into a set of matrix addition operations indexed by position. |
|
Execute the matrix addition operations specified in the compiled EMU decomposition |
|
|
|
Compute the MDV for a given EMU from a set of labeled substrates. |
|
Returns: 1) a set of input MDVs in tuple of tuples form |
|
Pre-deconstructs an EMU network, for later simulation of specific |
|
Simulates the Mass Distribution Vector (MDV) for a set of inputEMUs given |
- class bayflux.core.emus.EMU(metabolite, indices)
A class for representing EMUs that cross-references a metabolite object.
- Args:
- metabolite (cobra.Metabolite): A COBRApy metabolite object, which
this EMU is a subset of.
- indices (list): A list of integers representing the 1-indexed
atoms in the metabolite to include in this EMU. Our standard is to use canonical smiles, and represent atoms from left to right.
- Attributes:
- metabolite (cobra.Metabolite): A COBRApy metabolite object, which
this EMU is a subset of.
- indices (list): A list of integers representing the 1-indexed
atoms in the metabolite to include in this EMU. Our standard is to use canonical smiles, and represent atoms from left to right.
- __repr__()
Return repr(self).
- size()
- __hash__()
Return hash(self).
- __eq__(other)
Return self==value.
- __ne__(other)
Return self!=value.
- class bayflux.core.emus.EMUTransition(reactants, product, parentReaction, forward=True, contribution=1.0)
A class for representing an EMU reaction.
- Args:
reactants (list): A list of EMU objects representing all reactants. product (EMU): A single EMU object representing the product. parentReaction (cobra.Reaction): The parent reaction this EMU reaction
is derived from. Used for applying the correct flux later on.
- forward (bool): True if this reaction comes from the forward direction
of the parent reaction.
- contribution (float): The fraction of the parent reaction flux carried
by this EMU reaction within a set of equivalent EMU reactions.
- Attributes:
reactants (list): A list of EMU objects representing all reactants. product (EMU): A single EMU object representing the product. parentReaction (cobra.Reaction): The parent reaction this EMU reaction
is derived from. Used for applying the correct flux later on.
- forward (bool): True if this reaction comes from the forward direction
of the parent reaction.
- contribution (float): The fraction of the parent reaction flux carried
by this EMU reaction within a set of equivalent EMU reactions.
- __repr__()
Return repr(self).
- copy()
Copies EMU transition without copying the parent reaction or metabolites.
- bayflux.core.emus.findProducingReactions(metabolite, ignoreNoTransitions=True)
- Find all reactions which can produce a given metabolite in the forward
and reverse directions.
- Args:
metabolite (cobra.Metabolite): A metabolite to look up. ignoreNoTransitions (bool, optional): If True, only EnhancedReaction
objects that have 1 or more atom transitions will be returned.
- Returns:
- list: A list of tuples (bayflux.EnhancedReaction, bool) representing each
reaction that can produce the input metabolite. The bool value is true if and only if the metabolite is produced in the forward direction. If a metabolite can be produced in both directions it will occur twice, once with a True, and once with a False value.
- bayflux.core.emus.findProducingEMUTransitions(inputEMU)
Find all EMUTransition objects that directly produce the inputEMU.
- Args:
inputEMU (EMU): An EMU to look up.
- Returns:
list: A list of EMUtransition objects.
- bayflux.core.emus.emuDecomposition(inputEMUs, transitionLimit=5000000)
Perform a full EMU decomposition of the input EMUs.
- Args:
inputEMUs (list): A list of target EMUs to analyze. transitionLimit (int): The maximum number of atom transitions to allow
in the deconstruction. This should be increased for very large models on high memory systems.
- Returns:
list: A list of EMUTransition objects representing the full decomposition.
- bayflux.core.emus.EMUsizes(EMUTransitionList)
Identify which size EMUs are found in a list of EMUtransitions.
- Args:
EMUTransitionList (list): A list of EMUtransition objects.
- Returns:
- list: A list of integers in sorted increasing order, which represents
all EMU sizes found in the products and reactants of the input list.
- bayflux.core.emus.splitBySize(EMUTransitionList)
Split apart an EMU transition list by size.
- Args:
EMUTransitionList (list): A list of EMUtransition objects.
- Returns:
- dict: A dict where keys represent EMU transition product sizes in the
input list, and values are a list of EMUTransition objects from the input which produce a product of this size.
- bayflux.core.emus.constructMatrixCoords(EMUTransitionList)
- Computes human readable and hash versions of the list of internal EMUs
and external EMUs for a list of EMUTransitions.
- Args:
- EMUTransitionList (list): A list of EMUtransition objects, typically
of equal product size.
- Returns:
- dict: A dict of dicts representing the internal and external EMUs
with the keys ‘internalEMUs’ and ‘externalEMUs’ respectively. Each of these values is a dict which has three keys ‘text’, ‘hashes’, and ‘objects’ with list values (in the same order for all 3) representing human readable text, a hash value, and the EMU objects themselves respectively. For condensation EMUs, the ‘externalEMUs’ objects will be list form, where each element is an EMU object.
- bayflux.core.emus.constructZeroMatrices(matrixCoords)
Constructs the A and B zero matrices from the results of constructMatrixCoords.
- Args:
matrixCoords (dict): the result of running constructMatrixCoords()
- Returns:
- tuple: A tuple of length 2, where each element is a numpy.ndarray representing
an all zeros version of the appropriately sized A or B matrices for EMU simulation for later ‘injection’ of fluxes by addition.
- bayflux.core.emus.mergeDuplicates(transitionList)
- bayflux.core.emus._traceReplacement(emu, replacementPairs)
- bayflux.core.emus._identifyIdenticalEMUs(transitionList, metabolitesToKeep)
- bayflux.core.emus.pruneTransitionList(transitionList, metabolitesToKeep)
- bayflux.core.emus.compileEMUTransitionList(EMUTransitionList, matrixCoords, model)
Compiles an EMU transition list into a set of matrix addition operations indexed by position.
- Args:
- EMUTransitionList (list): A list of EMUtransition objects, typically
of equal product size.
- matrixCoords (dict): the result of running constructMatrixCoords()
on the above list.
model (bayflux.ReactionNetwork): A genome scale model, used to determine the order of variables in a flux vector.
- Returns:
list: A list of tuples, where each inner tuple represents a matrix addition operation to the A or B matrix and has the following structure:
-matrix selector (0: matrix A, 1: matrix B) -row: row number to inject to into in the above matrix -column: column number to inject into in the above matrix -reaction selector: a column number in the flux vector -multiplier: a float: multiply flux by this before injecting
- bayflux.core.emus.executeCompiledEMUTransitionList(operations, zeroMatrices, fluxes)
- Execute the matrix addition operations specified in the compiled EMU decomposition
and return the new A and B matrices.
- Args:
- operations (list): A list of compiled operations as produced by
compileEMUTransitionList.
- zeroMatrices (tuple): A tuple of length 2, where each element is a numpy.ndarray representing
an all zeros version of the appropriately sized A or B matrices for EMU simulation for later ‘injection’ of fluxes by addition.
- fluxes (bayflux.FluxVector): A flux vector or numpy array with a flux value for each variable in the genome scale model.
The order of values in fluxVector should match that used to generate the operations list.
- Returns:
- tuple: A tuple of length 2, where each element is a numpy.ndarray representing
the A and B matrices respectively, after execution of the specified addition operations.
- bayflux.core.emus.executeCompiledMatrixY(substrateMDVs, operationsY, results, size)
- bayflux.core.emus.extractSubstrateEMU(inputEMU, substrateLabelingDict)
Compute the MDV for a given EMU from a set of labeled substrates.
- Args:
- inputEMU (EMU): An EMU object representing a subset of one of the labeled
substrate metabolites.
- substrateLabelingDict (dict): A dict where keys are cobra.Metabolite
objects, and values a tuple of length 2 tuples each representing a fractional labeling pattern on an input substrate. The first value in the length 2 tuple is a float representing a fractional contribution and the second is a list of integers representing the number of extra neutrons at each atom location. The standard index is left to right in the canonical SMILES structure of the metabolite. Fractional contributions must sum to 1.0.
- Returns:
- list: A list of float values, representing the mass distribution vector
for the inputEMU, starting from the fraction with 0 extra neutrons in the first position.
- bayflux.core.emus.compileMatrixY(compiledData, matrixCoords, size, substrateLabelingDict)
Returns: 1) a set of input MDVs in tuple of tuples form
A set of compiled operations with the following syntax:
A list where each element corresponds to a row in matY in order.
Each of these is a length 2 list with: -result size, representing a matrix X EMU of a particular size, or an input emu (called size 0) -MDV number: a row number from that size EMU result, or from the input MDVs in tuple form
Execution instructions: convolve together all MDVs with the same row #, and inject the result into that row
- bayflux.core.emus.emuCompile(emusToSimulate, model, substrateLabelingDict, merge=False, prune=False)
- Pre-deconstructs an EMU network, for later simulation of specific
flux vectors.
- Args:
- emusToSimulate (list): A list of EMU objects, representing the
metabolites we would like to predict MDVs for.
- reactions (list): A list of ‘str’ objects representing the names
of reactions in our flux vector in order.
- Returns:
- list: A list of dicts representing each EMU size sub-network with the
- following keys and values:
‘matrixCoords’: (dict) the output of constructMatrixCoords ‘size’: (int) the EMU sub-network size ‘operations’: (list) the output of compileEMUTransitionList
- bayflux.core.emus.simulateLabeling(compiledData, fluxes, substrateLabelingDict)
- Simulates the Mass Distribution Vector (MDV) for a set of inputEMUs given
a specific flux vector.
- Args:
compiledData (list): The output of emuCompile. fluxes (numpy.matrix): A matrix of fluxes where columns represent
reactions, the first row is forward fluxes, and the second row is backwards fluxes. Non-reversible reactions should always have a flux of 0 in the second row. The order of columns should match that used to generate the operations list.
- substrateLabelingDict (dict): See bayflux.extractSubstrateEMU for
a detailed description.
- Returns:
- dict: A dict of results where each key is an integer specifying
an EMU sub-network size, and each value is an EMU simulation X numpy.matrix which contains simulated MDVs. Columns represent number of extra neutrons starting at 0, while rows represent the ‘internalEMUs’ from ‘matrixCoords’ in the compiledData.