NCBI C++ ToolKit
blast_diagnostics.c
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: blast_diagnostics.c 72378 2016-05-04 14:59:01Z camacho $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Author: Ilya Dondoshansky
27  *
28  */
29 
30 /** @file blast_diagnostics.c
31  * Manipulating diagnostics data returned from BLAST
32  */
33 
34 
37 
39 {
40  if (diagnostics) {
41  sfree(diagnostics->ungapped_stat);
42  sfree(diagnostics->gapped_stat);
43  sfree(diagnostics->cutoffs);
44  if (diagnostics->mt_lock)
45  diagnostics->mt_lock = MT_LOCK_Delete(diagnostics->mt_lock);
46  sfree(diagnostics);
47  }
48  return NULL;
49 }
50 
52 {
53  BlastDiagnostics* retval = NULL;
54  if (diagnostics == NULL) {
55  return retval;
56  }
57  retval = Blast_DiagnosticsInit();
58  if (diagnostics->ungapped_stat) {
59  memcpy((void*)retval->ungapped_stat, (void*)diagnostics->ungapped_stat,
60  sizeof(*retval->ungapped_stat));
61  } else {
62  sfree(diagnostics->ungapped_stat);
63  }
64  if (diagnostics->gapped_stat) {
65  memcpy((void*)retval->gapped_stat, (void*)diagnostics->gapped_stat,
66  sizeof(*retval->gapped_stat));
67  } else {
68  sfree(diagnostics->gapped_stat);
69  }
70  if (diagnostics->cutoffs) {
71  memcpy((void*)retval->cutoffs, (void*)diagnostics->cutoffs,
72  sizeof(*retval->cutoffs));
73  } else {
74  sfree(diagnostics->cutoffs);
75  }
76  return retval;
77 }
78 
80 {
81  BlastDiagnostics* diagnostics =
83 
84  diagnostics->ungapped_stat =
86  diagnostics->gapped_stat =
88  diagnostics->cutoffs =
89  (BlastRawCutoffs*) calloc(1, sizeof(BlastRawCutoffs));
90 
91  return diagnostics;
92 }
93 
95 {
97  retval->mt_lock = mt_lock;
98 
99  return retval;
100 }
101 
103  Int4 total_hits, Int4 extended_hits,
104  Int4 saved_hits)
105 {
106  if (!ungapped_stats || total_hits == 0)
107  return;
108 
109  ungapped_stats->lookup_hits += total_hits;
110  ++ungapped_stats->num_seqs_lookup_hits;
111  ungapped_stats->init_extends += extended_hits;
112  ungapped_stats->good_init_extends += saved_hits;
113  if (saved_hits > 0)
114  ++ungapped_stats->num_seqs_passed;
115 }
116 
117 void
119 {
120  if (!local)
121  return;
122 
123  if (global->mt_lock)
124  MT_LOCK_Do(global->mt_lock, eMT_Lock);
125 
126  if (global->ungapped_stat && local->ungapped_stat) {
127  global->ungapped_stat->lookup_hits +=
128  local->ungapped_stat->lookup_hits;
130  local->ungapped_stat->num_seqs_lookup_hits;
131  global->ungapped_stat->init_extends +=
132  local->ungapped_stat->init_extends;
133  global->ungapped_stat->good_init_extends +=
134  local->ungapped_stat->good_init_extends;
135  global->ungapped_stat->num_seqs_passed +=
136  local->ungapped_stat->num_seqs_passed;
137  }
138 
139  if (global->gapped_stat && local->gapped_stat) {
140  global->gapped_stat->seqs_ungapped_passed +=
141  local->gapped_stat->seqs_ungapped_passed;
142  global->gapped_stat->extensions +=
143  local->gapped_stat->extensions;
144  global->gapped_stat->good_extensions +=
145  local->gapped_stat->good_extensions;
146  global->gapped_stat->num_seqs_passed +=
147  local->gapped_stat->num_seqs_passed;
148  }
149 
150  if (global->cutoffs && local->cutoffs) {
151  global->cutoffs->x_drop_ungapped = local->cutoffs->x_drop_ungapped;
152  global->cutoffs->x_drop_gap = local->cutoffs->x_drop_gap;
153  global->cutoffs->x_drop_gap_final = local->cutoffs->x_drop_gap_final;
154  global->cutoffs->ungapped_cutoff = local->cutoffs->ungapped_cutoff;
155  global->cutoffs->cutoff_score = local->cutoffs->cutoff_score;
156  }
157 
158  if (global->mt_lock)
159  MT_LOCK_Do(global->mt_lock, eMT_Unlock);
160 }
Definitions used throughout BLAST.
#define sfree(x)
Safe free a pointer: belongs to a higher level header.
Definition: blast_def.h:112
BlastDiagnostics * Blast_DiagnosticsInitMT(MT_LOCK mt_lock)
Initialize the BlastDiagnostics structure for a multi-threaded search.
void Blast_UngappedStatsUpdate(BlastUngappedStats *ungapped_stats, Int4 total_hits, Int4 extended_hits, Int4 saved_hits)
Fill data in the ungapped hits diagnostics structure.
BlastDiagnostics * Blast_DiagnosticsFree(BlastDiagnostics *diagnostics)
Free the BlastDiagnostics structure and all substructures.
void Blast_DiagnosticsUpdate(BlastDiagnostics *global, BlastDiagnostics *local)
In a multi-threaded run, update global diagnostics data with the data coming from one of the prelimin...
BlastDiagnostics * Blast_DiagnosticsCopy(const BlastDiagnostics *diagnostics)
Free the BlastDiagnostics structure and all substructures.
BlastDiagnostics * Blast_DiagnosticsInit()
Initialize the BlastDiagnostics structure and all its substructures.
Various diagnostics (hit counts, etc.) returned from the BLAST engine.
#define NULL
Definition: ncbistd.hpp:225
int32_t Int4
4-byte (32-bit) signed integer
Definition: ncbitype.h:102
MT_LOCK MT_LOCK_Delete(MT_LOCK lk)
Decrement internal reference count by 1, and if it reaches 0, then destroy the handle,...
Definition: ncbi_core.c:234
#define MT_LOCK_Do(lk, how)
Call "lk->handler(lk->data, how)".
Definition: ncbi_core.h:270
@ eMT_Unlock
unlock critical section
Definition: ncbi_core.h:183
@ eMT_Lock
lock critical section
Definition: ncbi_core.h:181
Return statistics from the BLAST search.
BlastUngappedStats * ungapped_stat
Ungapped extension counts.
BlastRawCutoffs * cutoffs
Various raw values for the cutoffs.
BlastGappedStats * gapped_stat
Gapped extension counts.
MT_LOCK mt_lock
Mutex for updating diagnostics data in a multi-threaded search.
Structure containing hit counts from the gapped stage of a BLAST search.
Int4 good_extensions
Number of HSPs below the e-value threshold after gapped extension.
Int4 num_seqs_passed
Number of sequences with top HSP passing the e-value threshold.
Int4 seqs_ungapped_passed
Number of sequences with top HSP after ungapped extension passing the e-value threshold.
Int4 extensions
Total number of gapped extensions performed.
Structure holding raw cutoff and gap-x-drop values.
Int4 ungapped_cutoff
Minimal raw score for starting gapped extension.
Int4 x_drop_gap_final
Raw value of the x-dropoff for gapped extensions with traceback.
Int4 x_drop_gap
Raw value of the x-dropoff for preliminary gapped extensions.
Int4 x_drop_ungapped
Raw value of the x-dropoff for ungapped extensions.
Int4 cutoff_score
Cutoff score corresponding to given evalue.
Structure containing hit counts from the ungapped stage of a BLAST search.
Int4 num_seqs_lookup_hits
Number of sequences which had at least one lookup table hit.
Int8 lookup_hits
Number of successful lookup table hits.
Int4 init_extends
Number of initial words found and extended.
Int4 good_init_extends
Number of successful initial extensions, i.e.
Int4 num_seqs_passed
Number of sequences with at least one HSP saved after ungapped stage.
voidp calloc(uInt items, uInt size)
#define local
Definition: zutil.h:33
Modified on Tue May 28 05:53:04 2024 by modify_doxy.py rev. 669887