22 #include "utilities.hpp"
25 #include "sbml/SBMLDocument.h"
26 #include "sbml/Model.h"
27 #include "sbml/Rule.h"
28 #include "sbml/Species.h"
29 #include "sbml/Parameter.h"
30 #include "sbml/math/ASTNode.h"
57 CPPUNIT_ASSERT(pDataModel->
getModel() != NULL);
60 CPPUNIT_ASSERT(pDocument != NULL);
61 Model* pSBMLModel = pDocument->getModel();
62 CPPUNIT_ASSERT(pSBMLModel != NULL);
63 CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 0);
64 CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 0);
65 CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 0);
66 CPPUNIT_ASSERT(pSBMLModel->getNumInitialAssignments() == 0);
67 CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 5);
68 const Parameter* pParameter1 = pSBMLModel->getParameter(0);
69 CPPUNIT_ASSERT(pParameter1 != NULL);
70 CPPUNIT_ASSERT(pParameter1->getConstant() ==
false);
71 const Parameter* pParameter2 = pSBMLModel->getParameter(1);
72 CPPUNIT_ASSERT(pParameter2 != NULL);
73 CPPUNIT_ASSERT(pParameter2->getConstant() ==
false);
74 const Parameter* pParameter3 = pSBMLModel->getParameter(2);
75 CPPUNIT_ASSERT(pParameter3 != NULL);
76 CPPUNIT_ASSERT(pParameter3->getConstant() ==
false);
77 const Parameter* pParameter4 = pSBMLModel->getParameter(3);
78 CPPUNIT_ASSERT(pParameter4 != NULL);
79 CPPUNIT_ASSERT(pParameter4->getConstant() ==
false);
80 const Parameter* pParameter5 = pSBMLModel->getParameter(4);
81 CPPUNIT_ASSERT(pParameter5 != NULL);
82 CPPUNIT_ASSERT(pParameter5->getConstant() ==
false);
83 CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 5);
85 const Rule* pRule = pSBMLModel->getRule(0);
86 CPPUNIT_ASSERT(pRule != NULL);
87 CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
88 const AssignmentRule* pARule =
dynamic_cast<const AssignmentRule*
>(pRule);
89 CPPUNIT_ASSERT(pARule != NULL);
90 CPPUNIT_ASSERT(pARule->getVariable() == pParameter4->getId());
91 CPPUNIT_ASSERT(pARule->isSetMath() ==
true);
92 const ASTNode* pMath = pARule->getMath();
93 CPPUNIT_ASSERT(pMath != NULL);
94 CPPUNIT_ASSERT(pMath->getType() == AST_PLUS);
95 CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
96 const ASTNode* pChild1 = pMath->getChild(0);
97 CPPUNIT_ASSERT(pChild1 != NULL);
98 CPPUNIT_ASSERT(pChild1->getType() == AST_REAL);
99 CPPUNIT_ASSERT(fabs((pChild1->getReal() - 2.0) / 2.0) < 1e-15);
100 const ASTNode* pChild2 = pMath->getChild(1);
101 CPPUNIT_ASSERT(pChild2 != NULL);
102 CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
103 CPPUNIT_ASSERT(fabs((pChild2->getReal() - 4.0) / 4.0) < 1e-15);
105 pRule = pSBMLModel->getRule(1);
106 CPPUNIT_ASSERT(pRule != NULL);
107 CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
108 pARule =
dynamic_cast<const AssignmentRule*
>(pRule);
109 CPPUNIT_ASSERT(pARule != NULL);
110 CPPUNIT_ASSERT(pARule->getVariable() == pParameter1->getId());
111 CPPUNIT_ASSERT(pARule->isSetMath() ==
true);
112 pMath = pARule->getMath();
113 CPPUNIT_ASSERT(pMath != NULL);
114 CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
115 CPPUNIT_ASSERT(pMath->getName() == pParameter4->getId());
116 CPPUNIT_ASSERT(pMath->getNumChildren() == 0);
118 pRule = pSBMLModel->getRule(2);
119 CPPUNIT_ASSERT(pRule != NULL);
120 CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
121 pARule =
dynamic_cast<const AssignmentRule*
>(pRule);
122 CPPUNIT_ASSERT(pARule != NULL);
123 CPPUNIT_ASSERT(pARule->getVariable() == pParameter3->getId());
124 CPPUNIT_ASSERT(pARule->isSetMath() ==
true);
125 pMath = pARule->getMath();
126 CPPUNIT_ASSERT(pMath != NULL);
127 CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
128 CPPUNIT_ASSERT(pMath->getName() == pParameter1->getId());
129 CPPUNIT_ASSERT(pMath->getNumChildren() == 0);
131 pRule = pSBMLModel->getRule(3);
132 CPPUNIT_ASSERT(pRule != NULL);
133 CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
134 pARule =
dynamic_cast<const AssignmentRule*
>(pRule);
135 CPPUNIT_ASSERT(pARule != NULL);
136 CPPUNIT_ASSERT(pARule->getVariable() == pParameter5->getId());
137 CPPUNIT_ASSERT(pARule->isSetMath() ==
true);
138 pMath = pARule->getMath();
139 CPPUNIT_ASSERT(pMath != NULL);
140 CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
141 CPPUNIT_ASSERT(pMath->getName() == pParameter3->getId());
142 CPPUNIT_ASSERT(pMath->getNumChildren() == 0);
144 pRule = pSBMLModel->getRule(4);
145 CPPUNIT_ASSERT(pRule != NULL);
146 CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
147 pARule =
dynamic_cast<const AssignmentRule*
>(pRule);
148 CPPUNIT_ASSERT(pARule != NULL);
149 CPPUNIT_ASSERT(pARule->getVariable() == pParameter2->getId());
150 CPPUNIT_ASSERT(pARule->isSetMath() ==
true);
151 pMath = pARule->getMath();
152 CPPUNIT_ASSERT(pMath != NULL);
153 CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
154 CPPUNIT_ASSERT(pMath->getName() == pParameter5->getId());
155 CPPUNIT_ASSERT(pMath->getNumChildren() == 0);
159 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
160 "<!-- generated with COPASI 4.3.25 (Debug) (http://www.copasi.org) at 2008-03-08 18:49:47 UTC -->\n"
161 "<COPASI xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://www.copasi.org/static/schema.xsd\" versionMajor=\"1\" versionMinor=\"0\" versionDevel=\"25\">\n"
162 " <Model key=\"Model_1\" name=\"New Model\" timeUnit=\"s\" volumeUnit=\"ml\" quantityUnit=\"mmol\" type=\"deterministic\">\n"
164 " <body xmlns=\"http://www.w3.org/1999/xhtml\">\n"
168 " <ListOfModelValues>\n"
169 " <ModelValue key=\"ModelValue_0\" name=\"A\" simulationType=\"assignment\">\n"
171 " <CN=Root,Model=New Model,Vector=Values[D],Reference=Value>\n"
174 " <ModelValue key=\"ModelValue_1\" name=\"B\" simulationType=\"assignment\">\n"
176 " <CN=Root,Model=New Model,Vector=Values[E],Reference=Value>\n"
179 " <ModelValue key=\"ModelValue_2\" name=\"C\" simulationType=\"assignment\">\n"
181 " <CN=Root,Model=New Model,Vector=Values[A],Reference=Value>\n"
184 " <ModelValue key=\"ModelValue_3\" name=\"D\" simulationType=\"assignment\">\n"
189 " <ModelValue key=\"ModelValue_4\" name=\"E\" simulationType=\"assignment\">\n"
191 " <CN=Root,Model=New Model,Vector=Values[C],Reference=Value>\n"
194 " </ListOfModelValues>\n"
196 " <StateTemplateVariable objectReference=\"Model_1\"/>\n"
197 " <StateTemplateVariable objectReference=\"ModelValue_0\"/>\n"
198 " <StateTemplateVariable objectReference=\"ModelValue_1\"/>\n"
199 " <StateTemplateVariable objectReference=\"ModelValue_2\"/>\n"
200 " <StateTemplateVariable objectReference=\"ModelValue_3\"/>\n"
201 " <StateTemplateVariable objectReference=\"ModelValue_4\"/>\n"
202 " </StateTemplate>\n"
203 " <InitialState type=\"initialState\">\n"
204 " 0 NaN NaN NaN 3 7\n"
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static CCopasiDataModel * pCOPASIDATAMODEL
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
static const char * MODEL_STRING
static CCopasiDataModel * addDatamodel()
static void init(int argc, char *argv[], const bool &withGui=false)