COPASI API  4.16.103
test000068.cpp
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 #include "test000068.h"
12 
13 #include <sstream>
14 #include "utilities.hpp"
16 #include "copasi/model/CModel.h"
17 #include "copasi/model/CMetab.h"
19 #include "copasi/model/CReaction.h"
24 
25 #include "sbml/SBMLDocument.h"
26 #include "sbml/Model.h"
27 #include "sbml/Reaction.h"
28 
30 
31 CCopasiDataModel* test000068::pCOPASIDATAMODEL = NULL;
32 
34 {
35  // Create the root container.
36  CCopasiRootContainer::init(0, NULL, false);
37  // Create the global data model.
39 }
40 
42 {
44 }
45 
47 {
48  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
49  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING1));
50  CModel* pModel = pDataModel->getModel();
51  CPPUNIT_ASSERT(pModel != NULL);
52  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::Mol);
53  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::l);
54  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
55  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
56  const CCompartment* pCompartment = pModel->getCompartments()[0];
57  CPPUNIT_ASSERT(pCompartment != NULL);
58  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
59  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 6);
60  // check metabolites
61  const CMetab* pMetab = pModel->getMetabolites()[0];
62  CPPUNIT_ASSERT(pMetab != NULL);
63  CPPUNIT_ASSERT(pMetab->getObjectName() == "A");
64  CPPUNIT_ASSERT(pMetab->getStatus() == CModelEntity::REACTIONS);
65  pMetab = pModel->getMetabolites()[1];
66  CPPUNIT_ASSERT(pMetab != NULL);
67  CPPUNIT_ASSERT(pMetab->getObjectName() == "B");
68  CPPUNIT_ASSERT(pMetab->getStatus() == CModelEntity::REACTIONS);
69 
70  pMetab = pModel->getMetabolites()[2];
71  CPPUNIT_ASSERT(pMetab != NULL);
72  CPPUNIT_ASSERT(pMetab->getObjectName() == "C");
73  CPPUNIT_ASSERT(pMetab->getStatus() == CModelEntity::ASSIGNMENT);
74  // check assignment
75  const CEvaluationTree* pTree = pMetab->getExpressionPtr();
76  CPPUNIT_ASSERT(pTree != NULL);
77  const CEvaluationNode* pRoot = pTree->getRoot();
78  CPPUNIT_ASSERT(pRoot != NULL);
79  CPPUNIT_ASSERT(dynamic_cast<const CEvaluationNodeCall*>(pRoot) != NULL);
80  CPPUNIT_ASSERT(dynamic_cast<const CEvaluationNodeCall*>(pRoot)->getData() == "function_5");
81 
82  pMetab = pModel->getMetabolites()[3];
83  CPPUNIT_ASSERT(pMetab != NULL);
84  CPPUNIT_ASSERT(pMetab->getObjectName() == "D");
85  CPPUNIT_ASSERT(pMetab->getStatus() == CModelEntity::ODE);
86  // check ode
87  pTree = pMetab->getExpressionPtr();
88  CPPUNIT_ASSERT(pTree != NULL);
89  pRoot = pTree->getRoot();
90  CPPUNIT_ASSERT(pRoot != NULL);
91  CPPUNIT_ASSERT(dynamic_cast<const CEvaluationNodeCall*>(pRoot) != NULL);
92  CPPUNIT_ASSERT(dynamic_cast<const CEvaluationNodeCall*>(pRoot)->getData() == "function_2");
93 
94  pMetab = pModel->getMetabolites()[4];
95  CPPUNIT_ASSERT(pMetab != NULL);
96  CPPUNIT_ASSERT(pMetab->getObjectName() == "E");
97  CPPUNIT_ASSERT(pMetab->getStatus() == CModelEntity::ODE);
98  // check ode
99  pTree = pMetab->getExpressionPtr();
100  CPPUNIT_ASSERT(pTree != NULL);
101  pRoot = pTree->getRoot();
102  CPPUNIT_ASSERT(pRoot != NULL);
103  CPPUNIT_ASSERT(dynamic_cast<const CEvaluationNodeCall*>(pRoot) != NULL);
104  CPPUNIT_ASSERT(dynamic_cast<const CEvaluationNodeCall*>(pRoot)->getData() == "function_4");
105 
106  pMetab = pModel->getMetabolites()[5];
107  CPPUNIT_ASSERT(pMetab != NULL);
108  CPPUNIT_ASSERT(pMetab->getObjectName() == "F");
109  CPPUNIT_ASSERT(pMetab->getStatus() == CModelEntity::ODE);
110  // check ode
111  pTree = pMetab->getExpressionPtr();
112  CPPUNIT_ASSERT(pTree != NULL);
113  pRoot = pTree->getRoot();
114  CPPUNIT_ASSERT(pRoot != NULL);
115  CPPUNIT_ASSERT(dynamic_cast<const CEvaluationNodeCall*>(pRoot) != NULL);
116  CPPUNIT_ASSERT(dynamic_cast<const CEvaluationNodeCall*>(pRoot)->getData() == "function_6");
117 
118  // check model values
119  CPPUNIT_ASSERT(pModel->getModelValues().size() == 3);
120  const CModelValue* pModelValue = pModel->getModelValues()[0];
121  CPPUNIT_ASSERT(pModelValue != NULL);
122  CPPUNIT_ASSERT(pModelValue->getObjectName() == "K1");
123  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::ASSIGNMENT);
124  // check assignment
125  pTree = pModelValue->getExpressionPtr();
126  CPPUNIT_ASSERT(pTree != NULL);
127  pRoot = pTree->getRoot();
128  CPPUNIT_ASSERT(pRoot != NULL);
129  CPPUNIT_ASSERT(dynamic_cast<const CEvaluationNodeCall*>(pRoot) != NULL);
130  CPPUNIT_ASSERT(dynamic_cast<const CEvaluationNodeCall*>(pRoot)->getData() == "function_1");
131 
132  pModelValue = pModel->getModelValues()[1];
133  CPPUNIT_ASSERT(pModelValue != NULL);
134  CPPUNIT_ASSERT(pModelValue->getObjectName() == "K2");
135  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::FIXED);
136 
137  pModelValue = pModel->getModelValues()[2];
138  CPPUNIT_ASSERT(pModelValue != NULL);
139  CPPUNIT_ASSERT(pModelValue->getObjectName() == "K3");
140  // check assignment
141  pTree = pModelValue->getExpressionPtr();
142  CPPUNIT_ASSERT(pTree != NULL);
143  pRoot = pTree->getRoot();
144  CPPUNIT_ASSERT(pRoot != NULL);
145  CPPUNIT_ASSERT(dynamic_cast<const CEvaluationNodeCall*>(pRoot) != NULL);
146  CPPUNIT_ASSERT(dynamic_cast<const CEvaluationNodeCall*>(pRoot)->getData() == "function_3");
147 
148  CPPUNIT_ASSERT(pModel->getReactions().size() == 6);
149  // check reactions
150  const CReaction* pReaction = pModel->getReactions()[0];
151  CPPUNIT_ASSERT(pReaction != NULL);
152  CPPUNIT_ASSERT(pReaction->getChemEq().getSubstrates().size() == 1);
153  CPPUNIT_ASSERT(pReaction->getChemEq().getProducts().size() == 1);
154  CPPUNIT_ASSERT(pReaction->getChemEq().getModifiers().size() == 0);
155  CPPUNIT_ASSERT(pReaction->isReversible() == true);
156  // check the kinetic law
157  CPPUNIT_ASSERT(pReaction->getParameters().size() == 1);
158  const CFunction* pFunction = pReaction->getFunction();
159  CPPUNIT_ASSERT(pFunction != NULL);
160  CPPUNIT_ASSERT(pFunction->getType() == CEvaluationTree::UserDefined);
161  CPPUNIT_ASSERT(pFunction->getObjectName() == "Function for reaction1");
162  pRoot = pFunction->getRoot();
163  CPPUNIT_ASSERT(pRoot != NULL);
164 
165  pReaction = pModel->getReactions()[1];
166  CPPUNIT_ASSERT(pReaction != NULL);
167  CPPUNIT_ASSERT(pReaction->getChemEq().getSubstrates().size() == 1);
168  CPPUNIT_ASSERT(pReaction->getChemEq().getProducts().size() == 1);
169  CPPUNIT_ASSERT(pReaction->getChemEq().getModifiers().size() == 0);
170  CPPUNIT_ASSERT(pReaction->isReversible() == true);
171  // check the kinetic law
172  CPPUNIT_ASSERT(pReaction->getParameters().size() == 2);
173  pFunction = pReaction->getFunction();
174  CPPUNIT_ASSERT(pFunction != NULL);
175  CPPUNIT_ASSERT(pFunction->getType() == CEvaluationTree::UserDefined);
176  CPPUNIT_ASSERT(pFunction->getObjectName() == "Function for reaction2");
177  pRoot = pFunction->getRoot();
178  CPPUNIT_ASSERT(pRoot != NULL);
179 
180  pReaction = pModel->getReactions()[2];
181  CPPUNIT_ASSERT(pReaction != NULL);
182  CPPUNIT_ASSERT(pReaction->getChemEq().getSubstrates().size() == 1);
183  CPPUNIT_ASSERT(pReaction->getChemEq().getProducts().size() == 1);
184  CPPUNIT_ASSERT(pReaction->getChemEq().getModifiers().size() == 0);
185  CPPUNIT_ASSERT(pReaction->isReversible() == true);
186  // check the kinetic law
187  CPPUNIT_ASSERT(pReaction->getParameters().size() == 1);
188  pFunction = pReaction->getFunction();
189  CPPUNIT_ASSERT(pFunction != NULL);
190  CPPUNIT_ASSERT(pFunction->getType() == CEvaluationTree::UserDefined);
191  CPPUNIT_ASSERT(pFunction->getObjectName() == "Function for reaction3");
192  pRoot = pFunction->getRoot();
193  CPPUNIT_ASSERT(pRoot != NULL);
194 
195  pReaction = pModel->getReactions()[3];
196  CPPUNIT_ASSERT(pReaction != NULL);
197  CPPUNIT_ASSERT(pReaction->getChemEq().getSubstrates().size() == 1);
198  CPPUNIT_ASSERT(pReaction->getChemEq().getProducts().size() == 1);
199  CPPUNIT_ASSERT(pReaction->getChemEq().getModifiers().size() == 0);
200  CPPUNIT_ASSERT(pReaction->isReversible() == true);
201  // check the kinetic law
202  CPPUNIT_ASSERT(pReaction->getParameters().size() == 0);
203  pFunction = pReaction->getFunction();
204  CPPUNIT_ASSERT(pFunction != NULL);
205  CPPUNIT_ASSERT(pFunction->getType() == CEvaluationTree::UserDefined);
206  CPPUNIT_ASSERT(pFunction->getObjectName() == "Function for reaction4");
207  pRoot = pFunction->getRoot();
208  CPPUNIT_ASSERT(pRoot != NULL);
209 
210  pReaction = pModel->getReactions()[4];
211  CPPUNIT_ASSERT(pReaction != NULL);
212  CPPUNIT_ASSERT(pReaction->getChemEq().getSubstrates().size() == 1);
213  CPPUNIT_ASSERT(pReaction->getChemEq().getProducts().size() == 1);
214  CPPUNIT_ASSERT(pReaction->getChemEq().getModifiers().size() == 0);
215  CPPUNIT_ASSERT(pReaction->isReversible() == true);
216  // check the kinetic law
217  CPPUNIT_ASSERT(pReaction->getParameters().size() == 2);
218  pFunction = pReaction->getFunction();
219  CPPUNIT_ASSERT(pFunction != NULL);
220  CPPUNIT_ASSERT(pFunction->getType() == CEvaluationTree::UserDefined);
221  CPPUNIT_ASSERT(pFunction->getObjectName() == "Function for reaction5");
222  pRoot = pFunction->getRoot();
223  CPPUNIT_ASSERT(pRoot != NULL);
224 
225  pReaction = pModel->getReactions()[5];
226  CPPUNIT_ASSERT(pReaction != NULL);
227  CPPUNIT_ASSERT(pReaction->getChemEq().getSubstrates().size() == 1);
228  CPPUNIT_ASSERT(pReaction->getChemEq().getProducts().size() == 1);
229  CPPUNIT_ASSERT(pReaction->getChemEq().getModifiers().size() == 0);
230  CPPUNIT_ASSERT(pReaction->isReversible() == true);
231  // check the kinetic law
232  CPPUNIT_ASSERT(pReaction->getParameters().size() == 3);
233  pFunction = pReaction->getFunction();
234  CPPUNIT_ASSERT(pFunction != NULL);
235  CPPUNIT_ASSERT(pFunction->getType() == CEvaluationTree::UserDefined);
236  CPPUNIT_ASSERT(pFunction->getObjectName() == "Function for reaction6");
237  pRoot = pFunction->getRoot();
238  CPPUNIT_ASSERT(pRoot != NULL);
239 
240  // export to SBML
241  std::string s = pDataModel->exportSBMLToString(NULL, 1, 2);
242  CPPUNIT_ASSERT(s.empty() == false);
243  // due to the bugfix for Bug 1086 and some issues with libsbml and the current exporter,
244  // we now no longer have a L1 document in the datamodel if there was an SBMLDocument prior
245  // to exporting to L1 already.
246  // To test now, we have to call newModel on the datamodel to delete the old sbml document,
247  // and reimport the exported model
248  // This will also lead to a Level 2 Version 1 model since we convert all Level 1 model to
249  // Level 2 Version 1 on import, but we can at least test if the export worked.
250  pCOPASIDATAMODEL->newModel(NULL, true);
251  CPPUNIT_ASSERT(pCOPASIDATAMODEL->importSBMLFromString(s));
252  // check the sbml model
253  const SBMLDocument* pDocument = pCOPASIDATAMODEL->getCurrentSBMLDocument();
254  CPPUNIT_ASSERT(pDocument != NULL);
255  CPPUNIT_ASSERT(pDocument->getLevel() == 2);
256  CPPUNIT_ASSERT(pDocument->getVersion() == 1);
257  const Model* pSBMLModel = pDocument->getModel();
258  CPPUNIT_ASSERT(pSBMLModel != NULL);
259 
260  CPPUNIT_ASSERT(pSBMLModel->getListOfFunctionDefinitions()->size() == 0);
261  CPPUNIT_ASSERT(pSBMLModel->getListOfCompartments()->size() == 1);
262  CPPUNIT_ASSERT(pSBMLModel->getListOfSpecies()->size() == 6);
263  CPPUNIT_ASSERT(pSBMLModel->getListOfParameters()->size() == 3);
264  CPPUNIT_ASSERT(pSBMLModel->getListOfRules()->size() == 6);
265  CPPUNIT_ASSERT(pSBMLModel->getListOfReactions()->size() == 6);
266 
267  std::map<std::string, const Rule*> ruleMap;
268  unsigned int i, iMax = pSBMLModel->getListOfRules()->size();
269  const Rule* pRule = NULL;
270 
271  for (i = 0; i < iMax; ++i)
272  {
273  pRule = pSBMLModel->getRule(i);
274  ruleMap.insert(std::pair<std::string, const Rule*>(pRule->getVariable(), pRule));
275  }
276 
277  // check the rules
278  std::map<std::string, const Rule*>::const_iterator pos = ruleMap.find("parameter_1");
279  CPPUNIT_ASSERT(pos != ruleMap.end());
280  pRule = pos->second;
281  CPPUNIT_ASSERT(pRule != NULL);
282  CPPUNIT_ASSERT(pRule->getVariable() == "parameter_1");
283  const ASTNode* pMath = pRule->getMath();
284  CPPUNIT_ASSERT(pMath != NULL);
285  // only check the infix
286  std::string formula = pRule->getFormula();
287  CPPUNIT_ASSERT(formula == "3 * 4.5");
288 
289  pos = ruleMap.find("parameter_3");
290  CPPUNIT_ASSERT(pos != ruleMap.end());
291  pRule = pos->second;
292  CPPUNIT_ASSERT(pRule != NULL);
293  CPPUNIT_ASSERT(pRule->getVariable() == "parameter_3");
294  pRule->getMath();
295  CPPUNIT_ASSERT(pMath != NULL);
296  // only check the infix
297  formula = pRule->getFormula();
298  CPPUNIT_ASSERT(formula == "parameter_1 - 2 * 1.3");
299 
300  pos = ruleMap.find("species_3");
301  CPPUNIT_ASSERT(pos != ruleMap.end());
302  pRule = pos->second;
303  CPPUNIT_ASSERT(pRule != NULL);
304  CPPUNIT_ASSERT(pRule->getVariable() == "species_3");
305  pRule->getMath();
306  CPPUNIT_ASSERT(pMath != NULL);
307  // only check the infix
308  formula = pRule->getFormula();
309  CPPUNIT_ASSERT(formula == "parameter_1 - 3.5 * 1.3 + (3 * 2.4 - 5.23)");
310 
311  pos = ruleMap.find("species_4");
312  CPPUNIT_ASSERT(pos != ruleMap.end());
313  pRule = pos->second;
314  CPPUNIT_ASSERT(pRule != NULL);
315  CPPUNIT_ASSERT(pRule->getVariable() == "species_4");
316  pRule->getMath();
317  CPPUNIT_ASSERT(pMath != NULL);
318  // only check the infix
319  formula = pRule->getFormula();
320  CPPUNIT_ASSERT(formula == "3.4 + parameter_1");
321 
322  pos = ruleMap.find("species_5");
323  CPPUNIT_ASSERT(pos != ruleMap.end());
324  pRule = pos->second;
325  CPPUNIT_ASSERT(pRule != NULL);
326  CPPUNIT_ASSERT(pRule->getVariable() == "species_5");
327  pRule->getMath();
328  CPPUNIT_ASSERT(pMath != NULL);
329  // only check the infix
330  formula = pRule->getFormula();
331  CPPUNIT_ASSERT(formula == "(parameter_2 + 1.4) / 2");
332 
333  pos = ruleMap.find("species_6");
334  CPPUNIT_ASSERT(pos != ruleMap.end());
335  pRule = pos->second;
336  CPPUNIT_ASSERT(pRule != NULL);
337  CPPUNIT_ASSERT(pRule->getVariable() == "species_6");
338  pRule->getMath();
339  CPPUNIT_ASSERT(pMath != NULL);
340  // only check the infix
341  formula = pRule->getFormula();
342  CPPUNIT_ASSERT(formula == "parameter_3 - 3.4 * 1.3 + (3 * parameter_1 - 5.23)");
343 
344  // check the reactions
345  const Reaction* pSBMLReaction = pSBMLModel->getReaction(0);
346  CPPUNIT_ASSERT(pSBMLReaction != NULL);
347  CPPUNIT_ASSERT(pSBMLReaction->getListOfReactants()->size() == 1);
348  CPPUNIT_ASSERT(pSBMLReaction->getListOfProducts()->size() == 1);
349  CPPUNIT_ASSERT(pSBMLReaction->getListOfModifiers()->size() == 0);
350  CPPUNIT_ASSERT(pSBMLReaction->getReversible() == true);
351  CPPUNIT_ASSERT(pSBMLReaction->getKineticLaw() != NULL);
352  CPPUNIT_ASSERT(pSBMLReaction->getKineticLaw()->getListOfParameters()->size() == 0);
353  pMath = pSBMLReaction->getKineticLaw()->getMath();
354  CPPUNIT_ASSERT(pMath != NULL);
355  formula = pSBMLReaction->getKineticLaw()->getFormula();
356  CPPUNIT_ASSERT(formula == "compartment_1 * 3 * parameter_1");
357 
358  pSBMLReaction = pSBMLModel->getReaction(1);
359  CPPUNIT_ASSERT(pSBMLReaction != NULL);
360  CPPUNIT_ASSERT(pSBMLReaction->getListOfReactants()->size() == 1);
361  CPPUNIT_ASSERT(pSBMLReaction->getListOfProducts()->size() == 1);
362  CPPUNIT_ASSERT(pSBMLReaction->getListOfModifiers()->size() == 0);
363  CPPUNIT_ASSERT(pSBMLReaction->getReversible() == true);
364  CPPUNIT_ASSERT(pSBMLReaction->getKineticLaw() != NULL);
365  CPPUNIT_ASSERT(pSBMLReaction->getKineticLaw()->getListOfParameters()->size() == 0);
366  pMath = pSBMLReaction->getKineticLaw()->getMath();
367  CPPUNIT_ASSERT(pMath != NULL);
368  formula = pSBMLReaction->getKineticLaw()->getFormula();
369  CPPUNIT_ASSERT(formula == "compartment_1 * (parameter_2 + parameter_1)");
370 
371  pSBMLReaction = pSBMLModel->getReaction(2);
372  CPPUNIT_ASSERT(pSBMLReaction != NULL);
373  CPPUNIT_ASSERT(pSBMLReaction->getListOfReactants()->size() == 1);
374  CPPUNIT_ASSERT(pSBMLReaction->getListOfProducts()->size() == 1);
375  CPPUNIT_ASSERT(pSBMLReaction->getListOfModifiers()->size() == 0);
376  CPPUNIT_ASSERT(pSBMLReaction->getReversible() == true);
377  CPPUNIT_ASSERT(pSBMLReaction->getKineticLaw() != NULL);
378  CPPUNIT_ASSERT(pSBMLReaction->getKineticLaw()->getListOfParameters()->size() == 0);
379  pMath = pSBMLReaction->getKineticLaw()->getMath();
380  CPPUNIT_ASSERT(pMath != NULL);
381  formula = pSBMLReaction->getKineticLaw()->getFormula();
382  CPPUNIT_ASSERT(formula == "compartment_1 * (species_2 - parameter_1 * 1.3)");
383 
384  pSBMLReaction = pSBMLModel->getReaction(3);
385  CPPUNIT_ASSERT(pSBMLReaction != NULL);
386  CPPUNIT_ASSERT(pSBMLReaction->getListOfReactants()->size() == 1);
387  CPPUNIT_ASSERT(pSBMLReaction->getListOfProducts()->size() == 1);
388  CPPUNIT_ASSERT(pSBMLReaction->getListOfModifiers()->size() == 0);
389  CPPUNIT_ASSERT(pSBMLReaction->getReversible() == true);
390  CPPUNIT_ASSERT(pSBMLReaction->getKineticLaw() != NULL);
391  CPPUNIT_ASSERT(pSBMLReaction->getKineticLaw()->getListOfParameters()->size() == 0);
392  pMath = pSBMLReaction->getKineticLaw()->getMath();
393  CPPUNIT_ASSERT(pMath != NULL);
394  formula = pSBMLReaction->getKineticLaw()->getFormula();
395  CPPUNIT_ASSERT(formula == "compartment_1 * ((species_2 + species_1) / 2)");
396 
397  pSBMLReaction = pSBMLModel->getReaction(4);
398  CPPUNIT_ASSERT(pSBMLReaction != NULL);
399  CPPUNIT_ASSERT(pSBMLReaction->getListOfReactants()->size() == 1);
400  CPPUNIT_ASSERT(pSBMLReaction->getListOfProducts()->size() == 1);
401  CPPUNIT_ASSERT(pSBMLReaction->getListOfModifiers()->size() == 0);
402  CPPUNIT_ASSERT(pSBMLReaction->getReversible() == true);
403  CPPUNIT_ASSERT(pSBMLReaction->getKineticLaw() != NULL);
404  CPPUNIT_ASSERT(pSBMLReaction->getKineticLaw()->getListOfParameters()->size() == 0);
405  pMath = pSBMLReaction->getKineticLaw()->getMath();
406  CPPUNIT_ASSERT(pMath != NULL);
407  formula = pSBMLReaction->getKineticLaw()->getFormula();
408  CPPUNIT_ASSERT(formula == "compartment_1 * (parameter_1 - species_2 * 1.3 + (3 * parameter_3 - 5.23))");
409 
410  pSBMLReaction = pSBMLModel->getReaction(5);
411  CPPUNIT_ASSERT(pSBMLReaction != NULL);
412  CPPUNIT_ASSERT(pSBMLReaction->getListOfReactants()->size() == 1);
413  CPPUNIT_ASSERT(pSBMLReaction->getListOfProducts()->size() == 1);
414  CPPUNIT_ASSERT(pSBMLReaction->getListOfModifiers()->size() == 0);
415  CPPUNIT_ASSERT(pSBMLReaction->getReversible() == true);
416  CPPUNIT_ASSERT(pSBMLReaction->getKineticLaw() != NULL);
417  CPPUNIT_ASSERT(pSBMLReaction->getKineticLaw()->getListOfParameters()->size() == 0);
418  pMath = pSBMLReaction->getKineticLaw()->getMath();
419  CPPUNIT_ASSERT(pMath != NULL);
420  formula = pSBMLReaction->getKineticLaw()->getFormula();
421  CPPUNIT_ASSERT(formula == "compartment_1 * (parameter_1 - parameter_3 * 1.3 + (3 * parameter_2 - 5.23))");
422 }
423 
424 const char* test000068::MODEL_STRING1 =
425  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
426  "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version3\" level=\"2\" version=\"3\">\n"
427  " <model id=\"Model_1\" name=\"New Model\">\n"
428  " <notes>\n"
429  " <body xmlns=\"http://www.w3.org/1999/xhtml\">\n"
430  " <p>Model with function call in kinetics and rules.</p>\n"
431  " <p>This is to check function expansion for export to L1V2</p>\n"
432  " </body>\n"
433  " </notes>\n"
434  " <listOfFunctionDefinitions>\n"
435  " <functionDefinition id=\"function_1\" name=\"function_1\">\n"
436  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
437  " <lambda>\n"
438  " <bvar>\n"
439  " <ci> k </ci>\n"
440  " </bvar>\n"
441  " <apply>\n"
442  " <times/>\n"
443  " <cn> 3.0 </cn>\n"
444  " <ci> k </ci>\n"
445  " </apply>\n"
446  " </lambda>\n"
447  " </math>\n"
448  " </functionDefinition>\n"
449  " <functionDefinition id=\"function_2\" name=\"function_2\">\n"
450  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
451  " <lambda>\n"
452  " <bvar>\n"
453  " <ci> A </ci>\n"
454  " </bvar>\n"
455  " <bvar>\n"
456  " <ci> B </ci>\n"
457  " </bvar>\n"
458  " <apply>\n"
459  " <plus/>\n"
460  " <ci> B </ci>\n"
461  " <ci> A </ci>\n"
462  " </apply>\n"
463  " </lambda>\n"
464  " </math>\n"
465  " </functionDefinition>\n"
466  " <functionDefinition id=\"function_3\" name=\"function_3\">\n"
467  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
468  " <lambda>\n"
469  " <bvar>\n"
470  " <ci> k </ci>\n"
471  " </bvar>\n"
472  " <bvar>\n"
473  " <ci> C </ci>\n"
474  " </bvar>\n"
475  " <apply>\n"
476  " <minus/>\n"
477  " <ci> C </ci>\n"
478  " <apply>\n"
479  " <times/>\n"
480  " <ci> k </ci>\n"
481  " <cn> 1.3 </cn>\n"
482  " </apply>\n"
483  " </apply>\n"
484  " </lambda>\n"
485  " </math>\n"
486  " </functionDefinition>\n"
487  " <functionDefinition id=\"function_4\" name=\"function_4\">\n"
488  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
489  " <lambda>\n"
490  " <bvar>\n"
491  " <ci> x </ci>\n"
492  " </bvar>\n"
493  " <bvar>\n"
494  " <ci> y </ci>\n"
495  " </bvar>\n"
496  " <apply>\n"
497  " <divide/>\n"
498  " <apply>\n"
499  " <ci> function_2 </ci>\n"
500  " <ci> x </ci>\n"
501  " <ci> y </ci>\n"
502  " </apply>\n"
503  " <cn> 2.0 </cn>\n"
504  " </apply>\n"
505  " </lambda>\n"
506  " </math>\n"
507  " </functionDefinition>\n"
508  " <functionDefinition id=\"function_5\" name=\"function_5\">\n"
509  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
510  " <lambda>\n"
511  " <bvar>\n"
512  " <ci> a </ci>\n"
513  " </bvar>\n"
514  " <bvar>\n"
515  " <ci> b </ci>\n"
516  " </bvar>\n"
517  " <bvar>\n"
518  " <ci> c </ci>\n"
519  " </bvar>\n"
520  " <apply>\n"
521  " <plus/>\n"
522  " <apply>\n"
523  " <ci> function_3 </ci>\n"
524  " <ci> c </ci>\n"
525  " <ci> a </ci>\n"
526  " </apply>\n"
527  " <apply>\n"
528  " <minus/>\n"
529  " <apply>\n"
530  " <ci> function_1 </ci>\n"
531  " <ci> b </ci>\n"
532  " </apply>\n"
533  " <cn> 5.23 </cn>\n"
534  " </apply>\n"
535  " </apply>\n"
536  " </lambda>\n"
537  " </math>\n"
538  " </functionDefinition>\n"
539  " <functionDefinition id=\"function_6\" name=\"function_6\">\n"
540  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
541  " <lambda>\n"
542  " <bvar>\n"
543  " <ci> k1 </ci>\n"
544  " </bvar>\n"
545  " <bvar>\n"
546  " <ci> k2 </ci>\n"
547  " </bvar>\n"
548  " <bvar>\n"
549  " <ci> k3 </ci>\n"
550  " </bvar>\n"
551  " <apply>\n"
552  " <ci> function_5 </ci>\n"
553  " <ci> k1 </ci>\n"
554  " <ci> k2 </ci>\n"
555  " <ci> k3 </ci>\n"
556  " </apply>\n"
557  " </lambda>\n"
558  " </math>\n"
559  " </functionDefinition>\n"
560  " </listOfFunctionDefinitions>\n"
561  " <listOfCompartments>\n"
562  " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>\n"
563  " </listOfCompartments>\n"
564  " <listOfSpecies>\n"
565  " <species id=\"species_1\" name=\"A\" compartment=\"compartment_1\" initialConcentration=\"1\"/>\n"
566  " <species id=\"species_2\" name=\"B\" compartment=\"compartment_1\" initialConcentration=\"1\"/>\n"
567  " <species id=\"species_3\" name=\"C\" compartment=\"compartment_1\" initialConcentration=\"1\" constant=\"false\"/>\n"
568  " <species id=\"species_4\" name=\"D\" compartment=\"compartment_1\" initialConcentration=\"1\" constant=\"false\"/>\n"
569  " <species id=\"species_5\" name=\"E\" compartment=\"compartment_1\" initialConcentration=\"1\" constant=\"false\"/>\n"
570  " <species id=\"species_6\" name=\"F\" compartment=\"compartment_1\" initialConcentration=\"1\" constant=\"false\"/>\n"
571  " </listOfSpecies>\n"
572  " <listOfParameters>\n"
573  " <parameter id=\"parameter_1\" name=\"K1\" value=\"1.1\" constant=\"false\"/>\n"
574  " <parameter id=\"parameter_2\" name=\"K2\" value=\"1.2\"/>\n"
575  " <parameter id=\"parameter_3\" name=\"K3\" value=\"1.3\" constant=\"false\"/>\n"
576  " </listOfParameters>\n"
577  " <listOfRules>\n"
578  " <assignmentRule variable=\"parameter_1\">\n"
579  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
580  " <apply>\n"
581  " <ci> function_1 </ci>\n"
582  " <cn> 4.5 </cn>\n"
583  " </apply>\n"
584  " </math>\n"
585  " </assignmentRule>\n"
586  " <assignmentRule variable=\"parameter_3\">\n"
587  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
588  " <apply>\n"
589  " <ci> function_3 </ci>\n"
590  " <cn> 2.0 </cn>\n"
591  " <ci> parameter_1 </ci>\n"
592  " </apply>\n"
593  " </math>\n"
594  " </assignmentRule>\n"
595  " <assignmentRule variable=\"species_3\">\n"
596  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
597  " <apply>\n"
598  " <ci> function_5 </ci>\n"
599  " <ci> parameter_1 </ci>\n"
600  " <cn> 2.4 </cn>\n"
601  " <cn> 3.5 </cn>\n"
602  " </apply>\n"
603  " </math>\n"
604  " </assignmentRule>\n"
605  " <rateRule variable=\"species_4\">\n"
606  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
607  " <apply>\n"
608  " <ci> function_2 </ci>\n"
609  " <ci> parameter_1 </ci>\n"
610  " <cn> 3.4 </cn>\n"
611  " </apply>\n"
612  " </math>\n"
613  " </rateRule>\n"
614  " <rateRule variable=\"species_5\">\n"
615  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
616  " <apply>\n"
617  " <ci> function_4 </ci>\n"
618  " <cn> 1.4 </cn>\n"
619  " <ci> parameter_2 </ci>\n"
620  " </apply>\n"
621  " </math>\n"
622  " </rateRule>\n"
623  " <rateRule variable=\"species_6\">\n"
624  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
625  " <apply>\n"
626  " <ci> function_6 </ci>\n"
627  " <ci> parameter_3 </ci>\n"
628  " <ci> parameter_1 </ci>\n"
629  " <cn> 3.4 </cn>\n"
630  " </apply>\n"
631  " </math>\n"
632  " </rateRule>\n"
633  " </listOfRules>\n"
634  " <listOfReactions>\n"
635  " <reaction id=\"reaction1\" reversible=\"true\">\n"
636  " <listOfReactants>\n"
637  " <speciesReference species=\"species_1\"/>\n"
638  " </listOfReactants>\n"
639  " <listOfProducts>\n"
640  " <speciesReference species=\"species_2\"/>\n"
641  " </listOfProducts>\n"
642  " <kineticLaw>\n"
643  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
644  " <apply>\n"
645  " <times/>\n"
646  " <ci> compartment_1 </ci>\n"
647  " <apply>\n"
648  " <ci> function_1 </ci>\n"
649  " <ci> parameter_1 </ci>\n"
650  " </apply>\n"
651  " </apply>\n"
652  " </math>\n"
653  " </kineticLaw>\n"
654  " </reaction>\n"
655  " <reaction id=\"reaction2\" reversible=\"true\">\n"
656  " <listOfReactants>\n"
657  " <speciesReference species=\"species_1\"/>\n"
658  " </listOfReactants>\n"
659  " <listOfProducts>\n"
660  " <speciesReference species=\"species_2\"/>\n"
661  " </listOfProducts>\n"
662  " <kineticLaw>\n"
663  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
664  " <apply>\n"
665  " <times/>\n"
666  " <ci> compartment_1 </ci>\n"
667  " <apply>\n"
668  " <ci> function_2 </ci>\n"
669  " <ci> parameter_1 </ci>\n"
670  " <ci> parameter_2 </ci>\n"
671  " </apply>\n"
672  " </apply>\n"
673  " </math>\n"
674  " </kineticLaw>\n"
675  " </reaction>\n"
676  " <reaction id=\"reaction3\" reversible=\"true\">\n"
677  " <listOfReactants>\n"
678  " <speciesReference species=\"species_1\"/>\n"
679  " </listOfReactants>\n"
680  " <listOfProducts>\n"
681  " <speciesReference species=\"species_2\"/>\n"
682  " </listOfProducts>\n"
683  " <kineticLaw>\n"
684  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
685  " <apply>\n"
686  " <times/>\n"
687  " <ci> compartment_1 </ci>\n"
688  " <apply>\n"
689  " <ci> function_3 </ci>\n"
690  " <ci> parameter_1 </ci>\n"
691  " <ci> species_2 </ci>\n"
692  " </apply>\n"
693  " </apply>\n"
694  " </math>\n"
695  " </kineticLaw>\n"
696  " </reaction>\n"
697  " <reaction id=\"reaction4\" reversible=\"true\">\n"
698  " <listOfReactants>\n"
699  " <speciesReference species=\"species_1\"/>\n"
700  " </listOfReactants>\n"
701  " <listOfProducts>\n"
702  " <speciesReference species=\"species_2\"/>\n"
703  " </listOfProducts>\n"
704  " <kineticLaw>\n"
705  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
706  " <apply>\n"
707  " <times/>\n"
708  " <ci> compartment_1 </ci>\n"
709  " <apply>\n"
710  " <ci> function_4 </ci>\n"
711  " <ci> species_1 </ci>\n"
712  " <ci> species_2 </ci>\n"
713  " </apply>\n"
714  " </apply>\n"
715  " </math>\n"
716  " </kineticLaw>\n"
717  " </reaction>\n"
718  " <reaction id=\"reaction5\" reversible=\"true\">\n"
719  " <listOfReactants>\n"
720  " <speciesReference species=\"species_1\"/>\n"
721  " </listOfReactants>\n"
722  " <listOfProducts>\n"
723  " <speciesReference species=\"species_2\"/>\n"
724  " </listOfProducts>\n"
725  " <kineticLaw>\n"
726  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
727  " <apply>\n"
728  " <times/>\n"
729  " <ci> compartment_1 </ci>\n"
730  " <apply>\n"
731  " <ci> function_5 </ci>\n"
732  " <ci> parameter_1 </ci>\n"
733  " <ci> parameter_3 </ci>\n"
734  " <ci> species_2 </ci>\n"
735  " </apply>\n"
736  " </apply>\n"
737  " </math>\n"
738  " </kineticLaw>\n"
739  " </reaction>\n"
740  " <reaction id=\"reaction6\" reversible=\"true\">\n"
741  " <listOfReactants>\n"
742  " <speciesReference species=\"species_1\"/>\n"
743  " </listOfReactants>\n"
744  " <listOfProducts>\n"
745  " <speciesReference species=\"species_2\"/>\n"
746  " </listOfProducts>\n"
747  " <kineticLaw>\n"
748  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
749  " <apply>\n"
750  " <times/>\n"
751  " <ci> compartment_1 </ci>\n"
752  " <apply>\n"
753  " <ci> function_6 </ci>\n"
754  " <ci> parameter_1 </ci>\n"
755  " <ci> parameter_2 </ci>\n"
756  " <ci> parameter_3 </ci>\n"
757  " </apply>\n"
758  " </apply>\n"
759  " </math>\n"
760  " </kineticLaw>\n"
761  " </reaction>\n"
762  " </listOfReactions>\n"
763  " </model>\n"
764  "</sbml>\n"
765  ;
Header file of class CExpression.
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static const char * MODEL_STRING1
Definition: test000068.h:33
bool newModel(CProcessReport *pProcessReport, const bool &deleteOldData)
Definition: CMetab.h:178
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000068.h:34
void tearDown()
Definition: test000068.cpp:41
static CCopasiDataModel * addDatamodel()
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
static void init(int argc, char *argv[], const bool &withGui=false)
Definition: CModel.h:50
void test_bug1068()
Definition: test000068.cpp:46
void setUp()
Definition: test000068.cpp:33