Ejemplo n.º 1
0
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; 
	
}
Ejemplo n.º 2
0
void SBMLmodel::InitializeFromSBML(std::string &sSBML)
{
	SBMLReader oReader;
	_Document = oReader.readSBMLFromString(sSBML);
	_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.");

}
Ejemplo n.º 3
0
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;
}
Ejemplo n.º 4
0
// 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);
}