COPASI API  4.16.103
Public Member Functions | Static Public Member Functions | Static Protected Attributes | Private Member Functions | List of all members
test000059 Class Reference

#include <test000059.h>

Inheritance diagram for test000059:
Inheritance graph
[legend]
Collaboration diagram for test000059:
Collaboration graph
[legend]

Public Member Functions

void setUp ()
 
void tearDown ()
 
void test_unique_id_1 ()
 
void test_unique_id_10 ()
 
void test_unique_id_11 ()
 
void test_unique_id_12 ()
 
void test_unique_id_13 ()
 
void test_unique_id_14 ()
 
void test_unique_id_15 ()
 
void test_unique_id_16 ()
 
void test_unique_id_17 ()
 
void test_unique_id_18 ()
 
void test_unique_id_19 ()
 
void test_unique_id_2 ()
 
void test_unique_id_20 ()
 
void test_unique_id_21 ()
 
void test_unique_id_21_2 ()
 
void test_unique_id_22 ()
 
void test_unique_id_3 ()
 
void test_unique_id_4 ()
 
void test_unique_id_5 ()
 
void test_unique_id_6 ()
 
void test_unique_id_7 ()
 
void test_unique_id_8 ()
 
void test_unique_id_9 ()
 

Static Public Member Functions

static bool checkIfIdsUnique (const Model *pSBMLModel)
 

Static Protected Attributes

static const char * MODEL_STRING1
 
static const char * MODEL_STRING10
 
static const char * MODEL_STRING11
 
static const char * MODEL_STRING12
 
static const char * MODEL_STRING13
 
static const char * MODEL_STRING14
 
static const char * MODEL_STRING15
 
static const char * MODEL_STRING16
 
static const char * MODEL_STRING17
 
static const char * MODEL_STRING18
 
static const char * MODEL_STRING19
 
static const char * MODEL_STRING2
 
static const char * MODEL_STRING20
 
static const char * MODEL_STRING21
 
static const char * MODEL_STRING22
 
static const char * MODEL_STRING3
 
static const char * MODEL_STRING4
 
static const char * MODEL_STRING5
 
static const char * MODEL_STRING6
 
static const char * MODEL_STRING7
 
static const char * MODEL_STRING8
 
static const char * MODEL_STRING9
 
static CCopasiDataModelpCOPASIDATAMODEL = NULL
 

Private Member Functions

 CPPUNIT_TEST (test_unique_id_1)
 
 CPPUNIT_TEST (test_unique_id_2)
 
 CPPUNIT_TEST (test_unique_id_3)
 
 CPPUNIT_TEST (test_unique_id_4)
 
 CPPUNIT_TEST (test_unique_id_5)
 
 CPPUNIT_TEST (test_unique_id_6)
 
 CPPUNIT_TEST (test_unique_id_7)
 
 CPPUNIT_TEST (test_unique_id_8)
 
 CPPUNIT_TEST (test_unique_id_9)
 
 CPPUNIT_TEST (test_unique_id_10)
 
 CPPUNIT_TEST (test_unique_id_11)
 
 CPPUNIT_TEST (test_unique_id_12)
 
 CPPUNIT_TEST (test_unique_id_13)
 
 CPPUNIT_TEST (test_unique_id_14)
 
 CPPUNIT_TEST (test_unique_id_15)
 
 CPPUNIT_TEST (test_unique_id_16)
 
 CPPUNIT_TEST (test_unique_id_17)
 
 CPPUNIT_TEST (test_unique_id_18)
 
 CPPUNIT_TEST (test_unique_id_19)
 
 CPPUNIT_TEST (test_unique_id_20)
 
 CPPUNIT_TEST (test_unique_id_21)
 
 CPPUNIT_TEST (test_unique_id_21_2)
 
 CPPUNIT_TEST (test_unique_id_22)
 
 CPPUNIT_TEST_SUITE (test000059)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

These tests check if all elements in an SBML model get unique ids on export, even if one element that has been exported before has an id that might potentially be assigned to a different element that is exported later. e.g. a species being named "reaction_2" These tests assume a certain order for the export of elements.

Definition at line 34 of file test000059.h.

Member Function Documentation

bool test000059::checkIfIdsUnique ( const Model *  pSBMLModel)
static

Definition at line 44 of file test000059.cpp.

Referenced by test000067::test_bug1060(), test_unique_id_1(), test_unique_id_10(), test_unique_id_11(), test_unique_id_12(), test_unique_id_13(), test_unique_id_14(), test_unique_id_15(), test_unique_id_16(), test_unique_id_17(), test_unique_id_18(), test_unique_id_19(), test_unique_id_2(), test_unique_id_20(), test_unique_id_21(), test_unique_id_21_2(), test_unique_id_22(), test_unique_id_3(), test_unique_id_4(), test_unique_id_5(), test_unique_id_6(), test_unique_id_7(), test_unique_id_8(), and test_unique_id_9().

45 {
46  bool result = true;
47  std::set<std::string> ids;
48 
49  if (pSBMLModel != NULL)
50  {
51  // the model itself
52  const SBase* pSBase = NULL;
53  std::string id;
54 
55  if (pSBMLModel->isSetId())
56  {
57  id = pSBMLModel->getId();
58 
59  if (ids.find(id) == ids.end())
60  {
61  ids.insert(id);
62  }
63  else
64  {
65  result = false;
66  }
67  }
68 
69  // ListOfFunctionDefinitions
70  pSBase = pSBMLModel->getListOfFunctionDefinitions();
71 
72  if (pSBase != NULL)
73  {
74  if (pSBase->isSetId())
75  {
76  id = pSBase->getId();
77 
78  if (ids.find(id) == ids.end())
79  {
80  ids.insert(id);
81  }
82  else
83  {
84  result = false;
85  }
86  }
87 
88  unsigned int i, iMax = pSBMLModel->getListOfFunctionDefinitions()->size();
89 
90  for (i = 0; i < iMax; ++i)
91  {
92  pSBase = pSBMLModel->getListOfFunctionDefinitions()->get(i);
93 
94  if (pSBase->isSetId())
95  {
96  id = pSBase->getId();
97 
98  if (ids.find(id) == ids.end())
99  {
100  ids.insert(id);
101  }
102  else
103  {
104  result = false;
105  }
106  }
107  }
108  }
109 
110  // ListOfCompartmentTypes
111  pSBase = pSBMLModel->getListOfCompartmentTypes();
112 
113  if (pSBase != NULL)
114  {
115  if (pSBase->isSetId())
116  {
117  id = pSBase->getId();
118 
119  if (ids.find(id) == ids.end())
120  {
121  ids.insert(id);
122  }
123  else
124  {
125  result = false;
126  }
127  }
128 
129  // each compartment type
130  unsigned int i, iMax = pSBMLModel->getListOfCompartmentTypes()->size();
131 
132  for (i = 0; i < iMax; ++i)
133  {
134  pSBase = pSBMLModel->getCompartmentType(i);
135  assert(pSBase != NULL);
136 
137  if (pSBase->isSetId())
138  {
139  id = pSBase->getId();
140 
141  if (ids.find(id) == ids.end())
142  {
143  ids.insert(id);
144  }
145  else
146  {
147  result = false;
148  }
149  }
150  }
151  }
152 
153  // ListOfSpeciesTypes
154  pSBase = pSBMLModel->getListOfSpeciesTypes();
155 
156  if (pSBase != NULL)
157  {
158  if (pSBase->isSetId())
159  {
160  id = pSBase->getId();
161 
162  if (ids.find(id) == ids.end())
163  {
164  ids.insert(id);
165  }
166  else
167  {
168  result = false;
169  }
170  }
171 
172  // each species type
173  unsigned int i, iMax = pSBMLModel->getListOfSpeciesTypes()->size();
174 
175  for (i = 0; i < iMax; ++i)
176  {
177  pSBase = pSBMLModel->getSpeciesType(i);
178  assert(pSBase != NULL);
179 
180  if (pSBase->isSetId())
181  {
182  id = pSBase->getId();
183 
184  if (ids.find(id) == ids.end())
185  {
186  ids.insert(id);
187  }
188  else
189  {
190  result = false;
191  }
192  }
193  }
194  }
195 
196  // ListOfCompartments
197  pSBase = pSBMLModel->getListOfCompartments();
198 
199  if (pSBase != NULL)
200  {
201  if (pSBase->isSetId())
202  {
203  id = pSBase->getId();
204 
205  if (ids.find(id) == ids.end())
206  {
207  ids.insert(id);
208  }
209  else
210  {
211  result = false;
212  }
213  }
214 
215  // all compartments
216  unsigned int i, iMax = pSBMLModel->getListOfCompartments()->size();
217 
218  for (i = 0; i < iMax; ++i)
219  {
220  pSBase = pSBMLModel->getCompartment(i);
221  assert(pSBase != NULL);
222 
223  if (pSBase->isSetId())
224  {
225  id = pSBase->getId();
226 
227  if (ids.find(id) == ids.end())
228  {
229  ids.insert(id);
230  }
231  else
232  {
233  result = false;
234  }
235  }
236  }
237  }
238 
239  // ListOfSpecies
240  pSBase = pSBMLModel->getListOfSpecies();
241 
242  if (pSBase != NULL)
243  {
244  if (pSBase->isSetId())
245  {
246  id = pSBase->getId();
247 
248  if (ids.find(id) == ids.end())
249  {
250  ids.insert(id);
251  }
252  else
253  {
254  result = false;
255  }
256  }
257 
258  // all species
259  unsigned int i, iMax = pSBMLModel->getListOfSpecies()->size();
260 
261  for (i = 0; i < iMax; ++i)
262  {
263  pSBase = pSBMLModel->getSpecies(i);
264  assert(pSBase != NULL);
265 
266  if (pSBase->isSetId())
267  {
268  id = pSBase->getId();
269 
270  if (ids.find(id) == ids.end())
271  {
272  ids.insert(id);
273  }
274  else
275  {
276  result = false;
277  }
278  }
279  }
280  }
281 
282  // ListOfParameters
283  pSBase = pSBMLModel->getListOfParameters();
284 
285  if (pSBase != NULL)
286  {
287  if (pSBase->isSetId())
288  {
289  id = pSBase->getId();
290 
291  if (ids.find(id) == ids.end())
292  {
293  ids.insert(id);
294  }
295  else
296  {
297  result = false;
298  }
299  }
300 
301  // each parameter
302  unsigned int i, iMax = pSBMLModel->getListOfParameters()->size();
303 
304  for (i = 0; i < iMax; ++i)
305  {
306  pSBase = pSBMLModel->getParameter(i);
307  assert(pSBase != NULL);
308 
309  if (pSBase->isSetId())
310  {
311  id = pSBase->getId();
312 
313  if (ids.find(id) == ids.end())
314  {
315  ids.insert(id);
316  }
317  else
318  {
319  result = false;
320  }
321  }
322  }
323  }
324 
325  // ListOfInitialAssignments
326  pSBase = pSBMLModel->getListOfInitialAssignments();
327 
328  if (pSBase != NULL)
329  {
330  if (pSBase->isSetId())
331  {
332  id = pSBase->getId();
333 
334  if (ids.find(id) == ids.end())
335  {
336  ids.insert(id);
337  }
338  else
339  {
340  result = false;
341  }
342  }
343  }
344 
345  // ListOfRules
346  pSBase = pSBMLModel->getListOfRules();
347 
348  if (pSBase != NULL)
349  {
350  if (pSBase->isSetId())
351  {
352  id = pSBase->getId();
353 
354  if (ids.find(id) == ids.end())
355  {
356  ids.insert(id);
357  }
358  else
359  {
360  result = false;
361  }
362  }
363  }
364 
365  // ListOfConstraints
366  pSBase = pSBMLModel->getListOfConstraints();
367 
368  if (pSBase != NULL)
369  {
370  if (pSBase->isSetId())
371  {
372  id = pSBase->getId();
373 
374  if (ids.find(id) == ids.end())
375  {
376  ids.insert(id);
377  }
378  else
379  {
380  result = false;
381  }
382  }
383  }
384 
385  // ListOfReactions
386  pSBase = pSBMLModel->getListOfReactions();
387 
388  if (pSBase != NULL)
389  {
390  if (pSBase->isSetId())
391  {
392  id = pSBase->getId();
393 
394  if (ids.find(id) == ids.end())
395  {
396  ids.insert(id);
397  }
398  else
399  {
400  result = false;
401  }
402  }
403 
404  // all reactions
405  unsigned int i, iMax = pSBMLModel->getListOfReactions()->size();
406 
407  for (i = 0; i < iMax; ++i)
408  {
409  const Reaction* pReaction = pSBMLModel->getReaction(i);
410  assert(pReaction != NULL);
411 
412  if (pReaction->isSetId())
413  {
414  id = pReaction->getId();
415 
416  if (ids.find(id) == ids.end())
417  {
418  ids.insert(id);
419  }
420  else
421  {
422  result = false;
423  }
424  }
425 
426  // for each reaction: ListOfSubstrates, each substrate, ListOfProducts, each
427  // Product, ListOfModifieres, each modifier, KineticLaw, ListOfparameters,
428  // each parameter
429  if (pReaction->getListOfReactants() != NULL)
430  {
431  pSBase = pReaction->getListOfReactants();
432  unsigned int j, jMax = pReaction->getListOfReactants()->size();
433 
434  for (j = 0; j < jMax; ++j)
435  {
436  pSBase = pReaction->getReactant(j);
437  assert(pSBase != NULL);
438 
439  // since L2V2 species references can have ids
440  if (pSBase->isSetId())
441  {
442  id = pSBase->getId();
443 
444  if (ids.find(id) == ids.end())
445  {
446  ids.insert(id);
447  }
448  else
449  {
450  result = false;
451  }
452  }
453  }
454  }
455 
456  if (pReaction->getListOfProducts() != NULL)
457  {
458  pSBase = pReaction->getListOfProducts();
459  unsigned int j, jMax = pReaction->getListOfProducts()->size();
460 
461  for (j = 0; j < jMax; ++j)
462  {
463  pSBase = pReaction->getProduct(j);
464  assert(pSBase != NULL);
465 
466  // since L2V2 species references can have ids
467  if (pSBase->isSetId())
468  {
469  id = pSBase->getId();
470 
471  if (ids.find(id) == ids.end())
472  {
473  ids.insert(id);
474  }
475  else
476  {
477  result = false;
478  }
479  }
480  }
481  }
482 
483  if (pReaction->getListOfModifiers() != NULL)
484  {
485  pSBase = pReaction->getListOfModifiers();
486  unsigned int j, jMax = pReaction->getListOfModifiers()->size();
487 
488  for (j = 0; j < jMax; ++j)
489  {
490  pSBase = pReaction->getModifier(j);
491  assert(pSBase != NULL);
492 
493  // since L2V2 species references can have ids
494  if (pSBase->isSetId())
495  {
496  id = pSBase->getId();
497 
498  if (ids.find(id) == ids.end())
499  {
500  ids.insert(id);
501  }
502  else
503  {
504  result = false;
505  }
506  }
507  }
508  }
509  }
510  }
511 
512  // ListOfEvents
513  pSBase = pSBMLModel->getListOfEvents();
514 
515  if (pSBase != NULL)
516  {
517  if (pSBase->isSetId())
518  {
519  id = pSBase->getId();
520 
521  if (ids.find(id) == ids.end())
522  {
523  ids.insert(id);
524  }
525  else
526  {
527  result = false;
528  }
529  }
530  }
531  }
532 
533  /*
534  std::cout << "number of ids: " << ids.size() << std::endl;
535  std::set<std::string>::iterator it=ids.begin();
536  while(it!=ids.end())
537  {
538  std::cout << "id: " << *it << std::endl;
539  ++it;
540  }
541  */
542  return result;
543 }
const char * id
Definition: stdsoap2.h:1262
test000059::CPPUNIT_TEST ( test_unique_id_1  )
private
test000059::CPPUNIT_TEST ( test_unique_id_2  )
private
test000059::CPPUNIT_TEST ( test_unique_id_3  )
private
test000059::CPPUNIT_TEST ( test_unique_id_4  )
private
test000059::CPPUNIT_TEST ( test_unique_id_5  )
private
test000059::CPPUNIT_TEST ( test_unique_id_6  )
private
test000059::CPPUNIT_TEST ( test_unique_id_7  )
private
test000059::CPPUNIT_TEST ( test_unique_id_8  )
private
test000059::CPPUNIT_TEST ( test_unique_id_9  )
private
test000059::CPPUNIT_TEST ( test_unique_id_10  )
private
test000059::CPPUNIT_TEST ( test_unique_id_11  )
private
test000059::CPPUNIT_TEST ( test_unique_id_12  )
private
test000059::CPPUNIT_TEST ( test_unique_id_13  )
private
test000059::CPPUNIT_TEST ( test_unique_id_14  )
private
test000059::CPPUNIT_TEST ( test_unique_id_15  )
private
test000059::CPPUNIT_TEST ( test_unique_id_16  )
private
test000059::CPPUNIT_TEST ( test_unique_id_17  )
private
test000059::CPPUNIT_TEST ( test_unique_id_18  )
private
test000059::CPPUNIT_TEST ( test_unique_id_19  )
private
test000059::CPPUNIT_TEST ( test_unique_id_20  )
private
test000059::CPPUNIT_TEST ( test_unique_id_21  )
private
test000059::CPPUNIT_TEST ( test_unique_id_21_2  )
private
test000059::CPPUNIT_TEST ( test_unique_id_22  )
private
test000059::CPPUNIT_TEST_SUITE ( test000059  )
private
test000059::CPPUNIT_TEST_SUITE_END ( )
private
void test000059::setUp ( )

Definition at line 31 of file test000059.cpp.

References CCopasiRootContainer::addDatamodel(), CCopasiRootContainer::init(), and pCOPASIDATAMODEL.

32 {
33  // Create the root container.
34  CCopasiRootContainer::init(0, NULL, false);
35  // Create the global data model.
37 }
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000059.h:85
static CCopasiDataModel * addDatamodel()
static void init(int argc, char *argv[], const bool &withGui=false)
void test000059::tearDown ( )

Definition at line 39 of file test000059.cpp.

References CCopasiRootContainer::destroy().

void test000059::test_unique_id_1 ( )

Definition at line 545 of file test000059.cpp.

References checkIfIdsUnique(), CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CModelEntity::getInitialValueReference(), CCopasiDataModel::getModel(), CCopasiDataModel::importSBMLFromString(), MODEL_STRING1, and pCOPASIDATAMODEL.

546 {
547  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
548  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000059::MODEL_STRING1));
549  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
550  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
551  const Model* pSBMLModel = pDocument->getModel();
552  CPPUNIT_ASSERT(pSBMLModel != NULL);
553  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
554  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
555  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
556  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
557  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
558  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
559  // now we add a new compartment
560  CModel* pModel = pDataModel->getModel();
561  CPPUNIT_ASSERT(pModel != NULL);
562  CCompartment* pCompartment = pModel->createCompartment("compartment_2");
563  CPPUNIT_ASSERT(pCompartment != NULL);
564  pModel->compileIfNecessary(NULL);
565  std::set<const CCopasiObject*> changedObjects;
566  const CCopasiObject* pObject = pCompartment->getInitialValueReference();
567  CPPUNIT_ASSERT(pObject != NULL);
568  changedObjects.insert(pObject);
569  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
570  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
571 
572  while (refreshIt != refreshEndit)
573  {
574  (**refreshIt++)();
575  }
576 
577  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
578  pDocument = pDataModel->getCurrentSBMLDocument();
579  pSBMLModel = pDocument->getModel();
580  CPPUNIT_ASSERT(pSBMLModel != NULL);
581  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
582  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 2);
583  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
584  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
585  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
586  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
587  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
588 }
SBMLDocument * getCurrentSBMLDocument()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000059.h:85
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000059.cpp:44
CCopasiObject * getInitialValueReference() const
static const char * MODEL_STRING1
Definition: test000059.h:63
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
void test000059::test_unique_id_10 ( )

Definition at line 953 of file test000059.cpp.

References CReaction::addProduct(), checkIfIdsUnique(), CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiDataModel::getModel(), CCopasiParameterGroup::getParameter(), CReaction::getParameters(), CCopasiParameter::getValueReference(), CCopasiDataModel::importSBMLFromString(), MODEL_STRING10, pCOPASIDATAMODEL, CReaction::setFunction(), and CReaction::setParameterValue().

954 {
955  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
956  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000059::MODEL_STRING10));
957  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
958  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
959  const Model* pSBMLModel = pDocument->getModel();
960  CPPUNIT_ASSERT(pSBMLModel != NULL);
961  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
962  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
963  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
964  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
965  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
966  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
967  // now we add a new reaction
968  CModel* pModel = pDataModel->getModel();
969  CPPUNIT_ASSERT(pModel != NULL);
970  CReaction* pReaction = pModel->createReaction("influx");
971  CPPUNIT_ASSERT(pReaction != NULL);
972  pReaction->addProduct(pModel->getMetabolites()[0]->getKey());
973  pReaction->setFunction("Constant flux (irreversible)");
974  pReaction->setParameterValue("v", 1.0, true);
975  pModel->compileIfNecessary(NULL);
976  std::set<const CCopasiObject*> changedObjects;
977  changedObjects.insert(pReaction->getParameters().getParameter(0)->getValueReference());
978  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
979  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
980 
981  while (refreshIt != refreshEndit)
982  {
983  (**refreshIt++)();
984  }
985 
986  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
987  pDocument = pDataModel->getCurrentSBMLDocument();
988  pSBMLModel = pDocument->getModel();
989  CPPUNIT_ASSERT(pSBMLModel != NULL);
990  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 2);
991  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
992  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
993  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 2);
994  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
995  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
996  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
997 }
SBMLDocument * getCurrentSBMLDocument()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000059.h:85
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000059.cpp:44
void setParameterValue(const std::string &parameterName, const C_FLOAT64 &value, const bool &updateStatus=true)
Definition: CReaction.cpp:303
CCopasiObject * getValueReference() const
bool addProduct(const std::string &metabKey, const C_FLOAT64 &multiplicity=1.0)
Definition: CReaction.cpp:236
bool setFunction(const std::string &functionName)
Definition: CReaction.cpp:255
CCopasiParameter * getParameter(const std::string &name)
const CCopasiParameterGroup & getParameters() const
Definition: CReaction.cpp:333
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
static const char * MODEL_STRING10
Definition: test000059.h:72
void test000059::test_unique_id_11 ( )

Definition at line 999 of file test000059.cpp.

References CModel::buildInitialRefreshSequence(), checkIfIdsUnique(), CModel::compileIfNecessary(), CModel::createMetabolite(), CCopasiDataModel::exportSBMLToString(), CModelEntity::FIXED, CCopasiDataModel::getCurrentSBMLDocument(), CMetab::getInitialConcentrationReference(), CCopasiDataModel::getModel(), load_cps_model_from_stream(), MODEL_STRING11, and pCOPASIDATAMODEL.

1000 {
1001  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1002  std::istringstream iss(test000059::MODEL_STRING11);
1003  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
1004  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
1005  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
1006  CPPUNIT_ASSERT(pDocument == NULL);
1007  // now we add a new species
1008  CModel* pModel = pDataModel->getModel();
1009  CPPUNIT_ASSERT(pModel != NULL);
1010  CMetab* pMetabolite = pModel->createMetabolite("species_2", "compartment_1", 1.0, CModelEntity::FIXED);
1011  CPPUNIT_ASSERT(pMetabolite != NULL);
1012  pModel->compileIfNecessary(NULL);
1013  std::set<const CCopasiObject*> changedObjects;
1014  const CCopasiObject* pObject = pMetabolite->getInitialConcentrationReference();
1015  CPPUNIT_ASSERT(pObject != NULL);
1016  changedObjects.insert(pObject);
1017  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
1018  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
1019 
1020  while (refreshIt != refreshEndit)
1021  {
1022  (**refreshIt++)();
1023  }
1024 
1025  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
1026  pDocument = pDataModel->getCurrentSBMLDocument();
1027  const Model* pSBMLModel = pDocument->getModel();
1028  CPPUNIT_ASSERT(pSBMLModel != NULL);
1029  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
1030  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
1031  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 2);
1032  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
1033  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
1034  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
1035  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
1036 }
SBMLDocument * getCurrentSBMLDocument()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000059.h:85
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000059.cpp:44
Definition: CMetab.h:178
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static const char * MODEL_STRING11
Definition: test000059.h:73
bool compileIfNecessary(CProcessReport *pProcessReport)
Definition: CModel.cpp:612
Definition: CModel.h:50
CConcentrationReference * getInitialConcentrationReference() const
Definition: CMetab.cpp:861
std::vector< Refresh * > buildInitialRefreshSequence(std::set< const CCopasiObject * > &changedObjects)
Definition: CModel.cpp:4164
CMetab * createMetabolite(const std::string &name, const std::string &compartment, const C_FLOAT64 &iconc=1.0, const CModelEntity::Status &status=CModelEntity::REACTIONS)
Definition: CModel.cpp:2622
void test000059::test_unique_id_12 ( )

Definition at line 1038 of file test000059.cpp.

References CModel::buildInitialRefreshSequence(), checkIfIdsUnique(), CModel::compileIfNecessary(), CModel::createModelValue(), CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CModelEntity::getInitialValueReference(), CCopasiDataModel::getModel(), load_cps_model_from_stream(), MODEL_STRING12, and pCOPASIDATAMODEL.

1039 {
1040  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1041  std::istringstream iss(test000059::MODEL_STRING12);
1042  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
1043  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
1044  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
1045  CPPUNIT_ASSERT(pDocument == NULL);
1046  // now we add a new parameter
1047  CModel* pModel = pDataModel->getModel();
1048  CPPUNIT_ASSERT(pModel != NULL);
1049  CModelValue* pModelValue = pModel->createModelValue("parameter_2");
1050  CPPUNIT_ASSERT(pModelValue != NULL);
1051  pModel->compileIfNecessary(NULL);
1052  std::set<const CCopasiObject*> changedObjects;
1053  const CCopasiObject* pObject = pModelValue->getInitialValueReference();
1054  CPPUNIT_ASSERT(pObject != NULL);
1055  changedObjects.insert(pObject);
1056  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
1057  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
1058 
1059  while (refreshIt != refreshEndit)
1060  {
1061  (**refreshIt++)();
1062  }
1063 
1064  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
1065  pDocument = pDataModel->getCurrentSBMLDocument();
1066  const Model* pSBMLModel = pDocument->getModel();
1067  CPPUNIT_ASSERT(pSBMLModel != NULL);
1068  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
1069  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
1070  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
1071  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
1072  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
1073  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 2);
1074  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
1075 }
SBMLDocument * getCurrentSBMLDocument()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000059.h:85
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000059.cpp:44
CCopasiObject * getInitialValueReference() const
CModelValue * createModelValue(const std::string &name, const C_FLOAT64 &value=0.0)
Definition: CModel.cpp:2838
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
bool compileIfNecessary(CProcessReport *pProcessReport)
Definition: CModel.cpp:612
static const char * MODEL_STRING12
Definition: test000059.h:74
Definition: CModel.h:50
std::vector< Refresh * > buildInitialRefreshSequence(std::set< const CCopasiObject * > &changedObjects)
Definition: CModel.cpp:4164
void test000059::test_unique_id_13 ( )

Definition at line 1077 of file test000059.cpp.

References CReaction::addProduct(), CModel::buildInitialRefreshSequence(), checkIfIdsUnique(), CModel::compileIfNecessary(), CModel::createReaction(), CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiObject::getKey(), CModel::getMetabolites(), CCopasiDataModel::getModel(), CCopasiParameterGroup::getParameter(), CReaction::getParameters(), CCopasiParameter::getValueReference(), load_cps_model_from_stream(), MODEL_STRING13, pCOPASIDATAMODEL, CReaction::setFunction(), and CReaction::setParameterValue().

1078 {
1079  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1080  std::istringstream iss(test000059::MODEL_STRING13);
1081  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
1082  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
1083  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
1084  CPPUNIT_ASSERT(pDocument == NULL);
1085  // now we add a new reaction
1086  CModel* pModel = pDataModel->getModel();
1087  CPPUNIT_ASSERT(pModel != NULL);
1088  CReaction* pReaction = pModel->createReaction("influx");
1089  CPPUNIT_ASSERT(pReaction != NULL);
1090  pReaction->addProduct(pModel->getMetabolites()[0]->getKey());
1091  pReaction->setFunction("Constant flux (irreversible)");
1092  pReaction->setParameterValue("v", 1.0, true);
1093  pModel->compileIfNecessary(NULL);
1094  std::set<const CCopasiObject*> changedObjects;
1095  changedObjects.insert(pReaction->getParameters().getParameter(0)->getValueReference());
1096  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
1097  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
1098 
1099  while (refreshIt != refreshEndit)
1100  {
1101  (**refreshIt++)();
1102  }
1103 
1104  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
1105  pDocument = pDataModel->getCurrentSBMLDocument();
1106  const Model* pSBMLModel = pDocument->getModel();
1107  CPPUNIT_ASSERT(pSBMLModel != NULL);
1108  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 2);
1109  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
1110  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
1111  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 2);
1112  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
1113  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
1114  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
1115 }
SBMLDocument * getCurrentSBMLDocument()
const CCopasiVector< CMetab > & getMetabolites() const
Definition: CModel.cpp:1051
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000059.h:85
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000059.cpp:44
void setParameterValue(const std::string &parameterName, const C_FLOAT64 &value, const bool &updateStatus=true)
Definition: CReaction.cpp:303
CCopasiObject * getValueReference() const
bool addProduct(const std::string &metabKey, const C_FLOAT64 &multiplicity=1.0)
Definition: CReaction.cpp:236
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
virtual const std::string & getKey() const
bool setFunction(const std::string &functionName)
Definition: CReaction.cpp:255
CReaction * createReaction(const std::string &name)
Definition: CModel.cpp:2760
CCopasiParameter * getParameter(const std::string &name)
bool compileIfNecessary(CProcessReport *pProcessReport)
Definition: CModel.cpp:612
const CCopasiParameterGroup & getParameters() const
Definition: CReaction.cpp:333
Definition: CModel.h:50
static const char * MODEL_STRING13
Definition: test000059.h:75
std::vector< Refresh * > buildInitialRefreshSequence(std::set< const CCopasiObject * > &changedObjects)
Definition: CModel.cpp:4164
void test000059::test_unique_id_14 ( )

