NCBI C++ ToolKit
hspstream_test_util.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: hspstream_test_util.cpp 52410 2011-12-22 15:08:49Z 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 hspstream_test_util.cpp
31  * Auxiliary utilities needed for testing HSP stream interface.
32  */
33 
34 #include <ncbi_pch.hpp>
35 #include "hspstream_test_util.hpp"
37 
39 setupHSPList(int score, int num_queries, int oid)
40 {
41  BlastHSPList* hsp_list = Blast_HSPListNew(0);
42  int index;
43  for (index = 0; index < num_queries; ++index) {
44  hsp_list->hsp_array[index] = Blast_HSPNew();
45  hsp_list->hsp_array[index]->context = index;
46  hsp_list->hsp_array[index]->score = score;
47  }
48  hsp_list->hspcnt = num_queries;
49  hsp_list->oid = oid;
50  return hsp_list;
51 }
52 
54  int index, int nthreads, int total, int nqueries)
55  : m_ipHspStream(hsp_stream), m_iIndex(index), m_iNumThreads(nthreads),
56  m_iTotal(total), m_iNumQueries(nqueries)
57 {
58 }
59 
61 {
62 }
63 
65 {
66  const int max_score = 100;
67  int index;
68  int status;
69  BlastHSPList* hsp_list;
70 
71  for (index = m_iIndex; index < m_iTotal; index += m_iNumThreads) {
72  hsp_list =
73  setupHSPList(rand() % max_score, m_iNumQueries, index);
74  status = BlastHSPStreamWrite(m_ipHspStream, &hsp_list);
75  if (status != kBlastHSPStream_Success)
76  abort();
77  ASSERT(hsp_list == NULL);
78  }
79  return NULL;
80 }
81 
83 {
84 }
Structures and API used for saving BLAST hits.
BlastHSP * Blast_HSPNew(void)
Allocate and zeros out memory for an HSP structure.
Definition: blast_hits.c:141
BlastHSPList * Blast_HSPListNew(Int4 hsp_max)
Creates HSP list structure with a default size HSP array.
Definition: blast_hits.c:1558
int BlastHSPStreamWrite(BlastHSPStream *hsp_stream, BlastHSPList **hsp_list)
Invokes the user-specified write function for this BlastHSPStream implementation.
const int kBlastHSPStream_Success
Standard success return value for BlastHSPStream methods.
virtual void * Main(void)
Derived (user-created) class must provide a real thread function.
BlastHSPStream * m_ipHspStream
virtual void OnExit(void)
Override this to execute finalization code.
CHspStreamWriteThread(BlastHSPStream *hsp_stream, int index, int nthreads, int total, int nqueries)
#define NULL
Definition: ncbistd.hpp:225
BlastHSPList * setupHSPList(int score, int num_queries, int oid)
Auxiliary utilities needed for testing HSP stream interface.
#define ASSERT
macro for assert.
Definition: ncbi_std.h:107
void abort()
The structure to hold all HSPs for a given sequence after the gapped alignment.
Definition: blast_hits.h:153
Int4 oid
The ordinal id of the subject sequence this HSP list is for.
Definition: blast_hits.h:154
Int4 hspcnt
Number of HSPs saved.
Definition: blast_hits.h:158
BlastHSP ** hsp_array
Array of pointers to individual HSPs.
Definition: blast_hits.h:157
Default implementation of BlastHSPStream.
Int4 context
Context number of query.
Definition: blast_hits.h:133
Int4 score
This HSP's raw score.
Definition: blast_hits.h:127
Modified on Tue Apr 23 07:38:56 2024 by modify_doxy.py rev. 669887