|
libSBML C# API
libSBML 5.10.0 C# API
|
{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:
| 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:
For many applications, the details of ASTs are irrelevant because the applications can use the text-string based translation functions such as . 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.
*
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:
'+'), then the node's type will be AST_PLUS, AST_MINUS, AST_TIMES, AST_DIVIDE, or AST_POWER, as appropriate.AST_FUNCTION_ X, AST_LOGICAL_ X, or AST_RELATIONAL_ X, as appropriate. (Examples: AST_FUNCTION_LOG, AST_RELATIONAL_LEQ.)'ExponentialE', 'Pi', 'True' or 'False'), then the node's type will be AST_CONSTANT_E, AST_CONSTANT_PI, AST_CONSTANT_TRUE, or AST_CONSTANT_FALSE.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.)avogadro, the value of the node will be AST_NAME_AVOGADRO.The text-string form of mathematical formulas produced bylibsbmlcs.libsbml.formulaToString()and read bylibsbmlcs.libsbml.parseFormula() and SBML_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 libsbmlcs.libsbml.parseFormula() and SBML_parseL3Formula() for detailed explanations of the infix syntax they accept.
Public Member Functions | |
| int | addChild (ASTNode child) |
| Adds the given node as a child of this ASTNode. More... | |
| void | addExpectedAttributes (SWIGTYPE_p_ExpectedAttributes attributes, XMLInputStream stream) |
| void | addPlugin (ASTBasePlugin plugin) |
| int | addSemanticsAnnotation (XMLNode sAnnotation) |
| Adds the given XMLNode as a MathML. More... | |
| ASTNode (int type) | |
| Creates a new ASTNode. More... | |
| ASTNode (SBMLNamespaces sbmlns, int type) | |
| ASTNode () | |
| ASTNode (SBMLNamespaces sbmlns) | |
| ASTNode (ASTNode orig) | |
| Copy constructor; creates a deep copy of the given ASTNode. More... | |
| bool | canonicalize () |
| Converts this ASTNode to a canonical form. More... | |
| ASTBase | deepCopy () |
| Creates a recursive copy of this node and all its children. More... | |
| override void | Dispose () |
| override bool | Equals (Object sb) |
| int | freeName () |
Frees the name of this ASTNode and sets it to null. More... | |
| char | getCharacter () |
| Returns the value of this node as a single character. More... | |
| ASTNode | getChild (long n) |
| Returns the child at index n of this node. More... | |
| string | getClass () |
Returns the MathML class attribute value of this ASTNode. More... | |
| XMLAttributes | getDefinitionURL () |
Returns the MathML definitionURL attribute value. More... | |
| string | getDefinitionURLString () |
Returns the MathML definitionURL attribute value as a string. More... | |
| int | getDenominator () |
| Returns the value of the denominator of this node. More... | |
| int | getExponent () |
| Returns the exponent value of this ASTNode. More... | |
| int | getExtendedType () |
| Returns the extended type of this ASTNode. More... | |
| ASTBase | getFunction () |
| override int | GetHashCode () |
| string | getId () |
Returns the MathML id attribute value of this ASTNode. More... | |
| int | getInteger () |
| Returns the value of this node as an integer. More... | |
| ASTNode | getLeftChild () |
| Returns the left child of this node. More... | |
| ASTNodeList | getListOfNodes () |
| double | getMantissa () |
| Returns the mantissa value of this node. More... | |
| string | getName () |
| Returns the value of this node as a string. More... | |
| string | getNameFromType (int type) |
| long | getNumBvars () |
| long | getNumChildren () |
| Returns the number of children of this node. More... | |
| int | getNumerator () |
| Returns the value of the numerator of this node. More... | |
| long | getNumPlugins () |
| Returns the number of plug-in objects (extenstion interfaces) for SBML Level 3 package extensions known. More... | |
| long | getNumSemanticsAnnotations () |
| Returns the number of MathML. More... | |
| string | getOperatorName () |
| Returns the value of this operator node as a string. More... | |
| string | getPackageName () |
| SBase | getParentSBMLObject () |
| Returns the parent SBML object. More... | |
| ASTBasePlugin | getPlugin (string package) |
| Returns a plug-in object (extension interface) for an SBML Level 3 package extension with the given package name or URI. More... | |
| ASTBasePlugin | getPlugin (long n) |
| Returns the nth plug-in object (extension interface) for an SBML Level 3 package extension. More... | |
| int | getPrecedence () |
| Returns the precedence of this node in the infix math syntax of SBML Level 1. More... | |
| double | getReal () |
| Returns the real-numbered value of this node. More... | |
| ASTNode | getRightChild () |
| Returns the right child of this node. More... | |
| XMLNode | getSemanticsAnnotation (long n) |
| Returns the nth MathML. More... | |
| string | getStyle () |
Returns the MathML style attribute value of this ASTNode. More... | |
| int | getType () |
| Returns the type of this ASTNode. More... | |
| int | getTypeCode () |
| int | getTypeFromName (string name) |
| string | getUnits () |
| Returns the units of this ASTNode. More... | |
| string | getUnitsPrefix () |
| SWIGTYPE_p_void | getUserData () |
| Returns the user data that has been previously set via setUserData(). More... | |
| bool | hasCnUnits () |
| bool | hasCorrectNumberArguments () |
Returns true if this ASTNode has the correct number of children for its type. More... | |
| int | hasTypeAndNumChildren (int type, long numchildren) |
Returns true if this node is of a certain type with a specific number of children. More... | |
| bool | hasUnits () |
Returns true if this node or any of its children nodes have the attribute. More... | |
| int | insertChild (long n, ASTNode newChild) |
| Inserts the given ASTNode node at a given point in the current ASTNode's list of children. More... | |
| bool | isAvogadro () |
Returns true if this node represents the predefined value for Avogadro's constant. More... | |
| bool | isBinaryFunction () |
| bool | isBoolean () |
Returns true if this node has a Boolean type. More... | |
| bool | isChild () |
| bool | isCiNumber () |
| bool | isConstant () |
Returns true if this node represents a MathML constant. More... | |
| bool | isConstantNumber () |
| bool | isCSymbolFunction () |
| bool | isCSymbolNumber () |
| bool | isExponential () |
| bool | isFunction () |
Returns true if this node represents a function. More... | |
| bool | isFunctionNode () |
| bool | isInfinity () |
Returns true if this node represents the special IEEE 754 value for infinity. More... | |
| bool | isInteger () |
Returns true if this node contains an integer value. More... | |
| bool | isLambda () |
Returns true if this node is a MathML. More... | |
| bool | isLog10 () |
Returns true if this node represents a log10 function. More... | |
| bool | isLogical () |
Returns true if this node is a MathML logical operator. More... | |
| bool | isName () |
Returns true if this node is a user-defined variable name or the symbols for time or Avogadro's constant. More... | |
| bool | isNaN () |
Returns true if this node represents the special IEEE 754 value 'not a number' (NaN). More... | |
| bool | isNaryFunction () |
| bool | isNegInfinity () |
Returns true if this node represents the special IEEE 754 value 'negative infinity'. More... | |
| bool | isNumber () |
Returns true if this node contains a number. More... | |
| bool | isNumberNode () |
| bool | isOperator () |
Returns true if this node is a mathematical operator. More... | |
| bool | isPiecewise () |
Returns true if this node is the MathML. More... | |
| bool | isQualifier () |
Predicate returning true if this node is a MathML qualifier. More... | |
| bool | isRational () |
Returns true if this node represents a rational number. More... | |
| bool | isReal () |
Returns true if this node can represent a real number. More... | |
| bool | isRelational () |
Returns true if this node is a MathML relational operator. More... | |
| bool | isSemantics () |
Predicate returning true if this node is a MathML semantics node. More... | |
| bool | isSetClass () |
Returns true if this node has a value for the MathML attribute class. More... | |
| bool | isSetId () |
Returns true if this node has a value for the MathML attribute id. More... | |
| bool | isSetParentSBMLObject () |
Returns true if this node has a value for the parent SBML object. More... | |
| bool | isSetStyle () |
Returns true if this node has a value for the MathML attribute style. More... | |
| bool | isSetType () |
| bool | isSetUnits () |
Returns true if this node has the attribute. More... | |
| bool | isSetUserData () |
Returns true if this node has a user data object. More... | |
| bool | isSqrt () |
Returns true if this node represents a square root function. More... | |
| bool | isTopLevelMathMLFunctionNodeTag (string name) |
| bool | isTopLevelMathMLNumberNodeTag (string name) |
| bool | isUMinus () |
Returns true if this node is a unary minus operator. More... | |
| bool | isUnaryFunction () |
| bool | isUnknown () |
Returns true if this node has an unknown type. More... | |
| bool | isUPlus () |
Returns true if this node is a unary plus operator. More... | |
| bool | isUserFunction () |
| bool | isWellFormedASTNode () |
Returns true or false depending on whether this ASTNode is well-formed. More... | |
| bool | isWellFormedNode () |
| void | loadASTPlugins (SBMLNamespaces sbmlns) |
| void | logError (XMLInputStream stream, XMLToken element, int code, string msg) |
| void | logError (XMLInputStream stream, XMLToken element, int code) |
| int | prependChild (ASTNode child) |
| Adds the given node as a child of this ASTNode. More... | |
| bool | read (XMLInputStream stream, string reqd_prefix) |
| bool | read (XMLInputStream stream) |
| bool | readAttributes (XMLAttributes attributes, SWIGTYPE_p_ExpectedAttributes expectedAttributes, XMLInputStream stream, XMLToken element) |
| void | reduceToBinary () |
| Reduces this ASTNode to a binary tree. More... | |
| int | removeChild (long n) |
| Removes the nth child of this ASTNode object. More... | |
| void | renameSIdRefs (string oldid, string newid) |
| Renames all the SIdRef attributes on this node and its child nodes. More... | |
| void | renameUnitSIdRefs (string oldid, string newid) |
| Renames all the UnitSIdRef attributes on this node and its child nodes. More... | |
| void | replaceArgument (string bvar, ASTNode arg) |
| Replaces occurrences of a given name with a given ASTNode. More... | |
| int | replaceChild (long n, ASTNode newChild) |
| Replaces the nth child of this ASTNode with the given ASTNode. More... | |
| void | replaceIDWithFunction (string id, ASTNode function) |
| Replace any nodes of type AST_NAME with the name 'id' from the child 'math' object with the provided ASTNode. More... | |
| bool | returnsBoolean (Model model) |
Returns true if this node returns a Boolean value. More... | |
| bool | returnsBoolean () |
Returns true if this node returns a Boolean value. More... | |
| int | setCharacter (char value) |
| Sets the value of this ASTNode to the given character. More... | |
| int | setClass (string className) |
Sets the MathML attribute class of this ASTNode. More... | |
| int | setDefinitionURL (XMLAttributes url) |
Sets the MathML attribute definitionURL. More... | |
| int | setDefinitionURL (string url) |
Sets the MathML attribute definitionURL. More... | |
| int | setId (string id) |
Sets the MathML attribute id of this ASTNode. More... | |
| void | setIsChildFlag (bool flag) |
| int | setName (string name) |
| Sets the value of this ASTNode to the given name. More... | |
| int | setPackageName (string name) |
| int | setStyle (string style) |
Sets the MathML attribute style of this ASTNode. More... | |
| int | setType (int type) |
| Sets the type of this ASTNode to the given type code. More... | |
| int | setUnits (string units) |
| Sets the units of this ASTNode to units. More... | |
| int | setUserData (SWIGTYPE_p_void userData) |
| int | setValue (int value) |
Sets the value of this ASTNode to the given (long) integer. More... | |
| int | setValue (int numerator, int denominator) |
| Sets the value of this ASTNode to the given rational. More... | |
| int | setValue (double value) |
Sets the value of this ASTNode to the given real (double). More... | |
| int | setValue (double mantissa, int exponent) |
Sets the value of this ASTNode to the given real (double) More... | |
| int | swapChildren (ASTNode that) |
| Swaps the children of this node with the children of another node. More... | |
| int | unsetClass () |
Unsets the MathML class attribute of this ASTNode. More... | |
| int | unsetId () |
Unsets the MathML id attribute of this ASTNode. More... | |
| int | unsetParentSBMLObject () |
| Unsets the parent SBML object. More... | |
| int | unsetStyle () |
Unsets the MathML style attribute of this ASTNode. More... | |
| int | unsetUnits () |
| Unsets the units of this ASTNode. More... | |
| int | unsetUserData () |
| Unsets the user data of this node. More... | |
| void | write (XMLOutputStream stream) |
| void | writeNodeOfType (XMLOutputStream stream, int type, bool inChildNode) |
| void | writeNodeOfType (XMLOutputStream stream, int type) |
Static Public Member Functions | |
| static bool | operator!= (ASTNode lhs, ASTNode rhs) |
| static bool | operator== (ASTNode lhs, ASTNode rhs) |
Protected Attributes | |
| bool | swigCMemOwn |
| libsbmlcs.ASTNode.ASTNode | ( | int | type | ) |
Creates 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(int).
| type | an optional typecode indicating the type of node to create. |
| libsbmlcs.ASTNode.ASTNode | ( | SBMLNamespaces | sbmlns, |
| int | type | ||
| ) |
| libsbmlcs.ASTNode.ASTNode | ( | ) |
| libsbmlcs.ASTNode.ASTNode | ( | SBMLNamespaces | sbmlns | ) |
| libsbmlcs.ASTNode.ASTNode | ( | ASTNode | orig | ) |
| int libsbmlcs.ASTNode.addChild | ( | ASTNode | child | ) |
Adds the given node as a child of this ASTNode.
Child nodes are added in-order, from left to right.
| child | the ASTNode instance to add |
|
inherited |
|
inherited |
| int libsbmlcs.ASTNode.addSemanticsAnnotation | ( | XMLNode | sAnnotation | ) |
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.
| sAnnotation | the annotation to add. |
<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.| bool libsbmlcs.ASTNode.canonicalize | ( | ) |
Converts this ASTNode to a canonical form.
The rules determining the canonical form conversion are as follows:
'ExponentialE', 'Pi', 'True' or 'False' the node type is converted to the corresponding AST_CONSTANT_X type. 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.
true if this node was successfully converted to canonical form, false otherwise. | ASTBase libsbmlcs.ASTNode.deepCopy | ( | ) |
|
virtual |
Reimplemented from libsbmlcs.ASTBase.
| override bool libsbmlcs.ASTNode.Equals | ( | Object | sb | ) |
| int libsbmlcs.ASTNode.freeName | ( | ) |
Frees the name of this ASTNode and sets it to null.
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.
| char libsbmlcs.ASTNode.getCharacter | ( | ) |
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.
| ASTNode libsbmlcs.ASTNode.getChild | ( | long | n | ) |
Returns the child at index n of this node.
| n | the index of the child to get |
null if this node has no nth child (n > ASTNode::getNumChildren()- 1).| string libsbmlcs.ASTNode.getClass | ( | ) |
Returns the MathML class attribute value of this ASTNode.
| XMLAttributes libsbmlcs.ASTNode.getDefinitionURL | ( | ) |
Returns the MathML definitionURL attribute value.
definitionURL attribute, in the form of a libSBML XMLAttributes object.| string libsbmlcs.ASTNode.getDefinitionURLString | ( | ) |
Returns the MathML definitionURL attribute value as a string.
definitionURL attribute, as a string.| int libsbmlcs.ASTNode.getDenominator | ( | ) |
Returns the value of the denominator of this node.
1 if this node has no numerical value.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. | int libsbmlcs.ASTNode.getExponent | ( | ) |
Returns the exponent value of this ASTNode.
0 if this is not a type of node that has an exponent.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. | int libsbmlcs.ASTNode.getExtendedType | ( | ) |
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.
|
inherited |
| override int libsbmlcs.ASTNode.GetHashCode | ( | ) |
| string libsbmlcs.ASTNode.getId | ( | ) |
| int libsbmlcs.ASTNode.getInteger | ( | ) |
Returns the value of this node as an integer.
If this node type is AST_RATIONAL, this method returns the value of the numerator.
long) integer.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. | ASTNode libsbmlcs.ASTNode.getLeftChild | ( | ) |
Returns the left child of this node.
0.| ASTNodeList libsbmlcs.ASTNode.getListOfNodes | ( | ) |
| double libsbmlcs.ASTNode.getMantissa | ( | ) |
Returns the mantissa value of this node.
If ASTNode::getType()returns AST_REAL, this method is identical to ASTNode::getReal().
0 if this node is not a type that has a real-numbered value.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. | string libsbmlcs.ASTNode.getName | ( | ) |
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.
null if it is a node that does not have a name equivalent (e.g., if it is a number).
|
inherited |
| long libsbmlcs.ASTNode.getNumBvars | ( | ) |
| long libsbmlcs.ASTNode.getNumChildren | ( | ) |
Returns the number of children of this node.
| int libsbmlcs.ASTNode.getNumerator | ( | ) |
Returns the value of the numerator of this node.
This function should be called only when ASTNode::getType()returns AST_RATIONAL or AST_INTEGER.
|
inherited |
Returns the number of plug-in objects (extenstion interfaces) for SBML Level 3 package extensions known.
| long libsbmlcs.ASTNode.getNumSemanticsAnnotations | ( | ) |
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.
*
<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.| string libsbmlcs.ASTNode.getOperatorName | ( | ) |
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.
null if not an operator). | string libsbmlcs.ASTNode.getPackageName | ( | ) |
| SBase libsbmlcs.ASTNode.getParentSBMLObject | ( | ) |
Returns the parent SBML object.
|
inherited |
Returns a plug-in object (extension interface) for an SBML Level 3 package extension with the given package name or URI.
| package | the name or URI of the package |
|
inherited |
Returns the nth plug-in object (extension interface) for an SBML Level 3 package extension.
| n | the index of the plug-in to return |
| int libsbmlcs.ASTNode.getPrecedence | ( | ) |
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.
| double libsbmlcs.ASTNode.getReal | ( | ) |
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).
0 if this is not a node that holds a number.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. | ASTNode libsbmlcs.ASTNode.getRightChild | ( | ) |
Returns the right child of this node.
null if this node has no right child. If ASTNode::getNumChildren() > 1, then this is equivalent to: getChild( getNumChildren() - 1 );
| XMLNode libsbmlcs.ASTNode.getSemanticsAnnotation | ( | long | n | ) |
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.
| n | the index of the annotation to return. Callers should use ASTNode::getNumSemanticsAnnotations() to first find out how many annotations there are. |
null if this node has no nth annotation (n > ASTNode::getNumSemanticsAnnotations() - 1).*
<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.| string libsbmlcs.ASTNode.getStyle | ( | ) |
Returns the MathML style attribute value of this ASTNode.
| int libsbmlcs.ASTNode.getType | ( | ) |
Returns the type of this ASTNode.
The value returned is one of the Core AST type codes such as AST_LAMBDA, AST_PLUS, etc.
| int libsbmlcs.ASTNode.getTypeCode | ( | ) |
|
inherited |
| string libsbmlcs.ASTNode.getUnits | ( | ) |
Returns the units of this ASTNode.
SBML Level 3 Version 1 introduced the ability to include an attributesbml: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>
sbml:units attribute is only available in SBML Level 3. It may not be used in Levels 1–2 of SBML.
|
inherited |
|
inherited |
Returns the user data that has been previously set via setUserData().
null if no user data has been set.
|
inherited |
| bool libsbmlcs.ASTNode.hasCorrectNumberArguments | ( | ) |
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.
true if this ASTNode has the appropriate number of children for its type, false otherwise.| int libsbmlcs.ASTNode.hasTypeAndNumChildren | ( | int | type, |
| long | numchildren | ||
| ) |
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.
| type | the type of ASTNode sought. |
| numchildren | the number of child nodes sought. |
true if this ASTNode is has the specified type and number of children, false otherwise. | bool libsbmlcs.ASTNode.hasUnits | ( | ) |
Returns true if this node or any of its children nodes have the attribute.
sbml:units.
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>
true if this ASTNode or its children has units associated with it, false otherwise.sbml:units attribute is only available in SBML Level 3. It may not be used in Levels 1–2 of SBML.| int libsbmlcs.ASTNode.insertChild | ( | long | n, |
| ASTNode | newChild | ||
| ) |
Inserts the given ASTNode node at a given point in the current ASTNode's list of children.
| bool libsbmlcs.ASTNode.isAvogadro | ( | ) |
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.
true if this ASTNode is the special symbol avogadro, false otherwise.
|
inherited |
| bool libsbmlcs.ASTNode.isBoolean | ( | ) |
|
inherited |
|
inherited |
| bool libsbmlcs.ASTNode.isConstant | ( | ) |
Returns true if this node represents a MathML constant.
Examples of MathML constants include such things as pi.
true if this ASTNode is a MathML constant, false otherwise.true for nodes of type AST_NAME_AVOGADRO in SBML Level 3.
|
inherited |
|
inherited |
|
inherited |
|
inherited |
| bool libsbmlcs.ASTNode.isFunction | ( | ) |
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).
true if this ASTNode is a function, false otherwise.
|
inherited |
| bool libsbmlcs.ASTNode.isInfinity | ( | ) |
Returns true if this node represents the special IEEE 754 value for infinity.
true if this ASTNode is the special IEEE 754 value infinity, false otherwise. | bool libsbmlcs.ASTNode.isInteger | ( | ) |
Returns true if this node contains an integer value.
true if this ASTNode is of type AST_INTEGER, false otherwise. | bool libsbmlcs.ASTNode.isLambda | ( | ) |
Returns true if this node is a MathML.
<lambda>.
true if this ASTNode is of type AST_LAMBDA, false otherwise. | bool libsbmlcs.ASTNode.isLog10 | ( | ) |
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.
true if the given ASTNode represents a log10() function, false otherwise.| bool libsbmlcs.ASTNode.isLogical | ( | ) |
Returns true if this node is a MathML logical operator.
The possible MathML logical operators are and, or, not, and xor.
true if this ASTNode is a MathML logical operator, false otherwise. | bool libsbmlcs.ASTNode.isName | ( | ) |
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.
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. | bool libsbmlcs.ASTNode.isNaN | ( | ) |
Returns true if this node represents the special IEEE 754 value 'not a number' (NaN).
true if this ASTNode is the special IEEE 754 NaN, false otherwise.
|
inherited |
| bool libsbmlcs.ASTNode.isNegInfinity | ( | ) |
Returns true if this node represents the special IEEE 754 value 'negative infinity'.
true if this ASTNode is the special IEEE 754 value negative infinity, false otherwise. | bool libsbmlcs.ASTNode.isNumber | ( | ) |
Returns true if this node contains a number.
true if this ASTNode is a number, false otherwise.
|
inherited |
| bool libsbmlcs.ASTNode.isOperator | ( | ) |
Returns true if this node is a mathematical operator.
The possible mathematical operators in the MathML syntax supported by SBML are +, -, *, / and ^ (power).
true if this ASTNode is an operator, false otherwise. | bool libsbmlcs.ASTNode.isPiecewise | ( | ) |
Returns true if this node is the MathML.
<piecewise> construct.
true if this ASTNode is a MathML piecewise function, false otherwise. | bool libsbmlcs.ASTNode.isQualifier | ( | ) |
Predicate returning true if this node is a MathML qualifier.
The MathML qualifier node types are bvar, degree, base, piece, and otherwise.
true if this ASTNode is a MathML qualifier, false otherwise. | bool libsbmlcs.ASTNode.isRational | ( | ) |
Returns true if this node represents a rational number.
true if this ASTNode is of type AST_RATIONAL, false otherwise. | bool libsbmlcs.ASTNode.isReal | ( | ) |
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.
true if the value of this ASTNode can represented as a real number, false otherwise. | bool libsbmlcs.ASTNode.isRelational | ( | ) |
Returns true if this node is a MathML relational operator.
The MathML relational operators are ==, >=, >, <, and !=.
true if this ASTNode is a MathML relational operator, false otherwise. | bool libsbmlcs.ASTNode.isSemantics | ( | ) |
Predicate returning true if this node is a MathML semantics node.
true if this ASTNode is a MathML semantics node, false otherwise. | bool libsbmlcs.ASTNode.isSetClass | ( | ) |
Returns true if this node has a value for the MathML attribute class.
false otherwise.| bool libsbmlcs.ASTNode.isSetId | ( | ) |
Returns true if this node has a value for the MathML attribute id.
false otherwise.| bool libsbmlcs.ASTNode.isSetParentSBMLObject | ( | ) |
Returns true if this node has a value for the parent SBML object.
false otherwise.| bool libsbmlcs.ASTNode.isSetStyle | ( | ) |
Returns true if this node has a value for the MathML attribute style.
false otherwise.
|
inherited |
| bool libsbmlcs.ASTNode.isSetUnits | ( | ) |
Returns true if this node has the attribute.
sbml:units.
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>
true if this ASTNode has units associated with it, false otherwise.sbml:units attribute is only available in SBML Level 3. It may not be used in Levels 1–2 of SBML.| bool libsbmlcs.ASTNode.isSetUserData | ( | ) |
Returns true if this node has a user data object.
false otherwise. | bool libsbmlcs.ASTNode.isSqrt | ( | ) |
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.
true if the given ASTNode represents a sqrt() function, false otherwise.
|
inherited |
|
inherited |
| bool libsbmlcs.ASTNode.isUMinus | ( | ) |
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, libsbmlcs.libsbml.parseFormula()does this during its parsing process, and SBML_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.
true if this ASTNode is a unary minus, false otherwise.
|
inherited |
| bool libsbmlcs.ASTNode.isUnknown | ( | ) |
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.
true if this ASTNode is of type AST_UNKNOWN, false otherwise. | bool libsbmlcs.ASTNode.isUPlus | ( | ) |
|
inherited |
| bool libsbmlcs.ASTNode.isWellFormedASTNode | ( | ) |
Returns true or false depending on whether this ASTNode is well-formed.
true if this ASTNode is well-formed, false otherwise.
|
inherited |
|
inherited |
|
inherited |
|
inherited |
| int libsbmlcs.ASTNode.prependChild | ( | ASTNode | child | ) |
Adds the given node as a child of this ASTNode.
This method adds child nodes from right to left.
| child | the ASTNode instance to add |
| bool libsbmlcs.ASTNode.read | ( | XMLInputStream | stream, |
| string | reqd_prefix | ||
| ) |
| bool libsbmlcs.ASTNode.read | ( | XMLInputStream | stream | ) |
|
inherited |
| void libsbmlcs.ASTNode.reduceToBinary | ( | ) |
| int libsbmlcs.ASTNode.removeChild | ( | long | n | ) |
Removes the nth child of this ASTNode object.
| n | long the index of the child to remove |
| void libsbmlcs.ASTNode.renameSIdRefs | ( | string | oldid, |
| string | newid | ||
| ) |
Renames all the SIdRef attributes on this node and its child nodes.
| oldid | the old identifier. |
| newid | the new identifier. |
| void libsbmlcs.ASTNode.renameUnitSIdRefs | ( | 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.
| oldid | the old identifier. |
| newid | the new identifier. |
| void libsbmlcs.ASTNode.replaceArgument | ( | 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.
| bvar | a string representing the variable name to be substituted. |
| arg | an ASTNode representing the name/value/formula to use as a replacement. |
| int libsbmlcs.ASTNode.replaceChild | ( | long | n, |
| ASTNode | newChild | ||
| ) |
Replaces the nth child of this ASTNode with the given ASTNode.
| n | long the index of the child to replace |
| newChild | ASTNode to replace the nth child |
| void libsbmlcs.ASTNode.replaceIDWithFunction | ( | string | id, |
| ASTNode | function | ||
| ) |
Replace any nodes of type AST_NAME with the name 'id' from the child 'math' object with the provided ASTNode.
| bool libsbmlcs.ASTNode.returnsBoolean | ( | Model | model | ) |
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.
| model | the Model to use as context |
false otherwise. | bool libsbmlcs.ASTNode.returnsBoolean | ( | ) |
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.
| model | the Model to use as context |
false otherwise. | int libsbmlcs.ASTNode.setCharacter | ( | char | value | ) |
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.
| value | the character value to which the node's value should be set. |
| int libsbmlcs.ASTNode.setClass | ( | string | className | ) |
Sets the MathML attribute class of this ASTNode.
| className | string representing the MathML class for this node. |
| int libsbmlcs.ASTNode.setDefinitionURL | ( | XMLAttributes | url | ) |
Sets the MathML attribute definitionURL.
| url | the URL value for the definitionURL attribute. |
| int libsbmlcs.ASTNode.setDefinitionURL | ( | string | url | ) |
Sets the MathML attribute definitionURL.
| url | the URL value for the definitionURL attribute. |
| int libsbmlcs.ASTNode.setId | ( | string | id | ) |
Sets the MathML attribute id of this ASTNode.
| id | string representing the identifier. |
|
inherited |
| int libsbmlcs.ASTNode.setName | ( | string | name | ) |
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.
| name | the string containing the name to which this node's value should be set. |
|
inherited |
| int libsbmlcs.ASTNode.setStyle | ( | string | style | ) |
Sets the MathML attribute style of this ASTNode.
| style | string representing the identifier. |
| int libsbmlcs.ASTNode.setType | ( | int | type | ) |
Sets the type of this ASTNode to the given type code.
| type | the type to which this node should be set. |
| int libsbmlcs.ASTNode.setUnits | ( | string | units | ) |
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: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>
| units | string representing the unit identifier. |
sbml:units attribute is only available in SBML Level 3. It may not be used in Levels 1–2 of SBML.
|
inherited |
| int libsbmlcs.ASTNode.setValue | ( | int | 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.
| value | the integer to which this node's value should be set. |
| int libsbmlcs.ASTNode.setValue | ( | int | numerator, |
| int | denominator | ||
| ) |
Sets the value of this ASTNode to the given rational.
As a side effect, this operation sets the node type to AST_RATIONAL.
| numerator | the numerator value of the rational. |
| denominator | the denominator value of the rational. |
| int libsbmlcs.ASTNode.setValue | ( | double | value | ) |
Sets the value of this ASTNode to the given real (double).
As a side effect, this operation sets the node type to AST_REAL.
This is functionally equivalent to:
setValue(value, 0);
| value | the double format number to which this node's value should be set. |
| int libsbmlcs.ASTNode.setValue | ( | double | mantissa, |
| int | exponent | ||
| ) |
Sets the value of this ASTNode to the given real (double)
As a side effet, this operation sets the node type to AST_REAL_E.
| mantissa | the mantissa of this node's real-numbered value. |
| exponent | the exponent of this node's real-numbered value. |
| int libsbmlcs.ASTNode.swapChildren | ( | ASTNode | that | ) |
Swaps the children of this node with the children of another node.
| that | the other node whose children should be used to replace this node's children. |
| int libsbmlcs.ASTNode.unsetClass | ( | ) |
Unsets the MathML class attribute of this ASTNode.
| int libsbmlcs.ASTNode.unsetId | ( | ) |
Unsets the MathML id attribute of this ASTNode.
| int libsbmlcs.ASTNode.unsetParentSBMLObject | ( | ) |
Unsets the parent SBML object.
| int libsbmlcs.ASTNode.unsetStyle | ( | ) |
Unsets the MathML style attribute of this ASTNode.
| int libsbmlcs.ASTNode.unsetUnits | ( | ) |
Unsets the units of this ASTNode.
| int libsbmlcs.ASTNode.unsetUserData | ( | ) |
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.
| void libsbmlcs.ASTNode.write | ( | XMLOutputStream | stream | ) |
| void libsbmlcs.ASTNode.writeNodeOfType | ( | XMLOutputStream | stream, |
| int | type, | ||
| bool | inChildNode | ||
| ) |
| void libsbmlcs.ASTNode.writeNodeOfType | ( | XMLOutputStream | stream, |
| int | type | ||
| ) |
|
protectedinherited |