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

Go to the SVN repository for this file.

1 /* $Id: igblastn.hpp 93299 2021-03-29 18:29:47Z jianye $
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  * Authors: Ning Ma, Jian Jee, Yury Merezhuk
27  *
28  */
29 
30 #ifndef __IGBLASTN_HPP__
31 #define __IGBLASTN_HPP__
32 
33 
34 #include "igblast_types.hpp"
35 
36 
37 
39 {
40 public:
41  class CIgBlastContext : public CObject {
42  public:
47 
48  };
49 
50  typedef std::map< int , CRef<CIgBlastContext> > IG_ResultsMap ;
51 
52  class CiGCommonBlock : public CObject {
53  public:
54 
55  };
56 
57  // START: WORKER THREAD DECLARATION ===========================
58  // USES:
59  // m_Mutex -- for access controll
60  // m_run_thread_count -- +1 on start -1 on exit. used by formatter thread exit condition
61  // m_max_batch -- +1 if next batch was succesfuly taken from input
62  // m_input -- to get data to search
63  // m_all_results -- to store results
64  // m_new_batch_done -- to notify formater thread fo new data available
65  class CIgWorker : public CThread{
66  public:
67  CIgWorker( const CArgs& args,
68  CRef<CIgBlastnAppArgs> cmd_line_args,
69  CFastMutex &mx_input,
70  CFastMutex &mx_output,
71  CFastMutex &mx_notify,
72  CFastMutex &mx_global,
73  IG_ResultsMap &resmap,
74  int &maxbatch,
75  CRef<CIgBlastArgs> igargs,
76  CRef<CBlastOptionsHandle> opts_hndl,
77  CRef<CLocalDbAdapter> blastdb,
78  CRef<CBlastInput> user_input,
79  int &th_count,
80  CSemaphore &batct_notify,
81  bool &any_started) :
82  thm_args( args ),
83  thm_CmdLineArgs( cmd_line_args ),
84  thm_Mutex_Input(mx_input),
85  thm_Mutex_Output(mx_output),
86  thm_Mutex_Notify(mx_notify),
87  thm_Mutex_Global(mx_global),
88  thm_all_results(resmap),
89  thm_max_batch(maxbatch),
90  thm_ig_args( igargs ),
91  thm_opts_hndl( opts_hndl ),
92  thm_blastdb( blastdb ),
93  thm_input(user_input),
94  thm_run_thread_count(th_count),
95  thm_new_batch_done(batct_notify),
96  thm_any_started( any_started )
97  { }
98  virtual void* Main(void);
99  virtual void OnExit(void);
100 
101  private:
102  const CArgs& thm_args;
109  int &thm_max_batch; // indicate # but taken from m_input
116  int thm_tid;
119  };
120  // END: WORKER THREAD DECLARATION ===========================
121  // START: FORMATTER THREAD DECLARATION ========================
122  // USES:
123  // m_Mutex -- for access controll
124  // m_run_thread_count -- +1 on start -1 on exit. used by formatter thread exit condition
125  // m_max_batch -- +1 if next batch was succesfuly taken from input
126  // m_input -- NOT USED
127  // m_all_results -- to read/process results
128  // m_new_batch_done -- to listen for notify for new data available
129  // m_Clone -- to store collected clone info
130  //
131  class CIgFormatter : public CThread{
132  public:
134  CRef<CBlastOptionsHandle> opts_hndl,
135  CFastMutex &mx_input,
136  CFastMutex &mx_output,
137  CFastMutex &mx_notify,
138  CFastMutex &mx_global,
139  IG_ResultsMap &resmap,
140  int &total_input,
141  int &maxbatch,
142  int &th_count,
143  CSemaphore &batct_notify,
144  CloneInfo &cinfo,
145  bool &any_started) :
146  thm_CmdLineArgs( cmd_line_args ),
147  thm_opts_hndl( opts_hndl ),
148  thm_Mutex_Input(mx_input),
149  thm_Mutex_Output(mx_output),
150  thm_Mutex_Notify(mx_notify),
151  thm_Mutex_Global(mx_global),
152  thm_all_results(resmap),
153  thm_max_batch(maxbatch),
154  thm_total_input(total_input),
155  thm_run_thread_count(th_count),
156  thm_new_batch_done(batct_notify),
157  thm_Clone( cinfo),
158  thm_any_started(any_started)
159  { }
160 
161  virtual void* Main(void);
162  virtual void OnExit(void);
163 
164  private:
172  int &thm_max_batch; // indicate # but taken from m_input
177  int thm_tid;
180  };
181  // END: FORMATTER THREAD DECLARATION ========================
182 
183  /** @inheritDoc */
184  CIgBlastnApp() : m_new_batch_done(0, UINT_MAX>>1)
185  {
187  version->SetVersionInfo(new CIgBlastVersion());
189  m_max_batch = 0;
190  m_run_thread_count = 0; // number of thread running
191  m_global_done = false;
192  }
193 
194 private:
195  /** @inheritDoc */
196  virtual void Init();
197  /** @inheritDoc */
198  virtual int Run();
199  // run worker threads
200  void Init_Worker_Threads( int thread_num );
201  void Init_Formatter_Thread(void);
202  void Join_Worker_Threads(void);
203  void Run_Worker_Threads(bool is_detached );
204  void Run_Formatter_Threads(void);
205  unsigned int x_CountUserBatches(CBlastInputSourceConfig &iconfig, int batch_size=10000 );
206 
207  /// This application's command line args
210  // START THREAD-COMMON-DATA-BLOCK=========================
214  //OLD OK static CFastMutex m_Mutex;
220  int m_max_batch; // indicate number pf batches taken from m_input
228  bool m_any_started; // Formatter thread only
229  // END THREAD-COMMON-DATA-BLOCK =========================
232  vector< CRef < CIgWorker > > m_workers;
237 };
238 
239 #endif
CArgs –.
Definition: ncbiargs.hpp:379
Class that centralizes the configuration data for sequences to be converted.
Definition: blast_input.hpp:48
CFastMutex –.
Definition: ncbimtx.hpp:667
Keeps track of the version of IgBLAST in the NCBI C++ toolkit.
Definition: igblast.hpp:54
CRef< CSearchResultSet > m_results
Definition: igblastn.hpp:44
CRef< CBlastQueryVector > m_queries
Definition: igblastn.hpp:45
CRef< CIgBlastnAppArgs > thm_CmdLineArgs
Definition: igblastn.hpp:165
CIgFormatter(CRef< CIgBlastnAppArgs > cmd_line_args, CRef< CBlastOptionsHandle > opts_hndl, CFastMutex &mx_input, CFastMutex &mx_output, CFastMutex &mx_notify, CFastMutex &mx_global, IG_ResultsMap &resmap, int &total_input, int &maxbatch, int &th_count, CSemaphore &batct_notify, CloneInfo &cinfo, bool &any_started)
Definition: igblastn.hpp:133
CRef< CBlastOptionsHandle > thm_opts_hndl
Definition: igblastn.hpp:166
IG_ResultsMap & thm_all_results
Definition: igblastn.hpp:171
CFastMutex & thm_Mutex_Input
Definition: igblastn.hpp:167
CFastMutex & thm_Mutex_Global
Definition: igblastn.hpp:170
CFastMutex & thm_Mutex_Notify
Definition: igblastn.hpp:169
virtual void * Main(void)
Derived (user-created) class must provide a real thread function.
CFastMutex & thm_Mutex_Output
Definition: igblastn.hpp:168
virtual void OnExit(void)
Override this to execute finalization code.
CSemaphore & thm_new_batch_done
Definition: igblastn.hpp:175
IG_ResultsMap & thm_all_results
Definition: igblastn.hpp:108
CRef< CBlastOptionsHandle > thm_opts_hndl
Definition: igblastn.hpp:111
CRef< CIgBlastArgs > thm_ig_args
Definition: igblastn.hpp:110
CFastMutex & thm_Mutex_Output
Definition: igblastn.hpp:105
CFastMutex & thm_Mutex_Input
Definition: igblastn.hpp:104
CFastMutex & thm_Mutex_Global
Definition: igblastn.hpp:107
CRef< CBlastInput > thm_input
Definition: igblastn.hpp:113
CRef< CLocalDbAdapter > thm_blastdb
Definition: igblastn.hpp:112
virtual void * Main(void)
Derived (user-created) class must provide a real thread function.
virtual void OnExit(void)
Override this to execute finalization code.
CSemaphore & thm_new_batch_done
Definition: igblastn.hpp:115
const CArgs & thm_args
Definition: igblastn.hpp:102
CIgWorker(const CArgs &args, CRef< CIgBlastnAppArgs > cmd_line_args, CFastMutex &mx_input, CFastMutex &mx_output, CFastMutex &mx_notify, CFastMutex &mx_global, IG_ResultsMap &resmap, int &maxbatch, CRef< CIgBlastArgs > igargs, CRef< CBlastOptionsHandle > opts_hndl, CRef< CLocalDbAdapter > blastdb, CRef< CBlastInput > user_input, int &th_count, CSemaphore &batct_notify, bool &any_started)
Definition: igblastn.hpp:67
CFastMutex & thm_Mutex_Notify
Definition: igblastn.hpp:106
CRef< CIgBlastnAppArgs > thm_CmdLineArgs
Definition: igblastn.hpp:103
size_t m_worker_thread_num
Definition: igblastn.hpp:234
CRef< CIgBlastnAppArgs > m_CmdLineArgs
Definition: igblastn.hpp:211
CBlastUsageReport m_UsageReport
Definition: igblastn.hpp:236
void Run_Formatter_Threads(void)
CFastMutex m_Mutex_Notify
Definition: igblastn.hpp:217
CFastMutex m_Mutex_Output
Definition: igblastn.hpp:216
CRef< CBlastInput > m_input
Definition: igblastn.hpp:222
CFastMutex m_Mutex_Input
Definition: igblastn.hpp:215
CFastMutex m_Mutex_Global
Definition: igblastn.hpp:218
int m_run_thread_count
Definition: igblastn.hpp:223
IG_ResultsMap m_all_results
Definition: igblastn.hpp:219
void Init_Formatter_Thread(void)
vector< CRef< CIgWorker > > m_workers
Definition: igblastn.hpp:232
virtual void Init()
@inheritDoc
void Init_Worker_Threads(int thread_num)
CRef< CIgBlastArgs > m_ig_args
Definition: igblastn.hpp:221
virtual int Run()
@inheritDoc
std::map< int, CRef< CIgBlastContext > > IG_ResultsMap
Definition: igblastn.hpp:50
int m_total_input
Definition: igblastn.hpp:227
CRef< CIgFormatter > m_formatter
Definition: igblastn.hpp:233
CRef< CLocalDbAdapter > m_blastdb
Definition: igblastn.hpp:212
CRef< CLocalDbAdapter > m_blastdb_full
Definition: igblastn.hpp:209
void Join_Worker_Threads(void)
void Run_Worker_Threads(bool is_detached)
CRef< CBlastOptionsHandle > m_opts_hndl
Definition: igblastn.hpp:213
unsigned int x_CountUserBatches(CBlastInputSourceConfig &iconfig, int batch_size=10000)
CloneInfo m_Clone
Definition: igblastn.hpp:225
CRef< CIgBlastOptions > m_ig_opts
Definition: igblastn.hpp:231
CSemaphore m_new_batch_done
Definition: igblastn.hpp:224
CRef< CSraInputSource > m_sra_src
Definition: igblastn.hpp:235
CRef< CQueryOptionsArgs > m_query_opts
Definition: igblastn.hpp:230
bool m_global_done
Definition: igblastn.hpp:226
CRef< CBlastFastaInputSource > m_fasta
This application's command line args.
Definition: igblastn.hpp:208
CIgBlastnApp()
@inheritDoc
Definition: igblastn.hpp:184
bool m_any_started
Definition: igblastn.hpp:228
CObject –.
Definition: ncbiobj.hpp:180
CSemaphore –.
Definition: ncbimtx.hpp:1375
CStopWatch –.
Definition: ncbitime.hpp:1938
void SetFullVersion(CRef< CVersionAPI > version)
Set version data for the program.
Definition: ncbiapp.cpp:1174
#define CVersion
static int version
Definition: mdb_load.c:29
Modified on Wed Apr 17 13:09:49 2024 by modify_doxy.py rev. 669887