libSBML Python API  5.18.0
libsbml.ASTNode Class Reference
Inheritance diagram for libsbml.ASTNode:
[legend]

Detailed Description

Abstract Syntax Tree (AST) representation of a mathematical expression.

This class of objects is defined by libSBML only and has no direct equivalent in terms of SBML components. This class is not prescribed by the SBML specifications, although it is used to implement features defined in SBML.

Abstract Syntax Trees (ASTs) are a simple kind of data structure used in libSBML for storing mathematical expressions. The ASTNode is the cornerstone of libSBML's AST representation. An AST 'node' represents the most basic, indivisible part of a mathematical formula and come in many types. For instance, there are node types to represent numbers (with subtypes to distinguish integer, real, and rational numbers), names (e.g., constants or variables), simple mathematical operators, logical or relational operators and functions. LibSBML ASTs provide a canonical, in-memory representation for all mathematical formulas regardless of their original format (which might be MathML or might be text strings).

An AST node in libSBML is a recursive tree structure; each node has a type, a pointer to a value, and a list of children nodes. Each ASTNode node may have none, one, two, or more children depending on its type. There are node types to represent numbers (with subtypes to distinguish integer, real, and rational numbers), names (e.g., constants or variables), simple mathematical operators, logical or relational operators and functions. The following diagram illustrates an example of how the mathematical expression '1 + 2' is represented as an AST with one plus node having two integer children nodes for the numbers 1 and 2. The figure also shows the corresponding MathML representation:
Example AST representation of a mathematical expression.
Infix AST MathML
1 + 2 <math xmlns="http://www.w3.org/1998/Math/MathML">
  <apply>
    <plus/>
    <cn type="integer"> 1 </cn>
    <cn type="integer"> 2 </cn>
  </apply>
</math>

The following are other noteworthy points about the AST representation in libSBML:

  • A numerical value represented in MathML as a real number with an exponent is preserved as such in the AST node representation, even if the number could be stored in a float data type. This is done so that when an SBML model is read in and then written out again, the amount of change introduced by libSBML to the SBML during the round-trip activity is minimized.
  • The children of an ASTNode are other ASTNode objects. The list of children is empty for nodes that are leaf elements, such as numbers. For nodes that are actually roots of expression subtrees, the list of children points to the parsed objects that make up the rest of the expression.

For many applications, the details of ASTs are irrelevant because libSBML provides text-string based translation functions such as formulaToL3String() and parseL3Formula(). If you find the complexity of using the AST representation of expressions too high for your purposes, perhaps the string-based functions will be more suitable.

The set of possible ASTNode types

Every ASTNode has an associated type code to indicate whether, for example, it holds a number or stands for an arithmetic operator.

The type is recorded as a value drawn from a set of static integer constants defined in the class libsbml. Their names begin with the characters AST_.The list of possible types is quite long, because it covers all the mathematical functions that are permitted in SBML. The values are shown in the following table:

AST_CONSTANT_E AST_FUNCTION_CSC AST_LOGICAL_AND
AST_CONSTANT_FALSE AST_FUNCTION_CSCH AST_LOGICAL_IMPLIES2
AST_CONSTANT_PI AST_FUNCTION_DELAY AST_LOGICAL_NOT
AST_CONSTANT_TRUE AST_FUNCTION_EXP AST_LOGICAL_OR
AST_DIVIDE AST_FUNCTION_FACTORIAL AST_LOGICAL_XOR
AST_FUNCTION AST_FUNCTION_FLOOR AST_MINUS
AST_FUNCTION_ABS AST_FUNCTION_LN AST_NAME
AST_FUNCTION_ARCCOS AST_FUNCTION_LOG AST_NAME_AVOGADRO1
AST_FUNCTION_ARCCOSH AST_FUNCTION_MAX2 AST_NAME_TIME
AST_FUNCTION_ARCCOT AST_FUNCTION_MIN2 AST_ORIGINATES_IN_PACKAGE2
AST_FUNCTION_ARCCOTH AST_FUNCTION_PIECEWISE AST_PLUS
AST_FUNCTION_ARCCSC AST_FUNCTION_POWER AST_POWER
AST_FUNCTION_ARCCSCH AST_FUNCTION_QUOTIENT2 AST_RATIONAL
AST_FUNCTION_ARCSEC AST_FUNCTION_RATE_OF2 AST_REAL
AST_FUNCTION_ARCSECH AST_FUNCTION_REM2 AST_REAL_E
AST_FUNCTION_ARCSIN AST_FUNCTION_ROOT AST_RELATIONAL_EQ
AST_FUNCTION_ARCSINH AST_FUNCTION_SEC AST_RELATIONAL_GEQ
AST_FUNCTION_ARCTAN AST_FUNCTION_SECH AST_RELATIONAL_GT
AST_FUNCTION_ARCTANH AST_FUNCTION_SIN AST_RELATIONAL_LEQ
AST_FUNCTION_CEILING AST_FUNCTION_SINH AST_RELATIONAL_LT
AST_FUNCTION_COS AST_FUNCTION_TAN AST_RELATIONAL_NEQ
AST_FUNCTION_COSH AST_FUNCTION_TANH AST_TIMES
AST_FUNCTION_COT AST_INTEGER AST_UNKNOWN
AST_FUNCTION_COTH AST_LAMBDA
1 (Level 3 only)
2 (Level 3 Version 2+ only)

The types have the following meanings:

  • If the node is a predefined function or operator from SBML Level 1 (in the string-based formula syntax used in Level 1) or SBML Level 2 and 3 (in the subset of MathML used in SBML Levels 2 and 3), then the node's type will be either AST_FUNCTION_X, AST_LOGICAL_X, or AST_RELATIONAL_X, as appropriate. (Examples: AST_FUNCTION_LOG, AST_RELATIONAL_LEQ.)
  • If the node refers to a user-defined function, the node's type will be AST_FUNCTION (because it holds the name of the function).
  • If the node is a lambda expression, its type will be AST_LAMBDA.
  • (Levels 2 and 3 only) If the node is the special MathML csymbol time, the value of the node will be AST_NAME_TIME. (Note, however, that the MathML csymbol delay is translated into a node of type AST_FUNCTION_DELAY. The difference is due to the fact that time is a single variable, whereas delay is actually a function taking arguments.)
  • (Level 3 only) If the node is the special MathML csymbol avogadro, the value of the node will be AST_NAME_AVOGADRO.
  • (Level 3 Version 2+ only) If the node is the special MathML csymbol rateOf, the value of the node will be AST_FUNCTION_RATE_OF.
  • (Level 3 Version 2+ only) If the node is a MathML operator that originates in a package, it is included in the long list, but may not be legally used in an SBML document that does not include that package. This includes the node types from the 'Distributions' package (AST_DISTRIB_FUNCTION_NORMAL, AST_DISTRIB_FUNCTION_UNIFORM, etc.), and elements from MathML that were not included in core.

Converting between ASTs and text strings

The text-string form of mathematical formulas produced bylibsbml.formulaToString() and read bylibsbml.parseFormula() and libsbml.parseL3Formula() are in a simple C-inspired infix notation. A formula in this text-string form can be handed to a program that understands SBML mathematical expressions, or used as part of a translation system. The libSBML distribution comes with an example program in the 'examples' subdirectory called translateMath that implements an interactive command-line demonstration of translating infix formulas into MathML and vice-versa.

