COPASI API  4.16.103
test000050.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 #include "test000050.h"
12 
13 #include <sstream>
14 #include "utilities.hpp"
15 
16 #include <sbml/SBMLDocument.h>
17 #include <sbml/Model.h>
18 #include <sbml/Rule.h>
19 #include <sbml/Species.h>
20 #include <sbml/FunctionDefinition.h>
21 #include <sbml/Parameter.h>
22 #include <sbml/math/ASTNode.h>
23 
27 
28 CCopasiDataModel* test000050::pCOPASIDATAMODEL = NULL;
29 
31 {
32  // Create the root container.
33  CCopasiRootContainer::init(0, NULL, false);
34  // Create the global data model.
36 }
37 
39 {
41 }
42 
44 {
45  // load the CPS file
46  // export to SBML
47  // check the resulting SBML model
48  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
49  std::istringstream iss(test000050::MODEL_STRING);
50  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
51  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
52 
53  std::string sbml = pDataModel->exportSBMLToString(NULL, 2, 3);
54  CPPUNIT_ASSERT(sbml.empty() == false);
55  SBMLDocument* doc = pDataModel->getCurrentSBMLDocument();
56  CPPUNIT_ASSERT(doc != NULL);
57  CPPUNIT_ASSERT(doc->getModel() != NULL);
58  CPPUNIT_ASSERT(doc->getModel()->getNumFunctionDefinitions() > 0);
59 
60  SBase* def = doc->getModel()->getFunctionDefinition(0);
61  CPPUNIT_ASSERT(def != NULL);
62 
63  FunctionDefinition* fDef = dynamic_cast<FunctionDefinition*>(def);
64  CPPUNIT_ASSERT(def != NULL);
65  CPPUNIT_ASSERT(def->isSetAnnotation() == true);
66  CPPUNIT_ASSERT(def->getAnnotation() != NULL);
67  CPPUNIT_ASSERT(def->getAnnotation()->getNumChildren() == 1);
68  CPPUNIT_ASSERT(def->getAnnotation()->getChild(0).getURI() == "http://sbml.org/annotations/distribution");
69  CPPUNIT_ASSERT(def->getAnnotation()->getChild(0).getAttrValue("definition") == "http://www.uncertml.org/distributions/uniform");
70 }
71 
72 const char* test000050::MODEL_STRING =
73  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
74  "<!-- generated with COPASI 4.3.25 (Debug) (http://www.copasi.org) at 2008-02-27 12:47:16 UTC -->\n"
75  "<COPASI xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://www.copasi.org/static/schema.xsd\" versionMajor=\"1\" versionMinor=\"0\" versionDevel=\"25\">\n"
76  " <Model key=\"Model_0\" name=\"New Model\" timeUnit=\"s\" volumeUnit=\"ml\" quantityUnit=\"mmol\" type=\"deterministic\">\n"
77  " <Comment>\n"
78  " <body xmlns=\"http://www.w3.org/1999/xhtml\">\n"
79  " \n"
80  " </body>\n"
81  " </Comment>\n"
82  " <ListOfModelValues>\n"
83  " <ModelValue key=\"ModelValue_0\" name=\"K\" simulationType=\"fixed\">\n"
84  " <InitialExpression>\n"
85  " uniform(4.0,0.5)\n"
86  " </InitialExpression>\n"
87  " </ModelValue>\n"
88  " </ListOfModelValues>\n"
89  " <StateTemplate>\n"
90  " <StateTemplateVariable objectReference=\"Model_0\"/>\n"
91  " <StateTemplateVariable objectReference=\"ModelValue_0\"/>\n"
92  " </StateTemplate>\n"
93  " <InitialState type=\"initialState\">\n"
94  " 0 4.12243135037551\n"
95  " </InitialState>\n"
96  " </Model>\n"
97  "</COPASI>\n"
98  ;
SBMLDocument * getCurrentSBMLDocument()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000050.h:32
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
void setUp()
Definition: test000050.cpp:30
void tearDown()
Definition: test000050.cpp:38
static CCopasiDataModel * addDatamodel()
static void init(int argc, char *argv[], const bool &withGui=false)
static const char * MODEL_STRING
Definition: test000050.h:31
void test_bug894()
Definition: test000050.cpp:43