18 #include "utilities.hpp"
20 #include "sbml/SBMLDocument.h"
21 #include "sbml/Model.h"
22 #include "sbml/xml/XMLNode.h"
54 CPPUNIT_ASSERT(pModel != NULL);
55 std::string notes = pModel->getNotes();
56 CPPUNIT_ASSERT(!notes.empty());
57 CPPUNIT_ASSERT(notes.find(
"Simple note on model") != std::string::npos);
58 CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
59 CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
60 CPPUNIT_ASSERT(pModel->getReactions().size() == 1);
61 CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
62 CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
64 const CCompartment* pCompartment = pModel->getCompartments()[0];
65 CPPUNIT_ASSERT(pCompartment != NULL);
66 notes = pCompartment->getNotes();
67 CPPUNIT_ASSERT(!notes.empty());
68 CPPUNIT_ASSERT(notes.find(
"Simple note on compartment") != std::string::npos);
70 const CMetab* pMetab = pModel->getMetabolites()[0];
71 CPPUNIT_ASSERT(pMetab != NULL);
72 notes = pMetab->getNotes();
73 CPPUNIT_ASSERT(!notes.empty());
74 CPPUNIT_ASSERT(notes.find(
"Simple note on species") != std::string::npos);
76 const CReaction* pReaction = pModel->getReactions()[0];
77 CPPUNIT_ASSERT(pReaction != NULL);
78 notes = pReaction->getNotes();
79 CPPUNIT_ASSERT(!notes.empty());
80 CPPUNIT_ASSERT(notes.find(
"Simple note on reaction") != std::string::npos);
82 const CModelValue* pModelValue = pModel->getModelValues()[0];
83 CPPUNIT_ASSERT(pModelValue != NULL);
84 notes = pModelValue->getNotes();
85 CPPUNIT_ASSERT(!notes.empty());
86 CPPUNIT_ASSERT(notes.find(
"Simple note on parameter") != std::string::npos);
88 const CEvent* pEvent = pModel->getEvents()[0];
89 CPPUNIT_ASSERT(pEvent != NULL);
90 notes = pEvent->getNotes();
91 CPPUNIT_ASSERT(!notes.empty());
92 CPPUNIT_ASSERT(notes.find(
"Simple note on event") != std::string::npos);
109 CPPUNIT_ASSERT(
false);
112 CPPUNIT_ASSERT(!s.empty());
114 SBMLDocument* pSBMLDocument = NULL;
118 pSBMLDocument = reader.readSBMLFromString(s);
122 CPPUNIT_ASSERT(
false);
125 CPPUNIT_ASSERT(pSBMLDocument != NULL);
126 Model* pModel = pSBMLDocument->getModel();
127 CPPUNIT_ASSERT(pModel != NULL);
128 CPPUNIT_ASSERT(pModel->isSetNotes() ==
true);
129 std::string notes = pModel->getNotesString();
130 CPPUNIT_ASSERT(!notes.empty());
131 CPPUNIT_ASSERT(notes.find(
"Simple note on model") != std::string::npos);
133 CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
134 CPPUNIT_ASSERT(pModel->getNumSpecies() == 1);
135 CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
136 CPPUNIT_ASSERT(pModel->getNumReactions() == 1);
137 CPPUNIT_ASSERT(pModel->getNumEvents() == 1);
139 SBase* pObject = pModel->getCompartment(0);
140 CPPUNIT_ASSERT(pObject != NULL);
141 CPPUNIT_ASSERT(pObject->isSetNotes() ==
true);
142 notes = pObject->getNotesString();
143 CPPUNIT_ASSERT(!notes.empty());
144 CPPUNIT_ASSERT(notes.find(
"Simple note on compartment") != std::string::npos);
146 pObject = pModel->getSpecies(0);
147 CPPUNIT_ASSERT(pObject != NULL);
148 CPPUNIT_ASSERT(pObject->isSetNotes() ==
true);
149 notes = pObject->getNotesString();
150 CPPUNIT_ASSERT(!notes.empty());
151 CPPUNIT_ASSERT(notes.find(
"Simple note on species") != std::string::npos);
153 pObject = pModel->getParameter(0);
154 CPPUNIT_ASSERT(pObject != NULL);
155 CPPUNIT_ASSERT(pObject->isSetNotes() ==
true);
156 notes = pObject->getNotesString();
157 CPPUNIT_ASSERT(!notes.empty());
158 CPPUNIT_ASSERT(notes.find(
"Simple note on parameter") != std::string::npos);
160 pObject = pModel->getReaction(0);
161 CPPUNIT_ASSERT(pObject != NULL);
162 CPPUNIT_ASSERT(pObject->isSetNotes() ==
true);
163 notes = pObject->getNotesString();
164 CPPUNIT_ASSERT(!notes.empty());
165 CPPUNIT_ASSERT(notes.find(
"Simple note on reaction") != std::string::npos);
167 pObject = pModel->getEvent(0);
168 CPPUNIT_ASSERT(pObject != NULL);
169 CPPUNIT_ASSERT(pObject->isSetNotes() ==
true);
170 notes = pObject->getNotesString();
171 CPPUNIT_ASSERT(!notes.empty());
172 CPPUNIT_ASSERT(notes.find(
"Simple note on event") != std::string::npos);
183 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
184 "<!-- Created by COPASI version 4.6.34 (Debug) on 2011-05-12 15:45 with libSBML version 4.2.0. -->\n"
185 "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version4\" level=\"2\" version=\"4\">\n"
186 " <model metaid=\"COPASI1\" id=\"Model_1\" name=\"New Model\">\n"
188 " <body xmlns=\"http://www.w3.org/1999/xhtml\">Simple note on model</body>\n"
190 " <listOfFunctionDefinitions>\n"
191 " <functionDefinition id=\"function_1\" name=\"Constant flux (irreversible)\">\n"
192 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
200 " </functionDefinition>\n"
201 " </listOfFunctionDefinitions>\n"
202 " <listOfUnitDefinitions>\n"
203 " <unitDefinition id=\"volume\" name=\"volume\">\n"
205 " <unit kind=\"litre\" scale=\"-3\"/>\n"
207 " </unitDefinition>\n"
208 " <unitDefinition id=\"substance\" name=\"substance\">\n"
210 " <unit kind=\"mole\" scale=\"-3\"/>\n"
212 " </unitDefinition>\n"
213 " </listOfUnitDefinitions>\n"
214 " <listOfCompartments>\n"
215 " <compartment metaid=\"COPASI2\" id=\"compartment_1\" name=\"compartment_1\" size=\"1\">\n"
217 " <body xmlns=\"http://www.w3.org/1999/xhtml\">Simple note on compartment</body>\n"
220 " </listOfCompartments>\n"
222 " <species metaid=\"COPASI3\" id=\"species_1\" name=\"species_1\" compartment=\"compartment_1\" initialConcentration=\"1\">\n"
224 " <body xmlns=\"http://www.w3.org/1999/xhtml\">Simple note on species</body>\n"
227 " </listOfSpecies>\n"
228 " <listOfParameters>\n"
229 " <parameter metaid=\"COPASI4\" id=\"parameter_1\" name=\"quantity_1\" value=\"0\" constant=\"false\">\n"
231 " <body xmlns=\"http://www.w3.org/1999/xhtml\">Simple note on parameter</body>\n"
234 " </listOfParameters>\n"
235 " <listOfReactions>\n"
236 " <reaction metaid=\"COPASI6\" id=\"reaction_1\" name=\"reaction_1\" reversible=\"false\">\n"
238 " <body xmlns=\"http://www.w3.org/1999/xhtml\">Simple note on reaction</body>\n"
240 " <listOfProducts>\n"
241 " <speciesReference species=\"species_1\"/>\n"
242 " </listOfProducts>\n"
244 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
247 " <ci> compartment_1 </ci>\n"
249 " <ci> function_1 </ci>\n"
254 " <listOfParameters>\n"
255 " <parameter id=\"v\" name=\"v\" value=\"0.1\"/>\n"
256 " </listOfParameters>\n"
259 " </listOfReactions>\n"
261 " <event metaid=\"COPASI5\" id=\"event_1\" name=\"event_1\">\n"
263 " <body xmlns=\"http://www.w3.org/1999/xhtml\">Simple note on event</body>\n"
266 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
269 " <csymbol encoding=\"text\" definitionURL=\"http://www.sbml.org/sbml/symbols/time\"> time </csymbol>\n"
274 " <listOfEventAssignments>\n"
275 " <eventAssignment variable=\"parameter_1\">\n"
276 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
279 " </eventAssignment>\n"
280 " </listOfEventAssignments>\n"
289 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
290 "<!-- generated with COPASI 4.6.34 (Debug) (http://www.copasi.org) at 2011-05-12 13:45:33 UTC -->\n"
291 "<?oxygen RNGSchema=\"http://www.copasi.org/static/schema/CopasiML.rng\" type=\"xml\"?>\n"
292 "<COPASI xmlns=\"http://www.copasi.org/static/schema\" versionMajor=\"1\" versionMinor=\"0\" versionDevel=\"34\">\n"
293 " <ListOfFunctions>\n"
294 " <Function key=\"Function_6\" name=\"Constant flux (irreversible)\" type=\"PreDefined\" reversible=\"false\">\n"
298 " <ListOfParameterDescriptions>\n"
299 " <ParameterDescription key=\"FunctionParameter_49\" name=\"v\" order=\"0\" role=\"constant\"/>\n"
300 " </ListOfParameterDescriptions>\n"
302 " </ListOfFunctions>\n"
303 " <Model key=\"Model_0\" name=\"New Model\" simulationType=\"time\" timeUnit=\"s\" volumeUnit=\"ml\" areaUnit=\"m²\" lengthUnit=\"m\" quantityUnit=\"mmol\" type=\"deterministic\" avogadroConstant=\"6.02214179e+23\">\n"
305 " Simple note on model\n"
307 " <ListOfCompartments>\n"
308 " <Compartment key=\"Compartment_0\" name=\"compartment_1\" simulationType=\"fixed\" dimensionality=\"3\">\n"
310 " Simple note on compartment\n"
313 " </ListOfCompartments>\n"
314 " <ListOfMetabolites>\n"
315 " <Metabolite key=\"Metabolite_0\" name=\"species_1\" simulationType=\"reactions\" compartment=\"Compartment_0\">\n"
317 " Simple note on species\n"
320 " </ListOfMetabolites>\n"
321 " <ListOfModelValues>\n"
322 " <ModelValue key=\"ModelValue_0\" name=\"quantity_1\" simulationType=\"fixed\">\n"
324 " Simple note on parameter\n"
327 " </ListOfModelValues>\n"
328 " <ListOfReactions>\n"
329 " <Reaction key=\"Reaction_0\" name=\"reaction_1\" reversible=\"false\">\n"
331 " Simple note on reaction\n"
333 " <ListOfProducts>\n"
334 " <Product metabolite=\"Metabolite_0\" stoichiometry=\"1\"/>\n"
335 " </ListOfProducts>\n"
336 " <ListOfConstants>\n"
337 " <Constant key=\"Parameter_74\" name=\"v\" value=\"0.1\"/>\n"
338 " </ListOfConstants>\n"
339 " <KineticLaw function=\"Function_6\">\n"
340 " <ListOfCallParameters>\n"
341 " <CallParameter functionParameter=\"FunctionParameter_49\">\n"
342 " <SourceParameter reference=\"Parameter_74\"/>\n"
343 " </CallParameter>\n"
344 " </ListOfCallParameters>\n"
347 " </ListOfReactions>\n"
349 " <Event key=\"Event_0\" name=\"event_1\" order=\"1\">\n"
351 " Simple note on event\n"
353 " <TriggerExpression>\n"
354 " <CN=Root,Model=New Model,Reference=Time> gt 3.0\n"
355 " </TriggerExpression>\n"
356 " <ListOfAssignments>\n"
357 " <Assignment targetKey=\"ModelValue_0\">\n"
362 " </ListOfAssignments>\n"
366 " <StateTemplateVariable objectReference=\"Model_0\"/>\n"
367 " <StateTemplateVariable objectReference=\"Metabolite_0\"/>\n"
368 " <StateTemplateVariable objectReference=\"ModelValue_0\"/>\n"
369 " <StateTemplateVariable objectReference=\"Compartment_0\"/>\n"
370 " </StateTemplate>\n"
371 " <InitialState type=\"initialState\">\n"
372 " 0 6.022141790000001e+20 0 1 \n"
Header file of class CModelEntity and CModelValue.
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static const char * CPS_MODEL_1
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
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)
Header file of class CEvent.
static const char * SBML_MODEL_1
CCopasiDataModel * pDataModel