Exemple #1
0
PUBLIC int find_saddle(const char *sequence, const char *struc1, const char *struc2, int max) {
  int maxl, maxE, i;
  const char *tmp;
  move_t *bestpath=NULL;
  int dir;

  path_fwd = 0;
  maxE = INT_MAX - 1;
  seq = sequence;

  update_fold_params();
  make_pair_matrix();

  /* nummerically encode sequence */
  S   = encode_sequence(seq, 0);
  S1  = encode_sequence(seq, 1);

  maxl=1;
  do {
    int saddleE;
    path_fwd = !path_fwd;
    if (maxl>max) maxl=max;
    if(path) free(path);
    saddleE  = find_path_once(struc1, struc2, maxE, maxl);
    if (saddleE<maxE) {
      maxE = saddleE;
      if (bestpath) free(bestpath);
      bestpath = path;
      path = NULL;
      dir = path_fwd;
    } else{
      free(path);path=NULL;
    }
    tmp=struc1;
    struc1=struc2;
    struc2=tmp;
    maxl *=2;
  } while (maxl<2*max);

  free(S); free(S1);
  /* (re)set some globals */
  path=bestpath;
  path_fwd = dir;
  return maxE;
}
Exemple #2
0
int find_saddle(char *sequence, char *struc1, char *struc2, int max) {
  int maxl, maxE, i;
  char *tmp;
  move_t *bestpath=NULL;
  int dir;

  maxE = INT_MAX - 1;
  seq = sequence;

  update_fold_params();
  make_pair_matrix();

  /* nummerically encode sequence */
  S = (short *) space(sizeof(short)*(strlen(seq)+1));
  S1 = (short *) space(sizeof(short)*(strlen(seq)+1));
  S[0] = S1[0] = (short) strlen(seq);
  for (i=0; i< strlen(seq); i++) {
    S[i+1] = encode_char(seq[i]);
    S1[i+1] = alias[S[i+1]];
  }

  maxl=1;
  do {
    int saddleE;
    path_fwd = !path_fwd;
    if (maxl>max) maxl=max;
    saddleE  = find_path_once(struc1, struc2, maxE, maxl);
    if (saddleE<maxE) {
      maxE = saddleE;
      if (bestpath) free(bestpath);
      bestpath = path;
      dir = path_fwd;
    } else
      free(path);
    tmp=struc1; struc1=struc2; struc2=tmp; 
    maxl *=2;
  } while (maxl<2*max);

  free(S); free(S1);
  path=bestpath;
  path_fwd = dir;
  return maxE;
}