#include #include #include "scconst.h" #include "scio.h" /** This computes 1-erf(x) with fractional error everywhere less than **/ /** 1.2 * 10^-7. ***/ /** I changed things from "float" to "double" from the numerical methods **/ /** in C code. **/ double erfcc(x) double x; { double t,z,ans; z=fabs(x); t=1.0/(1.0+0.5*z); ans=t*exp(-z*z-1.26551223+t*(1.00002368+t*(0.37409196+t*(0.09678418+ t*(-0.18628806+t*(0.27886807+t*(-1.13520398+t*(1.48851587+ t*(-0.82215223+t*0.17087277))))))))); return x >= 0.0 ? ans : 2.0-ans; } double erf(double x) { return(1-erfcc(x)); } void printweight(long pfreqs[AANUM][POSNUM], long pfreqp[AANUM][AANUM][POSNUM][POSNUM], double gprobs[NUM_RES_TYPE], double gprobp[NUM_RES_TYPE][NUM_RES_TYPE][POSNUM], double weights[AANUM][POSNUM], double weightp[AANUM][AANUM][POSNUM][POSNUM], long totals[POSNUM], long totalp[POSNUM][POSNUM], FILE *weight_file, double pprobs[NUM_RES_TYPE][POSNUM], double pprobp[NUM_RES_TYPE][NUM_RES_TYPE][POSNUM][POSNUM], double bonnies_pprobs[NUM_RES_TYPE][POSNUM], double bonnies_pprobp[NUM_RES_TYPE][NUM_RES_TYPE][POSNUM][POSNUM]) { int reg1, reg2, res1, res2; double expect_prob, quantity,value; long Num_samples; int alert=0; fprintf(weight_file,"\n\n SINGLE WEIGHTS \n\n"); fprintf(weight_file," "); /* 9 spaces to get register to line up in columns*/ for(reg1=0; reg11) weights[res1][pos1]=1; } } for (pos1=0; pos11) weightp[res1][res2][pos1][pos2]=1; } } /******* Now done in PairCoilData in sc2seq_interface.c printweight(pfreqs,pfreqp,gprobs,gprobp,weights, weightp, totals,totalp,weight_file); *********/ } /** Give the combination table a wt. that is the max of the wt. in the **/ /** other two tables. i.e. if it is significant in one table, it should **/ /** be significant in the combination??? Could just average??? **/ void combine_many_weight(int current_table) { int reg1, reg2, res1, res2; /********* extern double many_weights[MAX_TABLE_NUMBER][AANUM][POSNUM]; extern double many_weightp[MAX_TABLE_NUMBER][AANUM][AANUM][POSNUM][POSNUM]; **********/ double many_weights[MAX_TABLE_NUMBER][AANUM][POSNUM]; double many_weightp[MAX_TABLE_NUMBER][AANUM][AANUM][POSNUM][POSNUM]; for (res1=0; res1 many_weights[1][res1][reg1]) many_weights[current_table][res1][reg1] = many_weights[0][res1][reg1]; else many_weights[current_table][res1][reg1] = many_weights[1][res1][reg1]; for (res2=0; res2 many_weightp[1][res1][res2][reg1][reg2]) many_weightp[current_table][res1][res2][reg1][reg2] = many_weightp[0][res1][res2][reg1][reg2]; else many_weightp[current_table][res1][res2][reg1][reg2] = many_weightp[1][res1][res2][reg1][reg2]; } } /** Note that these weights should all be <= 1....Maybe even sum to 1 if ***/ /** want to use them is a weighted avg. But in "geometric averaging" don't */ /** have to sum to 1. Note that the bigger the sum though, the smaller **/ /** the output prob. **/ void calc_distance_weights(double dist_weight[POSNUM]) { int i; dist_weight[0]= .3; dist_weight[1]= .1; dist_weight[2]= .3; dist_weight[3]= .3; dist_weight[4]= .2; dist_weight[5]= .05; dist_weight[6]= .1; for(i=0; icutoff) return(1); else return(0); } /*** Want a sigma that maps 0 to 0 and 1 to 1. ***/ /*** middle is the value that things should have things above it be mapped */ /*** towards 1, and below it mapped towards 0. **/ /*** Use 1+middle since want 0 mapped to 0 and middle to middle. **/ /*** The larger power is, the more values are mapped towards the **/ /*** extremes. **/ double sigma(double x, int power, double middle) { double result; if (power ==-1) /** signal to do hardcutoff **/ return(hard_cutoff(x,middle)); if (power == 0) /** Just do nothing. **/ return(x); if (x<=middle) result= pow(1+middle,pow(x/middle,power)) - 1; else result= 2-pow(2-middle,pow( (1 - x)/(1-middle),power)); return(result); }