~ubuntu-branches/debian/experimental/ncbi-tools6/experimental

« back to all changes in this revision

Viewing changes to algo/blast/api/blast_returns.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_returns.c,v 1.12 2004/10/06 15:01:01 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
/*****************************************************************************
 
27
 
 
28
File name: blast_returns.c
 
29
 
 
30
Author: Ilya Dondoshansky
 
31
 
 
32
Contents: Manipulating data returned from BLAST other than Seq-aligns
 
33
 
 
34
Detailed Contents: 
 
35
 
 
36
******************************************************************************
 
37
 * $Revision: 1.12 $
 
38
 * */
 
39
 
 
40
static char const rcsid[] = "$Id: blast_returns.c,v 1.12 2004/10/06 15:01:01 dondosha Exp $";
 
41
 
 
42
#include <algo/blast/api/blast_returns.h>
 
43
#include <algo/blast/api/blast_seq.h>
 
44
#include <algo/blast/core/blast_filter.h>
 
45
#include <algo/blast/core/blast_util.h>
 
46
 
 
47
TxDfDbInfo* Blast_GetDbInfo(ReadDBFILE* rdfp)
 
48
{
 
49
   TxDfDbInfo* dbinfo = NULL;
 
50
   char* chptr = NULL;
 
51
 
 
52
   if (!rdfp)
 
53
      return NULL;
 
54
 
 
55
   dbinfo = calloc(1, sizeof(TxDfDbInfo));
 
56
 
 
57
   dbinfo->name = strdup(readdb_get_filename(rdfp));
 
58
      
 
59
   if (((chptr = readdb_get_title(rdfp)) == NULL) && dbinfo->name)
 
60
      dbinfo->definition = strdup(dbinfo->name);
 
61
   else
 
62
      dbinfo->definition = strdup(chptr);       
 
63
      
 
64
   dbinfo->date = strdup(readdb_get_date(rdfp));
 
65
 
 
66
   dbinfo->is_protein = readdb_is_prot(rdfp);
 
67
     
 
68
   readdb_get_totals_ex(rdfp, &dbinfo->total_length, &dbinfo->number_seqs, TRUE);
 
69
   
 
70
   return dbinfo;
 
71
}
 
72
 
 
73
char*
 
74
Blast_GetParametersBuffer(EBlastProgramType program_number, 
 
75
        const Blast_SummaryReturn* sum_returns)
 
