~ubuntu-branches/ubuntu/feisty/ncbi-tools6/feisty

« back to all changes in this revision

Viewing changes to algo/blast/core/blast_stat.h

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese
  • Date: 2006-07-19 23:28:07 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20060719232807-et3cdmcjgmnyleyx
Tags: 6.1.20060507-3ubuntu1
Re-merge with Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  $Id: blast_stat.h,v 1.74 2005/09/27 14:43:16 madden Exp $
 
1
/*  $Id: blast_stat.h,v 1.78 2006/04/20 19:26:37 madden Exp $
2
2
 * ===========================================================================
3
3
 *
4
4
 *                            PUBLIC DOMAIN NOTICE
36
36
#define __BLAST_STAT__
37
37
 
38
38
#include <algo/blast/core/blast_def.h>
 
39
#include <algo/blast/core/blast_query_info.h>
39
40
#include <algo/blast/core/blast_message.h>
40
41
 
41
42
#ifdef __cplusplus
113
114
 * @return NULL in case of memory allocation failure, else new
114
115
 * SPsiBlastScoreMatrix structure
115
116
 */
 
117
NCBI_XBLAST_EXPORT
116
118
SPsiBlastScoreMatrix*
117
119
SPsiBlastScoreMatrixNew(size_t ncols);
118
120
 
120
122
 * @param matrix structure to deallocate [in]
121
123
 * @return NULL
122
124
 */
 
125
NCBI_XBLAST_EXPORT
123
126
SPsiBlastScoreMatrix*
124
127
SPsiBlastScoreMatrixFree(SPsiBlastScoreMatrix* matrix);
125
128
 
178
181
 * @param number_of_contexts how many strands or sequences [in]
179
182
 * @return BlastScoreBlk*
180
183
*/
 
184
NCBI_XBLAST_EXPORT
181
185
BlastScoreBlk* BlastScoreBlkNew (Uint1 alphabet, Int4 number_of_contexts);
182
186
 
183
187
/** Deallocates BlastScoreBlk as well as all associated structures.
184
188
 * @param sbp BlastScoreBlk to be deallocated [in]
185
189
 * @return NULL pointer.
186
190
 */
 
191
NCBI_XBLAST_EXPORT
187
192
BlastScoreBlk* BlastScoreBlkFree (BlastScoreBlk* sbp);
188
193
 
189
194
/** Set the ambiguous residue (e.g, 'N', 'X') in the BlastScoreBlk*.
193
198
 * @param ambiguous_res the residue to be set on the BlastScoreBlk
194
199
 * @return zero on success, others on error
195
200
 */
 
201
NCBI_XBLAST_EXPORT
196
202
Int2 BLAST_ScoreSetAmbigRes (BlastScoreBlk* sbp, char ambiguous_res);
197
203
 
198
204
 
199
205
/** Calculate and fill the ungapped Karlin-Altschul parameters in the
200
 
 * BlastScoreBlk structure.
 
206
 * BlastScoreBlk structure (fields kbp_std, kbp_psi, and kbp of that structure).
201
207
 * @param program BLAST program type, needed to decide whether to substitute
202
208
 *                ideal values. [in]
203
209
 * @param sbp Scoring block to work with [in] [out]
204
210
 * @param query Buffer containing (concatenated) query sequence [in]
205
211
 * @param query_info Information about offsets of concatenated queries [in]
206
 
 * @return 0 if ungapped Karlin-Altschul parameters could be 
207
 
 *               calculated for at least one context; 1 otherwise.
 
212
 * @param blast_message returns queries that could not be processed [out]
 
213
 * @return 0 if ungapped Karlin-Altschul parameters could be calculated for 
 
214
 *        all of the query sequence's contexts; 1 if any of the contexts 
 
215
 *        failed (but all others will be populated).
208
216
 */
 
217
NCBI_XBLAST_EXPORT
209
218
Int2
210
219
Blast_ScoreBlkKbpUngappedCalc(EBlastProgramType program, 
211
220
                              BlastScoreBlk* sbp, Uint1* query, 
212
 
                              const BlastQueryInfo* query_info);
 
