COPASI API
4.40.278
|
#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 |
CSBMLunitInformation * | getMappedUnitFromIdentifier (const std::string &node, const CEnvironmentInformation &ei) |
CSBMLunitInformation * | getMappedUnitFromNumberNode (const ASTNode *node) |
std::string | getMessageAboutUnknownUnits () const |
Model * | getModel () |
const Model * | getModel () const |
const Statistics & | getStatistics () const |
void | setAssumeDimensionlessOne (bool f) |
void | writeBackToModel () |
~CSBMLunitInterface () | |
Static Public Member Functions | |
static void | outputStatistics (const Statistics &stat, bool flag) |
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... | |
CSBMLunitInformation * | mpSBMLAmountUnit |
CSBMLunitInformation * | mpSBMLAreaUnit |
CSBMLunitInformation * | mpSBMLConflictUnit |
CSBMLunitInformation * | mpSBMLLengthUnit |
CSBMLunitInformation * | mpSBMLTimeUnit |
CSBMLunitInformation * | mpSBMLVolumeUnit |
std::vector< CExpressionInformation > | mSBMLExpressions |
unsigned int | mSBMLLevel |
std::map< std::string, std::map< std::string, CSBMLunitInformation > > | mSBMLLocalParametersMap |
std::map< const ASTNode *, CSBMLunitInformation > | mSBMLNumbersMap |
std::map< std::string, CSBMLunitInformation > | mSBMLObjectsMap |
unsigned int | mSBMLVersion |
Statistics | mStatistics |
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.
|
private |
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 | ( | ) |
Destructor.
References mpSBMLAmountUnit, mpSBMLAreaUnit, mpSBMLConflictUnit, mpSBMLLengthUnit, mpSBMLTimeUnit, mpSBMLVolumeUnit, and pdelete.
void CSBMLunitInterface::calculateStatistics | ( | ) |
References CSBMLunitInterface::Statistics::all, CSBMLunitInterface::Statistics::global, CSBMLunitInterface::Statistics::local, mSBMLLocalParametersMap, mSBMLNumbersMap, mSBMLObjectsMap, mStatistics, and CSBMLunitInterface::Statistics::numbers.
Referenced by determineUnits(), and initializeFromSBMLModel().
void CSBMLunitInterface::debugOutput | ( | ) | const |
initialize the unit interface from an sbml model, without using any unit information from the model
References CSBMLunitInformation::getDisplayString(), CSBMLunitInterface::CExpressionInformation::mErrorCode, CSBMLunitInterface::CExpressionInformation::mPerTime, CSBMLunitInterface::CExpressionInformation::mpExpression, mpSBMLAmountUnit, mpSBMLAreaUnit, mpSBMLLengthUnit, mpSBMLTimeUnit, mpSBMLVolumeUnit, CSBMLunitInterface::CExpressionInformation::mReactionId, CSBMLunitInterface::CExpressionInformation::mRootObject, CSBMLunitInterface::CExpressionInformation::mRootUnit, mSBMLExpressions, mSBMLLocalParametersMap, and mSBMLObjectsMap.
void CSBMLunitInterface::determineUnits | ( | ) |
Tries to determine unknown units by considering the known units and all the contrains imposed by the mathmatical expressions.
References calculateStatistics(), CSBMLunitInformation::getDisplayString(), handleOneExpression(), mConflictingNodes, CSBMLunitInterface::CExpressionInformation::mPerTime, CSBMLunitInterface::CExpressionInformation::mpExpression, mpModel, CSBMLunitInterface::CExpressionInformation::mReactionId, CSBMLunitInterface::CExpressionInformation::mRootObject, CSBMLunitInterface::CExpressionInformation::mRootUnit, and mSBMLExpressions.
|
private |
References getValueFromNumberNode(), isNumber(), CSBMLunitInterface::EvaluationResult::known, and CSBMLunitInterface::EvaluationResult::result.
Referenced by recursionPower().
|
inline |
return the list of all mathematical expressions including additional information
References mSBMLExpressions.
|
staticprivate |
Referenced by recursion().
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().
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().
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().
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().
CSBMLunitInformation * CSBMLunitInterface::getMappedUnitFromNumberNode | ( | const ASTNode * | node | ) |
find the unit information corresponding to a number node
References mSBMLNumbersMap.
Referenced by Expression2PresentationMMLUnits::writeMathMLNumber().
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.
|
inline |
retrieve the SBML model
References mpModel.
Referenced by Expression2PresentationMMLUnits::setUnitInterface().
|
inline |
References mpModel.
|
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.
|
staticprivate |
return the value of a number node
Referenced by evaluate(), and recursion().
|
private |
try to find out as much as possible about the units from one expression
References CSBMLunitInformation::getInfo(), getMappedUnitFromIdentifier(), handleTerminalNode(), CSBMLunit::invert(), mError, CSBMLunitInterface::CExpressionInformation::mErrorCode, CSBMLunitInterface::CExpressionInformation::mPerTime, CSBMLunitInterface::CExpressionInformation::mpExpression, mpSBMLTimeUnit, CSBMLunitInterface::CExpressionInformation::mReactionId, CSBMLunitInterface::CEnvironmentInformation::mReactionID, CSBMLunitInterface::CExpressionInformation::mRootObject, CSBMLunitInterface::CExpressionInformation::mRootUnit, CSBMLunit::multiply(), recursion(), and CSBMLunitInformation::UNKNOWN.
Referenced by determineUnits().
|
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().
|
private |
initializes the base units with the defaults (moles, seconds, l, m, m^2)
References CSBMLunitInformation::DEFAULT, mpSBMLAmountUnit, mpSBMLAreaUnit, mpSBMLConflictUnit, mpSBMLLengthUnit, mpSBMLTimeUnit, mpSBMLVolumeUnit, mSBMLLevel, mSBMLVersion, and CSBMLunitInformation::UNKNOWN.
Referenced by CSBMLunitInterface().
|
private |
initialize from sbml model. If unitsFromModel is true the unit information is extracted from the model. Otherwise the units are constructed from a set of base units that was provided by initializeSetOfUnits(). .
References calculateStatistics(), CSBMLunitInformation::DEFAULT, CSBMLunitInformation::getInfo(), CSBMLunitInformation::GLOBAL, CSBMLunit::invert(), CSBMLunitInterface::CExpressionInformation::mObjectDisplayString, CSBMLunitInterface::CExpressionInformation::mPerTime, CSBMLunitInterface::CExpressionInformation::mpExpression, mpModel, mpSBMLAmountUnit, mpSBMLConflictUnit, CSBMLunitInterface::CExpressionInformation::mReactionId, CSBMLunitInterface::CExpressionInformation::mRootObject, CSBMLunitInterface::CExpressionInformation::mRootUnit, mSBMLExpressions, mSBMLLevel, mSBMLLocalParametersMap, mSBMLNumbersMap, mSBMLObjectsMap, mSBMLVersion, CSBMLunitInterface::CExpressionInformation::mTypeDescription, CSBMLunit::multiply(), CSBMLunitInformation::PROVIDED, CSBMLunitInformation::setInfo(), and CSBMLunitInformation::UNKNOWN.
Referenced by CSBMLunitInterface().
|
staticprivate |
determines if the node contains a call to a built in function
Referenced by recursion().
|
staticprivate |
determines if the node contains a call to a function definition
Referenced by recursion().
|
staticprivate |
determines if the node represents a number (integer, real, or rational)
Referenced by evaluate(), and recursion().
|
staticprivate |
Referenced by recursion().
|
staticprivate |
Referenced by recursion().
|
private |
|
static |
|
private |
References CSBMLunitInformation::DEFAULT, CSBMLunitInformation::DERIVED, CSBMLunitInterface::CEnvironmentInformation::drop(), getIdentifier(), getMappedUnitFromIdentifier(), getValueFromNumberNode(), handleTerminalNode(), isBuiltInFunctionCall(), isFunctionCall(), isNumber(), isObject(), isOperator(), mAssumeDimensionlessOne, mpSBMLConflictUnit, mSBMLLevel, mSBMLNumbersMap, mSBMLVersion, CSBMLunitInterface::CEnvironmentInformation::push(), recursionDivide(), recursionEqual(), recursionPiecewise(), recursionPower(), recursionTimes(), resolveFunctionName(), resolveVariableName(), CSBMLunitInformation::setInfo(), and CSBMLunitInformation::UNKNOWN.
Referenced by handleOneExpression(), recursionDivide(), recursionEqual(), recursionPiecewise(), recursionPower(), and recursionTimes().
|
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().
|
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().
|
private |
handle the case of a pieewise node
References CSBMLunitInformation::getInfo(), mSBMLLevel, mSBMLVersion, recursion(), and CSBMLunitInformation::UNKNOWN.
Referenced by recursion().
|
private |
References CSBMLunit::applyExponent(), CSBMLunit::applyInverseExponent(), CSBMLunitInformation::DEFAULT, CSBMLunitInformation::DERIVED, evaluate(), CSBMLunitInformation::getInfo(), CSBMLunitInterface::EvaluationResult::known, CSBMLunitInterface::CEnvironmentInformation::mFrameStack, mSBMLLevel, mSBMLVersion, recursion(), CSBMLunitInterface::EvaluationResult::result, CSBMLunitInformation::setInfo(), and CSBMLunitInformation::UNKNOWN.
Referenced by recursion().
|
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().
|
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().
|
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().
|
inline |
References mAssumeDimensionlessOne.
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.
|
private |
indicated whether a number 1.0 and -1.0 is considered to be dimensionless
Referenced by recursion(), and setAssumeDimensionlessOne().
|
private |
contains the (terminal) nodes where a conflict appeared
Referenced by determineUnits(), getListOfConflictingNodes(), and handleTerminalNode().
|
private |
Referenced by handleOneExpression(), and handleTerminalNode().
|
private |
the sbml model from which this interface was initialized
Referenced by CSBMLunitInterface(), determineUnits(), getMessageAboutUnknownUnits(), getModel(), initializeFromSBMLModel(), resolveFunctionName(), and writeBackToModel().
|
private |
Referenced by debugOutput(), initializeDefaultUnits(), initializeFromSBMLModel(), and ~CSBMLunitInterface().
|
private |
Referenced by debugOutput(), initializeDefaultUnits(), and ~CSBMLunitInterface().
|
private |
Referenced by initializeDefaultUnits(), initializeFromSBMLModel(), recursion(), and ~CSBMLunitInterface().
|
private |
Referenced by debugOutput(), initializeDefaultUnits(), and ~CSBMLunitInterface().
|
private |
Referenced by debugOutput(), handleOneExpression(), initializeDefaultUnits(), and ~CSBMLunitInterface().
|
private |
Referenced by debugOutput(), initializeDefaultUnits(), and ~CSBMLunitInterface().
|
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().
|
private |
|
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().
|
private |
This maps number nodes to units information
Referenced by calculateStatistics(), getMappedUnitFromNumberNode(), initializeFromSBMLModel(), and recursion().
|
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().
|
private |
|
private |
Referenced by calculateStatistics(), and getStatistics().