Пример #1
0
    def mathForFortran(self):
        """
        Takes the libSBML mathNode AST tree of this Reaction's
        KineticLaw and converts it into
        something that is valid FORTRAN code. (e.g. "pow(x,2)" becomes
        "x ** 2", etc.)

        """
        if not self.kineticLaw:
            return 
        
        validFortran = helpers.handleMathNode(self.kineticLaw.getMath())
        
        # we start with replacing the longest IDs first. should help
        # to minimize problems with IDs that are substrings of longer IDs
        # Note: The problem still persists, it's not gone entirely. (Because
        # the replacement also contains the original ID and can still overlap
        # with other IDs.)
        sortedLocalParamIDs = sorted(self.localParameterIDs, key=len, reverse=True)
        
        for localParam in sortedLocalParamIDs:
            if localParam in validFortran:
                validFortran = validFortran.replace(localParam, "%s_%s" % (self.id, localParam))
                
        return validFortran
Пример #2
0
    def mathForFortran(self):
        """
        Takes the libSBML mathNode AST tree of this Reaction's
        KineticLaw and converts it into
        something that is valid FORTRAN code. (e.g. "pow(x,2)" becomes
        "x ** 2", etc.)

        """
        if not self.kineticLaw:
            return

        validFortran = helpers.handleMathNode(self.kineticLaw.getMath())

        # we start with replacing the longest IDs first. should help
        # to minimize problems with IDs that are substrings of longer IDs
        # Note: The problem still persists, it's not gone entirely. (Because
        # the replacement also contains the original ID and can still overlap
        # with other IDs.)
        sortedLocalParamIDs = sorted(self.localParameterIDs,
                                     key=len,
                                     reverse=True)

        for localParam in sortedLocalParamIDs:
            if localParam in validFortran:
                validFortran = validFortran.replace(
                    localParam, "%s_%s" % (self.id, localParam))

        return validFortran
Пример #3
0
 def mathForFortran(self):
     """
     Takes the current libSBML mathNode AST tree and converts it into
     something that is valid FORTRAN code. (e.g. "pow(x,2)" becomes
     "x ** 2", etc.)
     """
     odeString = helpers.handleMathNode(self.mathNode)
     return odeString
Пример #4
0
 def mathForFortran(self):
     """
     Takes the current libSBML mathNode AST tree and converts it into
     something that is valid FORTRAN code. (e.g. "pow(x,2)" becomes
     "x ** 2", etc.)
     """
     odeString = helpers.handleMathNode(self.mathNode)
     return odeString
Пример #5
0
    def mathForFortran(self):
        """
        DEPRECATED! The FORTRAN backend is no longer... :)

        Takes the current libSBML mathNode AST tree and converts it into
        something that is valid FORTRAN code. (e.g. "pow(x,2)" becomes
        "x ** 2", etc.)

        If "formula" was given during creation of this instance it is assumed
        that this formula string already is valid FORTRAN code. It will
        be returned unaltered.
        """
        if self.formula:
            return self.formula

        # else: get string from self.mathNode (libSBML ASTNode graph)

        odeString = helpers.handleMathNode(self.mathNode)
        return odeString
Пример #6
0
    def mathForFortran(self):
        """
        DEPRECATED! The FORTRAN backend is no longer... :)

        Takes the current libSBML mathNode AST tree and converts it into
        something that is valid FORTRAN code. (e.g. "pow(x,2)" becomes
        "x ** 2", etc.)

        If "formula" was given during creation of this instance it is assumed
        that this formula string already is valid FORTRAN code. It will
        be returned unaltered.
        """
        if self.formula:
            return self.formula

        # else: get string from self.mathNode (libSBML ASTNode graph)

        odeString = helpers.handleMathNode(self.mathNode)
        return odeString