Example #1
0
/* Testing (conditional) folding; use with eval.pl */
void test_folding(char* seq, int length) {

    int i,j;
    char* constraints;

    fold_constrained = 1;
    constraints = (char *) space((unsigned) length+1);

    memset(constraints,'.',length);
    constraints[0]='x';

    //constraints=NULL;

    init_pf_fold(length);

    pf_fold_pb(seq, constraints);

    for (i = 1; i < length; i++) {
        for (j = i+1; j<= length; j++) {
            p_pp[i][j]=p_pp[j][i]=pr[iindx[i]-j];
            if (p_pp[i][j]>1e-50) {
                printf("%i %i %.13e \n", i, j, p_pp[i][j]);
            }
        }
    }

    free_arrays();
}
Example #2
0
JNIEXPORT jfloat JNICALL Java_wbitoolkit_rna_MfeFold_fold
(JNIEnv *env, jobject obj, jstring ss, jfloat t)
{

    float e=0;
    char* seq;
    char* struc;

    seq=(char*)(*env)->GetStringUTFChars(env,ss,NULL);
    if(seq==NULL) return 0;

    temperature = t;

    do_backtrack=0;

    /*initialize_fold(strlen(seq));*/
    update_fold_params();


    struc=(char*)space(sizeof(char)*(strlen(seq)+1));

    e=fold(seq,struc);

    free_arrays(); /* frees the memory allocated by fold() */

    (*env)->ReleaseStringUTFChars(env,ss,seq);
    return e;
}
Example #3
0
static void do_pgconf_xxx (void (*f)(const float *, int, int, int, int, int, int,
                                     float, float, const float *))
{
   float *a;
   unsigned int idim, jdim;
   int i_1, i_2, j_1, j_2;
   float c1, c2;
   SLang_Array_Type *at, *tr;

   at = tr = NULL;

   if (-1 == pop_float_vector (&tr))
     return;

   if (-1 == pop_5_floats (&c1, &c2, NULL, NULL, NULL))
     goto return_error;

   if (-1 == pop_4_ints (&j_1, &j_2, &i_1, &i_2))
     goto return_error;

   if (NULL == (at = pop_2d_float_array (&a, &jdim, &idim)))
     goto return_error;

   /* Convert to FORTRAN indexing */
   i_1++; j_1++; i_2++; j_2++;

   (*f) (a, idim, jdim, i_1, i_2, j_1, j_2,
         c1, c2, (float *)tr->data);

return_error:
   free_arrays (at, tr, NULL, NULL);
}
Example #4
0
static void _pgconl (char *label, int *intval, int *minint)
{
   float *a;
   unsigned int idim, jdim;
   int i_1, i_2, j_1, j_2;
   float c;
   SLang_Array_Type *tr, *at;

   tr = at = NULL;

   if (-1 == pop_float_vector (&tr))
     return;

   if (-1 == SLang_pop_float (&c))
     goto return_error;

   if (-1 == pop_4_ints (&j_1, &j_2, &i_1, &i_2))
     goto return_error;

   if (NULL == (at = pop_2d_float_array (&a, &jdim, &idim)))
     goto return_error;

   /* Convert to FORTRAN indexing */
   i_1++; j_1++; i_2++; j_2++;

   cpgconl (a, idim, jdim, i_1, i_2, j_1, j_2,
            c, (float *)tr->data,
            label, *intval, *minint);

return_error:

   free_arrays (at, tr, NULL, NULL);
}
Example #5
0
void phyanimal_free(PhyAnimal *model) {
  ListStr l;
  char *name;
  PhyAnimal m = *model;
  if (*model==NULL) return;
  free_temporaries(*model);
  free_arrays(m);
  /* Variable names */
  if (m->fvar != NULL) {
    l = m->fvar;
    while (!list_str_empty(l)) {
      list_str_pop_front(l,&name);
      PM_MEM_FREE(name);
    }
    list_str_free(&l);
  }
  if (m->yvar != NULL) {
    l = m->yvar;
    while (!list_str_empty(l)) {
      list_str_pop_front(l,&name);
      PM_MEM_FREE(name);
    }
    list_str_free(&l);
  }

  PM_MEM_FREE(*model);
  *model = NULL;
  return;
}
Example #6
0
char* seq_fold(const char* sequence, float* mfe)
{
    char* structure = (char*)space(sizeof(char) * (strlen(sequence) + 1));
    *mfe = fold(sequence, structure);
    free_arrays();
    return structure;
}
Example #7
0
PRIVATE cofoldF do_partfunc(char *string, int length, int Switch, struct plist **tpr, struct plist **mfpl, pf_paramT *parameters){
  /*compute mfe and partition function of dimere or  monomer*/
  char *Newstring;
  char *tempstruc;
  double min_en;
  double sfact=1.07;
  double kT;
  pf_paramT *par;
  FLT_OR_DBL *probs;
  cofoldF X;
  kT = parameters->kT/1000.;
  switch (Switch)
    {
    case 1: /*monomer*/
      cut_point=-1;
      tempstruc = (char *) space((unsigned)length+1);
      min_en = fold(string, tempstruc);
      assign_plist_from_db(mfpl, tempstruc, 0.95);
      free_arrays();
      /*En=pf_fold(string, tempstruc);*/
      /* init_co_pf_fold(length); <- obsolete */
      par = get_boltzmann_factor_copy(parameters);
      par->pf_scale = exp(-(sfact*min_en)/kT/(length));
      X=co_pf_fold_par(string, tempstruc, par, 1, fold_constrained);
      probs = export_co_bppm();
      assign_plist_from_pr(tpr, probs, length, bppmThreshold);
      free_co_pf_arrays();
      free(tempstruc);
      free(par);
      break;

    case 2: /*dimer*/
      Newstring=(char *)space(sizeof(char)*(length*2+1));
      strcat(Newstring,string);
      strcat(Newstring,string);
      cut_point=length+1;
      tempstruc = (char *) space((unsigned)length*2+1);
      min_en = cofold(Newstring, tempstruc);
      assign_plist_from_db(mfpl, tempstruc, 0.95);
      free_co_arrays();
      /* init_co_pf_fold(2*length); <- obsolete */
      par = get_boltzmann_factor_copy(parameters);
      par->pf_scale =exp(-(sfact*min_en)/kT/(2*length));
      X=co_pf_fold_par(Newstring, tempstruc, par, 1, fold_constrained);
      probs = export_co_bppm();
      assign_plist_from_pr(tpr, probs, 2*length, bppmThreshold);
      free_co_pf_arrays();
      free(Newstring);
      free(tempstruc);
      free(par);
      break;

    default:
      printf("Error in get_partfunc\n, computing neither mono- nor dimere!\n");
      exit (42);

    }
  return X;
}
Example #8
0
/* Prototype: _pghi2d (data[][], iy1, iy2, ix1, ix2, x[], ioff, bias, center) */
static void _pghi2d (int *ioff, double *bias, int *center)
{
   int ix1, ix2, iy1, iy2;
   SLang_Array_Type *x, *at;
   float *data;
   unsigned int nx, nxv, nyv;
   float *ylims;

   if (-1 == pop_float_vector (&x))
     return;

   nx = x->num_elements;

   if ((-1 == pop_4_ints (&iy1, &iy2, &ix1, &ix2))
       || (NULL == (at = pop_2d_float_array (&data, &nyv, &nxv))))
     {
        SLang_free_array (x);
        return;
     }

   if ((int) nx != (ix2 - ix1 + 1))
     {
        free_arrays (at, x, NULL, NULL);
        SLang_verror (SL_INVALID_PARM,
                      "pghi2d: ix1 and ix2 are out of range");
        return;
     }

   if (NULL == (ylims = (float *) SLmalloc (sizeof (float) * (nx + 1))))
     {
        free_arrays (at, x, NULL, NULL);
        return;
     }

   /* Don't forget to add one to the array indices since FORTRAN arrays
    * are indexed from 1
    */
   if (nx && nxv && nyv)
     cpghi2d (data, nxv, nyv, ix1 + 1, ix2 + 1, iy1 + 1, iy2 + 1,
              (float*)x->data, *ioff, (float) *bias, *center, ylims);

   SLfree ((char *) ylims);
   free_arrays (at, x, NULL, NULL);
}
Example #9
0
/****************************************************************************
 * Allocate memory for the global variables, using the current values of
 * iHeight and iWidth.
 ****************************************************************************/
static int alloc_arrays()
{
  int iRetVal = 0;
  int i;

  ppcTexts = 0;
  piArrows = 0;
  piLineContents = 0;

  /* ppcTexts */
  if (!(ppcTexts = kmalloc(sizeof(char *) * iHeight, GFP_KERNEL)))
  {
    printk(KERN_ERR "Couldn't kmalloc room for string pointer array\n");
    iRetVal = -ENOMEM;
  }
  else
  {
    memset(ppcTexts, '\0', sizeof(char *) * iHeight);
  }

  /* piArrows */
  if ((iRetVal == 0) &&
      !(piArrows = kmalloc(sizeof(int) * iHeight, GFP_KERNEL)))
  {
    printk(KERN_ERR "Couldn't kmalloc room for Arrows array\n");
    iRetVal = -ENOMEM;
  }

  /* piLineContents */
  if ((iRetVal == 0) &&
      !(piLineContents = kmalloc(sizeof(int) * iHeight, GFP_KERNEL)))
  {
    printk(KERN_ERR "Couldn't kmalloc room for Line Contents array\n");
    iRetVal = -ENOMEM;
  }

  /* Inside each array */
  for (i = 0; i < iHeight; ++i)
  {
    ppcTexts[i] = rutl_strdup(" ", GFP_KERNEL);
    if (!ppcTexts[i])
    {
      iRetVal = -ENOMEM;
      break;
    }
    piArrows[i] = LCD_ARROW_NONE;
    piLineContents[i] = LCD_LINE_CONTENTS_TEXT;
  }

  if (iRetVal != 0)
  {
    free_arrays();
  }

  return iRetVal;
}
Example #10
0
PRIVATE void heat_capacity(char *string, float T_min, float T_max,
                          float h, int m)
{
   int length, i;
   char *structure;
   float hc, kT, min_en;

   length = (int) strlen(string);

   do_backtrack = 0;

   temperature = T_min -m*h;
   /* initialize_fold(length); <- obsolete */
   structure = (char *) vrna_alloc((unsigned) length+1);
   min_en = fold(string, structure);
   free(structure); free_arrays();
   kT = (temperature+K0)*GASCONST/1000;    /* in kcal */
   pf_scale = exp(-(1.07*min_en)/kT/length );
   /* init_pf_fold(length); <- obsolete */
   vrna_exp_param_t  *pf_parameters = NULL;
   vrna_md_t         md;
   set_model_details(&md);
   pf_parameters = get_boltzmann_factors(temperature, 1.0, md, pf_scale);

   update_pf_params_par(length, pf_parameters);
   for (i=0; i<2*m+1; i++) {

      F[i] = pf_fold_par(string, NULL, pf_parameters, 0, 0, 0);   /* T_min -2h */
      md.temperature = temperature += h;
      kT = (temperature+K0)*GASCONST/1000;
      pf_scale=exp(-(F[i]/length +h*0.00727)/kT); /* try to extrapolate F */
      free(pf_parameters);
      pf_parameters = get_boltzmann_factors(temperature, 1.0, md, pf_scale);
      update_pf_params_par(length, pf_parameters);
}
   while (temperature <= (T_max+m*h+h)) {

      hc = - ddiff(F,h,m)* (temperature +K0 - m*h -h);
      printf("%g   %g\n", (temperature-m*h-h), hc);

      for (i=0; i<2*m; i++)
         F[i] = F[i+1];

      F[2*m] = pf_fold_par(string, NULL, pf_parameters, 0, 0, 0);
/*       printf("%g\n", F[2*m]);*/
      temperature += h;
      kT = (temperature+K0)*GASCONST/1000;
      pf_scale=exp(-(F[i]/length +h*0.00727)/kT);
      free(pf_parameters);
      md.temperature = temperature;
      pf_parameters = get_boltzmann_factors(temperature, 1.0, md, pf_scale);
      update_pf_params_par(length, pf_parameters);
   }
   free_pf_arrays();
}
Example #11
0
/* histogram of binned data */
static void _pgbin (int *center)
{
   SLang_Array_Type *x, *data;

   if (-1 == pop_two_float_vectors (&x, &data))
     return;

   cpgbin ((int) x->num_elements, (float*)x->data, (float*)data->data, *center);

   free_arrays (x, data, NULL, NULL);
}
Example #12
0
/* draw a polyline (curve defined by line-segments) */
static void _pgline (void)
{
   SLang_Array_Type *x, *y;

   if (-1 == pop_two_float_vectors (&x, &y))
     return;

   cpgline ((int) x->num_elements, (float *)x->data, (float *)y->data);

   free_arrays (x, y, NULL, NULL);
}
Example #13
0
/****************************************************************************
 * Free all dynamic memory that depended on the size, and reallocate it to the
 * new size.
 ****************************************************************************/
static int resize(int h, int w)
{
  printk("LCD:resize h=%d, w=%d\n", h,w);
  
  free_arrays();

  iHeight = h;
  iWidth  = w;

  return alloc_arrays();
}
Example #14
0
/****************************************************************************
 * Tidy up on exit
 ****************************************************************************/
void reciva_lcd_exit(void)
{
  if (tGreetingFramePid)
    wait_for_completion(&greeting_frame_complete);
  
  driver->power_off();
  misc_deregister(&lcd_miscdev);
  free_arrays();
  
  printk("RLCD: reciva_lcd_exit\n");
}
Example #15
0
/* horizontal error bar */
static void _pgerrx (double *len)
{
   SLang_Array_Type *x1, *x2, *y;

   if (-1 == pop_three_float_vectors (&x1, &x2, &y))
     return;

   cpgerrx ((int) x1->num_elements,
            (float*)x1->data, (float*)x2->data, (float*)y->data, (float) *len);

   free_arrays (x1, x2, y, NULL);
}
Example #16
0
/* vertical error bar */
static void _pgerry (double *len)
{
   SLang_Array_Type *x, *y_1, *y_2;

   if (-1 == pop_three_float_vectors (&x, &y_1, &y_2))
     return;

   cpgerry ((int) x->num_elements, (float*)x->data,
            (float*)y_1->data, (float *)y_2->data, (float) *len);

   free_arrays (x, y_1, y_2, NULL);
}
Example #17
0
static void _pgctab (double *contra, double *bright)
{
   SLang_Array_Type *l, *r, *g, *b;

   if (-1 == pop_four_float_vectors (&l, &r, &g, &b))
     return;

   cpgctab ((float *)l->data, (float *)r->data, (float *)g->data, (float *)b->data,
            (int) l->num_elements, *contra, *bright);

   free_arrays (l, r, g, b);
}
Example #18
0
PRIVATE cofoldF do_partfunc(char *string, int length, int Switch, struct plist **tpr, struct plist **mfpl) {
  /*compute mfe and partition function of dimere or  monomer*/
  char *Newstring;
  char *tempstruc;
  double min_en;
  double sfact=1.07;
  double kT;
  cofoldF X;
  kT = (temperature+273.15)*1.98717/1000.;
  switch (Switch)
    {
    case 1: /*monomer*/
      cut_point=-1;
      tempstruc = (char *) space((unsigned)length+1);
      min_en = fold(string, tempstruc);
      pf_scale = exp(-(sfact*min_en)/kT/(length));
      *mfpl=get_mfe_plist(*mfpl);
      free_arrays();
      /*En=pf_fold(string, tempstruc);*/
      init_co_pf_fold(length);
      X=co_pf_fold(string, tempstruc);

      *tpr=get_plist(*tpr, length,0.00001);
      free_co_pf_arrays();
      free(tempstruc);
      break;

    case 2: /*dimer*/
      Newstring=(char *)space(sizeof(char)*(length*2+1));
      strcat(Newstring,string);
      strcat(Newstring,string);
      cut_point=length+1;
      tempstruc = (char *) space((unsigned)length*2+1);
      min_en = cofold(Newstring, tempstruc);
      pf_scale =exp(-(sfact*min_en)/kT/(2*length));
      *mfpl=get_mfe_plist(*mfpl);
      free_co_arrays();
      init_co_pf_fold(2*length);
      X=co_pf_fold(Newstring, tempstruc);
      *tpr=get_plist(*tpr, 2*length,0.00001);
      free_co_pf_arrays();
      free(Newstring);
      free(tempstruc);
      break;

    default:
      printf("Error in get_partfunc\n, computing neither mono- nor dimere!\n");
      exit (42);

    }
  return X;
}
Example #19
0
void initialize_fold(int length)
{
  unsigned int n;
  if (length<1) nrerror("initialize_fold: argument must be greater 0");
  if (init_length>0) free_arrays();
  get_arrays((unsigned) length);
  init_length=length;

  for (n = 1; n <= (unsigned) length; n++)
    indx[n] = (n*(n-1)) >> 1;        /* n(n-1)/2 */

  update_fold_params();
}
Example #20
0
static void _pgpnts (void)
{
   SLang_Array_Type *x, *y;
   SLang_Array_Type *s;

   if (-1 == SLang_pop_array_of_type (&s, SLANG_INT_TYPE))
     return;
   if (0 == pop_two_float_vectors (&x, &y))
     {
        cpgpnts (x->num_elements, (float *) x->data, (float *) y->data,
                 (int *) s->data, s->num_elements);
     }
   free_arrays (x, y, s, NULL);
}
Example #21
0
/* Warning: This routine differs from its pgplot counterpart.
 * It does not allow the use of old arrays.  At most, 1024 points are allocated.
 */
static void _pglcur_pgncur_pgolin (SLang_Ref_Type *rx, SLang_Ref_Type *ry,
                                   int symbol, int what)
{
   SLang_Array_Type *a, *b;
   float x[1024];
   float y[1024];
   SLindex_Type n_it;
   int n;

   n = 0;

   switch (what)
     {
      case 1:
        cpglcur (1024, &n, x, y);
        break;

      case 2:
        cpgncur (1024, &n, x, y, symbol);
        break;

      case 3:
        cpgolin (1024, &n, x, y, symbol);
        break;
     }

   if (n < 0)
     n = 0;

   n_it = n;

   if (NULL == (a = SLang_create_array (SLANG_FLOAT_TYPE, 0, NULL, &n_it, 1)))
     return;
   if (NULL == (b = SLang_create_array (SLANG_FLOAT_TYPE, 0, NULL, &n_it, 1)))
     {
        SLang_free_array (a);
        return;
     }

   memcpy ((char *)a->data, (char *)x, n * sizeof (float));
   memcpy ((char *)b->data, (char *)y, n * sizeof (float));

   (void) SLang_assign_to_ref (rx, SLANG_ARRAY_TYPE, &a);
   (void) SLang_assign_to_ref (ry, SLANG_ARRAY_TYPE, &b);

   free_arrays (a, b, NULL, NULL);
}
Example #22
0
/* horizontal or vertical error bar */
static void _pgerrb (double *t)
{
   SLang_Array_Type *x, *y, *e;
   int dir;

   if (-1 == pop_three_float_vectors (&x, &y, &e))
     return;

   if (-1 != SLang_pop_integer (&dir))
     {
        cpgerrb (dir, (int)x->num_elements,
                 (float*)x->data, (float*)y->data, (float*)e->data,
                 (float) *t);
     }

   free_arrays (x, y, e, NULL);
}
Example #23
0
File: zscore.c Project: wash/rnaz
void zscore_explicitly_shuffled(const char *seq, double *avg, double *stdv, int type){
    unsigned int n = 1000;
    unsigned int counter;
    unsigned int length = strlen(seq);
    char *tmp = (char *) space((unsigned) length+1);
    char *shuff = (char *) space((unsigned) length+1);
    char *structure = (char *) space((unsigned) length+1);
    float *energies = (float*) space(sizeof(float) * n);
    float mean = 0;
    float sd = 0;
    /* generate seed from time */
    srand((unsigned)time(NULL));
    strcpy(tmp, seq);

    /*printf("INHERE\n");*/
    
    for (counter = 0; counter < n; counter++)
    {
      if (type == 1) fisher_yates_shuffle(tmp,length,shuff);
      if (type == 3) altschul_erickson_shuffle(tmp,length,shuff);
      energies[counter] = fold(shuff, structure);
      free_arrays();
      mean = mean + energies[counter];
    }

    mean = (float) mean/n;
    
    for (counter = 0; counter < n; counter++)
    {
      sd += (energies[counter]-mean)*(energies[counter]-mean);
    }

    sd = (float) sd/(n-1);
    sd = sqrt(sd);

    *avg = (double) mean;
    *stdv = (double) sd;

    free(energies);
    free(tmp);
    free(shuff);
    free(structure);
}
Example #24
0
PRIVATE void heat_capacity(char *string, float T_min, float T_max,
                          float h, int m)
{
   int length, i;
   char *structure;
   float hc, kT, min_en;
   
   length = (int) strlen(string);
   
   do_backtrack = 0;   

   temperature = T_min -m*h;
   initialize_fold(length);
   structure = (char *) space((unsigned) length+1);
   min_en = fold(string, structure);
   free(structure); free_arrays();
   kT = (temperature+K0)*GASCONST/1000;    /* in kcal */
   pf_scale = exp(-(1.07*min_en)/kT/length );
   init_pf_fold(length);
   
   for (i=0; i<2*m+1; i++) {
      F[i] = pf_fold(string, NULL);   /* T_min -2h */
      temperature += h;
      kT = (temperature+K0)*GASCONST/1000;
      pf_scale=exp(-(F[i]/length +h*0.00727)/kT); /* try to extrapolate F */
      update_pf_params(length); 
   }
   while (temperature <= (T_max+m*h+h)) {
      
      hc = - ddiff(F,h,m)* (temperature +K0 - m*h -h); 
      printf("%g   %g\n", (temperature-m*h-h), hc);  
      
      for (i=0; i<2*m; i++)
         F[i] = F[i+1];
      F[2*m] = pf_fold(string, NULL); 
      temperature += h;
      kT = (temperature+K0)*GASCONST/1000;
      pf_scale=exp(-(F[i]/length +h*0.00727)/kT);
      update_pf_params(length); 
   }
   free_pf_arrays();
}
Example #25
0
static void do_pgcon_bs (double *blank, int *nc_sign)
{
   unsigned int idim, jdim;
   float *a;
   int i_1, i_2, j_1, j_2;
   SLang_Array_Type *tr, *c, *at;

   at = NULL;

   if (-1 == pop_tr_vector (&tr))
     return;

   if (-1 == pop_float_vector (&c))
     goto return_error;

   if (-1 == pop_4_ints (&j_1, &j_2, &i_1, &i_2))
     goto return_error;

   if (NULL == (at = pop_2d_float_array (&a, &jdim, &idim)))
     goto return_error;

   /* Convert to FORTRAN indexing */
   i_1++; j_1++; i_2++; j_2++;

   if (blank != NULL)
     cpgconb (a, idim, jdim, i_1, i_2, j_1, j_2,
              (float *)c->data, c->num_elements,
              (float *)tr->data, *blank);
   else if (nc_sign != NULL)
     cpgcont (a, idim, jdim, i_1, i_2, j_1, j_2,
              (float *)c->data, *nc_sign * (int)c->num_elements,
              (float *)tr->data);
   else
     cpgcons (a, idim, jdim, i_1, i_2, j_1, j_2,
              (float *)c->data, c->num_elements,
              (float *)tr->data);

return_error:

   free_arrays (tr, c, at, NULL);
}
Example #26
0
void ini_or_reset_rl(void) {

  /* if there is no ringList-tree make a new one */
  if (wurzl == NULL) {
    ini_ringlist();

    /* start structure */
    struc2tree(GAV.startform);
    GSV.currE = GSV.startE = energy_of_struct(GAV.farbe, GAV.startform);


    /* stop structure(s) */
    if ( GTV.stop )  {
      int i;

      qsort(GAV.stopform, GSV.maxS, sizeof(char *), comp_struc);
      for (i = 0; i< GSV.maxS; i++)
	GAV.sE[i] = energy_of_struct(GAV.farbe_full, GAV.stopform[i]);
    }
    else {
      if(GTV.noLP)
	noLonelyPairs=1;
      initialize_fold(GSV.len);
      /* fold sequence to get Minimum free energy structure (Mfe) */
      GAV.sE[0] = fold(GAV.farbe_full, GAV.stopform[0]);
      free_arrays();
      /* revaluate energy of Mfe (maye differ if --logML=logarthmic */
      GAV.sE[0] = energy_of_struct(GAV.farbe_full, GAV.stopform[0]);
    }
    GSV.stopE = GAV.sE[0];
    ini_nbList(strlen(GAV.farbe_full)*strlen(GAV.farbe_full));
  }
  else {
    /* reset ringlist-tree to start conditions */
    reset_ringlist();
    if(GTV.start) struc2tree(GAV.startform);
    else {
      GSV.currE = GSV.startE;
    }
  }
}
Example #27
0
extern void fatalerror(char *s)
{   print_preamble();

    printf("Fatal error: %s\n",s);
    if (no_compiler_errors > 0) print_sorry_message();

#ifdef ARC_THROWBACK
    throwback(0, s);
    throwback_end();
#endif
#ifdef MAC_FACE
    close_all_source();
    if (temporary_files_switch) remove_temp_files();
    abort_transcript_file();
    free_arrays();
    if (store_the_text)
        my_free(&all_text,"transcription text");
    longjmp(g_fallback, 1);
#endif
    exit(1);
}
Example #28
0
void test_stochastic_backtracking(char* seq, int length) {

    int i, j, N;

    init_pf_fold(length);

    pf_fold_pb(seq, NULL);

    for (i = 1; i < length; i++) {
        for (j = i+1; j<= length; j++) {
            p_pp[i][j]=p_pp[j][i]=pr[iindx[i]-j];
        }
    }

    get_pair_prob_vector(p_pp, p_unpaired, length, 1);

    for (i=1; i <= length; i++) {
        q_unpaired[i] = 0.0;
    }

    N=10000;

    for (i=1; i<=N; i++) {
        char *s;
        s = pbacktrack_pb(seq);
        for (j=1; j <= length; j++) {
            if (s[j-1]=='.') {
                q_unpaired[j]+=1.0/N;
            }
        }
        free(s);
    }

    for (i=1; i <= length; i++) {
        printf("%.4f\t%.4f\t%.4f\n",  p_unpaired[i], q_unpaired[i], q_unpaired[i]-p_unpaired[i]);
    }

    free_arrays();

}
Example #29
0
static int pop_two_float_vectors (SLang_Array_Type **a, SLang_Array_Type **b)
{
   *a = *b = NULL;

   if (-1 == pop_float_vector (b))
     return -1;
   if (-1 == pop_float_vector (a))
     {
        SLang_free_array (*b);
        *b = 0;
        return -1;
     }

   if (-1 == check_vectors (*a, *b))
     {
        free_arrays (*a, *b, NULL, NULL);
        *a = *b = NULL;
        return -1;
     }

   return 0;
}
Example #30
0
static int pop_three_float_vectors (SLang_Array_Type **a, SLang_Array_Type **b, SLang_Array_Type **c)
{
   *a = *b = *c = NULL;

   if (-1 == pop_float_vector (c))
     return -1;

   if (-1 == pop_two_float_vectors (a, b))
     {
        SLang_free_array (*c);
        *c = NULL;
        return -1;
     }

   if (-1 == check_vectors (*a, *c))
     {
        free_arrays (*a, *b, *c, NULL);
        *a = *b = *c = NULL;
        return -1;
     }
   return 0;
}