当前位置: 首页>>代码示例>>C++>>正文


C++ SBMLReader类代码示例

本文整理汇总了C++中SBMLReader的典型用法代码示例。如果您正苦于以下问题:C++ SBMLReader类的具体用法?C++ SBMLReader怎么用?C++ SBMLReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SBMLReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: START_TEST

END_TEST

START_TEST (test_GetMultipleObjects_noLocalParameters)
{
  SBMLReader        reader;
  SBMLDocument*     d;

  std::string filename(TestDataDirectory);
  filename += "multiple-ids.xml";


  d = reader.readSBML(filename);

 if (d == NULL)
  {
    fail("readSBML(\"multiple-ids.xml\") returned a NULL pointer.");
  }

  SBase* rxn = d->getElementBySId("J0");
  fail_unless(rxn != NULL);
  SBase* obj = rxn->getElementBySId("x");
  fail_unless(obj == NULL);
  obj = rxn->getElementByMetaId("meta28");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_LOCAL_PARAMETER);


  delete d;
}
开发者ID:0u812,项目名称:libsbml.js.frozen,代码行数:29,代码来源:TestGetMultipleObjects.cpp

示例2: getCurrentMillis

void SBMLParser::inputSBMLDocumentFromString(const char *str)
{
	SBMLReader *reader;
	unsigned long start, stop;
	start = getCurrentMillis();
	
	reader = new SBMLReader();
	document = reader->readSBMLFromString(str);
	stop = getCurrentMillis();
	
	unsigned int errors = document->getNumErrors();

	if (verbose)
	{
		cout << endl;
		cout << "            filename: <stdin>" << endl;
		cout << "           file size: "<< strlen(str)    << endl;
		cout << "      read time (ms): " << stop - start          << endl;
		cout << " validation error(s): " << errors                << endl;
		cout << endl;
	}

	document->printErrors(cerr);
	delete reader; 
	
}
开发者ID:sba1,项目名称:biozim,代码行数:26,代码来源:SBMLParser.cpp

示例3: InitializeFromFile

void SBMLmodel::InitializeFromFile(std::string &sFileName)
{
	SBMLReader oReader;
	_Document = oReader.readSBML(sFileName);
	_Model = _Document->getModel();
	if (_Model == NULL)
		throw new ApplicationException("Invalid SBML Model", "The SBML model was invalid. Please validate it using a SBML validator such as: http://sys-bio.org/validate.");
}
开发者ID:mgaldzic,项目名称:copasi_api,代码行数:8,代码来源:sbmlmodel.cpp

示例4: main

BEGIN_C_DECLS

int
main (int argc, char* argv[])
{
    if (argc != 2)
    {
        cout << endl << "Usage: getAllElementsWithNotes filename" << endl << endl;
        return 1;
    }
    
    const char* filename   = argv[1];
    
        
    SBMLDocument* document;
    SBMLReader reader;
#ifdef __BORLANDC__
    unsigned long start, stop;
#else
    unsigned long long start, stop;
#endif
    
    start    = getCurrentMillis();
    document = reader.readSBML(filename);
    stop     = getCurrentMillis();
    
    unsigned int errors = document->getNumErrors(LIBSBML_SEV_ERROR);
    
    cout << endl;
    cout << "            filename: " << filename              << endl;
    cout << "      read time (ms): " << stop - start          << endl;
    
    if (errors > 0)
    {
		cout << "            error(s): " << errors << endl;
        document->printErrors(cerr);
        delete document;
        return errors;
    }
    
	start = stop;
	
	// create the filter we want to use
    NotesFilter filter;
	//  get a list of all elements with notes
	cout << "    searching ......:" << endl;
	List* allElements = document->getAllElements(&filter); 
	stop     = getCurrentMillis();
	cout << "    search time (ms): " << stop - start          << endl;
	cout << " elements with notes: " << allElements->getSize() << endl;
	
    delete document;
    return errors;
}
开发者ID:sys-bio,项目名称:libroadrunner-deps,代码行数:54,代码来源:getAllElementsWithNotes.cpp

示例5: loadSBML

void SBML_sim::loadSBML(std::string sbml_text, bool isFile)
{
	SBMLReader * sbmlreader = new SBMLReader;
	SBMLDocument * doc;
	
	if (isFile)
		doc = sbmlreader->readSBML(sbml_text);
	else
		doc = sbmlreader->readSBMLFromString(sbml_text); 
		
	loadSBML(doc);
	delete doc;
	delete sbmlreader;
}
开发者ID:mgaldzic,项目名称:copasi_api,代码行数:14,代码来源:sbml_sim.cpp

示例6: validate

/*
 * Validates the given SBMLDocument.  Failures logged during
 * validation may be retrieved via <code>getFailures()</code>.
 *
 * @return the number of validation errors that occurred.
 */
unsigned int
Validator::validate (const std::string& filename)
{
  SBMLReader    reader;
  SBMLDocument& d = *reader.readSBML(filename);


  for (unsigned int n = 0; n < d.getNumErrors(); ++n)
  {
    logFailure( *d.getError(n) );
  }

  return validate(d);
}
开发者ID:mgaldzic,项目名称:copasi_api,代码行数:20,代码来源:Validator.cpp

示例7: logFailure

/*
 * Validates the given SBMLDocument.  Failures logged during
 * validation may be retrieved via <code>getFailures()</code>.
 *
 * @return the number of validation errors that occurred.
 */
unsigned int
QualValidator::validate (const std::string& filename)
{
  SBMLReader    reader;
  SBMLDocument* d = reader.readSBML(filename);


  for (unsigned int n = 0; n < d->getNumErrors(); ++n)
  {
    logFailure( *(d->getError(n)) );
  }

  unsigned int ret = validate(*d);
  delete d;
  return ret;
}
开发者ID:sys-bio,项目名称:libroadrunner-deps,代码行数:22,代码来源:QualValidator.cpp

示例8: START_TEST

END_TEST


START_TEST (test_SBMLTransforms_replaceIA_species)
{
  SBMLReader        reader;
  SBMLDocument*     d;
  Model*            m;
  const ASTNode*          ast;
  FunctionDefinition*     fd;
  ListOfFunctionDefinitions * lofd;

  std::string filename(TestDataDirectory);
  filename += "initialAssignments_species.xml";


  d = reader.readSBML(filename);

  if (d == NULL)
  {
    fail("readSBML(\"initialAssignments_species.xml\") returned a NULL pointer.");
  }

  m = d->getModel();

  fail_unless( m->getNumInitialAssignments() == 3 );
  fail_unless( m->getParameter(1)->getValue() == 0.75);
  fail_unless( !(m->getParameter(2)->isSetValue()));
  fail_unless( m->getSpecies(2)->isSetInitialAmount());
  fail_unless( m->getSpecies(2)->getInitialAmount() == 2);

  d->expandInitialAssignments();

  m = d->getModel();

  fail_unless( m->getNumInitialAssignments() == 0 );
  fail_unless( m->getParameter(1)->getValue() == 3);
  fail_unless( m->getParameter(2)->isSetValue());
  fail_unless( m->getParameter(2)->getValue() == 0.75);
  fail_unless( !(m->getSpecies(2)->isSetInitialAmount()));
  fail_unless( m->getSpecies(2)->getInitialConcentration() == 2);
  
}
开发者ID:alexholehouse,项目名称:SBMLIntegrator,代码行数:43,代码来源:TestSBMLTransforms.cpp

示例9: main

LIBSBML_CPP_NAMESPACE_USE

BEGIN_C_DECLS

int
main (int argc, char* argv[])
{
  if (argc != 2)
  {
    cout << endl << "Usage: readSBML filename" << endl << endl;
    return 1;
  }

  const char* filename   = argv[1];
  SBMLDocument* document;
  SBMLReader reader;
#ifdef __BORLANDC__
  unsigned long start, stop;
#else
  unsigned long long start, stop;
#endif

  start    = getCurrentMillis();
  document = reader.readSBML(filename);
  stop     = getCurrentMillis();

  unsigned int errors = document->getNumErrors();

  cout << endl;
  cout << "            filename: " << filename              << endl;
  cout << "           file size: " << getFileSize(filename) << endl;
  cout << "      read time (ms): " << stop - start          << endl;
  cout << " validation error(s): " << errors << endl;
  cout << endl;

  document->printErrors(cerr);

  delete document;
  return errors;
}
开发者ID:copasi,项目名称:copasi-dependencies,代码行数:40,代码来源:readSBML.cpp

示例10: START_TEST

END_TEST


START_TEST (test_SBMLTransforms_replaceIA)
{
  SBMLReader        reader;
  SBMLDocument*     d;
  Model*            m;

  std::string filename(TestDataDirectory);
  filename += "initialAssignments.xml";


  d = reader.readSBML(filename);

  if (d == NULL)
  {
    fail("readSBML(\"initialAssignments.xml\") returned a NULL pointer.");
  }

  m = d->getModel();

  fail_unless( m->getNumInitialAssignments() == 2 );
  fail_unless( !(m->getCompartment(0)->isSetSize()));
  fail_unless( m->getParameter(1)->getValue() == 2);

  d->expandInitialAssignments();

  m = d->getModel();

  fail_unless( m->getNumInitialAssignments() == 0 );
  fail_unless( m->getCompartment(0)->isSetSize());
  fail_unless( m->getCompartment(0)->getSize() == 25.0);
  fail_unless( m->getParameter(1)->getValue() == 50);
  
}
开发者ID:0u812,项目名称:libsbml.js.frozen,代码行数:36,代码来源:TestSBMLTransforms.cpp

示例11: main

LIBSBML_CPP_NAMESPACE_USE

BEGIN_C_DECLS

int
main (int argc, char* argv[])
{
    if (argc != 5)
    {
        cout << endl << "Usage: renameSId filename oldSId newSId output" << endl << endl;
        return 1;
    }
    
    const char* filename   = argv[1];
    const char* oldSId     = argv[2];
    const char* newSId     = argv[3];
    const char* output     = argv[4];
    
    
    if (strcmp(oldSId, newSId) == 0)
    {
        cout << "The Ids are identical, renaming stopped." << endl;
        return 1;
    }

    if (!SyntaxChecker::isValidInternalSId(newSId))
    {
        cout << "The new SId '" << newSId
             << "' does not represent a valid SId."
             << endl;
        return 1;
    }
    
    
    SBMLDocument* document;
    SBMLReader reader;
#ifdef __BORLANDC__
    unsigned long start, stop;
#else
    unsigned long long start, stop;
#endif
    
    start    = getCurrentMillis();
    document = reader.readSBML(filename);
    stop     = getCurrentMillis();
    
    unsigned int errors = document->getNumErrors(LIBSBML_SEV_ERROR);
    
    cout << endl;
    cout << "            filename: " << filename              << endl;
    cout << "           file size: " << getFileSize(filename) << endl;
    cout << "      read time (ms): " << stop - start          << endl;
    cout << "            error(s): " << errors << endl;
    cout << endl;
    
    if (errors > 0)
    {
        document->printErrors(cerr);
        delete document;
        return errors;
    }
    
    // find elements for old id
    SBase* element = document->getElementBySId(oldSId);
    if (element == NULL)
    {
        cout << "Found no element with SId '"
             << oldSId << "'." << endl;
        return 1;
    }
    
    // found element --> renaming
    element->setId(newSId);

    // update all references to this element
    List *allElements = document->getAllElements();
    for (unsigned int i = 0; i < allElements->getSize(); ++i)
        static_cast<SBase*>(allElements->get(i))->renameSIdRefs(oldSId, newSId);
    
    
    // write to file
    writeSBMLToFile(document, output);
    
    delete document;
    return errors;
}
开发者ID:sys-bio,项目名称:libroadrunner-deps,代码行数:86,代码来源:renameSId.cpp

示例12: main

int
main (int argc, char* argv[])
{
  if (argc != 2)
  {
    cout << endl << "Usage: printNotes filename" << endl << endl;
    return 1;
  }

  unsigned int i,j;
  const char* filename   = argv[1];
  SBMLDocument* document;
  SBMLReader reader;

  document = reader.readSBML(filename);

  unsigned int errors = document->getNumErrors();

  cout << endl;
  cout << "filename: " << filename << endl;
  cout << endl;

  if(errors > 0)
  {
    document->printErrors(cerr);
    delete document;

    return errors;
  }

  /* Model */

  Model* m = document->getModel();
  printNotes(m);

  for(i=0; i < m->getNumReactions(); i++)
  {
    Reaction* re = m->getReaction(i);
    printNotes(re);

    /* SpeciesReference (Reacatant) */

    for(j=0; j < re->getNumReactants(); j++)
    {
      SpeciesReference* rt = re->getReactant(j);
      if (rt->isSetNotes()) cout << "   ";
      printNotes(rt, (rt->isSetSpecies() ? rt->getSpecies() : std::string("")) );
    }

    /* SpeciesReference (Product) */

    for(j=0; j < re->getNumProducts(); j++)
    {
      SpeciesReference* rt = re->getProduct(j);
      if (rt->isSetNotes()) cout << "   ";
      printNotes(rt, (rt->isSetSpecies() ? rt->getSpecies() : std::string("")) );
    }

    /* ModifierSpeciesReference (Modifier) */

    for(j=0; j < re->getNumModifiers(); j++)
    {
      ModifierSpeciesReference* md = re->getModifier(j);
      if (md->isSetNotes()) cout << "   ";
      printNotes(md, (md->isSetSpecies() ? md->getSpecies() : std::string("")) );
    }

    /* Kineticlaw */

    if(re->isSetKineticLaw())
    {
      KineticLaw* kl = re->getKineticLaw();
      if (kl->isSetNotes()) cout << "   ";
      printNotes(kl);

      /* Parameter */

      for(j=0; j < kl->getNumParameters(); j++)
      {
        Parameter* pa = kl->getParameter(j);
        if (pa->isSetNotes()) cout << "      ";
        printNotes(pa);
      }
    }

  }

  /* Species */

  for(i=0; i < m->getNumSpecies(); i++)
  {
    Species* sp = m->getSpecies(i);
    printNotes(sp);
  }

  /* Compartment */

  for(i=0; i < m->getNumCompartments(); i++)
  {
    Compartment* sp = m->getCompartment(i);
//.........这里部分代码省略.........
开发者ID:sys-bio,项目名称:libroadrunner-deps,代码行数:101,代码来源:printNotes.cpp

示例13: CPPUNIT_ASSERT

// tests whether we are importing global render information
void test000098::test_export_notes()
{
  CPPUNIT_ASSERT(pDataModel != NULL);
  std::istringstream iss(test000098::CPS_MODEL_1);
  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
  std::string s;

  try
    {
      s = pDataModel->exportSBMLToString(NULL, 2, 1);
    }
  catch (...)
    {
      CPPUNIT_ASSERT(false);
    }

  CPPUNIT_ASSERT(!s.empty());
  SBMLReader reader;
  SBMLDocument* pSBMLDocument = NULL;

  try
    {
      pSBMLDocument = reader.readSBMLFromString(s);
    }
  catch (...)
    {
      CPPUNIT_ASSERT(false);
    }

  CPPUNIT_ASSERT(pSBMLDocument != NULL);
  Model* pModel = pSBMLDocument->getModel();
  CPPUNIT_ASSERT(pModel != NULL);
  CPPUNIT_ASSERT(pModel->isSetNotes() == true);
  std::string notes = pModel->getNotesString();
  CPPUNIT_ASSERT(!notes.empty());
  CPPUNIT_ASSERT(notes.find("Simple note on model") != std::string::npos);

  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
  CPPUNIT_ASSERT(pModel->getNumSpecies() == 1);
  CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
  CPPUNIT_ASSERT(pModel->getNumReactions() == 1);
  CPPUNIT_ASSERT(pModel->getNumEvents() == 1);
  // compartment
  SBase* pObject = pModel->getCompartment(0);
  CPPUNIT_ASSERT(pObject != NULL);
  CPPUNIT_ASSERT(pObject->isSetNotes() == true);
  notes = pObject->getNotesString();
  CPPUNIT_ASSERT(!notes.empty());
  CPPUNIT_ASSERT(notes.find("Simple note on compartment") != std::string::npos);
  // species
  pObject = pModel->getSpecies(0);
  CPPUNIT_ASSERT(pObject != NULL);
  CPPUNIT_ASSERT(pObject->isSetNotes() == true);
  notes = pObject->getNotesString();
  CPPUNIT_ASSERT(!notes.empty());
  CPPUNIT_ASSERT(notes.find("Simple note on species") != std::string::npos);
  // parameter
  pObject = pModel->getParameter(0);
  CPPUNIT_ASSERT(pObject != NULL);
  CPPUNIT_ASSERT(pObject->isSetNotes() == true);
  notes = pObject->getNotesString();
  CPPUNIT_ASSERT(!notes.empty());
  CPPUNIT_ASSERT(notes.find("Simple note on parameter") != std::string::npos);
  // reaction
  pObject = pModel->getReaction(0);
  CPPUNIT_ASSERT(pObject != NULL);
  CPPUNIT_ASSERT(pObject->isSetNotes() == true);
  notes = pObject->getNotesString();
  CPPUNIT_ASSERT(!notes.empty());
  CPPUNIT_ASSERT(notes.find("Simple note on reaction") != std::string::npos);
  // event
  pObject = pModel->getEvent(0);
  CPPUNIT_ASSERT(pObject != NULL);
  CPPUNIT_ASSERT(pObject->isSetNotes() == true);
  notes = pObject->getNotesString();
  CPPUNIT_ASSERT(!notes.empty());
  CPPUNIT_ASSERT(notes.find("Simple note on event") != std::string::npos);
}
开发者ID:copasi,项目名称:COPASI,代码行数:79,代码来源:test000098.cpp

示例14: main

BEGIN_C_DECLS

int
main (int argc, char* argv[])
{
    if (argc != 3)
    {
        cout << endl << "Usage: setNamesFromIds filename output" << endl << endl;
        return 1;
    }
    
    const char* filename   = argv[1];
    const char* output     = argv[2];
    
        
    SBMLDocument* document;
    SBMLReader reader;
#ifdef __BORLANDC__
    unsigned long start, stop;
#else
    unsigned long long start, stop;
#endif
    
    start    = getCurrentMillis();
    document = reader.readSBML(filename);
    stop     = getCurrentMillis();
    
    unsigned int errors = document->getNumErrors(LIBSBML_SEV_ERROR);
    
    cout << endl;
    cout << "            filename: " << filename              << endl;
    cout << "      read time (ms): " << stop - start          << endl;
    
    if (errors > 0)
    {
		cout << "            error(s): " << errors << endl;
        document->printErrors(cerr);
        delete document;
        return errors;
    }
    
	start = stop;
	
	// get a list of all elements, as we will need to know all identifiers
	List* allElements = document->getAllElements(); 
	
	// create the transformer 
	NameIdTransformer trans;
	
	// rename the identifiers (using the elements we already gathered before)
	document->getModel()->renameIDs(allElements, &trans);    
	stop     = getCurrentMillis();
	cout << "    rename time (ms): " << stop - start          << endl;
	start = stop;
	
    // write to file
    writeSBMLToFile(document, output);
    stop     = getCurrentMillis();
	cout << "     write time (ms): " << stop - start          << endl;   
	cout << endl;
	
    delete document;
    return errors;
}
开发者ID:kirichoi,项目名称:roadrunner,代码行数:64,代码来源:setNamesFromIds.cpp

示例15: START_TEST

END_TEST

START_TEST (test_RemoveFromParent_alreadyRemoved)
{
  SBMLReader        reader;
  SBMLDocument*     d;

  std::string filename(TestDataDirectory);
  filename += "multiple-ids.xml";


  d = reader.readSBML(filename);

  if (d == NULL)
  {
    fail("readSBML(\"multiple-ids.xml\") returned a NULL pointer.");
  }
  SBase* obj;

  //List of function definitions
  obj = d->getElementByMetaId("meta20");
  fail_unless(obj != NULL);
  fail_unless(obj->removeFromParentAndDelete() == LIBSBML_OPERATION_SUCCESS);
  obj = d->getElementByMetaId("meta20");
  fail_unless(obj == NULL);

  //Function definition
  obj = d->getElementByMetaId("meta21");
  fail_unless(obj == NULL);

  //Unit Definition
  obj = d->getElementByMetaId("meta30");
  fail_unless(obj != NULL);
  fail_unless(obj->removeFromParentAndDelete() == LIBSBML_OPERATION_SUCCESS);
  obj = d->getElementByMetaId("meta30");
  fail_unless(obj == NULL);

  //Unit
  obj = d->getElementByMetaId("meta32");
  fail_unless(obj == NULL);

  //List of units
  obj = d->getElementByMetaId("meta31");
  fail_unless(obj == NULL);

  //List of compartments
  obj = d->getElementByMetaId("meta3");
  fail_unless(obj != NULL);
  fail_unless(obj->removeFromParentAndDelete() == LIBSBML_OPERATION_SUCCESS);
  obj = d->getElementByMetaId("meta3");
  fail_unless(obj == NULL);

  //Compartment
  obj = d->getElementByMetaId("meta4");
  fail_unless(obj == NULL);

  //List of species
  obj = d->getElementByMetaId("meta5");
  fail_unless(obj != NULL);
  fail_unless(obj->removeFromParentAndDelete() == LIBSBML_OPERATION_SUCCESS);
  obj = d->getElementByMetaId("meta5");
  fail_unless(obj == NULL);

  //Species
  obj = d->getElementByMetaId("meta6");
  fail_unless(obj == NULL);

  //Kinetic law
  obj = d->getElementByMetaId("meta11");
  fail_unless(obj != NULL);
  fail_unless(obj->removeFromParentAndDelete() == LIBSBML_OPERATION_SUCCESS);
  obj = d->getElementByMetaId("meta11");
  fail_unless(obj == NULL);

  //Local parameter
  obj = d->getElementByMetaId("meta28");
  fail_unless(obj == NULL);

  //List of local parameters
  obj = d->getElementByMetaId("meta27");
  fail_unless(obj == NULL);

  //List of modifiers
  obj = d->getElementByMetaId("meta34");
  fail_unless(obj != NULL);
  fail_unless(obj->removeFromParentAndDelete() == LIBSBML_OPERATION_SUCCESS);
  obj = d->getElementByMetaId("meta34");
  fail_unless(obj == NULL);

  //Modifier species reference
  obj = d->getElementByMetaId("meta35");
  fail_unless(obj == NULL);

  //Reaction
  obj = d->getElementByMetaId("meta8");
  fail_unless(obj != NULL);
  fail_unless(obj->removeFromParentAndDelete() == LIBSBML_OPERATION_SUCCESS);
  obj = d->getElementByMetaId("meta8");
  fail_unless(obj == NULL);

//.........这里部分代码省略.........
开发者ID:TotteKarlsson,项目名称:roadrunner,代码行数:101,代码来源:TestRemoveFromParent.cpp


注:本文中的SBMLReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。