Definition at line 1117 of file test000059.cpp.

References CModel::buildInitialRefreshSequence(), checkIfIdsUnique(), CModel::compileIfNecessary(), CModel::createModelValue(), CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CModelEntity::getInitialValueReference(), CCopasiDataModel::getModel(), load_cps_model_from_stream(), MODEL_STRING14, and pCOPASIDATAMODEL.

1118 {
1119  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1120  std::istringstream iss(test000059::MODEL_STRING14);
1121  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
1122  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
1123  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
1124  CPPUNIT_ASSERT(pDocument == NULL);
1125  // now we add a new parameter
1126  CModel* pModel = pDataModel->getModel();
1127  CPPUNIT_ASSERT(pModel != NULL);
1128  CModelValue* pModelValue = pModel->createModelValue("parameter_2");
1129  CPPUNIT_ASSERT(pModelValue != NULL);
1130  pModel->compileIfNecessary(NULL);
1131  std::set<const CCopasiObject*> changedObjects;
1132  const CCopasiObject* pObject = pModelValue->getInitialValueReference();
1133  CPPUNIT_ASSERT(pObject != NULL);
1134  changedObjects.insert(pObject);
1135  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
1136  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
1137 
1138  while (refreshIt != refreshEndit)
1139  {
1140  (**refreshIt++)();
1141  }
1142 
1143  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
1144  pDocument = pDataModel->getCurrentSBMLDocument();
1145  const Model* pSBMLModel = pDocument->getModel();
1146  CPPUNIT_ASSERT(pSBMLModel != NULL);
1147  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
1148  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
1149  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
1150  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
1151  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
1152  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 2);
1153  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
1154 }
SBMLDocument * getCurrentSBMLDocument()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000059.h:85
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000059.cpp:44
CCopasiObject * getInitialValueReference() const
static const char * MODEL_STRING14
Definition: test000059.h:76
CModelValue * createModelValue(const std::string &name, const C_FLOAT64 &value=0.0)
Definition: CModel.cpp:2838
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
bool compileIfNecessary(CProcessReport *pProcessReport)
Definition: CModel.cpp:612
Definition: CModel.h:50
std::vector< Refresh * > buildInitialRefreshSequence(std::set< const CCopasiObject * > &changedObjects)
Definition: CModel.cpp:4164
void test000059::test_unique_id_15 ( )

Definition at line 1156 of file test000059.cpp.

References CReaction::addProduct(), CModel::buildInitialRefreshSequence(), checkIfIdsUnique(), CModel::compileIfNecessary(), CModel::createReaction(), CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiObject::getKey(), CModel::getMetabolites(), CCopasiDataModel::getModel(), CCopasiParameterGroup::getParameter(), CReaction::getParameters(), CCopasiParameter::getValueReference(), load_cps_model_from_stream(), MODEL_STRING15, pCOPASIDATAMODEL, CReaction::setFunction(), and CReaction::setParameterValue().

1157 {
1158  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1159  std::istringstream iss(test000059::MODEL_STRING15);
1160  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
1161  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
1162  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
1163  CPPUNIT_ASSERT(pDocument == NULL);
1164  // now we add a new reaction
1165  CModel* pModel = pDataModel->getModel();
1166  CPPUNIT_ASSERT(pModel != NULL);
1167  CReaction* pReaction = pModel->createReaction("influx");
1168  CPPUNIT_ASSERT(pReaction != NULL);
1169  pReaction->addProduct(pModel->getMetabolites()[0]->getKey());
1170  pReaction->setFunction("Constant flux (irreversible)");
1171  pReaction->setParameterValue("v", 1.0, true);
1172  pModel->compileIfNecessary(NULL);
1173  std::set<const CCopasiObject*> changedObjects;
1174  changedObjects.insert(pReaction->getParameters().getParameter(0)->getValueReference());
1175  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
1176  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
1177 
1178  while (refreshIt != refreshEndit)
1179  {
1180  (**refreshIt++)();
1181  }
1182 
1183  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
1184  pDocument = pDataModel->getCurrentSBMLDocument();
1185  const Model* pSBMLModel = pDocument->getModel();
1186  CPPUNIT_ASSERT(pSBMLModel != NULL);
1187  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 2);
1188  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
1189  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
1190  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 2);
1191  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
1192  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
1193  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
1194 }
SBMLDocument * getCurrentSBMLDocument()
const CCopasiVector< CMetab > & getMetabolites() const
Definition: CModel.cpp:1051
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000059.h:85
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000059.cpp:44
void setParameterValue(const std::string &parameterName, const C_FLOAT64 &value, const bool &updateStatus=true)
Definition: CReaction.cpp:303
CCopasiObject * getValueReference() const
bool addProduct(const std::string &metabKey, const C_FLOAT64 &multiplicity=1.0)
Definition: CReaction.cpp:236
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
virtual const std::string & getKey() const
static const char * MODEL_STRING15
Definition: test000059.h:77
bool setFunction(const std::string &functionName)
Definition: CReaction.cpp:255
CReaction * createReaction(const std::string &name)
Definition: CModel.cpp:2760
CCopasiParameter * getParameter(const std::string &name)
bool compileIfNecessary(CProcessReport *pProcessReport)
Definition: CModel.cpp:612
const CCopasiParameterGroup & getParameters() const
Definition: CReaction.cpp:333
Definition: CModel.h:50
std::vector< Refresh * > buildInitialRefreshSequence(std::set< const CCopasiObject * > &changedObjects)
Definition: CModel.cpp:4164
void test000059::test_unique_id_16 ( )

Definition at line 1196 of file test000059.cpp.

References CReaction::addProduct(), CModel::buildInitialRefreshSequence(), checkIfIdsUnique(), CModel::compileIfNecessary(), CModel::createReaction(), CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiObject::getKey(), CModel::getMetabolites(), CCopasiDataModel::getModel(), CCopasiParameterGroup::getParameter(), CReaction::getParameters(), CCopasiParameter::getValueReference(), load_cps_model_from_stream(), MODEL_STRING16, pCOPASIDATAMODEL, CReaction::setFunction(), and CReaction::setParameterValue().

1197 {
1198  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1199  std::istringstream iss(test000059::MODEL_STRING16);
1200  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
1201  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
1202  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
1203  CPPUNIT_ASSERT(pDocument == NULL);
1204  // now we add a new reaction
1205  CModel* pModel = pDataModel->getModel();
1206  CPPUNIT_ASSERT(pModel != NULL);
1207  CReaction* pReaction = pModel->createReaction("influx");
1208  CPPUNIT_ASSERT(pReaction != NULL);
1209  pReaction->addProduct(pModel->getMetabolites()[0]->getKey());
1210  pReaction->setFunction("Constant flux (irreversible)");
1211  pReaction->setParameterValue("v", 1.0, true);
1212  pModel->compileIfNecessary(NULL);
1213  std::set<const CCopasiObject*> changedObjects;
1214  changedObjects.insert(pReaction->getParameters().getParameter(0)->getValueReference());
1215  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
1216  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
1217 
1218  while (refreshIt != refreshEndit)
1219  {
1220  (**refreshIt++)();
1221  }
1222 
1223  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
1224  pDocument = pDataModel->getCurrentSBMLDocument();
1225  const Model* pSBMLModel = pDocument->getModel();
1226  CPPUNIT_ASSERT(pSBMLModel != NULL);
1227  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 2);
1228  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
1229  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
1230  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 2);
1231  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
1232  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
1233  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
1234 }
SBMLDocument * getCurrentSBMLDocument()
static const char * MODEL_STRING16
Definition: test000059.h:78
const CCopasiVector< CMetab > & getMetabolites() const
Definition: CModel.cpp:1051
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000059.h:85
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000059.cpp:44
void setParameterValue(const std::string &parameterName, const C_FLOAT64 &value, const bool &updateStatus=true)
Definition: CReaction.cpp:303
CCopasiObject * getValueReference() const
bool addProduct(const std::string &metabKey, const C_FLOAT64 &multiplicity=1.0)
Definition: CReaction.cpp:236
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
virtual const std::string & getKey() const
bool setFunction(const std::string &functionName)
Definition: CReaction.cpp:255
CReaction * createReaction(const std::string &name)
Definition: CModel.cpp:2760
CCopasiParameter * getParameter(const std::string &name)
bool compileIfNecessary(CProcessReport *pProcessReport)
Definition: CModel.cpp:612
const CCopasiParameterGroup & getParameters() const
Definition: CReaction.cpp:333
Definition: CModel.h:50
std::vector< Refresh * > buildInitialRefreshSequence(std::set< const CCopasiObject * > &changedObjects)
Definition: CModel.cpp:4164
void test000059::test_unique_id_17 ( )

Definition at line 1236 of file test000059.cpp.

References CFunctionDB::addAndAdaptName(), CModelEntity::ASSIGNMENT, checkIfIdsUnique(), CEvaluationTree::compile(), CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiRootContainer::getFunctionList(), CModelEntity::getInitialValueReference(), CCopasiDataModel::getModel(), CCopasiObject::getObjectName(), CCopasiDataModel::importSBMLFromString(), MODEL_STRING17, pCOPASIDATAMODEL, CModelEntity::setExpression(), CFunction::setInfix(), and CModelEntity::setStatus().

