libSBML Python API  5.10.0
 All Classes Namespaces Files Functions Variables Modules Pages
libsbml.ASTNode Class Reference
Inheritance diagram for libsbml.ASTNode:
[legend]

Detailed Description

{core}

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 structure containing a pointer to the node's value (which might be, for example, a number or a symbol) and a list of children nodes. Each ASTNode node may have none, one, two, or more children depending on its type. 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 floatdata 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 the applications can use the text-string based translation functions such as libsbml.formulaToString(), libsbml.parseL3Formula() and libsbml.parseFormula(). 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.

Finally, it is worth noting that the AST and MathML handling code in libSBML remains written in C, not C++. (All of libSBML was originally written in C.) Readers may occasionally wonder why some aspects are more C-like and less object oriented, and that's one of the reasons.

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_COT AST_LOGICAL_NOT
AST_CONSTANT_FALSE AST_FUNCTION_COTH AST_LOGICAL_OR
AST_CONSTANT_PI AST_FUNCTION_CSC AST_LOGICAL_XOR
AST_CONSTANT_TRUE AST_FUNCTION_CSCH AST_MINUS
AST_DIVIDE AST_FUNCTION_DELAY AST_NAME
AST_FUNCTION AST_FUNCTION_EXP AST_NAME_AVOGADRO (Level 3 only)
AST_FUNCTION_ABS AST_FUNCTION_FACTORIAL AST_NAME_TIME
AST_FUNCTION_ARCCOS AST_FUNCTION_FLOOR AST_PLUS
AST_FUNCTION_ARCCOSH AST_FUNCTION_LN AST_POWER
AST_FUNCTION_ARCCOT AST_FUNCTION_LOG AST_RATIONAL
AST_FUNCTION_ARCCOTH AST_FUNCTION_PIECEWISE AST_REAL
AST_FUNCTION_ARCCSC AST_FUNCTION_POWER AST_REAL_E
AST_FUNCTION_ARCCSCH AST_FUNCTION_ROOT AST_RELATIONAL_EQ
AST_FUNCTION_ARCSEC AST_FUNCTION_SEC AST_RELATIONAL_GEQ
AST_FUNCTION_ARCSECH AST_FUNCTION_SECH AST_RELATIONAL_GT
AST_FUNCTION_ARCSIN AST_FUNCTION_SIN AST_RELATIONAL_LEQ
AST_FUNCTION_ARCSINH AST_FUNCTION_SINH AST_RELATIONAL_LT
AST_FUNCTION_ARCTAN AST_FUNCTION_TAN AST_RELATIONAL_NEQ
AST_FUNCTION_ARCTANH AST_FUNCTION_TANH AST_TIMES
AST_FUNCTION_CEILING AST_INTEGER AST_UNKNOWN
AST_FUNCTION_COS AST_LAMBDA
AST_FUNCTION_COSH AST_LOGICAL_AND

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.

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 one of these two text-string formats can be handed to a program that understands SBML mathematical expressions, or used as part of a translation system. The libSBML distribution comes with example programs in the 'examples' subdirectory that demonstrate such things as translating infix formulas into MathML and vice-versa.

Please see the documentation for the functions libsbml.parseFormula() and libsbml.parseL3Formula() for detailed explanations of the infix syntax they accept.

See also
libsbml.parseL3Formula()
libsbml.parseFormula()
libsbml.formulaToString()

Public Member Functions

def addChild
 
def addSemanticsAnnotation
 
def canonicalize
 
def deepCopy
 
def freeName
 
def getCharacter
 
def getChild
 
def getClass
 
def getDefinitionURL
 
def getDefinitionURLString
 
def getDenominator
 
def getExponent
 
def getExtendedType
 
def getId
 
def getInteger
 
def getLeftChild
 
def getListOfNodes
 
def getMantissa
 
def getName
 
def getNumChildren
 
def getNumerator
 
def getNumSemanticsAnnotations
 
def getOperatorName
 
def getParentSBMLObject
 
def getPrecedence
 
def getReal
 