The formula strings may contain operators, function calls, symbols, and white space characters. The allowable white space characters are tab and space. The following are illustrative examples of formulas expressed in the syntax:

0.10 * k4^2
(vm * s1)/(km + s1)

The following table shows the precedence rules in this syntax. In the Class column, operand implies the construct is an operand, prefix implies the operation is applied to the following arguments, unary implies there is one argument, and binary implies there are two arguments. The values in the Precedence column show how the order of different types of operation are determined. For example, the expression a * b + c is evaluated as (a * b) + c because the * operator has higher precedence. The Associates column shows how the order of similar precedence operations is determined; for example, a - b + c is evaluated as (a - b) + c because the + and - operators are left-associative. The precedence and associativity rules are taken from the C programming language, except for the symbol ^, which is used in C for a different purpose. (Exponentiation can be invoked using either ^ or the function power.)

Token Operation Class Precedence Associates
namesymbol referenceoperand6n/a
(expression)expression groupingoperand6n/a
f(...)function callprefix6left
-negationunary5right
^powerbinary4left
*multiplicationbinary3left
/divisonbinary3left
+additionbinary2left
-subtractionbinary2left
,argument delimiterbinary1left
A table of the expression operators and their precedence in the text-string format for mathematical expressions used by SBML_parseFormula().

A program parsing a formula in an SBML model should assume that names appearing in the formula are the identifiers of Species, Parameter, Compartment, FunctionDefinition, Reaction (in SBML Levels 2 and 3), or SpeciesReference (in SBML Level 3 only) objects defined in a model. When a function call is involved, the syntax consists of a function identifier, followed by optional white space, followed by an opening parenthesis, followed by a sequence of zero or more arguments separated by commas (with each comma optionally preceded and/or followed by zero or more white space characters), followed by a closing parenthesis. There is an almost one-to-one mapping between the list of predefined functions available, and those defined in MathML. All of the MathML functions are recognized; this set is larger than the functions defined in SBML Level 1. In the subset of functions that overlap between MathML and SBML Level 1, there exist a few differences. The following table summarizes the differences between the predefined functions in SBML Level 1 and the MathML equivalents in SBML Levels 2 and  3:

Text string formula functions MathML equivalents in SBML Levels 2 and 3
acosarccos
asinarcsin
atanarctan
ceilceiling
logln
log10(x)log(x) or log(10, x)
pow(x, y)power(x, y)
sqr(x)power(x, 2)
sqrt(x)root(x) or root(2, x)
Table comparing the names of certain functions in the SBML text-string formula syntax and MathML. The left column shows the names of functions recognized by SBML_parseFormula(); the right column shows their equivalent function names in MathML 2.0, used in SBML Levels 2 and 3.
See also
libsbml.parseL3Formula()
libsbml.parseFormula()

Public Member Functions

def __init__ (self, args)
 This method has multiple variants; they differ in the arguments they accept. More...
 
def addChild (self, disownedChild, inRead=False)
 Adds the given node as a child of this ASTNode. More...
 
def addSemanticsAnnotation (self, disownedAnnotation)
 Adds the given XMLNode as a semantic annotation of this ASTNode. More...
 
def canonicalize (self)
 Converts this ASTNode to a canonical form and returns True if successful, False otherwise. More...
 
def deepCopy (self)
 Creates a recursive copy of this node and all its children. More...
 
def freeName (self)
 Frees the name of this ASTNode and sets it to None. More...
 
def getASTPlugin (self, args)
 This method has multiple variants; they differ in the arguments they accept. More...
 
def getCharacter (self)
 Gets the value of this node as a single character. More...
 
def getChild (self, n)
 Gets a child of this node according to its index number. More...
 
def getClass (self)
 Gets the class of this ASTNode. More...
 
def getDefinitionURL (self)
 Gets the MathML 'definitionURL' attribute value. More...
 
def getDefinitionURLString (self)
 Returns the MathML definitionURL attribute value as a string. More...
 
def getDenominator (self)
 Gets the value of the denominator of this node. More...
 
def getExponent (self)
 Gets the exponent value of this ASTNode. More...
 
def getId (self)
 Gets the id of this ASTNode. More...
 
def getInteger (self)
 Gets the value of this node as an integer. More...
 
def getLeftChild (self)
 Gets the left child of this node. More...
 
def getListOfNodes (self)
 Returns a list of nodes. More...
 
def getMantissa (self)
 Gets the mantissa value of this node. More...
 
def getName (self)
 Gets the value of this node as a string. More...
 
def getNumChildren (self)
 Gets the number of children that this node has. More...
 
def getNumerator (self)
 Gets the value of the numerator of this node. More...
 
def getNumSemanticsAnnotations (self)
 Gets the number of semantic annotation elements inside this node. More...
 
def getOperatorName (self)
 Gets the value of this operator node as a string. More...
 
def getParentSBMLObject (self)
 Returns the parent SBML object. More...
 
def getPlugin (self, args)
 
def getPrecedence (self)
 Gets the precedence of this node in the infix math syntax of SBML Level 1. More...
 
def getReal (self)
 Gets the real-numbered value of this node. More...
 
def getRightChild (self)
 Gets the right child of this node. More...
 
def getSemanticsAnnotation (self, n)
 Gets the nth semantic annotation of this node. More...
 
def getStyle (self)
 Gets the style of this ASTNode. More...
 
def getType (self)
 Gets the type of this ASTNode. More...
 
def getUnits (self)
 Gets the units of this ASTNode. More...
 
def getValue (self)
 Returns the numerical value of this ASTNode. More...
 
def hasCorrectNumberArguments (self)
 Returns True or False depending on whether this ASTNode has the correct number of children for its type. More...
 
def hasTypeAndNumChildren (self, type, numchildren)
 Returns True if this node is of type. More...
 
def hasUnits (self)
 Returns True (non-zero) if this node or any of its children nodes have the attribute sbml:units. More...
 
def insertChild (self, n, disownedChild)
 Inserts the given ASTNode at point n in the list of children of this ASTNode. More...
 
def isAvogadro (self)
 Returns True (non-zero) if this node is the special symbol avogadro. More...
 
def isBoolean (self)
 Returns True (non-zero) if this node has a boolean type (a logical operator, a relational operator, or the constants True or False). More...
 
def isCiNumber (self)
 
def isConstant (self)
 
def isConstantNumber (self)
 
def isCSymbolFunction (self)
 Returns True (non-zero) if this node represents a MathML csymbol representing a function. More...
 
def isFunction (self)
 
def isInfinity (self)
 Returns True (non-zero) if this node represents the special IEEE 754 value infinity, False (zero) otherwise. More...
 
def isInteger (self)
 Returns True (non-zero) if this node contains an integer value, False (zero) otherwise. More...
 
def isLambda (self)
 Returns True (non-zero) if this node is a MathML <lambda>, False (zero) otherwise. More...
 
def isLog10 (self)
 Returns True (non-zero) if this node represents a log10 function, False (zero) otherwise. More...
 
