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

#include <test000058.h>

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

Public Member Functions

void setUp ()
 
void tearDown ()
 
void test_bug1025_1 ()
 
void test_bug1025_10 ()
 
void test_bug1025_2 ()
 
void test_bug1025_3 ()
 
void test_bug1025_4 ()
 
void test_bug1025_5 ()
 
void test_bug1025_6 ()
 
void test_bug1025_7 ()
 
void test_bug1025_8 ()
 
void test_bug1025_9 ()
 

Protected Member Functions

bool checkIfIdsUnique (const Model *pSBMLModel)
 

Static Protected Attributes

static const char * MODEL_STRING
 
static const char * MODEL_STRING2
 
static CCopasiDataModelpCOPASIDATAMODEL = NULL
 

Private Member Functions

 CPPUNIT_TEST (test_bug1025_1)
 
 CPPUNIT_TEST (test_bug1025_2)
 
 CPPUNIT_TEST (test_bug1025_3)
 
 CPPUNIT_TEST (test_bug1025_4)
 
 CPPUNIT_TEST (test_bug1025_5)
 
 CPPUNIT_TEST (test_bug1025_6)
 
 CPPUNIT_TEST (test_bug1025_7)
 
 CPPUNIT_TEST (test_bug1025_8)
 
 CPPUNIT_TEST (test_bug1025_9)
 
 CPPUNIT_TEST (test_bug1025_10)
 
 CPPUNIT_TEST_SUITE (test000058)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 25 of file test000058.h.

Member Function Documentation

bool test000058::checkIfIdsUnique ( const Model *  pSBMLModel)
protected

Definition at line 44 of file test000058.cpp.

Referenced by test_bug1025_1(), test_bug1025_10(), test_bug1025_2(), test_bug1025_3(), test_bug1025_4(), test_bug1025_5(), test_bug1025_6(), test_bug1025_7(), test_bug1025_8(), and test_bug1025_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
test000058::CPPUNIT_TEST ( test_bug1025_1  )
private
test000058::CPPUNIT_TEST ( test_bug1025_2  )
private
test000058::CPPUNIT_TEST ( test_bug1025_3  )
private
test000058::CPPUNIT_TEST ( test_bug1025_4  )
private
test000058::CPPUNIT_TEST ( test_bug1025_5  )
private
test000058::CPPUNIT_TEST ( test_bug1025_6  )
private
test000058::CPPUNIT_TEST ( test_bug1025_7  )
private
test000058::CPPUNIT_TEST ( test_bug1025_8  )
private
test000058::CPPUNIT_TEST ( test_bug1025_9  )
private
test000058::CPPUNIT_TEST ( test_bug1025_10  )
private
test000058::CPPUNIT_TEST_SUITE ( test000058  )
private
test000058::CPPUNIT_TEST_SUITE_END ( )
private
void test000058::setUp ( )

Definition at line 31 of file test000058.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: test000058.h:43
static CCopasiDataModel * addDatamodel()
static void init(int argc, char *argv[], const bool &withGui=false)
void test000058::tearDown ( )

Definition at line 39 of file test000058.cpp.

References CCopasiRootContainer::destroy().

void test000058::test_bug1025_1 ( )

Definition at line 545 of file test000058.cpp.

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

546 {
547  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
548  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000058::MODEL_STRING));
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 reaction
560  CModel* pModel = pDataModel->getModel();
561  CPPUNIT_ASSERT(pModel != NULL);
562  CReaction* pReaction = pModel->createReaction("influx");
563  CPPUNIT_ASSERT(pReaction != NULL);
564  pReaction->addProduct(pModel->getMetabolites()[0]->getKey());
565  pReaction->setFunction("Constant flux (irreversible)");
566  pReaction->setParameterValue("v", 1.0, true);
567  pModel->compileIfNecessary(NULL);
568  std::set<const CCopasiObject*> changedObjects;
569  changedObjects.insert(pReaction->getParameters().getParameter(0)->getValueReference());
570  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
571  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
572 
573  while (refreshIt != refreshEndit)
574  {
575  (**refreshIt++)();
576  }
577 
578  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
579  pDocument = pDataModel->getCurrentSBMLDocument();
580  pSBMLModel = pDocument->getModel();
581  CPPUNIT_ASSERT(pSBMLModel != NULL);
582  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 2);
583  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
584  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
585  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 2);
586  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
587  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
588  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
589 }
SBMLDocument * getCurrentSBMLDocument()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000058.h:43
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
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_STRING
Definition: test000058.h:41
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
bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000058.cpp:44
void test000058::test_bug1025_10 ( )

Definition at line 938 of file test000058.cpp.

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

939 {
940  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
941  std::istringstream iss(test000058::MODEL_STRING2);
942  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
943  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
944  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
945  CPPUNIT_ASSERT(pDocument == NULL);
946  // now we add a new parameter
947  CModel* pModel = pDataModel->getModel();
948  CPPUNIT_ASSERT(pModel != NULL);
949  // add a new function definition
950  CFunction* pFunctionDefinition = new CFunction("function_2");
951  CPPUNIT_ASSERT(pFunctionDefinition != NULL);
952  CPPUNIT_ASSERT(pFunctionDefinition->setInfix("3 * 5") == true);
953  pFunctionDefinition->compile();
954  // add the function definition to the function database
956  CModelValue* pModelValue = pModel->createModelValue("parameter_2");
957  CPPUNIT_ASSERT(pModelValue != NULL);
958  pModelValue->setStatus(CModelEntity::ASSIGNMENT);
959  CPPUNIT_ASSERT(pModelValue->setExpression(std::string(pFunctionDefinition->getObjectName() + "()")) == true);
960  // now create a rule for the parameter
961  pModel->compileIfNecessary(NULL);
962  std::set<const CCopasiObject*> changedObjects;
963  const CCopasiObject* pObject = pModelValue->getInitialValueReference();
964  CPPUNIT_ASSERT(pObject != NULL);
965  changedObjects.insert(pObject);
966  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
967  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
968 
969  while (refreshIt != refreshEndit)
970  {
971  (**refreshIt++)();
972  }
973 
974  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
975  pDocument = pDataModel->getCurrentSBMLDocument();
976  const Model* pSBMLModel = pDocument->getModel();
977  CPPUNIT_ASSERT(pSBMLModel != NULL);
978  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 2);
979  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
980  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
981  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
982  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 1);
983  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 2);
984  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
985 }
SBMLDocument * getCurrentSBMLDocument()
CFunction * addAndAdaptName(CFunction *pFunction)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000058.h:43
const std::string & getObjectName() const
static const char * MODEL_STRING2
Definition: test000058.h:42
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
CCopasiObject * getInitialValueReference() const
CModelValue * createModelValue(const std::string &name, const C_FLOAT64 &value=0.0)
Definition: CModel.cpp:2838
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()
bool compileIfNecessary(CProcessReport *pProcessReport)
Definition: CModel.cpp:612
virtual bool compile()
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
Definition: CModel.h:50
std::vector< Refresh * > buildInitialRefreshSequence(std::set< const CCopasiObject * > &changedObjects)
Definition: CModel.cpp:4164
bool setExpression(const std::string &expression)
bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000058.cpp:44
void test000058::test_bug1025_2 ( )

Definition at line 591 of file test000058.cpp.

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

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

Definition at line 636 of file test000058.cpp.

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

637 {
638  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
639  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000058::MODEL_STRING));
640  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
641  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
642  const Model* pSBMLModel = pDocument->getModel();
643  CPPUNIT_ASSERT(pSBMLModel != NULL);
644  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
645  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
646  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
647  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
648  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
649  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
650  // now we add a new species
651  CModel* pModel = pDataModel->getModel();
652  CPPUNIT_ASSERT(pModel != NULL);
653  CMetab* pMetabolite = pModel->createMetabolite("species_2", "compartment_1", 1.0, CModelEntity::FIXED);
654  CPPUNIT_ASSERT(pMetabolite != NULL);
655  pModel->compileIfNecessary(NULL);
656  std::set<const CCopasiObject*> changedObjects;
657  const CCopasiObject* pObject = pMetabolite->getInitialConcentrationReference();
658  CPPUNIT_ASSERT(pObject != NULL);
659  changedObjects.insert(pObject);
660  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
661  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
662 
663  while (refreshIt != refreshEndit)
664  {
665  (**refreshIt++)();
666  }
667 
668  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
669  pDocument = pDataModel->getCurrentSBMLDocument();
670  pSBMLModel = pDocument->getModel();
671  CPPUNIT_ASSERT(pSBMLModel != NULL);
672  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
673  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
674  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 2);
675  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
676  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
677  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
678  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
679 }
SBMLDocument * getCurrentSBMLDocument()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000058.h:43
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static const char * MODEL_STRING
Definition: test000058.h:41
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
bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000058.cpp:44
void test000058::test_bug1025_4 ( )

Definition at line 681 of file test000058.cpp.

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

682 {
683  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
684  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000058::MODEL_STRING));
685  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
686  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
687  const Model* pSBMLModel = pDocument->getModel();
688  CPPUNIT_ASSERT(pSBMLModel != NULL);
689  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
690  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
691  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
692  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
693  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
694  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
695  // now we add a new parameter
696  CModel* pModel = pDataModel->getModel();
697  CPPUNIT_ASSERT(pModel != NULL);
698  CModelValue* pModelValue = pModel->createModelValue("parameter_2");
699  CPPUNIT_ASSERT(pModelValue != NULL);
700  pModel->compileIfNecessary(NULL);
701  std::set<const CCopasiObject*> changedObjects;
702  const CCopasiObject* pObject = pModelValue->getInitialValueReference();
703  CPPUNIT_ASSERT(pObject != NULL);
704  changedObjects.insert(pObject);
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() == 1);
718  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
719  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
720  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
721  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
722  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 2);
723  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
724 }
SBMLDocument * getCurrentSBMLDocument()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000058.h:43
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
CCopasiObject * getInitialValueReference() const
static const char * MODEL_STRING
Definition: test000058.h:41
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000058.cpp:44
void test000058::test_bug1025_5 ( )

Definition at line 726 of file test000058.cpp.

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

727 {
728  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
729  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000058::MODEL_STRING));
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 parameter
741  CModel* pModel = pDataModel->getModel();
742  CPPUNIT_ASSERT(pModel != NULL);
743  // add a new function definition
744  CFunction* pFunctionDefinition = new CFunction("function_2");
745  CPPUNIT_ASSERT(pFunctionDefinition != NULL);
746  CPPUNIT_ASSERT(pFunctionDefinition->setInfix("3 * 5") == true);
747  pFunctionDefinition->compile();
748  // add the function definition to the function database
750  CModelValue* pModelValue = pModel->createModelValue("parameter_2");
751  CPPUNIT_ASSERT(pModelValue != NULL);
752  pModelValue->setStatus(CModelEntity::ASSIGNMENT);
753  CPPUNIT_ASSERT(pModelValue->setExpression(std::string(pFunctionDefinition->getObjectName() + "()")) == true);
754  // now create a rule for the parameter
755  pModel->compileIfNecessary(NULL);
756  std::set<const CCopasiObject*> changedObjects;
757  const CCopasiObject* pObject = pModelValue->getInitialValueReference();
758  CPPUNIT_ASSERT(pObject != NULL);
759  changedObjects.insert(pObject);
760  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
761  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
762 
763  while (refreshIt != refreshEndit)
764  {
765  (**refreshIt++)();
766  }
767 
768  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
769  pDocument = pDataModel->getCurrentSBMLDocument();
770  pSBMLModel = pDocument->getModel();
771  CPPUNIT_ASSERT(pSBMLModel != NULL);
772  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 2);
773  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
774  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
775  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
776  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 1);
777  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 2);
778  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
779 }
SBMLDocument * getCurrentSBMLDocument()
CFunction * addAndAdaptName(CFunction *pFunction)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000058.h:43
const std::string & getObjectName() const
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
CCopasiObject * getInitialValueReference() const
static const char * MODEL_STRING
Definition: test000058.h:41
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)
bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000058.cpp:44
void test000058::test_bug1025_6 ( )

Definition at line 781 of file test000058.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_STRING2, pCOPASIDATAMODEL, CReaction::setFunction(), and CReaction::setParameterValue().

782 {
783  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
784  std::istringstream iss(test000058::MODEL_STRING2);
785  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
786  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
787  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
788  CPPUNIT_ASSERT(pDocument == NULL);
789  // now we add a new reaction
790  CModel* pModel = pDataModel->getModel();
791  CPPUNIT_ASSERT(pModel != NULL);
792  CReaction* pReaction = pModel->createReaction("influx");
793  CPPUNIT_ASSERT(pReaction != NULL);
794  pReaction->addProduct(pModel->getMetabolites()[0]->getKey());
795  pReaction->setFunction("Constant flux (irreversible)");
796  pReaction->setParameterValue("v", 1.0, true);
797  pModel->compileIfNecessary(NULL);
798  std::set<const CCopasiObject*> changedObjects;
799  changedObjects.insert(pReaction->getParameters().getParameter(0)->getValueReference());
800  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
801  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
802 
803  while (refreshIt != refreshEndit)
804  {
805  (**refreshIt++)();
806  }
807 
808  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
809  pDocument = pDataModel->getCurrentSBMLDocument();
810  const Model* pSBMLModel = pDocument->getModel();
811  CPPUNIT_ASSERT(pSBMLModel != NULL);
812  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 2);
813  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
814  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
815  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 2);
816  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
817  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
818  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
819 }
SBMLDocument * getCurrentSBMLDocument()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000058.h:43
const CCopasiVector< CMetab > & getMetabolites() const
Definition: CModel.cpp:1051
static const char * MODEL_STRING2
Definition: test000058.h:42
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
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
bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000058.cpp:44
void test000058::test_bug1025_7 ( )

Definition at line 821 of file test000058.cpp.

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

822 {
823  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
824  std::istringstream iss(test000058::MODEL_STRING2);
825  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
826  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
827  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
828  CPPUNIT_ASSERT(pDocument == NULL);
829  // now we add a new compartment
830  CModel* pModel = pDataModel->getModel();
831  CPPUNIT_ASSERT(pModel != NULL);
832  CCompartment* pCompartment = pModel->createCompartment("compartment_2");
833  CPPUNIT_ASSERT(pCompartment != NULL);
834  pModel->compileIfNecessary(NULL);
835  std::set<const CCopasiObject*> changedObjects;
836  const CCopasiObject* pObject = pCompartment->getInitialValueReference();
837  CPPUNIT_ASSERT(pObject != NULL);
838  changedObjects.insert(pObject);
839  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
840  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
841 
842  while (refreshIt != refreshEndit)
843  {
844  (**refreshIt++)();
845  }
846 
847  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
848  pDocument = pDataModel->getCurrentSBMLDocument();
849  const Model* pSBMLModel = pDocument->getModel();
850  CPPUNIT_ASSERT(pSBMLModel != NULL);
851  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
852  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 2);
853  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
854  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
855  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
856  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
857  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
858 }
SBMLDocument * getCurrentSBMLDocument()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000058.h:43
static const char * MODEL_STRING2
Definition: test000058.h:42
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
CCopasiObject * getInitialValueReference() const
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
bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000058.cpp:44
CCompartment * createCompartment(const std::string &name, const C_FLOAT64 &volume=1.0)
Definition: CModel.cpp:2698
void test000058::test_bug1025_8 ( )

Definition at line 860 of file test000058.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_STRING2, and pCOPASIDATAMODEL.

861 {
862  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
863  std::istringstream iss(test000058::MODEL_STRING2);
864  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
865  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
866  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
867  CPPUNIT_ASSERT(pDocument == NULL);
868  // now we add a new species
869  CModel* pModel = pDataModel->getModel();
870  CPPUNIT_ASSERT(pModel != NULL);
871  CMetab* pMetabolite = pModel->createMetabolite("species_2", "compartment_1", 1.0, CModelEntity::FIXED);
872  CPPUNIT_ASSERT(pMetabolite != NULL);
873  pModel->compileIfNecessary(NULL);
874  std::set<const CCopasiObject*> changedObjects;
875  const CCopasiObject* pObject = pMetabolite->getInitialConcentrationReference();
876  CPPUNIT_ASSERT(pObject != NULL);
877  changedObjects.insert(pObject);
878  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
879  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
880 
881  while (refreshIt != refreshEndit)
882  {
883  (**refreshIt++)();
884  }
885 
886  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
887  pDocument = pDataModel->getCurrentSBMLDocument();
888  const Model* pSBMLModel = pDocument->getModel();
889  CPPUNIT_ASSERT(pSBMLModel != NULL);
890  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
891  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
892  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 2);
893  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
894  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
895  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
896  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
897 }
SBMLDocument * getCurrentSBMLDocument()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000058.h:43
static const char * MODEL_STRING2
Definition: test000058.h:42
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
Definition: CMetab.h:178
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
CConcentrationReference * getInitialConcentrationReference() const
Definition: CMetab.cpp:861
std::vector< Refresh * > buildInitialRefreshSequence(std::set< const CCopasiObject * > &changedObjects)
Definition: CModel.cpp:4164
bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000058.cpp:44
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 test000058::test_bug1025_9 ( )

Definition at line 899 of file test000058.cpp.

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

900 {
901  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
902  std::istringstream iss(test000058::MODEL_STRING2);
903  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
904  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
905  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
906  CPPUNIT_ASSERT(pDocument == NULL);
907  // now we add a new parameter
908  CModel* pModel = pDataModel->getModel();
909  CPPUNIT_ASSERT(pModel != NULL);
910  CModelValue* pModelValue = pModel->createModelValue("parameter_2");
911  CPPUNIT_ASSERT(pModelValue != NULL);
912  pModel->compileIfNecessary(NULL);
913  std::set<const CCopasiObject*> changedObjects;
914  const CCopasiObject* pObject = pModelValue->getInitialValueReference();
915  CPPUNIT_ASSERT(pObject != NULL);
916  changedObjects.insert(pObject);
917  std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
918  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
919 
920  while (refreshIt != refreshEndit)
921  {
922  (**refreshIt++)();
923  }
924 
925  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
926  pDocument = pDataModel->getCurrentSBMLDocument();
927  const Model* pSBMLModel = pDocument->getModel();
928  CPPUNIT_ASSERT(pSBMLModel != NULL);
929  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 1);
930  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
931  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
932  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 1);
933  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
934  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 2);
935  CPPUNIT_ASSERT(checkIfIdsUnique(pSBMLModel) == true);
936 }
SBMLDocument * getCurrentSBMLDocument()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000058.h:43
static const char * MODEL_STRING2
Definition: test000058.h:42
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
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
Definition: CModel.h:50
std::vector< Refresh * > buildInitialRefreshSequence(std::set< const CCopasiObject * > &changedObjects)
Definition: CModel.cpp:4164
bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000058.cpp:44

Member Data Documentation

const char * test000058::MODEL_STRING
staticprotected
const char * test000058::MODEL_STRING2
staticprotected
CCopasiDataModel * test000058::pCOPASIDATAMODEL = NULL
staticprotected

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