COPASI API  4.40.278
CSBMLunitInterface Class Reference

#include <CSBMLunitInterface.h>

Classes

class  CEnvironmentInformation
 
class  CExpressionInformation
 
class  EvaluationResult
 
class  Statistics
 

Public Member Functions

void calculateStatistics ()
 
 CSBMLunitInterface (Model *model, bool unitsFromModel)
 
void debugOutput () const
 
void determineUnits ()
 
const std::vector< CExpressionInformation > & getExpressions () const
 
const std::set< const ASTNode * > & getListOfConflictingNodes () const
 
std::vector< std::pair< std::string, std::string > > getListOfLocalParametersWithGivenUnitStatus (int status) const
 
std::vector< std::string > getListOfObjectsWithGivenUnitStatus (int status) const
 
CSBMLunitInformationgetMappedUnitFromIdentifier (const std::string &node, const CEnvironmentInformation &ei)
 
CSBMLunitInformationgetMappedUnitFromNumberNode (const ASTNode *node)
 
std::string getMessageAboutUnknownUnits () const
 
Model * getModel ()
 
const Model * getModel () const
 
const StatisticsgetStatistics () const
 
void setAssumeDimensionlessOne (bool f)
 
void writeBackToModel ()
 
 ~CSBMLunitInterface ()
 

Static Public Member Functions

static void outputStatistics (const Statistics &stat, bool flag)
 

Private Member Functions

 CSBMLunitInterface (const CSBMLunitInterface &src)
 
EvaluationResult evaluate (const ASTNode *node)
 
void handleOneExpression (CExpressionInformation &ei)
 try to find out as much as possible about the units from one expression More...
 
CSBMLunitInformation handleTerminalNode (const CSBMLunitInformation &ui, CSBMLunitInformation *pNodeUnit, const ASTNode *node)
 
void initializeDefaultUnits ()
 initializes the base units with the defaults (moles, seconds, l, m, m^2) More...
 
void initializeFromSBMLModel (bool unitsFromModel)
 
CSBMLunitInterfaceoperator= (const CSBMLunitInterface &src)
 
CSBMLunitInformation recursion (const ASTNode *node, const CSBMLunitInformation &ui, const CEnvironmentInformation &ei)
 
CSBMLunitInformation recursionDivide (const ASTNode *node, const CSBMLunitInformation &ui, const CEnvironmentInformation &ei)
 
CSBMLunitInformation recursionEqual (const ASTNode *node, const CSBMLunitInformation &ui, const CEnvironmentInformation &ei)
 
CSBMLunitInformation recursionPiecewise (const ASTNode *node, const CSBMLunitInformation &ui, const CEnvironmentInformation &ei)
 
CSBMLunitInformation recursionPower (const ASTNode *node, const CSBMLunitInformation &ui, const CEnvironmentInformation &ei)
 
CSBMLunitInformation recursionTimes (const ASTNode *node, const CSBMLunitInformation &ui, const CEnvironmentInformation &ei)
 
FunctionDefinition * resolveFunctionName (const std::string &node)
 
ASTNode * resolveVariableName (const std::string &node, const CEnvironmentInformation &ei)
 

Static Private Member Functions

static std::string getIdentifier (const ASTNode *node)
 
static double getValueFromNumberNode (const ASTNode *node)
 return the value of a number node More...
 
static bool isBuiltInFunctionCall (const ASTNode *node)
 determines if the node contains a call to a built in function More...
 
static bool isFunctionCall (const ASTNode *node)
 determines if the node contains a call to a function definition More...
 
static bool isNumber (const ASTNode *node)
 determines if the node represents a number (integer, real, or rational) More...
 
static bool isObject (const ASTNode *node)
 
static bool isOperator (const ASTNode *node)
 

Private Attributes

bool mAssumeDimensionlessOne
 
std::set< const ASTNode * > mConflictingNodes
 contains the (terminal) nodes where a conflict appeared More...
 
int mError
 
Model * mpModel
 the sbml model from which this interface was initialized More...
 
CSBMLunitInformationmpSBMLAmountUnit
 
CSBMLunitInformationmpSBMLAreaUnit
 
CSBMLunitInformationmpSBMLConflictUnit
 
CSBMLunitInformationmpSBMLLengthUnit
 
CSBMLunitInformationmpSBMLTimeUnit
 
CSBMLunitInformationmpSBMLVolumeUnit
 
std::vector< CExpressionInformationmSBMLExpressions
 
unsigned int mSBMLLevel
 
std::map< std::string, std::map< std::string, CSBMLunitInformation > > mSBMLLocalParametersMap
 
std::map< const ASTNode *, CSBMLunitInformationmSBMLNumbersMap
 
std::map< std::string, CSBMLunitInformationmSBMLObjectsMap
 
unsigned int mSBMLVersion
 
Statistics mStatistics
 

Detailed Description

This class contains a copy of the unit information of an sbml model in the data structures the unit conversion algorithm can deal with. It contains lists of all objects/numbers that potentially can have units, and a list of all mathematical expressions in the sbml model that impose constraints on the units.

Constructor & Destructor Documentation

◆ CSBMLunitInterface() [1/2]

CSBMLunitInterface::CSBMLunitInterface ( const CSBMLunitInterface src)
private

◆ CSBMLunitInterface() [2/2]

CSBMLunitInterface::CSBMLunitInterface ( Model *  model,
bool  unitsFromModel 
)

initialize the unit interface from an sbml model, extracting all the unit information from the model

References initializeDefaultUnits(), initializeFromSBMLModel(), mpModel, mSBMLLevel, and mSBMLVersion.

◆ ~CSBMLunitInterface()

CSBMLunitInterface::~CSBMLunitInterface ( )

Member Function Documentation

◆ calculateStatistics()

◆ debugOutput()

◆ determineUnits()

◆ evaluate()

◆ getExpressions()

const std::vector<CExpressionInformation>& CSBMLunitInterface::getExpressions ( ) const
inline

return the list of all mathematical expressions including additional information

References mSBMLExpressions.

◆ getIdentifier()

std::string CSBMLunitInterface::getIdentifier ( const ASTNode *  node)
staticprivate

Referenced by recursion().

◆ getListOfConflictingNodes()

const std::set< const ASTNode * > & CSBMLunitInterface::getListOfConflictingNodes ( ) const

after determineUnits() was called this contains a set of terminal ASTNodes in which a conflict was detected. Note that is not necessarily where one would intuitively locate the conflict, i's just where it was detected.

References mConflictingNodes.

Referenced by Expression2PresentationMMLUnits::writeMathMLName(), and Expression2PresentationMMLUnits::writeMathMLNumber().

◆ getListOfLocalParametersWithGivenUnitStatus()

std::vector< std::pair< std::string, std::string > > CSBMLunitInterface::getListOfLocalParametersWithGivenUnitStatus ( int  status) const

returns a list of pairs of sbml IDs corresponding to all local parameters that match the given unit status (as explained above)

References mSBMLLocalParametersMap.

Referenced by getMessageAboutUnknownUnits().

◆ getListOfObjectsWithGivenUnitStatus()

std::vector< std::string > CSBMLunitInterface::getListOfObjectsWithGivenUnitStatus ( int  status) const

returns a list of sbml id corresponding to all global sbml objects that match the given unit status (as explained above)

References mSBMLObjectsMap.

Referenced by getMessageAboutUnknownUnits().

◆ getMappedUnitFromIdentifier()

CSBMLunitInformation * CSBMLunitInterface::getMappedUnitFromIdentifier ( const std::string &  node,
const CEnvironmentInformation ei 
)

provided with an identifier from an object node, this method tries to find the mapped unit information. According to the provided environment, this could be a local parameter or a global object.

References CSBMLunitInterface::CEnvironmentInformation::isReactionScope(), CSBMLunitInterface::CEnvironmentInformation::mReactionID, mSBMLLocalParametersMap, and mSBMLObjectsMap.

Referenced by handleOneExpression(), recursion(), writeBackToModel(), and Expression2PresentationMMLUnits::writeMathMLName().

◆ getMappedUnitFromNumberNode()

CSBMLunitInformation * CSBMLunitInterface::getMappedUnitFromNumberNode ( const ASTNode *  node)

find the unit information corresponding to a number node

References mSBMLNumbersMap.

Referenced by Expression2PresentationMMLUnits::writeMathMLNumber().

◆ getMessageAboutUnknownUnits()

std::string CSBMLunitInterface::getMessageAboutUnknownUnits ( ) const

generates a message containing a list of the objects with unknown units. The message should be suitable for presentation in a user interface.

References getListOfLocalParametersWithGivenUnitStatus(), getListOfObjectsWithGivenUnitStatus(), and mpModel.

◆ getModel() [1/2]

Model* CSBMLunitInterface::getModel ( )
inline

retrieve the SBML model

References mpModel.

Referenced by Expression2PresentationMMLUnits::setUnitInterface().

◆ getModel() [2/2]

const Model* CSBMLunitInterface::getModel ( ) const
inline

References mpModel.

◆ getStatistics()

const Statistics& CSBMLunitInterface::getStatistics ( ) const
inline

get statistics of the units of the model. In each of the vectors: 0: unknown 1: default 2: model wide provided units 3: provided units 4: derived units 5: conflict

References mStatistics.

◆ getValueFromNumberNode()

double CSBMLunitInterface::getValueFromNumberNode ( const ASTNode *  node)
staticprivate

return the value of a number node

Referenced by evaluate(), and recursion().

◆ handleOneExpression()

◆ handleTerminalNode()

CSBMLunitInformation CSBMLunitInterface::handleTerminalNode ( const CSBMLunitInformation ui,
CSBMLunitInformation pNodeUnit,
const ASTNode *  node 
)
private

This handles the units assignment/comparison/query for terminal node of the tree. ui is the unit information that is passed from above, pNodeUnit is the unit information that is already present in the terminal node, and the return value is the units of the node after the assignment/comparison/querying. mError is set to 1 if a conflict appears. The node is optional (it can be NULL), it is only used for reporting conflicts. If a new conflict appears the node pointer is added to the mConflictingNodes set.

References CSBMLunitInformation::DERIVED, CSBMLunitInformation::getInfo(), CSBMLunitInformation::isConflict(), CSBMLunit::isEqual(), mConflictingNodes, mError, CSBMLunitInformation::setConflict(), CSBMLunitInformation::setInfo(), and CSBMLunitInformation::UNKNOWN.

Referenced by handleOneExpression(), and recursion().

◆ initializeDefaultUnits()

void CSBMLunitInterface::initializeDefaultUnits ( )
private

◆ initializeFromSBMLModel()

◆ isBuiltInFunctionCall()

bool CSBMLunitInterface::isBuiltInFunctionCall ( const ASTNode *  node)
staticprivate

determines if the node contains a call to a built in function

Referenced by recursion().

◆ isFunctionCall()

bool CSBMLunitInterface::isFunctionCall ( const ASTNode *  node)
staticprivate

determines if the node contains a call to a function definition

Referenced by recursion().

◆ isNumber()

bool CSBMLunitInterface::isNumber ( const ASTNode *  node)
staticprivate

determines if the node represents a number (integer, real, or rational)

Referenced by evaluate(), and recursion().

◆ isObject()

bool CSBMLunitInterface::isObject ( const ASTNode *  node)
staticprivate

Referenced by recursion().

◆ isOperator()

bool CSBMLunitInterface::isOperator ( const ASTNode *  node)
staticprivate

Referenced by recursion().

◆ operator=()

CSBMLunitInterface& CSBMLunitInterface::operator= ( const CSBMLunitInterface src)
private

◆ outputStatistics()

void CSBMLunitInterface::outputStatistics ( const Statistics stat,
bool  flag 
)
static

◆ recursion()

◆ recursionDivide()

CSBMLunitInformation CSBMLunitInterface::recursionDivide ( const ASTNode *  node,
const CSBMLunitInformation ui,
const CEnvironmentInformation ei 
)
private

handle a division node. If one unit is unknown it can be calculated. If no unit is unknown a consistency check can be made. If more than one unit is unknown, nothing can be done.

References CSBMLunitInformation::DERIVED, CSBMLunitInformation::getInfo(), CSBMLunit::invert(), mSBMLLevel, mSBMLVersion, CSBMLunit::multiply(), recursion(), CSBMLunitInformation::setInfo(), and CSBMLunitInformation::UNKNOWN.

Referenced by recursion().

◆ recursionEqual()

CSBMLunitInformation CSBMLunitInterface::recursionEqual ( const ASTNode *  node,
const CSBMLunitInformation ui,
const CEnvironmentInformation ei 
)
private

handle the case of a node where the units are supposed to be equal. This includes plus, minus, choice, comparison operators

References CSBMLunitInformation::getInfo(), mSBMLLevel, mSBMLVersion, recursion(), and CSBMLunitInformation::UNKNOWN.

Referenced by recursion().

◆ recursionPiecewise()

CSBMLunitInformation CSBMLunitInterface::recursionPiecewise ( const ASTNode *  node,
const CSBMLunitInformation ui,
const CEnvironmentInformation ei 
)
private

handle the case of a pieewise node

References CSBMLunitInformation::getInfo(), mSBMLLevel, mSBMLVersion, recursion(), and CSBMLunitInformation::UNKNOWN.

Referenced by recursion().

◆ recursionPower()

◆ recursionTimes()

CSBMLunitInformation CSBMLunitInterface::recursionTimes ( const ASTNode *  node,
const CSBMLunitInformation ui,
const CEnvironmentInformation ei 
)
private

handle a multiplication node. If one unit is unknown it can be calculated. If no unit is unknown a consistency check can be made. If more than one unit is unknown, nothing can be done.

References CSBMLunitInformation::DERIVED, CSBMLunitInformation::getInfo(), CSBMLunit::invert(), mSBMLLevel, mSBMLVersion, CSBMLunit::multiply(), recursion(), CSBMLunitInformation::setInfo(), and CSBMLunitInformation::UNKNOWN.

Referenced by recursion().

◆ resolveFunctionName()

FunctionDefinition * CSBMLunitInterface::resolveFunctionName ( const std::string &  node)
private

provided with an identifier from an object node, this method checks if it corresponds to a function definition in the current model. If it does, the FunctionDefinition* is returned, else NULL.

References mpModel.

Referenced by recursion().

◆ resolveVariableName()

ASTNode * CSBMLunitInterface::resolveVariableName ( const std::string &  node,
const CEnvironmentInformation ei 
)
private

provided with an identifier from an object node, this method checks if it corresponds to a function variable from the current environment. If it does, the ASTNode* is returned, else NULL.

References CSBMLunitInterface::CEnvironmentInformation::mFrameStack.

Referenced by recursion().

◆ setAssumeDimensionlessOne()

void CSBMLunitInterface::setAssumeDimensionlessOne ( bool  f)
inline

◆ writeBackToModel()

void CSBMLunitInterface::writeBackToModel ( )

Writes the units information back to an sbml model (without any unit conversions). The most common use case for this will be to annotate the model with units of objects that did not have explicit units before, e.g. parameters.

References CSBMLunitInformation::DERIVED, CSBMLunitInformation::getInfo(), getMappedUnitFromIdentifier(), CSBMLunit::getSBMLUnitDefinition(), CSBMLunit::getSymbolicExpExp(), and mpModel.

Member Data Documentation

◆ mAssumeDimensionlessOne

bool CSBMLunitInterface::mAssumeDimensionlessOne
private

indicated whether a number 1.0 and -1.0 is considered to be dimensionless

Referenced by recursion(), and setAssumeDimensionlessOne().

◆ mConflictingNodes

std::set<const ASTNode *> CSBMLunitInterface::mConflictingNodes
private

contains the (terminal) nodes where a conflict appeared

Referenced by determineUnits(), getListOfConflictingNodes(), and handleTerminalNode().

◆ mError

int CSBMLunitInterface::mError
private

◆ mpModel

Model* CSBMLunitInterface::mpModel
private

◆ mpSBMLAmountUnit

CSBMLunitInformation* CSBMLunitInterface::mpSBMLAmountUnit
private

◆ mpSBMLAreaUnit

CSBMLunitInformation* CSBMLunitInterface::mpSBMLAreaUnit
private

◆ mpSBMLConflictUnit

CSBMLunitInformation* CSBMLunitInterface::mpSBMLConflictUnit
private

◆ mpSBMLLengthUnit

CSBMLunitInformation* CSBMLunitInterface::mpSBMLLengthUnit
private

◆ mpSBMLTimeUnit

CSBMLunitInformation* CSBMLunitInterface::mpSBMLTimeUnit
private

◆ mpSBMLVolumeUnit

CSBMLunitInformation* CSBMLunitInterface::mpSBMLVolumeUnit
private

◆ mSBMLExpressions

std::vector<CExpressionInformation> CSBMLunitInterface::mSBMLExpressions
private

a list of all mathematical expressions in the sbml model along with the units information for their root node.

Referenced by debugOutput(), determineUnits(), getExpressions(), and initializeFromSBMLModel().

◆ mSBMLLevel

◆ mSBMLLocalParametersMap

std::map<std::string, std::map<std::string, CSBMLunitInformation> > CSBMLunitInterface::mSBMLLocalParametersMap
private

This maps the id of a reaction and the id of a local parameter to a copy of its units information. (Local parameters are the only objects in sbml that need two ids for their identification)

Referenced by calculateStatistics(), debugOutput(), getListOfLocalParametersWithGivenUnitStatus(), getMappedUnitFromIdentifier(), and initializeFromSBMLModel().

◆ mSBMLNumbersMap

std::map<const ASTNode*, CSBMLunitInformation> CSBMLunitInterface::mSBMLNumbersMap
private

This maps number nodes to units information

Referenced by calculateStatistics(), getMappedUnitFromNumberNode(), initializeFromSBMLModel(), and recursion().

◆ mSBMLObjectsMap

std::map<std::string, CSBMLunitInformation> CSBMLunitInterface::mSBMLObjectsMap
private

This maps the id of any sbml object that can be referenced by one id to a copy of its units information.

Referenced by calculateStatistics(), debugOutput(), getListOfObjectsWithGivenUnitStatus(), getMappedUnitFromIdentifier(), and initializeFromSBMLModel().

◆ mSBMLVersion

◆ mStatistics

Statistics CSBMLunitInterface::mStatistics
private

The documentation for this class was generated from the following files: