END_TEST


START_TEST (test_SBMLConvert_convertToL2v4_DuplicateAnnotations_model)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(2, 1);
  Model_t * m = SBMLDocument_createModel(d);

  char * annotation = "<rdf/>\n<rdf/>";

  int i = SBase_setAnnotationString((SBase_t *) (m), annotation);
  fail_unless( SBMLDocument_getLevel  (d) == 2, NULL );
  fail_unless( SBMLDocument_getVersion(d) == 1, NULL );
  fail_unless( XMLNode_getNumChildren(SBase_getAnnotation((SBase_t *) (m))) == 2);

  fail_unless( SBMLDocument_setLevelAndVersion(d, 2, 4) == 1, NULL );

  fail_unless( SBMLDocument_getLevel  (d) == 2, NULL );
  fail_unless( SBMLDocument_getVersion(d) == 4, NULL );

  m = SBMLDocument_getModel(d);
  fail_unless( XMLNode_getNumChildren(SBase_getAnnotation((SBase_t *) (m))) == 1);


  SBMLDocument_free(d);
}
示例#2
0
END_TEST


START_TEST (test_SBMLDocument_setLevelAndVersion_UnitsError)
{
  SBMLDocument_t *d  = SBMLDocument_create();
  SBMLDocument_setLevelAndVersionNonStrict(d, 2, 4);
  
  Model_t        *m1 = SBMLDocument_createModel(d);
  
  Compartment_t  *c = Model_createCompartment(m1);
  Compartment_setId(c, "c");
  
  Parameter_t *p = Model_createParameter(m1);
  Parameter_setId(p, "p");
  Parameter_setUnits(p, "mole");

  Rule_t * r = Model_createAssignmentRule(m1);
  Rule_setVariable(r, "c");
  Rule_setFormula(r, "p*p");

  fail_unless(SBMLDocument_setLevelAndVersionNonStrict(d,2,2) == 1);
  fail_unless(SBMLDocument_setLevelAndVersionNonStrict(d,2,3) == 1);
  fail_unless(SBMLDocument_setLevelAndVersionNonStrict(d,1,2) == 1);
  fail_unless(SBMLDocument_setLevelAndVersionNonStrict(d,1,1) == 0);

  SBMLDocument_free(d);
}
END_TEST


START_TEST (test_SBMLConvert_convertToL1_Species_Amount)
{
  SBMLDocument_t *d   = SBMLDocument_createWithLevelAndVersion(2, 4);
  Model_t        *m   = SBMLDocument_createModel(d);
  const char     *sid = "C";
  Compartment_t  *c   = Compartment_create(2, 4);
  Species_t      *s   = Species_create(2, 4);


  Compartment_setId   ( c, sid );
  Model_addCompartment( m, c   );

  Species_setCompartment  ( s, sid  ); 
  Species_setInitialAmount( s, 2.34 );
  Model_addSpecies        ( m, s    );
  
  fail_unless( SBMLDocument_setLevelAndVersion(d, 1, 2) == 1, NULL );

  fail_unless( Species_getInitialAmount(s) == 2.34, NULL );

  SBMLDocument_free(d);
}
END_TEST


START_TEST (test_SBMLConvert_convertFromL3)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(3, 1);
  Model_t        *m = SBMLDocument_createModel(d);

  const char   *sid = "C";
  Compartment_t  *c = Model_createCompartment(m);

  Compartment_setId   ( c, sid );
  Compartment_setSize ( c, 1.2 ); 
  Compartment_setConstant( c, 1);
  Compartment_setSpatialDimensionsAsDouble(c, 3.4);

  fail_unless(SBMLDocument_setLevelAndVersion(d, 1, 1) == 0);
  fail_unless(SBMLDocument_setLevelAndVersion(d, 1, 2) == 0);
  fail_unless(SBMLDocument_setLevelAndVersion(d, 2, 1) == 0);
  fail_unless(SBMLDocument_setLevelAndVersion(d, 2, 2) == 0);
  fail_unless(SBMLDocument_setLevelAndVersion(d, 2, 3) == 0);
  fail_unless(SBMLDocument_setLevelAndVersion(d, 2, 4) == 0);
  fail_unless(SBMLDocument_setLevelAndVersion(d, 3, 1) == 1);

}
END_TEST


START_TEST (test_SBMLConvertStrict_convertSBO)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(2, 4);
  Model_t * m = SBMLDocument_createModel(d);
  
  /* create a compartment with SBO */
  Compartment_t * c = Model_createCompartment(m);
  Compartment_setId(c, "c");
  SBase_setSBOTerm((SBase_t *) (c), 240);

  fail_unless( SBMLDocument_setLevelAndVersionStrict(d, 2, 3) == 1 );
  fail_unless( SBMLDocument_getLevel  (d) == 2, NULL );
  fail_unless( SBMLDocument_getVersion(d) == 3, NULL );
  
  fail_unless( SBMLDocument_setLevelAndVersionStrict(d, 2, 2) == 1 );
  fail_unless( SBMLDocument_getLevel  (d) == 2, NULL );
  fail_unless( SBMLDocument_getVersion(d) == 2, NULL );

  /* check that sbo term has been removed */
  Compartment_t *c1 = Model_getCompartment(SBMLDocument_getModel(d), 0);

  fail_unless (SBase_getSBOTerm((SBase_t *) (c1)) == -1, NULL );

  SBMLDocument_free(d);
}
END_TEST


