COPASI API  4.16.103
test000080.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/sbml/unittests/test000080.cpp,v $
3 // $Revision: 1.2 $
4 // $Name: $
5 // $Author: gauges $
6 // $Date: 2010/03/11 11:55:16 $
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 "test000080.h"
20 
21 #include "utilities.hpp"
24 #include "copasi/model/CModel.h"
25 #include "copasi/model/CReaction.h"
26 
27 /**
28  * This is a test for a bug where some kinetics were wrongly recognized as
29  * mass action.
30  * This kind of kinetic is used in the sbml testsuite in test 65, 121, 250,
31  * 253, 256 and 600.
32  */
33 CCopasiDataModel* test000080::pCOPASIDATAMODEL = NULL;
34 
36 {
37  // Create the root container.
38  CCopasiRootContainer::init(0, NULL, false);
39  // Create the global data model.
41 }
42 
44 {
46 }
47 
49 {
50  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
51 
52  try
53  {
54  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000080::MODEL_STRING1));
55  }
56  catch (...)
57  {
58  // there should not be an exception
59  CPPUNIT_ASSERT(false);
60  }
61 
62  const CModel* pModel = pDataModel->getModel();
63 
64  CPPUNIT_ASSERT(pModel != NULL);
65 
66  CPPUNIT_ASSERT(pModel->getReactions().size() == 1);
67 
68  const CReaction* pReaction = pModel->getReactions()[0];
69 
70  CPPUNIT_ASSERT(pReaction != NULL);
71 
72  const CFunction* pFun = pReaction->getFunction();
73 
74  CPPUNIT_ASSERT(pFun != NULL);
75 
76  CPPUNIT_ASSERT(pFun->getType() == CEvaluationTree::UserDefined);
77 }
78 
79 const char* test000080::MODEL_STRING1 =
80  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
81  "<sbml xmlns=\"http://www.sbml.org/sbml/level2\" level=\"2\" version=\"1\">\n"
82  " <model id=\"model_1\" name=\"Model_1\">\n"
83  " <listOfCompartments>\n"
84  " <compartment id=\"compartment\" name=\"compartment\" size=\"1\" units=\"volume\"/>\n"
85  " </listOfCompartments>\n"
86  " <listOfSpecies>\n"
87  " <species id=\"S1\" name=\"S1\" compartment=\"compartment\" initialAmount=\"1\" substanceUnits=\"substance\"/>\n"
88  " <species id=\"S2\" name=\"S2\" compartment=\"compartment\" initialAmount=\"1\" substanceUnits=\"substance\"/>\n"
89  " <species id=\"S3\" name=\"S3\" compartment=\"compartment\" initialAmount=\"1\" substanceUnits=\"substance\"/>\n"
90  " <species id=\"S4\" name=\"S4\" compartment=\"compartment\" initialAmount=\"1\" substanceUnits=\"substance\"/>\n"
91  " <species id=\"S5\" name=\"S5\" compartment=\"compartment\" initialAmount=\"1\" substanceUnits=\"substance\" constant=\"true\"/>\n"
92  " </listOfSpecies>\n"
93  " <listOfParameters>\n"
94  " <parameter id=\"k1\" name=\"k1\" value=\"1\"/>\n"
95  " </listOfParameters>\n"
96  " <listOfReactions>\n"
97  " <reaction id=\"reaction1\" name=\"reaction1\" reversible=\"false\" fast=\"false\">\n"
98  " <listOfReactants>\n"
99  " <speciesReference species=\"S1\"/>\n"
100  " <speciesReference species=\"S2\"/>\n"
101  " </listOfReactants>\n"
102  " <listOfProducts>\n"
103  " <speciesReference species=\"S3\"/>\n"
104  " <speciesReference species=\"S4\"/>\n"
105  " </listOfProducts>\n"
106  " <listOfModifiers>\n"
107  " <modifierSpeciesReference species=\"S5\"/>\n"
108  " </listOfModifiers>\n"
109  " <kineticLaw>\n"
110  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
111  " <apply>\n"
112  " <times/>\n"
113  " <ci> compartment </ci>\n"
114  " <ci> k1 </ci>\n"
115  " <ci> S1 </ci>\n"
116  " <ci> S2 </ci>\n"
117  " <apply>\n"
118  " <power/>\n"
119  " <ci> S5 </ci>\n"
120  " <cn type=\"integer\"> -1 </cn>\n"
121  " </apply>\n"
122  " </apply>\n"
123  " </math>\n"
124  " </kineticLaw>\n"
125  " </reaction>\n"
126  " </listOfReactions>\n"
127  " </model>\n"
128  "</sbml>\n";
void setUp()
Definition: test000080.cpp:35
virtual size_t size() const
static const char * MODEL_STRING1
Definition: test000080.h:34
void test_mass_action_recognition_bug()
Definition: test000080.cpp:48
const CEvaluationTree::Type & getType() const
static CCopasiDataModel * addDatamodel()
void tearDown()
Definition: test000080.cpp:43
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
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000080.h:33