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); }
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; }
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; }
void RDFAnnotation2_setup (void) { char *filename = safe_strcat(TestDataDirectory, "annotation2.xml"); // The following will return a pointer to a new SBMLDocument. d2 = readSBML(filename); m2 = d2->getModel(); }
void RDFAnnotationMetaid_setup (void) { char *filename = safe_strcat(TestDataDirectory, "annotationL3_3.xml"); // The following will return a pointer to a new SBMLDocument. d = readSBML(filename); m = d->getModel(); free(filename); }
int main (int argc, char *argv[]) { SBMLDocument_t *doc; if (argc != 4) { printf("Usage: stripPackage input-filename package-to-strip output-filename\n"); return 2; } doc = readSBML(argv[1]); if (SBMLDocument_getNumErrorsWithSeverity(doc, LIBSBML_SEV_ERROR) > 0) { SBMLDocument_printErrors(doc, stderr); } else { /* need new variables ... */ ConversionProperties_t* props; ConversionOption_t* option1; ConversionOption_t* option2; /* create a new conversion properties structure */ props = ConversionProperties_create(); /* add an option that we want to strip a given package */ option1 = ConversionOption_create("stripPackage"); ConversionOption_setType(option1, CNV_TYPE_BOOL); ConversionOption_setValue(option1, "true"); ConversionOption_setDescription(option1, "Strip SBML Level 3 package constructs from the model"); ConversionProperties_addOption(props, option1); /* add an option with the package we want to remove */ option2 = ConversionOption_create("package"); ConversionOption_setType(option2, CNV_TYPE_STRING); ConversionOption_setValue(option2, argv[2]); ConversionOption_setDescription(option2, "Name of the SBML Level 3 package to be stripped"); ConversionProperties_addOption(props, option2); /* perform the conversion */ if (SBMLDocument_convert(doc, props) != LIBSBML_OPERATION_SUCCESS) { printf ("conversion failed ... "); return 3; } /* successfully completed, write the resulting file */ writeSBML(doc, argv[3]); } return 0; }
void CalcUnitDefinition_setup (void) { d = new SBMLDocument(); char *filename = safe_strcat(TestDataDirectory, "calculateUnits.xml"); d = readSBML(filename); m = d->getModel(); }
void DerivedUnitDefinition_setup (void) { d = new SBMLDocument(); char *filename = safe_strcat(TestDataDirectory, "formula.xml"); d = readSBML(filename); m = d->getModel(); }
void FormulaUnitsData_setup (void) { d = new SBMLDocument(); char *filename = safe_strcat(TestDataDirectory, "formula.xml"); d = readSBML(filename); m = d->getModel(); m->populateListFormulaUnitsData(); }
/* * tests the results from different mathematical functions * components that have units * e.g. times */ BEGIN_C_DECLS void UnitFormulaFormatter3Test_setup (void) { char *filename = safe_strcat(TestDataDirectory, "unitsTest.xml"); d = readSBML(filename); m = d->getModel(); uff = new UnitFormulaFormatter(m); safe_free(filename); }
BEGIN_C_DECLS void UnitFormulaFormatter1Test_setup (void) { d = new SBMLDocument(); char *filename = safe_strcat(TestDataDirectory, "components.xml"); d = readSBML(filename); m = d->getModel(); uff = new UnitFormulaFormatter(m); }
int main (int argc, char *argv[]) { const char *filename; #ifdef __BORLANDC__ unsigned long start, stop; #else unsigned long long start, stop; #endif unsigned long size; unsigned int errors = 0; SBMLDocument_t *d; if (argc != 2) { printf("Usage: validateSBML filename\n"); return 2; } filename = argv[1]; start = getCurrentMillis(); d = readSBML(filename); stop = getCurrentMillis(); errors = SBMLDocument_getNumErrors(d); errors += SBMLDocument_checkConsistency(d); size = getFileSize(filename); printf( "\n" ); printf( " filename: %s\n" , filename ); printf( " file size: %lu\n", size ); printf( " read time (ms): %llu\n", stop - start ); printf( " error(s): %u\n" , errors ); if (errors > 0) SBMLDocument_printErrors(d, stdout); printf("\n"); SBMLDocument_free(d); return errors; }
/* * tests the results from different mathematical functions * components that have units * e.g. times */ BEGIN_C_DECLS static void UnitFormulaFormatterTest_setup (void) { d = new SBMLDocument(); char *filename = safe_strcat(TestDataDirectory, "rules.xml"); d = readSBML(filename); m = d->getModel(); uff = new UnitFormulaFormatter(m); safe_free(filename); }
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; }
int main (int argc, char *argv[]) { SBMLDocument_t *doc; if (argc != 3) { printf("Usage: echoSBML input-filename output-filename\n"); return 2; } doc = readSBML(argv[1]); if (SBMLDocument_getNumErrors(doc) > 0) { SBMLDocument_printErrors(doc, stderr); } else { writeSBML(doc, argv[2]); } return 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; }
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, *fsize; 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; //an den exei 2 argument if(argc != 2) { printf("Ektelesi: %s <SBML xml>\n", argv[0]); exit(-1); } //arxeia results if((pf1 = fopen("RT_reactant.txt", "w")) == NULL) { printf("Error create file %s\n","RT_reactant.txt"); exit(-1); } if((pf2 = fopen("RT_product.txt", "w")) == NULL) { printf("Error create file %s\n","RT_product.txt"); fclose(pf1); exit(-1); } if((pf3 = fopen("VT_reactant.txt", "w")) == NULL) { printf("Error create file %s\n","VT_reactant.txt"); fclose(pf1); fclose(pf2); exit(-1); } if((pf4 = fopen("VT_product.txt", "w")) == NULL) { printf("Error create file %s\n","VT_product.txt"); fclose(pf1); fclose(pf2); fclose(pf3); exit(-1); } if((pf5 = fopen("ST.txt", "w")) == NULL) { printf("Error create file %s\n","ST.txt"); fclose(pf1); fclose(pf2); fclose(pf3); fclose(pf4); exit(-1); } if((pf6 = fopen("k_parameter.txt", "w")) == NULL) { printf("Error create file %s\n","k_parameter.txt"); fclose(pf1); fclose(pf2); fclose(pf3); fclose(pf4); fclose(pf5); exit(-1); } fsize = fopen("fsize.txt", "w"); //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); fprintf(fsize,"%d\n",num_species); fprintf(fsize,"%d\n",num_reactions); //Pairnoume ton ogko c = Model_getCompartment(m,0); V = Compartment_getVolume(c); //Desmeysi pinakon domon gia stoixeia kai reaction species = (myspecies_t*) malloc(num_species*sizeof(myspecies_t)); reaction = (reaction_t*) malloc(num_reactions*sizeof(reaction_t)); //gemizo ton pinaka me tis arxikes sigkentroseis ton stoixeion for(i=0;i<num_species;i++) { sp = Model_getSpecies(m,i); species[i].conc = Species_getInitialConcentration(sp)?Species_getInitialConcentration(sp):Species_getInitialAmount(sp); species[i].name = malloc(50*sizeof(char)); strcpy(species[i].name,Species_getId(sp)); strcpy(species[i].name2,Species_getName(sp)); } ///gemizo ton pinaka domon ton reaction for(i=0;i<num_reactions;i++) { re = Model_getReaction(m,i); kin = Reaction_getKineticLaw(re); p = KineticLaw_getParameter(kin,0); reaction[i].react_num = Reaction_getNumReactants(re); reaction[i].product_num = Reaction_getNumProducts(re); reaction[i].react = (x_vector_t*) malloc(reaction[i].react_num*sizeof(x_vector_t)); reaction[i].product = (x_vector_t*) malloc(reaction[i].product_num*sizeof(x_vector_t)); for(j=0;j<reaction[i].react_num;j++) { sr = Reaction_getReactant(re,j); for(k=0;k<num_species;k++) { //an vrei to stoixeio ston megalo pinaka krata ti thesi tou if (strcmp(SpeciesReference_getSpecies(sr),species[k].name) == 0) { reaction[i].react[j].x = k; //ithesi ston pinaka species reaction[i].react[j].v = (-1) * SpeciesReference_getStoichiometry(sr); break; } } } for(j=0;j<reaction[i].product_num;j++) { sr = Reaction_getProduct(re,j); for(k=0;k<num_species;k++) { //an vrei to stoixeio ston megalo pinaka krata ti thesi tou if (strcmp(SpeciesReference_getSpecies(sr),species[k].name) == 0) { reaction[i].product[j].x = k; //ithesi ston pinaka species reaction[i].product[j].v = SpeciesReference_getStoichiometry(sr); break; } } } reaction[i].k = Parameter_getValue(p); //vlepo tin eidos antidraseis einai kai vazo to c tis kathe antidrasis if(reaction[i].react_num == 3) { reaction[i].type = 7; reaction[i].c = Parameter_getValue(p)/(V*V); //mallon } else if(reaction[i].react_num == 2) { sr = Reaction_getReactant(re,0); if (SpeciesReference_getStoichiometry(sr) == 2 ) { reaction[i].type = 5; reaction[i].c = 2*Parameter_getValue(p)/(V*V); //oute kan } else { sr = Reaction_getReactant(re,1); if (SpeciesReference_getStoichiometry(sr) == 2 ) { reaction[i].type = 6; reaction[i].c = 2*Parameter_getValue(p)/(V*V); //oute kan } else { reaction[i].type = 2; reaction[i].c = Parameter_getValue(p)/V; } } } else //if(reaction[i].react_num == 1) { sr = Reaction_getReactant(re,0); if (SpeciesReference_getStoichiometry(sr) == 2 ) //an einai bimolecular me to idio stoixeio { reaction[i].type = 3; reaction[i].c = 2*Parameter_getValue(p)/V; } else if(SpeciesReference_getStoichiometry(sr) == 3 ) { reaction[i].type = 4; reaction[i].c = 3*Parameter_getValue(p)/(V*V); //mallon } else { reaction[i].type = 1; reaction[i].c = Parameter_getValue(p); } } } for(i=0;i<num_species;i++) { //fprintf(pf5,"%d\t%s\n",(int)species[i].conc,species[i].name2); fprintf(pf5,"%d\t\n",(int)species[i].conc); } for(i=0;i<num_reactions;i++) { for(k=0;k<reaction[i].react_num;k++) { fprintf(pf1,"%d\t",reaction[i].react[k].x+1); fprintf(pf3,"%d\t",reaction[i].react[k].v); } for(k=0;k<reaction[i].product_num;k++) { fprintf(pf2,"%d\t",reaction[i].product[k].x+1); fprintf(pf4,"%d\t",reaction[i].product[k].v); } fprintf(pf1,"\n"); fprintf(pf3,"\n"); fprintf(pf2,"\n"); fprintf(pf4,"\n"); fprintf(pf6,"%f\n",reaction[i].k); } fclose(pf1); fclose(pf2); fclose(pf3); fclose(pf4); fclose(pf5); fclose(pf6); fclose(fsize); }
int main (int argc, char *argv[]) { unsigned int latestLevel = SBMLDocument_getDefaultLevel(); unsigned int latestVersion = SBMLDocument_getDefaultVersion(); unsigned int errors; SBMLDocument_t *d; if (argc != 3) { printf("Usage: convertSBML input-filename output-filename\n"); printf("This program will attempt to convert a model either to\n"); printf("SBML Level %d Version %d (if the model is not already) or, if", latestLevel, latestVersion); printf("the model is already expressed in Level %d Version %d, this\n", latestLevel, latestVersion); printf("program will attempt to convert the model to Level 1 Version 2.\n"); return 1; } d = readSBML(argv[1]); errors = SBMLDocument_getNumErrors(d); if (errors > 0) { printf("Encountered the following SBML error(s):\n"); SBMLDocument_printErrors(d, stdout); printf("Conversion skipped. Please correct the problems above first.\n"); return errors; } else { unsigned int olevel = SBMLDocument_getLevel(d); unsigned int oversion = SBMLDocument_getVersion(d); int success; if (olevel < latestLevel || oversion < latestVersion) { printf("Attempting to convert model to SBML Level %d Version %d.\n", latestLevel, latestVersion); success = SBMLDocument_setLevelAndVersion(d, latestLevel, latestVersion); } else { printf("Attempting to convert model to SBML Level 1 Version 2.\n"); success = SBMLDocument_setLevelAndVersion(d, 1, 2); } errors = SBMLDocument_getNumErrors(d); if (!success) { printf("Unable to perform conversion due to the following:\n"); SBMLDocument_printErrors(d, stdout); printf("Conversion skipped. Either libSBML does not (yet) have\n"); printf("ability to convert this model, or (automatic) conversion\n"); printf("is not possible in this case.\n"); } else if (errors > 0) { printf("Information may have been lost in conversion; but a valid model "); printf("was produced by the conversion.\nThe following information "); printf("was provided:\n"); SBMLDocument_printErrors(d, stdout); writeSBML(d, argv[2]); } else { printf("Conversion completed.\n"); writeSBML(d, argv[2]); } } SBMLDocument_free(d); return errors; }
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; }
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; }
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; }
int main (int argc, char *argv[]) { SBMLDocument_t* d; Model_t* m; unsigned int errors, n; Reaction_t *r; if (argc != 3) { printf("\n" " usage: addingEvidenceCodes_1 <input-filename> <output-filename>\n" " Adds controlled vocabulary term to a reaction\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 { m = SBMLDocument_getModel(d); n = Model_getNumReactions(m); if (n <= 0) { printf( "Model has no reactions.\n Cannot add CV terms\n"); } else { CVTerm_t *cv1, *cv2; r = Model_getReaction(m, 0); /* check that the reaction has a metaid * no CVTerms will be added if there is no metaid to reference */ if (SBase_isSetMetaId((SBase_t*)r)) SBase_setMetaId((SBase_t*)r, "metaid_0000052"); cv1 = CVTerm_createWithQualifierType(BIOLOGICAL_QUALIFIER); CVTerm_setBiologicalQualifierType(cv1, BQB_IS_DESCRIBED_BY); CVTerm_addResource(cv1, "urn:miriam:obo.eco:ECO%3A0000183"); SBase_addCVTerm((SBase_t*)r, cv1); cv2 = CVTerm_createWithQualifierType(BIOLOGICAL_QUALIFIER); CVTerm_setBiologicalQualifierType(cv2, BQB_IS); CVTerm_addResource(cv2, "urn:miriam:kegg.reaction:R00756"); CVTerm_addResource(cv2, "urn:miriam:reactome:REACT_736"); SBase_addCVTerm((SBase_t*)r, cv2); writeSBML(d, argv[2]); } } SBMLDocument_free(d); return errors; }