def isLogical (self)
 
def isName (self)
 Returns True (non-zero) if this node is a user-defined variable name in SBML L1, L2 (MathML), or the special symbols time or avogadro. More...
 
def isNaN (self)
 Returns True (non-zero) if this node represents the special IEEE 754 value 'not a number' (NaN), False (zero) otherwise. More...
 
def isNegInfinity (self)
 Returns True (non-zero) if this node represents the special IEEE 754 value 'negative infinity', False (zero) otherwise. More...
 
def isNumber (self)
 Returns True (non-zero) if this node contains a number, False (zero) otherwise. More...
 
def isOperator (self)
 Returns True (non-zero) if this node is a mathematical operator, meaning, +, -, *, / or ^ (power). More...
 
def isPiecewise (self)
 Returns True (non-zero) if this node is the MathML <piecewise> construct, False (zero) otherwise. More...
 
def isRational (self)
 Returns True (non-zero) if this node represents a rational number, False (zero) otherwise. More...
 
def isReal (self)
 Returns True (non-zero) if this node can represent a real number, False (zero) otherwise. More...
 
def isRelational (self)
 Returns True (non-zero) if this node is a MathML relational operator, meaning ==, >=, >, <, and !=. More...
 
def isSetClass (self)
 Returns True (non-zero) if this node has a value for the MathML attribute 'class'. More...
 
def isSetId (self)
 Returns True (non-zero) if this node has a value for the MathML attribute 'id'. More...
 
def isSetParentSBMLObject (self)
 Returns True if this node has a value for the parent SBML object. More...
 
def isSetStyle (self)
 Returns True (non-zero) if this node has a value for the MathML attribute 'style'. More...
 
def isSetUnits (self)
 Returns True (non-zero) if this node has the attribute sbml:units. More...
 
def isSetUserData (self)
 Returns True if this node has a user data object. More...
 
def isSqrt (self)
 Returns True (non-zero) if this node represents a square root function, False (zero) otherwise. More...
 
def isUMinus (self)
 Returns True (non-zero) if this node is a unary minus operator, False (zero) otherwise. More...
 
def isUnknown (self)
 Returns True (non-zero) if this node has an unknown type. More...
 
def isUPlus (self)
 Returns True (non-zero) if this node is a unary plus operator, False (zero) otherwise. More...
 
def isUserFunction (self)
 Returns True (non-zero) if this node represents a MathML user-defined function. More...
 
def isWellFormedASTNode (self)
 Returns True or False depending on whether this ASTNode is well-formed. More...
 
def prependChild (self, disownedChild)
 Adds the given node as a child of this ASTNode. More...
 
def reduceToBinary (self)
 Reduces this ASTNode to a binary tree. More...
 
def removeChild (self, n)
 Removes the nth child of this ASTNode object. More...
 
def renameSIdRefs (self, oldid, newid)
 
def renameUnitSIdRefs (self, oldid, newid)
 Renames all the UnitSIdRef attributes on this node and any child node. More...
 
def replaceArgument (self, bvar, arg)
 Replaces occurences of a given name within this ASTNode with the name/value/formula represented by arg. More...
 
def replaceChild (self, n, disownedChild, delreplaced=False)
 Replaces and optionally deletes the nth child of this ASTNode with the given ASTNode. More...
 
def returnsBoolean (self, model=None)
 Returns True (non-zero) if this node returns a boolean type or False (zero) otherwise. More...
 
def setCharacter (self, value)
 Sets the value of this ASTNode to the given character. More...
 
def setClass (self, className)
 Sets the MathML class of this ASTNode to className. More...
 
def setDefinitionURL (self, args)
 
def setId (self, id)
 Sets the MathML id of this ASTNode to id. More...
 
def setName (self, name)
 Sets the value of this ASTNode to the given name. More...
 
def setStyle (self, style)
 Sets the MathML style of this ASTNode to style. More...
 
def setType (self, type)
 Sets the type of this ASTNode to the given type code. More...
 
def setUnits (self, units)
 Sets the units of this ASTNode to units. More...
 
def setValue (self, args)
 This method has multiple variants; they differ in the arguments they accept. More...
 
def swapChildren (self, that)
 Swaps the children of this ASTNode object with the children of the given ASTNode object. More...
 
def unsetClass (self)
 Unsets the MathML class of this ASTNode. More...
 
def unsetId (self)
 Unsets the MathML id of this ASTNode. More...
 
def unsetParentSBMLObject (self)
 Unsets the parent SBML object. More...
 
def unsetStyle (self)
 Unsets the MathML style of this ASTNode. More...
 
def unsetUnits (self)
 Unsets the units of this ASTNode. More...
 
def unsetUserData (self)
 Unsets the user data of this node. More...
 

Constructor & Destructor Documentation

def libsbml.ASTNode.__init__ (   self,
  args 
)

This method has multiple variants; they differ in the arguments they accept.

__init__(long type)   ASTNode
__init__()   ASTNode
__init__(ASTNode orig)   ASTNode

Each variant is described separately below.


Method variant with the following signature:
ASTNode(ASTNode orig)

Copy constructor; creates a deep copy of the given ASTNode.

Parameters
origthe ASTNode to be copied.

Method variant with the following signature:
ASTNode(Token_t *token)

Creates a new ASTNode from the given Token. The resulting ASTNode will contain the same data as the Token.

Parameters
tokenthe Token to add.

Method variant with the following signature:
ASTNode(long type = AST_UNKNOWN)

Creates and returns a new ASTNode.

Unless the argument type is given, the returned node will by default have a type of AST_UNKNOWN. If the type isn't supplied when caling this constructor, the caller should set the node type to something else as soon as possible using ASTNode.setType().

Parameters
typean optional type code indicating the type of node to create.
Note
Owing to the way that language interfaces are created in libSBML, this documentation may show methods that define default values for parameters with text that has the form parameter = value. This is not to be intepreted as a Python keyword argument; the use of a parameter name followed by an equals sign followed by a value is only meant to indicate a default value if the argument is not provided at all. It is not a keyword in the Python sense.

Member Function Documentation

def libsbml.ASTNode.addChild (   self,
  disownedChild,
  inRead = False 
)

Adds the given node as a child of this ASTNode.

addChild(ASTNode disownedChild, bool inRead)   int
addChild(ASTNode disownedChild)   int

Child nodes are added in-order, from left to right.

Parameters
disownedChildthe ASTNode instance to add
inReadhack used for representsBVar function to be correct
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
Warning
Explicitly adding, removing or replacing children of an ASTNode object may change the structure of the mathematical formula it represents, and may even render the representation invalid. Callers need to be careful to use this method in the context of other operations to create complete and correct formulas. The methodASTNode.isWellFormedASTNode() may also be useful for checking the results of node modifications.
See also
prependChild()
replaceChild()
insertChild()
removeChild()
isWellFormedASTNode()
Note
Owing to the way that language interfaces are created in libSBML, this documentation may show methods that define default values for parameters with text that has the form parameter = value. This is not to be intepreted as a Python keyword argument; the use of a parameter name followed by an equals sign followed by a value is only meant to indicate a default value if the argument is not provided at all. It is not a keyword in the Python sense.
def libsbml.ASTNode.addSemanticsAnnotation (   self,
  disownedAnnotation 
)

Adds the given XMLNode as a semantic annotation of this ASTNode.

addSemanticsAnnotation(XMLNode disownedAnnotation)   int
The <semantics> element is a MathML 2.0 construct
that can be used to associate additional information with a MathML
construct.  The construct can be used to decorate a MathML expressions with
a sequence of one or more <annotation> or
<annotation-xml> elements.  Each such element contains a
pair of items; the first is a symbol that acts as an attribute or key, and
the second is the value associated with the attribute or key.  Please refer
to the MathML 2.0 documentation, particularly the Section
5.2, Semantic Annotations for more information about these constructs.
Parameters
disownedAnnotationthe annotation to add.
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
Note
Although SBML permits the semantic annotation construct in MathML expressions, the truth is that this construct has so far (at this time of this writing, which is early 2011) seen very little use in SBML software. The full implications of using semantic annotations are still poorly understood. If you wish to use this construct, we urge you to discuss possible uses and applications on the SBML discussion lists, particularly sbml-discuss&#64;caltech.edu and/or sbml-interoperability&#64;caltech.edu.
def libsbml.ASTNode.canonicalize (   self)

Converts this ASTNode to a canonical form and returns True if successful, False otherwise.

canonicalize()   bool

The rules determining the canonical form conversion are as follows:

  • If the node type is AST_NAME and the node name matches 'ExponentialE', 'Pi', 'True' or 'False' the node type is converted to the corresponding AST_CONSTANT_X type.

  • If the node type is an AST_FUNCTION and the node name matches an SBML (MathML) function name, logical operator name, or relational operator name, the node is converted to the corresponding AST_FUNCTION_X or AST_LOGICAL_X type.

SBML Level 1 function names are searched first; thus, for example, canonicalizing log will result in a node type of AST_FUNCTION_LN. (See the SBML Level 1 Version 2 Specification, Appendix C.)

Sometimes, canonicalization of a node results in a structural conversion of the node as a result of adding a child. For example, a node with the SBML Level 1 function name sqr and a single child node (the argument) will be transformed to a node of type AST_FUNCTION_POWER with two children. The first child will remain unchanged, but the second child will be an ASTNode of type AST_INTEGER and a value of 2. The function names that result in structural changes are: log10, sqr, and sqrt.

def libsbml.ASTNode.deepCopy (   self)

Creates a recursive copy of this node and all its children.

deepCopy()   ASTNode
Returns
a copy of this ASTNode and all its children. The caller owns the returned ASTNode and is responsible for deleting it.
def libsbml.ASTNode.freeName (   self)

Frees the name of this ASTNode and sets it to None.

freeName()   int

This operation is only applicable to ASTNode objects corresponding to operators, numbers, or AST_UNKNOWN. This method has no effect on other types of nodes.

Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.ASTNode.getASTPlugin (   self,
  args 
)

This method has multiple variants; they differ in the arguments they accept.

getASTPlugin(SBMLNamespaces sbmlns)   ASTBasePlugin
getASTPlugin(long type)   ASTBasePlugin
getASTPlugin(string name, bool isCsymbol, bool strCmpIsCaseSensitive)   ASTBasePlugin
getASTPlugin(string name, bool isCsymbol)   ASTBasePlugin
getASTPlugin(string name)   ASTBasePlugin

Each variant is described separately below.


Method variant with the following signature:
getASTPlugin(SBMLNamespaces sbmlns)

Method variant with the following signature:
getASTPlugin(string name, bool isCsymbol = false, bool strCmpIsCaseSensitive = false)
Note
Owing to the way that language interfaces are created in libSBML, this documentation may show methods that define default values for parameters with text that has the form parameter = value. This is not to be intepreted as a Python keyword argument; the use of a parameter name followed by an equals sign followed by a value is only meant to indicate a default value if the argument is not provided at all. It is not a keyword in the Python sense.

Method variant with the following signature:
getASTPlugin(long type)
def libsbml.ASTNode.getCharacter (   self)

Gets the value of this node as a single character.

getCharacter()   char

This function should be called only when ASTNode.getType() returns AST_PLUS, AST_MINUS, AST_TIMES, AST_DIVIDE or AST_POWER.

Returns
the value of this ASTNode as a single character
def libsbml.ASTNode.getChild (   self,
  n 
)

Gets a child of this node according to its index number.

getChild(long  n)   ASTNode
Parameters
nthe index of the child to get
Returns
the nth child of this ASTNode or None if this node has no nth child (n > ASTNode.getNumChildren() - 1).
See also
getNumChildren()
getLeftChild()
getRightChild()
def libsbml.ASTNode.getClass (   self)

Gets the class of this ASTNode.

getClass()   string
Returns
the MathML class of this ASTNode.
def libsbml.ASTNode.getDefinitionURL (   self)

Gets the MathML 'definitionURL' attribute value.

getDefinitionURL()   XMLAttributes
Returns
the value of the definitionURL attribute, in the form of a libSBML XMLAttributes object.
def libsbml.ASTNode.getDefinitionURLString (   self)

Returns the MathML definitionURL attribute value as a string.

getDefinitionURLString()   string
Returns
the value of the definitionURL attribute, as a string.
See also
getDefinitionURL()
setDefinitionURL()
setDefinitionURL()
def libsbml.ASTNode.getDenominator (   self)

Gets the value of the denominator of this node.

getDenominator()   long

This function should be called only when ASTNode.getType() == AST_RATIONAL.

Returns
the value of the denominator of this ASTNode.
def libsbml.ASTNode.getExponent (   self)

Gets the exponent value of this ASTNode.

getExponent()   long

This function should be called only when ASTNode.getType() returns AST_REAL_E or AST_REAL.

Returns
the value of the exponent of this ASTNode.
def libsbml.ASTNode.getId (   self)

Gets the id of this ASTNode.

getId()   string
Returns
the MathML id of this ASTNode.
def libsbml.ASTNode.getInteger (   self)

Gets the value of this node as an integer.

getInteger()   long

This function should be called only whenASTNode.getType() == AST_INTEGER.

Returns
the value of this ASTNode as a (long) integer.
def libsbml.ASTNode.getLeftChild (   self)

Gets the left child of this node.

getLeftChild()   ASTNode
Returns
the left child of this ASTNode. This is equivalent to calling ASTNode.getChild() with an argument of 0.
See also
getNumChildren()
getChild()
getRightChild()
def libsbml.ASTNode.getListOfNodes (   self)

Returns a list of nodes.

getListOfNodes()   ASTNodeList

Unlike the equivalent method in the libSBML C/C++ interface, this method does not offer the ability to pass a predicate as an argument. The method always returns the list of all ASTNode objects.

Returns
the ASTNodeList of nodes.
Warning
The list returned is owned by the caller and should be deleted after the caller is done using it. The ASTNode objects in the list; however, are not owned by the caller (as they still belong to the tree itself), and therefore should not be deleted.
def libsbml.ASTNode.getMantissa (   self)

Gets the mantissa value of this node.

getMantissa()   float

This function should be called only when ASTNode.getType() returns AST_REAL_E or AST_REAL. If ASTNode.getType() returns AST_REAL, this method is identical to ASTNode.getReal().

