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

#include <test000087.h>

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

Public Member Functions

void setUp ()
 
void tearDown ()
 
void test_export_reaction_flux_reference_1 ()
 
void test_export_reaction_flux_reference_2 ()
 
void test_import_reaction_flux_reference_1 ()
 
void test_import_reaction_flux_reference_2 ()
 
void test_import_reaction_flux_reference_3 ()
 
void test_simulate_reaction_flux_reference_1 ()
 

Static Protected Attributes

static const char * MODEL_STRING1
 
static const char * MODEL_STRING2
 
static const char * MODEL_STRING3
 
static const char * MODEL_STRING4
 
static const char * MODEL_STRING5
 
static CCopasiDataModelpCOPASIDATAMODEL = NULL
 

Private Member Functions

 CPPUNIT_TEST (test_import_reaction_flux_reference_1)
 
 CPPUNIT_TEST (test_import_reaction_flux_reference_2)
 
 CPPUNIT_TEST (test_import_reaction_flux_reference_3)
 
 CPPUNIT_TEST (test_export_reaction_flux_reference_1)
 
 CPPUNIT_TEST (test_export_reaction_flux_reference_2)
 
 CPPUNIT_TEST (test_simulate_reaction_flux_reference_1)
 
 CPPUNIT_TEST_SUITE (test000087)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 24 of file test000087.h.

Member Function Documentation

test000087::CPPUNIT_TEST ( test_import_reaction_flux_reference_1  )
private
test000087::CPPUNIT_TEST ( test_import_reaction_flux_reference_2  )
private
test000087::CPPUNIT_TEST ( test_import_reaction_flux_reference_3  )
private
test000087::CPPUNIT_TEST ( test_export_reaction_flux_reference_1  )
private
test000087::CPPUNIT_TEST ( test_export_reaction_flux_reference_2  )
private
test000087::CPPUNIT_TEST ( test_simulate_reaction_flux_reference_1  )
private
test000087::CPPUNIT_TEST_SUITE ( test000087  )
private
test000087::CPPUNIT_TEST_SUITE_END ( )
private
void test000087::setUp ( )

Definition at line 49 of file test000087.cpp.

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

50 {
51  // Create the root container.
52  CCopasiRootContainer::init(0, NULL, false);
53  // Create the global data model.
55 }
static CCopasiDataModel * addDatamodel()
static void init(int argc, char *argv[], const bool &withGui=false)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000087.h:38
void test000087::tearDown ( )

Definition at line 57 of file test000087.cpp.

References CCopasiRootContainer::destroy().

void test000087::test_export_reaction_flux_reference_1 ( )

Definition at line 165 of file test000087.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiDataModel::getModel(), load_cps_model_from_stream(), MODEL_STRING4, pCOPASIDATAMODEL, and CCopasiMessage::size().

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 }
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static size_t size()
static const char * MODEL_STRING4
Definition: test000087.h:42
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000087.h:38
void test000087::test_export_reaction_flux_reference_2 ( )

Definition at line 220 of file test000087.cpp.

References CCopasiMessage::EXCEPTION, CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiMessage::getLastMessage(), CCopasiDataModel::getModel(), load_cps_model_from_stream(), MODEL_STRING4, pCOPASIDATAMODEL, CCopasiMessage::RAW, and CCopasiMessage::size().

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 }
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static size_t size()
static const char * MODEL_STRING4
Definition: test000087.h:42
static CCopasiMessage getLastMessage()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000087.h:38
void test000087::test_import_reaction_flux_reference_1 ( )

Definition at line 62 of file test000087.cpp.

References CCopasiMessage::getLastMessage(), CCopasiMessage::getNumber(), CCopasiDataModel::importSBMLFromString(), MCSBML, MODEL_STRING1, pCOPASIDATAMODEL, and CCopasiMessage::size().

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 }
const size_t & getNumber() const
#define MCSBML
static size_t size()
static CCopasiMessage getLastMessage()
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000087.h:38
static const char * MODEL_STRING1
Definition: test000087.h:39
void test000087::test_import_reaction_flux_reference_2 ( )

Definition at line 94 of file test000087.cpp.

References CModelEntity::ASSIGNMENT, CModel::getCompartments(), CModelEntity::getExpressionPtr(), CModel::getMetabolites(), CCopasiDataModel::getModel(), CModel::getModelValues(), CEvaluationNodeObject::getObjectCN(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CModel::getReactions(), CModelEntity::getStatus(), CEvaluationNode::getType(), CCopasiDataModel::importSBMLFromString(), CCopasiObject::isReference(), MODEL_STRING2, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), pCOPASIDATAMODEL, CCopasiVector< T >::size(), and CEvaluationNode::type().

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 }
const CExpression * getExpressionPtr() const
const CCopasiVector< CMetab > & getMetabolites() const
Definition: CModel.cpp:1051
const std::string & getObjectName() const
const CCopasiVectorN< CModelValue > & getModelValues() const
Definition: CModel.cpp:1060
virtual size_t size() const
const CRegisteredObjectName & getObjectCN() const
const Type & getType() const
static const char * MODEL_STRING2
Definition: test000087.h:40
static Type type(const Type &type)
bool isReference() const
CCopasiVectorNS< CCompartment > & getCompartments()
Definition: CModel.cpp:1145
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
CCopasiVectorNS< CReaction > & getReactions()
Definition: CModel.cpp:1039
const CModelEntity::Status & getStatus() const
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000087.h:38
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CCopasiContainer * getObjectParent() const
void test000087::test_import_reaction_flux_reference_3 ( )

Definition at line 133 of file test000087.cpp.

References CCopasiMessage::getLastMessage(), CCopasiMessage::getNumber(), CCopasiDataModel::importSBMLFromString(), MCSBML, MODEL_STRING3, pCOPASIDATAMODEL, and CCopasiMessage::size().

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 }
const size_t & getNumber() const
static const char * MODEL_STRING3
Definition: test000087.h:41
#define MCSBML
static size_t size()
static CCopasiMessage getLastMessage()
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000087.h:38
void test000087::test_simulate_reaction_flux_reference_1 ( )

Definition at line 274 of file test000087.cpp.

References CCopasiVectorN< CType >::add(), CModelEntity::ASSIGNMENT, C_FLOAT64, C_INT32, CReportDefinitionVector::createReportDefinition(), CModelEntity::FIXED, CKeyFactory::get(), CReportDefinition::getBodyAddr(), CCopasiObject::getCN(), CModel::getCompartments(), CModelEntity::getExpressionPtr(), CReportDefinition::getHeaderAddr(), CMetab::getInitialConcentration(), CModelEntity::getInitialValue(), CModelEntity::getKey(), CCopasiRootContainer::getKeyFactory(), CModel::getMetabolites(), CCopasiTask::getMethod(), CCopasiDataModel::getModel(), CModel::getModelValues(), CEvaluationNodeObject::getObjectCN(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CCopasiParameterGroup::getParameter(), CCopasiTask::getProblem(), CModel::getReactions(), CCopasiTask::getReport(), CCopasiDataModel::getReportDefinitionList(), CEvaluationTree::getRoot(), CReportDefinition::getSeparator(), CCopasiDataModel::getTaskList(), CEvaluationNode::getType(), CCopasiDataModel::importSBMLFromString(), CTrajectoryTask::initialize(), CCopasiObject::isReference(), CCopasiMethod::LSODAR, CEvaluationTree::MassAction, max, MODEL_STRING5, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), CCopasiTask::OUTPUT_UI, pCOPASIDATAMODEL, CTrajectoryTask::process(), CCopasiVectorN< CType >::remove(), CTrajectoryTask::restore(), CTrajectoryProblem::setDuration(), CModel::setInitialTime(), CReportDefinition::setIsTable(), CTrajectoryTask::setMethodType(), CCopasiProblem::setModel(), CReport::setReportDefinition(), CCopasiTask::setScheduled(), CReportDefinition::setSeparator(), CTrajectoryProblem::setStepNumber(), CReport::setTarget(), CReportDefinition::setTaskType(), CTrajectoryProblem::setTimeSeriesRequested(), CCopasiParameter::setValue(), CCopasiVector< T >::size(), strToDouble(), CCopasiTask::timeCourse, and CEvaluationNode::type().

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 }
const CExpression * getExpressionPtr() const
bool setValue(const CType &value)
void setScheduled(const bool &scheduled)
virtual bool initialize(const OutputFlag &of, COutputHandler *pOutputHandler, std::ostream *pOstream)
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
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
virtual bool process(const bool &useInitialValues)
void setDuration(const C_FLOAT64 &duration)
void setSeparator(const CCopasiReportSeparator &Separator)
#define C_INT32
Definition: copasi.h:90
Definition: CMetab.h:178
void setIsTable(bool table)
virtual bool setModel(CModel *pModel)
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)
virtual bool add(const CType &src)
bool isReference() const
virtual const std::string & getKey() const
void setTimeSeriesRequested(bool flag)
CCopasiVectorN< CCopasiTask > * getTaskList()
void setStepNumber(const unsigned C_INT32 &stepNumber)
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
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
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
Definition: CModel.h:50
virtual bool restore()
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()
CCopasiContainer * getObjectParent() const
#define max(a, b)
Definition: f2c.h:176

Member Data Documentation

const char * test000087::MODEL_STRING1
staticprotected

Definition at line 39 of file test000087.h.

Referenced by test_import_reaction_flux_reference_1().

const char * test000087::MODEL_STRING2
staticprotected

Definition at line 40 of file test000087.h.

Referenced by test_import_reaction_flux_reference_2().

const char * test000087::MODEL_STRING3
staticprotected

Definition at line 41 of file test000087.h.

Referenced by test_import_reaction_flux_reference_3().

const char * test000087::MODEL_STRING4
staticprotected
const char * test000087::MODEL_STRING5
staticprotected

Definition at line 43 of file test000087.h.

Referenced by test_simulate_reaction_flux_reference_1().

CCopasiDataModel * test000087::pCOPASIDATAMODEL = NULL
staticprotected

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