def getRightChild
 
def getSemanticsAnnotation
 
def getStyle
 
def getType
 
def getUnits
 
def hasCorrectNumberArguments
 
def hasTypeAndNumChildren
 
def hasUnits
 
def insertChild
 
def isAvogadro
 
def isBoolean
 
def isConstant
 
def isFunction
 
def isInfinity
 
def isInteger
 
def isLambda
 
def isLog10
 
def isLogical
 
def isName
 
def isNaN
 
def isNegInfinity
 
def isNumber
 
def isOperator
 
def isPiecewise
 
def isQualifier
 
def isRational
 
def isReal
 
def isRelational
 
def isSemantics
 
def isSetClass
 
def isSetId
 
def isSetParentSBMLObject
 
def isSetStyle
 
def isSetUnits
 
def isSetUserData
 
def isSqrt
 
def isUMinus
 
def isUnknown
 
def isUPlus
 
def isWellFormedASTNode
 
def prependChild
 
def reduceToBinary
 
def removeChild
 
def renameSIdRefs
 
def renameUnitSIdRefs
 
def replaceArgument
 
def replaceChild
 
def returnsBoolean
 
def setCharacter
 
def setClass
 
def setDefinitionURL
 
def setId
 
def setName
 
def setStyle
 
def setType
 
def setUnits
 
def setValue
 
def swapChildren
 
def unsetClass
 
def unsetId
 
def unsetParentSBMLObject
 
def unsetStyle
 
def unsetUnits
 
def unsetUserData
 

Member Function Documentation

def libsbml.ASTNode.addChild (   self,
  args 
)

Python method signature(s):

addChild(ASTNode self, ASTNode child)   int

Adds the given node as a child of this ASTNode.

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

Parameters
childthe 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 method ASTNode.isWellFormedASTNode() may also be useful for checking the results of node modifications.
See also
prependChild()
replaceChild()
insertChild()
removeChild()
isWellFormedASTNode()
def libsbml.ASTNode.addSemanticsAnnotation (   self,
  args 
)

Python method signature(s):

addSemanticsAnnotation(ASTNode self, XMLNode sAnnotation)   int

Adds the given XMLNode as a MathML <semantics> element to this ASTNode.

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
sAnnotationthe 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 use of the MathML <semantics> annotation construct, the truth is that this construct has so far (at this time of this writing, which is early 2014) seen very little use in SBML software. The full implications of using these 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 and/or sbml-interoperability.
See also
ASTNode.getNumSemanticsAnnotations()
ASTNode.getSemanticsAnnotation()
def libsbml.ASTNode.canonicalize (   self)

Python method signature(s):

canonicalize(ASTNode self)   bool

Converts this ASTNode to a canonical form.

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.

Returns
True if this node was successfully converted to canonical form, False otherwise.
def libsbml.ASTNode.deepCopy (   self)

Python method signature(s):

deepCopy(ASTNode self)   ASTNode

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

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)

{core}

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 structure containing a pointer to the node's value (which might be, for example, a number or a symbol) and a list of children nodes. Each ASTNode node may have none, one, two, or more children depending on its type. 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 floatdata 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 the applications can use the text-string based translation functions such as libsbml.formulaToString(), libsbml.parseL3Formula() and libsbml.parseFormula(). 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.

