COPASI API  4.16.103
test000087.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/sbml/unittests/test000087.cpp,v $
3 // $Revision: 1.7 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2011/04/01 15:06:43 $
7 // End CVS Header
8 
9 // Copyright (C) 2011 - 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
16 // and The University of Manchester.
17 // All rights reserved.
18 
19 #include "test000087.h"
20 
21 #include <sstream>
22 #include <limits>
23 
24 #include "utilities.hpp"
30 #include "copasi/model/CModel.h"
31 #include "copasi/model/CReaction.h"
39 
40 #include <sbml/SBMLDocument.h>
41 #include <sbml/Model.h>
42 #include <sbml/Species.h>
43 #include <sbml/Reaction.h>
44 #include <sbml/Rule.h>
45 #include <sbml/math/ASTNode.h>
46 
47 CCopasiDataModel* test000087::pCOPASIDATAMODEL = NULL;
48 
50 {
51  // Create the root container.
52  CCopasiRootContainer::init(0, NULL, false);
53  // Create the global data model.
55 }
56 
58 {
60 }
61 
63 {
64  try
65  {
67  }
68  catch (...)
69  {
70  // there should be an exception (MCSBML + 81)
71  unsigned int i, iMax = CCopasiMessage::size();
72  CCopasiMessage message;
73  bool found81 = false;
74 
75  for (i = 0; i < iMax; ++i)
76  {
78 
79  if (message.getNumber() == MCSBML + 81)
80  {
81  found81 = true;
82  break;
83  }
84  }
85 
86  CPPUNIT_ASSERT(found81 == true);
87  return;
88  }
89 
90  // we should never get here
91  CPPUNIT_ASSERT(false);
92 }
93 
95 {
96  try
97  {
99  }
100  catch (...)
101  {
102  // there should not be an exception
103  CPPUNIT_ASSERT(false);
104  }
105 
106  CPPUNIT_ASSERT(pCOPASIDATAMODEL->getModel() != NULL);
107  CPPUNIT_ASSERT(pCOPASIDATAMODEL->getModel()->getCompartments().size() == 1);
108  CPPUNIT_ASSERT(pCOPASIDATAMODEL->getModel()->getMetabolites().size() == 2);
109  CPPUNIT_ASSERT(pCOPASIDATAMODEL->getModel()->getModelValues().size() == 1);
110  CPPUNIT_ASSERT(pCOPASIDATAMODEL->getModel()->getReactions().size() == 1);
111  const CReaction* pReaction = pCOPASIDATAMODEL->getModel()->getReactions()[0];
112  CPPUNIT_ASSERT(pReaction != NULL);
113  const CModelValue* pMV = pCOPASIDATAMODEL->getModel()->getModelValues()[0];
114  CPPUNIT_ASSERT(pMV != NULL);
115  CPPUNIT_ASSERT(pMV->getStatus() == CModelEntity::ASSIGNMENT);
116  const CExpression* pExpr = pMV->getExpressionPtr();
117  CPPUNIT_ASSERT(pExpr != NULL);
118  const CEvaluationNode* pRoot = pExpr->getRoot();
119  CPPUNIT_ASSERT(pRoot != NULL);
120  CPPUNIT_ASSERT(CEvaluationNode::type(pRoot->getType()) == CEvaluationNode::OBJECT);
121  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pRoot);
122  CPPUNIT_ASSERT(pObjectNode != NULL);
123  const CRegisteredObjectName cn = pObjectNode->getObjectCN();
124  std::vector<CCopasiContainer*> listOfContainers;
125  listOfContainers.push_back(pCOPASIDATAMODEL->getModel());
126  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, cn);
127  CPPUNIT_ASSERT(pObject != NULL);
128  CPPUNIT_ASSERT(pObject->isReference() == true);
129  CPPUNIT_ASSERT(pObject->getObjectName() == "Flux");
130  CPPUNIT_ASSERT(pObject->getObjectParent() == pReaction);
131 }
132 
134 {
135  try
136  {
138  }
139  catch (...)
140  {
141  // there should be an exception (MCSBML + 81)
142  unsigned int i, iMax = CCopasiMessage::size();
143  CCopasiMessage message;
144  bool found80 = false;
145 
146  for (i = 0; i < iMax; ++i)
147  {
148  message = CCopasiMessage::getLastMessage();
149 
150  if (message.getNumber() == MCSBML + 80)
151  {
152  found80 = true;
153  break;
154  }
155  }
156 
157  CPPUNIT_ASSERT(found80 == true);
158  return;
159  }
160 
161  // we should never get here
162  CPPUNIT_ASSERT(false);
163 }
164 
166 {
167  try
168  {
169  std::istringstream iss(test000087::MODEL_STRING4);
170  bool result = load_cps_model_from_stream(iss, *pCOPASIDATAMODEL);
171  CPPUNIT_ASSERT(result == true);
172  CPPUNIT_ASSERT(pCOPASIDATAMODEL->getModel() != NULL);
173  }
174  catch (...)
175  {
176  // there should be no exception
177  CPPUNIT_ASSERT(false);
178  }
179 
180  try
181  {
182  CPPUNIT_ASSERT(pCOPASIDATAMODEL->exportSBMLToString(NULL, 2, 3).empty() == false);
183  }
184  catch (...)
185  {
186  // there should be no exception
187  CPPUNIT_ASSERT(false);
188  }
189 
190  CPPUNIT_ASSERT(CCopasiMessage::size() == 0);
191  const SBMLDocument* pDocument = pCOPASIDATAMODEL->getCurrentSBMLDocument();
192  CPPUNIT_ASSERT(pDocument != NULL);
193  CPPUNIT_ASSERT(pDocument->getLevel() == 2);
194  CPPUNIT_ASSERT(pDocument->getVersion() == 3);
195  const Model* pModel = pDocument->getModel();
196  CPPUNIT_ASSERT(pModel != NULL);
197  CPPUNIT_ASSERT(pModel->getListOfFunctionDefinitions()->size() == 0);
198  CPPUNIT_ASSERT(pModel->getListOfCompartments()->size() == 1);
199  CPPUNIT_ASSERT(pModel->getListOfSpecies()->size() == 3);
200  CPPUNIT_ASSERT(pModel->getListOfReactions()->size() == 1);
201  CPPUNIT_ASSERT(pModel->getListOfRules()->size() == 1);
202  const Reaction* pReaction = pModel->getReaction(0);
203  CPPUNIT_ASSERT(pReaction != NULL);
204  std::string reactionId = pReaction->getId();
205  CPPUNIT_ASSERT(reactionId.empty() == false);
206  const Rule* pRule = pModel->getRule(0);
207  CPPUNIT_ASSERT(pRule != NULL);
208  CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
209  const AssignmentRule* pAssignmentRule = dynamic_cast<const AssignmentRule*>(pRule);
210  CPPUNIT_ASSERT(pAssignmentRule != NULL);
211  const Species* pSpecies = pModel->getSpecies(pAssignmentRule->getVariable());
212  CPPUNIT_ASSERT(pSpecies != NULL);
213  CPPUNIT_ASSERT(pSpecies->getName() == "C");
214  const ASTNode* pMath = pAssignmentRule->getMath();
215  CPPUNIT_ASSERT(pMath != NULL);
216  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
217  CPPUNIT_ASSERT(pMath->getName() == reactionId);
218 }
219 
221 {
222  try
223  {
224  std::istringstream iss(test000087::MODEL_STRING4);
225  bool result = load_cps_model_from_stream(iss, *pCOPASIDATAMODEL);
226  CPPUNIT_ASSERT(result == true);
227  CPPUNIT_ASSERT(pCOPASIDATAMODEL->getModel() != NULL);
228  }
229  catch (...)
230  {
231  // there should be no exception
232  CPPUNIT_ASSERT(false);
233  }
234 
235  try
236  {
237  std::string result = pCOPASIDATAMODEL->exportSBMLToString(NULL, 2, 1);
238  CPPUNIT_ASSERT(result.empty());
239  }
240  catch (...)
241  {
242  // there should be an exception
243  // check if the correct error message has been created
244  CPPUNIT_ASSERT(pCOPASIDATAMODEL->getCurrentSBMLDocument() == NULL);
245  // last message should be an exception
247  CPPUNIT_ASSERT(message.getType() == CCopasiMessage::EXCEPTION);
248  // see if the incompatibility message is there
249  bool found = false;
250 
251  while (CCopasiMessage::size() > 0)
252  {
253  message = CCopasiMessage::getLastMessage();
254 
255  if (message.getType() == CCopasiMessage::RAW)
256  {
257  std::string s = message.getText();
258 
259  if (s.find(std::string("SBML Incompatibility (10)")) != std::string::npos)
260  {
261  found = true;
262  break;
263  }
264  }
265  }
266 
267  CPPUNIT_ASSERT_MESSAGE("Error message not found.", found == true);
268  return;
269  }
270 
271  CPPUNIT_ASSERT(false);
272 }
273 
275 {
276  try
277  {
279  CPPUNIT_ASSERT(result = true);
280  }
281  catch (...)
282  {
283  // there should be no exception
284  CPPUNIT_ASSERT(false);
285  }
286 
287  CModel* pModel = pCOPASIDATAMODEL->getModel();
288  CPPUNIT_ASSERT(pModel != NULL);
289  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
290  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
291  CPPUNIT_ASSERT(pModel->getModelValues().size() == 2);
292  CPPUNIT_ASSERT(pModel->getReactions().size() == 1);
293  const CReaction* pReaction = pModel->getReactions()[0];
294  CPPUNIT_ASSERT(pReaction != NULL);
295  CModelValue* pConstParameter = NULL;
296  CModelValue* pNonConstParameter = NULL;
297  unsigned int i, iMax = pModel->getModelValues().size();
298 
299  for (i = 0; i < iMax; ++i)
300  {
301  if (pModel->getModelValues()[i]->getStatus() == CModelEntity::FIXED)
302  {
303  pConstParameter = pModel->getModelValues()[i];
304  }
305 
306  if (pModel->getModelValues()[i]->getStatus() == CModelEntity::ASSIGNMENT)
307  {
308  pNonConstParameter = pModel->getModelValues()[i];
309  }
310  }
311 
312  CPPUNIT_ASSERT(pConstParameter != NULL);
313  CPPUNIT_ASSERT(pNonConstParameter != NULL);
314  // check if the kinetic law is mass action with const global parameter as the kinetic constant
315  CPPUNIT_ASSERT(pReaction->getChemEq().getSubstrates().size() == 1);
316  CPPUNIT_ASSERT(pReaction->getChemEq().getProducts().size() == 1);
317  CPPUNIT_ASSERT(pReaction->getChemEq().getModifiers().size() == 0);
318  CPPUNIT_ASSERT(pReaction->isReversible() == false);
319  const CFunction* pKineticLaw = pReaction->getFunction();
320  CPPUNIT_ASSERT(pKineticLaw != NULL);
321  CPPUNIT_ASSERT(pKineticLaw->getType() == CEvaluationTree::MassAction);
322  const std::vector< std::vector<std::string> > & parameterMappings = pReaction->getParameterMappings();
323  CPPUNIT_ASSERT(parameterMappings.size() == 2);
324  CPPUNIT_ASSERT(parameterMappings[0].size() == 1);
325  CPPUNIT_ASSERT(parameterMappings[0][0] == pConstParameter->getKey());
326  CPPUNIT_ASSERT(parameterMappings[1].size() == 1);
327  std::string substrateKey = parameterMappings[1][0];
328  const CCopasiObject* pTempObject = CCopasiRootContainer::getKeyFactory()->get(substrateKey);
329  CPPUNIT_ASSERT(pTempObject != NULL);
330  const CMetab* pSubstrate = dynamic_cast<const CMetab*>(pTempObject);
331  CPPUNIT_ASSERT(pSubstrate != NULL);
332  // check that the assignment consists of only one object node that is a reference to the reaction flux
333  const CExpression* pExpression = pNonConstParameter->getExpressionPtr();
334  CPPUNIT_ASSERT(pExpression != NULL);
335  const CEvaluationNode* pRoot = pExpression->getRoot();
336  CPPUNIT_ASSERT(pRoot != NULL);
337  CPPUNIT_ASSERT(CEvaluationNode::type(pRoot->getType()) == CEvaluationNode::OBJECT);
338  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pRoot);
339  CPPUNIT_ASSERT(pObjectNode != NULL);
340  const CRegisteredObjectName cn = pObjectNode->getObjectCN();
341  std::vector<CCopasiContainer*> listOfContainers;
342  listOfContainers.push_back(pCOPASIDATAMODEL->getModel());
343  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, cn);
344  CPPUNIT_ASSERT(pObject != NULL);
345  CPPUNIT_ASSERT(pObject->isReference() == true);
346  CPPUNIT_ASSERT(pObject->getObjectName() == "Flux");
347  CPPUNIT_ASSERT(pObject->getObjectParent() == pReaction);
348  // Simulate the model (5 steps, stepsize 1 and check that at each step, the value of the variable parameter
349  // is the same as the flux through the reaction.
350  std::ostringstream result;
351  // create a report with the correct filename and all the species against
352  // time.
354  CReportDefinition* pReport = pReports->createReportDefinition("Report", "Output for simulation");
356  pReport->setIsTable(false);
357  pReport->setSeparator(CCopasiReportSeparator(", "));
358 
359  std::vector<CRegisteredObjectName>* pHeader = pReport->getHeaderAddr();
360  std::vector<CRegisteredObjectName>* pBody = pReport->getBodyAddr();
361  pHeader->push_back(CCopasiStaticString("time").getCN());
362  pHeader->push_back(pReport->getSeparator().getCN());
363  pHeader->push_back(CCopasiStaticString("substrate").getCN());
364  pHeader->push_back(pReport->getSeparator().getCN());
365  pHeader->push_back(CCopasiStaticString("reaction flux").getCN());
366  pHeader->push_back(pReport->getSeparator().getCN());
367  pHeader->push_back(CCopasiStaticString("variable model value").getCN());
368  pBody->push_back(CCopasiObjectName(pCOPASIDATAMODEL->getModel()->getCN() + ",Reference=Time"));
369  pBody->push_back(CRegisteredObjectName(pReport->getSeparator().getCN()));
370  pBody->push_back(CCopasiObjectName(pSubstrate->getCN() + ",Reference=Concentration"));
371  pBody->push_back(CRegisteredObjectName(pReport->getSeparator().getCN()));
372  pBody->push_back(CCopasiObjectName(pReaction->getCN() + ",Reference=Flux"));
373  pBody->push_back(CRegisteredObjectName(pReport->getSeparator().getCN()));
374  pBody->push_back(CCopasiObjectName(pNonConstParameter->getCN() + ",Reference=Value"));
375  //
376  // create a trajectory task
377  CTrajectoryTask* pTrajectoryTask = new CTrajectoryTask();
378  // use LSODAR from now on since we will have events pretty soon
379  pTrajectoryTask->setMethodType(CCopasiMethod::LSODAR);
380  pTrajectoryTask->getProblem()->setModel(pCOPASIDATAMODEL->getModel());
381 
382  pTrajectoryTask->setScheduled(true);
383  pTrajectoryTask->getReport().setReportDefinition(pReport);
384  // the target needs to be set in order to get output on the stream
385  // object passed to the task in the call to initialize below
386  pTrajectoryTask->getReport().setTarget("test.tmp");
387 
388  CTrajectoryProblem* pProblem = dynamic_cast<CTrajectoryProblem*>(pTrajectoryTask->getProblem());
389 
390  pProblem->setStepNumber((const unsigned C_INT32)30);
392  pProblem->setDuration((const C_FLOAT64)30);
393  pProblem->setTimeSeriesRequested(true);
394 
395  CTrajectoryMethod* pMethod = dynamic_cast<CTrajectoryMethod*>(pTrajectoryTask->getMethod());
396 
397  pMethod->getParameter("Absolute Tolerance")->setValue(1.0e-12);
398 
400 
401  TaskList.remove("Time-Course");
402  TaskList.add(pTrajectoryTask, true);
403 
404  try
405  {
406  pTrajectoryTask->initialize(CCopasiTask::OUTPUT_UI, pCOPASIDATAMODEL, &result);
407  pTrajectoryTask->process(true);
408  pTrajectoryTask->restore();
409  }
410  catch (...)
411  {
412  // there should be no exception
413  CPPUNIT_ASSERT(false);
414  }
415 
416  // analyse the result
417  CPPUNIT_ASSERT(!result.str().empty());
418  std::string result_string = result.str();
419  std::string delimiter = "\n";
420  std::string delimiter2 = ",";
421  std::size_t lastPos = result_string.find_first_not_of(delimiter);
422  std::size_t pos;
423  std::string line, number_string;
424  unsigned int index = 0;
425  unsigned int index2;
426  std::size_t lastPos2;
427  std::size_t pos2;
429 
430  while (lastPos != std::string::npos)
431  {
432  pos = result_string.find_first_of(delimiter, lastPos);
433  line = result_string.substr(lastPos, pos - lastPos);
434  lastPos = result_string.find_first_not_of(delimiter, pos);
435  lastPos2 = line.find_first_not_of(delimiter2);
436 
437  // skip the header line
438  if (index != 0)
439  {
440  index2 = 0;
441 
442  while (lastPos2 != std::string::npos)
443  {
444  pos2 = line.find_first_of(delimiter2, lastPos2);
445  number_string = line.substr(lastPos2, pos2 - lastPos2);
446  lastPos2 = line.find_first_not_of(delimiter2, pos2);
447 
448  // skip the time column
449  if (index2 != 0)
450  {
451  //check that all values in the row (besides the time)
452  // are always the same
453  if (index2 == 1)
454  {
455  last = strToDouble(number_string.c_str(), NULL);
456 
457  if (index == 1)
458  {
459  // just make sure that we don't compare all zeros
460  // The initial value of the substrate hould be higher than 1
461  CPPUNIT_ASSERT(fabs(pSubstrate->getInitialValue()) > 1);
462  // the first rwo should correspond the the initial value of the substrate
463  // We check this to make sure that the whole timeseries does not consist of zeros
464  CPPUNIT_ASSERT(fabs((last - pSubstrate->getInitialConcentration()) / pSubstrate->getInitialConcentration()) < 1e-20);
465  }
466  }
467  else
468  {
469  current = strToDouble(number_string.c_str(), NULL);
470  CPPUNIT_ASSERT(fabs((current - last) / last) < 1e-20);
471  last = current;
472  }
473  }
474 
475  ++index2;
476  }
477  }
478 
479  ++index;
480  }
481 
482  // make sure there actually were datapoints
483  CPPUNIT_ASSERT(index > 1);
484  // the simulation is set to run until all substrate is depleted, so in the end
485  // last should be below the absolute tolerance for the simulation
486  CPPUNIT_ASSERT(last < *pMethod->getParameter("Absolute Tolerance")->getValue().pDOUBLE);
487 }
488 
489 const char* test000087::MODEL_STRING1 =
490  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
491  "<sbml xmlns=\"http://www.sbml.org/sbml/level2\" level=\"2\" version=\"1\">\n"
492  " <model id=\"model_1\" name=\"model\">\n"
493  " <listOfCompartments>\n"
494  " <compartment id=\"compartment_1\" size=\"1\"/>\n"
495  " </listOfCompartments>\n"
496  " <listOfSpecies>\n"
497  " <species compartment=\"compartment_1\" id=\"species_1\" initialConcentration=\"1\" />\n"
498  " <species compartment=\"compartment_1\" id=\"species_2\" initialConcentration=\"1\" />\n"
499  " </listOfSpecies>\n"
500  " <listOfParameters>\n"
501  " <parameter constant=\"false\" id=\"parameter_1\"/>\n"
502  " </listOfParameters>\n"
503  " <listOfRules>\n"
504  " <assignmentRule variable=\"parameter_1\">\n"
505  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
506  " <ci> reaction_1 </ci>\n"
507  " </math>\n"
508  " </assignmentRule>\n"
509  " </listOfRules>\n"
510  " <listOfReactions>\n"
511  " <reaction id=\"reaction_1\" reversible=\"false\">\n"
512  " <listOfReactants>\n"
513  " <speciesReference species=\"species_1\"/>\n"
514  " </listOfReactants>\n"
515  " <listOfProducts>\n"
516  " <speciesReference species=\"species_2\"/>\n"
517  " </listOfProducts>\n"
518  " <kineticLaw>\n"
519  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
520  " <apply>\n"
521  " <times/>\n"
522  " <cn> 1 </cn>\n"
523  " <ci> species_1 </ci>\n"
524  " </apply>\n"
525  " </math>\n"
526  " </kineticLaw>\n"
527  " </reaction>\n"
528  " </listOfReactions>\n"
529  " </model>\n"
530  "</sbml>\n";
531 
532 const char* test000087::MODEL_STRING2 =
533  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
534  "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version3\" level=\"2\" version=\"3\">\n"
535  " <model id=\"model_1\" name=\"model\">\n"
536  " <listOfCompartments>\n"
537  " <compartment id=\"compartment_1\" size=\"1\"/>\n"
538  " </listOfCompartments>\n"
539  " <listOfSpecies>\n"
540  " <species compartment=\"compartment_1\" id=\"species_1\" initialConcentration=\"1\" />\n"
541  " <species compartment=\"compartment_1\" id=\"species_2\" initialConcentration=\"1\" />\n"
542  " </listOfSpecies>\n"
543  " <listOfParameters>\n"
544  " <parameter constant=\"false\" id=\"parameter_1\"/>\n"
545  " </listOfParameters>\n"
546  " <listOfRules>\n"
547  " <assignmentRule variable=\"parameter_1\">\n"
548  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
549  " <ci> reaction_1 </ci>\n"
550  " </math>\n"
551  " </assignmentRule>\n"
552  " </listOfRules>\n"
553  " <listOfReactions>\n"
554  " <reaction id=\"reaction_1\" reversible=\"false\">\n"
555  " <listOfReactants>\n"
556  " <speciesReference species=\"species_1\"/>\n"
557  " </listOfReactants>\n"
558  " <listOfProducts>\n"
559  " <speciesReference species=\"species_2\"/>\n"
560  " </listOfProducts>\n"
561  " <kineticLaw>\n"
562  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
563  " <apply>\n"
564  " <times/>\n"
565  " <cn> 1 </cn>\n"
566  " <ci> species_1 </ci>\n"
567  " </apply>\n"
568  " </math>\n"
569  " </kineticLaw>\n"
570  " </reaction>\n"
571  " </listOfReactions>\n"
572  " </model>\n"
573  "</sbml>\n";
574 
575 const char* test000087::MODEL_STRING3 =
576  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
577  "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version3\" level=\"2\" version=\"3\">\n"
578  " <model id=\"model_1\" name=\"model\">\n"
579  " <listOfCompartments>\n"
580  " <compartment id=\"compartment_1\" size=\"1\"/>\n"
581  " </listOfCompartments>\n"
582  " <listOfSpecies>\n"
583  " <species compartment=\"compartment_1\" id=\"species_1\" initialConcentration=\"1\" />\n"
584  " <species compartment=\"compartment_1\" id=\"species_2\" initialConcentration=\"1\" />\n"
585  " </listOfSpecies>\n"
586  " <listOfParameters>\n"
587  " <parameter constant=\"false\" id=\"parameter_1\"/>\n"
588  " </listOfParameters>\n"
589  " <listOfRules>\n"
590  " <assignmentRule variable=\"parameter_1\">\n"
591  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
592  " <ci> reaction_1 </ci>\n"
593  " </math>\n"
594  " </assignmentRule>\n"
595  " </listOfRules>\n"
596  " <listOfReactions>\n"
597  " <reaction id=\"reaction_1\" reversible=\"false\">\n"
598  " <listOfReactants>\n"
599  " <speciesReference species=\"species_1\"/>\n"
600  " </listOfReactants>\n"
601  " <listOfProducts>\n"
602  " <speciesReference species=\"species_2\"/>\n"
603  " </listOfProducts>\n"
604  " </reaction>\n"
605  " </listOfReactions>\n"
606  " </model>\n"
607  "</sbml>\n";
608 
609 const char* test000087::MODEL_STRING4 =
610  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
611  "<COPASI xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://www.copasi.org/static/schema.xsd\" versionMajor=\"1\" versionMinor=\"0\" versionDevel=\"30\">\n"
612  " <ListOfFunctions>\n"
613  " <Function key=\"Function_13\" name=\"Mass action (irreversible)\" type=\"MassAction\" reversible=\"false\">\n"
614  " <Expression>\n"
615  " k1*PRODUCT&lt;substrate_i&gt;\n"
616  " </Expression>\n"
617  " <ListOfParameterDescriptions>\n"
618  " <ParameterDescription key=\"FunctionParameter_81\" name=\"k1\" order=\"0\" role=\"constant\"/>\n"
619  " <ParameterDescription key=\"FunctionParameter_79\" name=\"substrate\" order=\"1\" role=\"substrate\"/>\n"
620  " </ListOfParameterDescriptions>\n"
621  " </Function>\n"
622  " </ListOfFunctions>\n"
623  " <Model key=\"Model_1\" name=\"New Model\" timeUnit=\"s\" volumeUnit=\"ml\" areaUnit=\"m²\" lengthUnit=\"m\" quantityUnit=\"mmol\" type=\"deterministic\">\n"
624  " <ListOfCompartments>\n"
625  " <Compartment key=\"Compartment_0\" name=\"compartment\" simulationType=\"fixed\" dimensionality=\"3\">\n"
626  " </Compartment>\n"
627  " </ListOfCompartments>\n"
628  " <ListOfMetabolites>\n"
629  " <Metabolite key=\"Metabolite_0\" name=\"A\" simulationType=\"reactions\" compartment=\"Compartment_0\">\n"
630  " </Metabolite>\n"
631  " <Metabolite key=\"Metabolite_1\" name=\"B\" simulationType=\"reactions\" compartment=\"Compartment_0\">\n"
632  " </Metabolite>\n"
633  " <Metabolite key=\"Metabolite_2\" name=\"C\" simulationType=\"assignment\" compartment=\"Compartment_0\">\n"
634  " <Expression>\n"
635  " &lt;CN=Root,Model=New Model,Vector=Reactions[Reaction 1],Reference=Flux&gt;\n"
636  " </Expression>\n"
637  " </Metabolite>\n"
638  " </ListOfMetabolites>\n"
639  " <ListOfReactions>\n"
640  " <Reaction key=\"Reaction_0\" name=\"Reaction 1\" reversible=\"false\">\n"
641  " <ListOfSubstrates>\n"
642  " <Substrate metabolite=\"Metabolite_0\" stoichiometry=\"1\"/>\n"
643  " </ListOfSubstrates>\n"
644  " <ListOfProducts>\n"
645  " <Product metabolite=\"Metabolite_1\" stoichiometry=\"1\"/>\n"
646  " </ListOfProducts>\n"
647  " <ListOfConstants>\n"
648  " <Constant key=\"Parameter_511\" name=\"k1\" value=\"0.1\"/>\n"
649  " </ListOfConstants>\n"
650  " <KineticLaw function=\"Function_13\">\n"
651  " <ListOfCallParameters>\n"
652  " <CallParameter functionParameter=\"FunctionParameter_81\">\n"
653  " <SourceParameter reference=\"Parameter_511\"/>\n"
654  " </CallParameter>\n"
655  " <CallParameter functionParameter=\"FunctionParameter_79\">\n"
656  " <SourceParameter reference=\"Metabolite_0\"/>\n"
657  " </CallParameter>\n"
658  " </ListOfCallParameters>\n"
659  " </KineticLaw>\n"
660  " </Reaction>\n"
661  " </ListOfReactions>\n"
662  " <StateTemplate>\n"
663  " <StateTemplateVariable objectReference=\"Model_1\"/>\n"
664  " <StateTemplateVariable objectReference=\"Metabolite_0\"/>\n"
665  " <StateTemplateVariable objectReference=\"Metabolite_1\"/>\n"
666  " <StateTemplateVariable objectReference=\"Metabolite_2\"/>\n"
667  " <StateTemplateVariable objectReference=\"Compartment_0\"/>\n"
668  " </StateTemplate>\n"
669  " <InitialState type=\"initialState\">\n"
670  " 0 10000.0 0.0 NaN 1\n"
671  " </InitialState>\n"
672  " </Model>\n"
673  "</COPASI>\n";
674 
675 const char* test000087::MODEL_STRING5 =
676  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
677  "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version3\" level=\"2\" version=\"3\">\n"
678  " <model id=\"model_1\" name=\"model\">\n"
679  " <listOfCompartments>\n"
680  " <compartment id=\"compartment_1\" size=\"1\"/>\n"
681  " </listOfCompartments>\n"
682  " <listOfSpecies>\n"
683  " <species compartment=\"compartment_1\" id=\"species_1\" initialConcentration=\"5\" />\n"
684  " <species compartment=\"compartment_1\" id=\"species_2\" initialConcentration=\"0\" />\n"
685  " </listOfSpecies>\n"
686  " <listOfParameters>\n"
687  " <parameter constant=\"false\" id=\"parameter_1\"/>\n"
688  " <parameter constant=\"true\" id=\"parameter_2\" value=\"1.0\" />\n"
689  " </listOfParameters>\n"
690  " <listOfRules>\n"
691  " <assignmentRule variable=\"parameter_1\">\n"
692  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
693  " <ci> reaction_1 </ci>\n"
694  " </math>\n"
695  " </assignmentRule>\n"
696  " </listOfRules>\n"
697  " <listOfReactions>\n"
698  " <reaction id=\"reaction_1\" reversible=\"false\">\n"
699  " <listOfReactants>\n"
700  " <speciesReference species=\"species_1\"/>\n"
701  " </listOfReactants>\n"
702  " <listOfProducts>\n"
703  " <speciesReference species=\"species_2\"/>\n"
704  " </listOfProducts>\n"
705  " <kineticLaw>\n"
706  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
707  " <apply>\n"
708  " <times/>\n"
709  " <ci> compartment_1 </ci>\n"
710  " <ci> parameter_2 </ci>\n"
711  " <ci> species_1 </ci>\n"
712  " </apply>\n"
713  " </math>\n"
714  " </kineticLaw>\n"
715  " </reaction>\n"
716  " </listOfReactions>\n"
717  " </model>\n"
718  "</sbml>\n";
const CExpression * getExpressionPtr() const
Header file of class CExpression.
SBMLDocument * getCurrentSBMLDocument()
Header file of class CModelEntity and CModelValue.
bool setValue(const CType &value)
void setScheduled(const bool &scheduled)
virtual bool initialize(const OutputFlag &of, COutputHandler *pOutputHandler, std::ostream *pOstream)
void test_simulate_reaction_flux_reference_1()
Definition: test000087.cpp:274
CCopasiProblem * getProblem()
virtual CCopasiObjectName getCN() const
bool setTaskType(const CCopasiTask::Type &taskType)
const CCopasiVector< CMetab > & getMetabolites() const
Definition: CModel.cpp:1051
const std::string & getObjectName() const
const CCopasiVectorN< CModelValue > & getModelValues() const
Definition: CModel.cpp:1060
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
virtual size_t size() const
const C_FLOAT64 & getInitialConcentration() const
Definition: CMetab.cpp:220
const CRegisteredObjectName & getObjectCN() const
CCopasiObject * get(const std::string &key)
const Type & getType() const
const CCopasiReportSeparator & getSeparator() const
const size_t & getNumber() const
static const char * MODEL_STRING2
Definition: test000087.h:40
virtual bool process(const bool &useInitialValues)
void setDuration(const C_FLOAT64 &duration)
void setSeparator(const CCopasiReportSeparator &Separator)
void test_export_reaction_flux_reference_1()
Definition: test000087.cpp:165
#define C_INT32
Definition: copasi.h:90
void test_import_reaction_flux_reference_2()
Definition: test000087.cpp:94
static const char * MODEL_STRING3
Definition: test000087.h:41
Definition: CMetab.h:178
void test_import_reaction_flux_reference_3()
Definition: test000087.cpp:133
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
void setIsTable(bool table)
virtual bool setModel(CModel *pModel)
void test_export_reaction_flux_reference_2()
Definition: test000087.cpp:220
const CReportDefinitionVector * getReportDefinitionList() const
void setInitialTime(const C_FLOAT64 &time)
Definition: CModel.cpp:1181
const C_FLOAT64 & getInitialValue() const
static const char * MODEL_STRING5
Definition: test000087.h:43
static Type type(const Type &type)
#define MCSBML
virtual bool add(const CType &src)
bool isReference() const
virtual const std::string & getKey() const
void setTimeSeriesRequested(bool flag)
static size_t size()
CCopasiVectorN< CCopasiTask > * getTaskList()
void test_import_reaction_flux_reference_1()
Definition: test000087.cpp:62
void setStepNumber(const unsigned C_INT32 &stepNumber)
void tearDown()
Definition: test000087.cpp:57
static const char * MODEL_STRING4
Definition: test000087.h:42
CCopasiParameter * getParameter(const std::string &name)
CReportDefinition * createReportDefinition(const std::string &name, const std::string &comment)
virtual void remove(const std::string &name)
void setTarget(const std::string &target)
Definition: CReport.cpp:92
static CCopasiDataModel * addDatamodel()
CCopasiVectorNS< CCompartment > & getCompartments()
Definition: CModel.cpp:1145
CCopasiMethod * getMethod()
static CKeyFactory * getKeyFactory()
CReport & getReport()
double strToDouble(const char *str, char const **pTail)
Definition: utility.cpp:325
#define C_FLOAT64
Definition: copasi.h:92
static CCopasiMessage getLastMessage()
std::vector< CRegisteredObjectName > * getBodyAddr()
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
CCopasiVectorNS< CReaction > & getReactions()
Definition: CModel.cpp:1039
static void init(int argc, char *argv[], const bool &withGui=false)
Definition: CModel.h:50
virtual bool restore()
const CModelEntity::Status & getStatus() const
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000087.h:38
void setReportDefinition(CReportDefinition *reportDef)
Definition: CReport.cpp:86
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
virtual bool setMethodType(const int &type)
std::vector< CRegisteredObjectName > * getHeaderAddr()
CEvaluationNode * getRoot()
void setUp()
Definition: test000087.cpp:49
CCopasiContainer * getObjectParent() const
static const char * MODEL_STRING1
Definition: test000087.h:39
#define max(a, b)
Definition: f2c.h:176