fern.network.sbml
Class MathTree

java.lang.Object
  extended by fern.network.sbml.MathTree

public class MathTree
extends Object

Representation of am evaluation tree. Within a sbml file, MathML branches may occur at different positions. These are represented as MathTrees in FERN.

Author:
Florian Erhard

Nested Class Summary
static class MathTree.ConstLeaf
           
static class MathTree.GlobalLeaf
           
static class MathTree.InnerNode
           
static class MathTree.Node
           
static class MathTree.VarLeaf
           
 
Constructor Summary
MathTree(Network net, org.sbml.libsbml.ASTNode ast, Map<String,Double> globals, Map<String,Double> locals, Map<String,Integer> bindings)
          Creates a MathTree from an libsbml ASTNode.
 
Method Summary
 double calculate(AmountManager amount, Simulator sim)
          Evaluate the MathTree.
 MathTree.Node getRoot()
          Gets the root of this MathTree.
 List<Integer> getSpecies()
          Gets the species present in this tree.
static String inferStringFromSBMLConstant(String prefix, Object c)
          Uses reflection to get a string representation of a libsml constant.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MathTree

public MathTree(Network net,
                org.sbml.libsbml.ASTNode ast,
                Map<String,Double> globals,
                Map<String,Double> locals,
                Map<String,Integer> bindings)
Creates a MathTree from an libsbml ASTNode.

Parameters:
net - sbml network
ast - ASTNode
globals - pointer to the global variable mapping
locals - pointer to the local variable mapping of this entity
bindings - mapping of the variable names to their indices
Method Detail

getSpecies

public List<Integer> getSpecies()
Gets the species present in this tree.

Returns:
indices of the species.

getRoot

public MathTree.Node getRoot()
Gets the root of this MathTree. Feature versions may implement the Visitor pattern, but for now traversing by using instanceof will do.

Returns:
the root of this MathTree

calculate

public double calculate(AmountManager amount,
                        Simulator sim)
Evaluate the MathTree.

Parameters:
amount - AmountManager
sim - Simulator
Returns:
value of the expression

inferStringFromSBMLConstant

public static String inferStringFromSBMLConstant(String prefix,
                                                 Object c)
Uses reflection to get a string representation of a libsml constant.

Parameters:
prefix - a prefix for the constant name e.g. AST
c - the libsml constant
Returns:
the name of the constant in libsbmlConstants