1237 {
1238  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1239  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000059::MODEL_STRING17));
1240  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
1241  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
1242  const Model* pSBMLModel = pDocument->getModel();
1243  CPPUNIT_ASSERT(pSBMLModel != NULL);
1244  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
1245  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
1246  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
1247  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
1248  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
1249  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
1250  // now we add a new parameter
1251  CModel* pModel = pDataModel->getModel();
1252  CPPUNIT_ASSERT(pModel != NULL);
1253  // add a new function definition
1254  CFunction* pFunctionDefinition = new CFunction("function_2");
1255  CPPUNIT_ASSERT(pFunctionDefinition != NULL);
1256  CPPUNIT_ASSERT(pFunctionDefinition->setInfix("3 * 5") == true);
1257  pFunctionDefinition->compile();
1258  // add the function definition to the function database
1260  CModelValue* pModelValue = pModel->createModelValue("parameter_2");
1261  CPPUNIT_ASSERT(pModelValue != NULL);
1262  pModelValue->setStatus(CModelEntity::ASSIGNMENT);
1263  CPPUNIT_ASSERT(pModelValue->setExpression(std::string(pFunctionDefinition->getObjectName() + "()")) == true);
1264  // now create a rule for the parameter
1265  pModel->compileIfNecessary(NULL);
1266  std::set<const CCopasiObject*> changedObjects;
1267  const CCopasiObject* pObject = pModelValue->getInitialValueReference();
1268  CPPUNIT_ASSERT(pObject != NULL);
1269  changedObjects.insert(pObject);
1270  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
1271  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
1272 
1273  while (refreshIt != refreshEndit)
1274  {
1275  (**refreshIt++)();
1276  }
1277 
1278  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
1279  pDocument = pDataModel->getCurrentSBMLDocument();
1280  pSBMLModel = pDocument->getModel();
1281  CPPUNIT_ASSERT(pSBMLModel != NULL);
1282  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 2);
1283  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
1284  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
1285  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
1286  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 1);
1287  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 2);
1288  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
1289 }
SBMLDocument * getCurrentSBMLDocument()
CFunction * addAndAdaptName(CFunction *pFunction)
static const char * MODEL_STRING17
Definition: test000059.h:79
const std::string & getObjectName() const
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000059.h:85
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000059.cpp:44
CCopasiObject * getInitialValueReference() const
virtual bool setInfix(const std::string &infix)
Definition: CFunction.cpp:73
virtual void setStatus(const CModelEntity::Status &status)
static CFunctionDB * getFunctionList()
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
virtual bool compile()
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
Definition: CModel.h:50
bool setExpression(const std::string &expression)
void test000059::test_unique_id_18 ( )

Definition at line 1291 of file test000059.cpp.

References CFunctionDB::addAndAdaptName(), CModelEntity::ASSIGNMENT, checkIfIdsUnique(), CEvaluationTree::compile(), CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiRootContainer::getFunctionList(), CModelEntity::getInitialValueReference(), CCopasiDataModel::getModel(), CCopasiObject::getObjectName(), CCopasiDataModel::importSBMLFromString(), MODEL_STRING18, pCOPASIDATAMODEL, CModelEntity::setExpression(), CFunction::setInfix(), and CModelEntity::setStatus().

1292 {
1293  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1294  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000059::MODEL_STRING18));
1295  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
1296  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
1297  const Model* pSBMLModel = pDocument->getModel();
1298  CPPUNIT_ASSERT(pSBMLModel != NULL);
1299  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
1300  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
1301  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
1302  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
1303  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
1304  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
1305  // now we add a new parameter
1306  CModel* pModel = pDataModel->getModel();
1307  CPPUNIT_ASSERT(pModel != NULL);
1308  // add a new function definition
1309  CFunction* pFunctionDefinition = new CFunction("function_2");
1310  CPPUNIT_ASSERT(pFunctionDefinition != NULL);
1311  CPPUNIT_ASSERT(pFunctionDefinition->setInfix("3 * 5") == true);
1312  pFunctionDefinition->compile();
1313  // add the function definition to the function database
1315  CModelValue* pModelValue = pModel->createModelValue("parameter_2");
1316  CPPUNIT_ASSERT(pModelValue != NULL);
1317  pModelValue->setStatus(CModelEntity::ASSIGNMENT);
1318  CPPUNIT_ASSERT(pModelValue->setExpression(std::string(pFunctionDefinition->getObjectName() + "()")) == true);
1319  // now create a rule for the parameter
1320  pModel->compileIfNecessary(NULL);
1321  std::set<const CCopasiObject*> changedObjects;
1322  const CCopasiObject* pObject = pModelValue->getInitialValueReference();
1323  CPPUNIT_ASSERT(pObject != NULL);
1324  changedObjects.insert(pObject);
1325  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
1326  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
1327 
1328  while (refreshIt != refreshEndit)
1329  {
1330  (**refreshIt++)();
1331  }
1332 
1333  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
1334  pDocument = pDataModel->getCurrentSBMLDocument();
1335  pSBMLModel = pDocument->getModel();
1336  CPPUNIT_ASSERT(pSBMLModel != NULL);
1337  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 2);
1338  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
1339  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
1340  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
1341  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 1);
1342  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 2);
1343  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
1344 }
SBMLDocument * getCurrentSBMLDocument()
CFunction * addAndAdaptName(CFunction *pFunction)
const std::string & getObjectName() const
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000059.h:85
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000059.cpp:44
CCopasiObject * getInitialValueReference() const
virtual bool setInfix(const std::string &infix)
Definition: CFunction.cpp:73
virtual void setStatus(const CModelEntity::Status &status)
static CFunctionDB * getFunctionList()
static const char * MODEL_STRING18
Definition: test000059.h:80
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
virtual bool compile()
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
Definition: CModel.h:50
bool setExpression(const std::string &expression)
void test000059::test_unique_id_19 ( )

Definition at line 1346 of file test000059.cpp.

References CFunctionDB::addAndAdaptName(), CModelEntity::ASSIGNMENT, checkIfIdsUnique(), CEvaluationTree::compile(), CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiRootContainer::getFunctionList(), CModelEntity::getInitialValueReference(), CCopasiDataModel::getModel(), CCopasiObject::getObjectName(), CCopasiDataModel::importSBMLFromString(), MODEL_STRING19, pCOPASIDATAMODEL, CModelEntity::setExpression(), CFunction::setInfix(), and CModelEntity::setStatus().

1347 {
1348  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1349  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000059::MODEL_STRING19));
1350  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
1351  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
1352  const Model* pSBMLModel = pDocument->getModel();
1353  CPPUNIT_ASSERT(pSBMLModel != NULL);
1354  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
1355  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
1356  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
1357  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
1358  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
1359  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
1360  // now we add a new parameter
1361  CModel* pModel = pDataModel->getModel();
1362  CPPUNIT_ASSERT(pModel != NULL);
1363  // add a new function definition
1364  CFunction* pFunctionDefinition = new CFunction("function_2");
1365  CPPUNIT_ASSERT(pFunctionDefinition != NULL);
1366  CPPUNIT_ASSERT(pFunctionDefinition->setInfix("3 * 5") == true);
1367  pFunctionDefinition->compile();
1368  // add the function definition to the function database
1370  CModelValue* pModelValue = pModel->createModelValue("parameter_2");
1371  CPPUNIT_ASSERT(pModelValue != NULL);
1372  pModelValue->setStatus(CModelEntity::ASSIGNMENT);
1373  CPPUNIT_ASSERT(pModelValue->setExpression(std::string(pFunctionDefinition->getObjectName() + "()")) == true);
1374  // now create a rule for the parameter
1375  pModel->compileIfNecessary(NULL);
1376  std::set<const CCopasiObject*> changedObjects;
1377  const CCopasiObject* pObject = pModelValue->getInitialValueReference();
1378  CPPUNIT_ASSERT(pObject != NULL);
1379  changedObjects.insert(pObject);
1380  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
1381  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
1382 
1383  while (refreshIt != refreshEndit)
1384  {
1385  (**refreshIt++)();
1386  }
1387 
1388  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
1389  pDocument = pDataModel->getCurrentSBMLDocument();
1390  pSBMLModel = pDocument->getModel();
1391  CPPUNIT_ASSERT(pSBMLModel != NULL);
1392  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 2);
1393  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
1394  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
1395  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
1396  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 1);
1397  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 2);
1398  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
1399 }
SBMLDocument * getCurrentSBMLDocument()
CFunction * addAndAdaptName(CFunction *pFunction)
const std::string & getObjectName() const
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000059.h:85
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000059.cpp:44
CCopasiObject * getInitialValueReference() const
virtual bool setInfix(const std::string &infix)
Definition: CFunction.cpp:73
virtual void setStatus(const CModelEntity::Status &status)
static const char * MODEL_STRING19
Definition: test000059.h:81
static CFunctionDB * getFunctionList()
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
virtual bool compile()
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
Definition: CModel.h:50
bool setExpression(const std::string &expression)
void test000059::test_unique_id_2 ( )

Definition at line 590 of file test000059.cpp.

References checkIfIdsUnique(), CCopasiDataModel::exportSBMLToString(), CModelEntity::FIXED, CCopasiDataModel::getCurrentSBMLDocument(), CMetab::getInitialConcentrationReference(), CCopasiDataModel::getModel(), CCopasiDataModel::importSBMLFromString(), MODEL_STRING2, and pCOPASIDATAMODEL.

591 {
592  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
593  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000059::MODEL_STRING2));
594  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
595  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
596  const Model* pSBMLModel = pDocument->getModel();
597  CPPUNIT_ASSERT(pSBMLModel != NULL);
598  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
599  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
600  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
601  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
602  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
603  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
604  // now we add a new species
605  CModel* pModel = pDataModel->getModel();
606  CPPUNIT_ASSERT(pModel != NULL);
607  CMetab* pMetabolite = pModel->createMetabolite("species_2", "compartment_1", 1.0, CModelEntity::FIXED);
608  CPPUNIT_ASSERT(pMetabolite != NULL);
609  pModel->compileIfNecessary(NULL);
610  std::set<const CCopasiObject*> changedObjects;
611  const CCopasiObject* pObject = pMetabolite->getInitialConcentrationReference();
612  CPPUNIT_ASSERT(pObject != NULL);
613  changedObjects.insert(pObject);
614  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
615  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
616 
617  while (refreshIt != refreshEndit)
618  {
619  (**refreshIt++)();
620  }
621 
622  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
623  pDocument = pDataModel->getCurrentSBMLDocument();
624  pSBMLModel = pDocument->getModel();
625  CPPUNIT_ASSERT(pSBMLModel != NULL);
626  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
627  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
628  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 2);
629  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
630  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
631  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
632  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
633 }
SBMLDocument * getCurrentSBMLDocument()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000059.h:85
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000059.cpp:44
Definition: CMetab.h:178
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
CConcentrationReference * getInitialConcentrationReference() const
Definition: CMetab.cpp:861
static const char * MODEL_STRING2
Definition: test000059.h:64
void test000059::test_unique_id_20 ( )

Definition at line 1401 of file test000059.cpp.

References CFunctionDB::addAndAdaptName(), CModelEntity::ASSIGNMENT, checkIfIdsUnique(), CEvaluationTree::compile(), CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiRootContainer::getFunctionList(), CModelEntity::getInitialValueReference(), CCopasiDataModel::getModel(), CCopasiObject::getObjectName(), CCopasiDataModel::importSBMLFromString(), MODEL_STRING20, pCOPASIDATAMODEL, CModelEntity::setExpression(), CFunction::setInfix(), and CModelEntity::setStatus().

1402 {
1403  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1404  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000059::MODEL_STRING20));
1405  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
1406  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
1407  const Model* pSBMLModel = pDocument->getModel();
1408  CPPUNIT_ASSERT(pSBMLModel != NULL);
1409  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
1410  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
1411  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
1412  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
1413  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
1414  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
1415  // now we add a new parameter
1416  CModel* pModel = pDataModel->getModel();
1417  CPPUNIT_ASSERT(pModel != NULL);
1418  // add a new function definition
1419  CFunction* pFunctionDefinition = new CFunction("function_2");
1420  CPPUNIT_ASSERT(pFunctionDefinition != NULL);
1421  CPPUNIT_ASSERT(pFunctionDefinition->setInfix("3 * 5") == true);
1422  pFunctionDefinition->compile();
1423  // add the function definition to the function database
1425  CModelValue* pModelValue = pModel->createModelValue("parameter_2");
1426  CPPUNIT_ASSERT(pModelValue != NULL);
1427  pModelValue->setStatus(CModelEntity::ASSIGNMENT);
1428  CPPUNIT_ASSERT(pModelValue->setExpression(std::string(pFunctionDefinition->getObjectName() + "()")) == true);
1429  // now create a rule for the parameter
1430  pModel->compileIfNecessary(NULL);
1431  std::set<const CCopasiObject*> changedObjects;
1432  const CCopasiObject* pObject = pModelValue->getInitialValueReference();
1433  CPPUNIT_ASSERT(pObject != NULL);
1434  changedObjects.insert(pObject);
1435  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
1436  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
1437 
1438  while (refreshIt != refreshEndit)
1439  {
1440  (**refreshIt++)();
1441  }
1442 
1443  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
1444  pDocument = pDataModel->getCurrentSBMLDocument();
1445  pSBMLModel = pDocument->getModel();
1446  CPPUNIT_ASSERT(pSBMLModel != NULL);
1447  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 2);
1448  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
1449  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
1450  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
1451  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 1);
1452  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 2);
1453  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
1454 }
SBMLDocument * getCurrentSBMLDocument()
CFunction * addAndAdaptName(CFunction *pFunction)
const std::string & getObjectName() const
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000059.h:85
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000059.cpp:44
CCopasiObject * getInitialValueReference() const
virtual bool setInfix(const std::string &infix)
Definition: CFunction.cpp:73
virtual void setStatus(const CModelEntity::Status &status)
static CFunctionDB * getFunctionList()
static const char * MODEL_STRING20
Definition: test000059.h:82
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
virtual bool compile()
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
Definition: CModel.h:50
bool setExpression(const std::string &expression)
void test000059::test_unique_id_21 ( )

Test for Bug 1060.

Definition at line 1459 of file test000059.cpp.

References CFunctionDB::addAndAdaptName(), CModelEntity::ASSIGNMENT, checkIfIdsUnique(), CEvaluationTree::compile(), CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiRootContainer::getFunctionList(), CModelEntity::getInitialValueReference(), CCopasiDataModel::getModel(), CCopasiObject::getObjectName(), load_cps_model_from_stream(), MODEL_STRING21, pCOPASIDATAMODEL, CModelEntity::setExpression(), CFunction::setInfix(), and CModelEntity::setStatus().

1460 {
1461  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1462  std::istringstream iss(test000059::MODEL_STRING21);
1463  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
1464  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
1465  // now we add a new function definition
1466  CModel* pModel = pDataModel->getModel();
1467  CPPUNIT_ASSERT(pModel != NULL);
1468  // add a new function definition
1469  CFunction* pFunctionDefinition = new CFunction("test function");
1470  CPPUNIT_ASSERT(pFunctionDefinition != NULL);
1471  CPPUNIT_ASSERT(pFunctionDefinition->setInfix("3 * 5") == true);
1472  pFunctionDefinition->compile();
1473  // add the function definition to the function database
1475  CModelValue* pModelValue = pModel->createModelValue("parameter_2");
1476  CPPUNIT_ASSERT(pModelValue != NULL);
1477  pModelValue->setStatus(CModelEntity::ASSIGNMENT);
1478  CPPUNIT_ASSERT(pModelValue->setExpression(std::string("\"" + pFunctionDefinition->getObjectName() + "\"()")) == true);
1479  // now create a rule for the parameter
1480  pModel->compileIfNecessary(NULL);
1481  std::set<const CCopasiObject*> changedObjects;
1482  const CCopasiObject* pObject = pModelValue->getInitialValueReference();
1483  CPPUNIT_ASSERT(pObject != NULL);
1484  changedObjects.insert(pObject);
1485  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
1486  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
1487 
1488  while (refreshIt != refreshEndit)
1489  {
1490  (**refreshIt++)();
1491  }
1492 
1493  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
1494  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
1495  const Model* pSBMLModel = pDocument->getModel();
1496  CPPUNIT_ASSERT(pSBMLModel != NULL);
1497  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 2);
1498  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
1499  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
1500  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
1501  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 1);
1502  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 2);
1503  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
1504 }
SBMLDocument * getCurrentSBMLDocument()
CFunction * addAndAdaptName(CFunction *pFunction)
static const char * MODEL_STRING21
Definition: test000059.h:83
const std::string & getObjectName() const
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000059.h:85
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000059.cpp:44
CCopasiObject * getInitialValueReference() const
virtual bool setInfix(const std::string &infix)
Definition: CFunction.cpp:73
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
virtual void setStatus(const CModelEntity::Status &status)
static CFunctionDB * getFunctionList()
virtual bool compile()
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
Definition: CModel.h:50
bool setExpression(const std::string &expression)
void test000059::test_unique_id_21_2 ( )

Same test as the test before, only the newly added function definition has a different name.

Definition at line 1510 of file test000059.cpp.

References CFunctionDB::addAndAdaptName(), CModelEntity::ASSIGNMENT, checkIfIdsUnique(), CEvaluationTree::compile(), CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiRootContainer::getFunctionList(), CModelEntity::getInitialValueReference(), CCopasiDataModel::getModel(), CCopasiObject::getObjectName(), load_cps_model_from_stream(), MODEL_STRING21, pCOPASIDATAMODEL, CModelEntity::setExpression(), CFunction::setInfix(), and CModelEntity::setStatus().

1511 {
1512  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1513  std::istringstream iss(test000059::MODEL_STRING21);
1514  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
1515  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
1516  // now we add a new function definition
1517  CModel* pModel = pDataModel->getModel();
1518  CPPUNIT_ASSERT(pModel != NULL);
1519  // add a new function definition
1520  CFunction* pFunctionDefinition = new CFunction("function_1");
1521  CPPUNIT_ASSERT(pFunctionDefinition != NULL);
1522  CPPUNIT_ASSERT(pFunctionDefinition->setInfix("3 * 5") == true);
1523  pFunctionDefinition->compile();
1524  // add the function definition to the function database
1526  CModelValue* pModelValue = pModel->createModelValue("parameter_2");
1527  CPPUNIT_ASSERT(pModelValue != NULL);
1528  pModelValue->setStatus(CModelEntity::ASSIGNMENT);
1529  CPPUNIT_ASSERT(pModelValue->setExpression(std::string(pFunctionDefinition->getObjectName() + "()")) == true);
1530  // now create a rule for the parameter
1531  pModel->compileIfNecessary(NULL);
1532  std::set<const CCopasiObject*> changedObjects;
1533  const CCopasiObject* pObject = pModelValue->getInitialValueReference();
1534  CPPUNIT_ASSERT(pObject != NULL);
1535  changedObjects.insert(pObject);
1536  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
1537  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
1538 
1539  while (refreshIt != refreshEndit)
1540  {
1541  (**refreshIt++)();
1542  }
1543 
1544  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
1545  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
1546  const Model* pSBMLModel = pDocument->getModel();
1547  CPPUNIT_ASSERT(pSBMLModel != NULL);
1548  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 2);
1549  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
1550  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
1551  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
1552  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 1);
1553  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 2);
1554  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
1555 }
SBMLDocument * getCurrentSBMLDocument()
CFunction * addAndAdaptName(CFunction *pFunction)
static const char * MODEL_STRING21
Definition: test000059.h:83
const std::string & getObjectName() const
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000059.h:85
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000059.cpp:44
CCopasiObject * getInitialValueReference() const
virtual bool setInfix(const std::string &infix)
Definition: CFunction.cpp:73
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
virtual void setStatus(const CModelEntity::Status &status)
static CFunctionDB * getFunctionList()
virtual bool compile()
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
Definition: CModel.h:50
bool setExpression(const std::string &expression)
void test000059::test_unique_id_22 ( )

Definition at line 1557 of file test000059.cpp.

References checkIfIdsUnique(), CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiDataModel::getModel(), CCopasiDataModel::importSBMLFromString(), load_cps_model_from_stream(), MODEL_STRING22, and pCOPASIDATAMODEL.

1558 {
1559  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1560  std::istringstream iss(test000059::MODEL_STRING22);
1561  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
1562  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
1563  std::string modelString;
1564 
1565  try
1566  {
1567  modelString = pDataModel->exportSBMLToString(NULL, 2, 3);
1568  }
1569  catch (...)
1570  {
1571  CPPUNIT_ASSERT(false);
1572  }
1573 
1574  CPPUNIT_ASSERT(modelString.empty() == false);
1575 
1576  try
1577  {
1578  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(modelString));
1579  }
1580  catch (...)
1581  {
1582  CPPUNIT_ASSERT(false);
1583  }
1584 
1585  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
1586  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
1587  const Model* pSBMLModel = pDocument->getModel();
1588  CPPUNIT_ASSERT(pSBMLModel != NULL);
1589  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 0);
1590  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
1591  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 3);
1592  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
1593  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 1);
1594  CPPUNIT_ASSERT(pSBMLModel->getNumInitialAssignments() == 2);
1595  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 5);
1596  // now we check if the ids are unique
1597  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
1598 }
SBMLDocument * getCurrentSBMLDocument()
static const char * MODEL_STRING22
Definition: test000059.h:84
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000059.h:85
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000059.cpp:44
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
void test000059::test_unique_id_3 ( )

Definition at line 635 of file test000059.cpp.

References checkIfIdsUnique(), CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CModelEntity::getInitialValueReference(), CCopasiDataModel::getModel(), CCopasiDataModel::importSBMLFromString(), MODEL_STRING3, and pCOPASIDATAMODEL.

636 {
637  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
638  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000059::MODEL_STRING3));
639  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
640  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
641  const Model* pSBMLModel = pDocument->getModel();
642  CPPUNIT_ASSERT(pSBMLModel != NULL);
643  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
644  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
645  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
646  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
647  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
648  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
649  // now we add a new parameter
650  CModel* pModel = pDataModel->getModel();
651  CPPUNIT_ASSERT(pModel != NULL);
652  CModelValue* pModelValue = pModel->createModelValue("parameter_2");
653  CPPUNIT_ASSERT(pModelValue != NULL);
654  pModel->compileIfNecessary(NULL);
655  std::set<const CCopasiObject*> changedObjects;
656  const CCopasiObject* pObject = pModelValue->getInitialValueReference();
657  CPPUNIT_ASSERT(pObject != NULL);
658  changedObjects.insert(pObject);
659  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
660  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
661 
662  while (refreshIt != refreshEndit)
663  {
664  (**refreshIt++)();
665  }
666 
667  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
668  pDocument = pDataModel->getCurrentSBMLDocument();
669  pSBMLModel = pDocument->getModel();
670  CPPUNIT_ASSERT(pSBMLModel != NULL);
671  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
672  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
673  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
674  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
675  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
676  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 2);
677  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
678 }
SBMLDocument * getCurrentSBMLDocument()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000059.h:85
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static const char * MODEL_STRING3
Definition: test000059.h:65
static bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000059.cpp:44
CCopasiObject * getInitialValueReference() const
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
void test000059::test_unique_id_4 ( )

Definition at line 680 of file test000059.cpp.

References CReaction::addProduct(), checkIfIdsUnique(), CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiDataModel::getModel(), CCopasiParameterGroup::getParameter(), CReaction::getParameters(), CCopasiParameter::getValueReference(), CCopasiDataModel::importSBMLFromString(), MODEL_STRING4, pCOPASIDATAMODEL, CReaction::setFunction(), and CReaction::setParameterValue().

681 {
682  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
683  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000059::MODEL_STRING4));
684  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
685  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
686  const Model* pSBMLModel = pDocument->getModel();
687  CPPUNIT_ASSERT(pSBMLModel != NULL);
688  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
689  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
690  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
691  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
692  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
693  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
694  // now we add a new reaction
695  CModel* pModel = pDataModel->getModel();
696  CPPUNIT_ASSERT(pModel != NULL);
697  CReaction* pReaction = pModel->createReaction("influx");
698  CPPUNIT_ASSERT(pReaction != NULL);
699  pReaction->addProduct(pModel->getMetabolites()[0]->getKey());
700  pReaction->setFunction("Constant flux (irreversible)");
701  pReaction->setParameterValue("v", 1.0, true);
702  pModel->compileIfNecessary(NULL);
703  std::set<const CCopasiObject*> changedObjects;
704  changedObjects.insert(pReaction->getParameters().getParameter(0)->getValueReference());
705  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
706  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
707 
708  while (refreshIt != refreshEndit)
709  {
710  (**refreshIt++)();
711  }
712 
713  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
714  pDocument = pDataModel->getCurrentSBMLDocument();
715  pSBMLModel = pDocument->getModel();
716  CPPUNIT_ASSERT(pSBMLModel != NULL);
717  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 2);
718  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
719  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
720  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 2);
721  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
722  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
723  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
724 }
SBMLDocument * getCurrentSBMLDocument()
static const char * MODEL_STRING4
Definition: test000059.h:66
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000059.h:85
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000059.cpp:44
void setParameterValue(const std::string &parameterName, const C_FLOAT64 &value, const bool &updateStatus=true)
Definition: CReaction.cpp:303
CCopasiObject * getValueReference() const
bool addProduct(const std::string &metabKey, const C_FLOAT64 &multiplicity=1.0)
Definition: CReaction.cpp:236
bool setFunction(const std::string &functionName)
Definition: CReaction.cpp:255
CCopasiParameter * getParameter(const std::string &name)
const CCopasiParameterGroup & getParameters() const
Definition: CReaction.cpp:333
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
void test000059::test_unique_id_5 ( )

Definition at line 726 of file test000059.cpp.

References checkIfIdsUnique(), CCopasiDataModel::exportSBMLToString(), CModelEntity::FIXED, CCopasiDataModel::getCurrentSBMLDocument(), CMetab::getInitialConcentrationReference(), CCopasiDataModel::getModel(), CCopasiDataModel::importSBMLFromString(), MODEL_STRING5, and pCOPASIDATAMODEL.

727 {
728  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
729  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000059::MODEL_STRING5));
730  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
731  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
732  const Model* pSBMLModel = pDocument->getModel();
733  CPPUNIT_ASSERT(pSBMLModel != NULL);
734  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
735  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
736  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
737  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
738  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
739  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
740  // now we add a new species
741  CModel* pModel = pDataModel->getModel();
742  CPPUNIT_ASSERT(pModel != NULL);
743  CMetab* pMetabolite = pModel->createMetabolite("species_2", "compartment_1", 1.0, CModelEntity::FIXED);
744  CPPUNIT_ASSERT(pMetabolite != NULL);
745  pModel->compileIfNecessary(NULL);
746  std::set<const CCopasiObject*> changedObjects;
747  const CCopasiObject* pObject = pMetabolite->getInitialConcentrationReference();
748  CPPUNIT_ASSERT(pObject != NULL);
749  changedObjects.insert(pObject);
750  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
751  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
752 
753  while (refreshIt != refreshEndit)
754  {
755  (**refreshIt++)();
756  }
757 
758  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
759  pDocument = pDataModel->getCurrentSBMLDocument();
760  pSBMLModel = pDocument->getModel();
761  CPPUNIT_ASSERT(pSBMLModel != NULL);
762  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
763  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
764  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 2);
765  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
766  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
767  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
768  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
769 }
SBMLDocument * getCurrentSBMLDocument()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000059.h:85
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000059.cpp:44
Definition: CMetab.h:178
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
CConcentrationReference * getInitialConcentrationReference() const
Definition: CMetab.cpp:861
static const char * MODEL_STRING5
Definition: test000059.h:67
void test000059::test_unique_id_6 ( )

Definition at line 771 of file test000059.cpp.

References checkIfIdsUnique(), CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CModelEntity::getInitialValueReference(), CCopasiDataModel::getModel(), CCopasiDataModel::importSBMLFromString(), MODEL_STRING6, and pCOPASIDATAMODEL.

772 {
773  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
774  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000059::MODEL_STRING6));
775  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
776  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
777  const Model* pSBMLModel = pDocument->getModel();
778  CPPUNIT_ASSERT(pSBMLModel != NULL);
779  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
780  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
781  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
782  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
783  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
784  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
785  // now we add a new parameter
786  CModel* pModel = pDataModel->getModel();
787  CPPUNIT_ASSERT(pModel != NULL);
788  CModelValue* pModelValue = pModel->createModelValue("parameter_2");
789  CPPUNIT_ASSERT(pModelValue != NULL);
790  pModel->compileIfNecessary(NULL);
791  std::set<const CCopasiObject*> changedObjects;
792  const CCopasiObject* pObject = pModelValue->getInitialValueReference();
793  CPPUNIT_ASSERT(pObject != NULL);
794  changedObjects.insert(pObject);
795  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
796  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
797 
798  while (refreshIt != refreshEndit)
799  {
800  (**refreshIt++)();
801  }
802 
803  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
804  pDocument = pDataModel->getCurrentSBMLDocument();
805  pSBMLModel = pDocument->getModel();
806  CPPUNIT_ASSERT(pSBMLModel != NULL);
807  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
808  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
809  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
810  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
811  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
812  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 2);
813  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
814 }
SBMLDocument * getCurrentSBMLDocument()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000059.h:85
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000059.cpp:44
CCopasiObject * getInitialValueReference() const
static const char * MODEL_STRING6
Definition: test000059.h:68
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
void test000059::test_unique_id_7 ( )

Definition at line 816 of file test000059.cpp.

References CReaction::addProduct(), checkIfIdsUnique(), CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiDataModel::getModel(), CCopasiParameterGroup::getParameter(), CReaction::getParameters(), CCopasiParameter::getValueReference(), CCopasiDataModel::importSBMLFromString(), MODEL_STRING7, pCOPASIDATAMODEL, CReaction::setFunction(), and CReaction::setParameterValue().

817 {
818  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
819  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000059::MODEL_STRING7));
820  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
821  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
822  const Model* pSBMLModel = pDocument->getModel();
823  CPPUNIT_ASSERT(pSBMLModel != NULL);
824  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
825  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
826  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
827  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
828  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
829  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
830  // now we add a new reaction
831  CModel* pModel = pDataModel->getModel();
832  CPPUNIT_ASSERT(pModel != NULL);
833  CReaction* pReaction = pModel->createReaction("influx");
834  CPPUNIT_ASSERT(pReaction != NULL);
835  pReaction->addProduct(pModel->getMetabolites()[0]->getKey());
836  pReaction->setFunction("Constant flux (irreversible)");
837  pReaction->setParameterValue("v", 1.0, true);
838  pModel->compileIfNecessary(NULL);
839  std::set<const CCopasiObject*> changedObjects;
840  changedObjects.insert(pReaction->getParameters().getParameter(0)->getValueReference());
841  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
842  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
843 
844  while (refreshIt != refreshEndit)
845  {
846  (**refreshIt++)();
847  }
848 
849  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
850  pDocument = pDataModel->getCurrentSBMLDocument();
851  pSBMLModel = pDocument->getModel();
852  CPPUNIT_ASSERT(pSBMLModel != NULL);
853  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 2);
854  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
855  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
856  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 2);
857  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
858  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
859  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
860 }
SBMLDocument * getCurrentSBMLDocument()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000059.h:85
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000059.cpp:44
void setParameterValue(const std::string &parameterName, const C_FLOAT64 &value, const bool &updateStatus=true)
Definition: CReaction.cpp:303
CCopasiObject * getValueReference() const
bool addProduct(const std::string &metabKey, const C_FLOAT64 &multiplicity=1.0)
Definition: CReaction.cpp:236
static const char * MODEL_STRING7
Definition: test000059.h:69
bool setFunction(const std::string &functionName)
Definition: CReaction.cpp:255
CCopasiParameter * getParameter(const std::string &name)
const CCopasiParameterGroup & getParameters() const
Definition: CReaction.cpp:333
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
void test000059::test_unique_id_8 ( )

Definition at line 862 of file test000059.cpp.

References checkIfIdsUnique(), CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CModelEntity::getInitialValueReference(), CCopasiDataModel::getModel(), CCopasiDataModel::importSBMLFromString(), MODEL_STRING8, and pCOPASIDATAMODEL.

863 {
864  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
865  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000059::MODEL_STRING8));
866  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
867  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
868  const Model* pSBMLModel = pDocument->getModel();
869  CPPUNIT_ASSERT(pSBMLModel != NULL);
870  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
871  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
872  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
873  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
874  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
875  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
876  // now we add a new parameter
877  CModel* pModel = pDataModel->getModel();
878  CPPUNIT_ASSERT(pModel != NULL);
879  CModelValue* pModelValue = pModel->createModelValue("parameter_2");
880  CPPUNIT_ASSERT(pModelValue != NULL);
881  pModel->compileIfNecessary(NULL);
882  std::set<const CCopasiObject*> changedObjects;
883  const CCopasiObject* pObject = pModelValue->getInitialValueReference();
884  CPPUNIT_ASSERT(pObject != NULL);
885  changedObjects.insert(pObject);
886  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
887  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
888 
889  while (refreshIt != refreshEndit)
890  {
891  (**refreshIt++)();
892  }
893 
894  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
895  pDocument = pDataModel->getCurrentSBMLDocument();
896  pSBMLModel = pDocument->getModel();
897  CPPUNIT_ASSERT(pSBMLModel != NULL);
898  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
899  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
900  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
901  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
902  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
903  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 2);
904  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
905 }
SBMLDocument * getCurrentSBMLDocument()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000059.h:85
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000059.cpp:44
CCopasiObject * getInitialValueReference() const
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
static const char * MODEL_STRING8
Definition: test000059.h:70
Definition: CModel.h:50
void test000059::test_unique_id_9 ( )

Definition at line 907 of file test000059.cpp.

References CReaction::addProduct(), checkIfIdsUnique(), CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiDataModel::getModel(), CCopasiParameterGroup::getParameter(), CReaction::getParameters(), CCopasiParameter::getValueReference(), CCopasiDataModel::importSBMLFromString(), MODEL_STRING9, pCOPASIDATAMODEL, CReaction::setFunction(), and CReaction::setParameterValue().

908 {
909  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
910  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000059::MODEL_STRING9));
911  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
912  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
913  const Model* pSBMLModel = pDocument->getModel();
914  CPPUNIT_ASSERT(pSBMLModel != NULL);
915  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
916  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
917  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
918  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
919  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
920  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
921  // now we add a new reaction
922  CModel* pModel = pDataModel->getModel();
923  CPPUNIT_ASSERT(pModel != NULL);
924  CReaction* pReaction = pModel->createReaction("influx");
925  CPPUNIT_ASSERT(pReaction != NULL);
926  pReaction->addProduct(pModel->getMetabolites()[0]->getKey());
927  pReaction->setFunction("Constant flux (irreversible)");
928  pReaction->setParameterValue("v", 1.0, true);
929  pModel->compileIfNecessary(NULL);
930  std::set<const CCopasiObject*> changedObjects;
931  changedObjects.insert(pReaction->getParameters().getParameter(0)->getValueReference());
932  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
933  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
934 
935  while (refreshIt != refreshEndit)
936  {
937  (**refreshIt++)();
938  }
939 
940  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
941  pDocument = pDataModel->getCurrentSBMLDocument();
942  pSBMLModel = pDocument->getModel();
943  CPPUNIT_ASSERT(pSBMLModel != NULL);
944  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 2);
945  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
946  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
947  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 2);
948  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
949  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
950  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
951 }
SBMLDocument * getCurrentSBMLDocument()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000059.h:85
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000059.cpp:44
void setParameterValue(const std::string &parameterName, const C_FLOAT64 &value, const bool &updateStatus=true)
Definition: CReaction.cpp:303
CCopasiObject * getValueReference() const
bool addProduct(const std::string &metabKey, const C_FLOAT64 &multiplicity=1.0)
Definition: CReaction.cpp:236
bool setFunction(const std::string &functionName)
Definition: CReaction.cpp:255
CCopasiParameter * getParameter(const std::string &name)
const CCopasiParameterGroup & getParameters() const
Definition: CReaction.cpp:333
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
static const char * MODEL_STRING9
Definition: test000059.h:71
Definition: CModel.h:50

Member Data Documentation

const char * test000059::MODEL_STRING1
staticprotected

Definition at line 63 of file test000059.h.

Referenced by test_unique_id_1().

const char * test000059::MODEL_STRING10
staticprotected

Definition at line 72 of file test000059.h.

Referenced by test_unique_id_10().

const char * test000059::MODEL_STRING11
staticprotected

Definition at line 73 of file test000059.h.

Referenced by test_unique_id_11().

const char * test000059::MODEL_STRING12
staticprotected

Definition at line 74 of file test000059.h.

Referenced by test_unique_id_12().

const char * test000059::MODEL_STRING13
staticprotected

Definition at line 75 of file test000059.h.

Referenced by test_unique_id_13().

const char * test000059::MODEL_STRING14
staticprotected

Definition at line 76 of file test000059.h.

Referenced by test_unique_id_14().

const char * test000059::MODEL_STRING15
staticprotected

Definition at line 77 of file test000059.h.

Referenced by test_unique_id_15().

const char * test000059::MODEL_STRING16
staticprotected

Definition at line 78 of file test000059.h.

Referenced by test_unique_id_16().

const char * test000059::MODEL_STRING17
staticprotected

Definition at line 79 of file test000059.h.

Referenced by test_unique_id_17().

const char * test000059::MODEL_STRING18
staticprotected

Definition at line 80 of file test000059.h.

Referenced by test_unique_id_18().

const char * test000059::MODEL_STRING19
staticprotected

Definition at line 81 of file test000059.h.

Referenced by test_unique_id_19().

const char * test000059::MODEL_STRING2
staticprotected

Definition at line 64 of file test000059.h.

Referenced by test_unique_id_2().

const char * test000059::MODEL_STRING20
staticprotected

Definition at line 82 of file test000059.h.

Referenced by test_unique_id_20().

const char * test000059::MODEL_STRING21
staticprotected

Definition at line 83 of file test000059.h.

Referenced by test_unique_id_21(), and test_unique_id_21_2().

const char * test000059::MODEL_STRING22
staticprotected

Definition at line 84 of file test000059.h.

Referenced by test_unique_id_22().

const char * test000059::MODEL_STRING3
staticprotected

Definition at line 65 of file test000059.h.

Referenced by test_unique_id_3().

const char * test000059::MODEL_STRING4
staticprotected

Definition at line 66 of file test000059.h.

Referenced by test_unique_id_4().

const char * test000059::MODEL_STRING5
staticprotected

Definition at line 67 of file test000059.h.

Referenced by test_unique_id_5().

const char * test000059::MODEL_STRING6
staticprotected

Definition at line 68 of file test000059.h.

Referenced by test_unique_id_6().

const char * test000059::MODEL_STRING7
staticprotected

Definition at line 69 of file test000059.h.

Referenced by test_unique_id_7().

const char * test000059::MODEL_STRING8
staticprotected

Definition at line 70 of file test000059.h.

Referenced by test_unique_id_8().

const char * test000059::MODEL_STRING9
staticprotected

Definition at line 71 of file test000059.h.

Referenced by test_unique_id_9().

CCopasiDataModel * test000059::pCOPASIDATAMODEL = NULL
staticprotected

The documentation for this class was generated from the following files: