44 #include "sbml/Species.h"
45 #include "sbml/Parameter.h"
46 #include "sbml/Compartment.h"
55 mChemEq(
"Chemical Equation", this),
58 mpFluxReference(NULL),
60 mpParticleFluxReference(NULL),
62 mpPropensityReference(NULL),
63 mScalingFactor(&mDefaultScalingFactor),
64 mUnitScalingFactor(&mDefaultScalingFactor),
66 mParameters(
"Parameters", this),
80 mChemEq(src.mChemEq, this),
81 mpFunction(src.mpFunction),
83 mpFluxReference(NULL),
84 mParticleFlux(src.mParticleFlux),
85 mpParticleFluxReference(NULL),
86 mPropensity(src.mPropensity),
87 mpPropensityReference(NULL),
88 mScalingFactor(src.mScalingFactor),
89 mUnitScalingFactor(src.mUnitScalingFactor),
91 mMetabKeyMap(src.mMetabKeyMap),
92 mParameters(src.mParameters, this),
121 if (pModel == NULL)
return "";
125 if (Name ==
"ParticleFlux")
127 else if (Name ==
"Flux")
129 else if (Name ==
"Propensity")
154 if ((Fail = configbuffer.
getVariable(
"Step",
"string", &tmp,
162 if ((Fail = configbuffer.
getVariable(
"Equation",
"string", &ChemEq)))
169 if ((Fail = configbuffer.
getVariable(
"KineticType",
"string", &tmp)))
179 if ((Fail = configbuffer.
getVariable(
"Reversible",
"bool", &revers,
305 const bool & updateStatus)
311 if (!updateStatus)
return;
391 const std::vector<std::string> & keys)
453 for (i = 0; i < imax; ++i)
484 if (pObject == NULL ||
489 while (pParent !=
this)
522 for (i = 0, pos = 0; i < imax; ++i)
541 std::vector< std::string > ToBeDeleted;
543 for (; it != end; ++it)
545 name = (*it)->getObjectName();
548 ToBeDeleted.push_back(name);
551 std::vector< std::string >::const_iterator itToBeDeleted = ToBeDeleted.begin();
552 std::vector< std::string >::const_iterator endToBeDeleted = ToBeDeleted.end();
554 for (; itToBeDeleted != endToBeDeleted; ++itToBeDeleted)
567 for (i = 0; i < imax; ++i)
586 std::set< const CCopasiObject * > Dependencies;
610 std::string paramName;
612 for (i = 0; i < imax; ++i)
621 for (j = 0; j < jmax; ++j)
647 for (; it != end; ++it)
653 for (; it != end; ++it)
659 for (; it != end; ++it)
670 const std::string & prefix)
680 std::string name, parName, metabName;
683 assert(pDataModel != NULL);
705 for (i = 0; i < n; i++)
707 name =
StringPrint(std::string(prefix +
"%d").c_str(), i);
724 for (i = 0, pos = 0; i < imax; i++)
726 name =
StringPrint(std::string(prefix +
"%d").c_str(), i);
757 for (i = imax; i < n; i++)
759 name =
StringPrint(std::string(prefix +
"%d").c_str(), i);
769 C_INT32 SubstrateSize, ProductSize, ModifierSize, ParameterSize;
771 configbuffer.
getVariable(
"Substrates",
"C_INT32", &SubstrateSize);
772 configbuffer.
getVariable(
"Products",
"C_INT32", &ProductSize);
773 configbuffer.
getVariable(
"Modifiers",
"C_INT32", &ModifierSize);
774 configbuffer.
getVariable(
"Constants",
"C_INT32", &ParameterSize);
778 SubstrateSize,
"Subs");
781 ProductSize,
"Prod");
784 ModifierSize,
"Modf");
790 != (size_t) ParameterSize)
801 for (i = 0, pos = 0; i < (size_t) ParameterSize; i++)
804 configbuffer.
getVariable(name,
"C_FLOAT64", &value);
856 (store < resolution) ? resolution * (1.0 + derivationFactor) : store;
858 *pXi = tmp * (1.0 + derivationFactor);
861 *pXi = tmp * (1.0 - derivationFactor);
866 return *
mScalingFactor * (f1 - f2) / (2.0 * tmp * derivationFactor);
885 const CMetab *pMetab = NULL;
896 if (pCompartment != NULL)
912 if (mpFunctionCompartment)
961 std::set< const CCopasiObject * > Deleted;
963 Deleted.insert(
this);
971 for (; it != end ; ++it)
974 Deleted.insert((*it)->getValueReference());
983 bool MustBeDeleted =
false;
990 for (; itParameter != endParameter ; ++itParameter)
994 DeletedObjects.erase((*itParameter)->getValueReference());
999 ChildObjects.insert(
this);
1003 DataObjectSet::const_iterator it = ChildObjects.begin();
1004 DataObjectSet::const_iterator end = ChildObjects.end();
1006 for (; it != end; ++it)
1010 if ((*it)->CCopasiObject::mustBeDeleted(DeletedObjects))
1012 MustBeDeleted =
true;
1019 if ((*it)->mustBeDeleted(DeletedObjects))
1021 MustBeDeleted =
true;
1026 return MustBeDeleted;
1032 os <<
" SBML id: " << d.
mSBMLId << std::endl;
1034 os <<
" mChemEq " << std::endl;
1040 os <<
" mpFunction == 0 " << std::endl;
1043 os <<
" mFlux: " << d.
mFlux << std::endl;
1048 os <<
" mScalingFactor == NULL " << std::endl;
1053 os <<
" mUnitScalingFactor == NULL " << std::endl;
1055 os <<
" parameter group:" << std::endl;
1058 os <<
" key map:" << std::endl;
1071 os <<
"----CReaction" << std::endl;
1079 std::string objectCN = objectNode->
getData();
1082 std::vector<CCopasiContainer*> containers = std::vector<CCopasiContainer*>();
1083 containers.push_back(pModel);
1096 std::map<CCopasiObject*, SBase*>::iterator pos = copasi2sbmlmap.find(
object);
1100 if (dynamic_cast<CMetab*>(
object))
1102 Species* pSpecies =
dynamic_cast<Species*
>(pos->second);
1103 id = pSpecies->getId();
1106 const char *Reserved[] =
1108 "pi",
"exponentiale",
"true",
"false",
"infinity",
"nan",
1109 "PI",
"EXPONENTIALE",
"TRUE",
"FALSE",
"INFINITY",
"NAN"
1112 size_t j, jmax = 12;
1114 for (j = 0; j < jmax; j++)
1115 if (
id == Reserved[j])
break;
1118 id =
"\"" +
id +
"\"";
1122 if (replacementMap.find(
id) == replacementMap.end())
1131 for (i = 0; i < v->
size(); ++i)
1133 if (((*v)[i]->getMetabolite()) ==
static_cast<CMetab *
>(object))
1145 for (i = 0; i < v->
size(); ++i)
1147 if (((*v)[i]->getMetabolite()) ==
static_cast<CMetab *
>(object))
1159 for (i = 0; i < v->
size(); ++i)
1161 if (((*v)[i]->getMetabolite()) ==
static_cast<CMetab *
>(object))
1174 if (pSpecies->getLevel() == 1)
1181 delete pVariableNode;
1182 pVariableNode = NULL;
1192 replacementMap[id] = std::make_pair(
object, pFunParam);
1196 else if (dynamic_cast<CModelValue*>(
object))
1199 id =
dynamic_cast<Parameter*
>(pos->second)->getId();
1202 if (replacementMap.find(
id) == replacementMap.end())
1206 replacementMap[id] = std::make_pair(
object, pFunParam);
1209 else if (dynamic_cast<CCompartment*>(
object))
1212 id =
dynamic_cast<Compartment*
>(pos->second)->getId();
1215 if (replacementMap.find(
id) == replacementMap.end())
1219 replacementMap[id] = std::make_pair(
object, pFunParam);
1222 else if (dynamic_cast<CModel*>(
object))
1224 id =
object->getObjectName();
1228 if (replacementMap.find(
id) == replacementMap.end())
1232 replacementMap[id] = std::make_pair(
object, pFunParam);
1235 else if (dynamic_cast<CReaction*>(
object))
1247 else if (dynamic_cast<CCopasiParameter*>(
object))
1249 id =
object->getObjectName();
1253 if (replacementMap.find(
id) == replacementMap.end())
1257 replacementMap[id] = std::make_pair(
object, pFunParam);
1282 return pVariableNode;
1291 while (itNode.
next() != itNode.
end())
1293 if (*itNode == NULL)
1302 pResult =
object2variable(static_cast<const CEvaluationNodeObject * >(*itNode), replacementMap, copasi2sbmlmap);
1333 if (pResult != NULL &&
1350 std::map<std::string, std::pair<CCopasiObject*, CFunctionParameter*> > replacementMap = std::map<std::string , std::pair<CCopasiObject*, CFunctionParameter*> >();
1368 pTmpFunction->
setRoot(pFunctionTree);
1371 pFunctionDB->
add(pTmpFunction,
true);
1374 std::map<std::string, std::pair<CCopasiObject*, CFunctionParameter*> >::iterator it = replacementMap.begin();
1375 std::map<std::string, std::pair<CCopasiObject*, CFunctionParameter*> >::iterator endIt = replacementMap.end();
1387 it = replacementMap.begin();
1392 std::string
id = it->first;
1398 std::string functionName =
"Function for " + this->
getObjectName();
1405 std::string appendix =
"";
1406 unsigned int counter = 0;
1407 std::ostringstream numberStream;
1410 while ((pExistingFunction = pFunctionDB->
findFunction(functionName + appendix)) != NULL)
1429 numberStream.str(
"");
1430 numberStream <<
"_" << counter;
1431 appendix = numberStream.str();
1437 return pTmpFunction;
1512 pChildNode = this->
variables2objects(static_cast<CEvaluationNode*>(pChildNode2));
1562 pTmpNode = this->
variable2object(static_cast<CEvaluationNodeVariable*>(expression));
1617 const std::string paraName =
static_cast<const std::string
>(pVariableNode->
getData());
1662 std::string::size_type idx = s.find(
'\\');
1664 while (idx != std::string::npos)
1666 s.insert(idx,
"\\");
1668 idx = s.find(
'\\', ++idx);
1673 while (idx != std::string::npos)
1675 s.insert(idx,
"\\");
1677 idx = s.find(
'"', ++idx);
1680 if (s.find(
' ') != std::string::npos || s.find(
'\t') != std::string::npos)
1682 s = std::string(
"\"") + s + std::string(
"\"");
Header file of class CExpression.
CCopasiDataModel * getObjectDataModel()
virtual bool setObjectParent(const CCopasiContainer *pParent)
CCopasiParameterGroup mParameters
CCopasiContainer * getObjectAncestor(const std::string &type) const
bool remove(const std::string &key)
size_t getCompartmentNumber() const
void setReversible(bool reversible)
virtual bool setRoot(CEvaluationNode *pRootNode)
CEvaluationNode * copyBranch() const
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
CCopasiObjectReference< C_FLOAT64 > * mpFluxReference
void clearDirectDependencies()
void setRefresh(CType *pType, void(CType::*method)(void))
virtual bool dependsOn(const C_FLOAT64 *parameter, const CCallParameters< C_FLOAT64 > &callParameters) const
void clearCallParameter(const std::string paramName)
static CFunction * getUndefinedFunction()
const CFunctionParameter::DataType & getType() const
CCopasiNode< Data > * getSibling()
CCopasiObject * getParticleFluxReference()
CCopasiObjectReference< C_FLOAT64 > * mpPropensityReference
std::ostream & operator<<(std::ostream &os, const CReaction &d)
CFunction * setFunctionFromExpressionTree(const CExpression &tree, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, CFunctionDB *pFunctionDB)
C_INT32 loadOld(CReadConfig &configbuffer)
const C_FLOAT64 & getParticleFlux() const
static void setChemEqFromString(CModel *model, CReaction &rea, const std::string &ces)
virtual CCopasiObjectName getCN() const
bool addSubstrate(const std::string &metabKey, const C_FLOAT64 &multiplicity=1.0)
const CCopasiVector< CMetab > & getMetabolites() const
const std::string & getObjectName() const
std::string getFrequencyUnitsDisplayString() const
CEvaluationNode * copyNode(CEvaluationNode *child1, CEvaluationNode *child2) const
virtual size_t size() const
virtual std::string getChildObjectUnits(const CCopasiObject *pObject) const
CCopasiObject * get(const std::string &key)
virtual const std::string & getKey() const
const CCopasiMessage & getMessage() const
bool isVector(CFunctionParameter::Role role) const
void setParameterValue(const std::string ¶meterName, const C_FLOAT64 &value, const bool &updateStatus=true)
const Type & getType() const
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
const CFunctionParameters & getFunctionParameters() const
void setDirectDependencies(const DataObjectSet &directDependencies)
std::string getQuantityRateUnitsDisplayString() const
size_t findParameterByName(const std::string &name, CFunctionParameter::DataType &dataType) const
const size_t & getNumber() const
const CCallParameters< C_FLOAT64 > & getCallParameters() const
size_t getNumberOfParametersByUsage(CFunctionParameter::Role usage) const
bool addProduct(const std::string &metabKey, const C_FLOAT64 &multiplicity=1.0)
bool isLocalParameter(const size_t &index) const
C_FLOAT64 calculatePartialDerivative(C_FLOAT64 *pXi, const C_FLOAT64 &derivationFactor, const C_FLOAT64 &resolution)
index_iterator endIndex() const
CEvaluationNode * objects2variables(const CEvaluationNode *expression, std::map< std::string, std::pair< CCopasiObject *, CFunctionParameter * > > &replacementMap, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
const std::string & getObjectType() const
void clearParameterMapping(const std::string ¶meterName)
const C_FLOAT64 & calculateFlux()
bool addVariable(const std::string &name, CFunctionParameter::Role usage=CFunctionParameter::VARIABLE, const CFunctionParameter::DataType &type=CFunctionParameter::FLOAT64)
CCallParameters< C_FLOAT64 > & getPointers()
void setMiriamAnnotation(const std::string &miriamAnnotation, const std::string &newId, const std::string &oldId)
const C_FLOAT64 & getFlux() const
CCopasiObject * getPropensityReference()
CFunction * findLoadFunction(const std::string &functionName)
virtual const CObjectInterface * getObject(const CCopasiObjectName &cn) const
const CNodeIteratorMode::State & next()
void setParameterMappingVector(const std::string ¶meterName, const std::vector< std::string > &keys)
const std::string & getMiriamAnnotation() const
void setReversible(const TriLogic &reversible)
virtual std::set< const CCopasiObject * > getDeletedObjects() const
CEvaluationNodeVariable * object2variable(const CEvaluationNodeObject *objectNode, std::map< std::string, std::pair< CCopasiObject *, CFunctionParameter * > > &replacementMap, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
const C_FLOAT64 * mUnitScalingFactor
const std::string & getSBMLId() const
virtual const std::string & getKey() const
const CCopasiVector< CChemEqElement > & getProducts() const
bool removeParameter(const std::string &name)
static Type type(const Type &type)
const CFunction * getFunction() const
void addDirectDependency(const CCopasiObject *pObject)
CEvaluationNode * variables2objects(CEvaluationNode *expression)
const C_FLOAT64 & getQuantity2NumberFactor() const
virtual bool mustBeDeleted(const DataObjectSet &deletedObjects) const
const CFunctionParameters & getFunctionParameters() const
CReaction(const std::string &name="NoName", const CCopasiContainer *pParent=NULL)
size_t getParameterIndex(const std::string ¶meterName, CFunctionParameter::DataType *pType=NULL) const
size_t findMetabByName(const std::string &Target) const
bool addModifier(const std::string &metabKey, const C_FLOAT64 &multiplicity=1.0)
CFunctionParameterMap mMap
const TriLogic & isReversible() const
virtual const std::string & getKey() const
bool setFunction(const std::string &functionName)
static bool areEqualFunctions(const CFunction *pFun, const CFunction *pFun2)
virtual bool addChild(CCopasiNode< Data > *pChild, CCopasiNode< Data > *pAfter=NULL)
const bool & getReversibility() const
void setSBMLId(const std::string &id)
index_iterator beginIndex() const
C_INT32 load(CReadConfig &configbuffer)
bool setValue(const std::string &name, const CType &value)
const C_FLOAT64 & calculateParticleFlux()
Context * parentContextPtr()
const CFunctionParameter * getParameterByUsage(CFunctionParameter::Role usage, size_t &pos) const
CCopasiParameter * getParameter(const std::string &name)
virtual void * getValuePointer() const
std::string add(const std::string &prefix, CCopasiObject *pObject)
const CCopasiVector< CChemEqElement > & getSubstrates() const
bool isReversible() const
static CFunctionDB * getFunctionList()
virtual const C_FLOAT64 & calcValue(const CCallParameters< C_FLOAT64 > &callParameters)
bool addMetabolite(const std::string &key, const C_FLOAT64 multiplicity, const MetaboliteRole &role)
const bool & isFast() const
virtual const DataObjectSet & getDirectDependencies(const DataObjectSet &context=DataObjectSet()) const
static Type subType(const Type &type)
const C_FLOAT64 * mScalingFactor
static CKeyFactory * getKeyFactory()
const CCopasiVector< CChemEqElement > & getModifiers() const
const CCopasiParameterGroup & getParameters() const
const CCompartment * getLargestCompartment() const
void initializeFromFunctionParameters(const CFunctionParameters &src)
void setParameterMapping(const size_t &index, const std::string &key)
size_t getCompartmentNumber() const
void setCallParameter(const std::string paramName, const CCopasiObject *obj)
void removeDirectDependency(const CCopasiObject *pObject)
std::string StringPrint(const char *format,...)
bool addParameter(const CCopasiParameter ¶meter)
bool loadOneRole(CReadConfig &configbuffer, CFunctionParameter::Role role, C_INT32 n, const std::string &prefix)
The class for handling a chemical kinetic function.
static CCopasiObject * pUnmappedObject
const CCopasiParameter::Value & getValue(const std::string &name) const
C_INT32 getVariable(const std::string &name, const std::string &type, void *pout, CReadConfig::Mode mode=CReadConfig::NEXT)
bool isStaticString() const
void setFast(const bool &fast)
virtual const CObjectInterface * getObject(const CCopasiObjectName &cn) const
virtual const Data & getData() const
std::string escapeId(const std::string &id)
void addCallParameter(const std::string paramName, const CCopasiObject *obj)
CEvaluationNodeObject * variable2object(CEvaluationNodeVariable *pVariableNode)
virtual bool setObjectParent(const CCopasiContainer *pParent)
virtual const Data & getData() const
CNodeIteratorMode::State end() const
std::vector< std::vector< std::string > > mMetabKeyMap
CEvaluationNode * getExpressionTree()
const std::vector< std::vector< std::string > > & getParameterMappings() const
static C_FLOAT64 mDefaultScalingFactor
virtual const CCopasiObject * getValueObject() const
void initializeParameters()
CCopasiNode< Data > * getChild()
const CCompartment * getLargestCompartment() const
bool setObjectName(const std::string &name)
parameterGroup::iterator index_iterator
std::set< const CCopasiObject * > DataObjectSet
CCopasiVectorS< CMetabOld > * pOldMetabolites
CFunction * findFunction(const std::string &functionName)
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CCopasiObject * addObjectReference(const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
void setReversibility(const bool &reversible)
CCopasiObjectReference< C_FLOAT64 > * mpParticleFluxReference
const CChemEq & getChemEq() const
size_t findParameterByName(const std::string &name, CFunctionParameter::DataType &dataType) const
CEvaluationNode * getRoot()
const C_FLOAT64 & getParameterValue(const std::string ¶meterName) const
CFunctionParameters & getVariables()
CCopasiContainer * getObjectParent() const
void addParameterMapping(const size_t &index, const std::string &key)
void initializeMetaboliteKeyMap()
virtual const std::string & getKey() const
#define CONSTRUCTOR_TRACE
const std::vector< std::string > & getParameterMapping(const size_t &index) const
CCopasiObject * getFluxReference()
bool add(CFunction *pFunction, const bool &adopt)
CCopasiObject * getValueReference() const