COPASI API  4.16.103
test000092.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/sbml/unittests/test000092.cpp,v $
3 // $Revision: 1.9 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2011/09/30 16:37:14 $
7 // End CVS Header
8 
9 // Copyright (C) 2011 - 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 #include <sstream>
15 #include "utilities.hpp"
17 #include "copasi/model/CModel.h"
22 
23 #include <sbml/SBMLDocument.h>
24 #include <sbml/Model.h>
25 #include <sbml/Compartment.h>
26 #include <sbml/annotation/CVTerm.h>
27 #include <sbml/annotation/ModelHistory.h>
28 #include <sbml/xml/XMLNode.h>
29 #include <sbml/xml/XMLInputStream.h>
30 #include <sbml/xml/XMLNamespaces.h>
31 
33 
34 #include "test000092.h"
35 
36 CCopasiDataModel* test000092::pCOPASIDATAMODEL = NULL;
37 
39 {
40  // Create the root container.
41  CCopasiRootContainer::init(0, NULL, false);
42  // Create the global data model.
44 }
45 
47 {
49 }
50 
52 {
53  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
54  std::istringstream iss(test000092::MODEL_STRING1);
55  bool result = load_cps_model_from_stream(iss, *pDataModel);
56  CPPUNIT_ASSERT(result == true);
57  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
58  std::string content = pDataModel->exportSBMLToString(NULL, 2, 4);
59  CPPUNIT_ASSERT(content.empty() == false);
60  // now we convert the content into an XMLNode and check if everything is there that needs to be there
61  XMLInputStream inputstream(content.c_str(), false);
62  XMLNode node(inputstream);
63  CPPUNIT_ASSERT(node.getName() == "sbml");
64  unsigned int i, iMax = node.getNumChildren();
65  CPPUNIT_ASSERT(iMax == 1);
66  const XMLNode* pModelNode = &node.getChild(0);
67  CPPUNIT_ASSERT(pModelNode != NULL);
68  CPPUNIT_ASSERT(pModelNode->getName() == "model");
69  iMax = pModelNode->getNumChildren();
70  CPPUNIT_ASSERT(iMax > 0);
71  // the annotation to the model should always be the first child
72  const XMLNode* pModelAnnotation = &pModelNode->getChild(0);
73  CPPUNIT_ASSERT(pModelAnnotation != NULL);
74  CPPUNIT_ASSERT(pModelAnnotation->getName() == "annotation");
75  // since the MIRIAM information is complete , we should have two children
76  // one with the libsbml MIRIAM annotation and one with the COPASI MIRIAM annotation
77  iMax = pModelAnnotation->getNumChildren();
78  CPPUNIT_ASSERT(iMax == 2);
79  const XMLNode* pMIRIAM1 = NULL, *pMIRIAM2 = NULL;
80  pMIRIAM1 = &pModelAnnotation->getChild(0);
81  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
82 
83  // make sure the libsbml annotation is stored in pMIRIAM1
84  if (pMIRIAM1->getName() != "RDF")
85  {
86  pMIRIAM2 = pMIRIAM1;
87  pMIRIAM1 = &pModelAnnotation->getChild(1);
88  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
89  CPPUNIT_ASSERT(pMIRIAM1->getName() == "RDF");
90  }
91  else
92  {
93  pMIRIAM2 = &pModelAnnotation->getChild(1);
94  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
95  CPPUNIT_ASSERT(pMIRIAM2->getName() == "COPASI");
96  }
97 
98  // check if the top level element for the libsbml annotation
99  // has all necessary namespaces
100  const XMLNamespaces* ns = &pMIRIAM2->getNamespaces();
101  CPPUNIT_ASSERT(ns != NULL);
102  int index = ns->getIndex("http://www.copasi.org/static/sbml");
103  CPPUNIT_ASSERT(index != -1);
104  CPPUNIT_ASSERT(ns->getPrefix(index) == "");
105  iMax = pMIRIAM2->getNumChildren();
106  CPPUNIT_ASSERT(iMax == 1);
107  pMIRIAM2 = &pMIRIAM2->getChild(0);
108  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
109  CPPUNIT_ASSERT(pMIRIAM2->getName() == "RDF");
110  CPPUNIT_ASSERT(pMIRIAM2->getPrefix() == "rdf");
111  ns = &pMIRIAM2->getNamespaces();
112  CPPUNIT_ASSERT(ns != NULL);
113  index = ns->getIndex("http://purl.org/dc/terms/");
114  CPPUNIT_ASSERT(index != -1);
115  CPPUNIT_ASSERT(ns->getPrefix(index) == "dcterms");
116  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
117  CPPUNIT_ASSERT(index != -1);
118  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
119  index = ns->getIndex("http://www.w3.org/2001/vcard-rdf/3.0#");
120  CPPUNIT_ASSERT(index != -1);
121  CPPUNIT_ASSERT(ns->getPrefix(index) == "vCard");
122  // same checks for the libsbml MIRIAM annotation
123  CPPUNIT_ASSERT(pMIRIAM1->getName() == "RDF");
124  CPPUNIT_ASSERT(pMIRIAM1->getPrefix() == "rdf");
125  ns = &pMIRIAM1->getNamespaces();
126  CPPUNIT_ASSERT(ns != NULL);
127  index = ns->getIndex("http://purl.org/dc/terms/");
128  CPPUNIT_ASSERT(index != -1);
129  CPPUNIT_ASSERT(ns->getPrefix(index) == "dcterms");
130  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
131  CPPUNIT_ASSERT(index != -1);
132  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
133  index = ns->getIndex("http://www.w3.org/2001/vcard-rdf/3.0#");
134  CPPUNIT_ASSERT(index != -1);
135  CPPUNIT_ASSERT(ns->getPrefix(index) == "vCard");
136  // there are actually more namespace attributes in the libsbml annotation, but that is enough to make sure
137  // that everything should be OK
138  //
139  // Right now, we don't care about the content of the annotations as long as they are there
140  //
141  // Find the compartment node
142  iMax = pModelNode->getNumChildren();
143  const XMLNode* pListOfCompartments = NULL;
144 
145  for (i = 0; i < iMax; ++i)
146  {
147  if (pModelNode->getChild(i).getName() == "listOfCompartments")
148  {
149  pListOfCompartments = &pModelNode->getChild(i);
150  break;
151  }
152  }
153 
154  CPPUNIT_ASSERT(pListOfCompartments != NULL);
155  iMax = pListOfCompartments->getNumChildren();
156  // we have only one compartment
157  CPPUNIT_ASSERT(iMax == 1);
158  const XMLNode* pCompartment = &pListOfCompartments->getChild(0);
159  CPPUNIT_ASSERT(pCompartment != NULL);
160  CPPUNIT_ASSERT(pCompartment->getName() == "compartment");
161  iMax = pCompartment->getNumChildren();
162  CPPUNIT_ASSERT(iMax > 0);
163  // the annotation to the model should always be the first child
164  const XMLNode* pAnnotation = &pCompartment->getChild(0);
165  CPPUNIT_ASSERT(pAnnotation != NULL);
166  CPPUNIT_ASSERT(pAnnotation->getName() == "annotation");
167  // since the MIRIAM information is complete , we should have two children
168  // one with the libsbml MIRIAM annotation and one with the COPASI MIRIAM annotation
169  iMax = pAnnotation->getNumChildren();
170  CPPUNIT_ASSERT(iMax == 2);
171  pMIRIAM1 = &pAnnotation->getChild(0);
172  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
173 
174  // make sure the libsbml annotation is stored in pMIRIAM1
175  if (pMIRIAM1->getName() != "RDF")
176  {
177  pMIRIAM2 = pMIRIAM1;
178  pMIRIAM1 = &pAnnotation->getChild(1);
179  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
180  CPPUNIT_ASSERT(pMIRIAM1->getName() == "RDF");
181  }
182  else
183  {
184  pMIRIAM2 = &pAnnotation->getChild(1);
185  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
186  CPPUNIT_ASSERT(pMIRIAM2->getName() == "COPASI");
187  }
188 
189  // check if the top level element for the libsbml annotation
190  // has all necessary namespaces
191  ns = &pMIRIAM2->getNamespaces();
192  CPPUNIT_ASSERT(ns != NULL);
193  index = ns->getIndex("http://www.copasi.org/static/sbml");
194  CPPUNIT_ASSERT(index != -1);
195  CPPUNIT_ASSERT(ns->getPrefix(index) == "");
196  iMax = pMIRIAM2->getNumChildren();
197  CPPUNIT_ASSERT(iMax == 1);
198  pMIRIAM2 = &pMIRIAM2->getChild(0);
199  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
200  CPPUNIT_ASSERT(pMIRIAM2->getName() == "RDF");
201  CPPUNIT_ASSERT(pMIRIAM2->getPrefix() == "rdf");
202  ns = &pMIRIAM2->getNamespaces();
203  CPPUNIT_ASSERT(ns != NULL);
204  index = ns->getIndex("http://purl.org/dc/terms/");
205  CPPUNIT_ASSERT(index != -1);
206  CPPUNIT_ASSERT(ns->getPrefix(index) == "dcterms");
207  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
208  CPPUNIT_ASSERT(index != -1);
209  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
210  index = ns->getIndex("http://www.w3.org/2001/vcard-rdf/3.0#");
211  CPPUNIT_ASSERT(index != -1);
212  CPPUNIT_ASSERT(ns->getPrefix(index) == "vCard");
213  // same checks for the libsbml MIRIAM annotation
214  CPPUNIT_ASSERT(pMIRIAM1->getName() == "RDF");
215  CPPUNIT_ASSERT(pMIRIAM1->getPrefix() == "rdf");
216  ns = &pMIRIAM1->getNamespaces();
217  CPPUNIT_ASSERT(ns != NULL);
218  index = ns->getIndex("http://purl.org/dc/terms/");
219  CPPUNIT_ASSERT(index != -1);
220  CPPUNIT_ASSERT(ns->getPrefix(index) == "dcterms");
221  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
222  CPPUNIT_ASSERT(index != -1);
223  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
224  index = ns->getIndex("http://www.w3.org/2001/vcard-rdf/3.0#");
225  CPPUNIT_ASSERT(index != -1);
226  CPPUNIT_ASSERT(ns->getPrefix(index) == "vCard");
227  // try to reimport the stuff to make sure it is valid SBML
228  result = pDataModel->importSBMLFromString(content);
229  CPPUNIT_ASSERT(result == true);
230 }
231 
233 {
234  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
235  std::istringstream iss(test000092::MODEL_STRING2);
236  bool result = load_cps_model_from_stream(iss, *pDataModel);
237  CPPUNIT_ASSERT(result == true);
238  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
239  std::string content = pDataModel->exportSBMLToString(NULL, 2, 4);
240  CPPUNIT_ASSERT(content.empty() == false);
241  // now we convert the content into an XMLNode and check if everything is there that needs to be there
242  XMLInputStream inputstream(content.c_str(), false);
243  XMLNode node(inputstream);
244  CPPUNIT_ASSERT(node.getName() == "sbml");
245  unsigned int i, iMax = node.getNumChildren();
246  CPPUNIT_ASSERT(iMax == 1);
247  const XMLNode* pModelNode = &node.getChild(0);
248  CPPUNIT_ASSERT(pModelNode != NULL);
249  CPPUNIT_ASSERT(pModelNode->getName() == "model");
250  iMax = pModelNode->getNumChildren();
251  CPPUNIT_ASSERT(iMax > 0);
252  // the annotation to the model should always be the first child
253  const XMLNode* pModelAnnotation = &pModelNode->getChild(0);
254  CPPUNIT_ASSERT(pModelAnnotation != NULL);
255  CPPUNIT_ASSERT(pModelAnnotation->getName() == "annotation");
256  // since the MIRIAM information is incomplete , we should have one or two children
257  // depending on the version of libsbml we are using
258  iMax = pModelAnnotation->getNumChildren();
259  CPPUNIT_ASSERT(iMax == 1 || iMax == 2);
260  const XMLNode* pMIRIAM1 = NULL, *pMIRIAM2 = NULL;
261  pMIRIAM1 = &pModelAnnotation->getChild(0);
262  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
263 
264  // make sure the libsbml annotation is stored in pMIRIAM1
265  if (pMIRIAM1->getName() != "RDF")
266  {
267  pMIRIAM2 = pMIRIAM1;
268  pMIRIAM1 = NULL;
269 
270  if (iMax == 2)
271  {
272  pMIRIAM1 = &pModelAnnotation->getChild(1);
273  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
274  CPPUNIT_ASSERT(pMIRIAM1->getName() == "RDF");
275  }
276  }
277  else
278  {
279  if (iMax == 2)
280  {
281  pMIRIAM2 = &pModelAnnotation->getChild(1);
282  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
283  CPPUNIT_ASSERT(pMIRIAM2->getName() == "COPASI");
284  }
285  }
286 
287  // check if the top level element for the libsbml annotation
288  // has all necessary namespaces
289  const XMLNamespaces* ns = &pMIRIAM2->getNamespaces();
290  CPPUNIT_ASSERT(ns != NULL);
291  int index = ns->getIndex("http://www.copasi.org/static/sbml");
292  CPPUNIT_ASSERT(index != -1);
293  CPPUNIT_ASSERT(ns->getPrefix(index) == "");
294  iMax = pMIRIAM2->getNumChildren();
295  CPPUNIT_ASSERT(iMax == 1);
296  pMIRIAM2 = &pMIRIAM2->getChild(0);
297  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
298  CPPUNIT_ASSERT(pMIRIAM2->getName() == "RDF");
299  CPPUNIT_ASSERT(pMIRIAM2->getPrefix() == "rdf");
300  ns = &pMIRIAM2->getNamespaces();
301  CPPUNIT_ASSERT(ns != NULL);
302  index = ns->getIndex("http://purl.org/dc/terms/");
303  CPPUNIT_ASSERT(index != -1);
304  CPPUNIT_ASSERT(ns->getPrefix(index) == "dcterms");
305  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
306  CPPUNIT_ASSERT(index != -1);
307  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
308  index = ns->getIndex("http://www.w3.org/2001/vcard-rdf/3.0#");
309  CPPUNIT_ASSERT(index != -1);
310  CPPUNIT_ASSERT(ns->getPrefix(index) == "vCard");
311 
312  // same checks for the libsbml MIRIAM annotation
313  if (pMIRIAM1 != NULL)
314  {
315  CPPUNIT_ASSERT(pMIRIAM1->getName() == "RDF");
316  CPPUNIT_ASSERT(pMIRIAM1->getPrefix() == "rdf");
317  ns = &pMIRIAM1->getNamespaces();
318  CPPUNIT_ASSERT(ns != NULL);
319  index = ns->getIndex("http://purl.org/dc/terms/");
320  CPPUNIT_ASSERT(index != -1);
321  CPPUNIT_ASSERT(ns->getPrefix(index) == "dcterms");
322  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
323  CPPUNIT_ASSERT(index != -1);
324  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
325  index = ns->getIndex("http://www.w3.org/2001/vcard-rdf/3.0#");
326  CPPUNIT_ASSERT(index != -1);
327  CPPUNIT_ASSERT(ns->getPrefix(index) == "vCard");
328  }
329 
330  // there are actually more namespace attributes in the libsbml annotation, but that is enough to make sure
331  // that everything should be OK
332  //
333  // Right now, we don't care about the content of the annotations as long as they are there
334  //
335  // Find the compartment node
336  iMax = pModelNode->getNumChildren();
337  const XMLNode* pListOfCompartments = NULL;
338 
339  for (i = 0; i < iMax; ++i)
340  {
341  if (pModelNode->getChild(i).getName() == "listOfCompartments")
342  {
343  pListOfCompartments = &pModelNode->getChild(i);
344  break;
345  }
346  }
347 
348  CPPUNIT_ASSERT(pListOfCompartments != NULL);
349  iMax = pListOfCompartments->getNumChildren();
350  // we have only one compartment
351  CPPUNIT_ASSERT(iMax == 1);
352  const XMLNode* pCompartment = &pListOfCompartments->getChild(0);
353  CPPUNIT_ASSERT(pCompartment != NULL);
354  CPPUNIT_ASSERT(pCompartment->getName() == "compartment");
355  iMax = pCompartment->getNumChildren();
356  CPPUNIT_ASSERT(iMax > 0);
357  // the annotation to the model should always be the first child
358  const XMLNode* pAnnotation = &pCompartment->getChild(0);
359  CPPUNIT_ASSERT(pAnnotation != NULL);
360  CPPUNIT_ASSERT(pAnnotation->getName() == "annotation");
361  // since the MIRIAM information is complete , we should have two children
362  // one with the libsbml MIRIAM annotation and one with the COPASI MIRIAM annotation
363  iMax = pAnnotation->getNumChildren();
364  CPPUNIT_ASSERT(iMax == 2);
365  pMIRIAM1 = &pAnnotation->getChild(0);
366  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
367 
368  // make sure the libsbml annotation is stored in pMIRIAM1
369  if (pMIRIAM1->getName() != "RDF")
370  {
371  pMIRIAM2 = pMIRIAM1;
372  pMIRIAM1 = &pAnnotation->getChild(1);
373  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
374  CPPUNIT_ASSERT(pMIRIAM1->getName() == "RDF");
375  }
376  else
377  {
378  pMIRIAM2 = &pAnnotation->getChild(1);
379  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
380  CPPUNIT_ASSERT(pMIRIAM2->getName() == "COPASI");
381  }
382 
383  // check if the top level element for the libsbml annotation
384  // has all necessary namespaces
385  ns = &pMIRIAM2->getNamespaces();
386  CPPUNIT_ASSERT(ns != NULL);
387  index = ns->getIndex("http://www.copasi.org/static/sbml");
388  CPPUNIT_ASSERT(index != -1);
389  CPPUNIT_ASSERT(ns->getPrefix(index) == "");
390  iMax = pMIRIAM2->getNumChildren();
391  CPPUNIT_ASSERT(iMax == 1);
392  pMIRIAM2 = &pMIRIAM2->getChild(0);
393  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
394  CPPUNIT_ASSERT(pMIRIAM2->getName() == "RDF");
395  CPPUNIT_ASSERT(pMIRIAM2->getPrefix() == "rdf");
396  ns = &pMIRIAM2->getNamespaces();
397  CPPUNIT_ASSERT(ns != NULL);
398  index = ns->getIndex("http://purl.org/dc/terms/");
399  CPPUNIT_ASSERT(index != -1);
400  CPPUNIT_ASSERT(ns->getPrefix(index) == "dcterms");
401  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
402  CPPUNIT_ASSERT(index != -1);
403  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
404  index = ns->getIndex("http://www.w3.org/2001/vcard-rdf/3.0#");
405  CPPUNIT_ASSERT(index != -1);
406  CPPUNIT_ASSERT(ns->getPrefix(index) == "vCard");
407  // same checks for the libsbml MIRIAM annotation
408  CPPUNIT_ASSERT(pMIRIAM1->getName() == "RDF");
409  CPPUNIT_ASSERT(pMIRIAM1->getPrefix() == "rdf");
410  ns = &pMIRIAM1->getNamespaces();
411  CPPUNIT_ASSERT(ns != NULL);
412  index = ns->getIndex("http://purl.org/dc/terms/");
413  CPPUNIT_ASSERT(index != -1);
414  CPPUNIT_ASSERT(ns->getPrefix(index) == "dcterms");
415  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
416  CPPUNIT_ASSERT(index != -1);
417  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
418  index = ns->getIndex("http://www.w3.org/2001/vcard-rdf/3.0#");
419  CPPUNIT_ASSERT(index != -1);
420  CPPUNIT_ASSERT(ns->getPrefix(index) == "vCard");
421  // try to reimport the stuff to make sure it is valid SBML
422  result = pDataModel->importSBMLFromString(content);
423  CPPUNIT_ASSERT(result == true);
424 }
425 
427 {
428  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
429  std::istringstream iss(test000092::MODEL_STRING3);
430  bool result = load_cps_model_from_stream(iss, *pDataModel);
431  CPPUNIT_ASSERT(result == true);
432  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
433  std::string content = pDataModel->exportSBMLToString(NULL, 2, 4);
434  CPPUNIT_ASSERT(content.empty() == false);
435  // now we convert the content into an XMLNode and check if everything is there that needs to be there
436  XMLInputStream inputstream(content.c_str(), false);
437  XMLNode node(inputstream);
438  CPPUNIT_ASSERT(node.getName() == "sbml");
439  unsigned int i, iMax = node.getNumChildren();
440  CPPUNIT_ASSERT(iMax == 1);
441  const XMLNode* pModelNode = &node.getChild(0);
442  CPPUNIT_ASSERT(pModelNode != NULL);
443  CPPUNIT_ASSERT(pModelNode->getName() == "model");
444  iMax = pModelNode->getNumChildren();
445  CPPUNIT_ASSERT(iMax > 0);
446  // the annotation to the model should always be the first child
447  // So since we don't expect any annotations for this model,
448  // the first node should not be an annotation node
449  const XMLNode* pModelAnnotation = &pModelNode->getChild(0);
450  CPPUNIT_ASSERT(pModelAnnotation != NULL);
451  CPPUNIT_ASSERT(pModelAnnotation->getName() != "annotation");
452  // Find the compartment node
453  iMax = pModelNode->getNumChildren();
454  const XMLNode* pListOfCompartments = NULL;
455 
456  for (i = 0; i < iMax; ++i)
457  {
458  if (pModelNode->getChild(i).getName() == "listOfCompartments")
459  {
460  pListOfCompartments = &pModelNode->getChild(i);
461  break;
462  }
463  }
464 
465  CPPUNIT_ASSERT(pListOfCompartments != NULL);
466  iMax = pListOfCompartments->getNumChildren();
467  // we have only one compartment
468  CPPUNIT_ASSERT(iMax == 1);
469  const XMLNode* pCompartment = &pListOfCompartments->getChild(0);
470  CPPUNIT_ASSERT(pCompartment != NULL);
471  CPPUNIT_ASSERT(pCompartment->getName() == "compartment");
472  iMax = pCompartment->getNumChildren();
473  // there should be no annotation to the compartment
474  CPPUNIT_ASSERT(iMax == 0);
475  // try to reimport the stuff to make sure it is valid SBML
476  result = pDataModel->importSBMLFromString(content);
477  CPPUNIT_ASSERT(result == true);
478 }
479 
480 
482 {
483  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
484  std::istringstream iss(test000092::MODEL_STRING4);
485  bool result = load_cps_model_from_stream(iss, *pDataModel);
486  CPPUNIT_ASSERT(result == true);
487  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
488  std::string content = pDataModel->exportSBMLToString(NULL, 2, 4);
489  CPPUNIT_ASSERT(content.empty() == false);
490  // now we convert the content into an XMLNode and check if everything is there that needs to be there
491  XMLInputStream inputstream(content.c_str(), false);
492  XMLNode node(inputstream);
493  CPPUNIT_ASSERT(node.getName() == "sbml");
494  unsigned int i, iMax = node.getNumChildren();
495  CPPUNIT_ASSERT(iMax == 1);
496  const XMLNode* pModelNode = &node.getChild(0);
497  CPPUNIT_ASSERT(pModelNode != NULL);
498  CPPUNIT_ASSERT(pModelNode->getName() == "model");
499  iMax = pModelNode->getNumChildren();
500  CPPUNIT_ASSERT(iMax > 0);
501  // the annotation to the model should always be the first child
502  const XMLNode* pModelAnnotation = &pModelNode->getChild(0);
503  CPPUNIT_ASSERT(pModelAnnotation != NULL);
504  CPPUNIT_ASSERT(pModelAnnotation->getName() == "annotation");
505  // since the MIRIAM information is complete , we should have two children
506  // one with the libsbml MIRIAM annotation and one with the COPASI MIRIAM annotation
507  iMax = pModelAnnotation->getNumChildren();
508  CPPUNIT_ASSERT(iMax == 3);
509  const XMLNode* pMIRIAM1 = NULL, *pMIRIAM2 = NULL, *pLayout = NULL;
510 
511  // make sure the libsbml annotation is stored in pMIRIAM1
512  for (unsigned int i = 0; i < iMax; ++i)
513  {
514  if (pModelAnnotation->getChild(i).getName() == "COPASI")
515  {
516  pMIRIAM2 = &pModelAnnotation->getChild(i);
517  }
518  else if (pModelAnnotation->getChild(i).getName() == "RDF")
519  {
520  pMIRIAM1 = &pModelAnnotation->getChild(i);
521  }
522  else if (pModelAnnotation->getChild(i).getName() == "listOfLayouts")
523  {
524  pLayout = &pModelAnnotation->getChild(i);
525  }
526  }
527 
528  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
529  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
530  CPPUNIT_ASSERT(pLayout != NULL);
531  // check if the top level element for the libsbml annotation
532  // has all necessary namespaces
533  const XMLNamespaces* ns = &pMIRIAM2->getNamespaces();
534  CPPUNIT_ASSERT(ns != NULL);
535  int index = ns->getIndex("http://www.copasi.org/static/sbml");
536  CPPUNIT_ASSERT(index != -1);
537  CPPUNIT_ASSERT(ns->getPrefix(index) == "");
538  iMax = pMIRIAM2->getNumChildren();
539  CPPUNIT_ASSERT(iMax == 1);
540  pMIRIAM2 = &pMIRIAM2->getChild(0);
541  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
542  CPPUNIT_ASSERT(pMIRIAM2->getName() == "RDF");
543  CPPUNIT_ASSERT(pMIRIAM2->getPrefix() == "rdf");
544  ns = &pMIRIAM2->getNamespaces();
545  CPPUNIT_ASSERT(ns != NULL);
546  index = ns->getIndex("http://purl.org/dc/terms/");
547  CPPUNIT_ASSERT(index != -1);
548  CPPUNIT_ASSERT(ns->getPrefix(index) == "dcterms");
549  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
550  CPPUNIT_ASSERT(index != -1);
551  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
552  index = ns->getIndex("http://www.w3.org/2001/vcard-rdf/3.0#");
553  CPPUNIT_ASSERT(index != -1);
554  CPPUNIT_ASSERT(ns->getPrefix(index) == "vCard");
555  // same checks for the libsbml MIRIAM annotation
556  CPPUNIT_ASSERT(pMIRIAM1->getName() == "RDF");
557  CPPUNIT_ASSERT(pMIRIAM1->getPrefix() == "rdf");
558  ns = &pMIRIAM1->getNamespaces();
559  CPPUNIT_ASSERT(ns != NULL);
560  index = ns->getIndex("http://purl.org/dc/terms/");
561  CPPUNIT_ASSERT(index != -1);
562  CPPUNIT_ASSERT(ns->getPrefix(index) == "dcterms");
563  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
564  CPPUNIT_ASSERT(index != -1);
565  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
566  index = ns->getIndex("http://www.w3.org/2001/vcard-rdf/3.0#");
567  CPPUNIT_ASSERT(index != -1);
568  CPPUNIT_ASSERT(ns->getPrefix(index) == "vCard");
569  // there are actually more namespace attributes in the libsbml annotation, but that is enough to make sure
570  // that everything should be OK
571  //
572  // Right now, we don't care about the content of the annotations as long as they are there
573  //
574  // Find the compartment node
575  iMax = pModelNode->getNumChildren();
576  const XMLNode* pListOfCompartments = NULL;
577 
578  for (i = 0; i < iMax; ++i)
579  {
580  if (pModelNode->getChild(i).getName() == "listOfCompartments")
581  {
582  pListOfCompartments = &pModelNode->getChild(i);
583  break;
584  }
585  }
586 
587  CPPUNIT_ASSERT(pListOfCompartments != NULL);
588  iMax = pListOfCompartments->getNumChildren();
589  // we have only one compartment
590  CPPUNIT_ASSERT(iMax == 1);
591  const XMLNode* pCompartment = &pListOfCompartments->getChild(0);
592  CPPUNIT_ASSERT(pCompartment != NULL);
593  CPPUNIT_ASSERT(pCompartment->getName() == "compartment");
594  iMax = pCompartment->getNumChildren();
595  CPPUNIT_ASSERT(iMax > 0);
596  // the annotation to the model should always be the first child
597  const XMLNode* pAnnotation = &pCompartment->getChild(0);
598  CPPUNIT_ASSERT(pAnnotation != NULL);
599  CPPUNIT_ASSERT(pAnnotation->getName() == "annotation");
600  // since the MIRIAM information is complete , we should have two children
601  // one with the libsbml MIRIAM annotation and one with the COPASI MIRIAM annotation
602  iMax = pAnnotation->getNumChildren();
603  CPPUNIT_ASSERT(iMax == 2);
604  pMIRIAM1 = NULL;
605  pMIRIAM2 = NULL;
606  pMIRIAM1 = &pAnnotation->getChild(0);
607  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
608 
609  // make sure the libsbml annotation is stored in pMIRIAM1
610  if (pMIRIAM1->getName() != "RDF")
611  {
612  pMIRIAM2 = pMIRIAM1;
613  pMIRIAM1 = &pAnnotation->getChild(1);
614  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
615  CPPUNIT_ASSERT(pMIRIAM1->getName() == "RDF");
616  }
617  else
618  {
619  pMIRIAM2 = &pAnnotation->getChild(1);
620  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
621  CPPUNIT_ASSERT(pMIRIAM2->getName() == "COPASI");
622  }
623 
624  // check if the top level element for the libsbml annotation
625  // has all necessary namespaces
626  ns = &pMIRIAM2->getNamespaces();
627  CPPUNIT_ASSERT(ns != NULL);
628  index = ns->getIndex("http://www.copasi.org/static/sbml");
629  CPPUNIT_ASSERT(index != -1);
630  CPPUNIT_ASSERT(ns->getPrefix(index) == "");
631  iMax = pMIRIAM2->getNumChildren();
632  CPPUNIT_ASSERT(iMax == 1);
633  pMIRIAM2 = &pMIRIAM2->getChild(0);
634  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
635  CPPUNIT_ASSERT(pMIRIAM2->getName() == "RDF");
636  CPPUNIT_ASSERT(pMIRIAM2->getPrefix() == "rdf");
637  ns = &pMIRIAM2->getNamespaces();
638  CPPUNIT_ASSERT(ns != NULL);
639  index = ns->getIndex("http://purl.org/dc/terms/");
640  CPPUNIT_ASSERT(index != -1);
641  CPPUNIT_ASSERT(ns->getPrefix(index) == "dcterms");
642  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
643  CPPUNIT_ASSERT(index != -1);
644  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
645  index = ns->getIndex("http://www.w3.org/2001/vcard-rdf/3.0#");
646  CPPUNIT_ASSERT(index != -1);
647  CPPUNIT_ASSERT(ns->getPrefix(index) == "vCard");
648  // same checks for the libsbml MIRIAM annotation
649  CPPUNIT_ASSERT(pMIRIAM1->getName() == "RDF");
650  CPPUNIT_ASSERT(pMIRIAM1->getPrefix() == "rdf");
651  ns = &pMIRIAM1->getNamespaces();
652  CPPUNIT_ASSERT(ns != NULL);
653  index = ns->getIndex("http://purl.org/dc/terms/");
654  CPPUNIT_ASSERT(index != -1);
655  CPPUNIT_ASSERT(ns->getPrefix(index) == "dcterms");
656  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
657  CPPUNIT_ASSERT(index != -1);
658  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
659  index = ns->getIndex("http://www.w3.org/2001/vcard-rdf/3.0#");
660  CPPUNIT_ASSERT(index != -1);
661  CPPUNIT_ASSERT(ns->getPrefix(index) == "vCard");
662  // try to reimport the stuff to make sure it is valid SBML
663  result = pDataModel->importSBMLFromString(content);
664  CPPUNIT_ASSERT(result == true);
665 }
666 
668 {
669  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
670  std::istringstream iss(test000092::MODEL_STRING5);
671  bool result = load_cps_model_from_stream(iss, *pDataModel);
672  CPPUNIT_ASSERT(result == true);
673  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
674  std::string content = pDataModel->exportSBMLToString(NULL, 2, 4);
675  CPPUNIT_ASSERT(content.empty() == false);
676  // now we convert the content into an XMLNode and check if everything is there that needs to be there
677  XMLInputStream inputstream(content.c_str(), false);
678  XMLNode node(inputstream);
679  CPPUNIT_ASSERT(node.getName() == "sbml");
680  unsigned int i, iMax = node.getNumChildren();
681  CPPUNIT_ASSERT(iMax == 1);
682  const XMLNode* pModelNode = &node.getChild(0);
683  CPPUNIT_ASSERT(pModelNode != NULL);
684  CPPUNIT_ASSERT(pModelNode->getName() == "model");
685  iMax = pModelNode->getNumChildren();
686  CPPUNIT_ASSERT(iMax > 0);
687  // the annotation to the model should always be the first child
688  const XMLNode* pModelAnnotation = &pModelNode->getChild(0);
689  CPPUNIT_ASSERT(pModelAnnotation != NULL);
690  CPPUNIT_ASSERT(pModelAnnotation->getName() == "annotation");
691  // since the MIRIAM information is incomplete , we should have one or two children
692  // depending on the version of libsbml we are using
693  iMax = pModelAnnotation->getNumChildren();
694  CPPUNIT_ASSERT(iMax == 2 || iMax == 3);
695  const XMLNode* pMIRIAM1 = NULL, *pMIRIAM2 = NULL, *pLayout;
696 
697  for (unsigned i = 0; i < iMax; ++i)
698  {
699  if (pModelAnnotation->getChild(i).getName() == "COPASI")
700  {
701  pMIRIAM2 = &pModelAnnotation->getChild(i);
702  }
703  else if (pModelAnnotation->getChild(i).getName() == "RDF")
704  {
705  pMIRIAM1 = &pModelAnnotation->getChild(i);
706  }
707  else if (pModelAnnotation->getChild(i).getName() == "listOfLayouts")
708  {
709  pLayout = &pModelAnnotation->getChild(i);
710  }
711  }
712 
713  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
714  CPPUNIT_ASSERT(pLayout != NULL);
715 
716  if (iMax == 3)
717  {
718  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
719  }
720 
721  // check if the top level element for the libsbml annotation
722  // has all necessary namespaces
723  const XMLNamespaces* ns = &pMIRIAM2->getNamespaces();
724  CPPUNIT_ASSERT(ns != NULL);
725  int index = ns->getIndex("http://www.copasi.org/static/sbml");
726  CPPUNIT_ASSERT(index != -1);
727  CPPUNIT_ASSERT(ns->getPrefix(index) == "");
728  iMax = pMIRIAM2->getNumChildren();
729  CPPUNIT_ASSERT(iMax == 1);
730  pMIRIAM2 = &pMIRIAM2->getChild(0);
731  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
732  CPPUNIT_ASSERT(pMIRIAM2->getName() == "RDF");
733  CPPUNIT_ASSERT(pMIRIAM2->getPrefix() == "rdf");
734  ns = &pMIRIAM2->getNamespaces();
735  CPPUNIT_ASSERT(ns != NULL);
736  index = ns->getIndex("http://purl.org/dc/terms/");
737  CPPUNIT_ASSERT(index != -1);
738  CPPUNIT_ASSERT(ns->getPrefix(index) == "dcterms");
739  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
740  CPPUNIT_ASSERT(index != -1);
741  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
742  index = ns->getIndex("http://www.w3.org/2001/vcard-rdf/3.0#");
743  CPPUNIT_ASSERT(index != -1);
744  CPPUNIT_ASSERT(ns->getPrefix(index) == "vCard");
745 
746  // same checks for the libsbml MIRIAM annotation
747  if (pMIRIAM1 != NULL)
748  {
749  CPPUNIT_ASSERT(pMIRIAM1->getName() == "RDF");
750  CPPUNIT_ASSERT(pMIRIAM1->getPrefix() == "rdf");
751  ns = &pMIRIAM1->getNamespaces();
752  CPPUNIT_ASSERT(ns != NULL);
753  index = ns->getIndex("http://purl.org/dc/terms/");
754  CPPUNIT_ASSERT(index != -1);
755  CPPUNIT_ASSERT(ns->getPrefix(index) == "dcterms");
756  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
757  CPPUNIT_ASSERT(index != -1);
758  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
759  index = ns->getIndex("http://www.w3.org/2001/vcard-rdf/3.0#");
760  CPPUNIT_ASSERT(index != -1);
761  CPPUNIT_ASSERT(ns->getPrefix(index) == "vCard");
762  }
763 
764  // there are actually more namespace attributes in the libsbml annotation, but that is enough to make sure
765  // that everything should be OK
766  //
767  // Right now, we don't care about the content of the annotations as long as they are there
768  //
769  // Find the compartment node
770  iMax = pModelNode->getNumChildren();
771  const XMLNode* pListOfCompartments = NULL;
772 
773  for (i = 0; i < iMax; ++i)
774  {
775  if (pModelNode->getChild(i).getName() == "listOfCompartments")
776  {
777  pListOfCompartments = &pModelNode->getChild(i);
778  break;
779  }
780  }
781 
782  CPPUNIT_ASSERT(pListOfCompartments != NULL);
783  iMax = pListOfCompartments->getNumChildren();
784  // we have only one compartment
785  CPPUNIT_ASSERT(iMax == 1);
786  const XMLNode* pCompartment = &pListOfCompartments->getChild(0);
787  CPPUNIT_ASSERT(pCompartment != NULL);
788  CPPUNIT_ASSERT(pCompartment->getName() == "compartment");
789  iMax = pCompartment->getNumChildren();
790  CPPUNIT_ASSERT(iMax > 0);
791  // the annotation to the model should always be the first child
792  const XMLNode* pAnnotation = &pCompartment->getChild(0);
793  CPPUNIT_ASSERT(pAnnotation != NULL);
794  CPPUNIT_ASSERT(pAnnotation->getName() == "annotation");
795  // since the MIRIAM information is complete , we should have two children
796  // one with the libsbml MIRIAM annotation and one with the COPASI MIRIAM annotation
797  iMax = pAnnotation->getNumChildren();
798  CPPUNIT_ASSERT(iMax == 2);
799  pMIRIAM1 = NULL;
800  pMIRIAM2 = NULL;
801  pMIRIAM1 = &pAnnotation->getChild(0);
802  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
803 
804  // make sure the libsbml annotation is stored in pMIRIAM1
805  if (pMIRIAM1->getName() != "RDF")
806  {
807  pMIRIAM2 = pMIRIAM1;
808  pMIRIAM1 = &pAnnotation->getChild(1);
809  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
810  CPPUNIT_ASSERT(pMIRIAM1->getName() == "RDF");
811  }
812  else
813  {
814  pMIRIAM2 = &pAnnotation->getChild(1);
815  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
816  CPPUNIT_ASSERT(pMIRIAM2->getName() == "COPASI");
817  }
818 
819  // check if the top level element for the libsbml annotation
820  // has all necessary namespaces
821  ns = &pMIRIAM2->getNamespaces();
822  CPPUNIT_ASSERT(ns != NULL);
823  index = ns->getIndex("http://www.copasi.org/static/sbml");
824  CPPUNIT_ASSERT(index != -1);
825  CPPUNIT_ASSERT(ns->getPrefix(index) == "");
826  iMax = pMIRIAM2->getNumChildren();
827  CPPUNIT_ASSERT(iMax == 1);
828  pMIRIAM2 = &pMIRIAM2->getChild(0);
829  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
830  CPPUNIT_ASSERT(pMIRIAM2->getName() == "RDF");
831  CPPUNIT_ASSERT(pMIRIAM2->getPrefix() == "rdf");
832  ns = &pMIRIAM2->getNamespaces();
833  CPPUNIT_ASSERT(ns != NULL);
834  index = ns->getIndex("http://purl.org/dc/terms/");
835  CPPUNIT_ASSERT(index != -1);
836  CPPUNIT_ASSERT(ns->getPrefix(index) == "dcterms");
837  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
838  CPPUNIT_ASSERT(index != -1);
839  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
840  index = ns->getIndex("http://www.w3.org/2001/vcard-rdf/3.0#");
841  CPPUNIT_ASSERT(index != -1);
842  CPPUNIT_ASSERT(ns->getPrefix(index) == "vCard");
843  // same checks for the libsbml MIRIAM annotation
844  CPPUNIT_ASSERT(pMIRIAM1->getName() == "RDF");
845  CPPUNIT_ASSERT(pMIRIAM1->getPrefix() == "rdf");
846  ns = &pMIRIAM1->getNamespaces();
847  CPPUNIT_ASSERT(ns != NULL);
848  index = ns->getIndex("http://purl.org/dc/terms/");
849  CPPUNIT_ASSERT(index != -1);
850  CPPUNIT_ASSERT(ns->getPrefix(index) == "dcterms");
851  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
852  CPPUNIT_ASSERT(index != -1);
853  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
854  index = ns->getIndex("http://www.w3.org/2001/vcard-rdf/3.0#");
855  CPPUNIT_ASSERT(index != -1);
856  CPPUNIT_ASSERT(ns->getPrefix(index) == "vCard");
857  // try to reimport the stuff to make sure it is valid SBML
858  result = pDataModel->importSBMLFromString(content);
859  CPPUNIT_ASSERT(result == true);
860 }
861 
863 {
864  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
865  std::istringstream iss(test000092::MODEL_STRING6);
866  bool result = load_cps_model_from_stream(iss, *pDataModel);
867  CPPUNIT_ASSERT(result == true);
868  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
869  std::string content = pDataModel->exportSBMLToString(NULL, 2, 4);
870  CPPUNIT_ASSERT(content.empty() == false);
871  // now we convert the content into an XMLNode and check if everything is there that needs to be there
872  XMLInputStream inputstream(content.c_str(), false);
873  XMLNode node(inputstream);
874  CPPUNIT_ASSERT(node.getName() == "sbml");
875  unsigned int i, iMax = node.getNumChildren();
876  CPPUNIT_ASSERT(iMax == 1);
877  const XMLNode* pModelNode = &node.getChild(0);
878  CPPUNIT_ASSERT(pModelNode != NULL);
879  CPPUNIT_ASSERT(pModelNode->getName() == "model");
880  iMax = pModelNode->getNumChildren();
881  CPPUNIT_ASSERT(iMax > 0);
882  // the annotation to the model should always be the first child
883  const XMLNode* pModelAnnotation = &pModelNode->getChild(0);
884  CPPUNIT_ASSERT(pModelAnnotation != NULL);
885  CPPUNIT_ASSERT(pModelAnnotation->getName() == "annotation");
886  CPPUNIT_ASSERT(pModelAnnotation->getNumChildren() == 1);
887  CPPUNIT_ASSERT(pModelAnnotation->getChild(0).getName() == "listOfLayouts");
888  // Find the compartment node
889  iMax = pModelNode->getNumChildren();
890  const XMLNode* pListOfCompartments = NULL;
891 
892  for (i = 0; i < iMax; ++i)
893  {
894  if (pModelNode->getChild(i).getName() == "listOfCompartments")
895  {
896  pListOfCompartments = &pModelNode->getChild(i);
897  break;
898  }
899  }
900 
901  CPPUNIT_ASSERT(pListOfCompartments != NULL);
902  iMax = pListOfCompartments->getNumChildren();
903  // we have only one compartment
904  CPPUNIT_ASSERT(iMax == 1);
905  const XMLNode* pCompartment = &pListOfCompartments->getChild(0);
906  CPPUNIT_ASSERT(pCompartment != NULL);
907  CPPUNIT_ASSERT(pCompartment->getName() == "compartment");
908  iMax = pCompartment->getNumChildren();
909  // there should be no annotation to the compartment
910  CPPUNIT_ASSERT(iMax == 0);
911  // try to reimport the stuff to make sure it is valid SBML
912  result = pDataModel->importSBMLFromString(content);
913  CPPUNIT_ASSERT(result == true);
914 }
915 
917 {
918  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
919  bool result = pDataModel->importSBMLFromString(test000092::MODEL_STRING7);
920  CPPUNIT_ASSERT(result == true);
921  CModel *pModel = pDataModel->getModel();
922  CPPUNIT_ASSERT(pModel != NULL);
923  // now we have to add some miriam annotation to the model
924  std::string miriamString = \
925  " <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\" xmlns:bqbiol=\"http://biomodels.net/biology-qualifiers/\" xmlns:bqmodel=\"http://biomodels.net/model-qualifiers/\">\n"
926  " <rdf:Description rdf:about=\"#COPASI1\">\n"
927  " <dc:creator rdf:parseType=\"Resource\">\n"
928  " <rdf:Bag>\n"
929  " <rdf:li rdf:parseType=\"Resource\">\n"
930  " <vCard:N rdf:parseType=\"Resource\">\n"
931  " <vCard:Family>Gauges</vCard:Family>\n"
932  " <vCard:Given>Ralph</vCard:Given>\n"
933  " </vCard:N>\n"
934  " </rdf:li>\n"
935  " </rdf:Bag>\n"
936  " </dc:creator>\n"
937  " <dcterms:created rdf:parseType=\"Resource\">\n"
938  " <dcterms:W3CDTF>2005-02-02T14:56:11Z</dcterms:W3CDTF>\n"
939  " </dcterms:created>\n"
940  " <dcterms:modified rdf:parseType=\"Resource\">\n"
941  " <dcterms:W3CDTF>2009-06-05T11:40:04Z</dcterms:W3CDTF>\n"
942  " </dcterms:modified>\n"
943  " </rdf:Description>\n"
944  " </rdf:RDF>\n";
945  const SBMLDocument* pSBMLDocument = pDataModel->getCurrentSBMLDocument();
946  CPPUNIT_ASSERT(pSBMLDocument != NULL);
947  const Model* pSBMLModel = pDataModel->getCurrentSBMLDocument()->getModel();
948  CPPUNIT_ASSERT(pSBMLModel != NULL);
949  CPPUNIT_ASSERT(pSBMLModel->isSetMetaId() == true);
950  CRDFGraphConverter::SBML2Copasi(miriamString);
951  pModel->setMiriamAnnotation(miriamString, pModel->getKey(), pSBMLModel->getMetaId());
952  // set some MIRIAM annotation on the compartment as well
953  miriamString = \
954  " <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\" xmlns:bqbiol=\"http://biomodels.net/biology-qualifiers/\" xmlns:bqmodel=\"http://biomodels.net/model-qualifiers/\">\n"
955  " <rdf:Description rdf:about=\"#COPASI2\">\n"
956  " <bqbiol:is>\n"
957  " <rdf:Bag>\n"
958  " <rdf:li rdf:resource=\"urn:miriam:obo.go:GO%3A0031594\"/>\n"
959  " </rdf:Bag>\n"
960  " </bqbiol:is>\n"
961  " </rdf:Description>\n"
962  " </rdf:RDF>\n";
963  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
964  CCompartment* pCompartment = pModel->getCompartments()[0];
965  CPPUNIT_ASSERT(pCompartment != NULL);
966  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 1);
967  const Compartment* pSBMLCompartment = pSBMLModel->getCompartment(0);
968  CPPUNIT_ASSERT(pSBMLCompartment != NULL);
969  CPPUNIT_ASSERT(pSBMLCompartment->isSetMetaId() == true);
970  CRDFGraphConverter::SBML2Copasi(miriamString);
971  pCompartment->setMiriamAnnotation(miriamString, pCompartment->getKey(), pSBMLCompartment->getMetaId());
972  //
973  std::string content = pDataModel->exportSBMLToString(NULL, 2, 4);
974  CPPUNIT_ASSERT(content.empty() == false);
975  // now we convert the content into an XMLNode and check if everything is there that needs to be there
976  XMLInputStream inputstream(content.c_str(), false);
977  XMLNode node(inputstream);
978  CPPUNIT_ASSERT(node.getName() == "sbml");
979  unsigned int i, iMax = node.getNumChildren();
980  CPPUNIT_ASSERT(iMax == 1);
981  const XMLNode* pModelNode = &node.getChild(0);
982  CPPUNIT_ASSERT(pModelNode != NULL);
983  CPPUNIT_ASSERT(pModelNode->getName() == "model");
984  iMax = pModelNode->getNumChildren();
985  CPPUNIT_ASSERT(iMax > 0);
986  // the annotation to the model should always be the first child
987  const XMLNode* pModelAnnotation = &pModelNode->getChild(0);
988  CPPUNIT_ASSERT(pModelAnnotation != NULL);
989  CPPUNIT_ASSERT(pModelAnnotation->getName() == "annotation");
990  // since the MIRIAM information is complete , we should have two children
991  // one with the libsbml MIRIAM annotation and one with the COPASI MIRIAM annotation
992  iMax = pModelAnnotation->getNumChildren();
993  CPPUNIT_ASSERT(iMax == 3);
994  const XMLNode* pMIRIAM1 = NULL, *pMIRIAM2 = NULL, *pOther = NULL;
995 
996  for (unsigned int i = 0; i < iMax; ++i)
997  {
998  if (pModelAnnotation->getChild(i).getName() == "RDF")
999  {
1000  pMIRIAM1 = &pModelAnnotation->getChild(i);
1001  }
1002  else if (pModelAnnotation->getChild(i).getName() == "COPASI")
1003  {
1004  pMIRIAM2 = &pModelAnnotation->getChild(i);
1005  }
1006  else if (pModelAnnotation->getChild(i).getName() == "SOMEANNOTATION")
1007  {
1008  pOther = &pModelAnnotation->getChild(i);
1009  }
1010  }
1011 
1012  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
1013  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
1014  CPPUNIT_ASSERT(pOther != NULL);
1015  // check if the top level element for the libsbml annotation
1016  // has all necessary namespaces
1017  const XMLNamespaces* ns = &pMIRIAM2->getNamespaces();
1018  CPPUNIT_ASSERT(ns != NULL);
1019  int index = ns->getIndex("http://www.copasi.org/static/sbml");
1020  CPPUNIT_ASSERT(index != -1);
1021  CPPUNIT_ASSERT(ns->getPrefix(index) == "");
1022  iMax = pMIRIAM2->getNumChildren();
1023  CPPUNIT_ASSERT(iMax == 1);
1024  pMIRIAM2 = &pMIRIAM2->getChild(0);
1025  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
1026  CPPUNIT_ASSERT(pMIRIAM2->getName() == "RDF");
1027  CPPUNIT_ASSERT(pMIRIAM2->getPrefix() == "rdf");
1028  ns = &pMIRIAM2->getNamespaces();
1029  CPPUNIT_ASSERT(ns != NULL);
1030  index = ns->getIndex("http://purl.org/dc/terms/");
1031  CPPUNIT_ASSERT(index != -1);
1032  CPPUNIT_ASSERT(ns->getPrefix(index) == "dcterms");
1033  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
1034  CPPUNIT_ASSERT(index != -1);
1035  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
1036  index = ns->getIndex("http://www.w3.org/2001/vcard-rdf/3.0#");
1037  CPPUNIT_ASSERT(index != -1);
1038  CPPUNIT_ASSERT(ns->getPrefix(index) == "vCard");
1039  // same checks for the libsbml MIRIAM annotation
1040  CPPUNIT_ASSERT(pMIRIAM1->getName() == "RDF");
1041  CPPUNIT_ASSERT(pMIRIAM1->getPrefix() == "rdf");
1042  ns = &pMIRIAM1->getNamespaces();
1043  CPPUNIT_ASSERT(ns != NULL);
1044  index = ns->getIndex("http://purl.org/dc/terms/");
1045  CPPUNIT_ASSERT(index != -1);
1046  CPPUNIT_ASSERT(ns->getPrefix(index) == "dcterms");
1047  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
1048  CPPUNIT_ASSERT(index != -1);
1049  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
1050  index = ns->getIndex("http://www.w3.org/2001/vcard-rdf/3.0#");
1051  CPPUNIT_ASSERT(index != -1);
1052  CPPUNIT_ASSERT(ns->getPrefix(index) == "vCard");
1053  // there are actually more namespace attributes in the libsbml annotation, but that is enough to make sure
1054  // that everything should be OK
1055  //
1056  // Right now, we don't care about the content of the annotations as long as they are there
1057  //
1058  // Find the compartment node
1059  iMax = pModelNode->getNumChildren();
1060  const XMLNode* pListOfCompartments = NULL;
1061 
1062  for (i = 0; i < iMax; ++i)
1063  {
1064  if (pModelNode->getChild(i).getName() == "listOfCompartments")
1065  {
1066  pListOfCompartments = &pModelNode->getChild(i);
1067  break;
1068  }
1069  }
1070 
1071  CPPUNIT_ASSERT(pListOfCompartments != NULL);
1072  iMax = pListOfCompartments->getNumChildren();
1073  // we have only one compartment
1074  CPPUNIT_ASSERT(iMax == 1);
1075  const XMLNode* pCompartmentNode = &pListOfCompartments->getChild(0);
1076  CPPUNIT_ASSERT(pCompartmentNode != NULL);
1077  CPPUNIT_ASSERT(pCompartmentNode->getName() == "compartment");
1078  iMax = pCompartmentNode->getNumChildren();
1079  CPPUNIT_ASSERT(iMax > 0);
1080  // the annotation to the model should always be the first child
1081  const XMLNode* pAnnotation = &pCompartmentNode->getChild(0);
1082  CPPUNIT_ASSERT(pAnnotation != NULL);
1083  CPPUNIT_ASSERT(pAnnotation->getName() == "annotation");
1084  // since the MIRIAM information is complete , we should have two children
1085  // one with the libsbml MIRIAM annotation and one with the COPASI MIRIAM annotation
1086  iMax = pAnnotation->getNumChildren();
1087  CPPUNIT_ASSERT(iMax == 3);
1088  pMIRIAM1 = NULL;
1089  pMIRIAM2 = NULL;
1090  pOther = NULL;
1091 
1092  for (unsigned int i = 0; i < iMax; ++i)
1093  {
1094  if (pAnnotation->getChild(i).getName() == "RDF")
1095  {
1096  pMIRIAM1 = &pAnnotation->getChild(i);
1097  }
1098  else if (pAnnotation->getChild(i).getName() == "COPASI")
1099  {
1100  pMIRIAM2 = &pAnnotation->getChild(i);
1101  }
1102  else if (pAnnotation->getChild(i).getName() == "SOMEANNOTATION")
1103  {
1104  pOther = &pAnnotation->getChild(i);
1105  }
1106  }
1107 
1108  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
1109  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
1110  CPPUNIT_ASSERT(pOther != NULL);
1111  // check if the top level element for the COPASI annotation
1112  // has all necessary namespaces
1113  ns = &pMIRIAM2->getNamespaces();
1114  CPPUNIT_ASSERT(ns != NULL);
1115  index = ns->getIndex("http://www.copasi.org/static/sbml");
1116  CPPUNIT_ASSERT(index != -1);
1117  CPPUNIT_ASSERT(ns->getPrefix(index) == "");
1118  iMax = pMIRIAM2->getNumChildren();
1119  CPPUNIT_ASSERT(iMax == 1);
1120  pMIRIAM2 = &pMIRIAM2->getChild(0);
1121  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
1122  CPPUNIT_ASSERT(pMIRIAM2->getName() == "RDF");
1123  CPPUNIT_ASSERT(pMIRIAM2->getPrefix() == "rdf");
1124  ns = &pMIRIAM2->getNamespaces();
1125  CPPUNIT_ASSERT(ns != NULL);
1126  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
1127  CPPUNIT_ASSERT(index != -1);
1128  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
1129  // same checks for the libsbml MIRIAM annotation
1130  CPPUNIT_ASSERT(pMIRIAM1->getName() == "RDF");
1131  CPPUNIT_ASSERT(pMIRIAM1->getPrefix() == "rdf");
1132  ns = &pMIRIAM1->getNamespaces();
1133  CPPUNIT_ASSERT(ns != NULL);
1134  index = ns->getIndex("http://purl.org/dc/terms/");
1135  CPPUNIT_ASSERT(index != -1);
1136  CPPUNIT_ASSERT(ns->getPrefix(index) == "dcterms");
1137  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
1138  CPPUNIT_ASSERT(index != -1);
1139  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
1140  index = ns->getIndex("http://www.w3.org/2001/vcard-rdf/3.0#");
1141  CPPUNIT_ASSERT(index != -1);
1142  CPPUNIT_ASSERT(ns->getPrefix(index) == "vCard");
1143  // try to reimport the stuff to make sure it is valid SBML
1144  result = pDataModel->importSBMLFromString(content);
1145  CPPUNIT_ASSERT(result == true);
1146 }
1147 
1149 {
1150  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1151  bool result = pDataModel->importSBMLFromString(test000092::MODEL_STRING8);
1152  CPPUNIT_ASSERT(result == true);
1153  CModel* pModel = pDataModel->getModel();
1154  CPPUNIT_ASSERT(pModel != NULL);
1155  // we need to modify the imported MIRIAM annotation,
1156  // e.g. the add a modified date
1157  std::string miriamString = pModel->getMiriamAnnotation();
1158  CPPUNIT_ASSERT(!miriamString.empty());
1159  CMIRIAMInfo miriamInfo;
1160  miriamInfo.load(pModel->getKey());
1161  // check the modified date
1162  const CCopasiVector<CModification>* pModifications = &miriamInfo.getModifications();
1163  CPPUNIT_ASSERT(pModifications != NULL);
1164  // there should be only one modification date
1165  CPPUNIT_ASSERT(pModifications->size() == 1);
1166  const CModification* pModification = (*pModifications)[0];
1167  CPPUNIT_ASSERT(pModification != NULL);
1168  std::string dateTime = pModification->getDate();
1169  CPPUNIT_ASSERT(dateTime == "2007-06-05T11:40:04Z");
1170  // now we add a new modification date
1171  dateTime = "2008-06-05T11:40:04Z";
1172  CModification* pNewModification = miriamInfo.createModification(dateTime);
1173  CPPUNIT_ASSERT(pNewModification != NULL);
1174  CPPUNIT_ASSERT(pNewModification->getDate() == dateTime);
1175  CPPUNIT_ASSERT(miriamInfo.save() == true);
1176 
1177  // now we do the same for the compartment
1178  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
1179  CCompartment* pCompartment = pModel->getCompartments()[0];
1180  CPPUNIT_ASSERT(pCompartment != NULL);
1181  miriamInfo.load(pCompartment->getKey());
1182  const CCopasiVector<CBiologicalDescription>* pDescriptions = &miriamInfo.getBiologicalDescriptions();
1183  CPPUNIT_ASSERT(pDescriptions != NULL);
1184  CPPUNIT_ASSERT(pDescriptions->size() == 1);
1185  CBiologicalDescription* pDescription = (*pDescriptions)[0];
1186  CPPUNIT_ASSERT(pDescription != NULL);
1187  std::string predicate = pDescription->getPredicate();
1188  CPPUNIT_ASSERT(predicate == "is version of");
1189  std::string resource = pDescription->getResource();
1190  CPPUNIT_ASSERT(resource == "Gene Ontology");
1191  std::string id = pDescription->getId();
1192  CPPUNIT_ASSERT(id == "GO:0005623");
1193  id = "GO:0001111";
1194  CBiologicalDescription* pNewDescription = miriamInfo.createBiologicalDescription();
1195  pNewDescription->setPredicate(predicate);
1196  pNewDescription->setResource(resource);
1197  pNewDescription->setId(id);
1198  CPPUNIT_ASSERT(pNewDescription != NULL);
1199  CPPUNIT_ASSERT(pNewDescription->getPredicate() == "is version of");
1200  CPPUNIT_ASSERT(pNewDescription->getResource() == "Gene Ontology");
1201  CPPUNIT_ASSERT(pNewDescription->getId() == "GO:0001111");
1202  CPPUNIT_ASSERT(miriamInfo.save() == true);
1203 
1204  std::string content = pDataModel->exportSBMLToString(NULL, 2, 4);
1205  CPPUNIT_ASSERT(content.empty() == false);
1206  // now we convert the content into an XMLNode and check if everything is there that needs to be there
1207  XMLInputStream inputstream(content.c_str(), false);
1208  XMLNode node(inputstream);
1209  CPPUNIT_ASSERT(node.getName() == "sbml");
1210  unsigned int i, iMax = node.getNumChildren();
1211  CPPUNIT_ASSERT(iMax == 1);
1212  const XMLNode* pModelNode = &node.getChild(0);
1213  CPPUNIT_ASSERT(pModelNode != NULL);
1214  CPPUNIT_ASSERT(pModelNode->getName() == "model");
1215  iMax = pModelNode->getNumChildren();
1216  CPPUNIT_ASSERT(iMax > 0);
1217  // the annotation to the model should always be the first child
1218  const XMLNode* pModelAnnotation = &pModelNode->getChild(0);
1219  CPPUNIT_ASSERT(pModelAnnotation != NULL);
1220  CPPUNIT_ASSERT(pModelAnnotation->getName() == "annotation");
1221  // since the MIRIAM information is complete , we should have three children
1222  // depending on the version of libsbml we are using
1223  iMax = pModelAnnotation->getNumChildren();
1224  CPPUNIT_ASSERT(iMax == 3);
1225  const XMLNode* pMIRIAM1 = NULL, *pMIRIAM2 = NULL, *pOther = NULL;
1226 
1227  for (unsigned int i = 0; i < iMax; ++i)
1228  {
1229  if (pModelAnnotation->getChild(i).getName() == "RDF")
1230  {
1231  pMIRIAM1 = &pModelAnnotation->getChild(i);
1232  }
1233  else if (pModelAnnotation->getChild(i).getName() == "COPASI")
1234  {
1235  pMIRIAM2 = &pModelAnnotation->getChild(i);
1236  }
1237  else if (pModelAnnotation->getChild(i).getName() == "SOMEANNOTATION")
1238  {
1239  pOther = &pModelAnnotation->getChild(i);
1240  }
1241  }
1242 
1243  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
1244  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
1245  CPPUNIT_ASSERT(pOther != NULL);
1246  // check if the top level element for the libsbml annotation
1247  // has all necessary namespaces
1248  const XMLNamespaces* ns = &pMIRIAM2->getNamespaces();
1249  CPPUNIT_ASSERT(ns != NULL);
1250  int index = ns->getIndex("http://www.copasi.org/static/sbml");
1251  CPPUNIT_ASSERT(index != -1);
1252  CPPUNIT_ASSERT(ns->getPrefix(index) == "");
1253  iMax = pMIRIAM2->getNumChildren();
1254  CPPUNIT_ASSERT(iMax == 1);
1255  pMIRIAM2 = &pMIRIAM2->getChild(0);
1256  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
1257  CPPUNIT_ASSERT(pMIRIAM2->getName() == "RDF");
1258  CPPUNIT_ASSERT(pMIRIAM2->getPrefix() == "rdf");
1259  ns = &pMIRIAM2->getNamespaces();
1260  CPPUNIT_ASSERT(ns != NULL);
1261  index = ns->getIndex("http://purl.org/dc/terms/");
1262  CPPUNIT_ASSERT(index != -1);
1263  CPPUNIT_ASSERT(ns->getPrefix(index) == "dcterms");
1264  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
1265  CPPUNIT_ASSERT(index != -1);
1266  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
1267  index = ns->getIndex("http://www.w3.org/2001/vcard-rdf/3.0#");
1268  CPPUNIT_ASSERT(index != -1);
1269  CPPUNIT_ASSERT(ns->getPrefix(index) == "vCard");
1270  // make sure the there are two modification dates
1271  CPPUNIT_ASSERT(pMIRIAM2->getNumChildren() == 1);
1272  pMIRIAM2 = &pMIRIAM2->getChild(0);
1273  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
1274  CPPUNIT_ASSERT(pMIRIAM2->getName() == "Description");
1275  iMax = pMIRIAM2->getNumChildren();
1276  CPPUNIT_ASSERT(iMax > 0);
1277 
1278  for (unsigned int i = 0; i < iMax; ++i)
1279  {
1280  if (pMIRIAM2->getChild(i).getName() == "modified")
1281  {
1282  pMIRIAM2 = &pMIRIAM2->getChild(i);
1283  }
1284  }
1285 
1286  CPPUNIT_ASSERT(pMIRIAM2->getName() == "modified");
1287  CPPUNIT_ASSERT(pMIRIAM2->getNumChildren() == 1);
1288  pMIRIAM2 = &pMIRIAM2->getChild(0);
1289  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
1290  CPPUNIT_ASSERT(pMIRIAM2->getName() == "Bag");
1291  CPPUNIT_ASSERT(pMIRIAM2->getNumChildren() == 2);
1292 
1293  // same checks for the libsbml MIRIAM annotation
1294  CPPUNIT_ASSERT(pMIRIAM1->getName() == "RDF");
1295  CPPUNIT_ASSERT(pMIRIAM1->getPrefix() == "rdf");
1296  ns = &pMIRIAM1->getNamespaces();
1297  CPPUNIT_ASSERT(ns != NULL);
1298  index = ns->getIndex("http://purl.org/dc/terms/");
1299  CPPUNIT_ASSERT(index != -1);
1300  CPPUNIT_ASSERT(ns->getPrefix(index) == "dcterms");
1301  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
1302  CPPUNIT_ASSERT(index != -1);
1303  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
1304  index = ns->getIndex("http://www.w3.org/2001/vcard-rdf/3.0#");
1305  CPPUNIT_ASSERT(index != -1);
1306  CPPUNIT_ASSERT(ns->getPrefix(index) == "vCard");
1307 
1308  // there are actually more namespace attributes in the libsbml annotation, but that is enough to make sure
1309  // that everything should be OK
1310  CPPUNIT_ASSERT(pMIRIAM1->getNumChildren() == 1);
1311  pMIRIAM1 = &pMIRIAM1->getChild(0);
1312  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
1313  CPPUNIT_ASSERT(pMIRIAM1->getName() == "Description");
1314  iMax = pMIRIAM1->getNumChildren();
1315  CPPUNIT_ASSERT(iMax > 0);
1316 
1317  for (unsigned int i = 0; i < iMax; ++i)
1318  {
1319  if (pMIRIAM1->getChild(i).getName() == "modified")
1320  {
1321  pMIRIAM1 = &pMIRIAM1->getChild(i);
1322  }
1323  }
1324 
1325  CPPUNIT_ASSERT(pMIRIAM1->getName() == "modified");
1326  CPPUNIT_ASSERT(pMIRIAM1->getNumChildren() == 1);
1327  pMIRIAM1 = &pMIRIAM1->getChild(0);
1328  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
1329  CPPUNIT_ASSERT(pMIRIAM1->getName() == "W3CDTF");
1330  CPPUNIT_ASSERT(pMIRIAM1->getNumChildren() == 1);
1331  pMIRIAM1 = &pMIRIAM1->getChild(0);
1332  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
1333  CPPUNIT_ASSERT(pMIRIAM1->getCharacters() == "2008-06-05T11:40:04Z");
1334 
1335  //
1336  // Find the compartment node
1337  iMax = pModelNode->getNumChildren();
1338  const XMLNode* pListOfCompartments = NULL;
1339 
1340  for (i = 0; i < iMax; ++i)
1341  {
1342  if (pModelNode->getChild(i).getName() == "listOfCompartments")
1343  {
1344  pListOfCompartments = &pModelNode->getChild(i);
1345  break;
1346  }
1347  }
1348 
1349  CPPUNIT_ASSERT(pListOfCompartments != NULL);
1350  iMax = pListOfCompartments->getNumChildren();
1351  // we have only one compartment
1352  CPPUNIT_ASSERT(iMax == 1);
1353  const XMLNode* pCompartmentNode = &pListOfCompartments->getChild(0);
1354  CPPUNIT_ASSERT(pCompartmentNode != NULL);
1355  CPPUNIT_ASSERT(pCompartmentNode->getName() == "compartment");
1356  iMax = pCompartmentNode->getNumChildren();
1357  CPPUNIT_ASSERT(iMax > 0);
1358  // the annotation to the model should always be the first child
1359  const XMLNode* pAnnotation = &pCompartmentNode->getChild(0);
1360  CPPUNIT_ASSERT(pAnnotation != NULL);
1361  CPPUNIT_ASSERT(pAnnotation->getName() == "annotation");
1362  // since the MIRIAM information is complete , we should have two children
1363  // one with the libsbml MIRIAM annotation and one with the COPASI MIRIAM annotation
1364  iMax = pAnnotation->getNumChildren();
1365  CPPUNIT_ASSERT(iMax == 3);
1366  pMIRIAM1 = NULL;
1367  pMIRIAM2 = NULL;
1368  pOther = NULL;
1369 
1370  // make sure the libsbml annotation is stored in pMIRIAM1
1371  for (unsigned int i = 0; i < iMax; ++i)
1372  {
1373  if (pAnnotation->getChild(i).getName() == "RDF")
1374  {
1375  pMIRIAM1 = &pAnnotation->getChild(i);
1376  }
1377  else if (pAnnotation->getChild(i).getName() == "COPASI")
1378  {
1379  pMIRIAM2 = &pAnnotation->getChild(i);
1380  }
1381  else if (pAnnotation->getChild(i).getName() == "SOMEANNOTATION")
1382  {
1383  pOther = &pAnnotation->getChild(i);
1384  }
1385  }
1386 
1387  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
1388  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
1389  CPPUNIT_ASSERT(pOther != NULL);
1390  // check if the top level element for the COPASI annotation
1391  // has all necessary namespaces
1392  ns = &pMIRIAM2->getNamespaces();
1393  CPPUNIT_ASSERT(ns != NULL);
1394  index = ns->getIndex("http://www.copasi.org/static/sbml");
1395  CPPUNIT_ASSERT(index != -1);
1396  CPPUNIT_ASSERT(ns->getPrefix(index) == "");
1397  iMax = pMIRIAM2->getNumChildren();
1398  CPPUNIT_ASSERT(iMax == 1);
1399  pMIRIAM2 = &pMIRIAM2->getChild(0);
1400  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
1401  CPPUNIT_ASSERT(pMIRIAM2->getName() == "RDF");
1402  CPPUNIT_ASSERT(pMIRIAM2->getPrefix() == "rdf");
1403  ns = &pMIRIAM2->getNamespaces();
1404  CPPUNIT_ASSERT(ns != NULL);
1405  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
1406  CPPUNIT_ASSERT(index != -1);
1407  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
1408  // check if there are two biological descriptions
1409  CPPUNIT_ASSERT(pMIRIAM2->getNumChildren() == 1);
1410  pMIRIAM2 = &pMIRIAM2->getChild(0);
1411  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
1412  CPPUNIT_ASSERT(pMIRIAM2->getName() == "Description");
1413  CPPUNIT_ASSERT(pMIRIAM2->getNumChildren() == 1);
1414  pMIRIAM2 = &pMIRIAM2->getChild(0);
1415  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
1416  CPPUNIT_ASSERT(pMIRIAM2->getName() == "isVersionOf");
1417  CPPUNIT_ASSERT(pMIRIAM2->getNumChildren() == 1);
1418  pMIRIAM2 = &pMIRIAM2->getChild(0);
1419  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
1420  CPPUNIT_ASSERT(pMIRIAM2->getName() == "Bag");
1421  CPPUNIT_ASSERT(pMIRIAM2->getNumChildren() == 2);
1422  CPPUNIT_ASSERT(pMIRIAM2->getChild(0).getName() == "li");
1423  CPPUNIT_ASSERT(pMIRIAM2->getChild(1).getName() == "li");
1424 
1425  // same checks for the libsbml MIRIAM annotation
1426  CPPUNIT_ASSERT(pMIRIAM1->getName() == "RDF");
1427  CPPUNIT_ASSERT(pMIRIAM1->getPrefix() == "rdf");
1428  ns = &pMIRIAM1->getNamespaces();
1429  CPPUNIT_ASSERT(ns != NULL);
1430  index = ns->getIndex("http://purl.org/dc/terms/");
1431  CPPUNIT_ASSERT(index != -1);
1432  CPPUNIT_ASSERT(ns->getPrefix(index) == "dcterms");
1433  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
1434  CPPUNIT_ASSERT(index != -1);
1435  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
1436  index = ns->getIndex("http://www.w3.org/2001/vcard-rdf/3.0#");
1437  CPPUNIT_ASSERT(index != -1);
1438  CPPUNIT_ASSERT(ns->getPrefix(index) == "vCard");
1439  // check if there are two biological descriptions
1440  CPPUNIT_ASSERT(pMIRIAM1->getNumChildren() == 1);
1441  pMIRIAM1 = &pMIRIAM1->getChild(0);
1442  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
1443  CPPUNIT_ASSERT(pMIRIAM1->getName() == "Description");
1444  CPPUNIT_ASSERT(pMIRIAM1->getNumChildren() == 1);
1445  pMIRIAM1 = &pMIRIAM1->getChild(0);
1446  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
1447  CPPUNIT_ASSERT(pMIRIAM1->getName() == "isVersionOf");
1448  CPPUNIT_ASSERT(pMIRIAM1->getNumChildren() == 1);
1449  pMIRIAM1 = &pMIRIAM1->getChild(0);
1450  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
1451  CPPUNIT_ASSERT(pMIRIAM1->getName() == "Bag");
1452  CPPUNIT_ASSERT(pMIRIAM1->getNumChildren() == 2);
1453  CPPUNIT_ASSERT(pMIRIAM1->getChild(0).getName() == "li");
1454  CPPUNIT_ASSERT(pMIRIAM1->getChild(1).getName() == "li");
1455  // try to reimport the stuff to make sure it is valid SBML
1456  result = pDataModel->importSBMLFromString(content);
1457  CPPUNIT_ASSERT(result == true);
1458 }
1459 
1460 
1462 {
1463  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1464  bool result = pDataModel->importSBMLFromString(test000092::MODEL_STRING9);
1465  CPPUNIT_ASSERT(result == true);
1466  CModel* pModel = pDataModel->getModel();
1467  CPPUNIT_ASSERT(pModel != NULL);
1468  // we need to modify the imported MIRIAM annotation,
1469  // e.g. the add a modified date
1470  std::string miriamString = pModel->getMiriamAnnotation();
1471  CPPUNIT_ASSERT(!miriamString.empty());
1472  CMIRIAMInfo miriamInfo;
1473  miriamInfo.load(pModel->getKey());
1474  // check the modified date
1475  const CCopasiVector<CModification>* pModifications = &miriamInfo.getModifications();
1476  CPPUNIT_ASSERT(pModifications != NULL);
1477  // there should be only one modification date
1478  CPPUNIT_ASSERT(pModifications->size() == 1);
1479  const CModification* pModification = (*pModifications)[0];
1480  CPPUNIT_ASSERT(pModification != NULL);
1481  std::string dateTime = pModification->getDate();
1482  CPPUNIT_ASSERT(dateTime == "2007-06-05T11:40:04Z");
1483  // now we add a new modification date
1484  dateTime = "2008-06-05T11:40:04Z";
1485  CModification* pNewModification = miriamInfo.createModification(dateTime);
1486  CPPUNIT_ASSERT(pNewModification != NULL);
1487  CPPUNIT_ASSERT(pNewModification->getDate() == dateTime);
1488  CPPUNIT_ASSERT(miriamInfo.save() == true);
1489 
1490  // now we do the same for the compartment
1491  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
1492  CCompartment* pCompartment = pModel->getCompartments()[0];
1493  CPPUNIT_ASSERT(pCompartment != NULL);
1494  miriamInfo.load(pCompartment->getKey());
1495  const CCopasiVector<CBiologicalDescription>* pDescriptions = &miriamInfo.getBiologicalDescriptions();
1496  CPPUNIT_ASSERT(pDescriptions != NULL);
1497  CPPUNIT_ASSERT(pDescriptions->size() == 1);
1498  CBiologicalDescription* pDescription = (*pDescriptions)[0];
1499  CPPUNIT_ASSERT(pDescription != NULL);
1500  std::string predicate = pDescription->getPredicate();
1501  CPPUNIT_ASSERT(predicate == "is version of");
1502  std::string resource = pDescription->getResource();
1503  CPPUNIT_ASSERT(resource == "Gene Ontology");
1504  std::string id = pDescription->getId();
1505  CPPUNIT_ASSERT(id == "GO:0005623");
1506  id = "GO:0001111";
1507  CBiologicalDescription* pNewDescription = miriamInfo.createBiologicalDescription();
1508  pNewDescription->setPredicate(predicate);
1509  pNewDescription->setResource(resource);
1510  pNewDescription->setId(id);
1511  CPPUNIT_ASSERT(pNewDescription != NULL);
1512  CPPUNIT_ASSERT(pNewDescription->getPredicate() == "is version of");
1513  CPPUNIT_ASSERT(pNewDescription->getResource() == "Gene Ontology");
1514  CPPUNIT_ASSERT(pNewDescription->getId() == "GO:0001111");
1515  CPPUNIT_ASSERT(miriamInfo.save() == true);
1516 
1517  std::string content = pDataModel->exportSBMLToString(NULL, 2, 4);
1518  CPPUNIT_ASSERT(content.empty() == false);
1519  // now we convert the content into an XMLNode and check if everything is there that needs to be there
1520  XMLInputStream inputstream(content.c_str(), false);
1521  XMLNode node(inputstream);
1522  CPPUNIT_ASSERT(node.getName() == "sbml");
1523  unsigned int i, iMax = node.getNumChildren();
1524  CPPUNIT_ASSERT(iMax == 1);
1525  const XMLNode* pModelNode = &node.getChild(0);
1526  CPPUNIT_ASSERT(pModelNode != NULL);
1527  CPPUNIT_ASSERT(pModelNode->getName() == "model");
1528  iMax = pModelNode->getNumChildren();
1529  CPPUNIT_ASSERT(iMax > 0);
1530  // the annotation to the model should always be the first child
1531  const XMLNode* pModelAnnotation = &pModelNode->getChild(0);
1532  CPPUNIT_ASSERT(pModelAnnotation != NULL);
1533  CPPUNIT_ASSERT(pModelAnnotation->getName() == "annotation");
1534  // since the MIRIAM information is complete , we should have three children
1535  // depending on the version of libsbml we are using
1536  iMax = pModelAnnotation->getNumChildren();
1537  CPPUNIT_ASSERT(iMax == 3);
1538  const XMLNode* pMIRIAM1 = NULL, *pMIRIAM2 = NULL, *pOther = NULL;
1539 
1540  for (unsigned int i = 0; i < iMax; ++i)
1541  {
1542  if (pModelAnnotation->getChild(i).getName() == "RDF")
1543  {
1544  pMIRIAM1 = &pModelAnnotation->getChild(i);
1545  }
1546  else if (pModelAnnotation->getChild(i).getName() == "COPASI")
1547  {
1548  pMIRIAM2 = &pModelAnnotation->getChild(i);
1549  }
1550  else if (pModelAnnotation->getChild(i).getName() == "SOMEANNOTATION")
1551  {
1552  pOther = &pModelAnnotation->getChild(i);
1553  }
1554  }
1555 
1556  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
1557  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
1558  CPPUNIT_ASSERT(pOther != NULL);
1559  // check if the top level element for the libsbml annotation
1560  // has all necessary namespaces
1561  const XMLNamespaces* ns = &pMIRIAM2->getNamespaces();
1562  CPPUNIT_ASSERT(ns != NULL);
1563  int index = ns->getIndex("http://www.copasi.org/static/sbml");
1564  CPPUNIT_ASSERT(index != -1);
1565  CPPUNIT_ASSERT(ns->getPrefix(index) == "");
1566  iMax = pMIRIAM2->getNumChildren();
1567  CPPUNIT_ASSERT(iMax == 1);
1568  pMIRIAM2 = &pMIRIAM2->getChild(0);
1569  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
1570  CPPUNIT_ASSERT(pMIRIAM2->getName() == "RDF");
1571  CPPUNIT_ASSERT(pMIRIAM2->getPrefix() == "rdf");
1572  ns = &pMIRIAM2->getNamespaces();
1573  CPPUNIT_ASSERT(ns != NULL);
1574  index = ns->getIndex("http://purl.org/dc/terms/");
1575  CPPUNIT_ASSERT(index != -1);
1576  CPPUNIT_ASSERT(ns->getPrefix(index) == "dcterms");
1577  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
1578  CPPUNIT_ASSERT(index != -1);
1579  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
1580  index = ns->getIndex("http://www.w3.org/2001/vcard-rdf/3.0#");
1581  CPPUNIT_ASSERT(index != -1);
1582  CPPUNIT_ASSERT(ns->getPrefix(index) == "vCard");
1583  // make sure the there are two modification dates
1584  CPPUNIT_ASSERT(pMIRIAM2->getNumChildren() == 1);
1585  pMIRIAM2 = &pMIRIAM2->getChild(0);
1586  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
1587  CPPUNIT_ASSERT(pMIRIAM2->getName() == "Description");
1588  iMax = pMIRIAM2->getNumChildren();
1589  CPPUNIT_ASSERT(iMax > 0);
1590 
1591  for (unsigned int i = 0; i < iMax; ++i)
1592  {
1593  if (pMIRIAM2->getChild(i).getName() == "modified")
1594  {
1595  pMIRIAM2 = &pMIRIAM2->getChild(i);
1596  }
1597  }
1598 
1599  CPPUNIT_ASSERT(pMIRIAM2->getName() == "modified");
1600  CPPUNIT_ASSERT(pMIRIAM2->getNumChildren() == 1);
1601  pMIRIAM2 = &pMIRIAM2->getChild(0);
1602  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
1603  CPPUNIT_ASSERT(pMIRIAM2->getName() == "Bag");
1604  CPPUNIT_ASSERT(pMIRIAM2->getNumChildren() == 2);
1605 
1606  // same checks for the libsbml MIRIAM annotation
1607  CPPUNIT_ASSERT(pMIRIAM1->getName() == "RDF");
1608  CPPUNIT_ASSERT(pMIRIAM1->getPrefix() == "rdf");
1609  ns = &pMIRIAM1->getNamespaces();
1610  CPPUNIT_ASSERT(ns != NULL);
1611  index = ns->getIndex("http://purl.org/dc/terms/");
1612  CPPUNIT_ASSERT(index != -1);
1613  CPPUNIT_ASSERT(ns->getPrefix(index) == "dcterms");
1614  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
1615  CPPUNIT_ASSERT(index != -1);
1616  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
1617  index = ns->getIndex("http://www.w3.org/2001/vcard-rdf/3.0#");
1618  CPPUNIT_ASSERT(index != -1);
1619  CPPUNIT_ASSERT(ns->getPrefix(index) == "vCard");
1620 
1621  // there are actually more namespace attributes in the libsbml annotation, but that is enough to make sure
1622  // that everything should be OK
1623  CPPUNIT_ASSERT(pMIRIAM1->getNumChildren() == 1);
1624  pMIRIAM1 = &pMIRIAM1->getChild(0);
1625  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
1626  CPPUNIT_ASSERT(pMIRIAM1->getName() == "Description");
1627  iMax = pMIRIAM1->getNumChildren();
1628  CPPUNIT_ASSERT(iMax > 0);
1629 
1630  for (unsigned int i = 0; i < iMax; ++i)
1631  {
1632  if (pMIRIAM1->getChild(i).getName() == "modified")
1633  {
1634  pMIRIAM1 = &pMIRIAM1->getChild(i);
1635  }
1636  }
1637 
1638  CPPUNIT_ASSERT(pMIRIAM1->getName() == "modified");
1639  CPPUNIT_ASSERT(pMIRIAM1->getNumChildren() == 1);
1640  pMIRIAM1 = &pMIRIAM1->getChild(0);
1641  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
1642  CPPUNIT_ASSERT(pMIRIAM1->getName() == "W3CDTF");
1643  CPPUNIT_ASSERT(pMIRIAM1->getNumChildren() == 1);
1644  pMIRIAM1 = &pMIRIAM1->getChild(0);
1645  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
1646  CPPUNIT_ASSERT(pMIRIAM1->getCharacters() == "2008-06-05T11:40:04Z");
1647  //
1648  // Find the compartment node
1649  iMax = pModelNode->getNumChildren();
1650  const XMLNode* pListOfCompartments = NULL;
1651 
1652  for (i = 0; i < iMax; ++i)
1653  {
1654  if (pModelNode->getChild(i).getName() == "listOfCompartments")
1655  {
1656  pListOfCompartments = &pModelNode->getChild(i);
1657  break;
1658  }
1659  }
1660 
1661  CPPUNIT_ASSERT(pListOfCompartments != NULL);
1662  iMax = pListOfCompartments->getNumChildren();
1663  // we have only one compartment
1664  CPPUNIT_ASSERT(iMax == 1);
1665  const XMLNode* pCompartmentNode = &pListOfCompartments->getChild(0);
1666  CPPUNIT_ASSERT(pCompartmentNode != NULL);
1667  CPPUNIT_ASSERT(pCompartmentNode->getName() == "compartment");
1668  iMax = pCompartmentNode->getNumChildren();
1669  CPPUNIT_ASSERT(iMax > 0);
1670  // the annotation to the model should always be the first child
1671  const XMLNode* pAnnotation = &pCompartmentNode->getChild(0);
1672  CPPUNIT_ASSERT(pAnnotation != NULL);
1673  CPPUNIT_ASSERT(pAnnotation->getName() == "annotation");
1674  // since the MIRIAM information is complete , we should have two children
1675  // one with the libsbml MIRIAM annotation and one with the COPASI MIRIAM annotation
1676  iMax = pAnnotation->getNumChildren();
1677  CPPUNIT_ASSERT(iMax == 3);
1678  pMIRIAM1 = NULL;
1679  pMIRIAM2 = NULL;
1680  pOther = NULL;
1681 
1682  // make sure the libsbml annotation is stored in pMIRIAM1
1683  for (unsigned int i = 0; i < iMax; ++i)
1684  {
1685  if (pAnnotation->getChild(i).getName() == "RDF")
1686  {
1687  pMIRIAM1 = &pAnnotation->getChild(i);
1688  }
1689  else if (pAnnotation->getChild(i).getName() == "COPASI")
1690  {
1691  pMIRIAM2 = &pAnnotation->getChild(i);
1692  }
1693  else if (pAnnotation->getChild(i).getName() == "SOMEANNOTATION")
1694  {
1695  pOther = &pAnnotation->getChild(i);
1696  }
1697  }
1698 
1699  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
1700  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
1701  CPPUNIT_ASSERT(pOther != NULL);
1702  // check if the top level element for the COPASI annotation
1703  // has all necessary namespaces
1704  ns = &pMIRIAM2->getNamespaces();
1705  CPPUNIT_ASSERT(ns != NULL);
1706  index = ns->getIndex("http://www.copasi.org/static/sbml");
1707  CPPUNIT_ASSERT(index != -1);
1708  CPPUNIT_ASSERT(ns->getPrefix(index) == "");
1709  iMax = pMIRIAM2->getNumChildren();
1710  CPPUNIT_ASSERT(iMax == 1);
1711  pMIRIAM2 = &pMIRIAM2->getChild(0);
1712  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
1713  CPPUNIT_ASSERT(pMIRIAM2->getName() == "RDF");
1714  CPPUNIT_ASSERT(pMIRIAM2->getPrefix() == "rdf");
1715  ns = &pMIRIAM2->getNamespaces();
1716  CPPUNIT_ASSERT(ns != NULL);
1717  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
1718  CPPUNIT_ASSERT(index != -1);
1719  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
1720  // check if there are two biological descriptions
1721  CPPUNIT_ASSERT(pMIRIAM2->getNumChildren() == 1);
1722  pMIRIAM2 = &pMIRIAM2->getChild(0);
1723  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
1724  CPPUNIT_ASSERT(pMIRIAM2->getName() == "Description");
1725  CPPUNIT_ASSERT(pMIRIAM2->getNumChildren() == 1);
1726  pMIRIAM2 = &pMIRIAM2->getChild(0);
1727  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
1728  CPPUNIT_ASSERT(pMIRIAM2->getName() == "isVersionOf");
1729  CPPUNIT_ASSERT(pMIRIAM2->getNumChildren() == 1);
1730  pMIRIAM2 = &pMIRIAM2->getChild(0);
1731  CPPUNIT_ASSERT(pMIRIAM2 != NULL);
1732  CPPUNIT_ASSERT(pMIRIAM2->getName() == "Bag");
1733  CPPUNIT_ASSERT(pMIRIAM2->getNumChildren() == 2);
1734  CPPUNIT_ASSERT(pMIRIAM2->getChild(0).getName() == "li");
1735  CPPUNIT_ASSERT(pMIRIAM2->getChild(1).getName() == "li");
1736 
1737  // same checks for the libsbml MIRIAM annotation
1738  CPPUNIT_ASSERT(pMIRIAM1->getName() == "RDF");
1739  CPPUNIT_ASSERT(pMIRIAM1->getPrefix() == "rdf");
1740  ns = &pMIRIAM1->getNamespaces();
1741  CPPUNIT_ASSERT(ns != NULL);
1742  index = ns->getIndex("http://purl.org/dc/terms/");
1743  CPPUNIT_ASSERT(index != -1);
1744  CPPUNIT_ASSERT(ns->getPrefix(index) == "dcterms");
1745  index = ns->getIndex("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
1746  CPPUNIT_ASSERT(index != -1);
1747  CPPUNIT_ASSERT(ns->getPrefix(index) == "rdf");
1748  index = ns->getIndex("http://www.w3.org/2001/vcard-rdf/3.0#");
1749  CPPUNIT_ASSERT(index != -1);
1750  CPPUNIT_ASSERT(ns->getPrefix(index) == "vCard");
1751  // check if there are two biological descriptions
1752  CPPUNIT_ASSERT(pMIRIAM1->getNumChildren() == 1);
1753  pMIRIAM1 = &pMIRIAM1->getChild(0);
1754  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
1755  CPPUNIT_ASSERT(pMIRIAM1->getName() == "Description");
1756  CPPUNIT_ASSERT(pMIRIAM1->getNumChildren() == 1);
1757  pMIRIAM1 = &pMIRIAM1->getChild(0);
1758  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
1759  CPPUNIT_ASSERT(pMIRIAM1->getName() == "isVersionOf");
1760  CPPUNIT_ASSERT(pMIRIAM1->getNumChildren() == 1);
1761  pMIRIAM1 = &pMIRIAM1->getChild(0);
1762  CPPUNIT_ASSERT(pMIRIAM1 != NULL);
1763  CPPUNIT_ASSERT(pMIRIAM1->getName() == "Bag");
1764  CPPUNIT_ASSERT(pMIRIAM1->getNumChildren() == 2);
1765  CPPUNIT_ASSERT(pMIRIAM1->getChild(0).getName() == "li");
1766  CPPUNIT_ASSERT(pMIRIAM1->getChild(1).getName() == "li");
1767  // try to reimport the stuff to make sure it is valid SBML
1768  result = pDataModel->importSBMLFromString(content);
1769  CPPUNIT_ASSERT(result == true);
1770 }
1771 
1772 
1773 /**
1774  * This test will most likely fail until we have a workaround for the SBML one modification limit.
1775  */
1777 {
1778  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1779  bool result = pDataModel->importSBMLFromString(test000092::MODEL_STRING10);
1780  CPPUNIT_ASSERT(result == true);
1781  CModel* pModel = pDataModel->getModel();
1782  CPPUNIT_ASSERT(pModel != NULL);
1783  // we need to modify the imported MIRIAM annotation,
1784  // e.g. the add a modified date
1785  std::string miriamString = pModel->getMiriamAnnotation();
1786  CPPUNIT_ASSERT(!miriamString.empty());
1787  CMIRIAMInfo miriamInfo;
1788  miriamInfo.load(pModel->getKey());
1789  // check the modified date
1790  const CCopasiVector<CModification>* pModifications = &miriamInfo.getModifications();
1791  CPPUNIT_ASSERT(pModifications != NULL);
1792  // there should be only one modification date
1793  CPPUNIT_ASSERT_MESSAGE("This test will fail until we have a workaround for the one modification date limit in SBML.", pModifications->size() == 2);
1794  const CModification* pModification = (*pModifications)[0];
1795  CPPUNIT_ASSERT(pModification != NULL);
1796  std::string dateTime = pModification->getDate();
1797  CPPUNIT_ASSERT(dateTime == "2007-06-05T11:40:04Z" || dateTime == "2008-06-05T11:40:04Z");
1798  const CModification* pModification2 = (*pModifications)[1];
1799  CPPUNIT_ASSERT(pModification2 != NULL);
1800  std::string dateTime2 = pModification2->getDate();
1801  CPPUNIT_ASSERT(dateTime2 == "2007-06-05T11:40:04Z" || dateTime2 == "2008-06-05T11:40:04Z");
1802  // make sure both dates are not the same
1803  CPPUNIT_ASSERT(dateTime != dateTime2);
1804 }
1805 
1806 
1807 
1808 
1809 /**
1810  * This model has complete MIRIAM compliant annotation, so of of it should be exported
1811  * by libsbml and in addition to that as annotation in the COPASI namespace.
1812  */
1813 const char* test000092::MODEL_STRING1 = \
1814  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
1815  "<!-- generated with COPASI 4.5.31 (Debug) (http://www.copasi.org) at 2010-04-21 14:00:12 UTC -->\n"
1816  "<?oxygen RNGSchema=\"http://www.copasi.org/static/schema/CopasiML.rng\" type=\"xml\"?>\n"
1817  "<COPASI xmlns=\"http://www.copasi.org/static/schema\" versionMajor=\"1\" versionMinor=\"0\" versionDevel=\"31\">\n"
1818  " <Model key=\"Model_0\" name=\"New Model\" simulationType=\"time\" timeUnit=\"s\" volumeUnit=\"ml\" areaUnit=\"m²\" lengthUnit=\"m\" quantityUnit=\"mmol\" type=\"deterministic\">\n"
1819  " <MiriamAnnotation>\n"
1820  "<rdf:RDF\n"
1821  " xmlns:dcterms=\"http://purl.org/dc/terms/\"\n"
1822  " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n"
1823  " xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\">\n"
1824  " <rdf:Description rdf:about=\"#Model_0\">\n"
1825  " <dcterms:created>\n"
1826  " <rdf:Description>\n"
1827  " <dcterms:W3CDTF>2010-04-21T15:55:08Z</dcterms:W3CDTF>\n"
1828  " </rdf:Description>\n"
1829  " </dcterms:created>\n"
1830  " <dcterms:creator>\n"
1831  " <rdf:Description>\n"
1832  " <vCard:N>\n"
1833  " <rdf:Description>\n"
1834  " <vCard:Family>Gauges</vCard:Family>\n"
1835  " <vCard:Given>Ralph</vCard:Given>\n"
1836  " </rdf:Description>\n"
1837  " </vCard:N>\n"
1838  " </rdf:Description>\n"
1839  " </dcterms:creator>\n"
1840  " <dcterms:modified>\n"
1841  " <rdf:Description>\n"
1842  " <dcterms:W3CDTF>2010-04-21T15:59:47</dcterms:W3CDTF>\n"
1843  " </rdf:Description>\n"
1844  " </dcterms:modified>\n"
1845  " </rdf:Description>\n"
1846  "</rdf:RDF>\n"
1847  "\n"
1848  " </MiriamAnnotation>\n"
1849  " <ListOfCompartments>\n"
1850  " <Compartment key=\"Compartment_0\" name=\"Compartment\" simulationType=\"fixed\" dimensionality=\"3\">\n"
1851  " <MiriamAnnotation>\n"
1852  "<rdf:RDF\n"
1853  " xmlns:CopasiMT=\"http://www.copasi.org/RDF/MiriamTerms#\"\n"
1854  " xmlns:dcterms=\"http://purl.org/dc/terms/\"\n"
1855  " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n"
1856  " xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\">\n"
1857  " <rdf:Description rdf:about=\"#Compartment_0\">\n"
1858  " <dcterms:created>\n"
1859  " <rdf:Description>\n"
1860  " <dcterms:W3CDTF>2010-04-21T15:55:31Z</dcterms:W3CDTF>\n"
1861  " </rdf:Description>\n"
1862  " </dcterms:created>\n"
1863  " <dcterms:creator>\n"
1864  " <rdf:Description>\n"
1865  " <vCard:N>\n"
1866  " <rdf:Description>\n"
1867  " <vCard:Family>Gauges</vCard:Family>\n"
1868  " <vCard:Given>Ralph</vCard:Given>\n"
1869  " </rdf:Description>\n"
1870  " </vCard:N>\n"
1871  " </rdf:Description>\n"
1872  " </dcterms:creator>\n"
1873  " <CopasiMT:isVersionOf rdf:resource=\"urn:miriam:obo.go:GO:0005623\"/>\n"
1874  " </rdf:Description>\n"
1875  "</rdf:RDF>\n"
1876  "\n"
1877  " </MiriamAnnotation>\n"
1878  " </Compartment>\n"
1879  " </ListOfCompartments>\n"
1880  " <StateTemplate>\n"
1881  " <StateTemplateVariable objectReference=\"Model_0\"/>\n"
1882  " <StateTemplateVariable objectReference=\"Compartment_0\"/>\n"
1883  " </StateTemplate>\n"
1884  " <InitialState type=\"initialState\">\n"
1885  " 0 1 \n"
1886  " </InitialState>\n"
1887  " </Model>\n"
1888  "</COPASI>\n";
1889 
1890 
1891 /**
1892  * In this model the Model history is incomplete because there is no creator
1893  * and no modified date so libsbml 4 will no longer write the model history. Nevertheless
1894  * the annotation should be written in the COPASI namespace.
1895  */
1896 const char* test000092::MODEL_STRING2 = \
1897  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
1898  "<!-- generated with COPASI 4.5.31 (Debug) (http://www.copasi.org) at 2010-04-21 14:00:12 UTC -->\n"
1899  "<?oxygen RNGSchema=\"http://www.copasi.org/static/schema/CopasiML.rng\" type=\"xml\"?>\n"
1900  "<COPASI xmlns=\"http://www.copasi.org/static/schema\" versionMajor=\"1\" versionMinor=\"0\" versionDevel=\"31\">\n"
1901  " <Model key=\"Model_0\" name=\"New Model\" simulationType=\"time\" timeUnit=\"s\" volumeUnit=\"ml\" areaUnit=\"m²\" lengthUnit=\"m\" quantityUnit=\"mmol\" type=\"deterministic\">\n"
1902  " <MiriamAnnotation>\n"
1903  "<rdf:RDF\n"
1904  " xmlns:dcterms=\"http://purl.org/dc/terms/\"\n"
1905  " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n"
1906  " xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\">\n"
1907  " <rdf:Description rdf:about=\"#Model_0\">\n"
1908  " <dcterms:created>\n"
1909  " <rdf:Description>\n"
1910  " <dcterms:W3CDTF>2010-04-21T15:55:08Z</dcterms:W3CDTF>\n"
1911  " </rdf:Description>\n"
1912  " </dcterms:created>\n"
1913  " </rdf:Description>\n"
1914  "</rdf:RDF>\n"
1915  "\n"
1916  " </MiriamAnnotation>\n"
1917  " <ListOfCompartments>\n"
1918  " <Compartment key=\"Compartment_0\" name=\"Compartment\" simulationType=\"fixed\" dimensionality=\"3\">\n"
1919  " <MiriamAnnotation>\n"
1920  "<rdf:RDF\n"
1921  " xmlns:CopasiMT=\"http://www.copasi.org/RDF/MiriamTerms#\"\n"
1922  " xmlns:dcterms=\"http://purl.org/dc/terms/\"\n"
1923  " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n"
1924  " xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\">\n"
1925  " <rdf:Description rdf:about=\"#Compartment_0\">\n"
1926  " <dcterms:created>\n"
1927  " <rdf:Description>\n"
1928  " <dcterms:W3CDTF>2010-04-21T15:55:31Z</dcterms:W3CDTF>\n"
1929  " </rdf:Description>\n"
1930  " </dcterms:created>\n"
1931  " <dcterms:creator>\n"
1932  " <rdf:Description>\n"
1933  " <vCard:N>\n"
1934  " <rdf:Description>\n"
1935  " <vCard:Family>Gauges</vCard:Family>\n"
1936  " <vCard:Given>Ralph</vCard:Given>\n"
1937  " </rdf:Description>\n"
1938  " </vCard:N>\n"
1939  " </rdf:Description>\n"
1940  " </dcterms:creator>\n"
1941  " <CopasiMT:isVersionOf rdf:resource=\"urn:miriam:obo.go:GO:0005623\"/>\n"
1942  " </rdf:Description>\n"
1943  "</rdf:RDF>\n"
1944  "\n"
1945  " </MiriamAnnotation>\n"
1946  " </Compartment>\n"
1947  " </ListOfCompartments>\n"
1948  " <StateTemplate>\n"
1949  " <StateTemplateVariable objectReference=\"Model_0\"/>\n"
1950  " <StateTemplateVariable objectReference=\"Compartment_0\"/>\n"
1951  " </StateTemplate>\n"
1952  " <InitialState type=\"initialState\">\n"
1953  " 0 1 \n"
1954  " </InitialState>\n"
1955  " </Model>\n"
1956  "</COPASI>\n";
1957 
1958 
1959 /**
1960  * In this model the Model there is no MIRIAM annotation.
1961  * There should be no annotation in the exported SBML model.
1962  */
1963 const char* test000092::MODEL_STRING3 = \
1964  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
1965  "<!-- generated with COPASI 4.5.31 (Debug) (http://www.copasi.org) at 2010-04-21 14:00:12 UTC -->\n"
1966  "<?oxygen RNGSchema=\"http://www.copasi.org/static/schema/CopasiML.rng\" type=\"xml\"?>\n"
1967  "<COPASI xmlns=\"http://www.copasi.org/static/schema\" versionMajor=\"1\" versionMinor=\"0\" versionDevel=\"31\">\n"
1968  " <Model key=\"Model_0\" name=\"New Model\" simulationType=\"time\" timeUnit=\"s\" volumeUnit=\"ml\" areaUnit=\"m²\" lengthUnit=\"m\" quantityUnit=\"mmol\" type=\"deterministic\">\n"
1969  " <ListOfCompartments>\n"
1970  " <Compartment key=\"Compartment_0\" name=\"Compartment\" simulationType=\"fixed\" dimensionality=\"3\"/>\n"
1971  " </ListOfCompartments>\n"
1972  " <StateTemplate>\n"
1973  " <StateTemplateVariable objectReference=\"Model_0\"/>\n"
1974  " <StateTemplateVariable objectReference=\"Compartment_0\"/>\n"
1975  " </StateTemplate>\n"
1976  " <InitialState type=\"initialState\">\n"
1977  " 0 1 \n"
1978  " </InitialState>\n"
1979  " </Model>\n"
1980  "</COPASI>\n";
1981 
1982 
1983 /**
1984  * This model has complete MIRIAM compliant annotation, so of of it should be exported
1985  * by libsbml and in addition to that as annotation in the COPASI namespace.
1986  * In addition there is layout information that should also end up in the annotation to the
1987  * SBML model
1988  */
1989 const char* test000092::MODEL_STRING4 = \
1990  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
1991  "<!-- generated with COPASI 4.5.31 (Debug) (http://www.copasi.org) at 2010-04-21 14:00:12 UTC -->\n"
1992  "<?oxygen RNGSchema=\"http://www.copasi.org/static/schema/CopasiML.rng\" type=\"xml\"?>\n"
1993  "<COPASI xmlns=\"http://www.copasi.org/static/schema\" versionMajor=\"1\" versionMinor=\"0\" versionDevel=\"31\">\n"
1994  " <Model key=\"Model_0\" name=\"New Model\" simulationType=\"time\" timeUnit=\"s\" volumeUnit=\"ml\" areaUnit=\"m²\" lengthUnit=\"m\" quantityUnit=\"mmol\" type=\"deterministic\">\n"
1995  " <MiriamAnnotation>\n"
1996  "<rdf:RDF\n"
1997  " xmlns:dcterms=\"http://purl.org/dc/terms/\"\n"
1998  " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n"
1999  " xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\">\n"
2000  " <rdf:Description rdf:about=\"#Model_0\">\n"
2001  " <dcterms:created>\n"
2002  " <rdf:Description>\n"
2003  " <dcterms:W3CDTF>2010-04-21T15:55:08Z</dcterms:W3CDTF>\n"
2004  " </rdf:Description>\n"
2005  " </dcterms:created>\n"
2006  " <dcterms:creator>\n"
2007  " <rdf:Description>\n"
2008  " <vCard:N>\n"
2009  " <rdf:Description>\n"
2010  " <vCard:Family>Gauges</vCard:Family>\n"
2011  " <vCard:Given>Ralph</vCard:Given>\n"
2012  " </rdf:Description>\n"
2013  " </vCard:N>\n"
2014  " </rdf:Description>\n"
2015  " </dcterms:creator>\n"
2016  " <dcterms:modified>\n"
2017  " <rdf:Description>\n"
2018  " <dcterms:W3CDTF>2010-04-21T15:59:47</dcterms:W3CDTF>\n"
2019  " </rdf:Description>\n"
2020  " </dcterms:modified>\n"
2021  " </rdf:Description>\n"
2022  "</rdf:RDF>\n"
2023  "\n"
2024  " </MiriamAnnotation>\n"
2025  " <ListOfCompartments>\n"
2026  " <Compartment key=\"Compartment_0\" name=\"Compartment\" simulationType=\"fixed\" dimensionality=\"3\">\n"
2027  " <MiriamAnnotation>\n"
2028  "<rdf:RDF\n"
2029  " xmlns:CopasiMT=\"http://www.copasi.org/RDF/MiriamTerms#\"\n"
2030  " xmlns:dcterms=\"http://purl.org/dc/terms/\"\n"
2031  " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n"
2032  " xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\">\n"
2033  " <rdf:Description rdf:about=\"#Compartment_0\">\n"
2034  " <dcterms:created>\n"
2035  " <rdf:Description>\n"
2036  " <dcterms:W3CDTF>2010-04-21T15:55:31Z</dcterms:W3CDTF>\n"
2037  " </rdf:Description>\n"
2038  " </dcterms:created>\n"
2039  " <dcterms:creator>\n"
2040  " <rdf:Description>\n"
2041  " <vCard:N>\n"
2042  " <rdf:Description>\n"
2043  " <vCard:Family>Gauges</vCard:Family>\n"
2044  " <vCard:Given>Ralph</vCard:Given>\n"
2045  " </rdf:Description>\n"
2046  " </vCard:N>\n"
2047  " </rdf:Description>\n"
2048  " </dcterms:creator>\n"
2049  " <CopasiMT:isVersionOf rdf:resource=\"urn:miriam:obo.go:GO:0005623\"/>\n"
2050  " </rdf:Description>\n"
2051  "</rdf:RDF>\n"
2052  "\n"
2053  " </MiriamAnnotation>\n"
2054  " </Compartment>\n"
2055  " </ListOfCompartments>\n"
2056  " <StateTemplate>\n"
2057  " <StateTemplateVariable objectReference=\"Model_0\"/>\n"
2058  " <StateTemplateVariable objectReference=\"Compartment_0\"/>\n"
2059  " </StateTemplate>\n"
2060  " <InitialState type=\"initialState\">\n"
2061  " 0 1 \n"
2062  " </InitialState>\n"
2063  " </Model>\n"
2064  " <ListOfLayouts>\n"
2065  " <Layout key=\"Layout_2\" name=\"layout_0\">\n"
2066  " <Dimensions width=\"500.0\" height=\"200.0\"/>\n"
2067  " <ListOfCompartmentGlyphs>\n"
2068  " <CompartmentGlyph key=\"Layout_3\" name=\"sGlyph_0\" compartment=\"Compartment_0\">\n"
2069  " <BoundingBox>\n"
2070  " <Position x=\"10.0\" y=\"10.0\"/>\n"
2071  " <Dimensions width=\"480.0\" height=\"180.0\"/>\n"
2072  " </BoundingBox>\n"
2073  " </CompartmentGlyph>\n"
2074  " </ListOfCompartmentGlyphs>\n"
2075  " </Layout>\n"
2076  " </ListOfLayouts>\n"
2077  "</COPASI>\n";
2078 
2079 
2080 /**
2081  * In this model the Model history is incomplete because there is no creator
2082  * and no modified date so libsbml 4 will no longer write the model history. Nevertheless
2083  * the annotation should be written in the COPASI namespace.
2084  * In addition there is layout information that should also end up in the annotation to the
2085  * SBML model
2086  */
2087 const char* test000092::MODEL_STRING5 = \
2088  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
2089  "<!-- generated with COPASI 4.5.31 (Debug) (http://www.copasi.org) at 2010-04-21 14:00:12 UTC -->\n"
2090  "<?oxygen RNGSchema=\"http://www.copasi.org/static/schema/CopasiML.rng\" type=\"xml\"?>\n"
2091  "<COPASI xmlns=\"http://www.copasi.org/static/schema\" versionMajor=\"1\" versionMinor=\"0\" versionDevel=\"31\">\n"
2092  " <Model key=\"Model_0\" name=\"New Model\" simulationType=\"time\" timeUnit=\"s\" volumeUnit=\"ml\" areaUnit=\"m²\" lengthUnit=\"m\" quantityUnit=\"mmol\" type=\"deterministic\">\n"
2093  " <MiriamAnnotation>\n"
2094  "<rdf:RDF\n"
2095  " xmlns:dcterms=\"http://purl.org/dc/terms/\"\n"
2096  " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n"
2097  " xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\">\n"
2098  " <rdf:Description rdf:about=\"#Model_0\">\n"
2099  " <dcterms:created>\n"
2100  " <rdf:Description>\n"
2101  " <dcterms:W3CDTF>2010-04-21T15:55:08Z</dcterms:W3CDTF>\n"
2102  " </rdf:Description>\n"
2103  " </dcterms:created>\n"
2104  " </rdf:Description>\n"
2105  "</rdf:RDF>\n"
2106  "\n"
2107  " </MiriamAnnotation>\n"
2108  " <ListOfCompartments>\n"
2109  " <Compartment key=\"Compartment_0\" name=\"Compartment\" simulationType=\"fixed\" dimensionality=\"3\">\n"
2110  " <MiriamAnnotation>\n"
2111  "<rdf:RDF\n"
2112  " xmlns:CopasiMT=\"http://www.copasi.org/RDF/MiriamTerms#\"\n"
2113  " xmlns:dcterms=\"http://purl.org/dc/terms/\"\n"
2114  " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n"
2115  " xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\">\n"
2116  " <rdf:Description rdf:about=\"#Compartment_0\">\n"
2117  " <dcterms:created>\n"
2118  " <rdf:Description>\n"
2119  " <dcterms:W3CDTF>2010-04-21T15:55:31Z</dcterms:W3CDTF>\n"
2120  " </rdf:Description>\n"
2121  " </dcterms:created>\n"
2122  " <dcterms:creator>\n"
2123  " <rdf:Description>\n"
2124  " <vCard:N>\n"
2125  " <rdf:Description>\n"
2126  " <vCard:Family>Gauges</vCard:Family>\n"
2127  " <vCard:Given>Ralph</vCard:Given>\n"
2128  " </rdf:Description>\n"
2129  " </vCard:N>\n"
2130  " </rdf:Description>\n"
2131  " </dcterms:creator>\n"
2132  " <CopasiMT:isVersionOf rdf:resource=\"urn:miriam:obo.go:GO:0005623\"/>\n"
2133  " </rdf:Description>\n"
2134  "</rdf:RDF>\n"
2135  "\n"
2136  " </MiriamAnnotation>\n"
2137  " </Compartment>\n"
2138  " </ListOfCompartments>\n"
2139  " <StateTemplate>\n"
2140  " <StateTemplateVariable objectReference=\"Model_0\"/>\n"
2141  " <StateTemplateVariable objectReference=\"Compartment_0\"/>\n"
2142  " </StateTemplate>\n"
2143  " <InitialState type=\"initialState\">\n"
2144  " 0 1 \n"
2145  " </InitialState>\n"
2146  " </Model>\n"
2147  " <ListOfLayouts>\n"
2148  " <Layout key=\"Layout_2\" name=\"layout_0\">\n"
2149  " <Dimensions width=\"500.0\" height=\"200.0\"/>\n"
2150  " <ListOfCompartmentGlyphs>\n"
2151  " <CompartmentGlyph key=\"Layout_3\" name=\"sGlyph_0\" compartment=\"Compartment_0\">\n"
2152  " <BoundingBox>\n"
2153  " <Position x=\"10.0\" y=\"10.0\"/>\n"
2154  " <Dimensions width=\"480.0\" height=\"180.0\"/>\n"
2155  " </BoundingBox>\n"
2156  " </CompartmentGlyph>\n"
2157  " </ListOfCompartmentGlyphs>\n"
2158  " </Layout>\n"
2159  " </ListOfLayouts>\n"
2160  "</COPASI>\n";
2161 
2162 /**
2163  * In this model the Model there is no MIRIAM annotation.
2164  * But the model has a layout, that should be exported as an annotation to the
2165  * SBML Model,
2166  */
2167 const char* test000092::MODEL_STRING6 = \
2168  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
2169  "<!-- generated with COPASI 4.5.31 (Debug) (http://www.copasi.org) at 2010-04-21 14:00:12 UTC -->\n"
2170  "<?oxygen RNGSchema=\"http://www.copasi.org/static/schema/CopasiML.rng\" type=\"xml\"?>\n"
2171  "<COPASI xmlns=\"http://www.copasi.org/static/schema\" versionMajor=\"1\" versionMinor=\"0\" versionDevel=\"31\">\n"
2172  " <Model key=\"Model_0\" name=\"New Model\" simulationType=\"time\" timeUnit=\"s\" volumeUnit=\"ml\" areaUnit=\"m²\" lengthUnit=\"m\" quantityUnit=\"mmol\" type=\"deterministic\">\n"
2173  " <ListOfCompartments>\n"
2174  " <Compartment key=\"Compartment_0\" name=\"Compartment\" simulationType=\"fixed\" dimensionality=\"3\"/>\n"
2175  " </ListOfCompartments>\n"
2176  " <StateTemplate>\n"
2177  " <StateTemplateVariable objectReference=\"Model_0\"/>\n"
2178  " <StateTemplateVariable objectReference=\"Compartment_0\"/>\n"
2179  " </StateTemplate>\n"
2180  " <InitialState type=\"initialState\">\n"
2181  " 0 1 \n"
2182  " </InitialState>\n"
2183  " </Model>\n"
2184  " <ListOfLayouts>\n"
2185  " <Layout key=\"Layout_2\" name=\"layout_0\">\n"
2186  " <Dimensions width=\"500.0\" height=\"200.0\"/>\n"
2187  " <ListOfCompartmentGlyphs>\n"
2188  " <CompartmentGlyph key=\"Layout_3\" name=\"sGlyph_0\" compartment=\"Compartment_0\">\n"
2189  " <BoundingBox>\n"
2190  " <Position x=\"10.0\" y=\"10.0\"/>\n"
2191  " <Dimensions width=\"480.0\" height=\"180.0\"/>\n"
2192  " </BoundingBox>\n"
2193  " </CompartmentGlyph>\n"
2194  " </ListOfCompartmentGlyphs>\n"
2195  " </Layout>\n"
2196  " </ListOfLayouts>\n"
2197  "</COPASI>\n";
2198 
2199 /**
2200  * This SBML model already contains an annotation.
2201  * We load it and add some MIRIAM annotation and write it out again to check
2202  * if MIRIAM annotation is correctly written even if another annotation exists.
2203  */
2204 const char* test000092::MODEL_STRING7 = \
2205  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
2206  "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version4\" level=\"2\" version=\"4\">\n"
2207  " <model metaid=\"COPASI1\" id=\"Model_1\" name=\"New Model\">\n"
2208  " <annotation>\n"
2209  " <SOMEANNOTATION xmlns=\"http://www.SOMEORGANISATION.org/\" />\n"
2210  " </annotation>\n"
2211  " <listOfCompartments>\n"
2212  " <compartment metaid=\"COPASI2\" id=\"compartment_1\" name=\"Compartment\" size=\"1\">\n"
2213  " <annotation>\n"
2214  " <SOMEANNOTATION xmlns=\"http://www.SOMEORGANISATION.org/\" />\n"
2215  " </annotation>\n"
2216  " </compartment>\n"
2217  " </listOfCompartments>\n"
2218  " </model>\n"
2219  "</sbml>\n";
2220 
2221 /**
2222  * This SBML model already contains RDF annotation and other annotation.
2223  * We load it and modify the MIRIAM annotation and write it out again to check
2224  * if MIRIAM annotation is correctly updated
2225  */
2226 const char* test000092::MODEL_STRING8 = \
2227  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
2228  "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version4\" level=\"2\" version=\"4\">\n"
2229  " <model metaid=\"COPASI1\" id=\"Model_1\" name=\"New Model\">\n"
2230  " <annotation>\n"
2231  " <SOMEANNOTATION xmlns=\"http://www.SOMEORGANISATION.org/\" />\n"
2232  " <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\" xmlns:bqbiol=\"http://biomodels.net/biology-qualifiers/\" xmlns:bqmodel=\"http://biomodels.net/model-qualifiers/\">\n"
2233  " <rdf:Description rdf:about=\"#COPASI1\">\n"
2234  " <dcterms:created rdf:parseType=\"Resource\">\n"
2235  " <dcterms:W3CDTF>2002-04-21T15:55:08Z</dcterms:W3CDTF>\n"
2236  " </dcterms:created>\n"
2237  " <dc:creator>\n"
2238  " <rdf:Bag>\n"
2239  " <rdf:li rdf:parseType=\"Resource\">\n"
2240  " <vCard:N rdf:parseType=\"Resource\">\n"
2241  " <vCard:Family>Gauges</vCard:Family>\n"
2242  " <vCard:Given>Ralph</vCard:Given>\n"
2243  " </vCard:N>\n"
2244  " </rdf:li>\n"
2245  " </rdf:Bag>\n"
2246  " </dc:creator>\n"
2247  " <dcterms:modified rdf:parseType=\"Resource\">\n"
2248  " <dcterms:W3CDTF>2007-06-05T11:40:04Z</dcterms:W3CDTF>\n"
2249  " </dcterms:modified>\n"
2250  " </rdf:Description>\n"
2251  " </rdf:RDF>\n"
2252  " </annotation>\n"
2253  " <listOfUnitDefinitions>\n"
2254  " <unitDefinition id=\"volume\" name=\"volume\">\n"
2255  " <listOfUnits>\n"
2256  " <unit kind=\"litre\" scale=\"-3\"/>\n"
2257  " </listOfUnits>\n"
2258  " </unitDefinition>\n"
2259  " <unitDefinition id=\"substance\" name=\"substance\">\n"
2260  " <listOfUnits>\n"
2261  " <unit kind=\"mole\" scale=\"-3\"/>\n"
2262  " </listOfUnits>\n"
2263  " </unitDefinition>\n"
2264  " </listOfUnitDefinitions>\n"
2265  " <listOfCompartments>\n"
2266  " <compartment metaid=\"COPASI2\" id=\"compartment_1\" name=\"Compartment\" size=\"1\">\n"
2267  " <annotation>\n"
2268  " <SOMEANNOTATION xmlns=\"http://www.SOMEORGANISATION.org/\" />\n"
2269  " <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\" xmlns:bqbiol=\"http://biomodels.net/biology-qualifiers/\" xmlns:bqmodel=\"http://biomodels.net/model-qualifiers/\">\n"
2270  " <rdf:Description rdf:about=\"#COPASI2\">\n"
2271  " <bqbiol:isVersionOf>\n"
2272  " <rdf:Bag>\n"
2273  " <rdf:li rdf:resource=\"urn:miriam:obo.go:GO:0005623\"/>\n"
2274  " </rdf:Bag>\n"
2275  " </bqbiol:isVersionOf>\n"
2276  " </rdf:Description>\n"
2277  " </rdf:RDF>\n"
2278  " </annotation>\n"
2279  " </compartment>\n"
2280  " </listOfCompartments>\n"
2281  " </model>\n"
2282  "</sbml>\n";
2283 
2284 /**
2285  * This SBML model already contains RDF annotation and other annotation.
2286  * It also contains COPASI RDF annotation.
2287  * We load it and modify the MIRIAM annotation and write it out again to check
2288  * if MIRIAM annotation is correctly updated and COPASI annotation is correctly replaced.
2289  */
2290 const char* test000092::MODEL_STRING9 = \
2291  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
2292  "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version4\" level=\"2\" version=\"4\">\n"
2293  " <model metaid=\"COPASI1\" id=\"Model_1\" name=\"New Model\">\n"
2294  " <annotation>\n"
2295  " <SOMEANNOTATION xmlns=\"http://www.SOMEORGANISATION.org/\" />\n"
2296  " <COPASI xmlns=\"http://www.copasi.org/static/sbml\">\n"
2297  " <rdf:RDF xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\">\n"
2298  " <rdf:Description rdf:about=\"#COPASI1\">\n"
2299  " <dcterms:created>\n"
2300  " <rdf:Description>\n"
2301  " <dcterms:W3CDTF>2002-04-21T15:55:08Z</dcterms:W3CDTF>\n"
2302  " </rdf:Description>\n"
2303  " </dcterms:created>\n"
2304  " <dcterms:creator>\n"
2305  " <rdf:Description>\n"
2306  " <vCard:N>\n"
2307  " <rdf:Description>\n"
2308  " <vCard:Family>Gauges</vCard:Family>\n"
2309  " <vCard:Given>Ralph</vCard:Given>\n"
2310  " </rdf:Description>\n"
2311  " </vCard:N>\n"
2312  " </rdf:Description>\n"
2313  " </dcterms:creator>\n"
2314  " <dcterms:modified rdf:parseType=\"Resource\">\n"
2315  " <dcterms:W3CDTF>2007-06-05T11:40:04Z</dcterms:W3CDTF>\n"
2316  " </dcterms:modified>\n"
2317  " </rdf:Description>\n"
2318  " </rdf:RDF>\n"
2319  " </COPASI>\n"
2320  " <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\" xmlns:bqbiol=\"http://biomodels.net/biology-qualifiers/\" xmlns:bqmodel=\"http://biomodels.net/model-qualifiers/\">\n"
2321  " <rdf:Description rdf:about=\"#COPASI1\">\n"
2322  " <dcterms:created rdf:parseType=\"Resource\">\n"
2323  " <dcterms:W3CDTF>2002-04-21T15:55:08Z</dcterms:W3CDTF>\n"
2324  " </dcterms:created>\n"
2325  " <dc:creator>\n"
2326  " <rdf:Bag>\n"
2327  " <rdf:li rdf:parseType=\"Resource\">\n"
2328  " <vCard:N rdf:parseType=\"Resource\">\n"
2329  " <vCard:Family>Gauges</vCard:Family>\n"
2330  " <vCard:Given>Ralph</vCard:Given>\n"
2331  " </vCard:N>\n"
2332  " </rdf:li>\n"
2333  " </rdf:Bag>\n"
2334  " </dc:creator>\n"
2335  " <dcterms:modified rdf:parseType=\"Resource\">\n"
2336  " <dcterms:W3CDTF>2007-06-05T11:40:04Z</dcterms:W3CDTF>\n"
2337  " </dcterms:modified>\n"
2338  " </rdf:Description>\n"
2339  " </rdf:RDF>\n"
2340  " </annotation>\n"
2341  " <listOfCompartments>\n"
2342  " <compartment metaid=\"COPASI2\" id=\"compartment_1\" name=\"Compartment\" size=\"1\">\n"
2343  " <annotation>\n"
2344  " <SOMEANNOTATION xmlns=\"http://www.SOMEORGANISATION.org/\" />\n"
2345  " <COPASI xmlns=\"http://www.copasi.org/static/sbml\">\n"
2346  " <rdf:RDF xmlns:CopasiMT=\"http://www.copasi.org/RDF/MiriamTerms#\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\">\n"
2347  " <rdf:Description rdf:about=\"#COPASI2\">\n"
2348  " <dcterms:created>\n"
2349  " <rdf:Description>\n"
2350  " <dcterms:W3CDTF>2002-04-21T15:55:31Z</dcterms:W3CDTF>\n"
2351  " </rdf:Description>\n"
2352  " </dcterms:created>\n"
2353  " <dcterms:creator>\n"
2354  " <rdf:Description>\n"
2355  " <vCard:N>\n"
2356  " <rdf:Description>\n"
2357  " <vCard:Family>Gauges</vCard:Family>\n"
2358  " <vCard:Given>Ralph</vCard:Given>\n"
2359  " </rdf:Description>\n"
2360  " </vCard:N>\n"
2361  " </rdf:Description>\n"
2362  " </dcterms:creator>\n"
2363  " <CopasiMT:isVersionOf rdf:resource=\"urn:miriam:obo.go:GO:0005623\"/>\n"
2364  " </rdf:Description>\n"
2365  " </rdf:RDF>\n"
2366  " </COPASI>\n"
2367  " <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\" xmlns:bqbiol=\"http://biomodels.net/biology-qualifiers/\" xmlns:bqmodel=\"http://biomodels.net/model-qualifiers/\">\n"
2368  " <rdf:Description rdf:about=\"#COPASI2\">\n"
2369  " <bqbiol:isVersionOf>\n"
2370  " <rdf:Bag>\n"
2371  " <rdf:li rdf:resource=\"urn:miriam:obo.go:GO:0005623\"/>\n"
2372  " </rdf:Bag>\n"
2373  " </bqbiol:isVersionOf>\n"
2374  " </rdf:Description>\n"
2375  " </rdf:RDF>\n"
2376  " </annotation>\n"
2377  " </compartment>\n"
2378  " </listOfCompartments>\n"
2379  " </model>\n"
2380  "</sbml>\n";
2381 
2382 
2383 const char* test000092::MODEL_STRING10 = \
2384  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
2385  "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version4\" level=\"2\" version=\"4\">\n"
2386  " <model metaid=\"COPASI1\" id=\"Model_1\" name=\"New Model\">\n"
2387  " <annotation>\n"
2388  " <COPASI xmlns=\"http://www.copasi.org/static/sbml\">\n"
2389  " <rdf:RDF xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\">\n"
2390  " <rdf:Description rdf:about=\"#COPASI1\">\n"
2391  " <dcterms:created>\n"
2392  " <rdf:Description>\n"
2393  " <dcterms:W3CDTF>2002-04-21T15:55:08Z</dcterms:W3CDTF>\n"
2394  " </rdf:Description>\n"
2395  " </dcterms:created>\n"
2396  " <dcterms:creator>\n"
2397  " <rdf:Description>\n"
2398  " <vCard:N>\n"
2399  " <rdf:Description>\n"
2400  " <vCard:Family>Gauges</vCard:Family>\n"
2401  " <vCard:Given>Ralph</vCard:Given>\n"
2402  " </rdf:Description>\n"
2403  " </vCard:N>\n"
2404  " </rdf:Description>\n"
2405  " </dcterms:creator>\n"
2406  " <dcterms:modified>\n"
2407  " <rdf:Bag>\n"
2408  " <rdf:li>\n"
2409  " <rdf:Description>\n"
2410  " <dcterms:W3CDTF>2007-06-05T11:40:04Z</dcterms:W3CDTF>\n"
2411  " </rdf:Description>\n"
2412  " </rdf:li>\n"
2413  " <rdf:li>\n"
2414  " <rdf:Description>\n"
2415  " <dcterms:W3CDTF>2008-06-05T11:40:04Z</dcterms:W3CDTF>\n"
2416  " </rdf:Description>\n"
2417  " </rdf:li>\n"
2418  " </rdf:Bag>\n"
2419  " </dcterms:modified>\n"
2420  " </rdf:Description>\n"
2421  " </rdf:RDF>\n"
2422  " </COPASI>\n"
2423  " <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\" xmlns:bqbiol=\"http://biomodels.net/biology-qualifiers/\" xmlns:bqmodel=\"http://biomodels.net/model-qualifiers/\">\n"
2424  " <rdf:Description rdf:about=\"#COPASI1\">\n"
2425  " <dc:creator>\n"
2426  " <rdf:Bag>\n"
2427  " <rdf:li rdf:parseType=\"Resource\">\n"
2428  " <vCard:N rdf:parseType=\"Resource\">\n"
2429  " <vCard:Family>Gauges</vCard:Family>\n"
2430  " <vCard:Given>Ralph</vCard:Given>\n"
2431  " </vCard:N>\n"
2432  " </rdf:li>\n"
2433  " </rdf:Bag>\n"
2434  " </dc:creator>\n"
2435  " <dcterms:created rdf:parseType=\"Resource\">\n"
2436  " <dcterms:W3CDTF>2002-04-21T15:55:08Z</dcterms:W3CDTF>\n"
2437  " </dcterms:created>\n"
2438  " <dcterms:modified rdf:parseType=\"Resource\">\n"
2439  " <dcterms:W3CDTF>2008-06-05T11:40:04Z</dcterms:W3CDTF>\n"
2440  " </dcterms:modified>\n"
2441  " </rdf:Description>\n"
2442  " </rdf:RDF>\n"
2443  " </annotation>\n"
2444  " <listOfCompartments>\n"
2445  " <compartment metaid=\"COPASI2\" id=\"compartment_1\" name=\"Compartment\" size=\"1\" />\n"
2446  " </listOfCompartments>\n"
2447  " </model>\n"
2448  "</sbml>\n";
2449 
static const char * MODEL_STRING8
Definition: test000092.h:47
void test_miriam_export_1()
Definition: test000092.cpp:51
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000092.h:50
SBMLDocument * getCurrentSBMLDocument()
void test_miriam_export_7()
Definition: test000092.cpp:916
void test_miriam_export_8()
void load(const std::string &key="")
void test_miriam_export_6()
Definition: test000092.cpp:862
static const char * MODEL_STRING1
Definition: test000092.h:40
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
virtual size_t size() const
static const char * MODEL_STRING4
Definition: test000092.h:43
void setResource(const std::string &resource)
void test_miriam_export_3()
Definition: test000092.cpp:426
static const char * MODEL_STRING9
Definition: test000092.h:48
void setMiriamAnnotation(const std::string &miriamAnnotation, const std::string &newId, const std::string &oldId)
static const char * MODEL_STRING5
Definition: test000092.h:44
const std::string & getMiriamAnnotation() const
void test_miriam_export_9()
void setUp()
Definition: test000092.cpp:38
const std::string & getId() const
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static const char * MODEL_STRING3
Definition: test000092.h:42
void test_miriam_export_2()
Definition: test000092.cpp:232
const std::string & getDate() const
Definition: CModified.cpp:70
void test_miriam_import_1()
void setPredicate(const std::string &predicate)
static const char * MODEL_STRING10
Definition: test000092.h:49
const std::string & getKey() const
Definition: CModel.cpp:1142
static CCopasiDataModel * addDatamodel()
CCopasiVectorNS< CCompartment > & getCompartments()
Definition: CModel.cpp:1145
std::string getPredicate() const
static bool SBML2Copasi(std::string &XML)
void test_miriam_export_4()
Definition: test000092.cpp:481
static const char * MODEL_STRING2
Definition: test000092.h:41
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
static const char * MODEL_STRING6
Definition: test000092.h:45
static void init(int argc, char *argv[], const bool &withGui=false)
Definition: CModel.h:50
void test_miriam_export_5()
Definition: test000092.cpp:667
void tearDown()
Definition: test000092.cpp:46
std::string getResource() const
void setId(const std::string &id)
static const char * MODEL_STRING7
Definition: test000092.h:46