76
{
 
77
   char buffer[128];
 
78
   char* ret_buffer=NULL;
 
79
   Int2 ret_buffer_length=0;
 
80
   BlastUngappedStats* ungapped_stats = NULL;
 
81
   BlastGappedStats* gapped_stats = NULL;
 
82
   BlastRawCutoffs* raw_cutoffs = NULL;
 
83
   Blast_SearchParams* search_params=NULL;
 
84
   Blast_DatabaseStats* db_stats = NULL;
 
85
   BlastDiagnostics* diagnostics = NULL;
 
86
   
 
87
 
 
88
   if (sum_returns == NULL)
 
89
     return NULL;
 
90
 
 
91
   search_params = sum_returns->search_params;
 
92
   db_stats = sum_returns->db_stats;
 
93
   diagnostics = sum_returns->diagnostics;
 
94
 
 
95
   if (diagnostics) {
 
96
      ungapped_stats = diagnostics->ungapped_stat;
 
97
      gapped_stats = diagnostics->gapped_stat;
 
98
      raw_cutoffs = diagnostics->cutoffs;
 
99
   }
 
100
 
 
101
   if (program_number == eBlastTypeBlastn)
 
102
   {
 
103
      sprintf(buffer, "Matrix: blastn matrix:%d %d", search_params->match, search_params->mismatch);
 
104
      add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
105
   } 
 
106
   else if (search_params->matrix) 
 
107
   {
 
108
      sprintf(buffer, "Matrix: %s", search_params->matrix);
 
109
      add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
110
   }
 
111
 
 
112
   if (search_params->gapped_search) {
 
113
      sprintf(buffer, "Gap Penalties: Existence: %ld, Extension: %ld",
 
114
              (long) search_params->gap_open, 
 
115
              (long) search_params->gap_extension);
 
116
      add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
117
   }
 
118
   
 
119
   sprintf(buffer, "Number of Sequences: %ld", (long) db_stats->dbnum);
 
120
   add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
121
   if (ungapped_stats) {
 
122
      sprintf(buffer, "Number of Hits to DB: %s", 
 
123
              Nlm_Int8tostr(ungapped_stats->lookup_hits, 1));
 
124
      add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
125
   
 
126
      sprintf(buffer, "Number of extensions: %ld", 
 
127
              (long) ungapped_stats->init_extends);
 
128
      add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
129
      sprintf(buffer, "Number of successful extensions: %ld", 
 
130
              (long) ungapped_stats->good_init_extends);
 
131
      add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
132
   }
 
133
 
 
134
   if (gapped_stats) {
 
135
      if (search_params->expect > 0.1) {
 
136
         sprintf(buffer, "Number of sequences better than %4.1f: %ld", 
 
137
                 search_params->expect, 
 
138
                 (long) gapped_stats->num_seqs_passed);
 
139
      } else {
 
140
         sprintf(buffer, "Number of sequences better than %3.1e: %ld", 
 
141
                 search_params->expect, 
 
142
                 (long) gapped_stats->num_seqs_passed);
 
143
      }
 
144
      add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
145
   
 
146
      if (search_params->gapped_search) {
 
147
         sprintf(buffer, 
 
148
                 "Number of HSP's better than %4.1f without gapping: %ld", 
 
149
                 search_params->expect, 
 
150
                 (long) gapped_stats->seqs_ungapped_passed);
 
151
         add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
152
         sprintf(buffer, 
 
153
                 "Number of HSP's gapped: %ld", 
 
154
                 (long) gapped_stats->extensions);
 
155
         add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
156
         sprintf(buffer, 
 
157
                 "Number of HSP's successfully gapped: %ld", 
 
158
                 (long) gapped_stats->good_extensions);
 
159
         add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
160
         sprintf(buffer, 
 
161
               "Number of extra gapped extensions for HSPs above %4.1f: %ld", 
 
162
                 search_params->expect,
 
163
                 (long) gapped_stats->extra_extensions);
 
164
         add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
165
      }
 
166
   }
 
167
 
 
168
   /* Query length makes sense only for single query sequence. */
 
169
   if (db_stats->qlen > 0) {
 
170
      sprintf(buffer, "Length of query: %ld", (long)db_stats->qlen);
 
171
      add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
172
   }
 
173
 
 
174
   sprintf(buffer, "Length of database: %s", Nlm_Int8tostr (db_stats->dblength, 1));
 
175
   add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
176
   
 
177
   if (db_stats->qlen > 0) {
 
178
      sprintf(buffer, "Length adjustment: %ld", (long) db_stats->hsp_length);
 
179
      add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
180
 
 
181
      /** FIXME: Should this be different for RPS BLAST? */
 
182
      sprintf(buffer, "Effective length of query: %ld", (long)db_stats->eff_qlen);
 
183
      add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
184
      
 
185
      sprintf(buffer, "Effective length of database: %s", 
 
186
              Nlm_Int8tostr (db_stats->eff_dblength , 1));
 
187
      add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
188
      sprintf(buffer, "Effective search space: %8.0f", (double) db_stats->eff_searchsp);
 
189
      add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
190
      sprintf(buffer, "Effective search space used: %8.0f", (double) db_stats->eff_searchsp_used);
 
191
      add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
192
   }
 
193
   sprintf(buffer, "Neighboring words threshold: %ld", 
 
194
           (long) search_params->threshold);
 
195
   add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
196
   sprintf(buffer, "Window for multiple hits: %ld", 
 
197
           (long) search_params->window_size);
 
198
   add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
199
   
 
200
   if (raw_cutoffs) {
 
201
      BLAST_KAParameters* ka_params_gap = sum_returns->ka_params_gap;
 
202
      BLAST_KAParameters* ka_params = sum_returns->ka_params;
 
203
 
 
204
      sprintf(buffer, "X1: %ld (%4.1f bits)", 
 
205
              (long)raw_cutoffs->x_drop_ungapped, (raw_cutoffs->x_drop_ungapped)*(ka_params->Lambda)/NCBIMATH_LN2);
 
206
      add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
207
 
 
208
      if (search_params->gapped_search) {
 
209
         sprintf(buffer, "X2: %ld (%4.1f bits)", 
 
210
                 (long)raw_cutoffs->x_drop_gap, raw_cutoffs->x_drop_gap*(ka_params_gap->Lambda)/NCBIMATH_LN2);
 
211
         add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
212
         sprintf(buffer, "X3: %ld (%4.1f bits)", 
 
213
                 (long)raw_cutoffs->x_drop_gap_final, raw_cutoffs->x_drop_gap_final*(ka_params_gap->Lambda)/NCBIMATH_LN2);
 
214
         add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
215
      
 
216
         sprintf(buffer, "S1: %ld (%4.1f bits)", 
 
217
                 (long)raw_cutoffs->gap_trigger, 
 
218
                 ((raw_cutoffs->gap_trigger*(ka_params->Lambda))-(log(ka_params->K)))/NCBIMATH_LN2);
 
219
         add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
220
      }
 
221
 
 
222
      if (search_params->gapped_search)
 
223
          sprintf(buffer, "S2: %ld (%4.1f bits)", (long) raw_cutoffs->cutoff_score, 
 
224
            (((raw_cutoffs->cutoff_score)*(ka_params_gap->Lambda))-(log(ka_params_gap->K)))/NCBIMATH_LN2);
 
225
      else
 
226
          sprintf(buffer, "S2: %ld (%4.1f bits)", (long) raw_cutoffs->cutoff_score, 
 
227
            (((raw_cutoffs->cutoff_score)*(ka_params->Lambda))-(log(ka_params->K)))/NCBIMATH_LN2);
 
228
      
 
229
      add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
 
230
   }
 
231
 
 
232
   return ret_buffer;
 
233
}
 
