~ubuntu-branches/ubuntu/maverick/ncbi-tools6/maverick

« back to all changes in this revision

Viewing changes to algo/blast/core/blast_diagnostics.c

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2005-03-27 12:00:15 UTC
  • mfrom: (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050327120015-embhesp32nj73p9r
Tags: 6.1.20041020-3
* Fix FTBFS under GCC 4.0 caused by inconsistent use of "static" on
  functions.  (Closes: #295110.)
* Add a watch file, now that we can.  (Upstream's layout needs version=3.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: blast_diagnostics.c,v 1.3 2004/07/06 15:38:23 dondosha Exp $
 
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 offical 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
 
 
35
static char const rcsid[] = 
 
36
    "$Id: blast_diagnostics.c,v 1.3 2004/07/06 15:38:23 dondosha Exp $";
 
37
 
 
38
#include <algo/blast/core/blast_diagnostics.h>
 
39
#include <algo/blast/core/blast_def.h>
 
40
 
 
41
BlastDiagnostics* Blast_DiagnosticsFree(BlastDiagnostics* diagnostics)
 
42
{
 
43
   if (diagnostics) {
 
44
      sfree(diagnostics->ungapped_stat);
 
45
      sfree(diagnostics->gapped_stat);
 
46
      sfree(diagnostics->cutoffs);
 
47
      if (diagnostics->mt_lock)
 
48
         diagnostics->mt_lock = MT_LOCK_Delete(diagnostics->mt_lock);
 
49
      sfree(diagnostics);
 
50
   }
 
51
   return NULL;
 
52
}
 
53
 
 
54
BlastDiagnostics* Blast_DiagnosticsInit() 
 
55
{
 
56
   BlastDiagnostics* diagnostics = 
 
57
      (BlastDiagnostics*) calloc(1, sizeof(BlastDiagnostics));
 
58
 
 
59
   diagnostics->ungapped_stat = 
 
60
      (BlastUngappedStats*) calloc(1, sizeof(BlastUngappedStats));
 
61
   diagnostics->gapped_stat = 
 
62
      (BlastGappedStats*) calloc(1, sizeof(BlastGappedStats));
 
63
   diagnostics->cutoffs = 
 
64
      (BlastRawCutoffs*) calloc(1, sizeof(BlastRawCutoffs));
 
65
 
 
66
   return diagnostics;
 
67
}
 
68
 
 
69
BlastDiagnostics* Blast_DiagnosticsInitMT(MT_LOCK mt_lock)
 
70
{
 
71
   BlastDiagnostics* retval = Blast_DiagnosticsInit();
 
72
   retval->mt_lock = mt_lock;
 
73
 
 
74
   return retval;
 
75
}
 
76
 
 
77
void Blast_UngappedStatsUpdate(BlastUngappedStats* ungapped_stats, 
 
78
                               Int4 total_hits, Int4 extended_hits,
 
79
                               Int4 saved_hits)
 
80
{
 
81
   if (!ungapped_stats || total_hits == 0)
 
82
      return;
 
83
 
 
84
   ungapped_stats->lookup_hits += total_hits;
 
85
   ++ungapped_stats->num_seqs_lookup_hits;
 
86
   ungapped_stats->init_extends += extended_hits;
 
87
   ungapped_stats->good_init_extends += saved_hits;
 
88
   if (saved_hits > 0)
 
89
      ++ungapped_stats->num_seqs_passed;
 
90
}
 
91
 
 
92
void 
 
93
Blast_DiagnosticsUpdate(BlastDiagnostics* global, BlastDiagnostics* local)
 
94
{
 
95
   if (global->mt_lock) 
 
96
      MT_LOCK_Do(global->mt_lock, eMT_Lock);
 
97
 
 
98
   if (global->ungapped_stat && local->ungapped_stat) {
 
99
      global->ungapped_stat->lookup_hits += 
 
100
         local->ungapped_stat->lookup_hits;
 
101
      global->ungapped_stat->num_seqs_lookup_hits += 
 
102
         local->ungapped_stat->num_seqs_lookup_hits;
 
103
      global->ungapped_stat->init_extends += 
 
104
         local->ungapped_stat->init_extends;
 
105
      global->ungapped_stat->good_init_extends += 
 
106
         local->ungapped_stat->good_init_extends;
 
107
      global->ungapped_stat->num_seqs_passed += 
 
108
         local->ungapped_stat->num_seqs_passed;
 
109
   }
 
110
 
 
111
   if (global->gapped_stat && local->gapped_stat) {
 
112
      global->gapped_stat->seqs_ungapped_passed += 
 
113
         local->gapped_stat->seqs_ungapped_passed;
 
114
      global->gapped_stat->extra_extensions += 
 
115
         local->gapped_stat->extra_extensions;
 
116
      global->gapped_stat->extensions += 
 
117
         local->gapped_stat->extensions;
 
118
      global->gapped_stat->good_extensions += 
 
119
         local->gapped_stat->good_extensions;
 
120
      global->gapped_stat->num_seqs_passed += 
 
121
         local->gapped_stat->num_seqs_passed;
 
122
   }
 
123
 
 
124
   if (global->cutoffs && local->cutoffs) {
 
125
      global->cutoffs->x_drop_ungapped = local->cutoffs->x_drop_ungapped;
 
126
      global->cutoffs->x_drop_gap = local->cutoffs->x_drop_gap;
 
127
      global->cutoffs->x_drop_gap_final = local->cutoffs->x_drop_gap_final;
 
128
      global->cutoffs->gap_trigger = local->cutoffs->gap_trigger;
 
129
   }
 
130
 
 
131
   if (global->mt_lock) 
 
132
      MT_LOCK_Do(global->mt_lock, eMT_Unlock);
 
133
}