Ejemplo n.º 1
0
END_TEST


START_TEST (test_KineticLaw_setFormula)
{
  const char *formula = "k1*X0";


  KineticLaw_setFormula(kl, formula);

  fail_unless( !strcmp(KineticLaw_getFormula(kl), formula) );
  fail_unless( KineticLaw_isSetFormula(kl)   );

  if (KineticLaw_getFormula(kl) == formula)
  {
    fail("KineticLaw_setFormula(...) did not make a copy of string.");
  }

  /* Reflexive case (pathological) */
  KineticLaw_setFormula(kl, KineticLaw_getFormula(kl));
  fail_unless( !strcmp(KineticLaw_getFormula(kl), formula) );

  KineticLaw_setFormula(kl, NULL);
  fail_unless( !KineticLaw_isSetFormula(kl) );

  if (KineticLaw_getFormula(kl) != NULL)
  {
    fail("KineticLaw_setFormula(kl, NULL) did not clear string.");
  }
}
Ejemplo n.º 2
0
/**
 * \fn void SBML_setReactions(Model_t *mod, pEspeces molecules, pScore result, double *reactions_ratio, int nbReactions, int nbEspeces)
 * \author Amine Ghozlane
 * \brief  Alloc memory and initialize the struct Especes
 * \param  mod Model of the SBML file
 * \param  molecules Struct Especes
 * \param  result Struct Score
 * \param  reactions_ratio List of computed reaction ratio
 * \param  nbReactions Number of reaction
 * \param  nbEspeces Number of molecules
 */
void SBML_setReactions(Model_t *mod, pEspeces molecules, pScore result, double *reactions_ratio, int nbReactions, int nbEspeces)
{
  /* Initialisation les reactions auquelles participent chaque espece */
  int ref = 0, i, j, resultat=OK;
  SpeciesReference_t *reactif=NULL;
  Species_t *especeId=NULL;
  Reaction_t *react=NULL;
  const char *kf=NULL;
  /*const ASTNode_t *km;*/
  KineticLaw_t *kl=NULL;

  /* Recherche les reactions ou apparaissent chaque espece */
  for (i = 0; i < nbReactions; i++) {
      react = Model_getReaction(mod, i);
      /* Recherche si la reaction est etudiee */
      resultat = SBML_findReaction(result->reaction,Reaction_getId(react), result->nb_reaction);
      /* Etude des reactifs */
      for (j = 0; j < (int)Reaction_getNumReactants(react); j++) {
          /* Recuperation d'un reactif */
          reactif = Reaction_getReactant(react, j);
          /* Recuperation du nom de l'espece */
          especeId = Model_getSpeciesById(mod, SpeciesReference_getSpecies(reactif));
          /* Recherche la reference de cette molecule dans la struture molecule */
          ref = Especes_find(molecules, Species_getId(especeId), nbEspeces);
          /* Recuperation de la loi cinetique sur la */
          kl = Reaction_getKineticLaw(react);
          /* Reaction dont on recherche le bon ratio */
          if(resultat!=OK){
              Especes_allocReactions(molecules, ref, react, reactions_ratio[resultat]);
          }
          /* Si la loi cinetique est au format : formule on recupere le ratio en question */
          else if (KineticLaw_isSetFormula(kl)) {
              kf = KineticLaw_getFormula(kl);
              Especes_allocReactions(molecules, ref, react, SBML_evalExpression(kf));
          } else { /* Sinon on n'utilise pas ces informations */
              /*km = KineticLaw_getMath(kl);*/
              fprintf(stderr,"SBML equation are taken into account, use instead the parameter file\n");
              /*exit(EXIT_FAILURE);*/
          }
      }
  }
}
Ejemplo n.º 3
0
END_TEST


/**
 * setFormulaFromMath() is no longer necessary.  LibSBML now keeps formula
 * strings and math ASTs synchronized automatically.  This (now modified)
 * test is kept around to demonstrate the behavioral change.
 */
START_TEST (test_KineticLaw_setFormulaFromMath)
{
  ASTNode_t *math = SBML_parseFormula("k1 * X0");


  fail_unless( !KineticLaw_isSetMath   (kl) );
  fail_unless( !KineticLaw_isSetFormula(kl) );

  KineticLaw_setMath(kl, math);
  fail_unless(  KineticLaw_isSetMath(kl) );
  fail_unless( KineticLaw_isSetFormula(kl) );

  fail_unless( !strcmp(KineticLaw_getFormula(kl), "k1 * X0") );

  ASTNode_free(math);
}
Ejemplo n.º 4
0
/**
 * \fn void SBML_score(Model_t *mod, pEspeces molecules, pScore result, double *reactions_ratio, int nbReactions, int nbEspeces)
 * \author Amine Ghozlane
 * \brief  Alloc memory and initialize the struct Especes
 * \param  mod Model of the SBML file
 * \param  molecules Struct Especes
 * \param  result Struct Score
 * \param  reactions_ratio List of computed reaction ratio
 * \param  nbReactions Number of reactions
 * \param  nbEspeces Number of molecules
 */
void SBML_score(Model_t *mod, pEspeces molecules, pScore result, double *reactions_ratio, int nbReactions, int nbEspeces)
{
  /* Fonction de score */
  int  i, resultat=OK;
  Reaction_t *react=NULL;
  const char *kf=NULL;
  KineticLaw_t *kl=NULL;

  /* Enregistre le score des especes */
  Especes_scoreSpecies(molecules, nbEspeces, result->name, result->quantite);

  /* Enregistre le ratio des reactions */
  for (i = 0; i < (nbReactions); i++) {
      react = Model_getReaction(mod, i);
      if(result->name[nbEspeces+i]==NULL){
          result->name[nbEspeces+i]=(char*)malloc(((int)strlen((char *)Reaction_getId(react))+1)*sizeof(char));
          assert(result->name[nbEspeces+i]!=NULL);
          strcpy(result->name[nbEspeces+i],(char *)Reaction_getId(react));
      }

      /* Recherche si la reaction est etudiee*/
      resultat = SBML_findReaction(result->reaction, result->name[nbEspeces+i], result->nb_reaction);
      /* Recuperation de la loi cinetique sur la */
      kl = Reaction_getKineticLaw(react);
      /* Reaction dont on recherche le bon ratio*/
      if(resultat!=OK) result->quantite[nbEspeces+i]=reactions_ratio[resultat];
      else if(KineticLaw_isSetFormula(kl)){
          kf = KineticLaw_getFormula(kl);
          result->quantite[nbEspeces+i]=SBML_evalExpression(kf);
      }
      else {  /*Sinon on n'utilise pas ces informations*/
          fprintf(stderr,"SBML equation are taken into account, use instead the parameter file\n");
          exit(EXIT_FAILURE);
      }
  }
}