234
 
 
235
/** Save the Karlin-Altschul parameters calculated in the BLAST search.
 
236
 * @param sbp Internal scoring block structure [in]
 
237
 * @param context Index into the array of structures containing
 
238
 *                Karlin-Altschul parameters [in]
 
239
 * @param sum_returns Returns summary structure [out]
 
240
*/
 
241
static void 
 
242
Blast_SummaryKAParametersFill(const BlastScoreBlk* sbp, Int4 context, 
 
243
                              Blast_SummaryReturn* sum_returns)
 
244
{
 
245
   Blast_KarlinBlk* kbp;
 
246
 
 
247
   if (!sbp)
 
248
      return;
 
249
 
 
250
   if (sbp->kbp) {
 
251
      kbp = sbp->kbp[context];
 
252
      sum_returns->ka_params = 
 
253
         (BLAST_KAParameters*) malloc(sizeof(BLAST_KAParameters));
 
254
      sum_returns->ka_params->Lambda = kbp->Lambda;
 
255
      sum_returns->ka_params->K = kbp->K;
 
256
      sum_returns->ka_params->H = kbp->H;
 
257
   }
 
258
 
 
259
   if (sbp->kbp_gap) {
 
260
      kbp = sbp->kbp_gap[context];
 
261
      sum_returns->ka_params_gap = 
 
262
         (BLAST_KAParameters*) malloc(sizeof(BLAST_KAParameters));
 
263
      sum_returns->ka_params_gap->Lambda = kbp->Lambda;
 
264
      sum_returns->ka_params_gap->K = kbp->K;
 
265
      sum_returns->ka_params_gap->H = kbp->H;
 
266
   }
 
267
}
 