START_TEST (test_SBMLConvert_addModifiersToReaction)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(1, 2);
  Model_t        *m = SBMLDocument_createModel(d);
  Reaction_t     *r = Model_createReaction(m);
  KineticLaw_t  *kl = Reaction_createKineticLaw(r);
  KineticLaw_setFormula(kl, "k1*S1*S2*S3*S4*S5");

  SpeciesReference_t *ssr1;
  SpeciesReference_t *ssr2;


  Species_t *s1 = Model_createSpecies( m ); 
  Species_setId( s1, "S1" );
  Species_t *s2 = Model_createSpecies( m ); 
  Species_setId( s2, "S2");
  Species_t *s3 = Model_createSpecies( m ); 
  Species_setId( s3, "S3");
  Species_t *s4 = Model_createSpecies( m ); 
  Species_setId( s4, "S4");
  Species_t *s5 = Model_createSpecies( m ); 
  Species_setId( s5, "S5");

  SpeciesReference_t *sr1 = Reaction_createReactant( r );
  SpeciesReference_t *sr2 = Reaction_createReactant( r );
  SpeciesReference_t *sr3 = Reaction_createProduct ( r );

  SpeciesReference_setSpecies(sr1, "S1");
  SpeciesReference_setSpecies(sr2, "S2");
  SpeciesReference_setSpecies(sr3, "S5");

  fail_unless( Reaction_getNumModifiers(r) == 0, NULL );

  fail_unless( SBMLDocument_setLevelAndVersionNonStrict(d, 2, 1) == 1, NULL );

  fail_unless( SBMLDocument_getLevel  (d) == 2, NULL );
  fail_unless( SBMLDocument_getVersion(d) == 1, NULL );


  fail_unless( Reaction_getNumModifiers(Model_getReaction(m, 0)) == 2, NULL );

  ssr1 = (SpeciesReference_t *) Reaction_getModifier(Model_getReaction(m, 0), 0);
  ssr2 = (SpeciesReference_t *) Reaction_getModifier(Model_getReaction(m, 0), 1);

  fail_unless( !strcmp(SpeciesReference_getSpecies(ssr1), "S3"), NULL );
  fail_unless( !strcmp(SpeciesReference_getSpecies(ssr2), "S4"), NULL );

  SBMLDocument_free(d);
}
END_TEST


START_TEST (test_SBMLConvert_convertToL3_defaultUnits)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(1, 2);
  Model_t        *m = SBMLDocument_createModel(d);

  const char   *sid = "C";
  Compartment_t  *c = Model_createCompartment(m);

  Compartment_setId   ( c, sid );
  Compartment_setSize ( c, 1.2 ); 
  Compartment_setUnits( c, "volume");

  fail_unless(Model_getNumUnitDefinitions(m) == 0);
  
  fail_unless( SBMLDocument_setLevelAndVersion(d, 3, 1) == 1, NULL);


  fail_unless(Model_getNumUnitDefinitions(m) == 2);

  UnitDefinition_t *ud = Model_getUnitDefinition(m, 0);

  fail_unless (ud != NULL);
  fail_unless (!strcmp(UnitDefinition_getId( ud), "volume"));
  fail_unless(UnitDefinition_getNumUnits(ud) == 1);

  Unit_t * u = UnitDefinition_getUnit(ud, 0);

  fail_unless(Unit_getKind(u) == UNIT_KIND_LITRE);
  fail_unless(Unit_getExponent(u) == 1);
  fail_unless(Unit_getMultiplier(u) == 1);
  fail_unless(Unit_getScale(u) == 0);

  ud = Model_getUnitDefinition(m, 1);

  fail_unless (ud != NULL);
  fail_unless (!strcmp(UnitDefinition_getId( ud), "time"));
  fail_unless(UnitDefinition_getNumUnits(ud) == 1);
  
  u = UnitDefinition_getUnit(ud, 0);

  fail_unless(Unit_getKind(u) == UNIT_KIND_SECOND);
  fail_unless(Unit_getExponent(u) == 1);
  fail_unless(Unit_getMultiplier(u) == 1);
  fail_unless(Unit_getScale(u) == 0);

  fail_unless(!strcmp(Model_getTimeUnits(m), "time"));

  SBMLDocument_free(d);
}
END_TEST


START_TEST (test_SBMLConvertStrict_convertNonStrictSBO)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(2, 4);
  Model_t * m = SBMLDocument_createModel(d);
  
  /* create a compartment with SBO */
  Compartment_t * c = Model_createCompartment(m);
  Compartment_setId(c, "c");
  Compartment_setConstant(c, 0);
  SBase_setSBOTerm((SBase_t *) (c), 64);

  /* conversion to L2V3 and L2V2 should fail due to bad SBO
   * but to L2V1 and L1 should pass as sbo terms not applicable
   */

  fail_unless( SBMLDocument_setLevelAndVersionStrict(d, 2, 3) == 0 );
  fail_unless( SBMLDocument_getLevel  (d) == 2, NULL );
  fail_unless( SBMLDocument_getVersion(d) == 4, NULL );

  fail_unless( SBMLDocument_setLevelAndVersionStrict(d, 2, 2) == 0 );
  fail_unless( SBMLDocument_getLevel  (d) == 2, NULL );
  fail_unless( SBMLDocument_getVersion(d) == 4, NULL );

  fail_unless( SBMLDocument_setLevelAndVersionStrict(d, 2, 1) == 1 );
  fail_unless( SBMLDocument_getLevel  (d) == 2, NULL );
  fail_unless( SBMLDocument_getVersion(d) == 1, NULL );

  /* check that sbo term has been removed */
  Compartment_t *c1 = Model_getCompartment(SBMLDocument_getModel(d), 0);

  fail_unless (SBase_getSBOTerm((SBase_t *) (c1)) == -1, NULL );

  fail_unless( SBMLDocument_setLevelAndVersionStrict(d, 1, 2) == 1 );
  fail_unless( SBMLDocument_getLevel  (d) == 1, NULL );
  fail_unless( SBMLDocument_getVersion(d) == 2, NULL );
  
  /* check that sbo term has been removed */
  Compartment_t *c2 = Model_getCompartment(SBMLDocument_getModel(d), 0);

  fail_unless (SBase_getSBOTerm((SBase_t *) (c2)) == -1, NULL );

  SBMLDocument_free(d);
}
END_TEST

START_TEST (test_SBMLConvert_convertToL3_event)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(2, 2);
  Model_t        *m = SBMLDocument_createModel(d);

  Event_t  *e = Model_createEvent(m);
  Event_t *e1;

  fail_unless( SBMLDocument_setLevelAndVersionNonStrict(d, 3, 1) == 1, NULL);

  e1 = Model_getEvent(m, 0);

  fail_unless(Event_hasRequiredAttributes(e1) == 1);

  SBMLDocument_free(d);
}
END_TEST


