COPASI API  4.40.278
CReactionInterface Class Reference

#include <CReactionInterface.h>

Public Member Functions

void clearChemEquation ()
 
 CReactionInterface ()
 
bool createMetabolites ()
 
bool createMetabolites (std::vector< std::string > &createdKeys)
 
bool createOtherObjects () const
 
bool createOtherObjects (std::vector< std::string > &createdKeys) const
 createOtherObjects More...
 
CUndoData createUndoData (const CCore::Framework &framework) const
 
std::string getAmountRateUnit () const
 
const CChemEqInterfacegetChemEqInterface () const
 
std::string getChemEqString () const
 
std::string getConcentrationRateUnit () const
 
std::string getDefaultScalingCompartment () const
 
std::set< const CDataObject * > getDeletedParameters () const
 
std::string getEffectiveKineticLawUnit () const
 
CReaction::KineticLawUnit getEffectiveKineticLawUnitType () const
 
const CFunctiongetFunction () const
 
std::string getFunctionDescription () const
 
std::string getFunctionName () const
 
const CReaction::KineticLawUnitgetKineticLawUnitType () const
 
const std::vector< std::string > & getListOfMetabs (CFunctionParameter::Role role) const
 
std::vector< std::string > getListOfPossibleFunctions () const
 
const C_FLOAT64getLocalValue (size_t index) const
 
const std::string & getMapping (size_t index) const
 
const std::vector< std::string > & getMappings (size_t index) const
 
const std::string & getNoiseExpression () const
 
std::string getParameterName (size_t index) const
 
const std::string & getScalingCompartment () const
 
std::string getUnit (size_t index) const
 
std::vector< std::string > getUnitVector (size_t index) const
 
CFunctionParameter::Role getUsage (size_t index) const
 
const bool & hasNoise () const
 
void init (const CReaction &reaction)
 
bool isLocalValue (size_t index) const
 
bool isLocked (CFunctionParameter::Role usage) const
 
bool isLocked (size_t index) const
 
bool isMulticompartment () const
 
bool isReversible () const
 
bool isValid () const
 
bool isVector (size_t index) const
 
void reverse (bool rev, const std::string &newFunction)
 
void setChemEqString (const std::string &eq, const std::string &newFunction)
 
void setFunctionAndDoMapping (const std::string &fn)
 
void setFunctionWithEmptyMapping (const std::string &fn)
 
void setHasNoise (const bool &hasNoise)
 
void setKineticLawUnitType (const CReaction::KineticLawUnit &kineticLawUnitType)
 
void setLocal (size_t index)
 
void setLocalValue (size_t index, C_FLOAT64 value)
 
void setMapping (size_t index, std::string mn)
 
bool setNoiseExpression (const std::string &expression)
 
void setReversibility (bool rev, const std::string &newFunction)
 
void setScalingCompartment (const std::string &scalingCompartment)
 
size_t size () const
 
bool writeBackToReaction (CReaction *rea=NULL, bool compile=true)
 
 ~CReactionInterface ()
 

Private Member Functions

void connectFromScratch (CFunctionParameter::Role role)
 
void connectNonMetabolites ()
 
void copyMapping ()
 
void findAndSetFunction (const std::string &newFunction)
 
std::vector< std::string > getExpandedMetabList (CFunctionParameter::Role role) const
 
void initMapping ()
 
bool loadMappingAndValues ()
 
void updateModifiersInChemEq ()
 

Private Attributes

CChemEqInterface mChemEqI
 
bool mHasNoise
 
std::vector< std::vector< std::string > * > mIndexMap
 
std::vector< bool > mIsLocal
 
CReaction::KineticLawUnit mKineticLawUnitType
 
CCopasiParameterGroup mLocalParameters
 
CFunction mMassAction
 
std::map< std::string, std::vector< std::string > > mNameMap
 
std::string mNoiseExpression
 
const CFunctionmpFunction
 
const CFunctionParametersmpFunctionParameters
 
const CModelmpModel
 
const CReactionmpReaction
 
std::string mScalingCompartment
 
std::vector< C_FLOAT64mValues
 

Detailed Description

This class provides an interface for dealing with reactions. For representing the parameter mappings it uses object names. A CReactionInterface allows editing a reaction while trying to keep everything consistent.

Note: Many of the methods need to be provided with a model. While handling of the metabolites is completely independent of the model (they are handled by name, and they don't need to exist), the mapping of Compartments and global parameters is done with the entities that exist in the model. This may seem inconsistent, but the idea is that metabolites can be created from the gui by entering them into the reaction equation. Compartments and global parameters can only be chosen from the list of existing objects.

Constructor & Destructor Documentation

◆ CReactionInterface()

CReactionInterface::CReactionInterface ( )

◆ ~CReactionInterface()

CReactionInterface::~CReactionInterface ( )

Member Function Documentation

◆ clearChemEquation()

void CReactionInterface::clearChemEquation ( )

internal function that temporarily removes the equation

References CChemEqInterface::clearAll(), mChemEqI, and setFunctionWithEmptyMapping().

◆ connectFromScratch()

◆ connectNonMetabolites()

◆ copyMapping()

void CReactionInterface::copyMapping ( )
private

create new mapping, try to keep as much information from the current mapping. Calls initMapping().

References CFunctionParameters::findParameterByName(), getParameterName(), getUsage(), initMapping(), isVector(), mIsLocal, mNameMap, mpFunctionParameters, mValues, size(), and CFunctionParameter::VFLOAT64.

Referenced by setFunctionAndDoMapping().

◆ createMetabolites() [1/2]

bool CReactionInterface::createMetabolites ( )

create all metabolites that are needed by the reaction but do not exist in the model yet.

Referenced by CReaction::setReactionScheme().

◆ createMetabolites() [2/2]

bool CReactionInterface::createMetabolites ( std::vector< std::string > &  createdKeys)

create all metabolites that are needed by the reaction but do not exist in the model yet.

Parameters
createdKeysvector, that will be filled with the keys of created elements
Returns
true in case elements were created, false otherwise

References CChemEqInterface::createNonExistingMetabs(), getFunctionName(), mChemEqI, and setFunctionAndDoMapping().

◆ createOtherObjects() [1/2]

bool CReactionInterface::createOtherObjects ( ) const

create all other objects that are needed by the reaction but do not exist in the model yet.

Referenced by CReaction::setReactionScheme().

◆ createOtherObjects() [2/2]

bool CReactionInterface::createOtherObjects ( std::vector< std::string > &  createdKeys) const

createOtherObjects

Parameters
createdKeysvector that will be filled with created keys
Returns
true, in case elements were created, false otherwise

References CModel::createCompartment(), CModel::createModelValue(), CModelEntity::getKey(), getUsage(), CDataContainer::insert(), isLocalValue(), mIndexMap, mpModel, CFunctionParameter::PARAMETER, size(), and CFunctionParameter::VOLUME.

◆ createUndoData()

CUndoData CReactionInterface::createUndoData ( const CCore::Framework framework) const

Create the undo data which represents the changes recording the differences between the provided oldData and the current data.

Parameters
constCCore::Framework & framework
Returns
CUndoData undoData

References CData::ADD_NOISE, CCopasiParameterGroup::addParameter(), CUndoData::addPreProcessData(), CUndoData::addProperty(), CData::addProperty(), C_FLOAT64, C_INVALID_INDEX, CUndoData::CHANGE, CData::CHEMICAL_EQUATION, CCore::Concentration, CChemEqInterface::displayNameToNamePair(), CCopasiParameter::DOUBLE, CCommonName::escape(), CDataObject::getCN(), CCopasiParameter::getCN(), CModel::getCompartments(), CDataVector< CType >::getIndex(), CDataVectorN< CType >::getIndex(), CModel::getMetabolites(), CModel::getMetabolitesX(), CModel::getModelValues(), CModel::getNumber2QuantityFactor(), CDataObject::getObjectName(), CCopasiParameterGroup::getParameter(), getParameterName(), CReaction::getParameters(), CData::getProperty(), CModel::getQuantity2NumberFactor(), getUsage(), CUndoData::INSERT, CData::KINETIC_LAW, CData::KINETIC_LAW_UNIT_TYPE, CData::KINETIC_LAW_VARIABLE_MAPPING, CReaction::KineticLawUnitTypeName, CChemEqInterface::listOfNonExistingMetabNames(), CData::LOCAL_REACTION_PARAMETERS, mChemEqI, mHasNoise, mIndexMap, mIsLocal, mKineticLawUnitType, mNoiseExpression, CFunctionParameter::MODIFIER, mpFunction, mpModel, mpReaction, mScalingCompartment, mValues, CData::NOISE_EXPRESSION, CData::OBJECT_NAME, CData::OBJECT_PARENT_CN, CData::OBJECT_REFERENCE_CN, CData::OBJECT_REFERENCE_INDEX, CData::OBJECT_REFERENCES, CFunctionParameter::PARAMETER, CData::PARAMETER_VALUE, CCore::ParticleNumbers, CFunctionParameter::PRODUCT, CData::SCALING_COMPARTMENT, CMetab::setInitialConcentration(), CModelEntity::setInitialValue(), size(), CFunctionParameter::SUBSTRATE, CFunctionParameter::TIME, CReaction::toData(), CCopasiParameter::toData(), CChemEqInterface::toDataValue(), CDataValue::toDataVector(), and CFunctionParameter::VOLUME.

◆ findAndSetFunction()

void CReactionInterface::findAndSetFunction ( const std::string &  newFunction)
private

checks if newFunction is an valid function for the reaction. If it is not or if newFunction="" another function is chosen.

References C_FLOAT64, fl(), getFunctionName(), CChemEqInterface::getListOfDisplayNames(), getListOfPossibleFunctions(), getLocalValue(), CChemEqInterface::getReversibility(), mChemEqI, CFunctionParameter::PRODUCT, setFunctionAndDoMapping(), and setLocalValue().

Referenced by reverse(), setChemEqString(), and setReversibility().

◆ getAmountRateUnit()

std::string CReactionInterface::getAmountRateUnit ( ) const
Returns
the amount rate unit display name

References CModel::getQuantityUnit(), CModel::getTimeUnit(), and mpModel.

Referenced by getEffectiveKineticLawUnit().

◆ getChemEqInterface()

const CChemEqInterface & CReactionInterface::getChemEqInterface ( ) const

References mChemEqI.

◆ getChemEqString()

std::string CReactionInterface::getChemEqString ( ) const

◆ getConcentrationRateUnit()

std::string CReactionInterface::getConcentrationRateUnit ( ) const

◆ getDefaultScalingCompartment()

std::string CReactionInterface::getDefaultScalingCompartment ( ) const

◆ getDeletedParameters()

std::set< const CDataObject * > CReactionInterface::getDeletedParameters ( ) const

◆ getEffectiveKineticLawUnit()

std::string CReactionInterface::getEffectiveKineticLawUnit ( ) const

◆ getEffectiveKineticLawUnitType()

CReaction::KineticLawUnit CReactionInterface::getEffectiveKineticLawUnitType ( ) const
Returns
the effective unit type in case the default is selected

References CReaction::AmountPerTime, CReaction::ConcentrationPerTime, CReaction::Default, isMulticompartment(), and mKineticLawUnitType.

Referenced by getEffectiveKineticLawUnit().

◆ getExpandedMetabList()

std::vector< std::string > CReactionInterface::getExpandedMetabList ( CFunctionParameter::Role  role) const
private

returns a list of metabolites (from the chemical equation). Species can occur several times according to the multiplicity

References C_FLOAT64, CChemEqInterface::getListOfDisplayNames(), CChemEqInterface::getListOfMultiplicities(), mChemEqI, and CFunctionParameter::MODIFIER.

Referenced by connectFromScratch().

◆ getFunction()

◆ getFunctionDescription()

std::string CReactionInterface::getFunctionDescription ( ) const
Returns
the function description

References CEvaluationTree::getInfix(), and mpFunction.

◆ getFunctionName()

std::string CReactionInterface::getFunctionName ( ) const
Returns
the function name

References CDataObject::getObjectName(), and mpFunction.

Referenced by createMetabolites(), and findAndSetFunction().

◆ getKineticLawUnitType()

const CReaction::KineticLawUnit & CReactionInterface::getKineticLawUnitType ( ) const
Returns
the currently set unit type

References mKineticLawUnitType.

◆ getListOfMetabs()

const std::vector< std::string > & CReactionInterface::getListOfMetabs ( CFunctionParameter::Role  role) const

This produces a list of metabolite names (from the chem eq) for use in the combo boxes. The role must be given like a usage, e.g. "SUBSTRATE".

References CChemEqInterface::getListOfDisplayNames(), and mChemEqI.

Referenced by setMapping().

◆ getListOfPossibleFunctions()

std::vector< std::string > CReactionInterface::getListOfPossibleFunctions ( ) const
Returns
a vector of possible functions for the specified number substrates / products and reversibility

References CRootContainer::getFunctionList(), CChemEqInterface::getMolecularity(), isReversible(), mChemEqI, CFunctionParameter::PRODUCT, CFunctionParameter::SUBSTRATE, CFunctionDB::suitableFunctions(), TriFalse, and TriTrue.

Referenced by findAndSetFunction().

◆ getLocalValue()

const double & CReactionInterface::getLocalValue ( size_t  index) const

Return the local parameter value of the parameter with given index

Parameters
indexthe index of the parameter
Returns
the value of the parameter with given index

References mValues.

Referenced by findAndSetFunction().

◆ getMapping()

const std::string & CReactionInterface::getMapping ( size_t  index) const

return the first mapping for the given index

Parameters
indexthe index
Returns
the first mapping for the given index

References mIndexMap.

Referenced by updateModifiersInChemEq().

◆ getMappings()

const std::vector< std::string > & CReactionInterface::getMappings ( size_t  index) const

returns all mappings for the given index

Parameters
indexthe index
Returns
the string vector of all mappings for the given index

References mIndexMap.

◆ getNoiseExpression()

const std::string & CReactionInterface::getNoiseExpression ( ) const

Retrieve the expression for non FIXED model values.

Returns
const std::string & expression

References mNoiseExpression.

◆ getParameterName()

std::string CReactionInterface::getParameterName ( size_t  index) const

Returns the name of the parameter with given index

Parameters
indexthe index
Returns
the name of the parameter if found, or an empty string

References mpFunctionParameters, and size().

Referenced by connectNonMetabolites(), copyMapping(), createUndoData(), getDeletedParameters(), initMapping(), loadMappingAndValues(), setMapping(), and writeBackToReaction().

◆ getScalingCompartment()

const std::string & CReactionInterface::getScalingCompartment ( ) const
Returns
the specified scaling compartment

References mScalingCompartment.

◆ getUnit()

◆ getUnitVector()

◆ getUsage()

CFunctionParameter::Role CReactionInterface::getUsage ( size_t  index) const

returns the function parameter role for the parameter with given index

Parameters
indexthe index
Returns
the role of that function parameter

References mpFunctionParameters, size(), and CFunctionParameter::VARIABLE.

Referenced by connectNonMetabolites(), copyMapping(), createOtherObjects(), createUndoData(), getUnit(), getUnitVector(), initMapping(), isLocked(), loadMappingAndValues(), setMapping(), updateModifiersInChemEq(), and writeBackToReaction().

◆ hasNoise()

const bool & CReactionInterface::hasNoise ( ) const

Check whether noise is added to the reaction rate

Returns
const bool & hasNoise

References mHasNoise.

Referenced by setHasNoise().

◆ init()

◆ initMapping()

void CReactionInterface::initMapping ( )
private

initialize mapping (resize vectors and set names to "unknown"). Also initializes mpParameters but doesn't delete the old mpParameters.

References getParameterName(), getUsage(), CFunction::getVariables(), isVector(), mIndexMap, mIsLocal, mNameMap, mpFunction, mpFunctionParameters, mValues, CFunctionParameter::PARAMETER, and size().

Referenced by copyMapping(), init(), and setFunctionWithEmptyMapping().

◆ isLocalValue()

bool CReactionInterface::isLocalValue ( size_t  index) const

tests whether the parameter with given index is a local parameter

Parameters
indexthe index
Returns
true, if the parameter with given index is local, false otherwise

References mIsLocal.

Referenced by connectNonMetabolites(), createOtherObjects(), and getUnit().

◆ isLocked() [1/2]

bool CReactionInterface::isLocked ( CFunctionParameter::Role  usage) const

Is the mapping of this parameter locked? The behavior of this method is different for different roles: SUBSTRATE, PRODUCT: according to the chemical equation MODIFIER: always unlocked TIME: always locked VOLUME, PARAMETER: according to the model

The idea is that in the reaction GUI new species can be entered in the chemical equation that are then created automatically. Compartments and global parameters can only be chosen from those existing in the model.

Parameters
usagethe usage of the parameter
Returns
boolean indicating whether the parameter with given usage should be locked

References CModel::getCompartments(), CChemEqInterface::getListOfDisplayNames(), CModel::getModelValues(), CFunctionParameters::getNumberOfParametersByUsage(), CFunctionParameters::getParameterByUsage(), isVector(), mChemEqI, CFunctionParameter::MODIFIER, mpFunctionParameters, mpModel, CFunctionParameter::PARAMETER, CFunctionParameter::PRODUCT, CDataVector< CType >::size(), CFunctionParameter::SUBSTRATE, CFunctionParameter::TIME, and CFunctionParameter::VOLUME.

◆ isLocked() [2/2]

bool CReactionInterface::isLocked ( size_t  index) const

Is the mapping of this parameter locked? The behavior of this method is different for different roles: SUBSTRATE, PRODUCT: according to the chemical equation MODIFIER: always unlocked TIME: always locked VOLUME, PARAMETER: according to the model

The idea is that in the reaction GUI new species can be entered in the chemical equation that are then created automatically. Compartments and global parameters can only be chosen from those existing in the model.

Parameters
indexthe index of the parameter
Returns
boolean indicating whether the parameter is locked or not

References getUsage().

◆ isMulticompartment()

bool CReactionInterface::isMulticompartment ( ) const

this method tries to find out if the REACTION involves several compartments It only takes into account the metabolites that actually exist in the model. A non existing metabolite is assumed not to be in a different compartment

References CChemEqInterface::isMulticompartment(), and mChemEqI.

Referenced by getEffectiveKineticLawUnitType().

◆ isReversible()

bool CReactionInterface::isReversible ( ) const

◆ isValid()

bool CReactionInterface::isValid ( ) const
Returns
boolean indicating whether this reaction is valid

References mIndexMap, mIsLocal, and size().

Referenced by writeBackToReaction().

◆ isVector()

bool CReactionInterface::isVector ( size_t  index) const

Tests whether the parameter at the given index is of type vector

Parameters
indexthe index
Returns
true, if the function parameter at the given index is a vector false otherwise

References mpFunctionParameters, size(), and CFunctionParameter::VFLOAT64.

Referenced by copyMapping(), getUnit(), initMapping(), isLocked(), loadMappingAndValues(), and setMapping().

◆ loadMappingAndValues()

◆ reverse()

void CReactionInterface::reverse ( bool  rev,
const std::string &  newFunction 
)

reverse the reaction and set the reversibility. newFunction suggests a new kinetic function which is only used if adequate.

References findAndSetFunction(), mChemEqI, CChemEqInterface::reverse(), and CChemEqInterface::setReversibility().

◆ setChemEqString()

void CReactionInterface::setChemEqString ( const std::string &  eq,
const std::string &  newFunction 
)

set a new chemical equation. newFunction suggests a new kinetic function which is only used if adequate.

References findAndSetFunction(), mChemEqI, and CChemEqInterface::setChemEqString().

Referenced by CReaction::setReactionScheme().

◆ setFunctionAndDoMapping()

void CReactionInterface::setFunctionAndDoMapping ( const std::string &  fn)

set the function. a new mapping is created that tries to preserve as much information as possible from the old mapping. Then a default mapping is set from the chemical equation and the model (if possible).

References connectFromScratch(), connectNonMetabolites(), copyMapping(), CFunctionDB::findLoadFunction(), CRootContainer::getFunctionList(), CRootContainer::getUndefinedFunction(), CFunctionParameter::MODIFIER, mpFunction, CFunctionParameter::PRODUCT, and CFunctionParameter::SUBSTRATE.

Referenced by CReaction::compile(), createMetabolites(), findAndSetFunction(), and init().

◆ setFunctionWithEmptyMapping()

void CReactionInterface::setFunctionWithEmptyMapping ( const std::string &  fn)

◆ setHasNoise()

void CReactionInterface::setHasNoise ( const bool &  hasNoise)

Set whether to add noise to the reaction rate

Parameters
constbool & hasNoise

References CReaction::getDefaultNoiseExpression(), hasNoise(), mHasNoise, mNoiseExpression, and mpReaction.

◆ setKineticLawUnitType()

void CReactionInterface::setKineticLawUnitType ( const CReaction::KineticLawUnit kineticLawUnitType)

Sets the kinetic law unit type

Parameters
kineticLawUnitTypethe type to set

References mKineticLawUnitType.

◆ setLocal()

void CReactionInterface::setLocal ( size_t  index)

Specified that the parameter with given index should be a local parameter

Parameters
indexthe index

References mIsLocal.

◆ setLocalValue()

void CReactionInterface::setLocalValue ( size_t  index,
C_FLOAT64  value 
)

Specifies that the parameter with given index should be a local parameter and specifies the value

Parameters
indexthe index of the parameter
valuethe new value of the parameter

References mIsLocal, and mValues.

Referenced by findAndSetFunction().

◆ setMapping()

◆ setNoiseExpression()

bool CReactionInterface::setNoiseExpression ( const std::string &  expression)

Set the expression for non FIXED model values

Parameters
conststd::string & expression
Returns
bool success

References mNoiseExpression.

◆ setReversibility()

void CReactionInterface::setReversibility ( bool  rev,
const std::string &  newFunction 
)

set the reversibility. newFunction suggests a new kinetic function which is only used if adequate.

References findAndSetFunction(), mChemEqI, and CChemEqInterface::setReversibility().

◆ setScalingCompartment()

void CReactionInterface::setScalingCompartment ( const std::string &  scalingCompartment)

Sets the scaling compartment to be used for this reaction

Parameters
scalingCompartment

References mScalingCompartment.

◆ size()

◆ updateModifiersInChemEq()

void CReactionInterface::updateModifiersInChemEq ( )
private

updates the modifiers in the chemical equation according to the parameter mapping

References CChemEqInterface::addModifier(), CChemEqInterface::clearModifiers(), getMapping(), getUsage(), mChemEqI, CFunctionParameter::MODIFIER, and size().

Referenced by setMapping().

◆ writeBackToReaction()

Member Data Documentation

◆ mChemEqI

◆ mHasNoise

bool CReactionInterface::mHasNoise
private

◆ mIndexMap

std::vector< std::vector< std::string > * > CReactionInterface::mIndexMap
private

◆ mIsLocal

std::vector<bool> CReactionInterface::mIsLocal
private

◆ mKineticLawUnitType

◆ mLocalParameters

CCopasiParameterGroup CReactionInterface::mLocalParameters
private

Referenced by init().

◆ mMassAction

CFunction CReactionInterface::mMassAction
mutableprivate

Referenced by getFunction().

◆ mNameMap

std::map< std::string, std::vector< std::string > > CReactionInterface::mNameMap
private

what metabolite for what function parameter

Referenced by connectFromScratch(), copyMapping(), initMapping(), loadMappingAndValues(), and setMapping().

◆ mNoiseExpression

std::string CReactionInterface::mNoiseExpression
private

◆ mpFunction

const CFunction* CReactionInterface::mpFunction
private

◆ mpFunctionParameters

const CFunctionParameters* CReactionInterface::mpFunctionParameters
private

◆ mpModel

◆ mpReaction

const CReaction* CReactionInterface::mpReaction
private

◆ mScalingCompartment

std::string CReactionInterface::mScalingCompartment
private

◆ mValues

std::vector< C_FLOAT64 > CReactionInterface::mValues
private

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