268
 
 
269
/** Frees Blast_DatabaseStats object
 
270
 * @param db_stats object to be freed [in]
 
271
 * @return NULL pointer 
 
272
 */
 
273
static Blast_DatabaseStats*
 
274
Blast_SummaryDBStatsFree(Blast_DatabaseStats* db_stats)
 
275
{
 
276
    sfree(db_stats);
 
277
    return NULL;
 
278
}
 
279
 
 
280
/** Allocated and fills in Blast_DatabaseStats
 
281
 * Either rdfp or subject_slp should be non-NULL, not both!
 
282
 *
 
283
 * @param program_number blastn/blastp/etc. [in]
 
284
 * @param eff_len_options pointer to effective length options [in]
 
285
 * @param query_info information about query [in]
 
286
 * @param rdfp pointer to BLAST DB reader [in]
 
287
 * @param subject_slp Seq-loc for target sequence [in]
 
288
 * @param db_stats object to be returned [out]
 
289
 * @return zero on success
 
290
 */
 
291
static Int2 
 
292
Blast_SummaryDBStatsFill(EBlastProgramType program_number, 
 
293
   const BlastEffectiveLengthsOptions* eff_len_options,
 
294
   const BlastQueryInfo* query_info, ReadDBFILE* rdfp, 
 
295
   SeqLoc* subject_slp, Blast_DatabaseStats** db_stats)
 
296
{
 
297
   Int8 total_length=0;  /* total length of database. */
 
298
   Int4 num_entries=0;   /* number of entries in database. */
 
299
   Int4 num_frames;      /* number of frames allowed. */
 
300
 
 
301
   ASSERT(db_stats);
 
302
 
 
303
   *db_stats = (Blast_DatabaseStats*) calloc(1, sizeof(Blast_DatabaseStats));
 
304
   if (*db_stats == NULL)
 
305
     return -1;
 
306
 
 
307
   if (eff_len_options->db_length) {
 
308
      total_length = eff_len_options->db_length;
 
309
   } else if (rdfp) {
 
310
      readdb_get_totals_ex(rdfp, &total_length, &num_entries, TRUE);
 
311
   } else {
 
312
      SeqLoc* slp;
 
313
      for (slp = subject_slp; slp; slp = slp->next) {
 
314
         total_length += SeqLocLen(slp);
 
315
      }
 
316
   }
 
317
      
 
318
   if (program_number == eBlastTypeTblastn || 
 
319
       program_number == eBlastTypeRpsTblastn ||
 
320
       program_number == eBlastTypeTblastx)
 
321
      total_length /= 3;
 
322
 
 
323
   (*db_stats)->dblength = total_length;
 
324
 
 
325
 
 
326
   if (eff_len_options->dbseq_num)
 
327
      num_entries = eff_len_options->dbseq_num;
 
328
   else if (!rdfp) 
 
329
      num_entries = ValNodeLen(subject_slp);
 
330
 
 
331
   (*db_stats)->dbnum = num_entries;
 
332
 
 
333
   if (program_number == eBlastTypeBlastx ||
 
334
       program_number == eBlastTypeTblastx)
 
335
      num_frames = NUM_FRAMES;
 
336
   else if (program_number == eBlastTypeBlastn)
 
337
      num_frames = 2;
 
338
   else
 
339
      num_frames = 1;
 
340
 
 
341
   
 
342
   if (query_info->last_context < num_frames) {  /* Only one query here. */
 
343
      Int4 qlen = BLAST_GetQueryLength(query_info, query_info->first_context);
 
344
      (*db_stats)->hsp_length = query_info->length_adjustments[query_info->first_context];
 
345
      /** FIXME: Should this be different for RPS BLAST? */
 
346
      (*db_stats)->qlen = qlen;
 
347
      (*db_stats)->eff_qlen = qlen - ((*db_stats)->hsp_length);
 
348
      (*db_stats)->eff_dblength = total_length - num_entries*((*db_stats)->hsp_length);
 
349
      (*db_stats)->eff_searchsp = query_info->eff_searchsp_array[query_info->first_context];
 
350
      if (eff_len_options && eff_len_options->searchsp_eff)
 
351
         (*db_stats)->eff_searchsp_used = eff_len_options->searchsp_eff;
 
352
      else
 
353
         (*db_stats)->eff_searchsp_used = (*db_stats)->eff_searchsp;
 
354
   }
 
355
 
 
356
   return 0;
 
357
}
 