Finally, it is worth noting that the AST and MathML handling code in libSBML remains written in C, not C++. (All of libSBML was originally written in C.) Readers may occasionally wonder why some aspects are more C-like and less object oriented, and that's one of the reasons.

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_COT AST_LOGICAL_NOT
AST_CONSTANT_FALSE AST_FUNCTION_COTH AST_LOGICAL_OR
AST_CONSTANT_PI AST_FUNCTION_CSC AST_LOGICAL_XOR
AST_CONSTANT_TRUE AST_FUNCTION_CSCH AST_MINUS
AST_DIVIDE AST_FUNCTION_DELAY AST_NAME
AST_FUNCTION AST_FUNCTION_EXP AST_NAME_AVOGADRO (Level 3 only)
AST_FUNCTION_ABS AST_FUNCTION_FACTORIAL AST_NAME_TIME
AST_FUNCTION_ARCCOS AST_FUNCTION_FLOOR AST_PLUS
AST_FUNCTION_ARCCOSH AST_FUNCTION_LN AST_POWER
AST_FUNCTION_ARCCOT AST_FUNCTION_LOG AST_RATIONAL
AST_FUNCTION_ARCCOTH AST_FUNCTION_PIECEWISE AST_REAL
AST_FUNCTION_ARCCSC AST_FUNCTION_POWER AST_REAL_E
AST_FUNCTION_ARCCSCH AST_FUNCTION_ROOT AST_RELATIONAL_EQ
AST_FUNCTION_ARCSEC AST_FUNCTION_SEC AST_RELATIONAL_GEQ
AST_FUNCTION_ARCSECH AST_FUNCTION_SECH AST_RELATIONAL_GT
AST_FUNCTION_ARCSIN AST_FUNCTION_SIN AST_RELATIONAL_LEQ
AST_FUNCTION_ARCSINH AST_FUNCTION_SINH AST_RELATIONAL_LT
AST_FUNCTION_ARCTAN AST_FUNCTION_TAN AST_RELATIONAL_NEQ
AST_FUNCTION_ARCTANH AST_FUNCTION_TANH AST_TIMES
AST_FUNCTION_CEILING AST_INTEGER AST_UNKNOWN
AST_FUNCTION_COS AST_LAMBDA
AST_FUNCTION_COSH AST_LOGICAL_AND

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.

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 one of these two text-string formats can be handed to a program that understands SBML mathematical expressions, or used as part of a translation system. The libSBML distribution comes with example programs in the 'examples' subdirectory that demonstrate such things as translating infix formulas into MathML and vice-versa.

Please see the documentation for the functions libsbml.parseFormula() and libsbml.parseL3Formula() for detailed explanations of the infix syntax they accept.

See also
libsbml.parseL3Formula()
libsbml.parseFormula()
libsbml.formulaToString() Python method signature(s):
freeName(ASTNode self)   int

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

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.getCharacter (   self)

Python method signature(s):

getCharacter(ASTNode self)   string

Returns the value of this node as a single character.

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,
  args 
)

Python method signature(s):

getChild(ASTNode self, long n)   ASTNode

Returns the child at index n of this node.

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)

Python method signature(s):

getClass(ASTNode self)   string

Returns the MathML class attribute value of this ASTNode.

Returns
the MathML class of this ASTNode, if any exists.
See also
isSetClass()
setClass()
unsetClass()
def libsbml.ASTNode.getDefinitionURL (   self)

Python method signature(s):

getDefinitionURL(ASTNode self)   XMLAttributes

Returns the MathML definitionURL attribute value.

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

Python method signature(s):

getDefinitionURLString(ASTNode self)   string

Returns the MathML definitionURL attribute value as a string.

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

Python method signature(s):

getDenominator(ASTNode self)   long

Returns the value of the denominator of this node.

Returns
the value of the denominator of this ASTNode, or 1 if this node has no numerical value.
Note
This function should be called only when ASTNode.getType() returns AST_RATIONAL. It will return 1 if the node type is another type, but since 1 may be a valid value for the denominator of a rational number, it is important to be sure that the node type is the correct type in order to correctly interpret the returned value.
def libsbml.ASTNode.getExponent (   self)

Python method signature(s):

getExponent(ASTNode self)   long

Returns the exponent value of this ASTNode.

Returns
the value of the exponent of this ASTNode, or 0 if this is not a type of node that has an exponent.
Note
This function should be called only when ASTNode.getType() returns AST_REAL_E. It will return 0 if the node type is another type, but since 0 may be a valid value, it is important to be sure that the node type is the correct type in order to correctly interpret the returned value.
def libsbml.ASTNode.getExtendedType (   self)

Python method signature(s):

getExtendedType(ASTNode self)   int

Returns the extended type of this ASTNode.

