libSBML C++ API  5.20.5
Loading...
Searching...
No Matches
ExpressionAnalyser Class Reference

Detailed Description

Converter that sorts SBML rules and assignments.

This class of objects is defined by libSBML only and has no direct equivalent in terms of SBML components. It is a class used in the implementation of extra functionality provided by libSBML.

ADD DESCRIPTION

Configuration and use of ExpressionAnalyser

ExpressionAnalyser is enabled by creating a ConversionProperties object with the option "inferReactions", and passing this properties object to SBMLDocument::convert( ). This converter offers no other options.

Implementation is based on the algorithm described in Fages et al, Theoretical Computer Science, 2015.

General information about the use of SBML converters

The use of all the converters follows a similar approach. First, one creates a ConversionProperties object and calls ConversionProperties::addOption( ) on this object with one argument: a text string that identifies the desired converter. (The text string is specific to each converter; consult the documentation for a given converter to find out how it should be enabled.)

Next, for some converters, the caller can optionally set some converter-specific properties using additional calls to ConversionProperties::addOption( ). Many converters provide the ability to configure their behavior to some extent; this is realized through the use of properties that offer different options. The default property values for each converter can be interrogated using the method SBMLConverter::getDefaultProperties() on the converter class in question .

Finally, the caller should invoke the method SBMLDocument::convert( ) with the ConversionProperties object as an argument.

Example of invoking an SBML converter

The following code fragment illustrates an example using SBMLReactionConverter, which is invoked using the option string "replaceReactions":

props.addOption("replaceReactions");
Definition ConversionProperties.h:84
virtual void addOption(const ConversionOption &option)
Adds a copy of the given option to this properties object.
Definition ConversionProperties.cpp:232

In the case of SBMLReactionConverter, there are no options to affect its behavior, so the next step is simply to invoke the converter on an SBMLDocument object. Continuing the example code:

// Assume that the variable "document" has been set to an SBMLDocument object.
int status = document->convert(props);
{
cerr << "Unable to perform conversion due to the following:" << endl;
document->printErrors(cerr);
}
@ LIBSBML_OPERATION_SUCCESS
Definition operationReturnValues.h:61

Here is an example of using a converter that offers an option. The following code invokes SBMLStripPackageConverter to remove the SBML Level 3 Layout package from a model. It sets the name of the package to be removed by adding a value for the option named "package" defined by that converter:

props.addOption("stripPackage");
props.addOption("package", "layout");
int status = document->convert(props);
{
cerr << "Unable to strip the Layout package from the model";
cerr << "Error returned: " << status;
}

Available SBML converters in libSBML

LibSBML provides a number of built-in converters; by convention, their names end in Converter. The following are the built-in converters provided by libSBML

Public Member Functions

void analyse ()
 Function to work through all the ODE expressions and invoke analyseNode where appropriate.
 
bool analyseNode (ASTNode *node, SubstitutionValues_t *value)
 Function to work through all the mathematical expressions and create substitution values.
 
virtual ExpressionAnalyserclone () const
 Creates and returns a deep copy of this ExpressionAnalyser object.
 
SubstitutionValues_tcreateBlankSubstitutionValues ()
 Function to create a blank substitution value.
 
void detectHiddenSpecies (bool testing=false)
 Function to work through all the expressions and detect hidden species.
 
 ExpressionAnalyser ()
 Creates a new ExpressionAnalyser object.
 
 ExpressionAnalyser (const ExpressionAnalyser &obj)
 Copy constructor; creates a copy of an ExpressionAnalyser object.
 
 ExpressionAnalyser (Model *m, pairODEs ode)
 Creates a new ExpressionAnalyser object with Model and ODEs.
 
SubstitutionValues_tgetExpression (unsigned int index)
 Returns the expression at the given index Only used in testing.
 
ListgetHiddenSpecies ()
 Returns the list of hidden species.
 
ParametergetHiddenSpecies (unsigned int index)
 
unsigned int getNumExpressions ()
 Returns the number of expressions Only used in testing.
 
unsigned int getNumHiddenNodes ()
 
unsigned int getNumHiddenSpecies ()
 Returns the number of hidden species.
 
void identifyHiddenSpeciesWithinExpressions ()
 Function to identify hidden species within expressions and substitute with the correct mathematical expression ie if we find k+v-x-y and k-x-y then replace k-x-y with newVar and replace k+v-x-y with newVar+v.
 
ExpressionAnalyseroperator= (const ExpressionAnalyser &rhs)
 Assignment operator for SBMLInferUnitsConverter.
 
void orderExpressions ()
 Function to order the expressions by type.
 
bool replaceExpressionInNodeWithNode (ASTNode *node, ASTNode *replaced, ASTNode *replacement)
 
virtual ~ExpressionAnalyser ()
 Destroy this ExpressionAnalyser object.
 

Constructor & Destructor Documentation

◆ ExpressionAnalyser() [1/3]

ExpressionAnalyser::ExpressionAnalyser ( )

Creates a new ExpressionAnalyser object.

◆ ExpressionAnalyser() [2/3]

ExpressionAnalyser::ExpressionAnalyser ( Model m,
pairODEs  ode 
)

Creates a new ExpressionAnalyser object with Model and ODEs.

◆ ExpressionAnalyser() [3/3]

ExpressionAnalyser::ExpressionAnalyser ( const ExpressionAnalyser obj)

Copy constructor; creates a copy of an ExpressionAnalyser object.

Parameters
objthe ExpressionAnalyser object to copy.

◆ ~ExpressionAnalyser()

ExpressionAnalyser::~ExpressionAnalyser ( )
virtual

Destroy this ExpressionAnalyser object.

Member Function Documentation

◆ analyse()

void ExpressionAnalyser::analyse ( )

Function to work through all the ODE expressions and invoke analyseNode where appropriate.

◆ analyseNode()

bool ExpressionAnalyser::analyseNode ( ASTNode node,
SubstitutionValues_t value 
)

Function to work through all the mathematical expressions and create substitution values.

◆ clone()

ExpressionAnalyser * ExpressionAnalyser::clone ( ) const
virtual

Creates and returns a deep copy of this ExpressionAnalyser object.

Returns
a (deep) copy of this converter.

◆ createBlankSubstitutionValues()

SubstitutionValues_t * ExpressionAnalyser::createBlankSubstitutionValues ( )

Function to create a blank substitution value.

◆ detectHiddenSpecies()

void ExpressionAnalyser::detectHiddenSpecies ( bool  testing = false)

Function to work through all the expressions and detect hidden species.

◆ getExpression()

SubstitutionValues_t * ExpressionAnalyser::getExpression ( unsigned int  index)

Returns the expression at the given index Only used in testing.

◆ getHiddenSpecies() [1/2]

List * ExpressionAnalyser::getHiddenSpecies ( )

Returns the list of hidden species.

◆ getHiddenSpecies() [2/2]

Parameter * ExpressionAnalyser::getHiddenSpecies ( unsigned int  index)

◆ getNumExpressions()

unsigned int ExpressionAnalyser::getNumExpressions ( )

Returns the number of expressions Only used in testing.

◆ getNumHiddenNodes()

unsigned int ExpressionAnalyser::getNumHiddenNodes ( )

◆ getNumHiddenSpecies()

unsigned int ExpressionAnalyser::getNumHiddenSpecies ( )

Returns the number of hidden species.

◆ identifyHiddenSpeciesWithinExpressions()

void ExpressionAnalyser::identifyHiddenSpeciesWithinExpressions ( )

Function to identify hidden species within expressions and substitute with the correct mathematical expression ie if we find k+v-x-y and k-x-y then replace k-x-y with newVar and replace k+v-x-y with newVar+v.

◆ operator=()

ExpressionAnalyser & ExpressionAnalyser::operator= ( const ExpressionAnalyser rhs)

Assignment operator for SBMLInferUnitsConverter.

Parameters
rhsthe object whose values are used as the basis of the assignment.

◆ orderExpressions()

void ExpressionAnalyser::orderExpressions ( )

Function to order the expressions by type.

◆ replaceExpressionInNodeWithNode()

bool ExpressionAnalyser::replaceExpressionInNodeWithNode ( ASTNode node,
ASTNode replaced,
ASTNode replacement 
)