/* * $Id: pssm-distr.c 4452 2010-04-14 03:45:52Z james_johnson $ * * $Log$ * Revision 1.2 2005/10/25 21:23:44 nadya * add Id and Log lines for keeping track of changes * change C++-style comments to C-style * * */ #include "macros.h" #include "pssm-distr.h" #include "user.h" #include static double *calc_pssm_pdf( int w, /* width of PSSM */ int alen, /* length of alphabet */ int range, /* largest value in PSSM */ double **pssm, /* scaled, integer PSSM: pssm[i][j] is score for j_th letter in i_th column of motif; entries in PSSM are in range [0..range] */ double *prob, /* 0-order Markov background model */ double psfm[MAXSITE][MAXALPH] /* psfm corresponding to the pssm */ ); /**********************************************************************/ /* calc_pssm_cdf Calculate the 1 minus the theoretical cumulative distribution function for an (integer-valued) PSSM given a 0-order Markov background model. PSSM entries must be in range [0..range]. Returns an array of 1-cdf values: pvalue[x] = Pr(score >= x) for 0 <= x <= range*w. */ /**********************************************************************/ extern double *calc_pssm_cdf( int w, /* width of PSSM */ int alen, /* length of alphabet */ int range, /* largest value in PSSM */ double **pssm, /* scaled, integer PSSM: pssm[i][j] is score for j_th letter in i_th column of motif; entries in PSSM are in range [0..range] */ double *prob /* 0-order Markov background model */ ) { int i; int size = w*range+1; /* size of cdf array */ double *pdf = NULL; /* probability distribution */ pdf = calc_pssm_pdf(w, alen, range, pssm, prob, NULL); if (!pdf) return NULL; /*for (i=0; i=0; i--) { pdf[i] += pdf[i+1]; pdf[i] = MIN(1.0, pdf[i]); /* if (isnan(pdf[i])) {fprintf(stderr, "cdf: i %d pdf %f\n", i, pdf[i]); abort(); } */ } /* return the cdf */ /*for (i=0; i= size) { fprintf(stderr, "calc_pssm_pdf error: i=%d j=%d k=%d max_score=%d score=%d size=%d\n", i, j, k, max_score, score, size); return NULL; } } } } /* clean up */ myfree(pdf_old); /* return the pdf */ return pdf_new; } /* calc_pssm_pdf */