COPASI API  4.40.278
SBMLUnitSupport Class Reference

#include <SBMLUnitSupport.h>

Inheritance diagram for SBMLUnitSupport:
[legend]

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 SUnitInfoimportUnit (const std::string unitId, const Model *pSBMLModel)
 
const SUnitInfoimportUnit (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, SUnitInfomImportedUnits
 
const SUnitInfompAreaUnit = nullptr
 
const SUnitInfompLengthUnit = nullptr
 
const SUnitInfompSubstanceUnit = nullptr
 
const SUnitInfompTimeUnit = nullptr
 
const SUnitInfompVolumeUnit = nullptr
 

Member Enumeration Documentation

◆ UnitType

Enumerator
dimensionless 
substance 
time 
volume 
area 
length 
other 
__SIZE 

Constructor & Destructor Documentation

◆ ~SBMLUnitSupport()

SBMLUnitSupport::~SBMLUnitSupport ( )

References mImportedUnits, and pdelete.

Member Function Documentation

◆ areSBMLUnitDefinitionsIdentical()

bool SBMLUnitSupport::areSBMLUnitDefinitionsIdentical ( const SUnitInfo unitInfo1,
const SUnitInfo unitInfo2 
)
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().

◆ checkElementUnits()

◆ checkForSpatialSizeUnits()

void SBMLUnitSupport::checkForSpatialSizeUnits ( const CDataModel dataModel,
std::vector< SBMLIncompatibility > &  result 
)
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().

◆ createUnitExpressionFor()

◆ importUnit() [1/2]

const SBMLUnitSupport::SUnitInfo & SBMLUnitSupport::importUnit ( const std::string  unitId,
const Model *  pSBMLModel 
)

◆ importUnit() [2/2]

◆ importUnitsFromSBMLDocument()

◆ setLevelAndVersion()

void SBMLUnitSupport::setLevelAndVersion ( int  level,
int  version 
)

References mLevel, and mVersion.

Referenced by checkForSpatialSizeUnits().

◆ unitKindToString()

std::string SBMLUnitSupport::unitKindToString ( UnitKind_t  kind)
static

◆ validateUnit()

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;

Parameters
SUnitInfo& unitInfo
conststd::string & constraint
Returns
std::string copasiUnitExpression

References createUnitExpressionFor(), SBMLUnitSupport::SUnitInfo::expression, CUnit::isDimensionless(), and CUnit::isEquivalent().

Referenced by importUnit().

Member Data Documentation

◆ mAvogadroSet

bool SBMLUnitSupport::mAvogadroSet = false
protected

◆ mImportedUnits

std::map< std::string, SUnitInfo > SBMLUnitSupport::mImportedUnits
private

Referenced by importUnit(), and ~SBMLUnitSupport().

◆ mLevel

◆ mpAreaUnit

const SUnitInfo* SBMLUnitSupport::mpAreaUnit = nullptr
private

◆ mpLengthUnit

const SUnitInfo* SBMLUnitSupport::mpLengthUnit = nullptr
private

◆ mpSubstanceUnit

const SUnitInfo* SBMLUnitSupport::mpSubstanceUnit = nullptr
private

◆ mpTimeUnit

const SUnitInfo* SBMLUnitSupport::mpTimeUnit = nullptr
private

◆ mpVolumeUnit

const SUnitInfo* SBMLUnitSupport::mpVolumeUnit = nullptr
private

◆ mVersion

unsigned int SBMLUnitSupport::mVersion = 0
protected

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