Esempio n. 1
0
int main(int argc, char *argv[]){
  char          *rec_sequence, *structure;
  double        min_en;

  rec_sequence = structure = NULL;

  /* initialization */
  if (argc>1) {
    read_parameter_file(argv[1]);
    // printf("Params: '%s'\n",argv[1]);
  }

  /* main loop: continue until end of file */
  while (!(get_multi_input_line(&rec_sequence, 0) & (VRNA_INPUT_ERROR | VRNA_INPUT_QUIT) )) {
    /* init everything according to the data we've read */
    int length  = (int)strlen(rec_sequence);
    structure = (char *)space(sizeof(char) *(length+1));
    /* actual computations */
    min_en = fold_par(rec_sequence, structure);
    printf("%s\n%s (%6.2f)\n", rec_sequence, structure, min_en);
    fflush(stdout);
    /* clean up */
    free(rec_sequence); free(structure);
    rec_sequence = structure = NULL;
  }
  return EXIT_SUCCESS;
}
Esempio n. 2
0
double score_seq( int s, char* seq, int ip )
{
    double score = 0.0;
    if( !is_legal( seq ) ) return score;

    int length = strlen( seq );
    int* ix = get_iindx( length );

    double betaScale = 1.0;
    double kT = ( betaScale*( ( temperature+K0 )*GASCONST ) )/1000.; /* in Kcal */
    model_detailsT md;
    set_model_details( &md );

    char* secstr = strdup( seq );
    secstr[0] = 0;
    fold_constrained = 0;
    paramT* params = get_scaled_parameters( temperature, md );
    double min_en = fold_par( seq, secstr, params, fold_constrained, 0 );
    if( strncmp( secstr + ip,
                 cnf->hairpin_ss, strlen( cnf->hairpin_ss ) ) != 0
        || strcmp( secstr + length - strlen( cnf->tail3p_ss ),
                   cnf->tail3p_ss ) != 0 ) {
        free( params );
        free( secstr );
        free( ix );
        return score;
    }
    if( !is_legal_pair_content( seq, secstr, ip ) ) {
        free( params );
        free( secstr );
        free( ix );
        return score;
    }
    #pragma omp atomic update
    num_scored++;

    double pf_scale = exp( -( 1.07*min_en )/kT/length );
    pf_paramT* pf_params = get_boltzmann_factors( temperature, betaScale, md, pf_scale );
    // Either patch fold_vars.h by inserting following at line 166
    //
    // #ifdef _OPENMP
    // #pragma omp threadprivate(iindx)
    // #endif
    //
    // or uncomment this pragma below
    //
    // #pragma omp critical(pf_fold)
    double e = pf_fold_par( seq, NULL, pf_params, 1, fold_constrained, 0 );
    FLT_OR_DBL* ppm = export_bppm();

#define pr_ij(i,j) (i == j? 0.0 : (i < j ? ppm[ix[i]-j] : ppm[ix[j]-i]))

    score = cnf->s_max;
    int i, o;
    for( i = 1; i <= length; i++ ) {
        for( o = 1; o <= strlen( cnf->hairpin_ss ); o++ ) {
            int j = ip + o;
            double v = pr_ij( i, j );
            score -= v * ( 1.0 - v );
        }
    }
    score *= cnf->s_scale;

    free( pf_params );
    free( params );
    free( secstr );
    free( ix );
    return score;
}