358
 
 
359
/** Free Blast_SearchParams structure and underlying data
 
360
 *
 
361
 * @param search_params the object to be freed [in]
 
362
 * @return NULL pointer 
 
363
 */
 
364
static Blast_SearchParams*
 
365
Blast_SummarySearchParamsFree(Blast_SearchParams* search_params)
 
366
{
 
367
 
 
368
   if (search_params == NULL)
 
369
      return NULL;
 
370
 
 
371
   sfree(search_params->matrix);
 
372
   sfree(search_params->entrez_query);
 
373
   sfree(search_params->filter_string);
 
374
   sfree(search_params);
 
375
 
 
376
   return NULL;
 
377
}
 
378
 
 
379
/** Allocated and fills some search parameters.  
 
380
 * 
 
381
 * @param program_number identifies blastn/blastp/etc. [in]
 
382
 * @param score_options pointer to scoring options [in]
 
383
 * @param lookup_options pointer to options for lookup table creation [in]
 
384
 * @param hit_options options for saving and evaluating hits [in]
 
385
 * @param query_setup options for filtering etc. [in]
 
386
 * @param word_options options for processing initial hits [in]
 
387
 * @param entrez_query limit search by this query [in]
 
388
 * @param search_params object to be allocated and filled [out]
 
389
 * @return zero on success
 
390
 */
 
391
static Int2 
 
392
Blast_SummarySearchParamsFill(EBlastProgramType program_number,
 
393
   const BlastScoringOptions* score_options,
 
394
   const LookupTableOptions* lookup_options,
 
395
   const BlastHitSavingOptions* hit_options,
 
396
   const QuerySetUpOptions* query_setup, 
 
397
   const BlastInitialWordOptions* word_options,
 
398
   const char* entrez_query,
 
399
   Blast_SearchParams** search_params)
 
400
{
 
401
   Blast_SearchParams* search_params_lcl;
 
402
 
 
403
   ASSERT(search_params);
 
404
   ASSERT(score_options && lookup_options && hit_options && query_setup);
 
405
 
 
406
   *search_params = search_params_lcl = (Blast_SearchParams*) calloc(1, sizeof(Blast_SearchParams));
 
407
   if (search_params_lcl == NULL)
 
408
     return -1;
 
409
 
 
410
   if (program_number == eBlastTypeBlastn)
 
411
   {
 
412
      search_params_lcl->match = score_options->reward;
 
413
      search_params_lcl->mismatch = score_options->penalty;
 
414
   } 
 
415
   else if (score_options->matrix) 
 
416
   {
 
417
      search_params_lcl->matrix = StringSave(score_options->matrix);
 
418
   }
 
419
 
 
420
   if (score_options->gapped_calculation) 
 
421
   {
 
422
      search_params_lcl->gapped_search = TRUE;
 
423
      search_params_lcl->gap_open = score_options->gap_open;
 
424
      search_params_lcl->gap_extension = score_options->gap_extend;
 
425
   }
 
426
   else
 
427
      search_params_lcl->gapped_search = FALSE;
 
428
 
 
429
   if (query_setup && query_setup->filter_string)
 
430
      search_params_lcl->filter_string = StringSave(query_setup->filter_string);
 
431
   else
 
432
      search_params_lcl->filter_string = StringSave("F");
 
433
 
 
434
   search_params_lcl->expect = hit_options->expect_value;
 
435
 
 
436
   if (lookup_options->phi_pattern)
 
437
      search_params_lcl->pattern = StringSave(lookup_options->phi_pattern); 
 
438
 
 
439
   search_params_lcl->threshold = lookup_options->threshold;
 
440
 
 
441
   search_params_lcl->window_size = word_options->window_size;
 
442
 
 
443
   if (entrez_query)
 
444
      search_params_lcl->entrez_query = StringSave(entrez_query);
 
445
 
 
446
   return 0;
 
447
}
 
