END_TEST START_TEST (test_Compartment_initDefaults) { Compartment_t *c = Compartment_create(2, 4); Compartment_setId(c, "A"); Compartment_initDefaults(c); fail_unless( !strcmp(Compartment_getId (c), "A")); fail_unless( Compartment_getName (c) == NULL ); fail_unless( Compartment_getUnits (c) == NULL ); fail_unless( Compartment_getOutside(c) == NULL ); fail_unless( Compartment_getSpatialDimensions(c) == 3 ); fail_unless( Compartment_getVolume (c) == 1.0 ); fail_unless( Compartment_getConstant (c) == 1 ); fail_unless( Compartment_isSetId (c) ); fail_unless( !Compartment_isSetName (c) ); fail_unless( !Compartment_isSetSize (c) ); fail_unless( !Compartment_isSetVolume (c) ); fail_unless( !Compartment_isSetUnits (c) ); fail_unless( !Compartment_isSetOutside(c) ); fail_unless( Compartment_isSetSpatialDimensions(c) ); fail_unless( Compartment_isSetConstant(c) ); Compartment_free(c); }
END_TEST START_TEST (test_Compartment_setVolume1) { int i = Compartment_setVolume(C, 2.0); fail_unless( i == LIBSBML_OPERATION_SUCCESS ); fail_unless( Compartment_getVolume(C) == 2.0 ); fail_unless( Compartment_isSetVolume(C)); i = Compartment_unsetVolume(C); fail_unless( i == LIBSBML_OPERATION_SUCCESS ); fail_unless( Compartment_getVolume(C) == 1.0 ); fail_unless( Compartment_isSetVolume(C)); }
END_TEST START_TEST (test_L3_Compartment_createWithNS ) { XMLNamespaces_t *xmlns = XMLNamespaces_create(); XMLNamespaces_add(xmlns, "http://www.sbml.org", "testsbml"); SBMLNamespaces_t *sbmlns = SBMLNamespaces_create(3,1); SBMLNamespaces_addNamespaces(sbmlns,xmlns); Compartment_t *c = Compartment_createWithNS (sbmlns); fail_unless( SBase_getTypeCode ((SBase_t *) c) == SBML_COMPARTMENT ); fail_unless( SBase_getMetaId ((SBase_t *) c) == NULL ); fail_unless( SBase_getNotes ((SBase_t *) c) == NULL ); fail_unless( SBase_getAnnotation((SBase_t *) c) == NULL ); fail_unless( SBase_getLevel ((SBase_t *) c) == 3 ); fail_unless( SBase_getVersion ((SBase_t *) c) == 1 ); fail_unless( Compartment_getNamespaces (c) != NULL ); fail_unless( XMLNamespaces_getLength(Compartment_getNamespaces(c)) == 2 ); fail_unless( Compartment_getId (c) == NULL ); fail_unless( Compartment_getName (c) == NULL ); fail_unless( Compartment_getUnits (c) == NULL ); fail_unless( Compartment_getOutside(c) == NULL ); fail_unless( util_isNaN(Compartment_getSpatialDimensionsAsDouble(c)) ); fail_unless( util_isNaN(Compartment_getVolume(c))); fail_unless( Compartment_getConstant(c) == 1 ); fail_unless( !Compartment_isSetId (c) ); fail_unless( !Compartment_isSetSpatialDimensions (c) ); fail_unless( !Compartment_isSetName (c) ); fail_unless( !Compartment_isSetSize (c) ); fail_unless( !Compartment_isSetVolume (c) ); fail_unless( !Compartment_isSetUnits (c) ); fail_unless( !Compartment_isSetOutside(c) ); fail_unless( !Compartment_isSetConstant(c) ); Compartment_free(c); XMLNamespaces_free(xmlns); SBMLNamespaces_free(sbmlns); }
END_TEST START_TEST (test_Compartment_unsetVolume) { Compartment_setVolume(C, 1.0); fail_unless( Compartment_getVolume(C) == 1.0 ); /* FIX_ME fail_unless( Compartment_isSetVolume(C) ); */ Compartment_unsetVolume(C); fail_unless( !Compartment_isSetVolume(C) ); }
END_TEST START_TEST (test_Compartment_setVolume2) { Compartment_t *c = Compartment_create(2, 2); int i = Compartment_setVolume(c, 4); fail_unless( i == LIBSBML_OPERATION_SUCCESS ); fail_unless( Compartment_getVolume(c) == 4.0 ); fail_unless( Compartment_isSetVolume(c)); i = Compartment_unsetVolume(c); fail_unless( i == LIBSBML_OPERATION_SUCCESS ); fail_unless( !Compartment_isSetVolume(c)); Compartment_free(c); }
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); }