Returns
the value of the mantissa of this ASTNode.
def libsbml.ASTNode.getName (   self)

Gets the value of this node as a string.

getName()   string  *

This function may be called on nodes that (1) are not operators, i.e., nodes for whichASTNode.isOperator() returns False, and (2) are not numbers, i.e., ASTNode.isNumber() returns False.

Returns
the value of this ASTNode as a string.
def libsbml.ASTNode.getNumChildren (   self)

Gets the number of children that this node has.

getNumChildren()   long
Returns
the number of children of this ASTNode, or 0 is this node has no children.
def libsbml.ASTNode.getNumerator (   self)

Gets the value of the numerator of this node.

getNumerator()   long

This function should be called only when ASTNode.getType() == AST_RATIONAL.

Returns
the value of the numerator of this ASTNode.
def libsbml.ASTNode.getNumSemanticsAnnotations (   self)

Gets the number of semantic annotation elements inside this node.

getNumSemanticsAnnotations()   long
The <semantics> element is a MathML 2.0 construct
that can be used to associate additional information with a MathML
construct.  The construct can be used to decorate a MathML expressions with
a sequence of one or more <annotation> or
<annotation-xml> elements.  Each such element contains a
pair of items; the first is a symbol that acts as an attribute or key, and
the second is the value associated with the attribute or key.  Please refer
to the MathML 2.0 documentation, particularly the Section
5.2, Semantic Annotations for more information about these constructs.
Returns
the number of annotations of this ASTNode.
See also
ASTNode.addSemanticsAnnotation()
def libsbml.ASTNode.getOperatorName (   self)

Gets the value of this operator node as a string.

getOperatorName()   string  *

This function may be called on nodes that are operators, i.e., nodes for which ASTNode.isOperator() returns True.

Returns
the name of this operator ASTNode as a string (or None if not an operator).
def libsbml.ASTNode.getParentSBMLObject (   self)

Returns the parent SBML object.

getParentSBMLObject()   SBase
Returns
the parent SBML object of this ASTNode.
def libsbml.ASTNode.getPlugin (   self,
  args 
)
getPlugin(string package)   ASTBasePlugin
getPlugin(long  n)   ASTBasePlugin
def libsbml.ASTNode.getPrecedence (   self)

Gets the precedence of this node in the infix math syntax of SBML Level 1.

getPrecedence()   int

For more information about the infix syntax, see the discussion about text string formulas at the top of the documentation for ASTNode.

Returns
an integer indicating the precedence of this ASTNode
def libsbml.ASTNode.getReal (   self)

Gets the real-numbered value of this node.

getReal()   float

This function should be called only when ASTNode.isReal() == true.

This function performs the necessary arithmetic if the node type is AST_REAL_E (mantissa * 10 exponent) or AST_RATIONAL (numerator / denominator).

Returns
the value of this ASTNode as a real (float).
def libsbml.ASTNode.getRightChild (   self)

Gets the right child of this node.

getRightChild()   ASTNode
Returns
the right child of this ASTNode, or None if this node has no right child. If ASTNode.getNumChildren() > 1, then this is equivalent to:
getChild( getNumChildren() - 1 );
See also
getNumChildren()
getLeftChild()
getChild()
def libsbml.ASTNode.getSemanticsAnnotation (   self,
  n 
)

Gets the nth semantic annotation of this node.

getSemanticsAnnotation(long  n)   XMLNode
The <semantics> element is a MathML 2.0 construct
that can be used to associate additional information with a MathML
construct.  The construct can be used to decorate a MathML expressions with
a sequence of one or more <annotation> or
<annotation-xml> elements.  Each such element contains a
pair of items; the first is a symbol that acts as an attribute or key, and
the second is the value associated with the attribute or key.  Please refer
to the MathML 2.0 documentation, particularly the Section
5.2, Semantic Annotations for more information about these constructs.
Returns
the nth annotation of this ASTNode, or None if this node has no nth annotation (n > ASTNode.getNumSemanticsAnnotations() - 1).
See also
ASTNode.addSemanticsAnnotation()
def libsbml.ASTNode.getStyle (   self)

Gets the style of this ASTNode.

getStyle()   string
Returns
the MathML style of this ASTNode.
def libsbml.ASTNode.getType (   self)

Gets the type of this ASTNode.

getType()   long

The value returned is one of the enumeration values such as AST_LAMBDA, AST_PLUS, etc.

Returns
the type of this ASTNode.
def libsbml.ASTNode.getUnits (   self)

Gets the units of this ASTNode.

getUnits()   string
SBML Level 3 Version 1 introduced the ability to include an
attribute sbml:units on MathML cn elements
appearing in SBML mathematical formulas.  The value of this attribute can
be used to indicate the unit of measurement to be associated with the
number in the content of the cn element.  The value of this
attribute must be the identifier of a unit of measurement defined by SBML
or the enclosing Model.  Here, the sbml portion is an XML
namespace prefix that must be associated with the SBML namespace for SBML
Level 3.  The following example illustrates how this attribute can be
used to define a number with value 10 and unit of measurement
second:
<math xmlns="http://www.w3.org/1998/Math/MathML"
      xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core">
        <cn type="integer" sbml:units="second"> 10 </cn>
</math>
Returns
the units of this ASTNode.
Note
The sbml:units attribute is only available in SBML Level 3. It may not be used in Levels 1–2 of SBML.
See also
libsbml.parseL3Formula()
def libsbml.ASTNode.getValue (   self)

Returns the numerical value of this ASTNode.

getValue()   float
Returns
the numerical value of this ASTNode, or NaN if this is not a type of node that has a numerical value.
Note
This function will return a numerical value (as a float) for any ASTNode_t that represents a number, a constant such as AST_CONSTANT_PI, AST_CONSTANT_E, or AST_NAME_AVOGADRO, or 1 for nodes of type AST_CONSTANT_TRUE and 0 for nodes of type AST_CONSTANT_FALSE. It does not evaluate the node in any way so, for example, it will not return the value of a named ASTNode_t or attempt to evaluate a function. This includes a node representing time i.e. nodes of type AST_NAME_TIME.
def libsbml.ASTNode.hasCorrectNumberArguments (   self)

Returns True or False depending on whether this ASTNode has the correct number of children for its type.

hasCorrectNumberArguments()   bool

For example, an ASTNode with type AST_PLUS expects 2 child nodes.

Note
This function performs a check on the top-level node only. Child nodes are not checked.
Returns
True if this ASTNode has the appropriate number of children for its type, False otherwise.
See also
isWellFormedASTNode()
def libsbml.ASTNode.hasTypeAndNumChildren (   self,
  type,
  numchildren 
)

Returns True if this node is of type.

Parameters
typeand has
numchildrennumber of children.
hasTypeAndNumChildren(long type, long  numchildren)   int

Designed for use in cases where it is useful to discover if the node is a unary not or unary minus, or a times node with no children, etc.

Returns
True if this ASTNode is has the specified type and number of children, False otherwise.
def libsbml.ASTNode.hasUnits (   self)

Returns True (non-zero) if this node or any of its children nodes have the attribute sbml:units.