START_TEST (test_SBMLConvert_convertToL1_Species_Concentration)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(2, 1);
  Model_t        *m = SBMLDocument_createModel(d);
  const char   *sid = "C";
  Compartment_t  *c = 
    Compartment_create(2, 1);
  Species_t      *s = 
    Species_create(2, 1);


  Compartment_setId   ( c, sid );
  Compartment_setSize ( c, 1.2 ); 
  Model_addCompartment( m, c   );

  Species_setId                  ( s, "s"  );
  Species_setCompartment         ( s, sid  ); 
  Species_setInitialConcentration( s, 2.34 );
  Model_addSpecies               ( m, s    );
  
  fail_unless( SBMLDocument_setLevelAndVersion(d, 1, 2) == 1, NULL);

  /**
   * These tests will fail under Cygwin because of a minimal
   * setlocale() implementation (see setlocale manpage).
   */
#ifndef CYGWIN
  fail_unless( Species_getInitialAmount(Model_getSpecies(m, 0)) == 2.808, NULL );
#endif

  Species_t * s1 = Model_getSpecies(m, 0);
  fail_unless (s1 != NULL);
  fail_unless (!strcmp(Species_getCompartment(s1), "C"));
  fail_unless(Compartment_getSize(Model_getCompartmentById(m, "C")) == 1.2);
  fail_unless(Species_getInitialConcentration(s1) == 2.34);
  fail_unless(Species_isSetInitialConcentration(s1) == 1);

  SBMLDocument_free(d);
}
END_TEST


START_TEST (test_SBMLConvert_convertToL3_reaction)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(2, 2);
  Model_t        *m = SBMLDocument_createModel(d);

  const char   *sid = "C";
  Reaction_t  *r = Model_createReaction(m);
  Reaction_setId   ( r, sid );

  fail_unless( SBMLDocument_setLevelAndVersionNonStrict(d, 3, 1) == 1, NULL);

  Reaction_t *r1 = Model_getReaction(m, 0);

  fail_unless(Reaction_hasRequiredAttributes(r1) == 1);

  SBMLDocument_free(d);
}
END_TEST


START_TEST (test_SBMLConvert_convertFromL3_priority)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(3, 1);
  Model_t        *m = SBMLDocument_createModel(d);

  Event_t * e = Model_createEvent(m);
  Priority_t * p = Event_createPriority(e);

  fail_unless(SBMLDocument_setLevelAndVersionNonStrict(d, 1, 1) == 0);
  fail_unless(SBMLDocument_setLevelAndVersionNonStrict(d, 1, 2) == 0);
  fail_unless(SBMLDocument_setLevelAndVersionNonStrict(d, 2, 1) == 1);
  fail_unless(SBMLDocument_setLevelAndVersionNonStrict(d, 2, 2) == 1);
  fail_unless(SBMLDocument_setLevelAndVersionNonStrict(d, 2, 3) == 1);
  fail_unless(SBMLDocument_setLevelAndVersionNonStrict(d, 2, 4) == 1);
  fail_unless(SBMLDocument_setLevelAndVersionNonStrict(d, 3, 1) == 1);

}
END_TEST


START_TEST (test_SBMLConvert_convertToL3_stoichiometryMath)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(2, 1);
  Model_t        *m = SBMLDocument_createModel(d);

  Compartment_t  *c = Model_createCompartment(m);
  Compartment_setId   ( c, "c" );

  Species_t *s = Model_createSpecies(m);
  Species_setId(s, "s");
  Species_setCompartment(s, "c");

  Reaction_t * r = Model_createReaction(m);
  SpeciesReference_t *sr = Reaction_createReactant(r);
  SpeciesReference_setSpecies(sr, "s");
  StoichiometryMath_t *sm = SpeciesReference_createStoichiometryMath(sr);

  ASTNode_t * ast = SBML_parseFormula("c*2");
  StoichiometryMath_setMath(sm, ast);

  fail_unless(Model_getNumRules(m) == 0);
  fail_unless(SpeciesReference_isSetId(sr) == 0);
  
  fail_unless( SBMLDocument_setLevelAndVersionNonStrict(d, 3, 1) == 1);

  m = SBMLDocument_getModel(d);
  r = Model_getReaction(m, 0);
  sr = Reaction_getReactant(r, 0);

  fail_unless(Model_getNumRules(m) == 1);
  fail_unless(SpeciesReference_isSetId(sr) == 1);
  
  Rule_t *rule = Model_getRule(m, 0);

  fail_unless( strcmp(SpeciesReference_getId(sr), Rule_getVariable(rule)) == 0 );

  SBMLDocument_free(d);
}
示例#14
0
END_TEST


START_TEST (test_SBMLConvertStrict_convertToL1)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(2, 4);
  
  /* create model with metaid */
  Model_t * m = SBMLDocument_createModel(d);
  SBase_setMetaId((SBase_t *) (m), "_m");
  
  /* create a compartment with sbo*/
  Compartment_t * c = Model_createCompartment(m);
  Compartment_setId(c, "c");
  SBase_setSBOTerm((SBase_t *) (c), 240);

  /* create a species with hasOnlySubstanceUnits = true*/
  Species_t *s = Model_createSpecies(m);
  Species_setId(s, "s");
  Species_setCompartment(s, "c");
  Species_setHasOnlySubstanceUnits(s, 1);

  fail_unless( SBMLDocument_setLevelAndVersionStrict(d, 1, 2) == 1 );
  fail_unless( SBMLDocument_getLevel  (d) == 1, NULL );
  fail_unless( SBMLDocument_getVersion(d) == 2, NULL );

  ///* check that attributes that are no longer valid have been removed */
  Model_t * m1 = SBMLDocument_getModel(d);

  fail_unless (SBase_getMetaId((SBase_t *) (m1)) == NULL);

  Compartment_t *c1 = Model_getCompartment(m1, 0);

  fail_unless (SBase_getSBOTerm((SBase_t *) (c1)) == -1, NULL );

  Species_t *s1 = Model_getSpecies(m1, 0);

  fail_unless (Species_getHasOnlySubstanceUnits(s1) == 0);

  SBMLDocument_free(d);
}
END_TEST


START_TEST (test_SBMLConvert_convertToL3_trigger)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(2, 2);
  Model_t        *m = SBMLDocument_createModel(d);

  Event_t  *e = Model_createEvent(m);
  Trigger_t *t = Event_createTrigger(e);

  Trigger_t *t1;

  fail_unless( SBMLDocument_setLevelAndVersionNonStrict(d, 3, 1) == 1, NULL);

  t1 = Event_getTrigger(Model_getEvent(m, 0));

  fail_unless(Trigger_hasRequiredAttributes(t1) == 1);

  SBMLDocument_free(d);
}
END_TEST