The type may be either a core integer type codeor a value of a type code defined by an SBML Level 3 package.

Returns
the type of this ASTNode.
Note
When the ASTNode is of a type from a package, the value returned by ASTNode.getType() will be AST_ORIGINATES_IN_PACKAGE and getExtendedType() will return a package-specific type code. To find out the possible package-specific types (if any), please consult the documentation for the particular package.
See also
getType()
def libsbml.ASTNode.getId (   self)

Python method signature(s):

getId(ASTNode self)   string

Returns the MathML id attribute value of this ASTNode.

Returns
the MathML id of this ASTNode.
See also
isSetId()
setId()
unsetId()
def libsbml.ASTNode.getInteger (   self)

Python method signature(s):

getInteger(ASTNode self)   long

Returns the value of this node as an integer.

If this node type is AST_RATIONAL, this method returns the value of the numerator.

Returns
the value of this ASTNode as a (long) integer.
Note
This function should be called only when ASTNode.getType() returns AST_INTEGER or AST_RATIONAL. It will return 0 if the node type is not one of these, but since 0 may be a valid value for integer, it is important to be sure that the node type is one of the expected types in order to understand if 0 is the actual value.
def libsbml.ASTNode.getLeftChild (   self)

Python method signature(s):

getLeftChild(ASTNode self)   ASTNode

Returns the left child of this node.

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)

Python method signature(s):

getListOfNodes(ASTNode self)   ASTNodeList

Returns an ASTNodeList of all ASTNode objects.

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 for which the predicate returned true (non-zero).
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)

Python method signature(s):

getMantissa(ASTNode self)   float

Returns the mantissa value of this node.

If ASTNode.getType() returns AST_REAL, this method is identical to ASTNode.getReal().

Returns
the value of the mantissa of this ASTNode, or 0 if this node is not a type that has a real-numbered value.
Note
This function should be called only when ASTNode.getType() returns AST_REAL_E, AST_REAL or AST_NAME_AVOGADRO. It will return 0 if the node type is another type, but since 0 may be a valid value, it is important to be sure that the node type is the correct type in order to correctly interpret the returned value.
def libsbml.ASTNode.getName (   self)

Python method signature(s):

getName(ASTNode self)   string *

Returns the value of this node as a string.

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

Returns
the value of this ASTNode as a string, or None if it is a node that does not have a name equivalent (e.g., if it is a number).
def libsbml.ASTNode.getNumChildren (   self)

Python method signature(s):

getNumChildren(ASTNode self)   long

Returns the number of children of this node.

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

Python method signature(s):

getNumerator(ASTNode self)   long

Returns the value of the numerator of this node.

This function should be called only when ASTNode.getType() returns AST_RATIONAL or AST_INTEGER.

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

Python method signature(s):

getNumSemanticsAnnotations(ASTNode self)   long

Returns the number of MathML <semantics> element elements on this node.

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.
Note
Although SBML permits the use of the MathML <semantics> annotation construct, the truth is that this construct has so far (at this time of this writing, which is early 2014) seen very little use in SBML software. The full implications of using these 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 and/or sbml-interoperability.
See also
ASTNode.addSemanticsAnnotation()
ASTNode.getSemanticsAnnotation()
def libsbml.ASTNode.getOperatorName (   self)

Python method signature(s):

getOperatorName(ASTNode self)   string *

Returns the value of this operator node as a 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)

Python method signature(s):

getParentSBMLObject(ASTNode self)   SBase

Returns the parent SBML object.

Returns
the parent SBML object of this ASTNode.
See also
isSetParentSBMLObject()
setParentSBMLObject()
def libsbml.ASTNode.getPrecedence (   self)

Python method signature(s):

getPrecedence(ASTNode self)   int

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

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)

Python method signature(s):

getReal(ASTNode self)   float

Returns the real-numbered value of this node.

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), or 0 if this is not a node that holds a number.
Note
This function should be called only when this ASTNode has a numerical value type. It will return 0 if the node type is another type, but since 0 may be a valid value, it is important to be sure that the node type is the correct type in order to correctly interpret the returned value.
def libsbml.ASTNode.getRightChild (   self)

Python method signature(s):

getRightChild(ASTNode self)   ASTNode

Returns the right child of this node.

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,
  args 
)

Python method signature(s):

getSemanticsAnnotation(ASTNode self, long n)   XMLNode

Returns the nth MathML <semantics> element on this ASTNode.

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
nthe index of the annotation to return. Callers should use ASTNode.getNumSemanticsAnnotations() to first find out how many annotations there are.
Returns
the nth annotation inside this ASTNode, or None if this node has no nth annotation (n > ASTNode.getNumSemanticsAnnotations() - 1).
Note
Although SBML permits the use of the MathML <semantics> annotation construct, the truth is that this construct has so far (at this time of this writing, which is early 2014) seen very little use in SBML software. The full implications of using these 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 and/or sbml-interoperability.
See also
ASTNode.addSemanticsAnnotation()
ASTNode.getNumSemanticsAnnotations()
def libsbml.ASTNode.getStyle (   self)

Python method signature(s):

getStyle(ASTNode self)   string

Returns the MathML style attribute value of this ASTNode.

Returns
the MathML style of this ASTNode, if any exists.
See also
isSetStyle()
setStyle()
unsetStyle()
def libsbml.ASTNode.getType (   self)

Python method signature(s):

getType(ASTNode self)   long

Returns the type of this ASTNode.

The value returned is one of the Core AST type codes such as AST_LAMBDA, AST_PLUS, etc.

Returns
the type of this ASTNode.
Note
The introduction of extensibility in SBML Level 3 brings with it a need to allow for the possibility of node types that are defined by plug-ins implementing SBML Level 3 packages. If a given ASTNode is a construct created by a package rather than libSBML Core, then getType() will return AST_ORIGINATES_IN_PACKAGE. Callers can then obtain the package-specific type by calling getExtendedType().
See also
getExtendedType()
def libsbml.ASTNode.getUnits (   self)

Python method signature(s):

getUnits(ASTNode self)   string

Returns the units of this ASTNode.

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.hasCorrectNumberArguments (   self)

Python method signature(s):

hasCorrectNumberArguments(ASTNode self)   bool

Returns True if this ASTNode has the correct number of children for its type.

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

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

Python method signature(s):

hasTypeAndNumChildren(ASTNode self, int type, long numchildren)   int

Returns True if this node is of a certain type with a specific number of children.

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.

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

Python method signature(s):

hasUnits(ASTNode self)   bool

Returns True if this node or any of its children nodes have the attribute sbml:units.

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.
See also
isSetUnits()
setUnits()
def libsbml.ASTNode.insertChild (   self,
  args 
)

Python method signature(s):

insertChild(ASTNode self, long n, ASTNode newChild)   int

Inserts the given ASTNode node at a given point in the current ASTNode's list of children.

Parameters
nlong the index of the ASTNode being added
newChildASTNode 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 method ASTNode.isWellFormedASTNode() may also be useful for checking the results of node modifications.
See also
addChild()
prependChild()
replaceChild()
removeChild()
def libsbml.ASTNode.isAvogadro (   self)

Python method signature(s):

isAvogadro(ASTNode self)   bool

Returns True if this node represents the predefined value for Avogadro's constant.

SBML Level 3 introduced a predefined MathML <csymbol> for the value of Avogadro's constant. LibSBML stores this internally as a node of type AST_NAME_AVOGADRO. This method returns True if this node has that type.

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

Python method signature(s):

isBoolean(ASTNode self)   bool

Returns True if this node has a Boolean type.

The ASTNode objects that have Boolean types are the logical operators, relational operators, and the constants True or False.

Returns
True if this ASTNode has a Boolean type, False otherwise.
def libsbml.ASTNode.isConstant (   self)

Python method signature(s):

isConstant(ASTNode self)   bool

Returns True if this node represents a MathML constant.

Examples of MathML constants include such things as pi.

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

Python method signature(s):

isFunction(ASTNode self)   bool

Returns True if this node represents a function.

The three types of functions in SBML are MathML functions (e.g., abs()), SBML Level 1 functions (in the SBML Level 1 math syntax), and user-defined functions (using FunctionDefinition in SBML Level 2 and 3).

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

Python method signature(s):

isInfinity(ASTNode self)   bool

Returns True if this node represents the special IEEE 754 value for infinity.

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

Python method signature(s):

isInteger(ASTNode self)   bool

Returns True if this node contains an integer value.

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

Python method signature(s):

isLambda(ASTNode self)   bool

Returns True if this node is a MathML <lambda>.

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

Python method signature(s):

isLog10(ASTNode self)   bool

Returns True if this node represents a log10 function.

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)

Python method signature(s):

isLogical(ASTNode self)   bool

Returns True if this node is a MathML logical operator.

The possible MathML logical operators are and, or, not, and xor.

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

Python method signature(s):

isName(ASTNode self)   bool

Returns True if this node is a user-defined variable name or the symbols for time or Avogadro's constant.

SBML Levels 2 and 3 provides <csymbol> definitions for 'time' and 'avogadro', which can be used to represent simulation time and Avogadro's constant in MathML.

Returns
True if this ASTNode is a user-defined variable name in SBML or the special symbols for time or Avogadro's constant. It returns false otherwise.
def libsbml.ASTNode.isNaN (   self)

Python method signature(s):

isNaN(ASTNode self)   bool

Returns True if this node represents the special IEEE 754 value 'not a number' (NaN).

Returns
True if this ASTNode is the special IEEE 754 NaN, False otherwise.
def libsbml.ASTNode.isNegInfinity (   self)

Python method signature(s):

isNegInfinity(ASTNode self)   bool

Returns True if this node represents the special IEEE 754 value 'negative infinity'.

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

Python method signature(s):

isNumber(ASTNode self)   bool

Returns True if this node contains a number.

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

Python method signature(s):

isOperator(ASTNode self)   bool

Returns True if this node is a mathematical operator.

The possible mathematical operators in the MathML syntax supported by SBML are +, -, *, / and ^ (power).

Returns
True if this ASTNode is an operator, False otherwise.
def libsbml.ASTNode.isPiecewise (   self)

Python method signature(s):

isPiecewise(ASTNode self)   bool

Returns True if this node is the MathML <piecewise> construct.

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

Python method signature(s):

isQualifier(ASTNode self)   bool

Predicate returning True if this node is a MathML qualifier.

The MathML qualifier node types are bvar, degree, base, piece, and otherwise.

Returns
True if this ASTNode is a MathML qualifier, False otherwise.
def libsbml.ASTNode.isRational (   self)

Python method signature(s):

isRational(ASTNode self)   bool

Returns True if this node represents a rational number.

Returns
True if this ASTNode is of type AST_RATIONAL, false otherwise.
def libsbml.ASTNode.isReal (   self)

Python method signature(s):

isReal(ASTNode self)   bool

Returns True if this node can represent a real number.

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)

Python method signature(s):

isRelational(ASTNode self)   bool

Returns True if this node is a MathML relational operator.

The MathML relational operators are ==, >=, >, <, and !=.

Returns
True if this ASTNode is a MathML relational operator, false otherwise.
def libsbml.ASTNode.isSemantics (   self)

Python method signature(s):

isSemantics(ASTNode self)   bool

Predicate returning True if this node is a MathML semantics node.

Returns
True if this ASTNode is a MathML semantics node, False otherwise.
def libsbml.ASTNode.isSetClass (   self)

Python method signature(s):

isSetClass(ASTNode self)   bool

Returns True if this node has a value for the MathML attribute class.

Returns
true if this ASTNode has an attribute class, False otherwise.
See also
isSetId()
isSetStyle()
setClass()
unsetClass()
def libsbml.ASTNode.isSetId (   self)

Python method signature(s):

isSetId(ASTNode self)   bool