448
 
 
449
 
 
450
Blast_SummaryReturn* 
 
451
Blast_SummaryReturnFree(Blast_SummaryReturn* sum_returns)
 
452
{
 
453
   if (sum_returns) {
 
454
      sfree(sum_returns->ka_params);
 
455
      sfree(sum_returns->ka_params_gap);
 
456
      sum_returns->db_stats = Blast_SummaryDBStatsFree(sum_returns->db_stats);
 
457
      sum_returns->search_params = Blast_SummarySearchParamsFree(sum_returns->search_params);
 
458
      sum_returns->diagnostics = Blast_DiagnosticsFree(sum_returns->diagnostics);
 
459
      sfree(sum_returns);
 
460
   }
 
461
   return NULL;
 
462
}
 
463
 
 
464
Int2 Blast_SummaryReturnFill(EBlastProgramType program_number, 
 
465
        const BlastScoringOptions* score_options, 
 
466
        const BlastScoreBlk* sbp,
 
467
        const LookupTableOptions* lookup_options,
 
468
        const BlastInitialWordOptions* word_options,
 
469
        const BlastExtensionOptions* ext_options,
 
470
        const BlastHitSavingOptions* hit_options,
 
471
        const BlastEffectiveLengthsOptions* eff_len_options,
 
472
        const QuerySetUpOptions* query_setup,
 
473
        const BlastQueryInfo* query_info,
 
474
        ReadDBFILE* rdfp, SeqLoc* subject_slp,
 
475
        BlastDiagnostics** diagnostics,
 
476
        Blast_SummaryReturn** sum_returns_out)
 
477
{
 
478
   Blast_SummaryReturn* sum_returns = 
 
479
      (Blast_SummaryReturn*) calloc(1, sizeof(Blast_SummaryReturn));
 
480
 
 
481
   if (sum_returns_out == NULL)
 
482
      return -1;
 
483
 
 
484
   if (score_options == NULL || sbp == NULL || lookup_options == NULL || 
 
485
      word_options == NULL || ext_options == NULL || hit_options == NULL ||
 
486
      eff_len_options == NULL || query_info == NULL)
 
487
     return -1;
 
488
 
 
489
   if (rdfp == NULL && subject_slp == NULL)
 
490
     return -1;
 
491
 
 
492
   Blast_SummaryKAParametersFill(sbp, query_info->first_context, sum_returns);
 
493
   Blast_SummaryDBStatsFill(program_number, eff_len_options, query_info, rdfp, 
 
494
            subject_slp, &(sum_returns->db_stats));
 
495
   
 
496
   Blast_SummarySearchParamsFill(program_number, score_options,
 
497
            lookup_options, hit_options, query_setup, word_options,
 
498
            NULL, &(sum_returns->search_params));
 
499
   if (diagnostics)
 
500
   {
 
501
      sum_returns->diagnostics = *diagnostics;
 
502
      *diagnostics = NULL;
 
503
   }
 
504
   *sum_returns_out = sum_returns;
 
505
 
 
506
   return 0;
 
507
}