COPASI API
4.40.278
|
#include <SBMLUnitSupport.h>
Classes | |
struct | SUnitInfo |
Public Types | |
enum class | UnitType { dimensionless , substance , time , volume , area , length , other , __SIZE } |
Public Member Functions | |
void | checkElementUnits (const Model *pSBMLModel, CModel *pCopasiModel) |
bool | createUnitExpressionFor (SUnitInfo &unitInfo) const |
const SUnitInfo & | importUnit (const std::string unitId, const Model *pSBMLModel) |
const SUnitInfo & | importUnit (const UnitDefinition *pUnitDefinition, const bool &allocated) |
void | importUnitsFromSBMLDocument (Model *sbmlModel, CModel *pCopasiModel) |
imports the units from the given sbml model More... | |
void | setLevelAndVersion (int level, int version) |
bool | validateUnit (SUnitInfo &unitInfo, const std::string &constraint) const |
~SBMLUnitSupport () | |
Static Public Member Functions | |
static bool | areSBMLUnitDefinitionsIdentical (const SUnitInfo &unitInfo1, const SUnitInfo &unitInfo2) |
static void | checkForSpatialSizeUnits (const CDataModel &dataModel, std::vector< SBMLIncompatibility > &result) |
static std::string | unitKindToString (UnitKind_t kind) |
Protected Attributes | |
bool | mAvogadroSet = false |
unsigned int | mLevel = 0 |
unsigned int | mVersion = 0 |
Private Attributes | |
std::map< std::string, SUnitInfo > | mImportedUnits |
const SUnitInfo * | mpAreaUnit = nullptr |
const SUnitInfo * | mpLengthUnit = nullptr |
const SUnitInfo * | mpSubstanceUnit = nullptr |
const SUnitInfo * | mpTimeUnit = nullptr |
const SUnitInfo * | mpVolumeUnit = nullptr |
|
strong |
SBMLUnitSupport::~SBMLUnitSupport | ( | ) |
References mImportedUnits, and pdelete.
|
static |
Enhanced method to identify identical SBML unit definitions. This method uses the areIdentical method from libSBML, but if the method return false, it does some extra checks. Right now it check for example if two volumes, one given in litre and one given in cubic meters are identical.
Enhanced method to identify identical sbml unit definitions. The method first converts the unit definitions to SI units and simplifies them, only then they are compared.
References areApproximatelyEqual(), SBMLUnitSupport::SUnitInfo::pSBML, SBMLUnitSupport::SUnitInfo::type, and SBMLUnitSupport::SUnitInfo::valid.
Referenced by checkElementUnits(), checkForSpatialSizeUnits(), and importUnitsFromSBMLDocument().
void SBMLUnitSupport::checkElementUnits | ( | const Model * | pSBMLModel, |
CModel * | pCopasiModel | ||
) |
References area, areApproximatelyEqual(), areSBMLUnitDefinitionsIdentical(), CCore::Concentration, dimensionless, SBMLUnitSupport::SUnitInfo::expression, importUnit(), CFlags< Enum >::isSet(), length, MCSBML, mLevel, mpAreaUnit, mpLengthUnit, mpSubstanceUnit, mpTimeUnit, mpVolumeUnit, mVersion, CModel::setAreaUnit(), CModel::setLengthUnit(), CModel::setQuantityUnit(), CModel::setTimeUnit(), CModel::setVolumeUnit(), substance, time, SBMLUnitSupport::SUnitInfo::type, SBMLUnitSupport::SUnitInfo::valid, volume, and CCopasiMessage::WARNING.
Referenced by importUnitsFromSBMLDocument().
|
static |
Go through all species in the model and check if the corresponding species in the SBML model has the spatialSizeUnits attribute set. This attribute is not supported in SBML L2V3 and above, so we have to get rid of this attribute when we export to a level equal to or higher than L2V3. If the attribute has the same value as the compartments units, we can just delete it without changing the model, otherwise we have to give a corresponding warning.
References areSBMLUnitDefinitionsIdentical(), CDataVector< CType >::begin(), CDataVector< CType >::end(), CModel::getMetabolites(), CDataModel::getModel(), importUnit(), MCSBML, setLevelAndVersion(), SBMLUnitSupport::SUnitInfo::valid, and CCopasiMessage::WARNING.
Referenced by CSBMLExporter::createMetabolites(), and CSBMLExporter::isModelSBMLL2V3Compatible().
bool SBMLUnitSupport::createUnitExpressionFor | ( | SUnitInfo & | unitInfo | ) | const |
Converts the given SBML unit to a COPASI Unit
SUnitInfo | & unitInfo |
References CUnit::addComponent(), areApproximatelyEqual(), CUnit::buildExpression(), CUnit::compile(), CBaseUnit::dimensionless, CUnit::exponentiate(), SBMLUnitSupport::SUnitInfo::expression, CUnit::filterUsedSymbols(), CUnit::getExpression(), CRootContainer::getUnitList(), SBMLUnitSupport::SUnitInfo::pSBML, CUnit::setDimensionLess(), unitKindToString(), and utf8Length().
Referenced by importUnit(), and validateUnit().
const SBMLUnitSupport::SUnitInfo & SBMLUnitSupport::importUnit | ( | const std::string | unitId, |
const Model * | pSBMLModel | ||
) |
References C_INT32.
Referenced by checkElementUnits(), checkForSpatialSizeUnits(), SBMLImporter::createCModelValueFromParameter(), and importUnitsFromSBMLDocument().
const SBMLUnitSupport::SUnitInfo & SBMLUnitSupport::importUnit | ( | const UnitDefinition * | pUnitDefinition, |
const bool & | allocated | ||
) |
void SBMLUnitSupport::importUnitsFromSBMLDocument | ( | Model * | sbmlModel, |
CModel * | pCopasiModel | ||
) |
imports the units from the given sbml model
sbmlModel |
References area, areSBMLUnitDefinitionsIdentical(), checkElementUnits(), CCore::Concentration, SBMLUnitSupport::SUnitInfo::expression, importUnit(), CFlags< Enum >::isSet(), length, mAvogadroSet, MCSBML, mLevel, mpAreaUnit, mpLengthUnit, mpSubstanceUnit, mpTimeUnit, mpVolumeUnit, SBML_AVOGADRO, CModel::setAreaUnit(), CModel::setAvogadro(), CModel::setLengthUnit(), CModel::setQuantityUnit(), CModel::setTimeUnit(), CModel::setVolumeUnit(), substance, time, SBMLUnitSupport::SUnitInfo::type, SBMLUnitSupport::SUnitInfo::valid, volume, and CCopasiMessage::WARNING.
Referenced by SBMLImporter::createCModelFromSBMLDocument().
void SBMLUnitSupport::setLevelAndVersion | ( | int | level, |
int | version | ||
) |
References mLevel, and mVersion.
Referenced by checkForSpatialSizeUnits().
|
static |
Referenced by SBMLImporter::createCModelValueFromParameter(), and createUnitExpressionFor().
bool SBMLUnitSupport::validateUnit | ( | SBMLUnitSupport::SUnitInfo & | unitInfo, |
const std::string & | constraint | ||
) | const |
Validates whether SBML unit definition is derived from constraint. If valid the equivalent COPASI unit expression is returned otherwise an empty string;
SUnitInfo | & unitInfo |
const | std::string & constraint |
References createUnitExpressionFor(), SBMLUnitSupport::SUnitInfo::expression, CUnit::isDimensionless(), and CUnit::isEquivalent().
Referenced by importUnit().
|
protected |
Referenced by importUnitsFromSBMLDocument(), and SBMLImporter::parseSBML().
|
private |
Referenced by importUnit(), and ~SBMLUnitSupport().
|
protected |
Referenced by checkElementUnits(), SBMLImporter::checkRuleMathConsistency(), SBMLImporter::createCCompartmentFromCompartment(), SBMLImporter::createCMetabFromSpecies(), SBMLImporter::createCModelFromSBMLDocument(), SBMLImporter::createCModelValueFromParameter(), SBMLImporter::createCReactionFromReaction(), SBMLImporter::importEvent(), SBMLImporter::importInitialAssignments(), SBMLImporter::importRule(), importUnitsFromSBMLDocument(), SBMLImporter::parseSBML(), SBMLImporter::preprocessNode(), SBMLImporter::replace_delay_nodes(), SBMLImporter::sbmlId2CopasiCN(), SBMLImporter::setInitialValues(), and setLevelAndVersion().
|
private |
Referenced by checkElementUnits(), and importUnitsFromSBMLDocument().
|
private |
Referenced by checkElementUnits(), and importUnitsFromSBMLDocument().
|
private |
Referenced by checkElementUnits(), and importUnitsFromSBMLDocument().
|
private |
Referenced by checkElementUnits(), and importUnitsFromSBMLDocument().
|
private |
Referenced by checkElementUnits(), and importUnitsFromSBMLDocument().
|
protected |