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
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
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