22 #include "utilities.hpp"
27 #include "sbml/SBMLDocument.h"
28 #include "sbml/Model.h"
29 #include "sbml/Rule.h"
30 #include "sbml/Species.h"
31 #include "sbml/Parameter.h"
32 #include "sbml/math/ASTNode.h"
55 CPPUNIT_ASSERT(pDataModel->
getModel() != NULL);
57 const Model* pSBMLModel = pDocument->getModel();
58 CPPUNIT_ASSERT(pSBMLModel != NULL);
59 CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 0);
60 CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 0);
61 CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 0);
62 CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
63 CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 5);
64 const Parameter* pParameter1 = pSBMLModel->getParameter(0);
65 CPPUNIT_ASSERT(pParameter1 != NULL);
66 CPPUNIT_ASSERT(pParameter1->getConstant() ==
true);
67 const Parameter* pParameter2 = pSBMLModel->getParameter(1);
68 CPPUNIT_ASSERT(pParameter2 != NULL);
69 CPPUNIT_ASSERT(pParameter2->getConstant() ==
true);
70 const Parameter* pParameter3 = pSBMLModel->getParameter(2);
71 CPPUNIT_ASSERT(pParameter3 != NULL);
72 CPPUNIT_ASSERT(pParameter3->getConstant() ==
true);
73 const Parameter* pParameter4 = pSBMLModel->getParameter(3);
74 CPPUNIT_ASSERT(pParameter4 != NULL);
75 CPPUNIT_ASSERT(pParameter4->getConstant() ==
true);
76 const Parameter* pParameter5 = pSBMLModel->getParameter(4);
77 CPPUNIT_ASSERT(pParameter5 != NULL);
78 CPPUNIT_ASSERT(pParameter5->getConstant() ==
true);
79 CPPUNIT_ASSERT(pSBMLModel->getNumInitialAssignments() == 5);
80 const InitialAssignment* pIA = pSBMLModel->getInitialAssignment(0);
81 CPPUNIT_ASSERT(pIA != NULL);
82 CPPUNIT_ASSERT(pIA->getSymbol() == pParameter1->getId());
83 CPPUNIT_ASSERT(pIA->isSetMath() ==
true);
84 const ASTNode* pMath = pIA->getMath();
85 CPPUNIT_ASSERT(pMath != NULL);
86 CPPUNIT_ASSERT(pMath->getType() == AST_TIMES);
87 CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
88 const ASTNode* pChild1 = pMath->getChild(0);
89 CPPUNIT_ASSERT(pChild1 != NULL);
90 CPPUNIT_ASSERT(pChild1->getType() == AST_REAL);
91 CPPUNIT_ASSERT(fabs((pChild1->getReal() - 3.0) / 3.0) < 1e-15);
92 const ASTNode* pChild2 = pMath->getChild(1);
93 CPPUNIT_ASSERT(pChild2 != NULL);
94 CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
95 CPPUNIT_ASSERT(fabs((pChild2->getReal() - 4.0) / 4.0) < 1e-15);
97 pIA = pSBMLModel->getInitialAssignment(1);
98 CPPUNIT_ASSERT(pIA != NULL);
99 CPPUNIT_ASSERT(pIA->getSymbol() == pParameter2->getId());
100 CPPUNIT_ASSERT(pIA->isSetMath() ==
true);
101 pMath = pIA->getMath();
102 CPPUNIT_ASSERT(pMath != NULL);
103 CPPUNIT_ASSERT(pMath->getType() == AST_PLUS);
104 CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
105 pChild1 = pMath->getChild(0);
106 CPPUNIT_ASSERT(pChild1 != NULL);
107 CPPUNIT_ASSERT(pChild1->getType() == AST_REAL);
108 CPPUNIT_ASSERT(fabs((pChild1->getReal() - 9.0) / 9.0) < 1e-15);
109 pChild2 = pMath->getChild(1);
110 CPPUNIT_ASSERT(pChild2 != NULL);
111 CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
112 CPPUNIT_ASSERT(fabs((pChild2->getReal() - 2.0) / 2.0) < 1e-15);
114 pIA = pSBMLModel->getInitialAssignment(2);
115 CPPUNIT_ASSERT(pIA != NULL);
116 CPPUNIT_ASSERT(pIA->getSymbol() == pParameter3->getId());
117 CPPUNIT_ASSERT(pIA->isSetMath() ==
true);
118 pMath = pIA->getMath();
119 CPPUNIT_ASSERT(pMath != NULL);
120 CPPUNIT_ASSERT(pMath->getType() == AST_MINUS);
121 CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
122 pChild1 = pMath->getChild(0);
123 CPPUNIT_ASSERT(pChild1 != NULL);
124 CPPUNIT_ASSERT(pChild1->getType() == AST_REAL);
125 CPPUNIT_ASSERT(fabs((pChild1->getReal() - 8.0) / 8.0) < 1e-15);
126 pChild2 = pMath->getChild(1);
127 CPPUNIT_ASSERT(pChild2 != NULL);
128 CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
129 CPPUNIT_ASSERT(fabs((pChild2->getReal() - 4.0) / 4.0) < 1e-15);
131 pIA = pSBMLModel->getInitialAssignment(3);
132 CPPUNIT_ASSERT(pIA != NULL);
133 CPPUNIT_ASSERT(pIA->getSymbol() == pParameter4->getId());
134 CPPUNIT_ASSERT(pIA->isSetMath() ==
true);
135 pMath = pIA->getMath();
136 CPPUNIT_ASSERT(pMath != NULL);
137 CPPUNIT_ASSERT(pMath->getType() == AST_DIVIDE);
138 CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
139 pChild1 = pMath->getChild(0);
140 CPPUNIT_ASSERT(pChild1 != NULL);
141 CPPUNIT_ASSERT(pChild1->getType() == AST_REAL);
142 CPPUNIT_ASSERT(fabs((pChild1->getReal() - 9.0) / 9.0) < 1e-15);
143 pChild2 = pMath->getChild(1);
144 CPPUNIT_ASSERT(pChild2 != NULL);
145 CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
146 CPPUNIT_ASSERT(fabs((pChild2->getReal() - 3.0) / 3.0) < 1e-15);
148 pIA = pSBMLModel->getInitialAssignment(4);
149 CPPUNIT_ASSERT(pIA != NULL);
150 CPPUNIT_ASSERT(pIA->getSymbol() == pParameter5->getId());
151 CPPUNIT_ASSERT(pIA->isSetMath() ==
true);
152 pMath = pIA->getMath();
153 CPPUNIT_ASSERT(pMath != NULL);
154 CPPUNIT_ASSERT(pMath->getType() == AST_PLUS);
155 CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
156 pChild1 = pMath->getChild(0);
157 CPPUNIT_ASSERT(pChild1 != NULL);
158 CPPUNIT_ASSERT(pChild1->getType() == AST_REAL);
159 CPPUNIT_ASSERT(fabs((pChild1->getReal() - 6.0) / 6.0) < 1e-15);
160 pChild2 = pMath->getChild(1);
161 CPPUNIT_ASSERT(pChild2 != NULL);
162 CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
163 CPPUNIT_ASSERT(fabs((pChild2->getReal() - 1.0) / 1.0) < 1e-15);
167 CPPUNIT_ASSERT(pModel != NULL);
168 CPPUNIT_ASSERT(pModel->getModelValues().size() == 5);
169 CModelValue *pMV1 = NULL, *pMV2 = NULL, *pMV3 = NULL, *pMV4 = NULL, *pMV5 = NULL;
170 unsigned int i, iMax = pModel->getModelValues().size();
172 for (i = 0; i < iMax; ++i)
176 if (pTmpMV->
getSBMLId() == pParameter1->getId())
180 else if (pTmpMV->
getSBMLId() == pParameter2->getId())
184 else if (pTmpMV->
getSBMLId() == pParameter3->getId())
188 else if (pTmpMV->
getSBMLId() == pParameter4->getId())
192 else if (pTmpMV->
getSBMLId() == pParameter5->getId())
198 CPPUNIT_ASSERT(pMV1 != NULL);
199 CPPUNIT_ASSERT(pMV2 != NULL);
200 CPPUNIT_ASSERT(pMV3 != NULL);
201 CPPUNIT_ASSERT(pMV4 != NULL);
202 CPPUNIT_ASSERT(pMV5 != NULL);
203 pMV1->setInitialExpression(
"");
204 pMV4->setInitialExpression(
"");
205 pMV5->setInitialExpression(
"");
210 CPPUNIT_ASSERT(pDocument != NULL);
211 pSBMLModel = pDocument->getModel();
212 CPPUNIT_ASSERT(pSBMLModel != NULL);
213 CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 0);
214 CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 0);
215 CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 0);
216 CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
217 CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 5);
218 pParameter1 = pSBMLModel->getParameter(0);
219 CPPUNIT_ASSERT(pParameter1 != NULL);
220 CPPUNIT_ASSERT(pParameter1->getConstant() ==
true);
221 pParameter2 = pSBMLModel->getParameter(1);
222 CPPUNIT_ASSERT(pParameter2 != NULL);
223 CPPUNIT_ASSERT(pParameter2->getConstant() ==
true);
224 pParameter3 = pSBMLModel->getParameter(2);
225 CPPUNIT_ASSERT(pParameter3 != NULL);
226 CPPUNIT_ASSERT(pParameter3->getConstant() ==
true);
227 pParameter4 = pSBMLModel->getParameter(3);
228 CPPUNIT_ASSERT(pParameter4 != NULL);
229 CPPUNIT_ASSERT(pParameter4->getConstant() ==
true);
230 pParameter5 = pSBMLModel->getParameter(4);
231 CPPUNIT_ASSERT(pParameter5 != NULL);
232 CPPUNIT_ASSERT(pParameter5->getConstant() ==
true);
233 CPPUNIT_ASSERT(pSBMLModel->getNumInitialAssignments() == 2);
234 pIA = pSBMLModel->getInitialAssignment(0);
235 CPPUNIT_ASSERT(pIA != NULL);
236 CPPUNIT_ASSERT(pIA->getSymbol() == pParameter2->getId());
237 CPPUNIT_ASSERT(pIA->isSetMath() ==
true);
238 pMath = pIA->getMath();
239 CPPUNIT_ASSERT(pMath != NULL);
240 CPPUNIT_ASSERT(pMath->getType() == AST_PLUS);
241 CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
242 pChild1 = pMath->getChild(0);
243 CPPUNIT_ASSERT(pChild1 != NULL);
244 CPPUNIT_ASSERT(pChild1->getType() == AST_REAL);
245 CPPUNIT_ASSERT(fabs((pChild1->getReal() - 9.0) / 9.0) < 1e-15);
246 pChild2 = pMath->getChild(1);
247 CPPUNIT_ASSERT(pChild2 != NULL);
248 CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
249 CPPUNIT_ASSERT(fabs((pChild2->getReal() - 2.0) / 2.0) < 1e-15);
251 pIA = pSBMLModel->getInitialAssignment(1);
252 CPPUNIT_ASSERT(pIA != NULL);
253 CPPUNIT_ASSERT(pIA->getSymbol() == pParameter3->getId());
254 CPPUNIT_ASSERT(pIA->isSetMath() ==
true);
255 pMath = pIA->getMath();
256 CPPUNIT_ASSERT(pMath != NULL);
257 CPPUNIT_ASSERT(pMath->getType() == AST_MINUS);
258 CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
259 pChild1 = pMath->getChild(0);
260 CPPUNIT_ASSERT(pChild1 != NULL);
261 CPPUNIT_ASSERT(pChild1->getType() == AST_REAL);
262 CPPUNIT_ASSERT(fabs((pChild1->getReal() - 8.0) / 8.0) < 1e-15);
263 pChild2 = pMath->getChild(1);
264 CPPUNIT_ASSERT(pChild2 != NULL);
265 CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
266 CPPUNIT_ASSERT(fabs((pChild2->getReal() - 4.0) / 4.0) < 1e-15);
270 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
271 "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version3\" level=\"2\" version=\"3\">\n"
272 " <model id=\"Model_1\" name=\"New Model\">\n"
273 " <listOfUnitDefinitions>\n"
274 " <unitDefinition id=\"volume\">\n"
276 " <unit kind=\"litre\" scale=\"-3\"/>\n"
278 " </unitDefinition>\n"
279 " <unitDefinition id=\"substance\">\n"
281 " <unit kind=\"mole\" scale=\"-3\"/>\n"
283 " </unitDefinition>\n"
284 " </listOfUnitDefinitions>\n"
285 " <listOfParameters>\n"
286 " <parameter id=\"parameter_1\" name=\"A\" value=\"12\"/>\n"
287 " <parameter id=\"parameter_2\" name=\"B\" value=\"11\"/>\n"
288 " <parameter id=\"parameter_3\" name=\"C\" value=\"4\"/>\n"
289 " <parameter id=\"parameter_4\" name=\"D\" value=\"3\"/>\n"
290 " <parameter id=\"parameter_5\" name=\"E\" value=\"7\"/>\n"
291 " </listOfParameters>\n"
292 " <listOfInitialAssignments>\n"
293 " <initialAssignment symbol=\"parameter_1\">\n"
294 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
301 " </initialAssignment>\n"
302 " <initialAssignment symbol=\"parameter_2\">\n"
303 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
310 " </initialAssignment>\n"
311 " <initialAssignment symbol=\"parameter_3\">\n"
312 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
319 " </initialAssignment>\n"
320 " <initialAssignment symbol=\"parameter_4\">\n"
321 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
328 " </initialAssignment>\n"
329 " <initialAssignment symbol=\"parameter_5\">\n"
330 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
337 " </initialAssignment>\n"
338 " </listOfInitialAssignments>\n"
SBMLDocument * getCurrentSBMLDocument()
Header file of class CModelEntity and CModelValue.
const std::string & getSBMLId() const
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static CCopasiDataModel * pCOPASIDATAMODEL
static CCopasiDataModel * addDatamodel()
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
static void init(int argc, char *argv[], const bool &withGui=false)
static const char * MODEL_STRING