START_TEST (test_SBMLConvert_invalidLevelVersion)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(2, 1);
  Model_t        *m = SBMLDocument_createModel(d);

  const char   *sid = "C";
  Compartment_t  *c = Model_createCompartment(m);

  Compartment_setId   ( c, sid );
  Compartment_setSize ( c, 1.2 ); 
  Compartment_setUnits( c, "volume");

  fail_unless(SBMLDocument_setLevelAndVersion(d, 1, 3) == 0);
  fail_unless(SBMLDocument_setLevelAndVersion(d, 2, 5) == 0);
  fail_unless(SBMLDocument_setLevelAndVersion(d, 3, 2) == 0);
  fail_unless(SBMLDocument_setLevelAndVersion(d, 4, 1) == 0);

}
END_TEST


START_TEST (test_SBMLConvert_convertFromL3_initialValue)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(3, 1);
  Model_t        *m = SBMLDocument_createModel(d);

  Event_t * e = Model_createEvent(m);
  Trigger_t * t = Event_createTrigger(e);
  Trigger_setInitialValue(t, 0);

  fail_unless(SBMLDocument_setLevelAndVersionNonStrict(d, 1, 1) == 0);
  fail_unless(SBMLDocument_setLevelAndVersionNonStrict(d, 1, 2) == 0);
  fail_unless(SBMLDocument_setLevelAndVersionNonStrict(d, 2, 1) == 0);
  fail_unless(SBMLDocument_setLevelAndVersionNonStrict(d, 2, 2) == 0);
  fail_unless(SBMLDocument_setLevelAndVersionNonStrict(d, 2, 3) == 0);
  fail_unless(SBMLDocument_setLevelAndVersionNonStrict(d, 2, 4) == 0);
  fail_unless(SBMLDocument_setLevelAndVersionNonStrict(d, 3, 1) == 1);

}
END_TEST


START_TEST (test_SBMLConvert_convertToL3_compartment)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(2, 2);
  Model_t        *m = SBMLDocument_createModel(d);

  const char   *sid = "C";
  Compartment_t  *c = Model_createCompartment(m);
  Compartment_t *c1;

  Compartment_setId   ( c, sid );

  fail_unless( SBMLDocument_setLevelAndVersionNonStrict(d, 3, 1) == 1, NULL);

  c1 = Model_getCompartment(m, 0);

  fail_unless(Compartment_hasRequiredAttributes(c1) == 1);

  SBMLDocument_free(d);
}
END_TEST


START_TEST (test_SBMLConvert_convertToL3_product)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(2, 2);
  Model_t        *m = SBMLDocument_createModel(d);
  Reaction_t     *r = Model_createReaction(m);

  SpeciesReference_t  *sr = Reaction_createProduct(r);
  SpeciesReference_t *sr1;

  SpeciesReference_setSpecies   ( sr, "s" );

  fail_unless( SBMLDocument_setLevelAndVersionNonStrict(d, 3, 1) == 1, NULL);

  sr1 = Reaction_getProduct(Model_getReaction(m, 0), 0);

  fail_unless(SpeciesReference_hasRequiredAttributes(sr1) == 1);

  SBMLDocument_free(d);
}
END_TEST


START_TEST (test_SBMLConvert_convertToL3_parameter)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(2, 2);
  Model_t        *m = SBMLDocument_createModel(d);

  const char   *sid = "C";
  Parameter_t  *p = Model_createParameter(m);
  Parameter_t *p1;

  Parameter_setId   ( p, sid );

  fail_unless( SBMLDocument_setLevelAndVersionNonStrict(d, 3, 1) == 1, NULL);

  p1 = Model_getParameter(m, 0);

  fail_unless(Parameter_hasRequiredAttributes(p1) == 1);

  SBMLDocument_free(d);
}
END_TEST


START_TEST (test_SBMLConvert_convertToL3_unit)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(2, 2);
  Model_t        *m = SBMLDocument_createModel(d);

  const char   *sid = "C";
  UnitDefinition_t  *ud = Model_createUnitDefinition(m);
  UnitDefinition_setId   ( ud, sid );
  Unit_t *u = UnitDefinition_createUnit(ud);
  Unit_setKind(u, UNIT_KIND_MOLE);

  fail_unless( SBMLDocument_setLevelAndVersionNonStrict(d, 3, 1) == 1, NULL);

  Unit_t *u1 = UnitDefinition_getUnit(Model_getUnitDefinition(m, 0), 0);

  fail_unless(Unit_hasRequiredAttributes(u1) == 1);

  SBMLDocument_free(d);
}
END_TEST

START_TEST (test_SBMLConvert_convertToL3_localParameters)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(1, 2);
  Model_t        *m = SBMLDocument_createModel(d);

  Compartment_t  *c = Model_createCompartment(m);
  Compartment_setId   ( c, "c" );

  Species_t *s = Model_createSpecies(m);
  Species_setId(s, "s");
  Species_setCompartment(s, "c");

  Reaction_t * r = Model_createReaction(m);
  SpeciesReference_t *sr = Reaction_createReactant(r);
  SpeciesReference_setSpecies(sr, "s");

  KineticLaw_t *kl = Reaction_createKineticLaw(r);

  KineticLaw_setFormula(kl, "s*k");
  Parameter_t *p = KineticLaw_createParameter(kl);
  Parameter_setId(p, "k");

  fail_unless(KineticLaw_getNumLocalParameters(kl) == 0);
  
  fail_unless( SBMLDocument_setLevelAndVersionNonStrict(d, 3, 1) == 1 );

  m = SBMLDocument_getModel(d);
  r = Model_getReaction(m,0);
  kl = Reaction_getKineticLaw(r);


  fail_unless(KineticLaw_getNumLocalParameters(kl) == 1);

  LocalParameter_t *lp = KineticLaw_getLocalParameter(kl, 0);

  SBMLDocument_free(d);
}
END_TEST


