COPASI API
4.16.103
|
#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.
Definition at line 27 of file CSBMLunitInterface.h.
|
private |
CSBMLunitInterface::CSBMLunitInterface | ( | Model * | model, |
bool | unitsFromModel | ||
) |
initialize the unit interface from an sbml model, extracting all the unit information from the model
Definition at line 14 of file CSBMLunitInterface.cpp.
References initializeDefaultUnits(), initializeFromSBMLModel(), mpModel, mSBMLLevel, and mSBMLVersion.
CSBMLunitInterface::~CSBMLunitInterface | ( | ) |
Destructor.
Definition at line 39 of file CSBMLunitInterface.cpp.
References mpSBMLAmountUnit, mpSBMLAreaUnit, mpSBMLConflictUnit, mpSBMLLengthUnit, mpSBMLTimeUnit, mpSBMLVolumeUnit, and pdelete.
void CSBMLunitInterface::calculateStatistics | ( | ) |
Definition at line 614 of file CSBMLunitInterface.cpp.
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
Definition at line 800 of file CSBMLunitInterface.cpp.
References CSBMLunitInformation::getDisplayString(), if(), 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.
Definition at line 859 of file CSBMLunitInterface.cpp.
References calculateStatistics(), CSBMLunitInformation::getDisplayString(), handleOneExpression(), if(), mConflictingNodes, CSBMLunitInterface::CExpressionInformation::mPerTime, CSBMLunitInterface::CExpressionInformation::mpExpression, mpModel, CSBMLunitInterface::CExpressionInformation::mReactionId, CSBMLunitInterface::CExpressionInformation::mRootObject, CSBMLunitInterface::CExpressionInformation::mRootUnit, and mSBMLExpressions.
Referenced by CSBMLExporter::exportModelToString().
|
private |
Definition at line 1533 of file CSBMLunitInterface.cpp.
References getValueFromNumberNode(), isNumber(), CSBMLunitInterface::EvaluationResult::known, and CSBMLunitInterface::EvaluationResult::result.
Referenced by recursionPower().
|
inline |
return the list of all mathematical expressions including additional information
Definition at line 167 of file CSBMLunitInterface.h.
References mSBMLExpressions.
|
staticprivate |
Definition at line 1730 of file CSBMLunitInterface.cpp.
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.
Definition at line 854 of file CSBMLunitInterface.cpp.
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)
Definition at line 729 of file CSBMLunitInterface.cpp.
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)
Definition at line 711 of file CSBMLunitInterface.cpp.
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.
Definition at line 1612 of file CSBMLunitInterface.cpp.
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
Definition at line 1667 of file CSBMLunitInterface.cpp.
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.
Definition at line 751 of file CSBMLunitInterface.cpp.
References getListOfLocalParametersWithGivenUnitStatus(), getListOfObjectsWithGivenUnitStatus(), and mpModel.
|
inline |
retrieve the SBML model
Definition at line 63 of file CSBMLunitInterface.h.
References mpModel.
Referenced by Expression2PresentationMMLUnits::setUnitInterface().
|
inline |
Definition at line 64 of file CSBMLunitInterface.h.
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
Definition at line 97 of file CSBMLunitInterface.h.
References mStatistics.
|
staticprivate |
return the value of a number node
Definition at line 1707 of file CSBMLunitInterface.cpp.
Referenced by evaluate(), and recursion().
|
private |
try to find out as much as possible about the units from one expression
Definition at line 898 of file CSBMLunitInterface.cpp.
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.
Definition at line 1170 of file CSBMLunitInterface.cpp.
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)
Definition at line 49 of file CSBMLunitInterface.cpp.
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(). .
Definition at line 85 of file CSBMLunitInterface.cpp.
References calculateStatistics(), CSBMLunitInformation::DEFAULT, CSBMLunitInformation::getInfo(), CSBMLunitInformation::GLOBAL, CSBMLunit::invert(), CSBMLunitInterface::CExpressionInformation::mObjectDisplayString, CSBMLunitInterface::CExpressionInformation::mPerTime, CSBMLunitInterface::CExpressionInformation::mpExpression, mpModel, mpSBMLAmountUnit, mpSBMLAreaUnit, mpSBMLLengthUnit, mpSBMLTimeUnit, mpSBMLVolumeUnit, 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
Definition at line 1702 of file CSBMLunitInterface.cpp.
Referenced by recursion().
|
staticprivate |
determines if the node contains a call to a function definition
Definition at line 1697 of file CSBMLunitInterface.cpp.
Referenced by recursion().
|
staticprivate |
determines if the node represents a number (integer, real, or rational)
Definition at line 1692 of file CSBMLunitInterface.cpp.
Referenced by evaluate(), and recursion().
|
staticprivate |
Definition at line 1680 of file CSBMLunitInterface.cpp.
Referenced by recursion().
|
staticprivate |
Definition at line 1685 of file CSBMLunitInterface.cpp.
Referenced by recursion().
|
private |
|
static |
Definition at line 668 of file CSBMLunitInterface.cpp.
References CSBMLunitInterface::Statistics::all, CSBMLunitInterface::Statistics::global, if(), CSBMLunitInterface::Statistics::local, and CSBMLunitInterface::Statistics::numbers.
|
private |
Definition at line 947 of file CSBMLunitInterface.cpp.
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.
Definition at line 1346 of file CSBMLunitInterface.cpp.
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
Definition at line 1211 of file CSBMLunitInterface.cpp.
References CSBMLunitInformation::getInfo(), mSBMLLevel, mSBMLVersion, recursion(), and CSBMLunitInformation::UNKNOWN.
Referenced by recursion().
|
private |
handle the case of a pieewise node
Definition at line 1551 of file CSBMLunitInterface.cpp.
References CSBMLunitInformation::getInfo(), mSBMLLevel, mSBMLVersion, recursion(), and CSBMLunitInformation::UNKNOWN.
Referenced by recursion().
|
private |
Definition at line 1438 of file CSBMLunitInterface.cpp.
References CSBMLunit::applyExponent(), CSBMLunit::applyInverseExponent(), CSBMLunitInformation::DEFAULT, CSBMLunitInformation::DERIVED, evaluate(), CSBMLunitInformation::getInfo(), CSBMLunitInterface::CEnvironmentInformation::mFrameStack, mSBMLLevel, mSBMLVersion, recursion(), 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.
Definition at line 1266 of file CSBMLunitInterface.cpp.
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.
Definition at line 1660 of file CSBMLunitInterface.cpp.
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.
Definition at line 1645 of file CSBMLunitInterface.cpp.
References CSBMLunitInterface::CEnvironmentInformation::mFrameStack.
Referenced by recursion().
|
inline |
Definition at line 66 of file CSBMLunitInterface.h.
References mAssumeDimensionlessOne.
Referenced by CSBMLExporter::exportModelToString().
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.
Definition at line 497 of file CSBMLunitInterface.cpp.
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
Definition at line 257 of file CSBMLunitInterface.h.
Referenced by recursion(), and setAssumeDimensionlessOne().
|
private |
contains the (terminal) nodes where a conflict appeared
Definition at line 364 of file CSBMLunitInterface.h.
Referenced by determineUnits(), getListOfConflictingNodes(), and handleTerminalNode().
|
private |
Definition at line 361 of file CSBMLunitInterface.h.
Referenced by handleOneExpression(), and handleTerminalNode().
|
private |
the sbml model from which this interface was initialized
Definition at line 224 of file CSBMLunitInterface.h.
Referenced by CSBMLunitInterface(), determineUnits(), getMessageAboutUnknownUnits(), getModel(), initializeFromSBMLModel(), resolveFunctionName(), and writeBackToModel().
|
private |
Definition at line 354 of file CSBMLunitInterface.h.
Referenced by debugOutput(), initializeDefaultUnits(), initializeFromSBMLModel(), and ~CSBMLunitInterface().
|
private |
Definition at line 356 of file CSBMLunitInterface.h.
Referenced by debugOutput(), initializeDefaultUnits(), initializeFromSBMLModel(), and ~CSBMLunitInterface().
|
private |
Definition at line 359 of file CSBMLunitInterface.h.
Referenced by initializeDefaultUnits(), recursion(), and ~CSBMLunitInterface().
|
private |
Definition at line 357 of file CSBMLunitInterface.h.
Referenced by debugOutput(), initializeDefaultUnits(), initializeFromSBMLModel(), and ~CSBMLunitInterface().
|
private |
Definition at line 353 of file CSBMLunitInterface.h.
Referenced by debugOutput(), handleOneExpression(), initializeDefaultUnits(), initializeFromSBMLModel(), and ~CSBMLunitInterface().
|
private |
Definition at line 355 of file CSBMLunitInterface.h.
Referenced by debugOutput(), initializeDefaultUnits(), initializeFromSBMLModel(), and ~CSBMLunitInterface().
|
private |
a list of all mathematical expressions in the sbml model along with the units information for their root node.
Definition at line 252 of file CSBMLunitInterface.h.
Referenced by debugOutput(), determineUnits(), getExpressions(), and initializeFromSBMLModel().
|
private |
Definition at line 226 of file CSBMLunitInterface.h.
Referenced by CSBMLunitInterface(), initializeDefaultUnits(), initializeFromSBMLModel(), recursion(), recursionDivide(), recursionEqual(), recursionPiecewise(), recursionPower(), and recursionTimes().
|
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)
Definition at line 241 of file CSBMLunitInterface.h.
Referenced by calculateStatistics(), debugOutput(), getListOfLocalParametersWithGivenUnitStatus(), getMappedUnitFromIdentifier(), and initializeFromSBMLModel().
|
private |
This maps number nodes to units information
Definition at line 246 of file CSBMLunitInterface.h.
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.
Definition at line 234 of file CSBMLunitInterface.h.
Referenced by calculateStatistics(), debugOutput(), getListOfObjectsWithGivenUnitStatus(), getMappedUnitFromIdentifier(), and initializeFromSBMLModel().
|
private |
Definition at line 228 of file CSBMLunitInterface.h.
Referenced by CSBMLunitInterface(), initializeDefaultUnits(), initializeFromSBMLModel(), recursion(), recursionDivide(), recursionEqual(), recursionPiecewise(), recursionPower(), and recursionTimes().
|
private |
Definition at line 366 of file CSBMLunitInterface.h.
Referenced by calculateStatistics(), and getStatistics().