コード例 #1
0
END_TEST


START_TEST (test_SBMLDocument_setModel)
{
  SBMLDocument_t *d  = SBMLDocument_createWithLevelAndVersion(2, 4);
  Model_t        *m1 = Model_create(2, 4);
  Model_t        *m2 = Model_create(2, 4);
  Model_t        *mout;

  fail_unless(SBMLDocument_getModel(d) == NULL);

  int i = SBMLDocument_setModel(d, m1);
  fail_unless ( i == LIBSBML_OPERATION_SUCCESS );
  mout = SBMLDocument_getModel(d);
  fail_unless(mout != NULL);
  fail_unless(mout != m1);

  /* Reflexive case (pathological) */
  i = SBMLDocument_setModel(d, SBMLDocument_getModel(d));
  fail_unless ( i == LIBSBML_OPERATION_SUCCESS );
  mout = SBMLDocument_getModel(d);
  fail_unless(mout != NULL);
  fail_unless(mout != m1);

  i = SBMLDocument_setModel(d, m2);
  fail_unless ( i == LIBSBML_OPERATION_SUCCESS );
  mout = SBMLDocument_getModel(d);
  fail_unless(mout != NULL);
  fail_unless(mout != m2);

  SBMLDocument_free(d);
  /* m1 is freed by SBMLDocument_setModel(d, m2); */
}
コード例 #2
0
ファイル: sbml_size.c プロジェクト: evlog/SysPy
int main(int argc, char** argv)
{
    myspecies_t* species;	//pinakas ximikon stoixeion
    reaction_t *reaction;	//20 ximikes antidraseis
    int i,j,k,num_species, num_reactions;
    double V;
    FILE *pf1, *pf2, *pf3, *pf4, *pf5, *pf6;

    SBMLDocument_t *d;
    Model_t        *m;
    ListOf_t    *lo;
    Species_t   *sp;
    Reaction_t  *re;
    Parameter_t *p;
    KineticLaw_t *kin;
    SpeciesReference_t *sr;
    Compartment_t *c;

	if(argc != 2)
    {
        printf("Ektelesi: %s <SBML xml>\n", argv[0]);
        exit(-1);
    }

    //anoigo to SBML arxeio
    d = readSBML(argv[1]);
    //d=readSBML("C:/home/orsalia/BIOMD0000000001");
    m = SBMLDocument_getModel(d);
    num_species = Model_getNumSpecies(m);
    num_reactions = Model_getNumReactions(m);

    printf("M: %d\n", num_species);
    printf("R: %d\n", num_reactions);
}
コード例 #3
0
ファイル: drawMath.c プロジェクト: copasi/copasi-dependencies
int
main (int argc, char *argv[])
{
  SBMLDocument_t *d;
  Model_t        *m;

  if (argc != 3)
  {
    printf("\n  usage: drawMath <sbml filename> <output dot filename>\n\n");
    return 1;
  }
  
  d = readSBML(argv[1]);
  m = SBMLDocument_getModel(d);

  SBMLDocument_printErrors(d, stdout);

  if ((fout  = fopen( argv[2], "w" )) == NULL )
  {
    printf( "The output file was not opened\n" );
  }
  else
  {
    printMath(m);
    fclose(fout);
  }

  SBMLDocument_free(d);
   
  return 0;
}
コード例 #4
0
ファイル: test_sbml.c プロジェクト: raim/SBML_odeSolver
END_TEST

START_TEST(test_parseModel_basic)
{
	doc = parseModel(EXAMPLES_FILENAME("basic.xml"), 0, 1);
	ck_assert(doc != NULL);
	model = SBMLDocument_getModel(doc);
	ck_assert(model != NULL);
	ck_assert(Model_getNumFunctionDefinitions(model) == 0);
	ck_assert(Model_getNumUnitDefinitions(model) == 0);
	ck_assert(Model_getNumCompartmentTypes(model) == 0);
	ck_assert(Model_getNumSpeciesTypes(model) == 0);
	ck_assert(Model_getNumCompartments(model) == 1);
	ck_assert(Model_getNumSpecies(model) == 2);
	ck_assert(Model_getNumSpeciesWithBoundaryCondition(model) == 0);
	ck_assert(Model_getNumParameters(model) == 1);
	ck_assert(Model_getNumInitialAssignments(model) == 0);
	ck_assert(Model_getNumRules(model) == 0);
	ck_assert(Model_getNumConstraints(model) == 0);
	ck_assert(Model_getNumReactions(model) == 2);
	ck_assert(Model_getNumEvents(model) == 0);
	CHECK_PARAMETER(model, 0, "k_1");
	CHECK_REACTION(model, 0, "R1", "k_1 * S1");
	CHECK_REACTION(model, 1, "R2", "k_2 * S2");
}
コード例 #5
0
ファイル: test_sbml.c プロジェクト: raim/SBML_odeSolver
END_TEST

