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

#include <test000067.h>

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

Public Member Functions

void setUp ()
 
void tearDown ()
 
void test_bug1060 ()
 

Static Protected Attributes

static const char * MODEL_STRING1
 
static CCopasiDataModelpCOPASIDATAMODEL = NULL
 

Private Member Functions

 CPPUNIT_TEST (test_bug1060)
 
 CPPUNIT_TEST_SUITE (test000067)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

This test is for Bug 1060.

Definition at line 29 of file test000067.h.

Member Function Documentation

test000067::CPPUNIT_TEST ( test_bug1060  )
private
test000067::CPPUNIT_TEST_SUITE ( test000067  )
private
test000067::CPPUNIT_TEST_SUITE_END ( )
private
void test000067::setUp ( )

Definition at line 41 of file test000067.cpp.

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

42 {
43  // Create the root container.
44  CCopasiRootContainer::init(0, NULL, false);
45  // Create the global data model.
47 }
static CCopasiDataModel * addDatamodel()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000067.h:37
static void init(int argc, char *argv[], const bool &withGui=false)
void test000067::tearDown ( )

Definition at line 49 of file test000067.cpp.

References CCopasiRootContainer::destroy().

void test000067::test_bug1060 ( )

Definition at line 54 of file test000067.cpp.

References test000059::checkIfIdsUnique(), CCopasiDataModel::exportSBMLToString(), CFunctionDB::findFunction(), CCopasiDataModel::getCopasi2SBMLMap(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiRootContainer::getFunctionList(), CCopasiDataModel::getModel(), load_cps_model_from_stream(), MODEL_STRING1, and pCOPASIDATAMODEL.

55 {
56  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
57  std::istringstream iss(test000067::MODEL_STRING1);
58  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
59  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
60  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
61  CPPUNIT_ASSERT(pDocument == NULL);
62  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 3).empty() == false);
63  pDocument = pDataModel->getCurrentSBMLDocument();
64  const Model* pSBMLModel = pDocument->getModel();
65  CPPUNIT_ASSERT(pSBMLModel != NULL);
66  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 3);
67  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
68  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 3);
69  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 8);
70  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
71  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 0);
72  CPPUNIT_ASSERT(test000059::checkIfIdsUnique(pSBMLModel) == true);
73  // check if each reaction call the correct kinetic law
75  CEvaluationTree* pModifiedMM = pFunDB->findFunction("Modified MM");
76  CPPUNIT_ASSERT(pModifiedMM != NULL);
77  CEvaluationTree* pModifiedCF = pFunDB->findFunction("modified constant flux");
78  CPPUNIT_ASSERT(pModifiedCF != NULL);
79  CEvaluationTree* pConstantFlux = pFunDB->findFunction("Constant flux (irreversible)");
80  CPPUNIT_ASSERT(pConstantFlux != NULL);
81  unsigned int i, iMax = pSBMLModel->getListOfReactions()->size();
82  const Reaction* pReaction = NULL;
83  const ASTNode* pRoot = NULL;
84  const std::map<CCopasiObject*, SBase*>& copasi2sbmlmap = pDataModel->getCopasi2SBMLMap();
85  std::map<CCopasiObject*, SBase*>::const_iterator mappos;
86 
87  for (i = 0; i < iMax; ++i)
88  {
89  pReaction = pSBMLModel->getReaction(i);
90  CPPUNIT_ASSERT(pReaction != NULL);
91  CPPUNIT_ASSERT(pReaction->getKineticLaw() != NULL);
92  pRoot = pReaction->getKineticLaw()->getMath();
93  CPPUNIT_ASSERT(pRoot != NULL);
94  CPPUNIT_ASSERT(pRoot->getType() == AST_TIMES);
95 
96  if (pRoot->getChild(0)->getType() == AST_NAME && pRoot->getChild(0)->getName() == pSBMLModel->getCompartment(0)->getId())
97  {
98  pRoot = pRoot->getChild(1);
99  }
100  else
101  {
102  pRoot = pRoot->getChild(0);
103  }
104 
105  if (pReaction->getName() == "y0Prod" || pReaction->getName() == "y1Prod" || pReaction->getName() == "xProdLin")
106  {
107  // uses modified constant flux
108  CPPUNIT_ASSERT(pRoot->getType() == AST_FUNCTION);
109  mappos = copasi2sbmlmap.find(pModifiedCF);
110  CPPUNIT_ASSERT(mappos != copasi2sbmlmap.end());
111  CPPUNIT_ASSERT(mappos->second != NULL);
112  CPPUNIT_ASSERT(pRoot->getName() == mappos->second->getId());
113  }
114  else if (pReaction->getName() == "xDegMM")
115  {
116  // uses modifed MM
117  CPPUNIT_ASSERT(pRoot->getType() == AST_FUNCTION);
118  mappos = copasi2sbmlmap.find(pModifiedMM);
119  CPPUNIT_ASSERT(mappos != copasi2sbmlmap.end());
120  CPPUNIT_ASSERT(mappos->second != NULL);
121  CPPUNIT_ASSERT(pRoot->getName() == mappos->second->getId());
122  }
123  else if (pReaction->getName() == "xProd")
124  {
125  // constant flux
126  CPPUNIT_ASSERT(pRoot->getType() == AST_FUNCTION);
127  mappos = copasi2sbmlmap.find(pConstantFlux);
128  CPPUNIT_ASSERT(mappos != copasi2sbmlmap.end());
129  CPPUNIT_ASSERT(mappos->second != NULL);
130  CPPUNIT_ASSERT(pRoot->getName() == mappos->second->getId());
131  }
132  else
133  {
134  // must be mass action
135  CPPUNIT_ASSERT(pRoot->getType() == AST_TIMES);
136  }
137  }
138 }
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static bool checkIfIdsUnique(const Model *pSBMLModel)
Definition: test000059.cpp:44
static const char * MODEL_STRING1
Definition: test000067.h:36
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static CFunctionDB * getFunctionList()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000067.h:37
std::map< CCopasiObject *, SBase * > & getCopasi2SBMLMap()
CFunction * findFunction(const std::string &functionName)

Member Data Documentation

const char * test000067::MODEL_STRING1
staticprotected

Definition at line 36 of file test000067.h.

Referenced by test_bug1060().

CCopasiDataModel * test000067::pCOPASIDATAMODEL = NULL
staticprotected

Definition at line 37 of file test000067.h.

Referenced by setUp(), and test_bug1060().


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