void initSeq(const char* param, const char* seq) { int i; read_parameter_file(param); c_P = get_scaled_parameters(); c_len = strlen(seq); c_seq = malloc(c_len+1); for (i=0; i<c_len; ++i) switch (seq[i]) { case 'a': c_seq[i]=1; break; case 'c': c_seq[i]=2; break; case 'g': c_seq[i]=3; break; case 'u': c_seq[i]=4; break; default: exit(1); } }
PUBLIC paramT *scale_parameters(void){ model_detailsT md; set_model_details(&md); return get_scaled_parameters(temperature, md); }
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; }