221
                              const BlastQueryInfo* query_info,
 
222
                              Blast_Message* *blast_message);
213
223
 
214
224
/** This function fills in the BlastScoreBlk structure.  
215
225
 * Tasks are:
218
228
 * @param sbp Scoring block [in] [out]
219
229
 * @param matrix Full path to the matrix in the directory structure [in]
220
230
*/
 
231
NCBI_XBLAST_EXPORT
221
232
Int2 Blast_ScoreBlkMatrixFill (BlastScoreBlk* sbp, char* matrix);
222
233
 
223
234
/** Callocs a Blast_KarlinBlk
224
235
 * @return pointer to the Blast_KarlinBlk
225
236
*/
 
237
NCBI_XBLAST_EXPORT
226
238
Blast_KarlinBlk* Blast_KarlinBlkNew (void);
227
239
 
228
240
/** Copies contents of one Karlin block to another. Both must be allocated
231
243
 * @param kbp_from Karlin block to copy values from [in]
232
244
 * @return 0 on success; -1 if either argument is NULL on input.
233
245
 */ 
 
246
NCBI_XBLAST_EXPORT
234
247
Int2 Blast_KarlinBlkCopy(Blast_KarlinBlk* kbp_to, Blast_KarlinBlk* kbp_from);
235
248
 
236
249
 
238
251
 * @param kbp KarlinBlk to be deallocated [in]
239
252
 * @return NULL
240
253
*/
 
254
NCBI_XBLAST_EXPORT
241
255
Blast_KarlinBlk* Blast_KarlinBlkFree(Blast_KarlinBlk* kbp);
242
256
 
243
257
/** Fills in lambda, H, and K values, as calculated by Stephen Altschul 
250
264
 * @param error_return filled in with error message if needed [out]
251
265
 * @return zero on success
252
266
 */
 
267
NCBI_XBLAST_EXPORT
253
268
Int2 Blast_KarlinBlkGappedCalc (Blast_KarlinBlk* kbp, Int4 gap_open, 
254
269
        Int4 gap_extend, Int4 decline_align, const char* matrix_name, 
255
270
        Blast_Message** error_return);
269
284
 *      score in some cases [in|out]
270
285
 * @param error_return Pointer to error message. [in] [out]
271
286
 */
 