hasUnits()   bool
SBML Level 3 Version 1 introduced the ability to include an
attribute sbml:units on MathML cn elements
appearing in SBML mathematical formulas.  The value of this attribute can
be used to indicate the unit of measurement to be associated with the
number in the content of the cn element.  The value of this
attribute must be the identifier of a unit of measurement defined by SBML
or the enclosing Model.  Here, the sbml portion is an XML
namespace prefix that must be associated with the SBML namespace for SBML
Level 3.  The following example illustrates how this attribute can be
used to define a number with value 10 and unit of measurement
second:
<math xmlns="http://www.w3.org/1998/Math/MathML"
      xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core">
        <cn type="integer" sbml:units="second"> 10 </cn>
</math>
Returns
True if this ASTNode or its children has units associated with it, False otherwise.
Note
The sbml:units attribute is only available in SBML Level 3. It may not be used in Levels 1–2 of SBML.
def libsbml.ASTNode.insertChild (   self,
  n,
  disownedChild 
)

Inserts the given ASTNode at point n in the list of children of this ASTNode.

insertChild(long  n, ASTNode disownedChild)   int
Parameters
nlong the index of the ASTNode being added
disownedChildASTNode to insert as the nth child
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
Warning
Explicitly adding, removing or replacing children of an ASTNode object may change the structure of the mathematical formula it represents, and may even render the representation invalid. Callers need to be careful to use this method in the context of other operations to create complete and correct formulas. The methodASTNode.isWellFormedASTNode() may also be useful for checking the results of node modifications.
See also
addChild()
prependChild()
replaceChild()
removeChild()
def libsbml.ASTNode.isAvogadro (   self)

Returns True (non-zero) if this node is the special symbol avogadro.

isAvogadro()   bool

The predicate returns False (zero) otherwise.

Returns
True if this ASTNode is the special symbol avogadro.
See also
libsbml.parseL3Formula()
def libsbml.ASTNode.isBoolean (   self)

Returns True (non-zero) if this node has a boolean type (a logical operator, a relational operator, or the constants True or False).

isBoolean()   bool
Returns
true if this ASTNode is a boolean, false otherwise.
def libsbml.ASTNode.isCiNumber (   self)
isCiNumber()   bool
 

Returns True (non-zero) if this node represents a MathML ci element representing a value not a function (e.g., True, Pi).

Returns
True if this ASTNode is a MathML ci element, False otherwise.
def libsbml.ASTNode.isConstant (   self)
isConstant()   bool
 

Returns True (non-zero) if this node represents a MathML constant (e.g., True, Pi).

Returns
True if this ASTNode is a MathML constant, False otherwise.
Note
this function will also return True for AST_NAME_AVOGADRO in SBML Level 3.
def libsbml.ASTNode.isConstantNumber (   self)
isConstantNumber()   bool
 

Returns True (non-zero) if this node represents a MathML constant with numeric value(e.g., Pi).

Returns
True if this ASTNode is a MathML constant, False otherwise.
Note
this function will also return True for AST_NAME_AVOGADRO in SBML Level 3.
def libsbml.ASTNode.isCSymbolFunction (   self)

Returns True (non-zero) if this node represents a MathML csymbol representing a function.

isCSymbolFunction()   bool
Returns
True if this ASTNode is a MathML csymbol function, False otherwise.
def libsbml.ASTNode.isFunction (   self)
isFunction()   bool
 

Returns True (non-zero) if this node represents a MathML function (e.g., abs()), or an SBML Level 1 function, or a user-defined function.

Returns
True if this ASTNode is a function, False otherwise.
def libsbml.ASTNode.isInfinity (   self)

Returns True (non-zero) if this node represents the special IEEE 754 value infinity, False (zero) otherwise.

isInfinity()   bool
Returns
True if this ASTNode is the special IEEE 754 value infinity, False otherwise.
def libsbml.ASTNode.isInteger (   self)

Returns True (non-zero) if this node contains an integer value, False (zero) otherwise.

isInteger()   bool
Returns
True if this ASTNode is of type AST_INTEGER, False otherwise.
def libsbml.ASTNode.isLambda (   self)

Returns True (non-zero) if this node is a MathML <lambda>, False (zero) otherwise.

isLambda()   bool
Returns
True if this ASTNode is of type AST_LAMBDA, False otherwise.
def libsbml.ASTNode.isLog10 (   self)

Returns True (non-zero) if this node represents a log10 function, False (zero) otherwise.

isLog10()   bool

More precisely, this predicate returns True if the node type is AST_FUNCTION_LOG with two children, the first of which is an AST_INTEGER equal to 10.

Returns
True if the given ASTNode represents a log10() function, False otherwise.
See also
libsbml.parseL3Formula()
def libsbml.ASTNode.isLogical (   self)
isLogical()   bool
 

Returns True (non-zero) if this node is a MathML logical operator (i.e., and, or, not, xor).

Returns
True if this ASTNode is a MathML logical operator
def libsbml.ASTNode.isName (   self)

Returns True (non-zero) if this node is a user-defined variable name in SBML L1, L2 (MathML), or the special symbols time or avogadro.

isName()   bool

The predicate returns False (zero) otherwise.

Returns
True if this ASTNode is a user-defined variable name in SBML L1, L2 (MathML) or the special symbols delay or time.
def libsbml.ASTNode.isNaN (   self)

Returns True (non-zero) if this node represents the special IEEE 754 value 'not a number' (NaN), False (zero) otherwise.

isNaN()   bool
Returns
True if this ASTNode is the special IEEE 754 NaN.
def libsbml.ASTNode.isNegInfinity (   self)

Returns True (non-zero) if this node represents the special IEEE 754 value 'negative infinity', False (zero) otherwise.

isNegInfinity()   bool
Returns
True if this ASTNode is the special IEEE 754 value negative infinity, False otherwise.
def libsbml.ASTNode.isNumber (   self)

Returns True (non-zero) if this node contains a number, False (zero) otherwise.

isNumber()   bool

This is functionally equivalent to the following code:

 isInteger() || isReal()
Returns
True if this ASTNode is a number, False otherwise.
def libsbml.ASTNode.isOperator (   self)

Returns True (non-zero) if this node is a mathematical operator, meaning, +, -, *, / or ^ (power).

isOperator()   bool
Returns
True if this ASTNode is an operator.
def libsbml.ASTNode.isPiecewise (   self)

Returns True (non-zero) if this node is the MathML <piecewise> construct, False (zero) otherwise.

isPiecewise()   bool
Returns
True if this ASTNode is a MathML piecewise function
def libsbml.ASTNode.isRational (   self)

Returns True (non-zero) if this node represents a rational number, False (zero) otherwise.

isRational()   bool
Returns
True if this ASTNode is of type AST_RATIONAL.
def libsbml.ASTNode.isReal (   self)

Returns True (non-zero) if this node can represent a real number, False (zero) otherwise.

isReal()   bool

More precisely, this node must be of one of the following types: AST_REAL, AST_REAL_E or AST_RATIONAL.

Returns
True if the value of this ASTNode can represented as a real number, False otherwise.
def libsbml.ASTNode.isRelational (   self)

Returns True (non-zero) if this node is a MathML relational operator, meaning ==, >=, >, <, and !=.

isRelational()   bool
Returns
True if this ASTNode is a MathML relational operator, False otherwise
def libsbml.ASTNode.isSetClass (   self)

Returns True (non-zero) if this node has a value for the MathML attribute 'class'.

isSetClass()   bool
Returns
true if this ASTNode has an attribute class, false otherwise.
def libsbml.ASTNode.isSetId (   self)

Returns True (non-zero) if this node has a value for the MathML attribute 'id'.

isSetId()   bool
Returns
true if this ASTNode has an attribute id, false otherwise.
def libsbml.ASTNode.isSetParentSBMLObject (   self)

Returns True if this node has a value for the parent SBML object.

isSetParentSBMLObject()   bool
Returns
true if this ASTNode has an parent SBML object set, False otherwise.
See also
getParentSBMLObject()
def libsbml.ASTNode.isSetStyle (   self)

Returns True (non-zero) if this node has a value for the MathML attribute 'style'.

isSetStyle()   bool
Returns
true if this ASTNode has an attribute style, false otherwise.
def libsbml.ASTNode.isSetUnits (   self)

Returns True (non-zero) if this node has the attribute sbml:units.

isSetUnits()   bool
SBML Level 3 Version 1 introduced the ability to include an
attribute sbml:units on MathML cn elements
appearing in SBML mathematical formulas.  The value of this attribute can
be used to indicate the unit of measurement to be associated with the
number in the content of the cn element.  The value of this
attribute must be the identifier of a unit of measurement defined by SBML
or the enclosing Model.  Here, the sbml portion is an XML
namespace prefix that must be associated with the SBML namespace for SBML
Level 3.  The following example illustrates how this attribute can be
used to define a number with value 10 and unit of measurement
second:
<math xmlns="http://www.w3.org/1998/Math/MathML"
      xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core">
        <cn type="integer" sbml:units="second"> 10 </cn>
</math>
Returns
True if this ASTNode has units associated with it, False otherwise.
Note
The sbml:units attribute is only available in SBML Level 3. It may not be used in Levels 1–2 of SBML.
def libsbml.ASTNode.isSetUserData (   self)

Returns True if this node has a user data object.

isSetUserData()   bool
Returns
true if this ASTNode has a user data object set, False otherwise.
def libsbml.ASTNode.isSqrt (   self)

Returns True (non-zero) if this node represents a square root function, False (zero) otherwise.

isSqrt()   bool

More precisely, the node type must be AST_FUNCTION_ROOT with two children, the first of which is an AST_INTEGER node having value equal to 2.

Returns
True if the given ASTNode represents a sqrt() function, False otherwise.
def libsbml.ASTNode.isUMinus (   self)

Returns True (non-zero) if this node is a unary minus operator, False (zero) otherwise.

isUMinus()   bool

A node is defined as a unary minus node if it is of type AST_MINUS and has exactly one child.

For numbers, unary minus nodes can be 'collapsed' by negating the number. In fact, libsbml.parseFormula() does this during its parsing process, and libsbml.parseL3Formula() has a configuration option that allows this behavior to be turned on or off. However, unary minus nodes for symbols (AST_NAME) cannot be 'collapsed', so this predicate function is necessary.

Returns
True if this ASTNode is a unary minus, False otherwise.
See also
libsbml.parseL3Formula()
def libsbml.ASTNode.isUnknown (   self)

Returns True (non-zero) if this node has an unknown type.

isUnknown()   bool

'Unknown' nodes have the type AST_UNKNOWN. Nodes with unknown types will not appear in an ASTNode tree returned by libSBML based upon valid SBML input; the only situation in which a node with type AST_UNKNOWN may appear is immediately after having create a new, untyped node using the ASTNode constructor. Callers creating nodes should endeavor to set the type to a valid node type as soon as possible after creating new nodes.

Returns
True if this ASTNode is of type AST_UNKNOWN, False otherwise.
def libsbml.ASTNode.isUPlus (   self)

Returns True (non-zero) if this node is a unary plus operator, False (zero) otherwise.

isUPlus()   bool

A node is defined as a unary minus node if it is of type AST_MINUS and has exactly one child.

Returns
True if this ASTNode is a unary plus, False otherwise.
def libsbml.ASTNode.isUserFunction (   self)

Returns True (non-zero) if this node represents a MathML user-defined function.

isUserFunction()   bool
Returns
True if this ASTNode is a user-defined function, False otherwise.
def libsbml.ASTNode.isWellFormedASTNode (   self)

Returns True or False depending on whether this ASTNode is well-formed.

isWellFormedASTNode()   bool
Note
An ASTNode may be well-formed, with each node and its children having the appropriate number of children for the given type, but may still be invalid in the context of its use within an SBML model.
Returns
True if this ASTNode is well-formed, False otherwise.
See also
hasCorrectNumberArguments()
def libsbml.ASTNode.prependChild (   self,
  disownedChild 
)

Adds the given node as a child of this ASTNode.

prependChild(ASTNode disownedChild)   int

This method adds child nodes from right to left.

Parameters
disownedChildthe ASTNode instance to add
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
Warning
Explicitly adding, removing or replacing children of an ASTNode object may change the structure of the mathematical formula it represents, and may even render the representation invalid. Callers need to be careful to use this method in the context of other operations to create complete and correct formulas. The methodASTNode.isWellFormedASTNode() may also be useful for checking the results of node modifications.
See also
addChild()
replaceChild()
insertChild()
removeChild()
def libsbml.ASTNode.reduceToBinary (   self)

Reduces this ASTNode to a binary tree.

reduceToBinary()

Example: if this ASTNode is and(x, y, z), then the formula of the reduced node is and(and(x, y), z). The operation replaces the formula stored in the current ASTNode object.

def libsbml.ASTNode.removeChild (   self,
  n 
)

Removes the nth child of this ASTNode object.

removeChild(long  n)   int
Parameters
nlong the index of the child to remove
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
Warning
Explicitly adding, removing or replacing children of an ASTNode object may change the structure of the mathematical formula it represents, and may even render the representation invalid. Callers need to be careful to use this method in the context of other operations to create complete and correct formulas. The methodASTNode.isWellFormedASTNode() may also be useful for checking the results of node modifications.
See also
addChild()
prependChild()
replaceChild()
insertChild()
def libsbml.ASTNode.renameSIdRefs (   self,
  oldid,
  newid 
)
renameSIdRefs(string oldid, string newid)
 

Renames all the SIdRef attributes on this node and any child node

def libsbml.ASTNode.renameUnitSIdRefs (   self,
  oldid,
  newid 
)

Renames all the UnitSIdRef attributes on this node and any child node.

renameUnitSIdRefs(string oldid, string newid)

(The only place UnitSIDRefs appear in MathML <cn> elements.)

def libsbml.ASTNode.replaceArgument (   self,
  bvar,
  arg 
)

Replaces occurences of a given name within this ASTNode with the name/value/formula represented by arg.

replaceArgument(string bvar, ASTNode arg)

For example, if the formula in this ASTNode is x + y, then the <bvar> is x and arg is an ASTNode representing the real value 3. This method substitutes 3 for x within this ASTNode object.

Parameters
bvara string representing the variable name to be substituted
argan ASTNode representing the name/value/formula to substitute
def libsbml.ASTNode.replaceChild (   self,
  n,
  disownedChild,
  delreplaced = False 
)

Replaces and optionally deletes the nth child of this ASTNode with the given ASTNode.

replaceChild(long  n, ASTNode disownedChild, bool delreplaced)   int
replaceChild(long  n, ASTNode disownedChild)   int
Parameters
nlong the index of the child to replace
disownedChildASTNode to replace the nth child
delreplacedboolean indicating whether to delete the replaced child.
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
Warning
Explicitly adding, removing or replacing children of an ASTNode object may change the structure of the mathematical formula it represents, and may even render the representation invalid. Callers need to be careful to use this method in the context of other operations to create complete and correct formulas. The methodASTNode.isWellFormedASTNode() may also be useful for checking the results of node modifications.
See also
addChild()
prependChild()
insertChild()
removeChild()
def libsbml.ASTNode.returnsBoolean (   self,
  model = None 
)

Returns True (non-zero) if this node returns a boolean type or False (zero) otherwise.

returnsBoolean(Model model)   bool
returnsBoolean()   bool

This function looks at the whole ASTNode rather than just the top level of the ASTNode. Thus it will consider return values from piecewise statements. In addition, if this ASTNode uses a function call, the return value of the functionDefinition will be determined. Note that this is only possible where the ASTNode can trace its parent Model, that is, the ASTNode must represent the math element of some SBML object that has already been added to an instance of an SBMLDocument.

See also
isBoolean()
Returns
true if this ASTNode returns a boolean, false otherwise.
def libsbml.ASTNode.setCharacter (   self,
  value 
)

Sets the value of this ASTNode to the given character.

setCharacter(char value)   int

If character is one of +, -, *, / or ^, the node type will be set accordingly. For all other characters, the node type will be set to AST_UNKNOWN.

Parameters
valuethe character value to which the node's value should be set.
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.ASTNode.setClass (   self,
  className 
)

Sets the MathML class of this ASTNode to className.

setClass(string className)   int
Parameters
classNamestring representing the MathML class for this node.
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.ASTNode.setDefinitionURL (   self,
  args 
)
setDefinitionURL(XMLAttributes url)   int
setDefinitionURL(string url)   int
def libsbml.ASTNode.setId (   self,
  id 
)

Sets the MathML id of this ASTNode to id.

setId(string id)   int
Parameters
idstring representing the identifier.
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.ASTNode.setName (   self,
  name 
)

Sets the value of this ASTNode to the given name.

setName(long  name)   int

As a side-effect, this ASTNode object's type will be reset to AST_NAME if (and only if) the ASTNode was previously an operator ( ASTNode.isOperator() == true), number ( ASTNode.isNumber() == true), or unknown. This allows names to be set for AST_FUNCTION nodes and the like.

Parameters
namethe string containing the name to which this node's value should be set
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.ASTNode.setStyle (   self,
  style 
)

Sets the MathML style of this ASTNode to style.

setStyle(string style)   int
Parameters
stylestring representing the identifier.
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.ASTNode.setType (   self,
  type 
)

Sets the type of this ASTNode to the given type code.

setType(long type)   int
Parameters
typethe type to which this node should be set
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
Note
A side-effect of doing this is that any numerical values previously stored in this node are reset to zero.
def libsbml.ASTNode.setUnits (   self,
  units 
)

Sets the units of this ASTNode to units.

setUnits(string units)   int

The units will be set only if this ASTNode object represents a MathML <cn> element, i.e., represents a number. Callers may use ASTNode.isNumber() to inquire whether the node is of that type.

SBML Level 3 Version 1 introduced the ability to include an attribute sbml:units on MathML cn elements appearing in SBML mathematical formulas. The value of this attribute can be used to indicate the unit of measurement to be associated with the number in the content of the cn element. The value of this attribute must be the identifier of a unit of measurement defined by SBML or the enclosing Model. Here, the sbml portion is an XML namespace prefix that must be associated with the SBML namespace for SBML Level 3. The following example illustrates how this attribute can be used to define a number with value 10 and unit of measurement second:
<math xmlns="http://www.w3.org/1998/Math/MathML"
      xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core">
        <cn type="integer" sbml:units="second"> 10 </cn>
</math>
Parameters
unitsstring representing the unit identifier.
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
Note
The sbml:units attribute is only available in SBML Level 3. It may not be used in Levels 1–2 of SBML.
def libsbml.ASTNode.setValue (   self,
  args 
)

This method has multiple variants; they differ in the arguments they accept.

setValue(long value)   int
setValue(long numerator, long denominator)   int
setValue (float value)   int
setValue (float mantissa, long exponent)   int

Each variant is described separately below.


Method variant with the following signature:
setValue(long numerator, long denominator)

Sets the value of this ASTNode to the given rational in two parts: the numerator and denominator. The node type is set to AST_RATIONAL.

Parameters
numeratorthe numerator value of the rational
denominatorthe denominator value of the rational
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:

Method variant with the following signature:
setValue (float mantissa, long exponent)

Sets the value of this ASTNode to the given real (float) in two parts: the mantissa and the exponent. The node type is set to AST_REAL_E.

Parameters
mantissathe mantissa of this node's real-numbered value
exponentthe exponent of this node's real-numbered value
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:

Method variant with the following signature:
setValue(int value)

Sets the value of this ASTNode to the given integer and sets the node type to AST_INTEGER.

Parameters
valuethe integer to which this node's value should be set
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:

Method variant with the following signature:
setValue (float value)

Sets the value of this ASTNode to the given real (float) and sets the node type to AST_REAL.

This is functionally equivalent to:

setValue(value, 0);
Parameters
valuethe float format number to which this node's value should be set
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:

Method variant with the following signature:
setValue(long value)

Sets the value of this ASTNode to the given (long) integer and sets the node type to AST_INTEGER.

Parameters
valuethe integer to which this node's value should be set
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.ASTNode.swapChildren (   self,
  that 
)

Swaps the children of this ASTNode object with the children of the given ASTNode object.

swapChildren(ASTNode that)   int
Parameters
thatthe other node whose children should be used to replace this node's children
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.ASTNode.unsetClass (   self)

Unsets the MathML class of this ASTNode.

unsetClass()   int
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.ASTNode.unsetId (   self)

Unsets the MathML id of this ASTNode.

unsetId()   int
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.ASTNode.unsetParentSBMLObject (   self)

Unsets the parent SBML object.

unsetParentSBMLObject()   int
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
See also
isSetParentSBMLObject()
getParentSBMLObject()
def libsbml.ASTNode.unsetStyle (   self)

Unsets the MathML style of this ASTNode.

unsetStyle()   int
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.ASTNode.unsetUnits (   self)

Unsets the units of this ASTNode.

unsetUnits()   int
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.ASTNode.unsetUserData (   self)

Unsets the user data of this node.

unsetUserData()   int

The user data can be used by the application developer to attach custom information to the node. In case of a deep copy, this attribute will passed as it is. The attribute will be never interpreted by this class.

Returns
integer value indicating success/failure of the function. The possible values returned by this function are: