COPASI API  4.16.103
test000060.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/sbml/unittests/test000060.cpp,v $
3 // $Revision: 1.6 $
4 // $Name: $
5 // $Author: gauges $
6 // $Date: 2010/03/11 11:52:00 $
7 // End CVS Header
8 
9 // Copyright (C) 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 "test000060.h"
20 
21 #include <sstream>
22 #include "utilities.hpp"
24 #include "copasi/model/CModel.h"
27 
28 #include "sbml/SBMLDocument.h"
29 #include "sbml/Model.h"
30 #include "sbml/Species.h"
31 
33 
34 CCopasiDataModel* test000060::pCOPASIDATAMODEL = NULL;
35 
37 {
38  // Create the root container.
39  CCopasiRootContainer::init(0, NULL, false);
40  // Create the global data model.
42 }
43 
45 {
47 }
48 
50 {
51  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
52  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000060::MODEL_STRING1));
53  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
54  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
55  const Model* pSBMLModel = pDocument->getModel();
56  CPPUNIT_ASSERT(pSBMLModel != NULL);
57  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 0);
58  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
59  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
60  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 0);
61  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
62  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 0);
63  // check if the species is constant and has boundaryCondition set to true
64  const Species* pSpecies = pSBMLModel->getSpecies(0);
65  CPPUNIT_ASSERT(pSpecies != NULL);
66  CPPUNIT_ASSERT(pSpecies->getConstant() == true);
67  CPPUNIT_ASSERT(pSpecies->getBoundaryCondition() == true);
68  // now change the status of the species in the underlying COPASI model
69  CPPUNIT_ASSERT(pDataModel->getModel()->getMetabolites().size() == 1);
70  CMetab* pMetab = pDataModel->getModel()->getMetabolites()[0];
71  pMetab->setStatus(CModelEntity::REACTIONS);
72  std::set<const CCopasiObject*> changedObjects;
73  changedObjects.insert(pMetab);
74  std::vector<Refresh*> refreshes = pDataModel->getModel()->buildInitialRefreshSequence(changedObjects);
75  std::vector<Refresh*>::iterator refreshIt = refreshes.begin(), refreshEndit = refreshes.end();
76 
77  while (refreshIt != refreshEndit)
78  {
79  (**refreshIt++)();
80  }
81 
82  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
83  pDocument = pDataModel->getCurrentSBMLDocument();
84  pSBMLModel = pDocument->getModel();
85  CPPUNIT_ASSERT(pSBMLModel != NULL);
86  CPPUNIT_ASSERT(pSBMLModel->getNumFunctionDefinitions() == 0);
87  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
88  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 1);
89  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 0);
90  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
91  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 0);
92  // check if the species is constant and has boundaryCondition set to false
93  pSpecies = pSBMLModel->getSpecies(0);
94  CPPUNIT_ASSERT(pSpecies != NULL);
95  CPPUNIT_ASSERT(pSpecies->getConstant() == false);
96  CPPUNIT_ASSERT(pSpecies->getBoundaryCondition() == false);
97 }
98 
99 const char* test000060::MODEL_STRING1 =
100  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
101  "<sbml xmlns=\"http://www.sbml.org/sbml/level2\" metaid=\"_000000\" level=\"2\" version=\"1\">\n"
102  " <model metaid=\"_000001\" id=\"bug_1026\" name=\"bug_1026\">\n"
103  " <listOfCompartments>\n"
104  " <compartment metaid=\"_000005\" id=\"compartment_1\" name=\"compartment_1\" size=\"1e-16\">\n"
105  " </compartment>\n"
106  " </listOfCompartments>\n"
107  " <listOfSpecies>\n"
108  " <species metaid=\"_000006\" id=\"species_1\" name=\"species_1\" compartment=\"compartment_1\" initialAmount=\"1.0\" constant=\"true\" boundaryCondition=\"true\" />\n"
109  " </listOfSpecies> \n"
110  " </model>\n"
111  "</sbml>\n"
112  ;
SBMLDocument * getCurrentSBMLDocument()
Header file of class CModelEntity and CModelValue.
const CCopasiVector< CMetab > & getMetabolites() const
Definition: CModel.cpp:1051
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
virtual size_t size() const
void test_bug_1026()
Definition: test000060.cpp:49
void tearDown()
Definition: test000060.cpp:44
Definition: CMetab.h:178
static const char * MODEL_STRING1
Definition: test000060.h:38
void setUp()
Definition: test000060.cpp:36
static CCopasiDataModel * addDatamodel()
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
static void init(int argc, char *argv[], const bool &withGui=false)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000060.h:39
std::vector< Refresh * > buildInitialRefreshSequence(std::set< const CCopasiObject * > &changedObjects)
Definition: CModel.cpp:4164