START_TEST (test_SBMLConvert_convertToL3_species)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(2, 2);
  Model_t        *m = SBMLDocument_createModel(d);

  const char   *sid = "C";
  Species_t  *s = Model_createSpecies(m);
  Species_t *s1;

  Species_setId   ( s, sid );
  Species_setCompartment( s, "comp");

  fail_unless( SBMLDocument_setLevelAndVersionNonStrict(d, 3, 1) == 1, NULL);

  s1 = Model_getSpecies(m, 0);

  fail_unless(Species_hasRequiredAttributes(s1) == 1);

  SBMLDocument_free(d);
}
示例#24
0
END_TEST


START_TEST (test_SBMLConvertStrict_convertL1ParamRule)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(1, 2);
  Model_t * m = SBMLDocument_createModel(d);
  
  /* create a compartment */
  Compartment_t * c = Model_createCompartment(m);
  Compartment_setId(c, "c");

  /* create  a parameter */
  Parameter_t * p = Model_createParameter(m);
  Parameter_setId(p, "p");
  Parameter_t * p1 = Model_createParameter(m);
  Parameter_setId(p1, "p1");

  /* create a math element */
  ASTNode_t *math = SBML_parseFormula("p");

  /* create an assignment rule */
  Rule_t *ar = Model_createAssignmentRule(m);
  Rule_setVariable(ar, "p1");
  Rule_setMath(ar, math);
  Rule_setUnits(ar, "mole");

  fail_unless( SBMLDocument_setLevelAndVersionStrict(d, 2, 1) == 1 );
  fail_unless( SBMLDocument_getLevel  (d) == 2, NULL );
  fail_unless( SBMLDocument_getVersion(d) == 1, NULL );

  Rule_t * r1 = Model_getRule(SBMLDocument_getModel(d), 0);

  fail_unless (Rule_getUnits(r1) == NULL );

  SBMLDocument_free(d);
}
END_TEST


START_TEST (test_SBMLConvert_convertFromL3_modelUnits)
{
  UnitDefinition_t *ud;
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(3, 1);
  Model_t        *m = SBMLDocument_createModel(d);
  Model_setVolumeUnits(m, "litre");

  fail_unless(Model_getNumUnitDefinitions(m) == 0);
  
  fail_unless(SBMLDocument_setLevelAndVersionNonStrict(d, 1, 2) == 1);

  m = SBMLDocument_getModel(d);

  fail_unless(Model_getNumUnitDefinitions(m) == 1);

  ud = Model_getUnitDefinition(m, 0);

  fail_unless(!strcmp(UnitDefinition_getId(ud), "volume"));
  fail_unless(UnitDefinition_getNumUnits(ud) == 1);
  fail_unless(Unit_getKind(UnitDefinition_getUnit(ud, 0)) == UNIT_KIND_LITRE );
}
END_TEST


START_TEST (test_SBMLConvert_convertFromL3_conversionFactor)
{
  SBMLDocument_t *d = SBMLDocument_createWithLevelAndVersion(3, 1);
  Model_t        *m = SBMLDocument_createModel(d);
  const char   *sid = "P";

  Model_setConversionFactor(m, sid);
  Parameter_t  *c = Model_createParameter(m);

  Parameter_setId   ( c, sid );
  Parameter_setConstant( c, 1);

  fail_unless(SBMLDocument_setLevelAndVersion(d, 1, 1) == 0);
  fail_unless(SBMLDocument_setLevelAndVersion(d, 1, 2) == 0);
  fail_unless(SBMLDocument_setLevelAndVersion(d, 2, 1) == 0);
  fail_unless(SBMLDocument_setLevelAndVersion(d, 2, 2) == 0);
  fail_unless(SBMLDocument_setLevelAndVersion(d, 2, 3) == 0);
  fail_unless(SBMLDocument_setLevelAndVersion(d, 2, 4) == 0);
  fail_unless(SBMLDocument_setLevelAndVersion(d, 3, 1) == 1);

}
示例#27
0
LIBSBML_CPP_NAMESPACE_USE


int main(int argc,char** argv)
{
  int retval = 0;
  XMLNamespaces_t * comp;
  SBMLNamespaces_t * sbmlns;
  SBMLDocument_t * doc;
  Compartment_t * c;
  Species_t * s1;
  Species_t * s2;
  Species_t * s3;
  Species_t * s4;
  Reaction_t * r1;
  Reaction_t * r2;
  SpeciesReference_t *sr1;
  SpeciesReference_t *sr2;
  SpeciesReference_t *sr3;
  SpeciesReference_t *sr4;
  SpeciesReference_t *sr5;
  SpeciesReference_t *sr6;
  Model_t * model;
  CompSBMLDocumentPlugin_t * docPlug;
  CompModelPlugin_t *modelPlug;
  Submodel_t * sub1;
  Submodel_t * sub2;
  ModelDefinition_t * modDef;

  /* get comp registry entry */
  SBMLExtension_t *sbmlext = SBMLExtensionRegistry_getExtension("comp");

  /* create the sbml namespaces object with comp */
  comp = XMLNamespaces_create();
  XMLNamespaces_add(comp, SBMLExtension_getURI(sbmlext, 3, 1, 1), "comp");
  
  sbmlns = SBMLNamespaces_create(3, 1);
  SBMLNamespaces_addNamespaces(sbmlns, comp);

  /* create the document */
  doc = SBMLDocument_createWithSBMLNamespaces(sbmlns);

  /* set the comp reqd attribute to true */
  docPlug = (CompSBMLDocumentPlugin_t * )(SBase_getPlugin((SBase_t*)(doc), "comp"));
  SBMLDocumentPlugin_setRequired((SBMLDocumentPlugin_t*)(docPlug), 1);


  /* create the submodel */
  modDef = CompSBMLDocumentPlugin_createModelDefinition(docPlug);

  Model_setId((Model_t*)(modDef), "enzyme");
  Model_setName((Model_t*)(modDef), "enzyme");

  c = Model_createCompartment((Model_t*)(modDef));
  Compartment_setId(c, "comp");
  Compartment_setConstant(c, 1);
  Compartment_setSize(c, 1.0);
  Compartment_setSpatialDimensions(c, 3);

  s1 = Model_createSpecies((Model_t*)(modDef));
  Species_setId(s1, "S");
  Species_setCompartment(s1, "comp");
  Species_setHasOnlySubstanceUnits(s1, 0);
  Species_setBoundaryCondition(s1, 0);
  Species_setConstant(s1, 0);
  
  s2 = Model_createSpecies((Model_t*)(modDef));
  Species_setId(s2, "E");
  Species_setCompartment(s2, "comp");
  Species_setHasOnlySubstanceUnits(s2, 0);
  Species_setBoundaryCondition(s2, 0);
  Species_setConstant(s2, 0);
  
  s3 = Model_createSpecies((Model_t*)(modDef));
  Species_setId(s3, "D");
  Species_setCompartment(s3, "comp");
  Species_setHasOnlySubstanceUnits(s3, 0);
  Species_setBoundaryCondition(s3, 0);
  Species_setConstant(s3, 0);

  s4 = Model_createSpecies((Model_t*)(modDef));
  Species_setId(s4, "ES");
  Species_setCompartment(s4, "comp");
  Species_setHasOnlySubstanceUnits(s4, 0);
  Species_setBoundaryCondition(s4, 0);
  Species_setConstant(s4, 0);

  r1 = Model_createReaction((Model_t*)(modDef));
  Reaction_setId(r1, "J0");
  Reaction_setReversible(r1, 1);
  Reaction_setFast(r1, 0);

  sr1 = Reaction_createReactant(r1);
  SpeciesReference_setSpecies(sr1, "S");
  SpeciesReference_setStoichiometry(sr1, 1.0);
  SpeciesReference_setConstant(sr1, 1);


  sr2 = Reaction_createReactant(r1);
  SpeciesReference_setSpecies(sr2, "E");
  SpeciesReference_setStoichiometry(sr2, 1.0);
  SpeciesReference_setConstant(sr2, 1);

  sr3 = Reaction_createProduct(r1);
  SpeciesReference_setSpecies(sr3, "ES");
  SpeciesReference_setStoichiometry(sr3, 1.0);
  SpeciesReference_setConstant(sr3, 1);

  r2 = Model_createReaction((Model_t*)(modDef));
  Reaction_setId(r2, "J1");
  Reaction_setReversible(r2, 1);
  Reaction_setFast(r2, 0);

  sr4 = Reaction_createProduct(r2);
  SpeciesReference_setSpecies(sr4, "E");
  SpeciesReference_setStoichiometry(sr4, 1.0);
  SpeciesReference_setConstant(sr4, 1);

  sr5 = Reaction_createReactant(r2);
  SpeciesReference_setSpecies(sr5, "ES");
  SpeciesReference_setStoichiometry(sr5, 1.0);
  SpeciesReference_setConstant(sr5, 1);

  sr6 = Reaction_createProduct(r2);
  SpeciesReference_setSpecies(sr6, "D");
  SpeciesReference_setStoichiometry(sr6, 1.0);
  SpeciesReference_setConstant(sr6, 1);

  /* create the model */
  model = SBMLDocument_createModel(doc);
  Model_setId(model, "aggregate");

  /* add the submodels*/
  modelPlug = (CompModelPlugin_t*)(SBase_getPlugin((SBase_t *)(model), "comp"));

  sub1 = CompModelPlugin_createSubmodel(modelPlug);
  Submodel_setId(sub1, "submod1");
  Submodel_setModelRef(sub1, "enzyme");


  sub2 = CompModelPlugin_createSubmodel(modelPlug);
  Submodel_setId(sub2, "submod2");
  Submodel_setModelRef(sub2, "enzyme");

  /* write the file */
  writeSBMLToFile(doc, "enzyme_model.xml");

  return retval;
}
int main(int argc,char** argv)
{
  int retval = 0;
  XMLNamespaces_t * groups;
  SBMLNamespaces_t * sbmlns;
  SBMLDocument_t * doc;
  Compartment_t * compartment;
  Species_t * species;
  Model_t * model;
  SBMLDocumentPlugin_t * docPlug;
  SBasePlugin_t * modelPlug;
  Group_t * group;
  Member_t * member;

  /* get groups registry entry */
  SBMLExtension_t *sbmlext = SBMLExtensionRegistry_getExtension("groups");

  /* create the sbml namespaces object with groups */
  groups = XMLNamespaces_create();
  XMLNamespaces_add(groups, SBMLExtension_getURI(sbmlext, 3, 1, 1), "groups");
  
  sbmlns = SBMLNamespaces_create(3, 1);
  SBMLNamespaces_addNamespaces(sbmlns, groups);

  /* create the document */
  doc = SBMLDocument_createWithSBMLNamespaces(sbmlns);

  /* set the groups reqd attribute to false */
  docPlug = (SBMLDocumentPlugin_t*)(SBase_getPlugin((SBase_t*)(doc), "groups"));
  SBMLDocumentPlugin_setRequired(docPlug, 0);

  // create the Model

  model = SBMLDocument_createModel(doc);

  // create the Compartment

  compartment = Model_createCompartment(model);
  Compartment_setId(compartment, "cytosol");
  Compartment_setConstant(compartment, 1);
  Compartment_setSize(compartment, 1);

  compartment = Model_createCompartment(model);
  Compartment_setId(compartment, "mitochon");
  Compartment_setConstant(compartment, 1);
  Compartment_setSize(compartment, 1);

  // create the Species

  species = Model_createSpecies(model);
  Species_setId(species, "ATPc");
  Species_setCompartment(species, "cytosol");
  Species_setBoundaryCondition(species, 0);
  Species_setConstant(species, 0);
  Species_setHasOnlySubstanceUnits(species, 0);

  species = Model_createSpecies(model);
  Species_setId(species, "ATPm");
  Species_setCompartment(species, "mitochon");
  Species_setBoundaryCondition(species, 0);
  Species_setConstant(species, 0);
  Species_setHasOnlySubstanceUnits(species, 0);

  // create the Groups
  // Get a SBasePlugin_t object plugged in the model object.

  modelPlug = SBase_getPlugin((SBase_t *)(model), "groups");

  // create the group object and add it to model plugin

  group = Group_create(3, 1, 1);
  Group_setId(group, "ATP");
  Group_setKind(group, GROUP_KIND_CLASSIFICATION);
  SBase_setSBOTerm(group, 252);

  member = Group_createMember(group);
  Member_setIdRef(member, "ATPc");

  member = Group_createMember(group);
  Member_setIdRef(member, "ATPm");

  // we need a function here
  GroupsModelPlugin_addGroup((GroupsModelPlugin_t*)(modelPlug), group);

  /* write the file */
  writeSBMLToFile(doc, "groups_example1.xml");

  return retval;
}
示例#29
0
LIBSBML_CPP_NAMESPACE_USE


