def handleMinus(self, node):
     if node.getRightChild():
         return Expression(parkin.MINUS,
                           self.astConverter.handle(node.getLeftChild()),
                           self.astConverter.handle(node.getRightChild()))
     else:
         return Expression(parkin.MINUS,
                           self.astConverter.handle(node.getLeftChild()))
 def handleTimes(self, node):
     left = self.astConverter.handle(node.getLeftChild())
     right = self.astConverter.handle(node.getRightChild())
     if right and left:
         return Expression(parkin.TIMES, left, right)
     else:
         return None
Пример #3
0
    def mathForBioParkinCpp(self, idsToReplace=None):
        """
        Creates and uses an AstConverter (with the BioParkinCppAstConverterTemplate) to
        convert the libsbml ASTNode into an PARKINcpp Expression object.
        """
        if self.localParams:
            if not idsToReplace:
                idsToReplace = {}
            for param in self.localParams:
                idsToReplace[param.getId()] = Expression(
                    self.getCombinedId(param))

        astConverter = AstConverter(BioParkinCppAstConverterTemplate(),
                                    mainModel=self.mainModel,
                                    idsToReplace=idsToReplace)
        return astConverter.handle(self.kineticLaw.getMath())
 def handleCos(self, node):
     return Expression(parkin.COS, self.astConverter.handle(node.getLeftChild()))
 def handleConstPi(self, node=None):
     """ Handles ASTNodes representing the constant pi. """
     return Expression(math.pi)
 def handleConstTrue(self, node=None):
     """ Handles ASTNodes representing a simple real/double/float. """
     return Expression(1.0)
 def handleOdeTime(self, node=None):
     """ Handles ASTNodes representing the (ODE-)time variable. """
     return Expression("odeTime")
 def handleConstE(self, node=None):
     """ Handles ASTNodes representing the Euler constant e. """
     return Expression(math.e)
 def handleReal(self, node):
     """ Handles ASTNodes representing a simple real/double/float. """
     return Expression(node.getReal())
 def handleString(self, node):
     """ Handles ASTNodes representing a simple String. """
     return Expression(node.getName())
 def handleDivide(self, node):
     return Expression(parkin.DIVIDE, self.astConverter.handle(node.getLeftChild()), self.astConverter.handle(node.getRightChild()))
 def handleInt(self, node):
     """ Handles ASTNodes representing a simple Integer. """
     return Expression(node.getInteger())
 def handleSin(self, node):
     return Expression(parkin.SIN, self.astConverter.handle(node.getLeftChild()))
 def handleFloor(self, node):
     return Expression(parkin.FLOOR, self.astConverter.handle(node.getLeftChild()))
 def handleCeiling(self, node):
     return Expression(parkin.CEIL, self.astConverter.handle(node.getLeftChild()))
 def handleLog(self, node):
     return Expression(parkin.LOG, self.astConverter.handle(node.getLeftChild()))
 def handlePower(self, node):
     return Expression(parkin.POWER, self.astConverter.handle(node.getLeftChild()), self.astConverter.handle(node.getRightChild()))