Returns True if this node has a value for the MathML attribute id.

Returns
true if this ASTNode has an attribute id, False otherwise.
See also
isSetClass()
isSetStyle()
setId()
unsetId()
def libsbml.ASTNode.isSetParentSBMLObject (   self)

Python method signature(s):

isSetParentSBMLObject(ASTNode self)   bool

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

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

Python method signature(s):

isSetStyle(ASTNode self)   bool

Returns True if this node has a value for the MathML attribute style.

Returns
true if this ASTNode has an attribute style, False otherwise.
See also
isSetClass()
isSetId()
setStyle()
unsetStyle()
def libsbml.ASTNode.isSetUnits (   self)

Python method signature(s):

isSetUnits(ASTNode self)   bool

Returns True if this node has the attribute sbml:units.

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.
See also
hasUnits()
setUnits()
def libsbml.ASTNode.isSetUserData (   self)

Python method signature(s):

isSetUserData(ASTNode self)   bool

Returns True if this node has a user data object.

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

Python method signature(s):

isSqrt(ASTNode self)   bool

Returns True if this node represents a square root function.

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)

Python method signature(s):

isUMinus(ASTNode self)   bool

Returns True if this node is a unary minus operator.

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)

Python method signature(s):

isUnknown(ASTNode self)   bool

Returns True if this node has an unknown type.

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

Python method signature(s):

isUPlus(ASTNode self)   bool

Returns True if this node is a unary plus operator.

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

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

Python method signature(s):

isWellFormedASTNode(ASTNode self)   bool

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

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,
  args 
)

Python method signature(s):

prependChild(ASTNode self, ASTNode child)   int

Adds the given node as a child of this ASTNode.

This method adds child nodes from right to left.

Parameters
childthe 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 method ASTNode.isWellFormedASTNode() may also be useful for checking the results of node modifications.
See also
addChild()
replaceChild()
insertChild()
removeChild()
def libsbml.ASTNode.reduceToBinary (   self)

Python method signature(s):

reduceToBinary(ASTNode self)

Reduces this ASTNode to a binary tree.

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,
  args 
)

Python method signature(s):

removeChild(ASTNode self, long n)   int

Removes the nth child of this ASTNode object.

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 method ASTNode.isWellFormedASTNode() may also be useful for checking the results of node modifications.
See also
addChild()
prependChild()
replaceChild()
insertChild()
def libsbml.ASTNode.renameSIdRefs (   self,
  args 
)

Python method signature(s):

renameSIdRefs(ASTNode self, string oldid, string newid)

Renames all the SIdRef attributes on this node and its child nodes.

Parameters
oldidthe old identifier.
newidthe new identifier.
def libsbml.ASTNode.renameUnitSIdRefs (   self,
  args 
)

Python method signature(s):

renameUnitSIdRefs(ASTNode self, string oldid, string newid)

Renames all the UnitSIdRef attributes on this node and its child nodes.

The only place UnitSIDRefs appear in MathML <cn> elements, so the effects of this method are limited to that.

Parameters
oldidthe old identifier.
newidthe new identifier.
def libsbml.ASTNode.replaceArgument (   self,
  args 
)

Python method signature(s):

replaceArgument(ASTNode self, string bvar, ASTNode arg)

Replaces occurrences of a given name with a given ASTNode.

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 use as a replacement.
def libsbml.ASTNode.replaceChild (   self,
  args 
)

Python method signature(s):

replaceChild(ASTNode self, long n, ASTNode newChild)   int

Replaces the nth child of this ASTNode with the given ASTNode.

Parameters
nlong the index of the child to replace
newChildASTNode to replace 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 method ASTNode.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 
)

Python method signature(s):

returnsBoolean(ASTNode self, Model model=None)   bool
returnsBoolean(ASTNode self)   bool

Returns True if this node returns a Boolean value.

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 to a user-defined function, the return value of the corresponding FunctionDefinition object 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.

Parameters
modelthe Model to use as context
See also
isBoolean()
Returns
true if this ASTNode returns a boolean, False otherwise.
def libsbml.ASTNode.setCharacter (   self,
  args 
)

Python method signature(s):

setCharacter(ASTNode self, char value)   int

Sets the value of this ASTNode to the given character. 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,
  args 
)

Python method signature(s):

setClass(ASTNode self, string className)   int

Sets the MathML attribute class of this ASTNode.

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:
See also
isSetClass()
getClass()
unsetClass()
def libsbml.ASTNode.setDefinitionURL (   self,
  args 
)

Python method signature(s):

setDefinitionURL(ASTNode self, XMLAttributes url)   int
setDefinitionURL(ASTNode self, string url)   int

This method has multiple variants that differ in the arguments they accept. Each is described separately below.


Method variant with the following signature:
setDefinitionURL(XMLAttributes url)

Sets the MathML attribute definitionURL.

Parameters
urlthe URL value for the definitionURL attribute.
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
See also
setDefinitionURL()
getDefinitionURL()
getDefinitionURLString()

Method variant with the following signature:
setDefinitionURL(string url)

Sets the MathML attribute definitionURL.

Parameters
urlthe URL value for the definitionURL attribute.
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
See also
setDefinitionURL()
getDefinitionURL()
getDefinitionURLString()
def libsbml.ASTNode.setId (   self,
  args 
)

Python method signature(s):

setId(ASTNode self, string id)   int

Sets the MathML attribute id of this ASTNode.

Parameters
idstring representing the identifier.
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
See also
isSetId()
getId()
unsetId()
def libsbml.ASTNode.setName (   self,
  args 
)

Python method signature(s):

setName(ASTNode self, char * name)   int

Sets the value of this ASTNode to the given name.

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 (i.e., ASTNode.isOperator() returns True), number (i.e., ASTNode.isNumber() returns 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,
  args 
)

Python method signature(s):

setStyle(ASTNode self, string style)   int

Sets the MathML attribute style of this ASTNode.

Parameters
stylestring representing the identifier.
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
See also
isSetStyle()
getStyle()
unsetStyle()
def libsbml.ASTNode.setType (   self,
  args 
)

Python method signature(s):

setType(ASTNode self, long type)   int
setType(ASTNode self, int type)   int

This method has multiple variants that differ in the arguments they accept. Each is described separately below.


Method variant with the following signature:
setType(int type)

Sets the type of this ASTNode.

This uses integer type codes, which may come from long or an enumeration of AST types in an SBML Level 3 package.

Parameters
typethe integer representing the 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.
See also
getType()
setType()

Method variant with the following signature:
setType(long type)

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

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.
See also
getType()
setType()
def libsbml.ASTNode.setUnits (   self,
  args 
)

Python method signature(s):

setUnits(ASTNode self, string units)   int

Sets the units of this ASTNode to units.

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.
See also
isSetUnits()
hasUnits()
def libsbml.ASTNode.setValue (   self,
  args 
)

Python method signature(s):

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

This method has multiple variants that differ in the arguments they accept. Each 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.

As a side effect, this operation sets the node type 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)

As a side effet, this operation sets the node type 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

As a side effect, this operation 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).

As a side effect, this operation 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

As a side effect, this operation 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,
  args 
)

Python method signature(s):

swapChildren(ASTNode self, ASTNode that)   int

Swaps the children of this node with the children of another node.

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)

Python method signature(s):

unsetClass(ASTNode self)   int

Unsets the MathML class attribute of this ASTNode.

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

Python method signature(s):

unsetId(ASTNode self)   int

Unsets the MathML id attribute of this ASTNode.

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

Python method signature(s):

unsetParentSBMLObject(ASTNode self)   int

Unsets the parent SBML object.

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

Python method signature(s):

unsetStyle(ASTNode self)   int

Unsets the MathML style attribute of this ASTNode.

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

Python method signature(s):

unsetUnits(ASTNode self)   int

Unsets the units of this ASTNode.

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

Python method signature(s):

unsetUserData(ASTNode self)   int

Unsets the user data of this node.

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: