COPASI API  4.16.103
test000069.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 "test000069.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 /**
32  * These tests are supposed to make sure that assignments on a species with the
33  * hasOnlySubstanceUnits flag set are exported correctly.
34  * It tests rules and event assignments with and without the flag set.
35  */
36 CCopasiDataModel* test000069::pCOPASIDATAMODEL = NULL;
37 
39 {
40  // Create the root container.
41  CCopasiRootContainer::init(0, NULL, false);
42  // Create the global data model.
44 }
45 
47 {
49 }
50 
52 {
53  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
54  std::istringstream iss(test000069::MODEL_STRING1);
55  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
56  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
57  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
58  CPPUNIT_ASSERT(pDocument == NULL);
59  CModel* pModel = pDataModel->getModel();
60  CPPUNIT_ASSERT(pModel != NULL);
61  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::Mol);
62  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::l);
63  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
64  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
65  const CCompartment* pCompartment = pModel->getCompartments()[0];
66  CPPUNIT_ASSERT(pCompartment != NULL);
67  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
68  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 6);
69  // check metabolites
70  const CMetab* pMetab = pModel->getMetabolites()[0];
71  CPPUNIT_ASSERT(pMetab != NULL);
72  CPPUNIT_ASSERT(pMetab->getObjectName() == "A");
73  CPPUNIT_ASSERT(pMetab->getStatus() == CModelEntity::REACTIONS);
74  pMetab = pModel->getMetabolites()[1];
75  CPPUNIT_ASSERT(pMetab != NULL);
76  CPPUNIT_ASSERT(pMetab->getObjectName() == "B");
77  CPPUNIT_ASSERT(pMetab->getStatus() == CModelEntity::REACTIONS);
78 
79  pMetab = pModel->getMetabolites()[2];
80  CPPUNIT_ASSERT(pMetab != NULL);
81  CPPUNIT_ASSERT(pMetab->getObjectName() == "C");
82  CPPUNIT_ASSERT(pMetab->getStatus() == CModelEntity::ASSIGNMENT);
83  // check assignment
84  const CEvaluationTree* pTree = pMetab->getExpressionPtr();
85  CPPUNIT_ASSERT(pTree != NULL);
86  const CEvaluationNode* pRoot = pTree->getRoot();
87  CPPUNIT_ASSERT(pRoot != NULL);
88  CPPUNIT_ASSERT(dynamic_cast<const CEvaluationNodeCall*>(pRoot) != NULL);
89  CPPUNIT_ASSERT(dynamic_cast<const CEvaluationNodeCall*>(pRoot)->getData() == "function_5");
90 
91  pMetab = pModel->getMetabolites()[3];
92  CPPUNIT_ASSERT(pMetab != NULL);
93  CPPUNIT_ASSERT(pMetab->getObjectName() == "D");
94  CPPUNIT_ASSERT(pMetab->getStatus() == CModelEntity::ODE);
95  // check ode
96  pTree = pMetab->getExpressionPtr();
97  CPPUNIT_ASSERT(pTree != NULL);
98  pRoot = pTree->getRoot();
99  CPPUNIT_ASSERT(pRoot != NULL);
100  CPPUNIT_ASSERT(dynamic_cast<const CEvaluationNodeCall*>(pRoot) != NULL);
101  CPPUNIT_ASSERT(dynamic_cast<const CEvaluationNodeCall*>(pRoot)->getData() == "function_2");
102 
103  pMetab = pModel->getMetabolites()[4];
104  CPPUNIT_ASSERT(pMetab != NULL);
105  CPPUNIT_ASSERT(pMetab->getObjectName() == "E");
106  CPPUNIT_ASSERT(pMetab->getStatus() == CModelEntity::ODE);
107  // check ode
108  pTree = pMetab->getExpressionPtr();
109  CPPUNIT_ASSERT(pTree != NULL);
110  pRoot = pTree->getRoot();
111  CPPUNIT_ASSERT(pRoot != NULL);
112  CPPUNIT_ASSERT(dynamic_cast<const CEvaluationNodeCall*>(pRoot) != NULL);
113  CPPUNIT_ASSERT(dynamic_cast<const CEvaluationNodeCall*>(pRoot)->getData() == "function_4");
114 
115  pMetab = pModel->getMetabolites()[5];
116  CPPUNIT_ASSERT(pMetab != NULL);
117  CPPUNIT_ASSERT(pMetab->getObjectName() == "F");
118  CPPUNIT_ASSERT(pMetab->getStatus() == CModelEntity::ODE);
119  // check ode
120  pTree = pMetab->getExpressionPtr();
121  CPPUNIT_ASSERT(pTree != NULL);
122  pRoot = pTree->getRoot();
123  CPPUNIT_ASSERT(pRoot != NULL);
124  CPPUNIT_ASSERT(dynamic_cast<const CEvaluationNodeCall*>(pRoot) != NULL);
125  CPPUNIT_ASSERT(dynamic_cast<const CEvaluationNodeCall*>(pRoot)->getData() == "function_6");
126 
127  // check model values
128  CPPUNIT_ASSERT(pModel->getModelValues().size() == 3);
129  const CModelValue* pModelValue = pModel->getModelValues()[0];
130  CPPUNIT_ASSERT(pModelValue != NULL);
131  CPPUNIT_ASSERT(pModelValue->getObjectName() == "K1");
132  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::ASSIGNMENT);
133  // check assignment
134  pTree = pModelValue->getExpressionPtr();
135  CPPUNIT_ASSERT(pTree != NULL);
136  pRoot = pTree->getRoot();
137  CPPUNIT_ASSERT(pRoot != NULL);
138  CPPUNIT_ASSERT(dynamic_cast<const CEvaluationNodeCall*>(pRoot) != NULL);
139  CPPUNIT_ASSERT(dynamic_cast<const CEvaluationNodeCall*>(pRoot)->getData() == "function_1");
140 
141  pModelValue = pModel->getModelValues()[1];
142  CPPUNIT_ASSERT(pModelValue != NULL);
143  CPPUNIT_ASSERT(pModelValue->getObjectName() == "K2");
144  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::FIXED);
145 
146  pModelValue = pModel->getModelValues()[2];
147  CPPUNIT_ASSERT(pModelValue != NULL);
148  CPPUNIT_ASSERT(pModelValue->getObjectName() == "K3");
149  // check assignment
150  pTree = pModelValue->getExpressionPtr();
151  CPPUNIT_ASSERT(pTree != NULL);
152  pRoot = pTree->getRoot();
153  CPPUNIT_ASSERT(pRoot != NULL);
154  CPPUNIT_ASSERT(dynamic_cast<const CEvaluationNodeCall*>(pRoot) != NULL);
155  CPPUNIT_ASSERT(dynamic_cast<const CEvaluationNodeCall*>(pRoot)->getData() == "function_3");
156 
157  CPPUNIT_ASSERT(pModel->getReactions().size() == 6);
158  // check reactions
159  const CReaction* pReaction = pModel->getReactions()[0];
160  CPPUNIT_ASSERT(pReaction != NULL);
161  CPPUNIT_ASSERT(pReaction->getChemEq().getSubstrates().size() == 1);
162  CPPUNIT_ASSERT(pReaction->getChemEq().getProducts().size() == 1);
163  CPPUNIT_ASSERT(pReaction->getChemEq().getModifiers().size() == 0);
164  CPPUNIT_ASSERT(pReaction->isReversible() == true);
165  // check the kinetic law
166  CPPUNIT_ASSERT(pReaction->getParameters().size() == 1);
167  const CFunction* pFunction = pReaction->getFunction();
168  CPPUNIT_ASSERT(pFunction != NULL);
169  CPPUNIT_ASSERT(pFunction->getType() == CEvaluationTree::UserDefined);
170  CPPUNIT_ASSERT(pFunction->getObjectName() == "Function for reaction1");
171  pRoot = pFunction->getRoot();
172  CPPUNIT_ASSERT(pRoot != NULL);
173 
174  pReaction = pModel->getReactions()[1];
175  CPPUNIT_ASSERT(pReaction != NULL);
176  CPPUNIT_ASSERT(pReaction->getChemEq().getSubstrates().size() == 1);
177  CPPUNIT_ASSERT(pReaction->getChemEq().getProducts().size() == 1);
178  CPPUNIT_ASSERT(pReaction->getChemEq().getModifiers().size() == 0);
179  CPPUNIT_ASSERT(pReaction->isReversible() == true);
180  // check the kinetic law
181  CPPUNIT_ASSERT(pReaction->getParameters().size() == 2);
182  pFunction = pReaction->getFunction();
183  CPPUNIT_ASSERT(pFunction != NULL);
184  CPPUNIT_ASSERT(pFunction->getType() == CEvaluationTree::UserDefined);
185  CPPUNIT_ASSERT(pFunction->getObjectName() == "Function for reaction2");
186  pRoot = pFunction->getRoot();
187  CPPUNIT_ASSERT(pRoot != NULL);
188 
189  pReaction = pModel->getReactions()[2];
190  CPPUNIT_ASSERT(pReaction != NULL);
191  CPPUNIT_ASSERT(pReaction->getChemEq().getSubstrates().size() == 1);
192  CPPUNIT_ASSERT(pReaction->getChemEq().getProducts().size() == 1);
193  CPPUNIT_ASSERT(pReaction->getChemEq().getModifiers().size() == 0);
194  CPPUNIT_ASSERT(pReaction->isReversible() == true);
195  // check the kinetic law
196  CPPUNIT_ASSERT(pReaction->getParameters().size() == 1);
197  pFunction = pReaction->getFunction();
198  CPPUNIT_ASSERT(pFunction != NULL);
199  CPPUNIT_ASSERT(pFunction->getType() == CEvaluationTree::UserDefined);
200  CPPUNIT_ASSERT(pFunction->getObjectName() == "Function for reaction3");
201  pRoot = pFunction->getRoot();
202  CPPUNIT_ASSERT(pRoot != NULL);
203 
204  pReaction = pModel->getReactions()[3];
205  CPPUNIT_ASSERT(pReaction != NULL);
206  CPPUNIT_ASSERT(pReaction->getChemEq().getSubstrates().size() == 1);
207  CPPUNIT_ASSERT(pReaction->getChemEq().getProducts().size() == 1);
208  CPPUNIT_ASSERT(pReaction->getChemEq().getModifiers().size() == 0);
209  CPPUNIT_ASSERT(pReaction->isReversible() == true);
210  // check the kinetic law
211  CPPUNIT_ASSERT(pReaction->getParameters().size() == 0);
212  pFunction = pReaction->getFunction();
213  CPPUNIT_ASSERT(pFunction != NULL);
214  CPPUNIT_ASSERT(pFunction->getType() == CEvaluationTree::UserDefined);
215  CPPUNIT_ASSERT(pFunction->getObjectName() == "Function for reaction4");
216  pRoot = pFunction->getRoot();
217  CPPUNIT_ASSERT(pRoot != NULL);
218 
219  pReaction = pModel->getReactions()[4];
220  CPPUNIT_ASSERT(pReaction != NULL);
221  CPPUNIT_ASSERT(pReaction->getChemEq().getSubstrates().size() == 1);
222  CPPUNIT_ASSERT(pReaction->getChemEq().getProducts().size() == 1);
223  CPPUNIT_ASSERT(pReaction->getChemEq().getModifiers().size() == 0);
224  CPPUNIT_ASSERT(pReaction->isReversible() == true);
225  // check the kinetic law
226  CPPUNIT_ASSERT(pReaction->getParameters().size() == 2);
227  pFunction = pReaction->getFunction();
228  CPPUNIT_ASSERT(pFunction != NULL);
229  CPPUNIT_ASSERT(pFunction->getType() == CEvaluationTree::UserDefined);
230  CPPUNIT_ASSERT(pFunction->getObjectName() == "Function for reaction5");
231  pRoot = pFunction->getRoot();
232  CPPUNIT_ASSERT(pRoot != NULL);
233 
234  pReaction = pModel->getReactions()[5];
235  CPPUNIT_ASSERT(pReaction != NULL);
236  CPPUNIT_ASSERT(pReaction->getChemEq().getSubstrates().size() == 1);
237  CPPUNIT_ASSERT(pReaction->getChemEq().getProducts().size() == 1);
238  CPPUNIT_ASSERT(pReaction->getChemEq().getModifiers().size() == 0);
239  CPPUNIT_ASSERT(pReaction->isReversible() == true);
240  // check the kinetic law
241  CPPUNIT_ASSERT(pReaction->getParameters().size() == 3);
242  pFunction = pReaction->getFunction();
243  CPPUNIT_ASSERT(pFunction != NULL);
244  CPPUNIT_ASSERT(pFunction->getType() == CEvaluationTree::UserDefined);
245  CPPUNIT_ASSERT(pFunction->getObjectName() == "Function for reaction6");
246  pRoot = pFunction->getRoot();
247  CPPUNIT_ASSERT(pRoot != NULL);
248 
249  // export to SBML
250  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 1, 2).empty() == false);
251  // check the sbml model
253  CPPUNIT_ASSERT(pDocument != NULL);
254  CPPUNIT_ASSERT(pDocument->getLevel() == 1);
255  CPPUNIT_ASSERT(pDocument->getVersion() == 2);
256  const Model* pSBMLModel = pDocument->getModel();
257  CPPUNIT_ASSERT(pSBMLModel != NULL);
258 
259  CPPUNIT_ASSERT(pSBMLModel->getListOfFunctionDefinitions()->size() == 0);
260  CPPUNIT_ASSERT(pSBMLModel->getListOfCompartments()->size() == 1);
261  CPPUNIT_ASSERT(pSBMLModel->getListOfSpecies()->size() == 6);
262  CPPUNIT_ASSERT(pSBMLModel->getListOfParameters()->size() == 3);
263  CPPUNIT_ASSERT(pSBMLModel->getListOfRules()->size() == 6);
264  CPPUNIT_ASSERT(pSBMLModel->getListOfReactions()->size() == 6);
265 
266  std::map<std::string, const Rule*> ruleMap;
267  unsigned int i, iMax = pSBMLModel->getListOfRules()->size();
268  const Rule* pRule = NULL;
269 
270  for (i = 0; i < iMax; ++i)
271  {
272  pRule = pSBMLModel->getRule(i);
273  ruleMap.insert(std::pair<std::string, const Rule*>(pRule->getVariable(), pRule));
274  }
275 
276  // check the rules
277  std::map<std::string, const Rule*>::const_iterator pos = ruleMap.find("parameter_1");
278  CPPUNIT_ASSERT(pos != ruleMap.end());
279  pRule = pos->second;
280  CPPUNIT_ASSERT(pRule != NULL);
281  CPPUNIT_ASSERT(pRule->getVariable() == "parameter_1");
282  const ASTNode* pMath = pRule->getMath();
283  CPPUNIT_ASSERT(pMath != NULL);
284  // only check the infix
285  std::string formula = pRule->getFormula();
286  CPPUNIT_ASSERT(formula == "3 * 4.5");
287 
288  pos = ruleMap.find("parameter_3");
289  CPPUNIT_ASSERT(pos != ruleMap.end());
290  pRule = pos->second;
291  CPPUNIT_ASSERT(pRule != NULL);
292  CPPUNIT_ASSERT(pRule->getVariable() == "parameter_3");
293  pRule->getMath();
294  CPPUNIT_ASSERT(pMath != NULL);
295  // only check the infix
296  formula = pRule->getFormula();
297  CPPUNIT_ASSERT(formula == "parameter_1 - 2 * 1.3");
298 
299  pos = ruleMap.find("species_3");
300  CPPUNIT_ASSERT(pos != ruleMap.end());
301  pRule = pos->second;
302  CPPUNIT_ASSERT(pRule != NULL);
303  CPPUNIT_ASSERT(pRule->getVariable() == "species_3");
304  pRule->getMath();
305  CPPUNIT_ASSERT(pMath != NULL);
306  // only check the infix
307  formula = pRule->getFormula();
308  CPPUNIT_ASSERT(formula == "parameter_1 - 3.5 * 1.3 + (3 * 2.4 - 5.23)");
309 
310  pos = ruleMap.find("species_4");
311  CPPUNIT_ASSERT(pos != ruleMap.end());
312  pRule = pos->second;
313  CPPUNIT_ASSERT(pRule != NULL);
314  CPPUNIT_ASSERT(pRule->getVariable() == "species_4");
315  pRule->getMath();
316  CPPUNIT_ASSERT(pMath != NULL);
317  // only check the infix
318  formula = pRule->getFormula();
319  CPPUNIT_ASSERT(formula == "3.4 + parameter_1");
320 
321  pos = ruleMap.find("species_5");
322  CPPUNIT_ASSERT(pos != ruleMap.end());
323  pRule = pos->second;
324  CPPUNIT_ASSERT(pRule != NULL);
325  CPPUNIT_ASSERT(pRule->getVariable() == "species_5");
326  pRule->getMath();
327  CPPUNIT_ASSERT(pMath != NULL);
328  // only check the infix
329  formula = pRule->getFormula();
330  CPPUNIT_ASSERT(formula == "(parameter_2 + 1.4) / 2");
331 
332  pos = ruleMap.find("species_6");
333  CPPUNIT_ASSERT(pos != ruleMap.end());
334  pRule = pos->second;
335  CPPUNIT_ASSERT(pRule != NULL);
336  CPPUNIT_ASSERT(pRule->getVariable() == "species_6");
337  pRule->getMath();
338  CPPUNIT_ASSERT(pMath != NULL);
339  // only check the infix
340  formula = pRule->getFormula();
341  CPPUNIT_ASSERT(formula == "parameter_3 - 3.4 * 1.3 + (3 * parameter_1 - 5.23)");
342 
343  // check the reactions
344  const Reaction* pSBMLReaction = pSBMLModel->getReaction(0);
345  CPPUNIT_ASSERT(pSBMLReaction != NULL);
346  CPPUNIT_ASSERT(pSBMLReaction->getListOfReactants()->size() == 1);
347  CPPUNIT_ASSERT(pSBMLReaction->getListOfProducts()->size() == 1);
348  CPPUNIT_ASSERT(pSBMLReaction->getListOfModifiers()->size() == 0);
349  CPPUNIT_ASSERT(pSBMLReaction->getReversible() == true);
350  CPPUNIT_ASSERT(pSBMLReaction->getKineticLaw() != NULL);
351  CPPUNIT_ASSERT(pSBMLReaction->getKineticLaw()->getListOfParameters()->size() == 0);
352  pMath = pSBMLReaction->getKineticLaw()->getMath();
353  CPPUNIT_ASSERT(pMath != NULL);
354  formula = pSBMLReaction->getKineticLaw()->getFormula();
355  CPPUNIT_ASSERT(formula == "compartment_1 * 3 * parameter_1");
356 
357  pSBMLReaction = pSBMLModel->getReaction(1);
358  CPPUNIT_ASSERT(pSBMLReaction != NULL);
359  CPPUNIT_ASSERT(pSBMLReaction->getListOfReactants()->size() == 1);
360  CPPUNIT_ASSERT(pSBMLReaction->getListOfProducts()->size() == 1);
361  CPPUNIT_ASSERT(pSBMLReaction->getListOfModifiers()->size() == 0);
362  CPPUNIT_ASSERT(pSBMLReaction->getReversible() == true);
363  CPPUNIT_ASSERT(pSBMLReaction->getKineticLaw() != NULL);
364  CPPUNIT_ASSERT(pSBMLReaction->getKineticLaw()->getListOfParameters()->size() == 0);
365  pMath = pSBMLReaction->getKineticLaw()->getMath();
366  CPPUNIT_ASSERT(pMath != NULL);
367  formula = pSBMLReaction->getKineticLaw()->getFormula();
368  CPPUNIT_ASSERT(formula == "compartment_1 * (parameter_2 + parameter_1)");
369 
370  pSBMLReaction = pSBMLModel->getReaction(2);
371  CPPUNIT_ASSERT(pSBMLReaction != NULL);
372  CPPUNIT_ASSERT(pSBMLReaction->getListOfReactants()->size() == 1);
373  CPPUNIT_ASSERT(pSBMLReaction->getListOfProducts()->size() == 1);
374  CPPUNIT_ASSERT(pSBMLReaction->getListOfModifiers()->size() == 0);
375  CPPUNIT_ASSERT(pSBMLReaction->getReversible() == true);
376  CPPUNIT_ASSERT(pSBMLReaction->getKineticLaw() != NULL);
377  CPPUNIT_ASSERT(pSBMLReaction->getKineticLaw()->getListOfParameters()->size() == 0);
378  pMath = pSBMLReaction->getKineticLaw()->getMath();
379  CPPUNIT_ASSERT(pMath != NULL);
380  formula = pSBMLReaction->getKineticLaw()->getFormula();
381  CPPUNIT_ASSERT(formula == "compartment_1 * (species_2 - parameter_1 * 1.3)");
382 
383  pSBMLReaction = pSBMLModel->getReaction(3);
384  CPPUNIT_ASSERT(pSBMLReaction != NULL);
385  CPPUNIT_ASSERT(pSBMLReaction->getListOfReactants()->size() == 1);
386  CPPUNIT_ASSERT(pSBMLReaction->getListOfProducts()->size() == 1);
387  CPPUNIT_ASSERT(pSBMLReaction->getListOfModifiers()->size() == 0);
388  CPPUNIT_ASSERT(pSBMLReaction->getReversible() == true);
389  CPPUNIT_ASSERT(pSBMLReaction->getKineticLaw() != NULL);
390  CPPUNIT_ASSERT(pSBMLReaction->getKineticLaw()->getListOfParameters()->size() == 0);
391  pMath = pSBMLReaction->getKineticLaw()->getMath();
392  CPPUNIT_ASSERT(pMath != NULL);
393  formula = pSBMLReaction->getKineticLaw()->getFormula();
394  CPPUNIT_ASSERT(formula == "compartment_1 * ((species_2 + species_1) / 2)");
395 
396  pSBMLReaction = pSBMLModel->getReaction(4);
397  CPPUNIT_ASSERT(pSBMLReaction != NULL);
398  CPPUNIT_ASSERT(pSBMLReaction->getListOfReactants()->size() == 1);
399  CPPUNIT_ASSERT(pSBMLReaction->getListOfProducts()->size() == 1);
400  CPPUNIT_ASSERT(pSBMLReaction->getListOfModifiers()->size() == 0);
401  CPPUNIT_ASSERT(pSBMLReaction->getReversible() == true);
402  CPPUNIT_ASSERT(pSBMLReaction->getKineticLaw() != NULL);
403  CPPUNIT_ASSERT(pSBMLReaction->getKineticLaw()->getListOfParameters()->size() == 0);
404  pMath = pSBMLReaction->getKineticLaw()->getMath();
405  CPPUNIT_ASSERT(pMath != NULL);
406  formula = pSBMLReaction->getKineticLaw()->getFormula();
407  CPPUNIT_ASSERT(formula == "compartment_1 * (parameter_1 - species_2 * 1.3 + (3 * parameter_3 - 5.23))");
408 
409  pSBMLReaction = pSBMLModel->getReaction(5);
410  CPPUNIT_ASSERT(pSBMLReaction != NULL);
411  CPPUNIT_ASSERT(pSBMLReaction->getListOfReactants()->size() == 1);
412  CPPUNIT_ASSERT(pSBMLReaction->getListOfProducts()->size() == 1);
413  CPPUNIT_ASSERT(pSBMLReaction->getListOfModifiers()->size() == 0);
414  CPPUNIT_ASSERT(pSBMLReaction->getReversible() == true);
415  CPPUNIT_ASSERT(pSBMLReaction->getKineticLaw() != NULL);
416  CPPUNIT_ASSERT(pSBMLReaction->getKineticLaw()->getListOfParameters()->size() == 0);
417  pMath = pSBMLReaction->getKineticLaw()->getMath();
418  CPPUNIT_ASSERT(pMath != NULL);
419  formula = pSBMLReaction->getKineticLaw()->getFormula();
420  CPPUNIT_ASSERT(formula == "compartment_1 * (parameter_1 - parameter_3 * 1.3 + (3 * parameter_2 - 5.23))");
421 }
422 
423 const char* test000069::MODEL_STRING1 =
424  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
425  "<!-- generated with COPASI 4.4.27 (Debug) (http://www.copasi.org) at 2008-08-30 15:28:23 UTC -->\n"
426  "<COPASI xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://www.copasi.org/static/schema.xsd\" versionMajor=\"1\" versionMinor=\"0\" versionDevel=\"27\">\n"
427  " <ListOfFunctions>\n"
428  " <Function key=\"Function_37\" name=\"function_1\" type=\"UserDefined\" reversible=\"unspecified\">\n"
429  " <Expression>\n"
430  " 3*k\n"
431  " </Expression>\n"
432  " <ListOfParameterDescriptions>\n"
433  " <ParameterDescription key=\"FunctionParameter_260\" name=\"k\" order=\"0\" role=\"variable\"/>\n"
434  " </ListOfParameterDescriptions>\n"
435  " </Function>\n"
436  " <Function key=\"Function_38\" name=\"function_2\" type=\"UserDefined\" reversible=\"unspecified\">\n"
437  " <Expression>\n"
438  " B+A\n"
439  " </Expression>\n"
440  " <ListOfParameterDescriptions>\n"
441  " <ParameterDescription key=\"FunctionParameter_258\" name=\"A\" order=\"0\" role=\"variable\"/>\n"
442  " <ParameterDescription key=\"FunctionParameter_243\" name=\"B\" order=\"1\" role=\"variable\"/>\n"
443  " </ListOfParameterDescriptions>\n"
444  " </Function>\n"
445  " <Function key=\"Function_39\" name=\"function_3\" type=\"UserDefined\" reversible=\"unspecified\">\n"
446  " <Expression>\n"
447  " C-k*1.3\n"
448  " </Expression>\n"
449  " <ListOfParameterDescriptions>\n"
450  " <ParameterDescription key=\"FunctionParameter_246\" name=\"k\" order=\"0\" role=\"variable\"/>\n"
451  " <ParameterDescription key=\"FunctionParameter_250\" name=\"C\" order=\"1\" role=\"variable\"/>\n"
452  " </ListOfParameterDescriptions>\n"
453  " </Function>\n"
454  " <Function key=\"Function_40\" name=\"function_4\" type=\"UserDefined\" reversible=\"unspecified\">\n"
455  " <Expression>\n"
456  " function_2(x,y)/2\n"
457  " </Expression>\n"
458  " <ListOfParameterDescriptions>\n"
459  " <ParameterDescription key=\"FunctionParameter_254\" name=\"x\" order=\"0\" role=\"variable\"/>\n"
460  " <ParameterDescription key=\"FunctionParameter_261\" name=\"y\" order=\"1\" role=\"variable\"/>\n"
461  " </ListOfParameterDescriptions>\n"
462  " </Function>\n"
463  " <Function key=\"Function_41\" name=\"function_5\" type=\"UserDefined\" reversible=\"unspecified\">\n"
464  " <Expression>\n"
465  " function_3(c,a)+(function_1(b)-5.23)\n"
466  " </Expression>\n"
467  " <ListOfParameterDescriptions>\n"
468  " <ParameterDescription key=\"FunctionParameter_262\" name=\"a\" order=\"0\" role=\"variable\"/>\n"
469  " <ParameterDescription key=\"FunctionParameter_263\" name=\"b\" order=\"1\" role=\"variable\"/>\n"
470  " <ParameterDescription key=\"FunctionParameter_264\" name=\"c\" order=\"2\" role=\"variable\"/>\n"
471  " </ListOfParameterDescriptions>\n"
472  " </Function>\n"
473  " <Function key=\"Function_42\" name=\"function_6\" type=\"UserDefined\" reversible=\"unspecified\">\n"
474  " <Expression>\n"
475  " function_5(k1,k2,k3)\n"
476  " </Expression>\n"
477  " <ListOfParameterDescriptions>\n"
478  " <ParameterDescription key=\"FunctionParameter_265\" name=\"k1\" order=\"0\" role=\"variable\"/>\n"
479  " <ParameterDescription key=\"FunctionParameter_266\" name=\"k2\" order=\"1\" role=\"variable\"/>\n"
480  " <ParameterDescription key=\"FunctionParameter_267\" name=\"k3\" order=\"2\" role=\"variable\"/>\n"
481  " </ListOfParameterDescriptions>\n"
482  " </Function>\n"
483  " <Function key=\"Function_54\" name=\"Function for reaction1\" type=\"UserDefined\" reversible=\"unspecified\">\n"
484  " <Expression>\n"
485  " 3*parameter_1\n"
486  " </Expression>\n"
487  " <ListOfParameterDescriptions>\n"
488  " <ParameterDescription key=\"FunctionParameter_269\" name=\"parameter_1\" order=\"0\" role=\"constant\"/>\n"
489  " </ListOfParameterDescriptions>\n"
490  " </Function>\n"
491  " <Function key=\"Function_55\" name=\"Function for reaction2\" type=\"UserDefined\" reversible=\"unspecified\">\n"
492  " <Expression>\n"
493  " parameter_2+parameter_1\n"
494  " </Expression>\n"
495  " <ListOfParameterDescriptions>\n"
496  " <ParameterDescription key=\"FunctionParameter_272\" name=\"parameter_1\" order=\"0\" role=\"constant\"/>\n"
497  " <ParameterDescription key=\"FunctionParameter_273\" name=\"parameter_2\" order=\"1\" role=\"constant\"/>\n"
498  " </ListOfParameterDescriptions>\n"
499  " </Function>\n"
500  " <Function key=\"Function_56\" name=\"Function for reaction3\" type=\"UserDefined\" reversible=\"unspecified\">\n"
501  " <Expression>\n"
502  " species_2-parameter_1*1.3\n"
503  " </Expression>\n"
504  " <ListOfParameterDescriptions>\n"
505  " <ParameterDescription key=\"FunctionParameter_276\" name=\"parameter_1\" order=\"0\" role=\"constant\"/>\n"
506  " <ParameterDescription key=\"FunctionParameter_277\" name=\"species_2\" order=\"1\" role=\"product\"/>\n"
507  " </ListOfParameterDescriptions>\n"
508  " </Function>\n"
509  " <Function key=\"Function_57\" name=\"Function for reaction4\" type=\"UserDefined\" reversible=\"true\">\n"
510  " <Expression>\n"
511  " function_2(species_1,species_2)/2\n"
512  " </Expression>\n"
513  " <ListOfParameterDescriptions>\n"
514  " <ParameterDescription key=\"FunctionParameter_280\" name=\"species_1\" order=\"0\" role=\"substrate\"/>\n"
515  " <ParameterDescription key=\"FunctionParameter_281\" name=\"species_2\" order=\"1\" role=\"product\"/>\n"
516  " </ListOfParameterDescriptions>\n"
517  " </Function>\n"
518  " <Function key=\"Function_58\" name=\"Function for reaction5\" type=\"UserDefined\" reversible=\"unspecified\">\n"
519  " <Expression>\n"
520  " function_3(species_2,parameter_1)+(function_1(parameter_3)-5.23)\n"
521  " </Expression>\n"
522  " <ListOfParameterDescriptions>\n"
523  " <ParameterDescription key=\"FunctionParameter_285\" name=\"parameter_1\" order=\"0\" role=\"constant\"/>\n"
524  " <ParameterDescription key=\"FunctionParameter_286\" name=\"parameter_3\" order=\"1\" role=\"constant\"/>\n"
525  " <ParameterDescription key=\"FunctionParameter_287\" name=\"species_2\" order=\"2\" role=\"product\"/>\n"
526  " </ListOfParameterDescriptions>\n"
527  " </Function>\n"
528  " <Function key=\"Function_59\" name=\"Function for reaction6\" type=\"UserDefined\" reversible=\"unspecified\">\n"
529  " <Expression>\n"
530  " function_5(parameter_1,parameter_2,parameter_3)\n"
531  " </Expression>\n"
532  " <ListOfParameterDescriptions>\n"
533  " <ParameterDescription key=\"FunctionParameter_291\" name=\"parameter_1\" order=\"0\" role=\"constant\"/>\n"
534  " <ParameterDescription key=\"FunctionParameter_292\" name=\"parameter_2\" order=\"1\" role=\"constant\"/>\n"
535  " <ParameterDescription key=\"FunctionParameter_293\" name=\"parameter_3\" order=\"2\" role=\"constant\"/>\n"
536  " </ListOfParameterDescriptions>\n"
537  " </Function>\n"
538  " </ListOfFunctions>\n"
539  " <Model key=\"Model_1\" name=\"New Model\" timeUnit=\"s\" volumeUnit=\"l\" quantityUnit=\"mol\" type=\"deterministic\">\n"
540  " <Comment>\n"
541  " <body xmlns=\"http://www.w3.org/1999/xhtml\">\n"
542  " <p>Model with function call in kinetics and rules.</p>\n"
543  " <p>This is to check function expansion for export to L1V2</p>\n"
544  "</body>\n"
545  "\n"
546  " </Comment>\n"
547  " <ListOfCompartments>\n"
548  " <Compartment key=\"Compartment_0\" name=\"compartment\" simulationType=\"fixed\">\n"
549  " </Compartment>\n"
550  " </ListOfCompartments>\n"
551  " <ListOfMetabolites>\n"
552  " <Metabolite key=\"Metabolite_0\" name=\"A\" simulationType=\"reactions\" compartment=\"Compartment_0\">\n"
553  " </Metabolite>\n"
554  " <Metabolite key=\"Metabolite_1\" name=\"B\" simulationType=\"reactions\" compartment=\"Compartment_0\">\n"
555  " </Metabolite>\n"
556  " <Metabolite key=\"Metabolite_2\" name=\"C\" simulationType=\"assignment\" compartment=\"Compartment_0\">\n"
557  " <Expression>\n"
558  " function_5(&lt;CN=Root,Model=New Model,Vector=Values[K1],Reference=Value&gt;,2.4,3.5)\n"
559  " </Expression>\n"
560  " </Metabolite>\n"
561  " <Metabolite key=\"Metabolite_3\" name=\"D\" simulationType=\"ode\" compartment=\"Compartment_0\">\n"
562  " <Expression>\n"
563  " function_2(&lt;CN=Root,Model=New Model,Vector=Values[K1],Reference=Value&gt;,3.4)\n"
564  " </Expression>\n"
565  " </Metabolite>\n"
566  " <Metabolite key=\"Metabolite_4\" name=\"E\" simulationType=\"ode\" compartment=\"Compartment_0\">\n"
567  " <Expression>\n"
568  " function_4(1.4,&lt;CN=Root,Model=New Model,Vector=Values[K2],Reference=Value&gt;)\n"
569  " </Expression>\n"
570  " </Metabolite>\n"
571  " <Metabolite key=\"Metabolite_5\" name=\"F\" simulationType=\"ode\" compartment=\"Compartment_0\">\n"
572  " <Expression>\n"
573  " function_6(&lt;CN=Root,Model=New Model,Vector=Values[K3],Reference=Value&gt;,&lt;CN=Root,Model=New Model,Vector=Values[K1],Reference=Value&gt;,3.4)\n"
574  " </Expression>\n"
575  " </Metabolite>\n"
576  " </ListOfMetabolites>\n"
577  " <ListOfModelValues>\n"
578  " <ModelValue key=\"ModelValue_0\" name=\"K1\" simulationType=\"assignment\">\n"
579  " <Expression>\n"
580  " function_1(4.5)\n"
581  " </Expression>\n"
582  " </ModelValue>\n"
583  " <ModelValue key=\"ModelValue_1\" name=\"K2\" simulationType=\"fixed\">\n"
584  " </ModelValue>\n"
585  " <ModelValue key=\"ModelValue_2\" name=\"K3\" simulationType=\"assignment\">\n"
586  " <Expression>\n"
587  " function_3(2,&lt;CN=Root,Model=New Model,Vector=Values[K1],Reference=Value&gt;)\n"
588  " </Expression>\n"
589  " </ModelValue>\n"
590  " </ListOfModelValues>\n"
591  " <ListOfReactions>\n"
592  " <Reaction key=\"Reaction_0\" name=\"reaction1\" reversible=\"true\">\n"
593  " <ListOfSubstrates>\n"
594  " <Substrate metabolite=\"Metabolite_0\" stoichiometry=\"1\"/>\n"
595  " </ListOfSubstrates>\n"
596  " <ListOfProducts>\n"
597  " <Product metabolite=\"Metabolite_1\" stoichiometry=\"1\"/>\n"
598  " </ListOfProducts>\n"
599  " <ListOfConstants>\n"
600  " <Constant key=\"Parameter_81\" name=\"parameter_1\" value=\"1\"/>\n"
601  " </ListOfConstants>\n"
602  " <KineticLaw function=\"Function_54\">\n"
603  " <ListOfCallParameters>\n"
604  " <CallParameter functionParameter=\"FunctionParameter_269\">\n"
605  " <SourceParameter reference=\"ModelValue_0\"/>\n"
606  " </CallParameter>\n"
607  " </ListOfCallParameters>\n"
608  " </KineticLaw>\n"
609  " </Reaction>\n"
610  " <Reaction key=\"Reaction_1\" name=\"reaction2\" reversible=\"true\">\n"
611  " <ListOfSubstrates>\n"
612  " <Substrate metabolite=\"Metabolite_0\" stoichiometry=\"1\"/>\n"
613  " </ListOfSubstrates>\n"
614  " <ListOfProducts>\n"
615  " <Product metabolite=\"Metabolite_1\" stoichiometry=\"1\"/>\n"
616  " </ListOfProducts>\n"
617  " <ListOfConstants>\n"
618  " <Constant key=\"Parameter_80\" name=\"parameter_1\" value=\"1\"/>\n"
619  " <Constant key=\"Parameter_79\" name=\"parameter_2\" value=\"1\"/>\n"
620  " </ListOfConstants>\n"
621  " <KineticLaw function=\"Function_55\">\n"
622  " <ListOfCallParameters>\n"
623  " <CallParameter functionParameter=\"FunctionParameter_272\">\n"
624  " <SourceParameter reference=\"ModelValue_0\"/>\n"
625  " </CallParameter>\n"
626  " <CallParameter functionParameter=\"FunctionParameter_273\">\n"
627  " <SourceParameter reference=\"ModelValue_1\"/>\n"
628  " </CallParameter>\n"
629  " </ListOfCallParameters>\n"
630  " </KineticLaw>\n"
631  " </Reaction>\n"
632  " <Reaction key=\"Reaction_2\" name=\"reaction3\" reversible=\"true\">\n"
633  " <ListOfSubstrates>\n"
634  " <Substrate metabolite=\"Metabolite_0\" stoichiometry=\"1\"/>\n"
635  " </ListOfSubstrates>\n"
636  " <ListOfProducts>\n"
637  " <Product metabolite=\"Metabolite_1\" stoichiometry=\"1\"/>\n"
638  " </ListOfProducts>\n"
639  " <ListOfConstants>\n"
640  " <Constant key=\"Parameter_78\" name=\"parameter_1\" value=\"1\"/>\n"
641  " </ListOfConstants>\n"
642  " <KineticLaw function=\"Function_56\">\n"
643  " <ListOfCallParameters>\n"
644  " <CallParameter functionParameter=\"FunctionParameter_276\">\n"
645  " <SourceParameter reference=\"ModelValue_0\"/>\n"
646  " </CallParameter>\n"
647  " <CallParameter functionParameter=\"FunctionParameter_277\">\n"
648  " <SourceParameter reference=\"Metabolite_1\"/>\n"
649  " </CallParameter>\n"
650  " </ListOfCallParameters>\n"
651  " </KineticLaw>\n"
652  " </Reaction>\n"
653  " <Reaction key=\"Reaction_3\" name=\"reaction4\" reversible=\"true\">\n"
654  " <ListOfSubstrates>\n"
655  " <Substrate metabolite=\"Metabolite_0\" stoichiometry=\"1\"/>\n"
656  " </ListOfSubstrates>\n"
657  " <ListOfProducts>\n"
658  " <Product metabolite=\"Metabolite_1\" stoichiometry=\"1\"/>\n"
659  " </ListOfProducts>\n"
660  " <KineticLaw function=\"Function_57\">\n"
661  " <ListOfCallParameters>\n"
662  " <CallParameter functionParameter=\"FunctionParameter_280\">\n"
663  " <SourceParameter reference=\"Metabolite_0\"/>\n"
664  " </CallParameter>\n"
665  " <CallParameter functionParameter=\"FunctionParameter_281\">\n"
666  " <SourceParameter reference=\"Metabolite_1\"/>\n"
667  " </CallParameter>\n"
668  " </ListOfCallParameters>\n"
669  " </KineticLaw>\n"
670  " </Reaction>\n"
671  " <Reaction key=\"Reaction_4\" name=\"reaction5\" reversible=\"true\">\n"
672  " <ListOfSubstrates>\n"
673  " <Substrate metabolite=\"Metabolite_0\" stoichiometry=\"1\"/>\n"
674  " </ListOfSubstrates>\n"
675  " <ListOfProducts>\n"
676  " <Product metabolite=\"Metabolite_1\" stoichiometry=\"1\"/>\n"
677  " </ListOfProducts>\n"
678  " <ListOfConstants>\n"
679  " <Constant key=\"Parameter_77\" name=\"parameter_1\" value=\"1\"/>\n"
680  " <Constant key=\"Parameter_76\" name=\"parameter_3\" value=\"1\"/>\n"
681  " </ListOfConstants>\n"
682  " <KineticLaw function=\"Function_58\">\n"
683  " <ListOfCallParameters>\n"
684  " <CallParameter functionParameter=\"FunctionParameter_285\">\n"
685  " <SourceParameter reference=\"ModelValue_0\"/>\n"
686  " </CallParameter>\n"
687  " <CallParameter functionParameter=\"FunctionParameter_286\">\n"
688  " <SourceParameter reference=\"ModelValue_2\"/>\n"
689  " </CallParameter>\n"
690  " <CallParameter functionParameter=\"FunctionParameter_287\">\n"
691  " <SourceParameter reference=\"Metabolite_1\"/>\n"
692  " </CallParameter>\n"
693  " </ListOfCallParameters>\n"
694  " </KineticLaw>\n"
695  " </Reaction>\n"
696  " <Reaction key=\"Reaction_5\" name=\"reaction6\" reversible=\"true\">\n"
697  " <ListOfSubstrates>\n"
698  " <Substrate metabolite=\"Metabolite_0\" stoichiometry=\"1\"/>\n"
699  " </ListOfSubstrates>\n"
700  " <ListOfProducts>\n"
701  " <Product metabolite=\"Metabolite_1\" stoichiometry=\"1\"/>\n"
702  " </ListOfProducts>\n"
703  " <ListOfConstants>\n"
704  " <Constant key=\"Parameter_67\" name=\"parameter_1\" value=\"1\"/>\n"
705  " <Constant key=\"Parameter_68\" name=\"parameter_2\" value=\"1\"/>\n"
706  " <Constant key=\"Parameter_71\" name=\"parameter_3\" value=\"1\"/>\n"
707  " </ListOfConstants>\n"
708  " <KineticLaw function=\"Function_59\">\n"
709  " <ListOfCallParameters>\n"
710  " <CallParameter functionParameter=\"FunctionParameter_291\">\n"
711  " <SourceParameter reference=\"ModelValue_0\"/>\n"
712  " </CallParameter>\n"
713  " <CallParameter functionParameter=\"FunctionParameter_292\">\n"
714  " <SourceParameter reference=\"ModelValue_1\"/>\n"
715  " </CallParameter>\n"
716  " <CallParameter functionParameter=\"FunctionParameter_293\">\n"
717  " <SourceParameter reference=\"ModelValue_2\"/>\n"
718  " </CallParameter>\n"
719  " </ListOfCallParameters>\n"
720  " </KineticLaw>\n"
721  " </Reaction>\n"
722  " </ListOfReactions>\n"
723  " <StateTemplate>\n"
724  " <StateTemplateVariable objectReference=\"Model_1\"/>\n"
725  " <StateTemplateVariable objectReference=\"Metabolite_3\"/>\n"
726  " <StateTemplateVariable objectReference=\"Metabolite_4\"/>\n"
727  " <StateTemplateVariable objectReference=\"Metabolite_5\"/>\n"
728  " <StateTemplateVariable objectReference=\"Metabolite_0\"/>\n"
729  " <StateTemplateVariable objectReference=\"Metabolite_1\"/>\n"
730  " <StateTemplateVariable objectReference=\"Metabolite_2\"/>\n"
731  " <StateTemplateVariable objectReference=\"ModelValue_0\"/>\n"
732  " <StateTemplateVariable objectReference=\"ModelValue_2\"/>\n"
733  " <StateTemplateVariable objectReference=\"ModelValue_1\"/>\n"
734  " <StateTemplateVariable objectReference=\"Compartment_0\"/>\n"
735  " </StateTemplate>\n"
736  " <InitialState type=\"initialState\">\n"
737  " 0 6.0221415e+23 6.0221415e+23 6.0221415e+23 6.0221415e+23 6.0221415e+23 6.0221415e+23 1.1 1.3 1.2 1\n"
738  " </InitialState>\n"
739  " </Model>\n"
740  "</COPASI>\n"
741  ;
Header file of class CExpression.
SBMLDocument * getCurrentSBMLDocument()
void setUp()
Definition: test000069.cpp:38
const CCopasiVector< CMetab > & getMetabolites() const
Definition: CModel.cpp:1051
const CCopasiVectorN< CModelValue > & getModelValues() const
Definition: CModel.cpp:1060
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
CModel::QuantityUnit getQuantityUnitEnum() const
Definition: CModel.cpp:2331
virtual size_t size() const
static const char * MODEL_STRING1
Definition: test000069.h:33
Definition: CMetab.h:178
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000069.h:34
void tearDown()
Definition: test000069.cpp:46
void test_bug1069()
Definition: test000069.cpp:51
static CCopasiDataModel * addDatamodel()
CCopasiVectorNS< CCompartment > & getCompartments()
Definition: CModel.cpp:1145
CModel::TimeUnit getTimeUnitEnum() const
Definition: CModel.cpp:2243
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
CCopasiVectorNS< CReaction > & getReactions()
Definition: CModel.cpp:1039
static void init(int argc, char *argv[], const bool &withGui=false)
Definition: CModel.h:50
CModel::VolumeUnit getVolumeUnitEnum() const
Definition: CModel.cpp:2175