287
NCBI_XBLAST_EXPORT
272
288
Int2
273
289
Blast_KarlinBlkNuclGappedCalc(Blast_KarlinBlk* kbp, Int4 gap_open, 
274
290
                              Int4 gap_extend, Int4 reward, Int4 penalty,
285
301
 * @param sbp ScoreBlk used to calculate "ideal" values. [in|out]
286
302
 * @return 0 on success, 1 on failure
287
303
*/
 
304
NCBI_XBLAST_EXPORT
288
305
Int2 Blast_ScoreBlkKbpIdealCalc(BlastScoreBlk* sbp);
289
306
 
290
307
/** Attempts to fill KarlinBlk for given gap opening, extensions etc.
298
315
 *          1 if matrix not found
299
316
 *           2 if matrix found, but open, extend etc. values not supported.
300
317
*/
 
318
NCBI_XBLAST_EXPORT
301
319
Int2 Blast_KarlinBlkGappedLoadFromTables(Blast_KarlinBlk* kbp, Int4 gap_open, Int4 gap_extend, Int4 decline_align, const char* matrix_name);
302
320
 
303
321
/** Prints a messages about the allowed matrices, BlastKarlinBlkGappedFill should return 1 before this is called. 
304
322
 * @param matrix the matrix to print a message about [in]
305
323
 * @return the message
306
324
 */
 
325
NCBI_XBLAST_EXPORT
307
326
char* BLAST_PrintMatrixMessage(const char *matrix);
308
327
 
309
328
/** Prints a messages about the allowed open etc values for the given matrix, 
314
333
 * @param decline_align cost of declining to align [in]
315
334
 * @return message
316
335
 */
 
336
NCBI_XBLAST_EXPORT
317
337
char* BLAST_PrintAllowedValues(const char *matrix, Int4 gap_open, Int4 gap_extend, Int4 decline_align);
318
338
 
319
339
/** Calculates the parameter Lambda given an initial guess for its value */
 
340
NCBI_XBLAST_EXPORT
320
341
double
321
342
Blast_KarlinLambdaNR(Blast_ScoreFreq* sfp, double initialLambdaGuess);
322
343
 
327
348
 * @param searchsp total search space to be used [in]
328
349
 * @return the expect value
329
350
 */
 
351
NCBI_XBLAST_EXPORT
330
352
double BLAST_KarlinStoE_simple (Int4 S, Blast_KarlinBlk* kbp, Int8  searchsp);
331
353
 
332
354
/** Compute a divisor used to weight the evalue of a collection of
345
367
 * @param nsegs the number of HSPs in the sum group [in]
346
368
 * @return divisor used to compensate for multiple tests
347
369
 */
 
370
NCBI_XBLAST_EXPORT
348
371
double BLAST_GapDecayDivisor(double decayrate, unsigned nsegs );
349
372
 
350
373
/** Calculate the cutoff score from the expected number of HSPs or vice versa.
355
378
 * @param dodecay Use gap decay feature? [in]
356
379
 * @param gap_decay_rate Gap decay rate to use, if dodecay is set [in]
357
380
 */
 
381
NCBI_XBLAST_EXPORT
358
382
Int2 BLAST_Cutoffs (Int4 *S, double* E, Blast_KarlinBlk* kbp, 
359
383
                    Int8 searchsp, Boolean dodecay, double gap_decay_rate);
360
384
 
373
397
 *    the calling routine [in]
374
398
 * @return the expect value 
375
399
 */
 
400
NCBI_XBLAST_EXPORT
376
401
double BLAST_SmallGapSumE (Int4 start_points, Int2 num,  double xsum,
377
402
                           Int4 query_length, Int4 subject_length,
378
403
                           Int8 searchsp_eff, double weight_divisor);
400
425
 *    the calling routine [in]
401
426
 * @return sum expect value.
402
427
 */
 
428
NCBI_XBLAST_EXPORT
403
429
double BLAST_UnevenGapSumE (Int4 query_start_points, Int4 subject_start_points,
404
430
                            Int2 num, double xsum,
405
431
                            Int4 query_length, Int4 subject_length,
418
444
 *    calling routine [in]
419
445
 * @return sum expect value.
420
446
 */
 
447
NCBI_XBLAST_EXPORT
421
448
double BLAST_LargeGapSumE (Int2 num,  double xsum,
422
449
                           Int4 query_length, Int4 subject_length,
423
450
                           Int8 searchsp_eff, double weight_divisor );
429
456
 * @param gap_extension returns recommended extension cost [in|out]
430
457
 * @return zero on success 
431
458
 */
 
459
NCBI_XBLAST_EXPORT
432
460
Int2 BLAST_GetProteinGapExistenceExtendParams(const char* matrixName,
433
461
                                       Int4* gap_existence,
434
462
                                       Int4* gap_extension);
441
469
 * @param gap_extension returns recommended extension cost [in|out]
442
470
 * @return zero on success 
443
471
 */
 
472
NCBI_XBLAST_EXPORT
444
473
Int2 BLAST_GetNucleotideGapExistenceExtendParams(Int4 reward,
445
474
                                       Int4 penalty,
446
475
                                       Int4* gap_existence,
456
485
 * @param gap_extend extension cost of a gap [in]
457
486
 * @param kbp_ungapped Karlin block with ungapped values of the parameters [in]
458
487
*/
 
488
NCBI_XBLAST_EXPORT
459
489
void BLAST_GetAlphaBeta (const char* matrixName, double *alpha,
460
490
                         double *beta, Boolean gapped, Int4 gap_open, 
461
491
                         Int4 gap_extend, const Blast_KarlinBlk* kbp_ungapped);
474
504
 * @param alpha Alpha parameter for this scoring system [out]
475
505
 * @param beta Beta parameter for this scoring system [out]
476
506
 */
 
507
NCBI_XBLAST_EXPORT
477
508
Int2 Blast_GetNuclAlphaBeta(Int4 reward, Int4 penalty, Int4 gap_open, 
478
509
                            Int4 gap_extend, Blast_KarlinBlk* kbp,
479
510
                            Boolean gapped_calculation,
495
526
 * @param matrix_name Name of the score matrix underlying the RPS search [in]
496
527
 * @return rescaled pssm 
497
528
 */
 
529
NCBI_XBLAST_EXPORT
498
530
Int4 ** RPSRescalePssm(double scalingFactor, Int4 rps_query_length, 
499
531
                   const Uint1 * rps_query_seq, Int4 db_seq_length, 
500
532
                   Int4 **posMatrix, const char *matrix_name);
539
571
 * @return   0 if length_adjustment is known to be the largest integer less
540
572
 *           than the fixed point of f(ell); 1 otherwise.
541
573
 */
 
574
NCBI_XBLAST_EXPORT
542
575
Int4
543
576
BLAST_ComputeLengthAdjustment(double K,
544
577
                              double logK,
554
587
    based upon the contents of sbp.
555
588
 * @param sbp The BlastScoreBlk* used to init prob [in]
556
589
*/
 
590
NCBI_XBLAST_EXPORT
557
591
Blast_ResFreq* Blast_ResFreqNew(const BlastScoreBlk* sbp);
558
592
 
559
593
/** Deallocates Blast_ResFreq and prob0 element.
560
594
 * @param rfp the Blast_ResFreq to be deallocated.
561
595
*/
 
596
NCBI_XBLAST_EXPORT
562
597
Blast_ResFreq* Blast_ResFreqFree(Blast_ResFreq* rfp);
563
598
 
564
599
 
567
602
 * @param rfp the prob element on this Blast_ResFreq is used.
568
603
 * @return zero on success
569
604
*/
 
605
NCBI_XBLAST_EXPORT
570
606
Int2 Blast_ResFreqStdComp(const BlastScoreBlk* sbp, Blast_ResFreq* rfp);
571
607
 
572
608
/** Creates a new structure to keep track of score frequencies for a scoring
575
611
 * @param score_max Maximum score [in]
576
612
 * @return allocated and initialized pointer to Blast_ScoreFreq
577
613
 */
 
614
NCBI_XBLAST_EXPORT
578
615
Blast_ScoreFreq*
579
616
Blast_ScoreFreqNew(Int4 score_min, Int4 score_max);
580
617
 
582
619
 * @param sfp the structure to deallocate [in]
583
620
 * @return NULL
584
621
 */
 
622
NCBI_XBLAST_EXPORT
585
623
Blast_ScoreFreq*
586
624
Blast_ScoreFreqFree(Blast_ScoreFreq* sfp);
587
625
 
593
631
 * @param residue_size size of "residues" buffer [in]
594
632
 * @return Number of residues in alphabet or negative returns upon error.
595
633
 */
 
634
NCBI_XBLAST_EXPORT
596
635
Int2
597
636
Blast_GetStdAlphabet(Uint1 alphabet_code, Uint1* residues, 
598
637
                     Uint4 residue_size);
604
643
 * @param sfp array of probabilities for all scores [in]
605
644
 * @return zero on success, 1 on error.
606
645
 */
 
646
NCBI_XBLAST_EXPORT
607
647
Int2
608
648
Blast_KarlinBlkUngappedCalc(Blast_KarlinBlk* kbp, Blast_ScoreFreq* sfp);
609
649
 
615
655
 * @param length the length of the sequence [in]
616
656
 * @param resProb the object to be filled in [in|out]
617
657
 */
 
658
NCBI_XBLAST_EXPORT
618
659
void
619
660
Blast_FillResidueProbability(const Uint1* sequence, Int4 length, double * resProb);
620
661
 
627
668
 [in|out]
628
669
 * @return zero on success.
629
670
*/
 
671
NCBI_XBLAST_EXPORT
630
672
Int2 BlastScoreBlkNuclMatrixCreate(BlastScoreBlk* sbp);
631
673
 
632
674
#ifdef __cplusplus