COPASI API  4.16.103
Public Member Functions | Static Protected Attributes | Private Member Functions | List of all members
test000092 Class Reference

#include <test000092.h>

Inheritance diagram for test000092:
Inheritance graph
[legend]
Collaboration diagram for test000092:
Collaboration graph
[legend]

Public Member Functions

void setUp ()
 
void tearDown ()
 
void test_miriam_export_1 ()
 
void test_miriam_export_2 ()
 
void test_miriam_export_3 ()
 
void test_miriam_export_4 ()
 
void test_miriam_export_5 ()
 
void test_miriam_export_6 ()
 
void test_miriam_export_7 ()
 
void test_miriam_export_8 ()
 
void test_miriam_export_9 ()
 
void test_miriam_import_1 ()
 

Static Protected Attributes

static const char * MODEL_STRING1
 
static const char * MODEL_STRING10
 
static const char * MODEL_STRING2
 
static const char * MODEL_STRING3
 
static const char * MODEL_STRING4
 
static const char * MODEL_STRING5
 
static const char * MODEL_STRING6
 
static const char * MODEL_STRING7
 
static const char * MODEL_STRING8
 
static const char * MODEL_STRING9
 
static CCopasiDataModelpCOPASIDATAMODEL = NULL
 

Private Member Functions

 CPPUNIT_TEST (test_miriam_export_1)
 
 CPPUNIT_TEST (test_miriam_export_2)
 
 CPPUNIT_TEST (test_miriam_export_3)
 
 CPPUNIT_TEST (test_miriam_export_4)
 
 CPPUNIT_TEST (test_miriam_export_5)
 
 CPPUNIT_TEST (test_miriam_export_6)
 
 CPPUNIT_TEST (test_miriam_export_7)
 
 CPPUNIT_TEST (test_miriam_export_8)
 
 CPPUNIT_TEST (test_miriam_export_9)
 
 CPPUNIT_TEST (test_miriam_import_1)
 
 CPPUNIT_TEST_SUITE (test000092)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 24 of file test000092.h.

Member Function Documentation

test000092::CPPUNIT_TEST ( test_miriam_export_1  )
private
test000092::CPPUNIT_TEST ( test_miriam_export_2  )
private
test000092::CPPUNIT_TEST ( test_miriam_export_3  )
private
test000092::CPPUNIT_TEST ( test_miriam_export_4  )
private
test000092::CPPUNIT_TEST ( test_miriam_export_5  )
private
test000092::CPPUNIT_TEST ( test_miriam_export_6  )
private
test000092::CPPUNIT_TEST ( test_miriam_export_7  )
private
test000092::CPPUNIT_TEST ( test_miriam_export_8  )
private
test000092::CPPUNIT_TEST ( test_miriam_export_9  )
private
test000092::CPPUNIT_TEST ( test_miriam_import_1  )
private
test000092::CPPUNIT_TEST_SUITE ( test000092  )
private
test000092::CPPUNIT_TEST_SUITE_END ( )
private
void test000092::setUp ( )

Definition at line 38 of file test000092.cpp.

References CCopasiRootContainer::addDatamodel(), CCopasiRootContainer::init(), and pCOPASIDATAMODEL.

39 {
40  // Create the root container.
41  CCopasiRootContainer::init(0, NULL, false);
42  // Create the global data model.
44 }
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000092.h:50
static CCopasiDataModel * addDatamodel()
static void init(int argc, char *argv[], const bool &withGui=false)
void test000092::tearDown ( )

Definition at line 46 of file test000092.cpp.

References CCopasiRootContainer::destroy().

void test000092::test_miriam_export_1 ( )

Definition at line 51 of file test000092.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getModel(), CCopasiDataModel::importSBMLFromString(), load_cps_model_from_stream(), MODEL_STRING1, and pCOPASIDATAMODEL.

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 }
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000092.h:50
static const char * MODEL_STRING1
Definition: test000092.h:40
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
const char * ns
Definition: stdsoap2.h:1263
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
void test000092::test_miriam_export_2 ( )

