COPASI API  4.16.103
CODEExporter.h
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 #include "model/CModel.h"
16 #include "model/CMetab.h"
17 
18 #include <iostream>
19 #include <fstream>
20 #include <ctype.h>
21 
22 #ifndef ODEExpoter_H__
23 #define ODEExpoter_H__
24 
25 class CCopasiDataModel;
26 
28 {
29 protected:
30  std::set<std::string> mExportedFunctions;
31 public:
32 
33  /**
34  ** Constructor for the exporter.
35  */
36 
37  CODEExporter();
38 
39  /**
40  ** Destructor for the exporter.
41  */
42  virtual ~CODEExporter();
43 
44  bool exportToStream(const CCopasiDataModel* pDataModel, std::ostream & os);
45 
46  virtual bool preprocess(const CModel* copasiModel);
47 
48  virtual bool exportTitleData(const CModel* copasiModel, std::ostream & os);
49 
50  virtual bool exportMetabolites(const CModel* copasiModel);
51 
52  virtual bool exportMetabolitesConcentrations(const CModel* copasiModel);
53 
54  bool exportCompartments(const CModel* copasiModel);
55 
56  bool exportModelValues(const CModel* copasiModel);
57 
58 #if 1
59  void exportObjectNodesFromModel(const CCopasiDataModel* pDataModel);
60 
61  CCopasiObject* findObjectFromRefresh(const CCopasiObject * tmp, const Refresh* ref);
62 
63  void exportSimulatedObject(CCopasiObject * obj, const CCopasiDataModel* pDataModel);
64 
65  bool exportModelEntityExpression(CCopasiObject * obj, const CCopasiDataModel* pDataModel);
66 
67  bool exportModelValuesExpressions(const CModel* copasiModel);
68 
69  void findFunctionsCalls(const CEvaluationNode* pNode);
70 
71  bool exportSingleFunction(const CFunction *func);
72 
73  virtual bool exportSingleFunction(const CFunction *func, std::set<std::string>& isExported);
74 
75  std::string isModelEntityExpressionODEExporterCompatible(CModelEntity * tmp, const CExpression* pExpression, const CCopasiDataModel* pDataModel);
76 
77  std::string exportExpression(const CExpression* pExpression, const CCopasiDataModel* pDataModel);
78 
79  virtual std::string getSingleLineComment();
80 
81  virtual bool exportSingleModelEntity(const CModelEntity* tmp, std::string & expression, std::string & comments);
82 #endif
83 
84  virtual std::string getDisplayExpressionString(CExpression* tmp);
85 
86  bool exportReacParamsAndFuncs(const CModel* copasiModel);
87 
88  bool exportODEs(const CModel* copasiModel);
89 
90  virtual bool exportClosingData(const CModel* copasiModel, std::ostream & os);
91 
92  virtual void setReservedNames();
93 
94  virtual std::string exportNumber(double number);
95 
96  virtual std::string translateTimeVariableName();
97 
98  virtual std::string translateObjectName(const std::string & realName);
99 
100  virtual std::string setConcentrationName(const std::string & objName);
101 
102  virtual std::string setODEName(const std::string & objName);
103 
104  virtual bool exportSingleObject(std::ostringstream & which,
105  const std::string & name,
106  const std::string & expression,
107  const std::string & comments);
108 
109  virtual bool exportSingleMetabolite(const CMetab* metab, std::string & expression, std::string & comments);
110 
111  virtual bool exportSingleCompartment(const CCompartment* comp, std::string & expression, std::string & comments);
112 
113  virtual bool exportSingleModVal(const CModelValue* modval, std::string & expression, std::string & comments);
114 
115  virtual bool exportSingleParameter(const CCopasiParameter* param, std::string & expression, std::string & comments);
116 
117  virtual std::string getDisplayFunctionString(CFunction * func);
118 
119  bool exportSingleFunction(CEvaluationNode* pNode, const CReaction *reac, size_t &index);
120  bool exportSingleFunction(CEvaluationNode* pNode, const std::string& key, size_t &index);
121 
122  virtual bool exportKineticFunction(CReaction* reac);
123 
124  virtual bool exportSingleODE(const CModelEntity* mentity, std::string & equation, std::string & comments);
125 
126  virtual bool exportKineticFunctionGroup(const CModel* copasiModel);
127 
128  virtual std::string KineticFunction2ODEmember(const CReaction *reac);
129 
130  virtual std::string exportTitleString(const size_t tmp);
131 
132  virtual std::string exportClosingString(const size_t tmp);
133 
134  /**
135  ** This method tests if a string consists only of whitespace characters
136  **/
137  virtual bool isEmptyString(std::string & str);
138 
139  /**
140  ** This method modifies the export tree of the function for internal calls of Mass Action
141  **/
142  void modifyTreeForMassAction(CFunction* tmpfunc);
143 
144  /**
145  ** This method assembles an expression sub tree for some internal call of Mass Action.
146  ** The sub tree has to be included in the tree of corresponding root kinetic function in order to
147  ** export this function whithout the user defined internall Mass Action calls
148  **/
150 
151  std::map< std::string, std::string > NameMap;
152  std::string timeKey;
153  std::map< std::string, std::string > equations;
154 
155  std::ostringstream initial;
156  std::ostringstream fixed;
157  std::ostringstream assignment;
158  std::ostringstream functions;
159  std::ostringstream headers;
160  std::ostringstream ode;
161 
162  enum Object
163  {
164  INITIAL = 0,
170  };
171 };
172 #endif
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)
std::ostringstream headers
Definition: CODEExporter.h:159
virtual std::string exportTitleString(const size_t tmp)
virtual bool exportTitleData(const CModel *copasiModel, std::ostream &os)
virtual bool exportMetabolitesConcentrations(const CModel *copasiModel)
virtual std::string setODEName(const std::string &objName)
virtual bool preprocess(const CModel *copasiModel)
virtual bool exportMetabolites(const CModel *copasiModel)
virtual bool exportSingleObject(std::ostringstream &which, const std::string &name, const std::string &expression, const std::string &comments)
virtual std::string getDisplayExpressionString(CExpression *tmp)
virtual ~CODEExporter()
virtual std::string setConcentrationName(const std::string &objName)
void assembleSubTreeForMassAction(CEvaluationNode *newNode, CEvaluationNode *child1, CEvaluationNode *child2)
std::ostringstream initial
Definition: CODEExporter.h:155
virtual void setReservedNames()
bool exportCompartments(const CModel *copasiModel)
virtual std::string exportClosingString(const size_t tmp)
Definition: CMetab.h:178
std::map< std::string, std::string > equations
Definition: CODEExporter.h:153
std::string exportExpression(const CExpression *pExpression, const CCopasiDataModel *pDataModel)
virtual bool isEmptyString(std::string &str)
virtual std::string getSingleLineComment()
std::ostringstream ode
Definition: CODEExporter.h:160
std::ostringstream functions
Definition: CODEExporter.h:158
bool exportModelValuesExpressions(const CModel *copasiModel)
virtual bool exportKineticFunctionGroup(const CModel *copasiModel)
virtual bool exportSingleModelEntity(const CModelEntity *tmp, std::string &expression, std::string &comments)
CCopasiObject * findObjectFromRefresh(const CCopasiObject *tmp, const Refresh *ref)
virtual bool exportSingleCompartment(const CCompartment *comp, std::string &expression, std::string &comments)
virtual bool exportSingleParameter(const CCopasiParameter *param, std::string &expression, std::string &comments)
bool exportModelEntityExpression(CCopasiObject *obj, const CCopasiDataModel *pDataModel)
virtual std::string translateTimeVariableName()
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)
bool exportReacParamsAndFuncs(const CModel *copasiModel)
bool exportToStream(const CCopasiDataModel *pDataModel, std::ostream &os)
bool exportModelValues(const CModel *copasiModel)
std::map< std::string, std::string > NameMap
Definition: CODEExporter.h:151
std::string timeKey
Definition: CODEExporter.h:152
std::ostringstream assignment
Definition: CODEExporter.h:157
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
virtual std::string KineticFunction2ODEmember(const CReaction *reac)
void findFunctionsCalls(const CEvaluationNode *pNode)
Definition: CModel.h:50
std::set< std::string > mExportedFunctions
Definition: CODEExporter.h:30
virtual bool exportSingleMetabolite(const CMetab *metab, std::string &expression, std::string &comments)
std::ostringstream fixed
Definition: CODEExporter.h:156
void exportObjectNodesFromModel(const CCopasiDataModel *pDataModel)
virtual bool exportClosingData(const CModel *copasiModel, std::ostream &os)
bool exportODEs(const CModel *copasiModel)
virtual std::string getDisplayFunctionString(CFunction *func)
bool exportSingleFunction(const CFunction *func)