int main(int argc,char** argv)
{
  int retval = 0;
  XMLNamespaces_t * fbc;
  SBMLNamespaces_t * sbmlns;
  SBMLDocument_t * doc;
  Compartment_t * compartment;
  Species_t * species;
  Reaction_t * reaction;
  SpeciesReference_t *reactant;
  SpeciesReference_t *product;
  Model_t * model;
  SBMLDocumentPlugin_t * docPlug;
  SBasePlugin_t * modelPlug;
  FluxBound_t * fluxBound;
  Objective_t * objective;
  FluxObjective_t * fluxObjective;

  /* get fbc registry entry */
  SBMLExtension_t *sbmlext = SBMLExtensionRegistry_getExtension("fbc");

  /* create the sbml namespaces object with fbc */
  fbc = XMLNamespaces_create();
  XMLNamespaces_add(fbc, SBMLExtension_getURI(sbmlext, 3, 1, 1), "fbc");
  
  sbmlns = SBMLNamespaces_create(3, 1);
  SBMLNamespaces_addNamespaces(sbmlns, fbc);

  /* create the document */
  doc = SBMLDocument_createWithSBMLNamespaces(sbmlns);

  /* set the fbc reqd attribute to false */
  docPlug = (SBMLDocumentPlugin_t*)(SBase_getPlugin((SBase_t*)(doc), "fbc"));
  SBMLDocumentPlugin_setRequired(docPlug, 0);

  // create the Model

  model = SBMLDocument_createModel(doc);

  // create the Compartment

  compartment = Model_createCompartment(model);
  Compartment_setId(compartment, "compartment");
  Compartment_setConstant(compartment, 1);
  Compartment_setSize(compartment, 1);

  // create the Species

  species = Model_createSpecies(model);
  Species_setId(species, "Node1");
  Species_setCompartment(species, "compartment");
  Species_setBoundaryCondition(species, 0);
  Species_setConstant(species, 0);
  Species_setHasOnlySubstanceUnits(species, 0);

  species = Model_createSpecies(model);
  Species_setId(species, "Node2");
  Species_setCompartment(species, "compartment");
  Species_setBoundaryCondition(species, 0);
  Species_setConstant(species, 0);
  Species_setHasOnlySubstanceUnits(species, 0);

  species = Model_createSpecies(model);
  Species_setId(species, "Node3");
  Species_setCompartment(species, "compartment");
  Species_setBoundaryCondition(species, 0);
  Species_setConstant(species, 0);
  Species_setHasOnlySubstanceUnits(species, 0);

  species = Model_createSpecies(model);
  Species_setId(species, "Node4");
  Species_setCompartment(species, "compartment");
  Species_setBoundaryCondition(species, 0);
  Species_setConstant(species, 0);
  Species_setHasOnlySubstanceUnits(species, 0);

  species = Model_createSpecies(model);
  Species_setId(species, "Node5");
  Species_setCompartment(species, "compartment");
  Species_setBoundaryCondition(species, 0);
  Species_setConstant(species, 0);
  Species_setHasOnlySubstanceUnits(species, 0);

  species = Model_createSpecies(model);
  Species_setId(species, "Node6");
  Species_setCompartment(species, "compartment");
  Species_setBoundaryCondition(species, 0);
  Species_setConstant(species, 0);
  Species_setHasOnlySubstanceUnits(species, 0);

  species = Model_createSpecies(model);
  Species_setId(species, "Node7");
  Species_setCompartment(species, "compartment");
  Species_setBoundaryCondition(species, 0);
  Species_setConstant(species, 0);
  Species_setHasOnlySubstanceUnits(species, 0);

  species = Model_createSpecies(model);
  Species_setId(species, "Node8");
  Species_setCompartment(species, "compartment");
  Species_setBoundaryCondition(species, 0);
  Species_setConstant(species, 0);
  Species_setHasOnlySubstanceUnits(species, 0);

  species = Model_createSpecies(model);
  Species_setId(species, "Node0");
  Species_setCompartment(species, "compartment");
  Species_setBoundaryCondition(species, 1);
  Species_setConstant(species, 0);
  Species_setHasOnlySubstanceUnits(species, 0);

  species = Model_createSpecies(model);
  Species_setId(species, "Node9");
  Species_setCompartment(species, "compartment");
  Species_setBoundaryCondition(species, 1);
  Species_setConstant(species, 0);
  Species_setHasOnlySubstanceUnits(species, 0);

  // create the Reactions

  reaction = Model_createReaction(model);
  Reaction_setId(reaction, "J0");
  Reaction_setReversible(reaction, 0);
  Reaction_setFast(reaction, 0);
  reactant = Reaction_createReactant(reaction);
  SpeciesReference_setSpecies(reactant, "Node0");
  SpeciesReference_setStoichiometry(reactant, 1);
  SpeciesReference_setConstant(reactant, 1);
  product = Reaction_createProduct(reaction);
  SpeciesReference_setSpecies(product, "Node1");
  SpeciesReference_setStoichiometry(product, 1);
  SpeciesReference_setConstant(product, 1);

  reaction = Model_createReaction(model);
  Reaction_setId(reaction, "J1");
  Reaction_setReversible(reaction, 0);
  Reaction_setFast(reaction, 0);
  reactant = Reaction_createReactant(reaction);
  SpeciesReference_setSpecies(reactant, "Node1");
  SpeciesReference_setStoichiometry(reactant, 1);
  SpeciesReference_setConstant(reactant, 1);
  product = Reaction_createProduct(reaction);
  SpeciesReference_setSpecies(product, "Node2");
  SpeciesReference_setStoichiometry(product, 1);
  SpeciesReference_setConstant(product, 1);

  reaction = Model_createReaction(model);
  Reaction_setId(reaction, "J2");
  Reaction_setReversible(reaction, 0);
  Reaction_setFast(reaction, 0);
  reactant = Reaction_createReactant(reaction);
  SpeciesReference_setSpecies(reactant, "Node2");
  SpeciesReference_setStoichiometry(reactant, 1);
  SpeciesReference_setConstant(reactant, 1);
  product = Reaction_createProduct(reaction);
  SpeciesReference_setSpecies(product, "Node3");
  SpeciesReference_setStoichiometry(product, 1);
  SpeciesReference_setConstant(product, 1);

  reaction = Model_createReaction(model);
  Reaction_setId(reaction, "J3");
  Reaction_setReversible(reaction, 0);
  Reaction_setFast(reaction, 0);
  reactant = Reaction_createReactant(reaction);
  SpeciesReference_setSpecies(reactant, "Node1");
  SpeciesReference_setStoichiometry(reactant, 1);
  SpeciesReference_setConstant(reactant, 1);
  product = Reaction_createProduct(reaction);
  SpeciesReference_setSpecies(product, "Node4");
  SpeciesReference_setStoichiometry(product, 1);
  SpeciesReference_setConstant(product, 1);

  reaction = Model_createReaction(model);
  Reaction_setId(reaction, "J4");
  Reaction_setReversible(reaction, 0);
  Reaction_setFast(reaction, 0);
  reactant = Reaction_createReactant(reaction);
  SpeciesReference_setSpecies(reactant, "Node4");
  SpeciesReference_setStoichiometry(reactant, 1);
  SpeciesReference_setConstant(reactant, 1);
  product = Reaction_createProduct(reaction);
  SpeciesReference_setSpecies(product, "Node3");
  SpeciesReference_setStoichiometry(product, 1);
  SpeciesReference_setConstant(product, 1);

  reaction = Model_createReaction(model);
  Reaction_setId(reaction, "J5");
  Reaction_setReversible(reaction, 0);
  Reaction_setFast(reaction, 0);
  reactant = Reaction_createReactant(reaction);
  SpeciesReference_setSpecies(reactant, "Node3");
  SpeciesReference_setStoichiometry(reactant, 1);
  SpeciesReference_setConstant(reactant, 1);
  product = Reaction_createProduct(reaction);
  SpeciesReference_setSpecies(product, "Node5");
  SpeciesReference_setStoichiometry(product, 1);
  SpeciesReference_setConstant(product, 1);

  reaction = Model_createReaction(model);
  Reaction_setId(reaction, "J6");
  Reaction_setReversible(reaction, 0);
  Reaction_setFast(reaction, 0);
  reactant = Reaction_createReactant(reaction);
  SpeciesReference_setSpecies(reactant, "Node5");
  SpeciesReference_setStoichiometry(reactant, 1);
  SpeciesReference_setConstant(reactant, 1);
  product = Reaction_createProduct(reaction);
  SpeciesReference_setSpecies(product, "Node6");
  SpeciesReference_setStoichiometry(product, 1);
  SpeciesReference_setConstant(product, 1);

  reaction = Model_createReaction(model);
  Reaction_setId(reaction, "J7");
  Reaction_setReversible(reaction, 0);
  Reaction_setFast(reaction, 0);
  reactant = Reaction_createReactant(reaction);
  SpeciesReference_setSpecies(reactant, "Node6");
  SpeciesReference_setStoichiometry(reactant, 1);
  SpeciesReference_setConstant(reactant, 1);
  product = Reaction_createProduct(reaction);
  SpeciesReference_setSpecies(product, "Node7");
  SpeciesReference_setStoichiometry(product, 1);
  SpeciesReference_setConstant(product, 1);

  reaction = Model_createReaction(model);
  Reaction_setId(reaction, "J8");
  Reaction_setReversible(reaction, 0);
  Reaction_setFast(reaction, 0);
  reactant = Reaction_createReactant(reaction);
  SpeciesReference_setSpecies(reactant, "Node5");
  SpeciesReference_setStoichiometry(reactant, 1);
  SpeciesReference_setConstant(reactant, 1);
  product = Reaction_createProduct(reaction);
  SpeciesReference_setSpecies(product, "Node8");
  SpeciesReference_setStoichiometry(product, 1);
  SpeciesReference_setConstant(product, 1);

  reaction = Model_createReaction(model);
  Reaction_setId(reaction, "J9");
  Reaction_setReversible(reaction, 0);
  Reaction_setFast(reaction, 0);
  reactant = Reaction_createReactant(reaction);
  SpeciesReference_setSpecies(reactant, "Node8");
  SpeciesReference_setStoichiometry(reactant, 1);
  SpeciesReference_setConstant(reactant, 1);
  product = Reaction_createProduct(reaction);
  SpeciesReference_setSpecies(product, "Node7");
  SpeciesReference_setStoichiometry(product, 1);
  SpeciesReference_setConstant(product, 1);

  reaction = Model_createReaction(model);
  Reaction_setId(reaction, "J10");
  Reaction_setReversible(reaction, 0);
  Reaction_setFast(reaction, 0);
  reactant = Reaction_createReactant(reaction);
  SpeciesReference_setSpecies(reactant, "Node7");
  SpeciesReference_setStoichiometry(reactant, 1);
  SpeciesReference_setConstant(reactant, 1);
  product = Reaction_createProduct(reaction);
  SpeciesReference_setSpecies(product, "Node9");
  SpeciesReference_setStoichiometry(product, 1);
  SpeciesReference_setConstant(product, 1);

  // Get a SBasePlugin_t object plugged in the model object.

  modelPlug = SBase_getPlugin((SBase_t *)(model), "fbc");

  // create the fluxBound object and add it to model plugin

  fluxBound = FluxBound_create(3, 1, 1);
  FluxBound_setId(fluxBound, "bound1");
  FluxBound_setReaction(fluxBound, "J0");
  FluxBound_setOperation(fluxBound, "equal");
  FluxBound_setValue(fluxBound, 10);

  FbcModelPlugin_addFluxBound(modelPlug, fluxBound);

  // create the objective object and add it to model plugin

  objective = Objective_create(3, 1, 1);
  Objective_setId(objective, "obj1");
  Objective_setType(objective, "maximize");

  fluxObjective = Objective_createFluxObjective(objective);
  FluxObjective_setReaction(fluxObjective, "J8");
  FluxObjective_setCoefficient(fluxObjective, 1);

  FbcModelPlugin_addObjective(modelPlug, objective);

  // mark obj1 as active objective
  FbcModelPlugin_setActiveObjectiveId(modelPlug, "obj1");

  /* write the file */
  writeSBMLToFile(doc, "fbc_example1.xml");

  return retval;
}