START_TEST(test_parseModel_repressilator)
{
	doc = parseModel(EXAMPLES_FILENAME("repressilator.xml"), 0, 1);
	ck_assert(doc != NULL);
	model = SBMLDocument_getModel(doc);
	ck_assert(model != NULL);
	ck_assert(Model_getNumFunctionDefinitions(model) == 0);
	ck_assert(Model_getNumUnitDefinitions(model) == 0);
	ck_assert(Model_getNumCompartmentTypes(model) == 0);
	ck_assert(Model_getNumSpeciesTypes(model) == 0);
	ck_assert(Model_getNumCompartments(model) == 1);
	ck_assert(Model_getNumSpecies(model) == 6);
	ck_assert(Model_getNumSpeciesWithBoundaryCondition(model) == 0);
	ck_assert(Model_getNumParameters(model) == 3);
	ck_assert(Model_getNumInitialAssignments(model) == 0);
	ck_assert(Model_getNumRules(model) == 6);
	ck_assert(Model_getNumConstraints(model) == 0);
	ck_assert(Model_getNumReactions(model) == 0);
	ck_assert(Model_getNumEvents(model) == 0);
	CHECK_PARAMETER(model, 0, "alpha");
	CHECK_PARAMETER(model, 1, "beta");
	CHECK_PARAMETER(model, 2, "rho");
	CHECK_RULE(model, 0, "beta * (y1 - x1)");
	CHECK_RULE(model, 1, "beta * (y2 - x2)");
	CHECK_RULE(model, 2, "beta * (y3 - x3)");
	CHECK_RULE(model, 3, "alpha * x1 / (1 + x1 + rho * x3) - y1");
	CHECK_RULE(model, 4, "alpha * x2 / (1 + x2 + rho * x1) - y2");
	CHECK_RULE(model, 5, "alpha * x3 / (1 + x3 + rho * x2) - y3");
}
コード例 #6
0
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);
}
コード例 #7
0
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);
}
コード例 #8
0
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);
}
コード例 #9
0
ファイル: test_odeSolver.c プロジェクト: raim/SBML_odeSolver
END_TEST

START_TEST(test_Model_odeSolver_repressilator)
{
	doc = parseModel(EXAMPLES_FILENAME("repressilator.xml"), 0, 1);
	model = SBMLDocument_getModel(doc);
	results = Model_odeSolver(model, cs);
	ck_assert(results != NULL);
}
コード例 #10
0
void
RDFAnnotation_C_setup (void)
{
  char *filename = safe_strcat(TestDataDirectory, "annotation.xml");

  // The following will return a pointer to a new SBMLDocument.
  d = readSBML(filename);
  m = SBMLDocument_getModel(d);
}
コード例 #11
0
int
main (int argc, char *argv[])
{
  const char *filename;

  SBMLDocument_t *d;
  Model_t        *m;

  unsigned int level, version;


  if (argc != 2)
  {
    printf("Usage: printSBML filename\n");
    return 2;
  }


  filename = argv[1];
  d        = readSBML(filename);

  SBMLDocument_printErrors(d, stdout);

  m = SBMLDocument_getModel(d);

  level   = SBMLDocument_getLevel  (d);
  version = SBMLDocument_getVersion(d);

  printf("\n");
  printf("File: %s (Level %u, version %u)\n", filename, level, version);

  if (m == NULL)
  {
    printf("No model present.");
    return 1;
  }

  printf("         ");
  printf("  model id: %s\n",  Model_isSetId(m) ? Model_getId(m) : "(empty)");

  printf( "functionDefinitions: %d\n",  Model_getNumFunctionDefinitions(m) );
  printf( "    unitDefinitions: %d\n",  Model_getNumUnitDefinitions    (m) );
  printf( "   compartmentTypes: %d\n",  Model_getNumCompartmentTypes   (m) );
  printf( "        specieTypes: %d\n",  Model_getNumSpeciesTypes       (m) );
  printf( "       compartments: %d\n",  Model_getNumCompartments       (m) );
  printf( "            species: %d\n",  Model_getNumSpecies            (m) );
  printf( "         parameters: %d\n",  Model_getNumParameters         (m) );
  printf( " initialAssignments: %d\n",  Model_getNumInitialAssignments (m) );
  printf( "              rules: %d\n",  Model_getNumRules              (m) );
  printf( "        constraints: %d\n",  Model_getNumConstraints        (m) );
  printf( "          reactions: %d\n",  Model_getNumReactions          (m) );
  printf( "             events: %d\n",  Model_getNumEvents             (m) );
  printf( "\n" );

  SBMLDocument_free(d);
  return 0;
}
コード例 #12
0
ファイル: test_odeSolver.c プロジェクト: raim/SBML_odeSolver
END_TEST

START_TEST(test_Model_odeSolver_events_2_events_1_assignment_l2)
{
	doc = parseModel(EXAMPLES_FILENAME("events-2-events-1-assignment-l2.xml"), 0, 1);
	model = SBMLDocument_getModel(doc);
	results = Model_odeSolver(model, cs);
	ck_assert(results != NULL);
}
コード例 #13
0
ファイル: test_odeSolver.c プロジェクト: raim/SBML_odeSolver
END_TEST

START_TEST(test_Model_odeSolver_basic_model1_forward_l2)
{
	doc = parseModel(EXAMPLES_FILENAME("basic-model1-forward-l2.xml"), 0, 1);
	model = SBMLDocument_getModel(doc);
	results = Model_odeSolver(model, cs);
	ck_assert(results != NULL);
}
コード例 #14
0
END_TEST


START_TEST (test_SBMLDocument_setModel2)
{
  SBMLDocument_t *d  = SBMLDocument_createWithLevelAndVersion(2, 2);
  
  Model_t        *m1 = Model_create(1, 2);

  int i = SBMLDocument_setModel(d, m1);

  fail_unless ( i == LIBSBML_LEVEL_MISMATCH);
  fail_unless (SBMLDocument_getModel(d) == 0);

  SBMLDocument_free(d);
}
コード例 #15
0
END_TEST


START_TEST (test_SBMLDocument_setModel3)
{
  SBMLDocument_t *d  = SBMLDocument_createWithLevelAndVersion(2, 2);
  
  Model_t        *m1 = Model_create(2, 2);

  int i = SBMLDocument_setModel(d, m1);

  fail_unless ( i == LIBSBML_OPERATION_SUCCESS);
  fail_unless (SBMLDocument_getModel(d) != 0);

  SBMLDocument_free(d);
}
コード例 #16
0
int
main (int argc, char *argv[]){
  int i, j;
  char *model;
  double time;
  double printstep;
  /* libSBML types */
  SBMLDocument_t *d;
  SBMLReader_t *sr;
  Model_t *m;
  Reaction_t *r;
  KineticLaw_t *kl;
  ASTNode_t *nary;
  ASTNode_t *diff;
  /* SOSlib types */
  SBMLResults_t *results;
  timeCourse_t *tc;
  cvodeSettings_t *set;

  /* parsing command-line arguments */
  if (argc < 4 ) {
    fprintf(stderr,
	    "usage %s sbml-model-file simulation-time time-steps\n",
            argv[0]);
    exit(EXIT_FAILURE);
  }
  model = argv[1];
  time = atof(argv[2]);
  printstep = atoi(argv[3]); 

  /* parsing the SBML model with libSBML */
  sr = SBMLReader_create();
  d = SBMLReader_readSBML(sr, model);
  SBMLReader_free(sr);

  m = SBMLDocument_getModel(d);

  r = Model_getReaction(m,0);
  kl = Reaction_getKineticLaw(r);
  nary = KineticLaw_getMath(kl);
  printf("N-ary formula: %s\n", SBML_formulaToString(nary));
  diff = differentiateAST(nary, "Product");
  printf("N-ary diff: %s\n", SBML_formulaToString(diff));
  ASTNode_free(diff);

  return (EXIT_SUCCESS);  
}
コード例 #17
0
ファイル: test_sbml.c プロジェクト: raim/SBML_odeSolver
END_TEST

START_TEST(test_parseModel_huang96)
{
	doc = parseModel(EXAMPLES_FILENAME("huang96.xml"), 0, 1);
	ck_assert(doc != NULL);
	model = SBMLDocument_getModel(doc);
	ck_assert(model != NULL);
	ck_assert(Model_getNumFunctionDefinitions(model) == 0);
	ck_assert(Model_getNumUnitDefinitions(model) == 0);
	ck_assert(Model_getNumCompartmentTypes(model) == 0);
	ck_assert(Model_getNumSpeciesTypes(model) == 0);
	ck_assert(Model_getNumCompartments(model) == 1);
	ck_assert(Model_getNumSpecies(model) == 22);
	ck_assert(Model_getNumSpeciesWithBoundaryCondition(model) == 0);
	ck_assert(Model_getNumParameters(model) == 0);
	ck_assert(Model_getNumInitialAssignments(model) == 0);
	ck_assert(Model_getNumRules(model) == 0);
	ck_assert(Model_getNumConstraints(model) == 0);
	ck_assert(Model_getNumReactions(model) == 20);
	ck_assert(Model_getNumEvents(model) == 0);
	CHECK_REACTION(model, 0, "r1a", "a1 * E1 * KKK - d1 * E1_KKK");
	CHECK_REACTION(model, 1, "r1b", "k2 * E1_KKK");
	CHECK_REACTION(model, 2, "r2a", "a2 * E2 * P_KKK - d2 * E2_P_KKK");
	CHECK_REACTION(model, 3, "r2b", "k2 * E2_P_KKK");
	CHECK_REACTION(model, 4, "r3a", "a3 * KK * P_KKK - d3 * P_KKK_KK");
	CHECK_REACTION(model, 5, "r3b", "k3 * P_KKK_KK");
	CHECK_REACTION(model, 6, "r4a", "a4 * P_KK * KKPase - d4 * KKPase_P_KK");
	CHECK_REACTION(model, 7, "r4b", "k4 * KKPase_P_KK");
	CHECK_REACTION(model, 8, "r5a", "a5 * P_KK * P_KKK - d5 * P_KKK_P_KK");
	CHECK_REACTION(model, 9, "r5b", "k5 * P_KKK_P_KK");
	CHECK_REACTION(model, 10, "r6a", "a6 * PP_KK * KKPase - d6 * KKPase_PP_KK");
	CHECK_REACTION(model, 11, "r6b", "k6 * KKPase_PP_KK");
	CHECK_REACTION(model, 12, "r7a", "a7 * K * PP_KK - d7 * PP_KK_K");
	CHECK_REACTION(model, 13, "r7b", "k7 * PP_KK_K");
	CHECK_REACTION(model, 14, "r8a", "a8 * P_K * KPase - d8 * KPase_P_K");
	CHECK_REACTION(model, 15, "r8b", "k8 * KPase_P_K");
	CHECK_REACTION(model, 16, "r9a", "a9 * P_K * PP_KK - d9 * PP_KK_P_K");
	CHECK_REACTION(model, 17, "r9b", "k9 * PP_KK_P_K");
	CHECK_REACTION(model, 18, "r10a", "a10 * PP_K * KPase - d10 * KPase_PP_K");
	CHECK_REACTION(model, 19, "r10b", "k10 * KPase_PP_K");
	/* TODO */
}
コード例 #18
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);
}
コード例 #19
0
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);
}
コード例 #20
0
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);
}
コード例 #21
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);
}
コード例 #22
0
ファイル: printMath.c プロジェクト: 0u812/roadrunner-backup
int
main (int argc, char *argv[])
{
  SBMLDocument_t *d;
  Model_t        *m;


  if (argc != 2)
  {
    printf("Usage: printMath filename\n");
    return 1;
  }

  d = readSBML(argv[1]);
  m = SBMLDocument_getModel(d);

  SBMLDocument_printErrors(d, stdout);

  printMath(m);
  printf("\n");

  SBMLDocument_free(d);
  return 0;
}
コード例 #23
0
ファイル: test_sbml.c プロジェクト: raim/SBML_odeSolver
END_TEST

START_TEST(test_parseModel_events_1_event_1_assignment_l2)
{
	doc = parseModel(EXAMPLES_FILENAME("events-1-event-1-assignment-l2.xml"), 0, 1);
	ck_assert(doc != NULL);
	model = SBMLDocument_getModel(doc);
	ck_assert(model != NULL);
	ck_assert(Model_getNumFunctionDefinitions(model) == 0);
	ck_assert(Model_getNumUnitDefinitions(model) == 0);
	ck_assert(Model_getNumCompartmentTypes(model) == 0);
	ck_assert(Model_getNumSpeciesTypes(model) == 0);
	ck_assert(Model_getNumCompartments(model) == 1);
	ck_assert(Model_getNumSpecies(model) == 2);
	ck_assert(Model_getNumSpeciesWithBoundaryCondition(model) == 0);
	ck_assert(Model_getNumParameters(model) == 0);
	ck_assert(Model_getNumInitialAssignments(model) == 0);
	ck_assert(Model_getNumRules(model) == 0);
	ck_assert(Model_getNumConstraints(model) == 0);
	ck_assert(Model_getNumReactions(model) == 1);
	ck_assert(Model_getNumEvents(model) == 1);
	CHECK_REACTION(model, 0, "R", "S1");
	/* TODO */
}
コード例 #24
0
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 );
}
コード例 #25
0
int
main (int argc, char* argv[])
{
  unsigned int i,j,errors;
  const char* filename;
  SBMLDocument_t* document;
  Model_t* m;

  if (argc != 2)
  {
    printf("\nUsage: printNotes filename\n\n");
    return 1;
  }

  filename  = argv[1];
  document  = readSBML(filename);

  errors = SBMLDocument_getNumErrors( document);

  printf("\n%s\n\n", filename);

  if(errors > 0)
  {
    SBMLDocument_printErrors(document, stderr);
    SBMLDocument_free(document);
    return errors;
  }


  /* Model */

  m = SBMLDocument_getModel(document);
  printNotes((SBase_t*)m, Model_getId(m));

  for(i=0; i < Model_getNumReactions(m); i++)
  {
    Reaction_t* re = Model_getReaction( m, i);
    printNotes((SBase_t*)re, Reaction_getId(re));

    /* SpeciesReference (Reactant) */

    for(j=0; j < Reaction_getNumReactants( re); j++)
    {
      SpeciesReference_t* rt =  Reaction_getReactant(re, j);
      if (SBase_isSetNotes((SBase_t*) rt)) printf("   ");
      printNotes((SBase_t*)rt, SpeciesReference_getSpecies( rt ) );
    }

    /* SpeciesReference (Product) */

    for(j=0; j < Reaction_getNumProducts( re ); j++)
    {
      SpeciesReference_t* rt = Reaction_getProduct( re, j);
      if (SBase_isSetNotes((SBase_t*) rt)) printf("   ");
      printNotes((SBase_t*)rt, SpeciesReference_getSpecies( rt ) );
    }

    /* ModifierSpeciesReference (Modifiers) */

    for(j=0; j < Reaction_getNumModifiers( re ); j++)
    {
      SpeciesReference_t* md = Reaction_getModifier(re, j);
      if (SBase_isSetNotes((SBase_t*) md)) printf("   ");
      printNotes((SBase_t*)md, SpeciesReference_getSpecies( md ) );
    }

    /* KineticLaw */

    if(Reaction_isSetKineticLaw( re ))
    {
      KineticLaw_t* kl = Reaction_getKineticLaw( re );
      if (SBase_isSetNotes((SBase_t*) kl)) printf("   ");
      printNotes((SBase_t*)kl, "");

      /* Parameter */

      for(j=0; j < KineticLaw_getNumParameters( kl ); j++)
      {
        Parameter_t* pa = KineticLaw_getParameter( kl, j);
        if (SBase_isSetNotes((SBase_t*) pa)) printf("   ");
        printNotes((SBase_t*)pa, Parameter_getId(pa));
      }
    }

  }

  /* Species */

  for(i=0; i < Model_getNumSpecies(m); i++)
  {
    Species_t* sp = Model_getSpecies(m, i);
    printNotes((SBase_t*)sp, Species_getId(sp));
  }

  /* Compartments */

  for(i=0; i < Model_getNumCompartments( m ); i++)
  {
    Compartment_t* sp = Model_getCompartment(m, i);
    printNotes((SBase_t*)sp, Compartment_getId(sp));
  }

  /* FunctionDefinition */

  for(i=0; i < Model_getNumFunctionDefinitions(m); i++)
  {
    FunctionDefinition_t* sp = Model_getFunctionDefinition(m, i);
    printNotes((SBase_t*)sp, FunctionDefinition_getId(sp));
  }

  /* UnitDefinition */

  for(i=0; i < Model_getNumUnitDefinitions(m); i++)
  {
    UnitDefinition_t* sp = Model_getUnitDefinition( m, i);
    printNotes((SBase_t*)sp, UnitDefinition_getId(sp));
  }

  /* Parameter */

  for(i=0; i < Model_getNumParameters( m ); i++)
  {
    Parameter_t* sp = Model_getParameter( m, i);
    printNotes((SBase_t*)sp, Parameter_getId(sp));
  }

  /* Rule */

  for(i=0; i < Model_getNumReactions( m ); i++)
  {
    Rule_t* sp = Model_getRule(m, i);
    printNotes((SBase_t*)sp, "");
  }

  /* InitialAssignment */

  for(i=0; i < Model_getNumInitialAssignments(m); i++)
  {
    InitialAssignment_t* sp = Model_getInitialAssignment(m, i);
    printNotes((SBase_t*)sp, "");
  }

  /* Event */

  for(i=0; i < Model_getNumEvents(m); i++)
  {
    Event_t* sp = Model_getEvent(m, i);
    printNotes((SBase_t*)sp, Event_getId(sp));

    /* Trigger */

    if(Event_isSetTrigger( sp ))
    {
      Trigger_t* tg = Event_getTrigger(sp);
      if (SBase_isSetNotes( (SBase_t*) tg)) printf( "   " );
      printNotes((SBase_t*)tg, "");
    }

    /* Delay */

    if(Event_isSetDelay(sp))
    {
      Delay_t* dl = Event_getDelay(sp);
      if (SBase_isSetNotes( (SBase_t*) dl)) printf( "   " );
      printNotes((SBase_t*) dl, "");
    }

    /* EventAssignment */

    for(j=0; j < Event_getNumEventAssignments(sp); j++)
    {
      EventAssignment_t* ea = Event_getEventAssignment(sp, j);
      if (SBase_isSetNotes( (SBase_t*) ea)) printf( "   " );      
      printNotes((SBase_t*)ea, "");
    }
  }

  /* SpeciesType */

  for(i=0; i < Model_getNumSpeciesTypes(m); i++)
  {
    SpeciesType_t* sp = Model_getSpeciesType(m, i);
    printNotes((SBase_t*)sp, SpeciesType_getId(sp));
  }

  /* Constraints */

  for(i=0; i < Model_getNumConstraints(m); i++)
  {
    Constraint_t* sp = Model_getConstraint(m, i);
    printNotes((SBase_t*)sp, "");
  }

  SBMLDocument_free( document );
  return errors;
}
コード例 #26
0
int
main (int argc, char* argv[])
{
  char         *line;
  char         *result;
  char         *buffer  = (char*)calloc( 1, sizeof(char) );
  unsigned long len;
  L3ParserSettings_t* settings;
  int           reading = 1;
  SBMLDocument_t*   doc = NULL;


  printf( "\n" );
  printf( "This program translates infix formulas into MathML and\n" );
  printf( "vice-versa.  An 'enter' or a 'return' on an empty line\n" );
  printf( "triggers translation.\n" );
  printf( "\n" );

  settings = L3ParserSettings_create();
  while (reading)
  {
    printf( "Enter infix formula, MathML expression, \n");
    printf( "or change parsing rules with the keywords:\n");
    printf( "LOG_AS_LOG10, LOG_AS_LN, LOG_AS_ERROR, EXPAND_UMINUS, ");
    printf( "COLLAPSE_UMINUS, TARGETL2, TARGETL3, NO_UNITS, UNITS, ");
    printf( "or FILE:<filename>\n\n\n" );
    printf( "> " );

    do
    {
      line = trim_whitespace(get_line(stdin));
      len  = (unsigned int)strlen(line);

      if (len > 0)
      {
        buffer = (char *) realloc( buffer, 1 + strlen(buffer) + len );

        if (strcmp(line, "LOG_AS_LOG10")==0) {
          L3ParserSettings_setParseLog(settings, L3P_PARSE_LOG_AS_LOG10);
          printf( "Now parsing 'log(x)' as 'log10(x)'\n\n> ");
        }
        else if (strcmp(line, "LOG_AS_LN")==0) {
          L3ParserSettings_setParseLog(settings, L3P_PARSE_LOG_AS_LN);
          printf( "Now parsing 'log(x)' as 'ln(x)'\n\n> ");
        }
        else if (strcmp(line, "LOG_AS_ERROR")==0) {
          L3ParserSettings_setParseLog(settings, L3P_PARSE_LOG_AS_ERROR);
          printf( "Now parsing 'log(x)' as an error\n\n> ");
        }
        else if (strcmp(line, "EXPAND_UMINUS")==0) {
          L3ParserSettings_setParseCollapseMinus(settings, 0);
          printf( "Will now leave multiple unary minuses expanded, ");
          printf("and all negative numbers will be translated using the ");
          printf("<minus> construct.\n\n> ");
        }
        else if (strcmp(line, "COLLAPSE_UMINUS")==0) {
          L3ParserSettings_setParseCollapseMinus(settings, 1);
          printf( "Will now collapse multiple unary minuses, and incorporate ");
          printf("a negative sign into digits.\n\n> ");
        }
        else if (strcmp(line, "NO_UNITS")==0) {
          L3ParserSettings_setParseUnits(settings, 0);
          printf( "Will now target MathML but with no units on numbers.\n\n> ");
        }
        else if (strcmp(line, "UNITS")==0) {
          L3ParserSettings_setParseUnits(settings, 1);
          printf( "Will now target MathML but with units on numbers.\n\n> ");
        }
        else if (line[0] == 'F' && line[1] == 'I' && line[2]=='L' 
          && line[3]=='E' && line[4]==':') {
		  int len = strlen(line);
		  char *filename = (char*) malloc(len-5+1);
		  strncpy(filename, line+5, len-5);
		  SBMLDocument_free(doc);
          doc = readSBMLFromFile(filename);
          if (SBMLDocument_getModel(doc)==NULL) {
            printf( "File '%s' not found or no model present.", filename);
            printf( "Clearing the Model parsing object.\n\n> ");
          }
          else {
            printf( "Using model from file %s to parse infix:", filename);
            printf( "all symbols present in that model will not be translated ");
            printf( "as native MathML or SBML-defined elements.\n\n> ");;
          }
          L3ParserSettings_setModel(settings, SBMLDocument_getModel(doc));
        }
        else
        {
          strncat(buffer, line, len);
          strncat(buffer, "\n", 1);
        }
      }
      else
      {
        result = (buffer[0] == '<') ?
          translateMathML(buffer) : translateInfix(buffer, settings);

        printf("Result:\n\n%s\n\n\n", result);

        free(result);
        reading = 0;
      }
    }
    while (len > 0);

  }

  free(line);
  return 0;
}
コード例 #27
0
int
main (int argc, char* argv[])
{
  unsigned int i,j,errors;
  const char* filename   = argv[1];
  SBMLDocument_t* document;
  Model_t* m;

  if (argc != 3)
  {
    printf("\nUsage: unsetNotes <input-filename> <output-filename>\n");
    return 1;
  }

  filename = argv[1];  
  document = readSBML(filename);

  errors =  SBMLDocument_getNumErrors(document);

  if(errors > 0)
  {
    SBMLDocument_printErrors(document, stderr);
    SBMLDocument_free(document);
    return errors;
  }

  m = SBMLDocument_getModel( document );
  SBase_unsetNotes((SBase_t*)m);

  for(i=0; i < Model_getNumReactions(m); i++)
  {
    Reaction_t* re = Model_getReaction(m, i);
    SBase_unsetNotes((SBase_t*)re);

    for(j=0; j < Reaction_getNumReactants(re); j++)
    {
      SpeciesReference_t* rt = Reaction_getReactant(re,j);
      SBase_unsetNotes((SBase_t*)rt);
    }

    for(j=0; j < Reaction_getNumProducts(re); j++)
    {
      SpeciesReference_t* rt = Reaction_getProduct(re,j);
      SBase_unsetNotes((SBase_t*)rt);
    }

    for(j=0; j < Reaction_getNumModifiers(re); j++)
    {
      SpeciesReference_t* md = Reaction_getModifier(re,j);
      SBase_unsetNotes((SBase_t*)md);
    }

    if(Reaction_isSetKineticLaw(re))
    {
      KineticLaw_t* kl =  Reaction_getKineticLaw(re);
      SBase_unsetNotes((SBase_t*)kl);

      for(j=0; j < KineticLaw_getNumParameters(kl); j++)
      {
        Parameter_t* pa = KineticLaw_getParameter(kl, j);
        SBase_unsetNotes((SBase_t*)pa);
      }
    }

  }

  for(i=0; i < Model_getNumSpecies(m); i++)
  {
    Species_t* sp = Model_getSpecies(m, i);
    SBase_unsetNotes((SBase_t*)sp);
  }

  for(i=0; i < Model_getNumCompartments(m); i++)
  {
    Compartment_t* sp = Model_getCompartment(m,i);
    SBase_unsetNotes((SBase_t*)sp);
  }

  for(i=0; i < Model_getNumFunctionDefinitions(m); i++)
  {
    FunctionDefinition_t* sp = Model_getFunctionDefinition(m,i);
    SBase_unsetNotes((SBase_t*)sp);
  }

  for(i=0; i < Model_getNumUnitDefinitions(m); i++)
  {
    UnitDefinition_t* sp = Model_getUnitDefinition(m, i);
    SBase_unsetNotes((SBase_t*)sp);
  }

  for(i=0; i < Model_getNumParameters(m); i++)
  {
    Parameter_t* sp = Model_getParameter(m, i);
    SBase_unsetNotes((SBase_t*)sp);
  }

  for(i=0; i < Model_getNumRules(m); i++)
  {
    Rule_t* sp = Model_getRule(m, i);
    SBase_unsetNotes((SBase_t*)sp);
  }

  for(i=0; i < Model_getNumInitialAssignments(m); i++)
  {
    InitialAssignment_t* sp = Model_getInitialAssignment(m, i);
    SBase_unsetNotes((SBase_t*)sp);
  }

  for(i=0; i < Model_getNumEvents(m); i++)
  {
    Event_t* sp = Model_getEvent(m, i);
    SBase_unsetNotes((SBase_t*)sp);

    for(j=0; j < Event_getNumEventAssignments(sp); j++)
    {
      EventAssignment_t* ea = Event_getEventAssignment(sp, j);
      SBase_unsetNotes((SBase_t*)ea);
    }
  }

  for(i=0; i < Model_getNumSpeciesTypes(m); i++)
  {
    SpeciesType_t* sp = Model_getSpeciesType(m, i);
    SBase_unsetNotes((SBase_t*)sp);
  }

  for(i=0; i < Model_getNumConstraints(m); i++)
  {
    Constraint_t* sp = Model_getConstraint(m, i);
    SBase_unsetNotes((SBase_t*)sp);
  }

  writeSBML(document, argv[2]);

  SBMLDocument_free(document);
  return errors;
}
コード例 #28
0
ファイル: interactive.c プロジェクト: bareqsh/SBML_odeSolver
void
interactive() {
  
  char *sbmlFilename;
  char *select;
  int quit;
  SBMLDocument_t *d  = NULL;
  Model_t        *m  = NULL;
  odeModel_t *om     = NULL;
  cvodeData_t * data = NULL;
  integratorInstance_t *ii = NULL;
  cvodeSettings_t *set = NULL;

  printf("\n\nWelcome to the simple SBML ODE solver.\n");
  printf("You have entered the interactive mode.\n");
  printf("All other commandline options have been ignored.\n");
  printf("Have fun!\n\n");

  initializeOptions();
  /* reset steady state */
  Opt.SteadyState = 0;
  /* activate printing of results to XMGrace */
  Opt.Xmgrace = 1;
  /* activate printing integrator messages */
  Opt.PrintMessage = 1;
  /* deactivate on the fly printing of results */
  Opt.PrintOnTheFly = 0;

  sbmlFilename = concat(Opt.ModelPath, Opt.ModelFile);

  if ( (d = parseModelWithArguments(sbmlFilename)) == 0 )
  {
    Warn(stderr, "%s:%d interactive(): Can't parse Model >%s<",
	  __FILE__, __LINE__, sbmlFilename);
    d = loadFile();
  }

  /* load models and default settings */
  m = SBMLDocument_getModel(d);
  om = ODEModel_create(m);
  set = CvodeSettings_create();
  SolverError_dumpAndClearErrors();
  
  quit = 0;
  data = NULL;
  
  while ( quit == 0 ) {

    printf("\n");
    printf("Press (h) for instructions or (q) to quit.\n");
    printf("> ");
    select = get_line( stdin );
    select = util_trim(select);
    printf("\n");

    if( strcmp(select,"l") == 0 ) {
      /* free all existing structures */
      if ( om != NULL )
	ODEModel_free(data->model);
      if ( d != NULL )
	SBMLDocument_free(d);
      if ( ii != NULL )
	IntegratorInstance_free(ii);

      /* load a new file */
      d = loadFile();
      
      /* load new models */
      m = SBMLDocument_getModel(d);
      om = ODEModel_create(m);
      SolverError_dumpAndClearErrors();            
    }

    if(strcmp(select,"h")==0)
      printMenu();
    
    if(strcmp(select,"s")==0)
      printModel(m, stdout);
    
    if(strcmp(select,"c")==0)
      printSpecies(m, stdout);
    
    if(strcmp(select,"r")==0)
      printReactions(m, stdout);
    
    if(strcmp(select,"o")==0)
      printODEs(om, stdout);

    /* integrate interface functions, asks for time and printsteps */
    if(strcmp(select,"i")==0){
      ii = callIntegrator(om, set);
      SolverError_dumpAndClearErrors();
    }

    if(strcmp(select,"x")==0){
      if ( Opt.Xmgrace == 1 ) {
	Opt.Xmgrace = 0;
	printf(" Printing results to stdout\n");
      }
      else if ( Opt.Xmgrace == 0 ) {
	Opt.Xmgrace = 1;
	printf(" Printing results to XMGrace\n");
      }
    }      
    if(strcmp(select,"st")==0)
      printConcentrationTimeCourse(ii->data, stdout);
    
    if(strcmp(select,"jt")==0)
      printJacobianTimeCourse(ii->data, stdout);

    
    if(strcmp(select,"ot")==0)
      printOdeTimeCourse(ii->data, stdout);

    
    if(strcmp(select,"rt")==0)
      printReactionTimeCourse(ii->data, m, stdout);
    
    if(strcmp(select,"xp")==0)
      printPhase(ii->data);
    
    
    if(strcmp(select,"set")==0)
      setValues(m);
    
    
    if(strcmp(select,"ss")==0){
      if ( Opt.SteadyState == 1 ) {
	Opt.SteadyState = 0;
	printf(" Not checking for steady states during integration.\n");
      }
      else if ( Opt.SteadyState == 0 ) {
	Opt.SteadyState = 1;
	printf(" Checking for steady states during integration.\n");
      }
    }

    if(strcmp(select,"uj")==0){
      if ( Opt.Jacobian == 1 ) {
	Opt.Jacobian = 0;
	printf(" Using CVODE's internal approximation\n");
	printf(" of the jacobian matrix for integration\n");
      }
      else if ( Opt.Jacobian == 0 ) {
	Opt.Jacobian = 1;
	printf(" Using automatically generated\n");
	printf(" jacobian matrix for integration\n");
      }
    }
    
    if(strcmp(select,"gf")==0)
      setFormat();
    
    if(strcmp(select,"rg")==0) {
      drawModel(m, sbmlFilename, Opt.GvFormat);
      SolverError_dumpAndClearErrors();
    }
    
    if(strcmp(select,"jg")==0){
      if ( ii == NULL ) {
	data = CvodeData_create(om);
	CvodeData_initialize(data, set, om, 0);
	drawJacoby(data, sbmlFilename, Opt.GvFormat);
	SolverError_dumpAndClearErrors();
	CvodeData_free(data);
      }
      else {
	drawJacoby(ii->data, sbmlFilename, Opt.GvFormat);
	SolverError_dumpAndClearErrors();
      }
    }

    
    if(strcmp(select,"j")==0) {
      if ( om->jacob == NULL )
	ODEModel_constructJacobian(om);
      printJacobian(om, stdout);
    }

    
    if(strcmp(select,"q")==0)
      quit = 1;
    
  }

  if ( ii != NULL )
    IntegratorInstance_free(ii);
  if ( om != NULL ) 
    ODEModel_free(om);

  SBMLDocument_free(d);
  SolverError_dumpAndClearErrors();
  printf("\n\nGood Bye. Thx for using.\n\n");
}
コード例 #29
0
int
main (int argc, char *argv[])
{

  SBMLDocument_t* d;
  Model_t* m;
  unsigned int  errors;

  if (argc != 3)
  {
    printf("\n"
      "  usage: appendAnnotation <input-filename> <output-filename>\n"
      "\n");
    return 2;
  }


  d      = readSBML(argv[1]);
  errors = SBMLDocument_getNumErrors(d);

  if (errors > 0)
  {
    printf("Read Error(s):\n");
    SBMLDocument_printErrors(d, stdout);	 
    printf("Correct the above and re-run.\n");
  }
  else
  {
    int n;
    Species_t* s;

    char* model_history_annotation = 
       "<annotation>\n"
       "  <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\" xmlns:bqbiol=\"http://biomodels.net/biology-qualifiers/\" xmlns:bqmodel=\"http://biomodels.net/model-qualifiers/\">\n"
       "    <rdf:Description rdf:about=\"#\">\n"
       "      <dc:creator rdf:parseType=\"Resource\">\n"
       "        <rdf:Bag>\n"
       "          <rdf:li rdf:parseType=\"Resource\">\n"
       "            <vCard:N rdf:parseType=\"Resource\">\n"
       "              <vCard:Family>Keating</vCard:Family>\n"
       "              <vCard:Given>Sarah</vCard:Given>\n"
       "            </vCard:N>\n"
       "            <vCard:EMAIL>[email protected]</vCard:EMAIL>\n"
       "            <vCard:ORG>\n"
       "              <vCard:Orgname>University of Hertfordshire</vCard:Orgname>\n"
       "            </vCard:ORG>\n"
       "          </rdf:li>\n"
       "        </rdf:Bag>\n"
       "      </dc:creator>\n"
       "      <dcterms:created rdf:parseType=\"Resource\">\n"
       "        <dcterms:W3CDTF>1999-11-13T06:54:32Z</dcterms:W3CDTF>\n"
       "      </dcterms:created>\n"
       "      <dcterms:modified rdf:parseType=\"Resource\">\n"
       "        <dcterms:W3CDTF>2007-11-31T06:54:00-02:00</dcterms:W3CDTF>\n"
       "      </dcterms:modified>\n"
       "    </rdf:Description>\n"
       "  </rdf:RDF>\n"
       "</annotation>\n";
    
    m = SBMLDocument_getModel(d);
    SBase_appendAnnotationString((SBase_t*)m, model_history_annotation);

    /*
     * The above code can be replaced by the following code.
     *

       ModelHistory * h = new ModelHistory();

       ModelCreator *c = new ModelCreator();
       c->setFamilyName("Keating");
       c->setGivenName("Sarah");
       c->setEmail("*****@*****.**");
       c->setOrganisation("University of Hertfordshire");

       h->addCreator(c);

       Date * date = new Date("1999-11-13T06:54:32");
       Date * date2 = new Date("2007-11-31T06:54:00-02:00");

       h->setCreatedDate(date);
       h->setModifiedDate(date2);

       d->getModel()->setModelHistory(h);

      *
      */


    n = Model_getNumSpecies(m);

    if (n > 0)
    {
      char* cvterms_annotation = "<annotation>\n"
        "  <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\" xmlns:bqbiol=\"http://biomodels.net/biology-qualifiers/\" xmlns:bqmodel=\"http://biomodels.net/model-qualifiers/\">\n"
        "    <rdf:Description rdf:about=\"#\">\n"
        "      <bqbiol:isVersionOf>\n"
        "        <rdf:Bag>\n"
        "          <rdf:li rdf:resource=\"http://www.geneontology.org/#GO:0005892\"/>\n"
        "          <rdf:li rdf:resource=\"http://www.ebi.ac.uk/interpro/#IPR002394\"/>\n"
        "        </rdf:Bag>\n"
        "      </bqbiol:isVersionOf>\n"
        "      <bqbiol:is>\n"
        "        <rdf:Bag>\n"
        "          <rdf:li rdf:resource=\"http://www.geneontology.org/#GO:0005895\"/>\n"
        "        </rdf:Bag>\n"
        "      </bqbiol:is>\n"
        "    </rdf:Description>\n"
        "  </rdf:RDF>\n"
        "</annotation>\n";

      s = Model_getSpecies(m, 0);

      SBase_appendAnnotationString((SBase_t*)s, cvterms_annotation);

      /*
       * The above code can be replaced by the following code.
       *

         CVTerm *cv = new CVTerm();
         cv->setQualifierType(BIOLOGICAL_QUALIFIER);
         cv->setBiologicalQualifierType(BQB_IS_VERSION_OF);
         cv->addResource("http://www.geneontology.org/#GO:0005892");

         CVTerm *cv2 = new CVTerm();
         cv2->setQualifierType(BIOLOGICAL_QUALIFIER);
         cv2->setBiologicalQualifierType(BQB_IS);
         cv2->addResource("http://www.geneontology.org/#GO:0005895");

         CVTerm *cv1 = new CVTerm();
         cv1->setQualifierType(BIOLOGICAL_QUALIFIER);
         cv1->setBiologicalQualifierType(BQB_IS_VERSION_OF);
         cv1->addResource("http://www.ebi.ac.uk/interpro/#IPR002394");

         s->addCVTerm(cv);
         s->addCVTerm(cv2);
         s->addCVTerm(cv1);

        *
        */
    }
  
    writeSBML(d, argv[2]);
  }

  SBMLDocument_free(d);
  return errors;
}
コード例 #30
0
int
main (int argc, char *argv[])
{

  SBMLDocument_t* d;
  Model_t* m;
  unsigned int  errors;

  if (argc != 3)
  {
    printf("\n"
      "  usage: addModelHistory <input-filename> <output-filename>\n"
      "\n");
    return 2;
  }


  d      = readSBML(argv[1]);
  errors = SBMLDocument_getNumErrors(d);

  if (errors > 0)
  {
    printf("Read Error(s):\n");
    SBMLDocument_printErrors(d, stdout);	 
    printf("Correct the above and re-run.\n");
  }
  else
  {
    int status;
    Date_t* date, *date2;
    ModelHistory_t* h = ModelHistory_create();
    ModelCreator_t* c = ModelCreator_create();

    ModelCreator_setFamilyName(c, "Keating");
    ModelCreator_setGivenName(c, "Sarah");
    ModelCreator_setEmail(c, "*****@*****.**");
    ModelCreator_setOrganisation(c, "University of Hertfordshire");


    status = ModelHistory_addCreator(h, c);
	  printStatus("Status for addCreator: ", status);

    
    date = Date_createFromString("1999-11-13T06:54:32");
    date2 = Date_createFromString("2007-11-30T06:54:00-02:00");
       
    status = ModelHistory_setCreatedDate(h, date);
	  printStatus("Set created date:      ", status);

    status = ModelHistory_setModifiedDate(h, date2);
	  printStatus("Set modified date:     ", status);

    m = SBMLDocument_getModel(d);
    status =  Model_setModelHistory(m, h);
	  printStatus("Set model history:     ", status);
  
    writeSBML(d, argv[2]);
  }

  SBMLDocument_free(d);
  return errors;
}