COPASI API  4.16.103
test000066.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/sbml/unittests/test000066.cpp,v $
3 // $Revision: 1.5 $
4 // $Name: $
5 // $Author: gauges $
6 // $Date: 2010/03/11 11:52:00 $
7 // End CVS Header
8 
9 // Copyright (C) 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
16 // and The University of Manchester.
17 // All rights reserved.
18 
19 #include "test000066.h"
20 
21 #include <sstream>
22 #include "utilities.hpp"
24 #include "copasi/model/CModel.h"
25 #include "copasi/model/CMetab.h"
27 #include "copasi/model/CReaction.h"
30 
31 #include "sbml/SBMLDocument.h"
32 #include "sbml/Model.h"
33 #include "sbml/Reaction.h"
34 
36 
37 /**
38  * These tests are supposed to make sure that assignments on a species with the
39  * hasOnlySubstanceUnits flag set are exported correctly.
40  * It tests rules and event assignments with and without the flag set.
41  */
42 CCopasiDataModel* test000066::pCOPASIDATAMODEL = NULL;
43 
45 {
46  // Create the root container.
47  CCopasiRootContainer::init(0, NULL, false);
48  // Create the global data model.
50 }
51 
53 {
55 }
56 
58 {
59  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
60  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING1));
61  CModel* pModel = pDataModel->getModel();
62  CPPUNIT_ASSERT(pModel != NULL);
63  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
64  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
65  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
66  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
67  const CCompartment* pCompartment = pModel->getCompartments()[0];
68  CPPUNIT_ASSERT(pCompartment != NULL);
69  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
70  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
71  CPPUNIT_ASSERT(pModel->getModelValues().size() == 0);
72  CPPUNIT_ASSERT(pModel->getReactions().size() == 1);
73  const CReaction* pReaction = pModel->getReactions()[0];
74  CPPUNIT_ASSERT(pReaction != NULL);
75  CPPUNIT_ASSERT(pReaction->getChemEq().getSubstrates().size() == 0);
76  CPPUNIT_ASSERT(pReaction->getChemEq().getProducts().size() == 1);
77  CPPUNIT_ASSERT(pReaction->getChemEq().getModifiers().size() == 0);
78  CPPUNIT_ASSERT(pReaction->isReversible() == false);
79  // check for the local parameter
80  CPPUNIT_ASSERT(pReaction->getParameters().size() == 1);
81  const CCopasiParameter* pParameter = pReaction->getParameters().getParameter(0);
82  CPPUNIT_ASSERT(pReaction->isLocalParameter(0) == true);
83  CPPUNIT_ASSERT(pParameter != NULL);
84  CPPUNIT_ASSERT(pParameter->getType() == CCopasiParameter::DOUBLE);
85  CPPUNIT_ASSERT(fabs(((*(pParameter->getValue().pDOUBLE)) - 0.015) / 0.015) < 1e-12);
86  CPPUNIT_ASSERT(pParameter->getObjectName() == "v");
87  const CFunction* pFunction = pReaction->getFunction();
88  CPPUNIT_ASSERT(pFunction != NULL);
89  CPPUNIT_ASSERT(pFunction->getType() == CEvaluationTree::PreDefined);
90  CPPUNIT_ASSERT(pFunction->getObjectName() == "Constant flux (irreversible)");
91 }
92 
94 {
95  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
96  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING2));
97  CModel* pModel = pDataModel->getModel();
98  CPPUNIT_ASSERT(pModel != NULL);
99  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
100  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
101  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
102  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
103  const CCompartment* pCompartment = pModel->getCompartments()[0];
104  CPPUNIT_ASSERT(pCompartment != NULL);
105  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
106  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
107  CPPUNIT_ASSERT(pModel->getModelValues().size() == 0);
108  CPPUNIT_ASSERT(pModel->getReactions().size() == 1);
109  const CReaction* pReaction = pModel->getReactions()[0];
110  CPPUNIT_ASSERT(pReaction != NULL);
111  CPPUNIT_ASSERT(pReaction->getChemEq().getSubstrates().size() == 0);
112  CPPUNIT_ASSERT(pReaction->getChemEq().getProducts().size() == 1);
113  CPPUNIT_ASSERT(pReaction->getChemEq().getModifiers().size() == 0);
114  CPPUNIT_ASSERT(pReaction->isReversible() == false);
115  // check for the local parameter
116  CPPUNIT_ASSERT(pReaction->getParameters().size() == 1);
117  const CCopasiParameter* pParameter = pReaction->getParameters().getParameter(0);
118  CPPUNIT_ASSERT(pReaction->isLocalParameter(0) == true);
119  CPPUNIT_ASSERT(pParameter != NULL);
120  CPPUNIT_ASSERT(pParameter->getType() == CCopasiParameter::DOUBLE);
121  CPPUNIT_ASSERT(fabs(((*pParameter->getValue().pDOUBLE) - 0.015) / 0.015) < 1e-12);
122  CPPUNIT_ASSERT(pParameter->getObjectName() == "v");
123  const CFunction* pFunction = pReaction->getFunction();
124  CPPUNIT_ASSERT(pFunction != NULL);
125  CPPUNIT_ASSERT(pFunction->getType() == CEvaluationTree::PreDefined);
126  CPPUNIT_ASSERT(pFunction->getObjectName() == "Constant flux (irreversible)");
127 }
128 
129 const char* test000066::MODEL_STRING1 =
130  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
131  "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version3\" level=\"2\" version=\"3\">"
132  " <model id=\"Model_1\" name=\"New Model\">"
133  " <notes>"
134  " <body xmlns=\"http://www.w3.org/1999/xhtml\">"
135  " <p>Model with one reaction that has constant flux kinetics.</p>"
136  " </body>"
137  " </notes>"
138  " <listOfUnitDefinitions>"
139  " <unitDefinition id=\"volume\">"
140  " <listOfUnits>"
141  " <unit kind=\"litre\" scale=\"-3\"/>"
142  " </listOfUnits>"
143  " </unitDefinition>"
144  " <unitDefinition id=\"substance\">"
145  " <listOfUnits>"
146  " <unit kind=\"mole\" scale=\"-3\"/>"
147  " </listOfUnits>"
148  " </unitDefinition>"
149  " </listOfUnitDefinitions>"
150  " <listOfCompartments>"
151  " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>"
152  " </listOfCompartments>"
153  " <listOfSpecies>"
154  " <species id=\"species_1\" name=\"A\" compartment=\"compartment_1\" initialConcentration=\"1\"/>"
155  " </listOfSpecies>"
156  " <listOfReactions>"
157  " <reaction id=\"reaction1\" reversible=\"false\">"
158  " <listOfProducts>"
159  " <speciesReference species=\"species_1\"/>"
160  " </listOfProducts>"
161  " <kineticLaw>"
162  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
163  " <apply>"
164  " <times/>"
165  " <ci> compartment_1 </ci>"
166  " <ci> k </ci>"
167  " </apply>"
168  " </math>"
169  " <listOfParameters>"
170  " <parameter id=\"k\" value=\"0.015\"/>"
171  " </listOfParameters>"
172  " </kineticLaw>"
173  " </reaction>"
174  " </listOfReactions>"
175  " </model>"
176  "</sbml>"
177  ;
178 
179 const char* test000066::MODEL_STRING2 =
180  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
181  "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version3\" level=\"2\" version=\"3\">"
182  " <model id=\"Model_1\" name=\"New Model\">"
183  " <notes>"
184  " <body xmlns=\"http://www.w3.org/1999/xhtml\">"
185  " <p>Model with one reaction with constant flux kinetics.</p>"
186  " </body>"
187  " </notes>"
188  " <listOfFunctionDefinitions>"
189  " <functionDefinition id=\"function_1\" name=\"MM\">"
190  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
191  " <lambda>"
192  " <bvar>"
193  " <ci> k </ci>"
194  " </bvar>"
195  " <ci> k </ci>"
196  " </lambda>"
197  " </math>"
198  " </functionDefinition>"
199  " </listOfFunctionDefinitions>"
200  " <listOfUnitDefinitions>"
201  " <unitDefinition id=\"volume\">"
202  " <listOfUnits>"
203  " <unit kind=\"litre\" scale=\"-3\"/>"
204  " </listOfUnits>"
205  " </unitDefinition>"
206  " <unitDefinition id=\"substance\">"
207  " <listOfUnits>"
208  " <unit kind=\"mole\" scale=\"-3\"/>"
209  " </listOfUnits>"
210  " </unitDefinition>"
211  " </listOfUnitDefinitions>"
212  " <listOfCompartments>"
213  " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>"
214  " </listOfCompartments>"
215  " <listOfSpecies>"
216  " <species id=\"species_1\" name=\"A\" compartment=\"compartment_1\" initialConcentration=\"1\"/>"
217  " </listOfSpecies>"
218  " <listOfReactions>"
219  " <reaction id=\"reaction1\" reversible=\"false\">"
220  " <listOfProducts>"
221  " <speciesReference species=\"species_1\"/>"
222  " </listOfProducts>"
223  " <kineticLaw>"
224  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
225  " <apply>"
226  " <times/>"
227  " <ci> compartment_1 </ci>"
228  " <apply>"
229  " <ci> function_1 </ci>"
230  " <ci> k1 </ci>"
231  " </apply>"
232  " </apply>"
233  " </math>"
234  " <listOfParameters>"
235  " <parameter id=\"k1\" value=\"0.015\"/>"
236  " </listOfParameters>"
237  " </kineticLaw>"
238  " </reaction>"
239  " </listOfReactions>"
240  " </model>"
241  "</sbml>"
242  ;
243 
245 {
246  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
247  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING3));
248  CModel* pModel = pDataModel->getModel();
249  CPPUNIT_ASSERT(pModel != NULL);
250  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
251  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
252  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
253  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
254  const CCompartment* pCompartment = pModel->getCompartments()[0];
255  CPPUNIT_ASSERT(pCompartment != NULL);
256  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
257  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
258  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
259  CPPUNIT_ASSERT(pModel->getReactions().size() == 1);
260  const CReaction* pReaction = pModel->getReactions()[0];
261  CPPUNIT_ASSERT(pReaction != NULL);
262  CPPUNIT_ASSERT(pReaction->getChemEq().getSubstrates().size() == 0);
263  CPPUNIT_ASSERT(pReaction->getChemEq().getProducts().size() == 1);
264  CPPUNIT_ASSERT(pReaction->getChemEq().getModifiers().size() == 0);
265  CPPUNIT_ASSERT(pReaction->isReversible() == false);
266  // check for the global parameter
267  CPPUNIT_ASSERT(pReaction->getParameters().size() == 1);
268  CPPUNIT_ASSERT(pReaction->isLocalParameter(0) == false);
269  const CFunction* pFunction = pReaction->getFunction();
270  CPPUNIT_ASSERT(pFunction != NULL);
271  CPPUNIT_ASSERT(pFunction->getType() == CEvaluationTree::PreDefined);
272  CPPUNIT_ASSERT(pFunction->getObjectName() == "Constant flux (irreversible)");
273 }
274 
276 {
277  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
278  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING4));
279  CModel* pModel = pDataModel->getModel();
280  CPPUNIT_ASSERT(pModel != NULL);
281  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
282  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
283  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
284  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
285  const CCompartment* pCompartment = pModel->getCompartments()[0];
286  CPPUNIT_ASSERT(pCompartment != NULL);
287  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
288  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
289  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
290  CPPUNIT_ASSERT(pModel->getReactions().size() == 1);
291  const CReaction* pReaction = pModel->getReactions()[0];
292  CPPUNIT_ASSERT(pReaction != NULL);
293  CPPUNIT_ASSERT(pReaction->getChemEq().getSubstrates().size() == 0);
294  CPPUNIT_ASSERT(pReaction->getChemEq().getProducts().size() == 1);
295  CPPUNIT_ASSERT(pReaction->getChemEq().getModifiers().size() == 0);
296  CPPUNIT_ASSERT(pReaction->isReversible() == false);
297  // check for the global parameter
298  CPPUNIT_ASSERT(pReaction->getParameters().size() == 1);
299  CPPUNIT_ASSERT(pReaction->isLocalParameter(0) == false);
300  const CFunction* pFunction = pReaction->getFunction();
301  CPPUNIT_ASSERT(pFunction != NULL);
302  CPPUNIT_ASSERT(pFunction->getType() == CEvaluationTree::PreDefined);
303  CPPUNIT_ASSERT(pFunction->getObjectName() == "Constant flux (irreversible)");
304 }
305 
306 const char* test000066::MODEL_STRING3 =
307  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
308  "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version3\" level=\"2\" version=\"3\">"
309  " <model id=\"Model_1\" name=\"New Model\">"
310  " <notes>"
311  " <body xmlns=\"http://www.w3.org/1999/xhtml\">"
312  " <p>Model with one reaction that has constant flux kinetics.</p>"
313  " </body>"
314  " </notes>"
315  " <listOfUnitDefinitions>"
316  " <unitDefinition id=\"volume\">"
317  " <listOfUnits>"
318  " <unit kind=\"litre\" scale=\"-3\"/>"
319  " </listOfUnits>"
320  " </unitDefinition>"
321  " <unitDefinition id=\"substance\">"
322  " <listOfUnits>"
323  " <unit kind=\"mole\" scale=\"-3\"/>"
324  " </listOfUnits>"
325  " </unitDefinition>"
326  " </listOfUnitDefinitions>"
327  " <listOfCompartments>"
328  " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>"
329  " </listOfCompartments>"
330  " <listOfSpecies>"
331  " <species id=\"species_1\" name=\"A\" compartment=\"compartment_1\" initialConcentration=\"1\"/>"
332  " </listOfSpecies>"
333  " <listOfParameters>"
334  " <parameter id=\"parameter_1\" name=\"K\" value=\"1.3\"/>"
335  " </listOfParameters>"
336  " <listOfReactions>"
337  " <reaction id=\"reaction1\" reversible=\"false\">"
338  " <listOfProducts>"
339  " <speciesReference species=\"species_1\"/>"
340  " </listOfProducts>"
341  " <kineticLaw>"
342  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
343  " <apply>"
344  " <times/>"
345  " <ci> compartment_1 </ci>"
346  " <ci> parameter_1 </ci>"
347  " </apply>"
348  " </math>"
349  " </kineticLaw>"
350  " </reaction>"
351  " </listOfReactions>"
352  " </model>"
353  "</sbml>"
354  ;
355 
356 const char* test000066::MODEL_STRING4 =
357  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
358  "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version3\" level=\"2\" version=\"3\">"
359  " <model id=\"Model_1\" name=\"New Model\">"
360  " <notes>"
361  " <body xmlns=\"http://www.w3.org/1999/xhtml\">"
362  " <p>Model with one reaction with constant flux kinetics.</p>"
363  " </body>"
364  " </notes>"
365  " <listOfFunctionDefinitions>"
366  " <functionDefinition id=\"function_1\" name=\"MM\">"
367  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
368  " <lambda>"
369  " <bvar>"
370  " <ci> k </ci>"
371  " </bvar>"
372  " <ci> k </ci>"
373  " </lambda>"
374  " </math>"
375  " </functionDefinition>"
376  " </listOfFunctionDefinitions>"
377  " <listOfUnitDefinitions>"
378  " <unitDefinition id=\"volume\">"
379  " <listOfUnits>"
380  " <unit kind=\"litre\" scale=\"-3\"/>"
381  " </listOfUnits>"
382  " </unitDefinition>"
383  " <unitDefinition id=\"substance\">"
384  " <listOfUnits>"
385  " <unit kind=\"mole\" scale=\"-3\"/>"
386  " </listOfUnits>"
387  " </unitDefinition>"
388  " </listOfUnitDefinitions>"
389  " <listOfCompartments>"
390  " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>"
391  " </listOfCompartments>"
392  " <listOfSpecies>"
393  " <species id=\"species_1\" name=\"A\" compartment=\"compartment_1\" initialConcentration=\"1\"/>"
394  " </listOfSpecies>"
395  " <listOfParameters>"
396  " <parameter id=\"parameter_1\" name=\"K\" value=\"1.3\"/>"
397  " </listOfParameters>"
398  " <listOfReactions>"
399  " <reaction id=\"reaction1\" reversible=\"false\">"
400  " <listOfProducts>"
401  " <speciesReference species=\"species_1\"/>"
402  " </listOfProducts>"
403  " <kineticLaw>"
404  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
405  " <apply>"
406  " <times/>"
407  " <ci> compartment_1 </ci>"
408  " <apply>"
409  " <ci> function_1 </ci>"
410  " <ci> parameter_1 </ci>"
411  " </apply>"
412  " </apply>"
413  " </math>"
414  " </kineticLaw>"
415  " </reaction>"
416  " </listOfReactions>"
417  " </model>"
418  "</sbml>"
419  ;
420 
422 {
423  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
424  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING5));
425  CModel* pModel = pDataModel->getModel();
426  CPPUNIT_ASSERT(pModel != NULL);
427  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
428  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
429  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
430  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
431  const CCompartment* pCompartment = pModel->getCompartments()[0];
432  CPPUNIT_ASSERT(pCompartment != NULL);
433  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
434  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
435  CPPUNIT_ASSERT(pModel->getModelValues().size() == 0);
436  CPPUNIT_ASSERT(pModel->getReactions().size() == 1);
437  const CReaction* pReaction = pModel->getReactions()[0];
438  CPPUNIT_ASSERT(pReaction != NULL);
439  CPPUNIT_ASSERT(pReaction->getChemEq().getSubstrates().size() == 1);
440  CPPUNIT_ASSERT(pReaction->getChemEq().getProducts().size() == 1);
441  CPPUNIT_ASSERT(pReaction->getChemEq().getModifiers().size() == 0);
442  CPPUNIT_ASSERT(pReaction->isReversible() == true);
443  // check for the local parameter
444  CPPUNIT_ASSERT(pReaction->getParameters().size() == 1);
445  const CCopasiParameter* pParameter = pReaction->getParameters().getParameter(0);
446  CPPUNIT_ASSERT(pReaction->isLocalParameter(0) == true);
447  CPPUNIT_ASSERT(pParameter != NULL);
448  CPPUNIT_ASSERT(pParameter->getType() == CCopasiParameter::DOUBLE);
449  CPPUNIT_ASSERT(fabs(((*(pParameter->getValue().pDOUBLE)) - 0.015) / 0.015) < 1e-12);
450  CPPUNIT_ASSERT(pParameter->getObjectName() == "v");
451  const CFunction* pFunction = pReaction->getFunction();
452  CPPUNIT_ASSERT(pFunction != NULL);
453  CPPUNIT_ASSERT(pFunction->getType() == CEvaluationTree::PreDefined);
454  CPPUNIT_ASSERT(pFunction->getObjectName() == "Constant flux (reversible)");
455 }
456 
458 {
459  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
460  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING6));
461  CModel* pModel = pDataModel->getModel();
462  CPPUNIT_ASSERT(pModel != NULL);
463  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
464  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
465  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
466  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
467  const CCompartment* pCompartment = pModel->getCompartments()[0];
468  CPPUNIT_ASSERT(pCompartment != NULL);
469  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
470  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
471  CPPUNIT_ASSERT(pModel->getModelValues().size() == 0);
472  CPPUNIT_ASSERT(pModel->getReactions().size() == 1);
473  const CReaction* pReaction = pModel->getReactions()[0];
474  CPPUNIT_ASSERT(pReaction != NULL);
475  CPPUNIT_ASSERT(pReaction->getChemEq().getSubstrates().size() == 1);
476  CPPUNIT_ASSERT(pReaction->getChemEq().getProducts().size() == 1);
477  CPPUNIT_ASSERT(pReaction->getChemEq().getModifiers().size() == 0);
478  CPPUNIT_ASSERT(pReaction->isReversible() == true);
479  // check for the local parameter
480  CPPUNIT_ASSERT(pReaction->getParameters().size() == 1);
481  const CCopasiParameter* pParameter = pReaction->getParameters().getParameter(0);
482  CPPUNIT_ASSERT(pReaction->isLocalParameter(0) == true);
483  CPPUNIT_ASSERT(pParameter != NULL);
484  CPPUNIT_ASSERT(pParameter->getType() == CCopasiParameter::DOUBLE);
485  CPPUNIT_ASSERT(fabs(((*pParameter->getValue().pDOUBLE) - 0.015) / 0.015) < 1e-12);
486  CPPUNIT_ASSERT(pParameter->getObjectName() == "v");
487  const CFunction* pFunction = pReaction->getFunction();
488  CPPUNIT_ASSERT(pFunction != NULL);
489  CPPUNIT_ASSERT(pFunction->getType() == CEvaluationTree::PreDefined);
490  CPPUNIT_ASSERT(pFunction->getObjectName() == "Constant flux (reversible)");
491 }
492 
493 const char* test000066::MODEL_STRING5 =
494  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
495  "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version3\" level=\"2\" version=\"3\">"
496  " <model id=\"Model_1\" name=\"New Model\">"
497  " <notes>"
498  " <body xmlns=\"http://www.w3.org/1999/xhtml\">"
499  " <p>Model with one reaction that has constant flux kinetics.</p>"
500  " </body>"
501  " </notes>"
502  " <listOfUnitDefinitions>"
503  " <unitDefinition id=\"volume\">"
504  " <listOfUnits>"
505  " <unit kind=\"litre\" scale=\"-3\"/>"
506  " </listOfUnits>"
507  " </unitDefinition>"
508  " <unitDefinition id=\"substance\">"
509  " <listOfUnits>"
510  " <unit kind=\"mole\" scale=\"-3\"/>"
511  " </listOfUnits>"
512  " </unitDefinition>"
513  " </listOfUnitDefinitions>"
514  " <listOfCompartments>"
515  " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>"
516  " </listOfCompartments>"
517  " <listOfSpecies>"
518  " <species id=\"species_1\" name=\"A\" compartment=\"compartment_1\" initialConcentration=\"1\"/>"
519  " <species id=\"species_2\" name=\"B\" compartment=\"compartment_1\" initialConcentration=\"1\"/>"
520  " </listOfSpecies>"
521  " <listOfReactions>"
522  " <reaction id=\"reaction1\" reversible=\"true\">"
523  " <listOfReactants>"
524  " <speciesReference species=\"species_1\"/>"
525  " </listOfReactants>"
526  " <listOfProducts>"
527  " <speciesReference species=\"species_2\"/>"
528  " </listOfProducts>"
529  " <kineticLaw>"
530  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
531  " <apply>"
532  " <times/>"
533  " <ci> compartment_1 </ci>"
534  " <ci> k </ci>"
535  " </apply>"
536  " </math>"
537  " <listOfParameters>"
538  " <parameter id=\"k\" value=\"0.015\"/>"
539  " </listOfParameters>"
540  " </kineticLaw>"
541  " </reaction>"
542  " </listOfReactions>"
543  " </model>"
544  "</sbml>"
545  ;
546 
547 const char* test000066::MODEL_STRING6 =
548  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
549  "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version3\" level=\"2\" version=\"3\">"
550  " <model id=\"Model_1\" name=\"New Model\">"
551  " <notes>"
552  " <body xmlns=\"http://www.w3.org/1999/xhtml\">"
553  " <p>Model with one reaction with constant flux kinetics.</p>"
554  " </body>"
555  " </notes>"
556  " <listOfFunctionDefinitions>"
557  " <functionDefinition id=\"function_1\" name=\"MM\">"
558  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
559  " <lambda>"
560  " <bvar>"
561  " <ci> k </ci>"
562  " </bvar>"
563  " <ci> k </ci>"
564  " </lambda>"
565  " </math>"
566  " </functionDefinition>"
567  " </listOfFunctionDefinitions>"
568  " <listOfUnitDefinitions>"
569  " <unitDefinition id=\"volume\">"
570  " <listOfUnits>"
571  " <unit kind=\"litre\" scale=\"-3\"/>"
572  " </listOfUnits>"
573  " </unitDefinition>"
574  " <unitDefinition id=\"substance\">"
575  " <listOfUnits>"
576  " <unit kind=\"mole\" scale=\"-3\"/>"
577  " </listOfUnits>"
578  " </unitDefinition>"
579  " </listOfUnitDefinitions>"
580  " <listOfCompartments>"
581  " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>"
582  " </listOfCompartments>"
583  " <listOfSpecies>"
584  " <species id=\"species_1\" name=\"A\" compartment=\"compartment_1\" initialConcentration=\"1\"/>"
585  " <species id=\"species_2\" name=\"B\" compartment=\"compartment_1\" initialConcentration=\"1\"/>"
586  " </listOfSpecies>"
587  " <listOfReactions>"
588  " <reaction id=\"reaction1\" reversible=\"true\">"
589  " <listOfReactants>"
590  " <speciesReference species=\"species_1\"/>"
591  " </listOfReactants>"
592  " <listOfProducts>"
593  " <speciesReference species=\"species_2\"/>"
594  " </listOfProducts>"
595  " <kineticLaw>"
596  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
597  " <apply>"
598  " <times/>"
599  " <ci> compartment_1 </ci>"
600  " <apply>"
601  " <ci> function_1 </ci>"
602  " <ci> k1 </ci>"
603  " </apply>"
604  " </apply>"
605  " </math>"
606  " <listOfParameters>"
607  " <parameter id=\"k1\" value=\"0.015\"/>"
608  " </listOfParameters>"
609  " </kineticLaw>"
610  " </reaction>"
611  " </listOfReactions>"
612  " </model>"
613  "</sbml>"
614  ;
615 
617 {
618  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
619  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING7));
620  CModel* pModel = pDataModel->getModel();
621  CPPUNIT_ASSERT(pModel != NULL);
622  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
623  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
624  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
625  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
626  const CCompartment* pCompartment = pModel->getCompartments()[0];
627  CPPUNIT_ASSERT(pCompartment != NULL);
628  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
629  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
630  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
631  CPPUNIT_ASSERT(pModel->getReactions().size() == 1);
632  const CReaction* pReaction = pModel->getReactions()[0];
633  CPPUNIT_ASSERT(pReaction != NULL);
634  CPPUNIT_ASSERT(pReaction->getChemEq().getSubstrates().size() == 1);
635  CPPUNIT_ASSERT(pReaction->getChemEq().getProducts().size() == 1);
636  CPPUNIT_ASSERT(pReaction->getChemEq().getModifiers().size() == 0);
637  CPPUNIT_ASSERT(pReaction->isReversible() == true);
638  // check for the global parameter
639  CPPUNIT_ASSERT(pReaction->getParameters().size() == 1);
640  CPPUNIT_ASSERT(pReaction->isLocalParameter(0) == false);
641  const CFunction* pFunction = pReaction->getFunction();
642  CPPUNIT_ASSERT(pFunction != NULL);
643  CPPUNIT_ASSERT(pFunction->getType() == CEvaluationTree::PreDefined);
644  CPPUNIT_ASSERT(pFunction->getObjectName() == "Constant flux (reversible)");
645 }
646 
648 {
649  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
650  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING8));
651  CModel* pModel = pDataModel->getModel();
652  CPPUNIT_ASSERT(pModel != NULL);
653  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
654  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
655  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
656  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
657  const CCompartment* pCompartment = pModel->getCompartments()[0];
658  CPPUNIT_ASSERT(pCompartment != NULL);
659  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
660  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
661  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
662  CPPUNIT_ASSERT(pModel->getReactions().size() == 1);
663  const CReaction* pReaction = pModel->getReactions()[0];
664  CPPUNIT_ASSERT(pReaction != NULL);
665  CPPUNIT_ASSERT(pReaction->getChemEq().getSubstrates().size() == 1);
666  CPPUNIT_ASSERT(pReaction->getChemEq().getProducts().size() == 1);
667  CPPUNIT_ASSERT(pReaction->getChemEq().getModifiers().size() == 0);
668  CPPUNIT_ASSERT(pReaction->isReversible() == true);
669  // check for the global parameter
670  CPPUNIT_ASSERT(pReaction->getParameters().size() == 1);
671  CPPUNIT_ASSERT(pReaction->isLocalParameter(0) == false);
672  const CFunction* pFunction = pReaction->getFunction();
673  CPPUNIT_ASSERT(pFunction != NULL);
674  CPPUNIT_ASSERT(pFunction->getType() == CEvaluationTree::PreDefined);
675  CPPUNIT_ASSERT(pFunction->getObjectName() == "Constant flux (reversible)");
676 }
677 
678 const char* test000066::MODEL_STRING7 =
679  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
680  "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version3\" level=\"2\" version=\"3\">"
681  " <model id=\"Model_1\" name=\"New Model\">"
682  " <notes>"
683  " <body xmlns=\"http://www.w3.org/1999/xhtml\">"
684  " <p>Model with one reaction that has constant flux kinetics.</p>"
685  " </body>"
686  " </notes>"
687  " <listOfUnitDefinitions>"
688  " <unitDefinition id=\"volume\">"
689  " <listOfUnits>"
690  " <unit kind=\"litre\" scale=\"-3\"/>"
691  " </listOfUnits>"
692  " </unitDefinition>"
693  " <unitDefinition id=\"substance\">"
694  " <listOfUnits>"
695  " <unit kind=\"mole\" scale=\"-3\"/>"
696  " </listOfUnits>"
697  " </unitDefinition>"
698  " </listOfUnitDefinitions>"
699  " <listOfCompartments>"
700  " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>"
701  " </listOfCompartments>"
702  " <listOfSpecies>"
703  " <species id=\"species_1\" name=\"A\" compartment=\"compartment_1\" initialConcentration=\"1\"/>"
704  " <species id=\"species_2\" name=\"B\" compartment=\"compartment_1\" initialConcentration=\"1\"/>"
705  " </listOfSpecies>"
706  " <listOfParameters>"
707  " <parameter id=\"parameter_1\" name=\"K\" value=\"1.3\"/>"
708  " </listOfParameters>"
709  " <listOfReactions>"
710  " <reaction id=\"reaction1\" reversible=\"true\">"
711  " <listOfReactants>"
712  " <speciesReference species=\"species_1\"/>"
713  " </listOfReactants>"
714  " <listOfProducts>"
715  " <speciesReference species=\"species_2\"/>"
716  " </listOfProducts>"
717  " <kineticLaw>"
718  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
719  " <apply>"
720  " <times/>"
721  " <ci> compartment_1 </ci>"
722  " <ci> parameter_1 </ci>"
723  " </apply>"
724  " </math>"
725  " </kineticLaw>"
726  " </reaction>"
727  " </listOfReactions>"
728  " </model>"
729  "</sbml>"
730  ;
731 
732 const char* test000066::MODEL_STRING8 =
733  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
734  "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version3\" level=\"2\" version=\"3\">"
735  " <model id=\"Model_1\" name=\"New Model\">"
736  " <notes>"
737  " <body xmlns=\"http://www.w3.org/1999/xhtml\">"
738  " <p>Model with one reaction with constant flux kinetics.</p>"
739  " </body>"
740  " </notes>"
741  " <listOfFunctionDefinitions>"
742  " <functionDefinition id=\"function_1\" name=\"MM\">"
743  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
744  " <lambda>"
745  " <bvar>"
746  " <ci> k </ci>"
747  " </bvar>"
748  " <ci> k </ci>"
749  " </lambda>"
750  " </math>"
751  " </functionDefinition>"
752  " </listOfFunctionDefinitions>"
753  " <listOfUnitDefinitions>"
754  " <unitDefinition id=\"volume\">"
755  " <listOfUnits>"
756  " <unit kind=\"litre\" scale=\"-3\"/>"
757  " </listOfUnits>"
758  " </unitDefinition>"
759  " <unitDefinition id=\"substance\">"
760  " <listOfUnits>"
761  " <unit kind=\"mole\" scale=\"-3\"/>"
762  " </listOfUnits>"
763  " </unitDefinition>"
764  " </listOfUnitDefinitions>"
765  " <listOfCompartments>"
766  " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>"
767  " </listOfCompartments>"
768  " <listOfSpecies>"
769  " <species id=\"species_1\" name=\"A\" compartment=\"compartment_1\" initialConcentration=\"1\"/>"
770  " <species id=\"species_2\" name=\"B\" compartment=\"compartment_1\" initialConcentration=\"1\"/>"
771  " </listOfSpecies>"
772  " <listOfParameters>"
773  " <parameter id=\"parameter_1\" name=\"K\" value=\"1.3\"/>"
774  " </listOfParameters>"
775  " <listOfReactions>"
776  " <reaction id=\"reaction1\" reversible=\"true\">"
777  " <listOfReactants>"
778  " <speciesReference species=\"species_1\"/>"
779  " </listOfReactants>"
780  " <listOfProducts>"
781  " <speciesReference species=\"species_2\"/>"
782  " </listOfProducts>"
783  " <kineticLaw>"
784  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
785  " <apply>"
786  " <times/>"
787  " <ci> compartment_1 </ci>"
788  " <apply>"
789  " <ci> function_1 </ci>"
790  " <ci> parameter_1 </ci>"
791  " </apply>"
792  " </apply>"
793  " </math>"
794  " </kineticLaw>"
795  " </reaction>"
796  " </listOfReactions>"
797  " </model>"
798  "</sbml>"
799  ;
static const char * MODEL_STRING1
Definition: test000066.h:40
void test_import_reaction_with_constant_flux_function_global_parameter()
Definition: test000066.cpp:275
static const char * MODEL_STRING8
Definition: test000066.h:47
void test_import_reaction_with_constant_flux_function()
Definition: test000066.cpp:93
static const char * MODEL_STRING2
Definition: test000066.h:41
static const char * MODEL_STRING7
Definition: test000066.h:46
static const char * MODEL_STRING5
Definition: test000066.h:44
static const char * MODEL_STRING4
Definition: test000066.h:43
void test_import_reaction_with_constant_flux_reversible_function_global_parameter()
Definition: test000066.cpp:647
void tearDown()
Definition: test000066.cpp:52
void test_import_reaction_with_constant_flux_reversible_function()
Definition: test000066.cpp:457
void test_import_reaction_with_constant_flux_reversible_global_parameter()
Definition: test000066.cpp:616
static const char * MODEL_STRING6
Definition: test000066.h:45
void setUp()
Definition: test000066.cpp:44
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000066.h:48
static CCopasiDataModel * addDatamodel()
static const char * MODEL_STRING3
Definition: test000066.h:42
void test_import_reaction_with_constant_flux()
Definition: test000066.cpp:57
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_import_reaction_with_constant_flux_reversible()
Definition: test000066.cpp:421
void test_import_reaction_with_constant_flux_global_parameter()
Definition: test000066.cpp:244