Exemplo n.º 1
0
  void convertLayoutToL2()
  {    
    if (_doc == NULL || _doc->getModel() == NULL)
      return;

    layoutNsUri = "http://projects.eml.org/bcb/sbml/level2";
    layoutNs = new LayoutPkgNamespaces(2, 1);

#ifdef LIBSBML_HAS_PACKAGE_RENDER
    foundRenderElements = false;
    renderNsUri = "http://projects.eml.org/bcb/sbml/render/level2";
    renderNs = new RenderPkgNamespaces(2, 1);
#endif

    LayoutModelPlugin* plugin
      = (LayoutModelPlugin*)_doc->getModel()->getPlugin("layout");
    if (plugin == NULL) 
      return;


    ConversionProperties prop(new SBMLNamespaces(2, 4));
    prop.addOption("strict", false);
    prop.addOption("setLevelAndVersion", true);
    prop.addOption("ignorePackages", true);

    if (_doc->convert(prop) != LIBSBML_OPERATION_SUCCESS)
    {
      cout << "Conversion failed!" << endl;
      _doc->printErrors();
      exit(2);  
    }


    plugin->setElementNamespace(layoutNsUri);

    SBMLDocumentPlugin *docPlugin = (SBMLDocumentPlugin*)_doc->getPlugin("layout");
    if (docPlugin != NULL)
      docPlugin->setElementNamespace(layoutNsUri);


    updateNs(plugin->getListOfLayouts());

    _doc->getSBMLNamespaces()->removePackageNamespace(3, 1, "layout", 1);        

#ifdef LIBSBML_HAS_PACKAGE_RENDER
    SBMLDocumentPlugin *rdocPlugin = (SBMLDocumentPlugin*)_doc->getPlugin("render");
    if (rdocPlugin!= NULL)
      rdocPlugin->setElementNamespace(renderNsUri);
    _doc->getSBMLNamespaces()->removePackageNamespace(3, 1, "render", 1);        
#endif
  }
Exemplo n.º 2
0
  void convertLayoutToL3()
  {
    if (_doc == NULL || _doc->getModel() == NULL)
      return;


    layoutNsUri = "http://www.sbml.org/sbml/level3/version1/layout/version1";
    layoutNs = new LayoutPkgNamespaces(3, 1, 1);

#ifdef CONVERT_RENDER
    renderNsUri = "http://www.sbml.org/sbml/level3/version1/render/version1";
    renderNs = new RenderPkgNamespaces(3, 1, 1);
#endif

    LayoutModelPlugin* plugin = (LayoutModelPlugin*)_doc->getModel()->getPlugin("layout");
    if (plugin == NULL) 
      return;


    ConversionProperties prop(new SBMLNamespaces(3, 1));
    prop.addOption("strict", false);
    prop.addOption("setLevelAndVersion", true);
    prop.addOption("ignorePackages", true);

    _doc->convert(prop);

    plugin->setElementNamespace(layoutNsUri);

    SBMLDocumentPlugin *docPlugin = (SBMLDocumentPlugin*)_doc->getPlugin("layout");
    if (docPlugin != NULL)
      docPlugin->setElementNamespace(layoutNsUri);

    updateNs(plugin->getListOfLayouts());
    
    _doc->getSBMLNamespaces()->addPackageNamespace("layout", 1);
    _doc->setPackageRequired("layout", false);

#ifdef CONVERT_RENDER
    SBMLDocumentPlugin *rdocPlugin = (SBMLDocumentPlugin*)_doc->getPlugin("render");
    if (rdocPlugin != NULL)
      rdocPlugin->setElementNamespace(renderNsUri);
    _doc->getSBMLNamespaces()->addPackageNamespace("render", 1);
    _doc->setPackageRequired("render", false);
#endif

  }
Exemplo n.º 3
0
  void convertLayoutToL3()
  {
    if (_doc == NULL || _doc->getModel() == NULL)
      return;


    layoutNsUri = "http://www.sbml.org/sbml/level3/version1/layout/version1";
    layoutNs = new LayoutPkgNamespaces(3, 1, 1);

#ifdef LIBSBML_HAS_PACKAGE_RENDER
    renderNsUri = "http://www.sbml.org/sbml/level3/version1/render/version1";
    renderNs = new RenderPkgNamespaces(3, 1, 1);
#endif

    LayoutModelPlugin* plugin = (LayoutModelPlugin*)_doc->getModel()->getPlugin("layout");
    if (plugin == NULL) 
      return;


    ConversionProperties prop(new SBMLNamespaces(3, 1));
    prop.addOption("strict", false);
    prop.addOption("setLevelAndVersion", true);
    prop.addOption("ignorePackages", true);

    if (_doc->convert(prop) != LIBSBML_OPERATION_SUCCESS)
    {
      cout << "Conversion failed!" << endl;
      _doc->printErrors();
      exit(2);  
    }

    //plugin->setElementNamespace(layoutNsUri);

    SBMLDocumentPlugin *docPlugin = (SBMLDocumentPlugin*)_doc->getPlugin("layout");
    if (docPlugin != NULL)
      docPlugin->setElementNamespace(layoutNsUri);


    _doc->getSBMLNamespaces()->addPackageNamespace("layout", 1);
    _doc->setPackageRequired("layout", false);

#ifdef LIBSBML_HAS_PACKAGE_RENDER

    SBMLDocumentPlugin *rdocPlugin = (SBMLDocumentPlugin*)_doc->getPlugin("render");
    if (rdocPlugin != NULL)
    {
      //rdocPlugin->setElementNamespace(renderNsUri);      
      _doc->getSBMLNamespaces()->addPackageNamespace("render", 1);    
    }
    else
    {
      _doc->enablePackage(renderNsUri, "render", true);
    }
    _doc->setPackageRequired("render", false);

#endif

  }
Exemplo n.º 4
0
END_TEST

START_TEST ( test_RenderExtension_convertLevel )
{
    string filename(TestDataDirectory);
    filename += "FutileCycle.xml";
    // read document
    SBMLDocument* doc = readSBMLFromFile(filename.c_str());
    doc->checkConsistency();

    // assert all is good
    fail_unless (doc->getModel() != NULL);
    fail_unless (doc->getNumErrors(LIBSBML_SEV_ERROR) == 0);

    // convert to L3 *without* upgrading the layout / render package
    bool result = doc->setLevelAndVersion(3,1, false, true);
    fail_unless(result == true);

    // write to string
    std::string l3SBML = writeSBMLToStdString(doc);

    delete doc;

    // read string back
    doc = readSBMLFromString(l3SBML.c_str());
    doc->checkConsistency();

    // assert all is good
    fail_unless (doc->getModel() != NULL);
    fail_unless (doc->getNumErrors(LIBSBML_SEV_ERROR) == 0);

    delete doc;

    filename = TestDataDirectory;
    filename += "FutileCycle.xml";
    // read document
    doc = readSBMLFromFile(filename.c_str());

    SBMLNamespaces nsl3v1(3, 1);
    ConversionProperties prop(&nsl3v1);
    prop.addOption("strict", false);
    prop.addOption("setLevelAndVersion", true);
    prop.addOption("ignorePackages", true);

    fail_unless(doc->convert(prop) == LIBSBML_OPERATION_SUCCESS);

    // now upgrade layout / render package
    SBMLDocumentPlugin *docPlugin = (SBMLDocumentPlugin*)doc->getPlugin("layout");
    if (docPlugin != NULL)
        docPlugin->setElementNamespace(LayoutExtension::getXmlnsL3V1V1());
    doc->getSBMLNamespaces()->addPackageNamespace("layout", 1);
    doc->setPackageRequired("layout", false);


    docPlugin = (SBMLDocumentPlugin*)doc->getPlugin("render");
    if (docPlugin != NULL)
        docPlugin->setElementNamespace(RenderExtension::getXmlnsL3V1V1());
    else
        doc->enablePackage(RenderExtension::getXmlnsL3V1V1(), "render", true);

    doc->getSBMLNamespaces()->addPackageNamespace("render", 1);
    doc->setPackageRequired("render", false);


    doc->checkConsistency();

    // assert all is good
    fail_unless (doc->getModel() != NULL);
    fail_unless (doc->getNumErrors(LIBSBML_SEV_ERROR) == 0);

    //l3SBML = writeSBMLToString(doc);

    delete doc;
}