Definition at line 232 of file test000092.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getModel(), CCopasiDataModel::importSBMLFromString(), load_cps_model_from_stream(), MODEL_STRING2, and pCOPASIDATAMODEL.

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 }
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000092.h:50
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
const char * ns
Definition: stdsoap2.h:1263
static const char * MODEL_STRING2
Definition: test000092.h:41
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
void test000092::test_miriam_export_3 ( )

Definition at line 426 of file test000092.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getModel(), CCopasiDataModel::importSBMLFromString(), load_cps_model_from_stream(), MODEL_STRING3, and pCOPASIDATAMODEL.

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 }
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000092.h:50
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static const char * MODEL_STRING3
Definition: test000092.h:42
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
void test000092::test_miriam_export_4 ( )

Definition at line 481 of file test000092.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getModel(), CCopasiDataModel::importSBMLFromString(), load_cps_model_from_stream(), MODEL_STRING4, and pCOPASIDATAMODEL.

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 }
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000092.h:50
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static const char * MODEL_STRING4
Definition: test000092.h:43
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
const char * ns
Definition: stdsoap2.h:1263
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
void test000092::test_miriam_export_5 ( )

Definition at line 667 of file test000092.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getModel(), CCopasiDataModel::importSBMLFromString(), load_cps_model_from_stream(), MODEL_STRING5, and pCOPASIDATAMODEL.

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 }
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000092.h:50
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static const char * MODEL_STRING5
Definition: test000092.h:44
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
const char * ns
Definition: stdsoap2.h:1263
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
void test000092::test_miriam_export_6 ( )

Definition at line 862 of file test000092.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getModel(), CCopasiDataModel::importSBMLFromString(), load_cps_model_from_stream(), MODEL_STRING6, and pCOPASIDATAMODEL.

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 }
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000092.h:50
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
static const char * MODEL_STRING6
Definition: test000092.h:45
void test000092::test_miriam_export_7 ( )

Definition at line 916 of file test000092.cpp.

References CCopasiDataModel::exportSBMLToString(), CModel::getCompartments(), CCopasiDataModel::getCurrentSBMLDocument(), CModel::getKey(), CCopasiDataModel::getModel(), CCopasiDataModel::importSBMLFromString(), MODEL_STRING7, pCOPASIDATAMODEL, CRDFGraphConverter::SBML2Copasi(), CAnnotation::setMiriamAnnotation(), and CCopasiVector< T >::size().

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 }
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000092.h:50
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
virtual size_t size() const
void setMiriamAnnotation(const std::string &miriamAnnotation, const std::string &newId, const std::string &oldId)
const char * ns
Definition: stdsoap2.h:1263
const std::string & getKey() const
Definition: CModel.cpp:1142
CCopasiVectorNS< CCompartment > & getCompartments()
Definition: CModel.cpp:1145
static bool SBML2Copasi(std::string &XML)
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
static const char * MODEL_STRING7
Definition: test000092.h:46
void test000092::test_miriam_export_8 ( )

Definition at line 1148 of file test000092.cpp.

References CCopasiDataModel::exportSBMLToString(), CModel::getCompartments(), CModification::getDate(), CBiologicalDescription::getId(), CModel::getKey(), CAnnotation::getMiriamAnnotation(), CCopasiDataModel::getModel(), CBiologicalDescription::getPredicate(), CBiologicalDescription::getResource(), CCopasiDataModel::importSBMLFromString(), CMIRIAMInfo::load(), MODEL_STRING8, pCOPASIDATAMODEL, CBiologicalDescription::setId(), CBiologicalDescription::setPredicate(), CBiologicalDescription::setResource(), and CCopasiVector< T >::size().

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 }
static const char * MODEL_STRING8
Definition: test000092.h:47
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000092.h:50
void load(const std::string &key="")
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
virtual size_t size() const
void setResource(const std::string &resource)
const std::string & getMiriamAnnotation() const
const std::string & getId() const
const std::string & getDate() const
Definition: CModified.cpp:70
const char * ns
Definition: stdsoap2.h:1263
void setPredicate(const std::string &predicate)
const std::string & getKey() const
Definition: CModel.cpp:1142
CCopasiVectorNS< CCompartment > & getCompartments()
Definition: CModel.cpp:1145
std::string getPredicate() const
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
std::string getResource() const
void setId(const std::string &id)
void test000092::test_miriam_export_9 ( )

Definition at line 1461 of file test000092.cpp.

References CCopasiDataModel::exportSBMLToString(), CModel::getCompartments(), CModification::getDate(), CBiologicalDescription::getId(), CModel::getKey(), CAnnotation::getMiriamAnnotation(), CCopasiDataModel::getModel(), CBiologicalDescription::getPredicate(), CBiologicalDescription::getResource(), CCopasiDataModel::importSBMLFromString(), CMIRIAMInfo::load(), MODEL_STRING9, pCOPASIDATAMODEL, CBiologicalDescription::setId(), CBiologicalDescription::setPredicate(), CBiologicalDescription::setResource(), and CCopasiVector< T >::size().

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 }
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000092.h:50
void load(const std::string &key="")
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
virtual size_t size() const
void setResource(const std::string &resource)
static const char * MODEL_STRING9
Definition: test000092.h:48
const std::string & getMiriamAnnotation() const
const std::string & getId() const
const std::string & getDate() const
Definition: CModified.cpp:70
const char * ns
Definition: stdsoap2.h:1263
void setPredicate(const std::string &predicate)
const std::string & getKey() const
Definition: CModel.cpp:1142
CCopasiVectorNS< CCompartment > & getCompartments()
Definition: CModel.cpp:1145
std::string getPredicate() const
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
std::string getResource() const
void setId(const std::string &id)
void test000092::test_miriam_import_1 ( )

This test will most likely fail until we have a workaround for the SBML one modification limit.

Definition at line 1776 of file test000092.cpp.

References CModification::getDate(), CModel::getKey(), CAnnotation::getMiriamAnnotation(), CCopasiDataModel::getModel(), CCopasiDataModel::importSBMLFromString(), CMIRIAMInfo::load(), MODEL_STRING10, pCOPASIDATAMODEL, and CCopasiVector< T >::size().

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 }
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000092.h:50
void load(const std::string &key="")
virtual size_t size() const
const std::string & getMiriamAnnotation() const
const std::string & getDate() const
Definition: CModified.cpp:70
static const char * MODEL_STRING10
Definition: test000092.h:49
const std::string & getKey() const
Definition: CModel.cpp:1142
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50

Member Data Documentation

const char * test000092::MODEL_STRING1
staticprotected

This model has complete MIRIAM compliant annotation, so of of it should be exported by libsbml and in addition to that as annotation in the COPASI namespace.

Definition at line 40 of file test000092.h.

Referenced by test_miriam_export_1().

const char * test000092::MODEL_STRING10
staticprotected

Definition at line 49 of file test000092.h.

Referenced by test_miriam_import_1().

const char * test000092::MODEL_STRING2
staticprotected

In this model the Model history is incomplete because there is no creator and no modified date so libsbml 4 will no longer write the model history. Nevertheless the annotation should be written in the COPASI namespace.

Definition at line 41 of file test000092.h.

Referenced by test_miriam_export_2().

const char * test000092::MODEL_STRING3
staticprotected
Initial value:
=
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<!-- generated with COPASI 4.5.31 (Debug) (http://www.copasi.org) at 2010-04-21 14:00:12 UTC -->\n"
"<?oxygen RNGSchema=\"http://www.copasi.org/static/schema/CopasiML.rng\" type=\"xml\"?>\n"
"<COPASI xmlns=\"http://www.copasi.org/static/schema\" versionMajor=\"1\" versionMinor=\"0\" versionDevel=\"31\">\n"
" <Model key=\"Model_0\" name=\"New Model\" simulationType=\"time\" timeUnit=\"s\" volumeUnit=\"ml\" areaUnit=\"m²\" lengthUnit=\"m\" quantityUnit=\"mmol\" type=\"deterministic\">\n"
" <ListOfCompartments>\n"
" <Compartment key=\"Compartment_0\" name=\"Compartment\" simulationType=\"fixed\" dimensionality=\"3\"/>\n"
" </ListOfCompartments>\n"
" <StateTemplate>\n"
" <StateTemplateVariable objectReference=\"Model_0\"/>\n"
" <StateTemplateVariable objectReference=\"Compartment_0\"/>\n"
" </StateTemplate>\n"
" <InitialState type=\"initialState\">\n"
" 0 1 \n"
" </InitialState>\n"
" </Model>\n"
"</COPASI>\n"

In this model the Model there is no MIRIAM annotation. There should be no annotation in the exported SBML model.

Definition at line 42 of file test000092.h.

Referenced by test_miriam_export_3().

const char * test000092::MODEL_STRING4
staticprotected

This model has complete MIRIAM compliant annotation, so of of it should be exported by libsbml and in addition to that as annotation in the COPASI namespace. In addition there is layout information that should also end up in the annotation to the SBML model

Definition at line 43 of file test000092.h.

Referenced by test_miriam_export_4().

const char * test000092::MODEL_STRING5
staticprotected

In this model the Model history is incomplete because there is no creator and no modified date so libsbml 4 will no longer write the model history. Nevertheless the annotation should be written in the COPASI namespace. In addition there is layout information that should also end up in the annotation to the SBML model

Definition at line 44 of file test000092.h.

Referenced by test_miriam_export_5().

const char * test000092::MODEL_STRING6
staticprotected

In this model the Model there is no MIRIAM annotation. But the model has a layout, that should be exported as an annotation to the SBML Model,

Definition at line 45 of file test000092.h.

Referenced by test_miriam_export_6().

const char * test000092::MODEL_STRING7
staticprotected
Initial value:
=
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<sbml xmlns=\"http://www.sbml.org/sbml/level2/version4\" level=\"2\" version=\"4\">\n"
" <model metaid=\"COPASI1\" id=\"Model_1\" name=\"New Model\">\n"
" <annotation>\n"
" <SOMEANNOTATION xmlns=\"http://www.SOMEORGANISATION.org/\" />\n"
" </annotation>\n"
" <listOfCompartments>\n"
" <compartment metaid=\"COPASI2\" id=\"compartment_1\" name=\"Compartment\" size=\"1\">\n"
" <annotation>\n"
" <SOMEANNOTATION xmlns=\"http://www.SOMEORGANISATION.org/\" />\n"
" </annotation>\n"
" </compartment>\n"
" </listOfCompartments>\n"
" </model>\n"
"</sbml>\n"

This SBML model already contains an annotation. We load it and add some MIRIAM annotation and write it out again to check if MIRIAM annotation is correctly written even if another annotation exists.

Definition at line 46 of file test000092.h.

Referenced by test_miriam_export_7().

const char * test000092::MODEL_STRING8
staticprotected

This SBML model already contains RDF annotation and other annotation. We load it and modify the MIRIAM annotation and write it out again to check if MIRIAM annotation is correctly updated

Definition at line 47 of file test000092.h.

Referenced by test_miriam_export_8().

const char * test000092::MODEL_STRING9
staticprotected

This SBML model already contains RDF annotation and other annotation. It also contains COPASI RDF annotation. We load it and modify the MIRIAM annotation and write it out again to check if MIRIAM annotation is correctly updated and COPASI annotation is correctly replaced.

Definition at line 48 of file test000092.h.

Referenced by test_miriam_export_9().

CCopasiDataModel * test000092::pCOPASIDATAMODEL = NULL
staticprotected

The documentation for this class was generated from the following files: