NCBI C++ ToolKit
blast_async_format.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: blast_async_format.hpp 76972 2017-03-16 12:03:45Z madden $
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: Tom Madden
27  *
28  * File Description:
29  * Class to print results in an asynchronous manner
30  *
31  */
32 
33 #ifndef ALGO_BLAST_FORMAT___BLAST_ASYNC_FORMAT__HPP
34 #define ALGO_BLAST_FORMAT___BLAST_ASYNC_FORMAT__HPP
35 
44 
45 
48 USING_SCOPE(blast);
49 
50 
51 /// Contains query, results and CBlastFormat for one batch
53 
56  CRef<CBlastFormat> formatter; ///< Information for formatting
58  : qVec(qv), blastResults(br), formatter(fmt) {}
59 };
60 
61 /////////////////////////////////////////////////////////////////////////////
62 /// Run as separate thread and format results.
64 {
65 public:
67  : m_ResultsMap(), m_Done(false), m_Semaphore(0, kMax_Int)
68  {
69  }
70 
71  /// Queue results for printing.
72  /// Will throw if called after call to Finalize or if a duplicate
73  /// batchNumber is entered.
74  /// Batch numbers should start at zero and increase. Missing numbers NOT allowed.
75  /// @param batchNumber orders how the results are printed.
76  /// Numbering starts at zero and missing values not allowed.
77  /// @param results data needed for formatting
78  void QueueResults(int batchNumber, vector<SFormatResultValues> results);
79 
80  /// Close queue for printing. No calls to QueueResults allowed after this.
81  void Finalize();
82 
83  /// Calls Finalize (if not already called) then CThread::Join();
84  /// Should only be called if QueueResults will no longer be called.
85  void Join();
86 
87 protected:
88  virtual ~CBlastAsyncFormatThread(void);
89 
90  virtual void* Main(void);
91 private:
92 
93  // Prohibit copy constructor and assignment operator
96 
97  std::map<int, vector<SFormatResultValues>> m_ResultsMap;
98 
99  bool m_Done;
100 
102 };
103 
104 #endif /* ALGO_BLAST_FORMAT___BLAST__ASYNC_FORMAT__HPP */
105 
Produce formatted blast output for command line applications.
USING_SCOPE(objects)
USING_NCBI_SCOPE
Interface for reading SRA sequences into blast input.
Interface for converting sources of sequence data into blast sequence input.
Declares CBlastScopeSource class to create properly configured CScope objects to invoke the BLAST dat...
Run as separate thread and format results.
std::map< int, vector< SFormatResultValues > > m_ResultsMap
CBlastAsyncFormatThread(const CBlastAsyncFormatThread &)
CSemaphore –.
Definition: ncbimtx.hpp:1375
#define false
Definition: bool.h:36
#define kMax_Int
Definition: ncbi_limits.h:184
virtual void * Main(void)=0
Derived (user-created) class must provide a real thread function.
void Join(void **exit_data=0)
Wait for the thread termination.
Definition: ncbithr.cpp:863
CThread & operator=(const CThread &)
#define NCBI_XBLASTFORMAT_EXPORT
Definition: ncbi_export.h:1073
The Object manager core.
NOTE: This file contains work in progress and the APIs are likely to change, please do not rely on th...
Defines BLAST database access classes.
Contains query, results and CBlastFormat for one batch.
CRef< CBlastFormat > formatter
Information for formatting.
SFormatResultValues(CRef< CBlastQueryVector > qv, CRef< CSearchResultSet > br, CRef< CBlastFormat > fmt)
CRef< CSearchResultSet > blastResults
Results.
CRef< CBlastQueryVector > qVec
Queries.
Uniform BLAST Search Interface.
Modified on Sun Apr 14 05:27:17 2024 by modify_doxy.py rev. 669887