56 : mExportedFunctions()
72 if (pNode == NULL)
return;
77 while (treeIt != NULL)
100 for (i = 0; i < size; ++i)
116 for (i = 0; i < size; ++i)
132 for (i = 0; i < size; ++i)
204 for (i = 0; i < imax; ++i)
223 CCopasiContainer::objectMap::const_iterator it = container->
getObjects().begin();
225 for (; it != container->
getObjects().end(); ++it)
230 if (it->second->getObjectParent() != container)
continue;
232 if (it->second->getRefresh() == ref)
241 if (it->second->getObjectName() ==
"Name")
continue;
243 if (it->second->getObjectType() ==
"Function")
continue;
258 if (obj == NULL || pDataModel == NULL)
268 if (typeString ==
"Metabolite" || typeString ==
"ModelValue" || typeString ==
"Compartment")
270 if (name ==
"Concentration" || name ==
"Value"
271 || name ==
"Volume" || name ==
"Rate"
272 || name ==
"ParticleNumberRate")
293 if (obj == NULL || pDataModel == NULL)
308 std::ostringstream comments;
309 std::ostringstream expression;
357 str1 = expression.str();
358 str2 = comments.str();
361 metab =
dynamic_cast< CMetab *
>(tmp);
365 std::ostringstream convert;
368 str1 += convert.str();
391 str2 = comments.str();
394 metab =
dynamic_cast< CMetab *
>(tmp);
398 std::ostringstream convert;
401 str1 += convert.str();
426 std::ostringstream result;
427 const std::vector<CEvaluationNode*>& objectNodes = pExpression->
getNodeList();
428 size_t j, jMax = objectNodes.size();
429 assert(pDataModel != NULL);
431 for (j = 0; j < jMax; ++j)
437 std::vector<CCopasiContainer*> containers;
438 containers.push_back(const_cast<CCopasiDataModel*>(pDataModel)->getModel());
445 assert(pObjectParent);
448 if (typeString ==
"Compartment")
457 else if (typeString ==
"Metabolite")
466 result << std::endl <<
getSingleLineComment() <<
"WARNING : reference to property other than transient concentration, initial concentration or concentrations rate for metabolite \"" << pObjectParent->
getObjectName() <<
"\" in expression for \"" << tmp->
getObjectType() <<
"\" \"" << tmp->
getObjectName() <<
"\".";
470 metab =
dynamic_cast< CMetab *
>(pObjectParent);
478 else if (typeString ==
"ModelValue")
485 result << std::endl <<
getSingleLineComment() <<
"WARNING : reference to property other than transient value, initial value or rate for \"" << typeString <<
"\" \"" << pObjectParent->
getObjectName() <<
"\" in expression for \"" << tmp->
getObjectType() <<
"\" \"" << tmp->
getObjectName() <<
"\".";
488 else if (typeString ==
"Model")
497 else if (typeString ==
"Parameter")
506 else if (typeString ==
"Reaction")
515 result << std::endl <<
getSingleLineComment() <<
"WARNING : expression for \"" << tmp->
getObjectType() <<
"\" \"" << tmp->
getObjectName() <<
"\" contains reference to a value in object \"" << pObjectParent->
getObjectName() <<
"\" of type \"" << typeString <<
"\" which is not supported in this ODE exporter Version.";
530 for (
size_t i = 0; i < reacs.
size(); ++i)
532 if (reacs[i] == react)
545 for (; it != vals.
end(); ++it)
547 std::map< std::string, std::string >::const_iterator key = map.find((*it)->getKey());
549 if ((*it)->getInitialValue() == val && key != map.end())
553 std::ostringstream str;
564 tmpExpression =
new CExpression(*pExpression, pDataModel);
565 assert(pDataModel != NULL);
567 const std::vector<CEvaluationNode*>& objectNodes = tmpExpression->
getNodeList();
568 size_t j, jMax = objectNodes.size();
570 for (j = 0; j < jMax; ++j)
592 if (objectType ==
"Model")
594 if (objectName ==
"Time")
597 if (objectName ==
"Avogadro Constant")
599 std::ostringstream value;
601 objectNodes[j]->setData(value.str());
604 if (objectName ==
"Initial Time")
612 std::ostringstream value;
614 objectNodes[j]->setData(value.str());
617 else if (objectType ==
"ModelValue")
619 if (objectName ==
"Value") objectNodes[j]->setData(
NameMap[pObject->
getKey()]);
621 if (objectName ==
"InitialValue")
624 modval =
dynamic_cast<const CModelValue *
>(pObject);
625 std::ostringstream value;
627 objectNodes[j]->setData(value.str());
630 if (objectName ==
"Rate")
633 modval =
dynamic_cast<const CModelValue *
>(pObject);
640 std::ostringstream odeKey;
641 odeKey <<
"ode_" << modval->
getKey();
642 objectNodes[j]->setData(
NameMap[odeKey.str()]);
646 std::ostringstream str1;
648 objectNodes[j]->setData(str1.str());
653 else if (objectType ==
"Metabolite")
655 if (objectName ==
"Concentration")
658 if (objectName ==
"ParticleNumber")
660 std::ostringstream str;
664 objectNodes[j]->setData(str.str());
667 if (objectName ==
"InitialConcentration")
670 metab =
dynamic_cast<const CMetab *
>(pObject);
671 std::ostringstream value;
673 objectNodes[j]->setData(value.str());
676 if (objectName ==
"Rate")
679 metab =
dynamic_cast<const CMetab *
>(pObject);
685 std::ostringstream odeKey;
686 odeKey <<
"ode_" << metab->
getKey();
687 objectNodes[j]->setData(
NameMap[odeKey.str()]);
691 std::ostringstream str1;
693 objectNodes[j]->setData(str1.str());
698 else if (objectType ==
"Compartment")
700 if (objectName ==
"Volume")
703 if (objectName ==
"InitialVolume")
707 std::ostringstream value;
709 objectNodes[j]->setData(value.str());
712 if (objectName ==
"Rate")
723 std::ostringstream odeKey;
724 odeKey <<
"ode_" << comp->
getKey();
725 objectNodes[j]->setData(
NameMap[odeKey.str()]);
729 std::ostringstream str1;
731 objectNodes[j]->setData(str1.str());
736 else if (objectType ==
"Parameter")
738 if (objectName ==
"Value")
741 else if (objectType ==
"Reaction")
743 if (objectName ==
"Flux")
753 objectNodes[j]->setData(
"0");
762 std::ostringstream jequation;
764 for (
size_t j1 = 0; j1 < indep_size; ++j1)
766 if (fabs(redStoi[j1][index]) > 0.0)
772 objectNodes[j]->setData(jequation.str());
794 size_t metabs_size = metabs.
size();
796 for (i = 0; i < metabs_size; i++)
798 CMetab * metab = metabs[i];
805 std::ostringstream smKey;
806 smKey <<
"sm_" << metab->
getKey();
814 std::ostringstream odeKey;
815 odeKey <<
"ode_" << metab->
getKey();
824 for (i = 0; i < comps_size; i++)
832 std::ostringstream odeKey;
833 odeKey <<
"ode_" << comp->
getKey();
841 for (i = 0; i < modvals_size; i++)
849 std::ostringstream odeKey;
850 odeKey <<
"ode_" << modval->
getKey();
859 for (i = 0; i < reacs_size; ++i)
863 params_size = reacs[i]->getParameters().
size();
865 for (j = 0; j < params_size; ++j)
867 if (reacs[i]->isLocalParameter(j))
869 NameMap[reacs[i]->getParameters().getParameter(j)->
getKey()] =
884 std::stringstream str; str << number;
895 size_t metabs_size = metabs.
size();
898 size_t conservedTotals = 0;
902 for (i = 0; i < metabs_size; i++)
909 std::ostringstream expression;
910 std::ostringstream comments;
957 std::ostringstream tmp;
958 std::ostringstream more;
960 double eps = std::numeric_limits<double>::epsilon();
965 for (j = 0; j < indep_size; j++)
968 if (fabs(L(i - ode_size, j)) > eps)
971 if (L(i - ode_size, j) < 0.0)
980 if (fabs(fabs(L(i - ode_size, j)) - 1.0) > eps)
982 tmp << fabs(L(i - ode_size, j)) <<
"*";
985 std::ostringstream jsmKey;
986 jsmKey <<
"sm_" << metabs[ode_size + j]->
getKey();
989 const CCompartment * compj = metabs[ode_size + j]->getCompartment();
991 value -= L(i - ode_size, j) * metabs[ode_size + j]->getInitialConcentration() * compj->
getInitialValue();
998 std::stringstream stream; stream <<
"ct[" << (conservedTotals++) <<
"]";
999 std::string ctName(stream.str());
1001 stream.clear(); stream <<
" conserved total for '" << metab->
getObjectName() <<
"'";
1003 expression << ctName << tmp.str();
1008 expression << more.str() << tmp.str();
1021 str1 = expression.str();
1022 str2 = comments.str();
1037 size_t metabs_size = metabs.
size();
1041 for (i = 0; i < metabs_size; i++)
1051 std::ostringstream expression;
1052 std::ostringstream comments;
1057 std::ostringstream smKey;
1058 smKey <<
"sm_" << metab->
getKey();
1062 str1 = expression.str();
1063 str2 = comments.str();
1078 size_t comps_size = comps.
size();
1081 for (i = 0; i < comps_size; i++)
1086 std::ostringstream comments;
1087 std::ostringstream expression;
1120 str1 = expression.str();
1121 str2 = comments.str();
1136 size_t modvals_size = modvals.
size();
1139 for (i = 0; i < modvals_size; i++)
1142 modval = modvals[i];
1144 std::ostringstream comments;
1145 std::ostringstream expression;
1185 str1 = expression.str();
1186 str2 = comments.str();
1203 size_t reacs_size = reacs.
size();
1211 for (i = 0; i < reacs_size; ++i)
1220 for (j = 0; j < params_size; ++j)
1225 std::ostringstream comments;
1226 std::ostringstream expression;
1233 comments <<
"reaction \'" << name <<
"\': " <<
1236 std::string str1 = expression.str();
1237 std::string str2 = comments.str();
1244 for (j = 0; j < indep_size; ++j)
1246 std::ostringstream jequation;
1248 if (fabs(redStoi[j][i]) > 0.0)
1250 if (redStoi[j][i] < 0.0)
1260 if (fabs(redStoi[j][i]) != 1.0)
1261 jequation << fabs(redStoi[j][i]) <<
"*";
1281 size_t metabs_size = metabs.
size();
1285 for (i = 0; i < indep_size && i + ode_size < metabs_size; ++i)
1287 CMetab * metab = metabs[ode_size + i];
1290 std::string str2 =
" ";
1296 for (i = indep_size; i + ode_size < metabs_size; ++i)
1298 CMetab * metab = metabs[ode_size + i];
1302 std::string str1 =
"0";
1303 std::string str2 =
" ";
1332 const std::string & ,
1333 const std::string & ,
1334 const std::string & )
1365 std::ostringstream comments;
1366 std::ostringstream expression;
1372 comments <<
"reaction \'" << reac->
getObjectName() <<
"\': "
1385 while (treeIt != NULL)
1392 std::string tmpname;
1408 tmpname =
"unknown";
1437 treeIt->setData(tmpname);
1457 size_t substrs_size = substrs.
size(), prods_size = prods.
size();
1480 for (k = 0; k < substrs_size; ++k)
1482 substr = substrs[k];
1488 for (m = 1; m < mult; ++m)
1511 for (k = 0; k < prods_size; ++k)
1519 for (m = 1; m < mult; ++m)
1526 std::ostringstream localKey;
1527 localKey << reac->
getKey() <<
"_root_func";
1528 NameMap[localKey.str()] = name;
1530 std::string str1 = expression.str();
1531 std::string str2 = comments.str();
1554 while (treeIt != NULL)
1564 std::ostringstream localKey;
1567 localKey << key <<
"_func_" << index;
1569 localKey << key <<
"_root_func";
1574 NameMap[localKey.str()] = name;
1576 treeIt->setData(name);
1589 else while (newIt != NULL)
1597 for (i = 0; i < vindex ; i++)
1598 child = dynamic_cast<CEvaluationNode*>((child)->getSibling());
1609 parent->
addChild(newnode, &(*iIt));
1621 std::string expression;
1622 std::string comments =
" ";
1667 {
return (str.find_first_not_of(
" \n\t\r") == std::string::npos);}
1678 while (treeIt != NULL)
1697 if (callfunc->
getObjectName() ==
"Mass action (irreversible)") newNode = newNode1;
1699 if (callfunc->
getObjectName() ==
"Mass action (reversible)")
1712 newNode->
addChild(newNode2, newNode1);
1717 parent->
addChild(newNode, &(*treeIt));
1739 newparent->
addChild(newchild1, NULL);
1746 newparent->
addChild(newchild2, newchild1);
1747 newparent = newchild2;
1749 newparent->
addChild(newchild1, NULL);
1751 newparent->
addChild(newchild2, newchild1);
1757 const std::vector<CEvaluationNode *> & vector =
dynamic_cast< CEvaluationNodeVector *
>(child2) ->getVector();
1758 std::vector<CEvaluationNode *>::const_iterator it = vector.begin();
1759 std::vector<CEvaluationNode *>::const_iterator end = vector.end();
1767 newparent->
addChild(newchild2, newchild1);
1769 newparent = newchild2;
1771 newparent->
addChild(newchild1, NULL);
1779 newparent->
addChild(newchild2, newchild1);
const CExpression * getExpressionPtr() const
Header file of class CExpression.
CCopasiDataModel * getObjectDataModel()
std::string isModelEntityExpressionODEExporterCompatible(CModelEntity *tmp, const CExpression *pExpression, const CCopasiDataModel *pDataModel)
virtual bool exportKineticFunction(CReaction *reac)
virtual bool exportSingleModVal(const CModelValue *modval, std::string &expression, std::string &comments)
void exportSimulatedObject(CCopasiObject *obj, const CCopasiDataModel *pDataModel)
CCopasiObject * getDataObject(const CCopasiObjectName &CN) const
CEvaluationNode * copyBranch() const
std::ostringstream headers
const CEvaluationTree * getCalledTree() const
virtual std::string exportTitleString(const size_t tmp)
virtual bool exportTitleData(const CModel *copasiModel, std::ostream &os)
CCopasiProblem * getProblem()
virtual bool exportMetabolitesConcentrations(const CModel *copasiModel)
static const std::string StatusName[]
const CLinkMatrixView & getL() const
virtual size_t getVariableIndex(const std::string &name) const
virtual std::string setODEName(const std::string &objName)
const CCopasiVector< CMetab > & getMetabolites() const
virtual bool preprocess(const CModel *copasiModel)
const std::string & getObjectName() const
const CCopasiVectorN< CModelValue > & getModelValues() const
virtual size_t size() const
const CRegisteredObjectName & getObjectCN() const
virtual bool exportMetabolites(const CModel *copasiModel)
CCopasiObject * get(const std::string &key)
size_t getNumMetabs() const
virtual const std::string & getKey() const
virtual bool exportSingleObject(std::ostringstream &which, const std::string &name, const std::string &expression, const std::string &comments)
virtual const objectMap & getObjects() const
const Type & getType() const
virtual std::string getDisplayExpressionString(CExpression *tmp)
static CEvaluationNode * create(const Type &type, const Data &data)
bool isLocalParameter(const size_t &index) const
virtual std::string setConcentrationName(const std::string &objName)
const CEvaluationTree::Type & getType() const
const std::string & getObjectType() const
void assembleSubTreeForMassAction(CEvaluationNode *newNode, CEvaluationNode *child1, CEvaluationNode *child2)
size_t getNumODEMetabs() const
std::ostringstream initial
virtual void setReservedNames()
bool exportCompartments(const CModel *copasiModel)
virtual std::string exportClosingString(const size_t tmp)
const std::vector< Refresh * > & getListOfSimulatedRefreshes() const
const CMatrix< C_FLOAT64 > & getRedStoi() const
std::map< std::string, std::string > equations
std::string exportExpression(const CExpression *pExpression, const CCopasiDataModel *pDataModel)
virtual const std::string & getKey() const
const C_FLOAT64 & getInitialValue() const
virtual bool isEmptyString(std::string &str)
const CCopasiVector< CChemEqElement > & getProducts() const
static Type type(const Type &type)
const CFunction * getFunction() const
const C_FLOAT64 & getQuantity2NumberFactor() const
virtual std::string getSingleLineComment()
std::ostringstream functions
bool exportModelValuesExpressions(const CModel *copasiModel)
const TriLogic & isReversible() const
virtual const std::string & getKey() const
virtual const std::string & getKey() const
virtual bool exportKineticFunctionGroup(const CModel *copasiModel)
virtual bool exportSingleModelEntity(const CModelEntity *tmp, std::string &expression, std::string &comments)
virtual bool addChild(CCopasiNode< Data > *pChild, CCopasiNode< Data > *pAfter=NULL)
const C_FLOAT64 & getMultiplicity() const
const std::string & getMetaboliteKey() const
CCopasiObject * findObjectFromRefresh(const CCopasiObject *tmp, const Refresh *ref)
const Value & getValue() const
virtual bool exportSingleCompartment(const CCompartment *comp, std::string &expression, std::string &comments)
virtual bool exportSingleParameter(const CCopasiParameter *param, std::string &expression, std::string &comments)
std::string getQuantityParameterOrValue(const std::map< std::string, std::string > &map, const CCopasiDataModel *pDataModel)
bool exportModelEntityExpression(CCopasiObject *obj, const CCopasiDataModel *pDataModel)
virtual std::string translateTimeVariableName()
CCopasiParameter * getParameter(const std::string &name)
const CCopasiVector< CChemEqElement > & getSubstrates() const
static CFunctionDB * getFunctionList()
size_t getNumIndependentReactionMetabs() const
virtual bool exportSingleODE(const CModelEntity *mentity, std::string &equation, std::string &comments)
virtual std::string exportNumber(double number)
virtual std::string translateObjectName(const std::string &realName)
void modifyTreeForMassAction(CFunction *tmpfunc)
CCopasiVectorNS< CCompartment > & getCompartments()
bool exportReacParamsAndFuncs(const CModel *copasiModel)
bool exportToStream(const CCopasiDataModel *pDataModel, std::ostream &os)
static CKeyFactory * getKeyFactory()
const C_FLOAT64 & getOutputStartTime() const
bool exportModelValues(const CModel *copasiModel)
std::map< std::string, std::string > NameMap
const CCopasiParameterGroup & getParameters() const
size_t getCompartmentNumber() const
size_t getNumModelValues() const
std::ostringstream assignment
The class for handling a chemical kinetic function.
CCopasiVectorNS< CReaction > & getReactions()
virtual std::string KineticFunction2ODEmember(const CReaction *reac)
void findFunctionsCalls(const CEvaluationNode *pNode)
virtual bool removeChild(CCopasiNode< Data > *pChild)
std::set< std::string > mExportedFunctions
virtual bool exportSingleMetabolite(const CMetab *metab, std::string &expression, std::string &comments)
void exportObjectNodesFromModel(const CCopasiDataModel *pDataModel)
virtual bool exportClosingData(const CModel *copasiModel, std::ostream &os)
const CModelEntity::Status & getStatus() const
const CCopasiVector< CMetab > & getMetabolitesX() const
bool exportODEs(const CModel *copasiModel)
const std::vector< std::vector< std::string > > & getParameterMappings() const
CFunction * findFunction(const std::string &functionName)
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
const std::vector< CEvaluationNode * > & getNodeList() const
virtual std::string getDisplayFunctionString(CFunction *func)
size_t getReactionIndex(const CCopasiVector< CReaction > &reacs, const CReaction *react)
const CChemEq & getChemEq() const
CEvaluationNode * getRoot()
bool exportSingleFunction(const CFunction *func)
CFunctionParameters & getVariables()
CCopasiContainer * getObjectParent() const