END_TEST START_TEST (test_comp_deletion_metaid) { const char *name = "delMetaId"; fail_unless( !SBase_isSetMetaId(P) ); SBase_setMetaId(P, name); const char* getmetaid = SBase_getMetaId(P); fail_unless( !strcmp(getmetaid, name) ); fail_unless( SBase_isSetMetaId(P) ); if (getmetaid == name) { fail("SBase_setMetaId(...) did not make a copy of string."); } SBase_unsetMetaId(P); fail_unless( !SBase_isSetMetaId(P) ); if (SBase_getMetaId(P) != NULL) { fail("Deletion_unsetName(P) did not clear string."); } }
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_L3_Species_ModelHistory) { ModelHistory_t * history = ModelHistory_create(); SBase_setMetaId((SBase_t *)(S), "_3"); int i = SBase_setModelHistory((SBase_t *)(S), history); fail_unless( i == LIBSBML_INVALID_OBJECT ); fail_unless( !SBase_isSetModelHistory((SBase_t *)(S)) ); ModelCreator_t * mc = ModelCreator_create(); Date_t * date = Date_createFromValues(2005, 12, 30, 12, 15, 45, 1, 2, 0); ModelCreator_setFamilyName(mc, "Keating"); ModelCreator_setGivenName(mc, "Sarah"); ModelCreator_setEmail(mc, "*****@*****.**"); ModelCreator_setOrganisation(mc, "UH"); ModelHistory_addCreator(history, mc); ModelHistory_setCreatedDate(history, date); ModelHistory_setModifiedDate(history, date); i = SBase_setModelHistory((SBase_t *)(S), history); fail_unless( i == LIBSBML_OPERATION_SUCCESS ); fail_unless( SBase_isSetModelHistory((SBase_t *)(S)) ); i = SBase_unsetModelHistory((SBase_t *)(S)); fail_unless( i == LIBSBML_OPERATION_SUCCESS ); fail_unless( !SBase_isSetModelHistory((SBase_t *)(S)) ); fail_unless( SBase_getModelHistory((SBase_t *)(S)) == NULL ); ModelHistory_free(history); ModelCreator_free(mc); Date_free(date); }
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; }