Beispiel #1
0
PUBLIC char *
vrna_ptypes(const short *S,
                vrna_md_t *md){

  char *ptype;
  int n,i,j,k,l,*idx;
  int min_loop_size = md->min_loop_size;

  n     = S[0];

  if((unsigned int)n > vrna_sequence_length_max(VRNA_OPTION_DEFAULT)){
    vrna_message_warning("[email protected]: sequence length of %d exceeds addressable range", n);
    return NULL;
  }

  ptype = (char *)vrna_alloc(sizeof(char)*((n*(n+1))/2+2));
  idx   = vrna_idx_col_wise(n);

  for (k=1; k<n-min_loop_size; k++)
    for (l=1; l<=2; l++) {
      int type,ntype=0,otype=0;
      i=k; j = i+min_loop_size+l; if (j>n) continue;
      type = md->pair[S[i]][S[j]];
      while ((i>=1)&&(j<=n)) {
        if ((i>1)&&(j<n)) ntype = md->pair[S[i-1]][S[j+1]];
        if (md->noLP && (!otype) && (!ntype))
          type = 0; /* i.j can only form isolated pairs */
        ptype[idx[j]+i] = (char) type;
        otype =  type;
        type  = ntype;
        i--; j++;
      }
    }
  free(idx);
  return ptype;
}
PRIVATE void
set_fold_compound(vrna_fold_compound_t *vc,
                  vrna_md_t *md_p,
                  unsigned int options,
                  unsigned int aux){


  char *sequence, **sequences;
  unsigned int        length, s;
  int                 cp;                     /* cut point for cofold */
  char                *seq, *seq2;

  sequence          = NULL;
  sequences         = NULL;
  cp                = -1;

  /* some default init values */
  vc->params        = NULL;
  vc->exp_params    = NULL;
  vc->matrices      = NULL;
  vc->exp_matrices  = NULL;
  vc->hc            = NULL;
  vc->auxdata       = NULL;
  vc->free_auxdata  = NULL;

  switch(vc->type){
    case VRNA_VC_TYPE_SINGLE:     sequence  = vc->sequence;

                                  seq2 = strdup(sequence);
                                  seq = vrna_cut_point_remove(seq2, &cp); /*  splice out the '&' if concatenated sequences and
                                                                        reset cp... this should also be safe for
                                                                        single sequences */
                                  vc->cutpoint            = cp;

                                  if((cp > 0) && (md_p->min_loop_size == TURN))
                                    md_p->min_loop_size = 0;  /* is it safe to set this here? */

                                  free(vc->sequence);
                                  vc->sequence            = seq;
                                  vc->length              = length = strlen(seq);
                                  vc->sequence_encoding   = vrna_seq_encode(seq, md_p);
                                  vc->sequence_encoding2  = vrna_seq_encode_simple(seq, md_p);
                                  if(!(options & VRNA_OPTION_EVAL_ONLY)){
                                    vc->ptype               = (aux & WITH_PTYPE) ? vrna_ptypes(vc->sequence_encoding2, md_p) : NULL;
                                    /* backward compatibility ptypes */
                                    vc->ptype_pf_compat     = (aux & WITH_PTYPE_COMPAT) ? get_ptypes(vc->sequence_encoding2, md_p, 1) : NULL;
                                  } else {
                                    vc->ptype           = NULL;
                                    vc->ptype_pf_compat = NULL;
                                  }
                                  vc->sc                  = NULL;
                                  free(seq2);
                                  break;

    case VRNA_VC_TYPE_ALIGNMENT:  sequences     = vc->sequences;

                                  vc->length    = length = vc->length;

                                  vc->cons_seq  = consensus((const char **)sequences);
                                  vc->S_cons    = vrna_seq_encode_simple(vc->cons_seq, md_p);

                                  vc->pscore    = vrna_alloc(sizeof(int)*((length*(length+1))/2+2));
                                  /* backward compatibility ptypes */
                                  vc->pscore_pf_compat = (aux & WITH_PTYPE_COMPAT) ? vrna_alloc(sizeof(int)*((length*(length+1))/2+2)) : NULL;

                                  oldAliEn = vc->oldAliEn  = md_p->oldAliEn;

                                  vc->S   = vrna_alloc((vc->n_seq+1) * sizeof(short *));
                                  vc->S5  = vrna_alloc((vc->n_seq+1) * sizeof(short *));
                                  vc->S3  = vrna_alloc((vc->n_seq+1) * sizeof(short *));
                                  vc->a2s = vrna_alloc((vc->n_seq+1) * sizeof(unsigned short *));
                                  vc->Ss  = vrna_alloc((vc->n_seq+1) * sizeof(char *));

                                  for (s = 0; s < vc->n_seq; s++) {
                                    vrna_aln_encode(vc->sequences[s],
                                                    &(vc->S[s]),
                                                    &(vc->S5[s]),
                                                    &(vc->S3[s]),
                                                    &(vc->Ss[s]),
                                                    &(vc->a2s[s]),
                                                    md_p);
                                  }
                                  vc->S5[vc->n_seq]  = NULL;
                                  vc->S3[vc->n_seq]  = NULL;
                                  vc->a2s[vc->n_seq] = NULL;
                                  vc->Ss[vc->n_seq]  = NULL;
                                  vc->S[vc->n_seq]   = NULL;

                                  vc->scs       = NULL;
                                  break;

    default:                      /* do nothing ? */
                                  break;
  }

  vc->iindx = vrna_idx_row_wise(vc->length);
  vc->jindx = vrna_idx_col_wise(vc->length);

  /* now come the energy parameters */
  add_params(vc, md_p, options);

}
Beispiel #3
0
PUBLIC int *
get_indx(unsigned int length){

  return vrna_idx_col_wise(length);
}