Module modelmage :: Module generator :: Class Generator
[hide private]
[frames] | no frames]

Class Generator

source code

This class is the core of model generation in modelMaGe. It creates a graph of from the model and provides methods to generate candidate models from this.

Instance Methods [hide private]
 
__init__(self, model, functionsIdName, verbose=None)
Init method of Generator class.
source code
list
getGraphHistory(self, nodes=None)
Returns the history of the nodes in the generated models.
source code
 
setGraphHistory(self, removedNodes, history)
Set the history for a model.
source code
 
getStoich(self, pair) source code
 
setStoich(self, pair, stoich) source code
 
getModel(self) source code
 
__checkSelfLoop(self, removed, predecessor, successor)
This method checks for resulting self-loops in case a species is removed.
source code
 
getChangedDG(self) source code
none
printReactionsSpecies(self, remove=None)
Prints lists of reactions and species of an SBML model to stdout.
source code
graph
removeNode(self, nodes)
Removes the nodes v from the graph DG.
source code
 
__removeModifier(self, removed, reaction, modifier)
Removes a modifier from a reaction.
source code
none
__removeReaction(self, removed, reaction, nodes)
Removes a reaction from a given graph.
source code
dict
__removeSpecies(self, removed, species, nodeHistory)
Removes a species from a graph.
source code
 
__combine(self, DG, i, j, v, newNode)
Combines two reactions if they have more than one reactant or product.
source code
 
generate(self, remove=[], kinetics=False, REVERSEMACROS=None, verbose=False)
Returns model objects that are generated according to give kinetics and remove commands.
source code
{str:{str:[str]}}
__findStructureKinetics(self)
Determines the possible kinetics of all generated Structures and returns the kinetics in a dictionary.
source code
 
__checkConsistentReverseMacros(self, ReverseMacros, ReverseKineticMacros)
For case ca1 = species_2 | species_5, there will be ca1.cps, ca1K1.cps, ca1K2.cps the keys in 2 ReverseMacros should be correspondingly changed ReverseMacros: {"['species_2', 'species_5']": 'ca1', "['species_5']": 'ca1', "['species_2']": 'ca1'} ReverseKineticMacros: {'reaction_6:MM:ca1': 'ca1', 'reaction_5:mMM:ca1': 'ca1'}
source code
list
__createKineticSBML(self)
Creates SBML models from structure graphs and kinetics.
source code
boolean
checkCompartment(self, sbmlModel)
check if there is more than one compartment of current system
source code
libSBML:KineticLaw
__lawToSBML(self, law, reaction, graph, assignModel, fIdName)
Constructs an SBML KineticLaw object out of an XML Node
source code
{str:libSBML.SBMLDocument}
__createStructureSBML(self)
Creates new models from given graphs(usually processed by Generator.removeNode()) and the old model.
source code
 
__updateReaction(self, node, reactants, products, modifiers, model, add)
Decides if a reaction must be updated or added according to the changes in the graph or not.
source code
Class Variables [hide private]
  DG = NW.XDiGraph()
  __changedDG = {}
  kinetics = {}
  __stoich = {}
  __graphHistory = {}
  possibleKinetics = {}
Method Details [hide private]

__init__(self, model, functionsIdName, verbose=None)
(Constructor)

source code 

Init method of Generator class.

Parameters:
  • model (Model) - the master model that will be used to generate new models
  • verbose (str) - switch that defines if the method returns vrbose output or not.

getGraphHistory(self, nodes=None)

source code 

Returns the history of the nodes in the generated models. The key of a newly generated reaction is the combined key of the reactions it is combined of.

Returns: list
history of nodes

setGraphHistory(self, removedNodes, history)

source code 

Set the history for a model. The model is defined by the nodes which are removed.

Parameters:
  • removedNodes (str) - Removed nodes in the model. This serves as a key in the history dict.
  • history (dict) - the dictionary containing the history of the newly added nodes

__checkSelfLoop(self, removed, predecessor, successor)

source code 

This method checks for resulting self-loops in case a species is removed. Self-loops are removed from the graph/model.

printReactionsSpecies(self, remove=None)

source code 

Prints lists of reactions and species of an SBML model to stdout.

Parameters:
  • remove (libsbml.model) - the model to get reactions and species from
Returns: none
none

removeNode(self, nodes)

source code 

Removes the nodes v from the graph DG. In case the node is a species, it combines the reactions which are connected to v in an intelligent way. This always leads to connected graphs if species are removed, but might lead to unconnected graphs in case reactions are removed.

Parameters:
  • nodes ([string]) - list of nodes to remove from the model
Returns: graph
removed

__removeModifier(self, removed, reaction, modifier)

source code 

Removes a modifier from a reaction.

Parameters:
  • removed (networkx.DG) - graph that will be the result of removed node
  • reaction (str) - the id of the reaction to remove the modifier from
  • modifier (str) - id of the species to be removed as a modifier from reaction

__removeReaction(self, removed, reaction, nodes)

source code 

Removes a reaction from a given graph.

Parameters:
  • removed (networkx.DG) - graph that will be the result of remove node
  • reaction (str) - the id of the reaction to remove
Returns: none
none

__removeSpecies(self, removed, species, nodeHistory)

source code 

Removes a species from a graph.

Parameters:
  • removed (networkx.DG) - graph that will be the result of remove node
  • species (str) - the id of the species to be removed
  • nodeHistory (dict) - dictionary that stores the history of newly created reactions
Returns: dict
nodeHistory

__combine(self, DG, i, j, v, newNode)

source code 

Combines two reactions if they have more than one reactant or product. Therefore it sets the products and reactants of reaction 'j' directly to products and reactants of reaction 'i' and then renames 'i' to 'reaction_i_j'. Species that are modifiers to reaction i as well as to reaction j are kept only once.

Parameters:
  • DG (networkx.XDiGraph) - the graph in which the reactions will be combined(should be the graph where v is removed)
  • i (string) - first reaction for combine
  • j (string) - second reaction for combine
  • v (string) - removed species

generate(self, remove=[], kinetics=False, REVERSEMACROS=None, verbose=False)

source code 

Returns model objects that are generated according to give kinetics and remove commands. Further the method returns dictionaries containing Maps of funcitons to reactions and ids to names.

__findStructureKinetics(self)

source code 

Determines the possible kinetics of all generated Structures and returns the kinetics in a dictionary.

Returns: {str:{str:[str]}}
a dictionary containing the possible kinetics for each reaction in every structure. {structure:{reaction:[kinetics]}}

__createKineticSBML(self)

source code 

Creates SBML models from structure graphs and kinetics.

Returns: list
a list of generated models that are using different kinetics

checkCompartment(self, sbmlModel)

source code 

check if there is more than one compartment of current system

Parameters:
  • sbmlModel (Model) - a model object
Returns: boolean
1 if one compartment, 0 if more compartments

__lawToSBML(self, law, reaction, graph, assignModel, fIdName)

source code 

Constructs an SBML KineticLaw object out of an XML Node

Parameters:
  • law (minidom:Dom Element) - A kinetic law element from the input XML-file which will be translated to SBML
  • reaction (str) - The reaction this law applies to
  • graph (networkx.XDiGraph) - the structure graph the reaction belongs to
  • assignModel (str) - the name of current candidate model
  • fIdName (list) - {function_id:function_name}
Returns: libSBML:KineticLaw
Kinetic law that can be inserted into a reaction and functionDefinition

__createStructureSBML(self)

source code 

Creates new models from given graphs(usually processed by Generator.removeNode()) and the old model.

Returns: {str:libSBML.SBMLDocument}
a dict of SBMLDocuments containing the created models

__updateReaction(self, node, reactants, products, modifiers, model, add)

source code 

Decides if a reaction must be updated or added according to the changes in the graph or not. If an update is neccessary the given arguments are passed to the reaction as products modifiers and reactants.

Parameters:
  • node (string) - new/changed reaction in the graph
  • reactants ([string]) - list of reactants of the reaction
  • products ([string]) - list of products of the reaction
  • modifiers ([string]) - list of modifiers of the reaction
  • model (libSBML.SBMLModel) - the model the reactions has to be added to
  • add (bool) - 1=add reaction, 0=update reaction