Ejemplo n.º 1
0
void SBMLParser::inputSBMLDocument(const char *fname)
{
	SBMLReader *reader;
	unsigned long start, stop;
	start = getCurrentMillis();
	
	reader = new SBMLReader();
	document = reader->readSBML(fname);
	stop = getCurrentMillis();
	
	unsigned int errors = document->getNumErrors();

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

	document->printErrors(cerr);
	delete reader; 
}
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;
}
END_TEST


START_TEST (test_GetMultipleObjects_noUnits)
{
  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 = d->getElementBySId("volume");
  fail_unless(obj == NULL);
  obj = d->getElementByMetaId("meta30");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_UNIT_DEFINITION);


  delete d;
}
Ejemplo n.º 4
0
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.");
}
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;
}
Ejemplo n.º 6
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.º 7
0
/*
 * 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);
}
Ejemplo n.º 8
0
/*
 * 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;
}
END_TEST


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

  std::string filename(TestDataDirectory);
  filename += "assignments-invalid.xml";


  d = reader.readSBML(filename);

 if (d->getModel() == NULL)
  {
    fail("readSBML(\"assignments-invalid.xml\") returned an empty model.");
  }

  SBase* obj = d->getElementBySId("ia");
  fail_unless(obj == NULL);
  obj = d->getElementByMetaId("ia_meta");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_INITIAL_ASSIGNMENT);

  obj = d->getElementBySId("ar");
  fail_unless(obj == NULL);
  obj = d->getElementByMetaId("ar_meta");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_ASSIGNMENT_RULE);

  obj = d->getElementBySId("rr");
  fail_unless(obj == NULL);
  obj = d->getElementByMetaId("rr_meta");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_RATE_RULE);

  obj = d->getElementBySId("ea");
  fail_unless(obj == NULL);
  obj = d->getElementByMetaId("ea_meta");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_EVENT_ASSIGNMENT);


  delete d;
}
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);
  
}
Ejemplo n.º 11
0
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;
}
END_TEST


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

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


  d = reader.readSBML(filename);

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

  List* list = d->getAllElements();
  fail_unless(list->getSize() == 37);
  delete list;
  delete d;
}
Ejemplo n.º 13
0
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);
  
}
Ejemplo n.º 14
0
/** 
 * Load a gene network from an SBML file. Overrides Structure.load(). Format must
 * be equal GeneNetwork.SBML. Note, the SBML file must be in the exact same format
 * as the SBML files produced by writeSBML(). In particular, we assume that reactions are listed
 * *ordered* as we do in writeSBML().
 * @param filename URL to the file describing the network to load
 * @param format File format (GML, DOT, etc.)
 * @throws IOException 
 */
void GeneNetwork::load_sbml(const char *filename) {
	SBMLDocument* document;
  	SBMLReader reader;

  	document = reader.readSBML(filename);

  	unsigned int errors = document->getNumErrors();
	if (errors > 0) {
        std::cerr << "Failed to open file " << filename << std::endl;
        exit(1);
    }

	Model *m = document->getModel();

	// -----------------------------------------
	// Set the network size and create the genes
	// do not count the species _void_
	int size = m->getNumSpecies() - 1;
	ListOfSpecies *species = m->getListOfSpecies();
	
	for (int g=0; g < size; g++) {
		if (species->get(g)->getId() != "_void_") {
			//HillGene hg = new HillGene(this);
			//hg.setLabel(species.get(g).getId());
			HillGene *n = new HillGene(species->get(g)->getId());
			//n.setLabel(species->get(g)->getId());
			nodes_.push_back(*n);
			delete n;
		}
	}
	
	x_ = Vec_DP(nodes_.size());
	x_ = 0;
	y_ = Vec_DP(nodes_.size());
	y_ = 0;
	
	//vector<string> parameterNames; // the names of the parameters
	//vector<double> parameterValues; // the values of the parameters
	std::map<std::string, double> params;
	std::vector<std::string> inputNodes; // the indexes of the inputs
	HillGene src, tgt;
	Parameter *param;
	
	// 2 loops for one gene: both synthesis and degradation reactions
	// (we assume that reactions are listed *ordered* as we do in writeSBML())
	//int counter = 0;
	for (unsigned int i=0; i < m->getNumReactions(); i++) {
		Reaction *re = m->getReaction(i);
		std::string id = re->getId();
		
		std::stringstream ss;
		ss << i;
		//::logging::log::emit<Debug>() << id.c_str() <<
		//		::logging::log::endl;
	
		tgt = nodes_.at(getIndexOfNode(getGeneReactantId(id)));
		//tgt->setLabel(getGeneReactantId(*re));
      	//SpeciesReference *rt = re->getReactant(0);
      	//Node *tgt = new HillGene();
      	//tgt->setLabel(rt->getSpecies());
      	//ListOfSpeciesReferences *modifiers = re->getListOfModifiers();

    	for (unsigned int j=0; j < re->getNumModifiers(); j++) {
      		ModifierSpeciesReference *md = re->getModifier(j);
      		src = nodes_.at(getIndexOfNode(md->getSpecies()));      		
      		inputNodes.push_back(src.getLabel());
      		
            // set output genes
            std::vector<std::string> outputs = src.getOutputGenes();
            outputs.push_back(tgt.getLabel());
            src.setOutputGenes(outputs);
      		
            // The edge type is unknown for now, it is initialized later
      		Edge *e = new Edge(&src, &tgt, "+-");
			edges_.push_back(*e);
			//delete src;
			delete e;
		}

      	KineticLaw *kl = re->getKineticLaw();
      		
      	for(unsigned int j=0; j < kl->getNumParameters(); j++) {
        	param = kl->getParameter(j);
			params[param->getId()] = param->getValue();
			//char buf[256];
      		//sprintf(buf, "%s\t%f", param->getId().c_str(), param->getValue());
			//::logging::log::emit<Info>() << buf <<	::logging::log::endl;
		}
		
		//::logging::log::emit<Info>() << ::logging::log::dec << params.size() <<
		//		::logging::log::endl;
		
		// in the second iteration for this gene
		if (i%2 == 1) {
			// set parameters in gene
			//tgt.initialization(params, inputNodes);
			nodes_.at(getIndexOfNode(getGeneReactantId(id))).initialization(params, inputNodes);;
			//char buf[256];
			//sprintf(buf, "%f", params["k_1"]);
			//::logging::log::emit<Info>() << buf << ::logging::log::endl;
			
			inputNodes.clear(); // don't clear because the reference was copied to the gene
			//parameterNames.clear(); // reset (they were not copied)
			//parameterValues.clear();
			params.clear();
		}
		//counter++;
	}
	//setEdgeTypesAccordingToDynamicalModel();
	//signed_ = true;
	
	//delete document;
	//delete n;
	//delete e;
}
Ejemplo n.º 15
0
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;
}
Ejemplo n.º 16
0
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);
    printNotes(sp);
  }

  /* FunctionDefinition */

  for(i=0; i < m->getNumFunctionDefinitions(); i++)
  {
    FunctionDefinition* sp = m->getFunctionDefinition(i);
    printNotes(sp);
  }

  /* UnitDefinition */

  for(i=0; i < m->getNumUnitDefinitions(); i++)
  {
    UnitDefinition* sp = m->getUnitDefinition(i);
    printNotes(sp);
  }

  /* Parameter */

  for(i=0; i < m->getNumParameters(); i++)
  {
    Parameter* sp = m->getParameter(i);
    printNotes(sp);
  }

  /* Rule */

  for(i=0; i < m->getNumRules(); i++)
  {
    Rule* sp = m->getRule(i);
    printNotes(sp);
  }

  /* InitialAssignment */

  for(i=0; i < m->getNumInitialAssignments(); i++)
  {
    InitialAssignment* sp = m->getInitialAssignment(i);
    printNotes(sp);
  }

  /* Event */

  for(i=0; i < m->getNumEvents(); i++)
  {
    Event* sp = m->getEvent(i);
    printNotes(sp);

    /* Trigger */

    if(sp->isSetTrigger())
    {
      const Trigger* tg = sp->getTrigger();
      if (tg->isSetNotes()) cout << "   ";
      printNotes(const_cast<Trigger*>(tg));
    }

    /* Delay */

    if(sp->isSetDelay())
    {
      const Delay* dl = sp->getDelay();
      if (dl->isSetNotes()) cout << "   ";
      printNotes(const_cast<Delay*>(dl));
    }

    /* EventAssignment */

    for(j=0; j < sp->getNumEventAssignments(); j++)
    {
      EventAssignment* ea = sp->getEventAssignment(j);
      if (ea->isSetNotes()) cout << "   ";
      printNotes(ea);
    }
  }

  /* SpeciesType */

  for(i=0; i < m->getNumSpeciesTypes(); i++)
  {
    SpeciesType* sp = m->getSpeciesType(i);
    printNotes(sp);
  }

  /* Constraint */

  for(i=0; i < m->getNumConstraints(); i++)
  {
    Constraint* sp = m->getConstraint(i);
    printNotes(sp);
  }

  delete document;
  return errors;
}
Ejemplo n.º 17
0
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;
}
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);

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

  //List of reactants
  obj = d->getElementByMetaId("meta9");
  fail_unless(obj == NULL);

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

  //Parameter
  obj = d->getElementByMetaId("meta18");
  fail_unless(obj == NULL);

  //List of event assignments
  obj = d->getElementByMetaId("meta15");
  fail_unless(obj != NULL);
  fail_unless(obj->removeFromParentAndDelete() == LIBSBML_OPERATION_SUCCESS);
  obj = d->getElementByMetaId("meta15");
  fail_unless(obj == NULL);

  //Event assignment
  obj = d->getElementByMetaId("meta16");
  fail_unless(obj == NULL);

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

  //Trigger
  obj = d->getElementByMetaId("meta14");
  fail_unless(obj == NULL);

  //Delay
  obj = d->getElementByMetaId("meta17");
  fail_unless(obj == NULL);

  //Priority
  obj = d->getElementByMetaId("meta19");
  fail_unless(obj == NULL);

  //List of initial assignments
  obj = d->getElementByMetaId("meta22");
  fail_unless(obj != NULL);
  fail_unless(obj->removeFromParentAndDelete() == LIBSBML_OPERATION_SUCCESS);
  obj = d->getElementByMetaId("meta22");
  fail_unless(obj == NULL);

  //Initial assignment
  obj = d->getElementByMetaId("meta23");
  fail_unless(obj == NULL);

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

  //Rate rule
  obj = d->getElementByMetaId("meta25");
  fail_unless(obj == NULL);

  //Assignment rule
  obj = d->getElementByMetaId("meta26");
  fail_unless(obj == NULL);


  delete d;
}
END_TEST


START_TEST (test_GetMultipleObjects_getMetaId)
{
  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 = d->getElementByMetaId("no_id");
  fail_unless(obj == NULL);

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

  obj = d->getElementByMetaId("meta1");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_DOCUMENT);

  obj = d->getElementByMetaId("meta2");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_MODEL);

  obj = d->getElementByMetaId("meta3");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_LIST_OF);
  fail_unless(static_cast<ListOf*>(obj)->getItemTypeCode() == SBML_COMPARTMENT);

  obj = d->getElementByMetaId("meta4");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_COMPARTMENT);

  obj = d->getElementByMetaId("meta5");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_LIST_OF);
  fail_unless(static_cast<ListOf*>(obj)->getItemTypeCode() == SBML_SPECIES);

  obj = d->getElementByMetaId("meta6");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_SPECIES);

  obj = d->getElementByMetaId("meta7");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_LIST_OF);
  fail_unless(static_cast<ListOf*>(obj)->getItemTypeCode() == SBML_REACTION);

  obj = d->getElementByMetaId("meta8");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_REACTION);

  obj = d->getElementByMetaId("meta9");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_LIST_OF);
  fail_unless(static_cast<ListOf*>(obj)->getItemTypeCode() == SBML_SPECIES_REFERENCE);

  obj = d->getElementByMetaId("meta10");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_SPECIES_REFERENCE);

  obj = d->getElementByMetaId("meta11");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_KINETIC_LAW);

  obj = d->getElementByMetaId("meta12");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_LIST_OF);
  fail_unless(static_cast<ListOf*>(obj)->getItemTypeCode() == SBML_EVENT);

  obj = d->getElementByMetaId("meta13");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_EVENT);

  obj = d->getElementByMetaId("meta14");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_TRIGGER);

  obj = d->getElementByMetaId("meta15");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_LIST_OF);
  fail_unless(static_cast<ListOf*>(obj)->getItemTypeCode() == SBML_EVENT_ASSIGNMENT);

  obj = d->getElementByMetaId("meta16");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_EVENT_ASSIGNMENT);

  obj = d->getElementByMetaId("meta17");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_DELAY);

  obj = d->getElementByMetaId("meta18");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_PARAMETER);

  obj = d->getElementByMetaId("meta19");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_PRIORITY);

  obj = d->getElementByMetaId("meta20");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_LIST_OF);
  fail_unless(static_cast<ListOf*>(obj)->getItemTypeCode() == SBML_FUNCTION_DEFINITION);

  obj = d->getElementByMetaId("meta21");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_FUNCTION_DEFINITION);

  obj = d->getElementByMetaId("meta22");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_LIST_OF);
  fail_unless(static_cast<ListOf*>(obj)->getItemTypeCode() == SBML_INITIAL_ASSIGNMENT);

  obj = d->getElementByMetaId("meta23");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_INITIAL_ASSIGNMENT);

  obj = d->getElementByMetaId("meta24");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_LIST_OF);
  fail_unless(static_cast<ListOf*>(obj)->getItemTypeCode() == SBML_RULE);

  obj = d->getElementByMetaId("meta25");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_RATE_RULE);

  obj = d->getElementByMetaId("meta26");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_ASSIGNMENT_RULE);

  obj = d->getElementByMetaId("meta27");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_LIST_OF);
  fail_unless(static_cast<ListOf*>(obj)->getItemTypeCode() == SBML_LOCAL_PARAMETER);

  obj = d->getElementByMetaId("meta28");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_LOCAL_PARAMETER);

  obj = d->getElementByMetaId("meta29");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_LIST_OF);
  fail_unless(static_cast<ListOf*>(obj)->getItemTypeCode() == SBML_UNIT_DEFINITION);

  obj = d->getElementByMetaId("meta30");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_UNIT_DEFINITION);

  obj = d->getElementByMetaId("meta31");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_LIST_OF);
  fail_unless(static_cast<ListOf*>(obj)->getItemTypeCode() == SBML_UNIT);

  obj = d->getElementByMetaId("meta32");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_UNIT);

  obj = d->getElementByMetaId("meta33");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_LIST_OF);
  fail_unless(static_cast<ListOf*>(obj)->getItemTypeCode() == SBML_PARAMETER);

  obj = d->getElementByMetaId("meta34");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_LIST_OF);
  fail_unless(static_cast<ListOf*>(obj)->getItemTypeCode() == SBML_MODIFIER_SPECIES_REFERENCE);

  obj = d->getElementByMetaId("meta35");
  fail_unless(obj != NULL);
  fail_unless(obj->getTypeCode() == SBML_MODIFIER_SPECIES_REFERENCE);


  delete d;
}