include/karlin.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void BlastKarlinBlkCalc (double *scoreProbabilities, int4 min, int4 max)
int4 BlastComputeLengthAdjustment (float K, float logK, float alpha_d_lambda, float beta, int4 query_length, uint4 db_length, int4 db_num_seqs, int4 *length_adjustment)

Variables

float BlastKarlin_lambda
float BlastKarlin_K
float BlastKarlin_H


Function Documentation

int4 BlastComputeLengthAdjustment ( float  K,
float  logK,
float  alpha_d_lambda,
float  beta,
int4  query_length,
uint4  db_length,
int4  db_num_seqs,
int4 *  length_adjustment 
)

Definition at line 457 of file karlin.c.

References int4, and maximum.

Referenced by statistics_calcLengthAdjustNew().

00465 {
00466     int4 i;                     /* iteration index */
00467     const int4 maxits = 20;     /* maximum allowed iterations */
00468     double m = query_length, n = db_length, N = db_num_seqs;
00469 
00470     double ell;            /* A float value of the length adjustment */
00471     double ss;             /* effective size of the search space */
00472     double ell_min = 0, ell_max;   /* At each iteration i,
00473                                          * ell_min <= ell <= ell_max. */
00474     char converged = 0;       /* True if the iteration converged */
00475     double ell_next = 0;   /* Value the variable ell takes at iteration
00476                                  * i + 1 */
00477     /* Choose ell_max to be the largest nonnegative value that satisfies
00478      *
00479      *    K * (m - ell) * (n - N * ell) > max(m,n)
00480      *
00481      * Use quadratic formula: 2 c /( - b + sqrt( b*b - 4 * a * c )) */
00482     { /* scope of a, mb, and c, the coefficients in the quadratic formula
00483        * (the variable mb is -b) */
00484         double a  = N;
00485         double mb = m * N + n;
00486         double c  = n * m - maximum(m, n) / K;
00487 
00488         if(c < 0) {
00489             *length_adjustment = 0;
00490             return 1;
00491         } else {
00492             ell_max = 2 * c / (mb + sqrt(mb * mb - 4 * a * c));
00493         }
00494     } /* end scope of a, mb and c */
00495 
00496     for(i = 1; i <= maxits; i++) {      /* for all iteration indices */
00497         double ell_bar;    /* proposed next value of ell */
00498         ell      = ell_next;
00499         ss       = (m - ell) * (n - N * ell);
00500         ell_bar  = alpha_d_lambda * (logK + log(ss)) + beta;
00501         if(ell_bar >= ell) { /* ell is no bigger than the true fixed point */
00502             ell_min = ell;
00503             if(ell_bar - ell_min <= 1.0) {
00504                 converged = 1;
00505                 break;
00506             }
00507             if(ell_min == ell_max) { /* There are no more points to check */
00508                 break;
00509             }
00510         } else { /* else ell is greater than the true fixed point */
00511             ell_max = ell;
00512         }
00513         if(ell_min <= ell_bar && ell_bar <= ell_max) {
00514           /* ell_bar is in range. Accept it */
00515             ell_next = ell_bar;
00516         } else { /* else ell_bar is not in range. Reject it */
00517             ell_next = (i == 1) ? ell_max : (ell_min + ell_max) / 2;
00518         }
00519     } /* end for all iteration indices */
00520     if(converged) { /* the iteration converged */
00521         /* If ell_fixed is the (unknown) true fixed point, then we
00522          * wish to set (*length_adjustment) to floor(ell_fixed).  We
00523          * assume that floor(ell_min) = floor(ell_fixed) */
00524         *length_adjustment = (int4) ell_min;
00525         /* But verify that ceil(ell_min) != floor(ell_fixed) */
00526         ell = ceil(ell_min);
00527         if( ell <= ell_max ) {
00528           ss = (m - ell) * (n - N * ell);
00529           if(alpha_d_lambda * (logK + log(ss)) + beta >= ell) {
00530             /* ceil(ell_min) == floor(ell_fixed) */
00531             *length_adjustment = (int4) ell;
00532           }
00533         }
00534     } else { /* else the iteration did not converge. */
00535         /* Use the best value seen so far */
00536         *length_adjustment = (int4) ell_min;
00537     }
00538 
00539     return converged ? 0 : 1;
00540 }

Here is the caller graph for this function:

void BlastKarlinBlkCalc ( double *  scoreProbabilities,
int4  min,
int4  max 
)

Definition at line 84 of file karlin.c.

References BlastKarlin_H, BlastKarlin_K, BlastKarlin_lambda, BlastKarlinLambdaNR(), BlastKarlinLHtoK(), and BlastKarlinLtoH().

Referenced by statistics_calculateUngappedKarlinParameters().

00085 {
00086         /* Calculate the parameter Lambda */
00087         BlastKarlin_lambda = BlastKarlinLambdaNR(scoreProbabilities, min, max);
00088 
00089         /* Calculate H */
00090         BlastKarlin_H = BlastKarlinLtoH(scoreProbabilities, min, max, BlastKarlin_lambda);
00091 
00092         /* Calculate K */
00093         BlastKarlin_K = BlastKarlinLHtoK(scoreProbabilities, min, max, BlastKarlin_lambda,
00094                                          BlastKarlin_H);
00095 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

float BlastKarlin_H

Definition at line 7 of file karlin.h.

Referenced by BlastKarlinBlkCalc(), and statistics_calculateUngappedKarlinParameters().

float BlastKarlin_K

Definition at line 6 of file karlin.h.

Referenced by BlastKarlinBlkCalc(), and statistics_calculateUngappedKarlinParameters().

float BlastKarlin_lambda

Definition at line 5 of file karlin.h.

Referenced by BlastKarlinBlkCalc(), and statistics_calculateUngappedKarlinParameters().


Generated on Wed Dec 19 20:49:46 2007 for fsa-blast by  doxygen 1.5.2