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

Go to the SVN repository for this file.

1 /* $Id: blast_databases.cpp 47250 2022-11-23 00:45:12Z evgeniev $
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: Roman Katargin
27  */
28 
29 
30 #include <ncbi_pch.hpp>
31 
32 #include <set>
33 #include <corelib/ncbifile.hpp>
34 
36 
40 
42 
46 
49 
51 
53 {
54  CMutexGuard LOCK(s_Mutex);
55  static CRef<CBLASTDatabases> instance;
56  if (!instance)
57  instance.Reset(new CBLASTDatabases());
58  return *instance;
59 }
60 
62  : m_JobId(CAppJobDispatcher::eInvalidJobID)
63  , m_State(eInitial)
64 {
65 }
66 
68 {
69  if (m_State != eLoaded) {
70  static TDbMap dummy;
71  return dummy;
72  }
74  return nuc ? m_NucDbMap : m_ProtDbMap;
75 }
76 
77 const vector<string>& CBLASTDatabases::GetDefaultMRU_DBs(bool nuc_db)
78 {
79  if (m_State != eLoaded) {
80  static vector<string> dummy;
81  return dummy;
82  }
83  x_UpdateDbMap(nuc_db);
84  return nuc_db ? m_Nuc_DefMRU_DBs : m_Prot_DefMRU_DBs;
85 }
86 
87 static const char* kBlastDbDataMD5 = "blast_dbs.md5";
88 static const char* kBlastDbDataNucl = "blast_dbs.nucl";
89 static const char* kBlastDbDataProt = "blast_dbs.prot";
91 
93 {
94  TDbMap& db = nuc ? m_NucDbMap : m_ProtDbMap;
95 
96  if (db.empty()) {
97  if (nuc)
98  m_NucDbMap.reserve(200000);
99 
101 
102  CNcbiIfstream is(path.c_str(), ios::in | ios::binary);
104  string str_line;
105  while (!istr.eof()) {
106  str_line.clear();
107  NcbiGetlineEOL(istr, str_line);
109  if (str_line.empty())
110  continue;
111  string db_name, db_string;
112  if (NStr::SplitInTwo(str_line, "\t", db_name, db_string)) {
113  db.insert(TDbMap::value_type(db_name, db_string));
114 
115  // if db_string == "nr" or "nt" populate default mru values
116  if (db_string.size() > 1 && db_string[0] == 'n' && (db_string[1] == 't' || db_string[1] == 'r')) {
117  vector<string>& mru_dbs = nuc ? m_Nuc_DefMRU_DBs : m_Prot_DefMRU_DBs;
118  mru_dbs.push_back(db_name);
119  }
120  }
121  }
122  }
123 }
124 
128 
129 void CBLASTDatabases::x_OnJobNotification(CEvent* evt)
130 {
131  CAppJobNotification* notn = dynamic_cast<CAppJobNotification*>(evt);
132  _ASSERT(notn);
133  if (notn->GetJobID() != m_JobId) return;
134 
135  switch (notn->GetState()) {
136  case IAppJob::eCompleted:
137  m_State = eLoaded;
138  break;
139  case IAppJob::eCanceled:
140  case IAppJob::eFailed:
141  m_State = eFailed;
142  break;
143  default:
144  return;
145  }
146 
148 }
149 
150 namespace {
151 
152 class CNetBlastLoadDBListJob : public CJobCancelable
153 {
154 public:
155  CNetBlastLoadDBListJob(const string& dir, const string& dbtree);
156  ~CNetBlastLoadDBListJob() {}
157 
158  typedef unordered_map<string, string> TDbMap;
159 
160  /// @name IAppJob implementation
161  /// @{
162  virtual EJobState Run();
164  virtual CRef<CObject> GetResult();
166  virtual string GetDescr() const;
167  /// @}
168 
169 private:
170  void x_CategorizeDBs(CRef<CBlast4_get_databases_ex_reply>& dbs);
171  void x_AddCategorizedDBs(CRef<objects::CBlast4_get_databases_ex_reply>& dbs, set<string>& categorized_dbs);
172  void x_SaveBlastDataBases(const string& md5);
173 
174  TDbMap m_NucDbMap;
175  TDbMap m_ProtDbMap;
176 
177  string m_Dir;
178  string m_DBTreePath;
179 
180  CRef<CAppJobError> m_Error;
181 };
182 
183 } // namespace
184 
185 void CBLASTDatabases::Load(const char* path, const char* dbtree)
186 {
187  if (m_State == eLoaded)
188  return;
189 
191  return;
192 
193  m_State = eLoading;
194 
195  m_Path = path;
196 
197  try {
198  CRef<CNetBlastLoadDBListJob> job(new CNetBlastLoadDBListJob(path, dbtree));
199  m_JobId = CAppJobDispatcher::GetInstance().StartJob(*job, "ThreadPool", *this);
200 
201  } catch (const CException& e) {
202  ERR_POST("CBLASTDatabases::Load() - Failed to start BLAST DBs loading job");
203  e.ReportAll();
204  m_State = eFailed;
205  }
206 }
207 
208 ///
209 /// CNetBlastLoadDBListJob
210 ///
211 
212 CNetBlastLoadDBListJob::CNetBlastLoadDBListJob(const string& dir, const string& dbtree)
213  : m_Dir(dir), m_DBTreePath(dbtree)
214 {
215 }
216 
217 CConstIRef<IAppJobProgress> CNetBlastLoadDBListJob::GetProgress()
218 {
220 }
221 
222 CRef<CObject> CNetBlastLoadDBListJob::GetResult()
223 {
224  return CRef<CObject>();
225 }
226 
227 CConstIRef<IAppJobError> CNetBlastLoadDBListJob::GetError()
228 {
229  return CConstIRef<IAppJobError>(m_Error.GetPointer());
230 }
231 
232 string CNetBlastLoadDBListJob::GetDescr() const
233 {
234  return "Load BLAST DB list job";
235 }
236 
237 static void s_GetBlastDbMd5(CBlast4Client& client, string& md5)
238 {
239  md5.clear();
240  CRef<CBlast4_get_protocol_info_reply> protocol_info_reply;
241  // get md5 digest
243  // ask for md5 digest for an extended BLAST DB list
244  ex_md5_req->Add(string("REQUEST"), string("INFO/BLAST-DBS-EX-MD5DIGEST") );
245  protocol_info_reply = client.AskGet_protocol_info( *ex_md5_req );
246  // get data from reply ( check -v flag to see all retirned data )
247  CRef< CBlast4_parameter > md5_param = protocol_info_reply->GetParamByName("MD5DIGEST");
248  if (!md5_param.Empty() && md5_param->GetValue().IsString())
249  md5 = md5_param->GetValue().GetString();
250 }
251 
253 {
254  string err_msg, logMsg = "Exception in CNetBlastLoadDBListJob: ";
255 
256  try {
257  CDirEntry dir(m_Dir);
258  if (!dir.IsDir())
259  NCBI_THROW(CException, eUnknown, "Invalid directory: " + m_Dir);
260 
261  string cached_md5;
262  try {
263  string md5path = CDirEntry::ConcatPath(m_Dir, kBlastDbDataMD5);
264  CFile md5file(md5path);
265  if (md5file.Exists()) {
266  CNcbiIfstream istr(md5path.c_str());
267  istr >> cached_md5;
268  }
269  } catch (const CException& e) {
270  LOG_POST(Error << "CNetBlastLoadDBListJob. Failed to load blast databases checksum: " << e.GetMsg());
271  }
272 
274  client.SetTryLimit(2);
275  string md5;
277 
278  if (!cached_md5.empty() && cached_md5 == md5) {
279  CFile nuclFile(CDirEntry::ConcatPath(m_Dir, kBlastDbDataNucl));
280  CFile protFile(CDirEntry::ConcatPath(m_Dir, kBlastDbDataProt));
281  if (nuclFile.Exists() && protFile.Exists())
282  return eCompleted;
283  }
284 
286  CRef<CBlast4_get_databases_ex_reply> dbs = client.AskGet_databases_ex(*ex_req);
287  if (!dbs)
288  NCBI_THROW(CException, eUnknown, "Failed to read blast databases");
289 
290  x_CategorizeDBs(dbs);
291  if (IsCanceled()) {
292  m_NucDbMap.clear();
293  m_ProtDbMap.clear();
294  return eCanceled;
295  }
296 
297  x_SaveBlastDataBases(md5);
298  m_NucDbMap.clear();
299  m_ProtDbMap.clear();
300  } catch (const CException& e) {
301  err_msg = logMsg + e.GetMsg();
302  } catch (const std::exception& e) {
303  err_msg = logMsg + e.what();
304  }
305 
306  if (IsCanceled())
307  return eCanceled;
308 
309  if (!err_msg.empty()) {
310  LOG_POST(Error << err_msg);
311  m_Error.Reset(new CAppJobError(err_msg));
312  return eFailed;
313  }
314 
315  return eCompleted;
316 }
317 
318 static void s_SaveDbMap(const string& path, const CNetBlastLoadDBListJob::TDbMap& dbmap)
319 {
320  CNcbiOfstream ostr(path.c_str(), ios::out | ios::binary);
322  ITERATE(CNetBlastLoadDBListJob::TDbMap, it, dbmap) {
323  string first = it->first, second = it->second;
324  NStr::ReplaceInPlace(first, "\t", "");
325  NStr::ReplaceInPlace(second, "\t", "");
326  os << first << "\t" << second << NcbiEndl;
327  }
328 }
329 
330 void CNetBlastLoadDBListJob::x_SaveBlastDataBases(const string& md5)
331 {
332  if (md5.empty() || m_NucDbMap.empty())
333  return;
334  LOG_POST(Info << "Net BLAST Data Source - saving blast databases...");
335  try {
336  string path = CDirEntry::ConcatPath(m_Dir, kBlastDbDataNucl);
337  s_SaveDbMap(path, m_NucDbMap);
339  s_SaveDbMap(path, m_ProtDbMap);
340  path = CDirEntry::ConcatPath(m_Dir, kBlastDbDataMD5);
341  CNcbiOfstream ostr(path.c_str(), ios::out);
342  ostr << md5;
343  LOG_POST(Info << "Net BLAST Data Source - finished saving blast databases");
344  } catch(CException& e) {
345  LOG_POST(Info << "Net BLAST Data Source - failed to save databases - " << e.GetMsg());
346  }
347 }
348 
349 void s_GetDBTree(const string& file, list<CConstRef<CUser_field> >& fields)
350 {
351  CStopWatch sw;
352  sw.Start();
353 
354  if (CFile(file).Exists()) {
355  try {
356  CRef<CUser_field> field(new CUser_field());
357  CNcbiIfstream istr(file.c_str());
358  istr >> MSerial_AsnText >> *field;
359 
360  /// flatten the hierarchy a bit - this is a triple-nested item
361  ITERATE (CUser_field::TData::TFields, outer_it, field->GetData().GetFields()) {
362  ITERATE (CUser_field::TData::TFields, inner_it, (*outer_it)->GetData().GetFields()) {
363  ITERATE (CUser_field::TData::TFields, it, (*inner_it)->GetData().GetFields()) {
364  fields.push_back(*it);
365  }
366  }
367  }
368  }
369  catch (CException& e) {
370  // TODO error reporting
371  LOG_POST(Error << "Error while loading blast-db-tree.asn: " << e.GetMsg());
372  }
373  }
374  LOG_POST(Info << "CNetBlastLoadDBListJob.s_GetDBTree()" << ": " << sw.Elapsed() << " seconds");
375 }
376 
377 void CNetBlastLoadDBListJob::x_AddCategorizedDBs(CRef<CBlast4_get_databases_ex_reply>& dbs, set<string>& categorized_dbs)
378 {
379  //CStopWatch sw; sw.Start();
380 
381  list<CConstRef<CUser_field> > fields;
382  s_GetDBTree(m_DBTreePath, fields);
383  if (fields.empty())
384  return;
385 
386 // TDbMap valid_db_names;
387  typedef CBlast4_get_databases_reply::Tdata TDBData;
388  CBlast4_get_databases_reply::Tdata& db_data = dbs->Set();
389 
390  typedef unordered_map<string, pair<bool, string> > TValidDbNames;
391  TValidDbNames valid_db_names(db_data.size());
392 
393  //TDbMap valid_db_names(db_data.size());
394 
395  // iterate by all available Databases
396  NON_CONST_ITERATE (TDBData, it, db_data) {
397  if (IsCanceled()) {
398  return;
399  }
400  const CBlast4_database_info& info = **it;
401  const string& db_name = info.GetDatabase().GetName();
402  // insert DB record into a temporary map
403  valid_db_names.insert(TValidDbNames::value_type(db_name,
404  pair<bool, string>((info.GetDatabase().GetType() == eBlast4_residue_type_protein), info.GetDatabase().GetName())));
405  }
406 
407  string label, db_name, desc;
408 
409  ITERATE (list< CConstRef<CUser_field> >, it, fields) {
410  try {
411  const CUser_field& f = **it;
412  label = f.GetLabel().GetStr();
413  db_name = f.GetField("Db").GetData().GetStr();
414  NStr::ReplaceInPlace(db_name, "//", "/");
415  desc = " ";
416  desc.append(f.GetField("Descr").GetData().GetStr());
417 
418  TValidDbNames::const_iterator dbname_iter = valid_db_names.find(db_name);
419  //TDbMap::const_iterator dbname_iter = valid_db_names.find(db_name);
420  if (dbname_iter == valid_db_names.end()) {
421  // TODO
422 #ifdef _DEBUG
423  //LOG_POST(Info << "Dropping categorized BLAST database: " << db_name << " (" << desc << ")");
424 #endif
425  } else{
426  categorized_dbs.insert(db_name);
427  TDbMap& db = dbname_iter->second.first ? m_ProtDbMap : m_NucDbMap;
428  db.insert(TDbMap::value_type(desc, dbname_iter->second.second));
429  }
430  }
431  catch (CException& e) {
432  //TODO error reporting
433  LOG_POST(Error << "error processing BLAST databases: " << e.GetMsg());
434  }
435  }
436 }
437 
438 static void sPrepareDBDescr(string& db_desc)
439 {
440  /// escape slashes in the description
441  NStr::ReplaceInPlace(db_desc, "/", "\\/");
442 
443  /// strip off external quotes
444  string::size_type pos = db_desc.find_first_not_of("\"'");
445  if (pos != string::npos) {
446  db_desc.erase(0, pos);
447  }
448  pos = db_desc.find_last_not_of("\"'");
449  if (pos != string::npos) {
450  pos += 1;
451  if (pos < db_desc.size()) {
452  db_desc.erase(pos);
453  }
454  }
455 }
456 
457 /// Fills sm_ProtDbMap and sm_NucDbMap maps.
458 /// The keys in the maps represent paths in the DB hierarchy.
459 void CNetBlastLoadDBListJob::x_CategorizeDBs(CRef<CBlast4_get_databases_ex_reply>& dbs)
460 {
461 # ifdef _DEBUG
463 # endif
464 
465 
466 // TDbMap valid_db_names;
467  string name, visible_name;
468  string db_desc, tax_label;
469  string org_name_label = "organism_label";
470  string prop_name;
471 
472  string visual_priority_label = "interface_priority";
473 
474 
475  typedef CBlast4_get_databases_reply::Tdata TDBData;
476  CBlast4_get_databases_reply::Tdata& db_data = dbs->Set();
477  m_NucDbMap.reserve(db_data.size());
478 /*
479  // iterate by all available Databases
480  NON_CONST_ITERATE (TDBData, it, db_data) {
481  if (m_StopRequested.Get()) {
482  return;
483  }
484 
485  const CBlast4_database_info& info = **it;
486  const string& db_name = info.GetDatabase().GetName();
487 
488  // insert DB record into a temporary map
489  valid_db_names.insert(TDbMap::value_type(db_name, *it));
490  }
491 */
492  NON_CONST_ITERATE (TDBData, it, db_data) {
493  if (IsCanceled())
494  return;
495  const CBlast4_database_info& info = **it;
496  const string& db_name = info.GetDatabase().GetName();
497  // 'nr' and 'nt' should never be subcategorized
498  if (!(db_name == "nr" || db_name == "nt"))
499  continue;
500  db_desc = info.GetDescription();
501  sPrepareDBDescr(db_desc);
502  name = db_name;
503  visible_name = db_name;
504  if ( ! db_desc.empty() && db_name.find(db_desc) == string::npos) {
505  name += " (" + db_desc + ")";
506  string db_desc_trimmed(db_desc);
507  visible_name += " (" + db_desc_trimmed + ")";
508  }
509  visible_name = string(" ") + visible_name;
510  bool prot = false;
511  if (db_name == "nr") {
512  prot = (info.GetDatabase().GetType() == eBlast4_residue_type_protein);
513  }
514  TDbMap& db = prot ? m_ProtDbMap : m_NucDbMap;
515  db.insert(TDbMap::value_type(visible_name, (*it)->GetDatabase().GetName()));
516 
517  } // ITERATE
518 
519 
520  // use categorization information to build the final maps
521  set<string> categorized_dbs;
522  x_AddCategorizedDBs(dbs, categorized_dbs);
523  CTaxonCache& tax_cache = CTaxonCache::GetInstance();
524  string s;
525  string db_desc_trimmed;
526 
527  NON_CONST_ITERATE (TDBData, it, db_data) {
528  if (IsCanceled())
529  return;
531  CBlast4_database_info_Base::TTaxid tax_id = info->GetTaxid();
532  if (tax_id == 0) {
533  // TODO: decide what to do with those DBs
534  continue;
535  }
536 
537  const string& db_name = info->GetDatabase().GetName();
538  // 'nr' and 'nt' should never be subcategorized
539  if (db_name == "nr" || db_name == "nt")
540  continue;
541  if (categorized_dbs.find(db_name) != categorized_dbs.end())
542  continue;
543 
544  db_desc = info->GetDescription();
545  sPrepareDBDescr(db_desc);
546  name = db_name;
547  visible_name = db_name;
548  NStr::ReplaceInPlace(visible_name, "GPIPE/", kEmptyStr);
549 
550  if ( ! db_desc.empty() && db_name.find(db_desc) == string::npos) {
551  name.append(" (");
552  name.append(db_desc);
553  name.append(")");
554  db_desc_trimmed = db_desc;
555  visible_name.append(" (");
556  visible_name.append(db_desc_trimmed);
557  visible_name.append(")");
558  }
559  s.clear();
560  tax_label.clear();
561 
562  TDbMap& db = m_NucDbMap;
563  // put human and mouse into top category of interest
564  if (tax_id == 9606 || tax_id == 10090) {
565  s = "A0. ";
566  }
567 
568  // ad-hoc anaysis to understand if taxonomy name is more than two letters, which is frequent
569  // when we dealing with various bacterial strands, so we can put them all under a common name
570  // (in the GUI tree)
571  //
572  vector<string> word_split_vec;
573 
574  // check if response contains tax label
575  //
576  if( (*it)->CanGetExtended() ) {
577  const CBlast4_parameters &ext = (*it)->GetExtended();
578  list< CRef< CBlast4_parameter > >::const_iterator pit = ext.Get().begin();
579  for(; pit != ext.Get().end(); pit++) {
580  prop_name = (*pit)->GetName();
581  if (prop_name == org_name_label) {
582  if( (*pit)->CanGetValue() ){
583  const CBlast4_value &pval = (*pit)->GetValue();
584  if( pval.IsString() )
585  tax_label = pval.GetString();
586  }
587  } else
588  if (prop_name == visual_priority_label) {
589  if( (*pit)->CanGetValue() ){
590  const CBlast4_value &pval = (*pit)->GetValue();
591  if( pval.IsInteger() ) {
592  int vp = pval.GetInteger();
593  if (vp > 0 && s.empty()) {
594  s = "A1. ";
595  //ERR_POST(Info << "GUI rankeddb:" << visible_name);
596  }
597  }
598  }
599  }
600 
601 
602  } // for
603  } // if
604 
605  if( tax_label.empty() ){
606  ERR_POST(Warning << "BLAST database without tax name:" << visible_name);
607  tax_label = tax_cache.GetLabel(tax_id);
608  } else {
609 /*
610 #ifdef _DEBUG
611  // brief diagnostics if strings are at least somewhat similar
612  // (using substring search)
613  // BLAST database names can sometimes be rather different from taxa names...
614  // (sometimes it is legal because of use of synonims)
615  //
616  string tl = tax_cache.GetLabel(tax_id);
617  {{
618  SIZE_TYPE pos = NPOS;
619  if( !tl.empty() ){
620  pos = NStr::Find( tax_label, tl, NStr::eNocase );
621  }
622  if( pos == NPOS ){
623  pos = NStr::Find( tl, tax_label, NStr::eNocase );
624  }
625  if (pos == NPOS) {
626  LOG_POST(Error << "BLAST tax name is different from tax name:" << tax_id << " " << tl << " - " << tax_label);
627  }
628  }}
629 #endif
630 */
631  }
632 
633 
634  NStr::ReplaceInPlace(tax_label, "/", " ");
635  NStr::ReplaceInPlace(tax_label, "//", " ");
636  NStr::ReplaceInPlace(tax_label, "'", "");
637 
638  if (tax_label.empty()) {
639  continue;
640  }
641  NStr::Split(tax_label, " \t", word_split_vec, NStr::fSplit_Tokenize);
642  if (word_split_vec.size() > 2) {
643  s.append(word_split_vec[0]);
644  s.append(" ");
645  s.append(word_split_vec[1]);
646  s.append(" /");
647  }
648 
649  s.append(tax_label);
650 
651  s.append("( taxid: ");
652  s.append(NStr::IntToString(tax_id));
653  s.append(" ) /");
654  s.append(visible_name);
655 
656  //ERR_POST(Info << s);
657 
658  if (IsCanceled()) {
659  return;
660  }
661 
662  db.insert(TDbMap::value_type(s, (*it)->GetDatabase().GetName()));
663 
664  }
665 
666  //NON_CONST_ITERATE (TDbMap, it, valid_db_names) {
667  // it->second.Reset();
668  //}
669 
670 // valid_db_names.clear();
671 # ifdef _DEBUG
672  watch.Stop();
673  ERR_POST(Info << "x_CategorizeBD() takes " << watch.AsSmartString() );
674 # endif
675 
676 }
677 
static CBioSource dummy
USING_SCOPE(objects)
DEFINE_STATIC_MUTEX(s_Mutex)
void s_GetDBTree(const string &file, list< CConstRef< CUser_field > > &fields)
static const char * kBlastDbDataProt
static void s_SaveDbMap(const string &path, const CNetBlastLoadDBListJob::TDbMap &dbmap)
static void s_GetBlastDbMd5(CBlast4Client &client, string &md5)
static const CCompressStream::EMethod kDbDataCompressMethod
static const char * kBlastDbDataNucl
static const char * kBlastDbDataMD5
static void sPrepareDBDescr(string &db_desc)
User-defined methods of the data storage class.
CAppJobDispatcher.
CAppJobError Default implementation for IAppJobError - encapsulates a text error message.
CAppJobNotification Notification send by CAppJobEventTranslator.
void x_UpdateDbMap(bool nuc)
void x_OnJobNotification(CEvent *evt)
static CBLASTDatabases & GetInstance()
vector< string > m_Prot_DefMRU_DBs
const TDbMap & GetDbMap(bool nuc)
void Load(const char *path, const char *dbtree)
vector< string > m_Nuc_DefMRU_DBs
const vector< string > & GetDefaultMRU_DBs(bool nuc_db)
std::unordered_map< string, string > TDbMap
CBlast4Client –.
Definition: blastclient.hpp:66
CBlast4_database_info –.
CBlast4_get_databases_ex_request –.
CBlast4_get_protocol_info_request –.
CBlast4_value –.
CCompressOStream –.
CDecompressIStream –.
CDirEntry –.
Definition: ncbifile.hpp:262
CEventHandler.
CEvent - generic event implementation TODO TODO - Attachments.
Definition: event.hpp:86
CFile –.
Definition: ncbifile.hpp:1604
Base class to build jobs with cancel functionality.
CRef –.
Definition: ncbiobj.hpp:618
CStopWatch –.
Definition: ncbitime.hpp:1938
static CTaxonCache & GetInstance()
string GetLabel(int tax_id)
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
const_iterator find(const key_type &key) const
Definition: set.hpp:137
const_iterator end() const
Definition: set.hpp:136
#define md5
Definition: compat-1.3.h:2022
constexpr auto end(const ct_const_array< T, N > &in) noexcept
std::ofstream out("events_result.xml")
main entry point for tests
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
Definition: dlist.tmpl.h:46
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
string
Definition: cgiapp.hpp:687
EMethod
Compression/decompression methods.
Definition: stream_util.hpp:98
@ eLZO
LZO (LZO1X)
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
Definition: ncbidiag.hpp:186
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
Definition: ncbidiag.hpp:226
void Error(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1197
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
const string & GetMsg(void) const
Get message string.
Definition: ncbiexpt.cpp:461
void Warning(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1191
string ReportAll(TDiagPostFlags flags=eDPF_Exception) const
Report all exceptions.
Definition: ncbiexpt.cpp:370
void Info(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1185
static string ConcatPath(const string &first, const string &second)
Concatenate two parts of the path for the current OS.
Definition: ncbifile.cpp:776
virtual CConstIRef< IAppJobProgress > GetProgress()=0
return progress object, the function shall be synchronized internally.
static CAppJobDispatcher & GetInstance()
virtual CConstIRef< IAppJobError > GetError()=0
Returns IAppJobError object describing internal error that caused the Job to fail.
virtual CRef< CObject > GetResult()=0
Returns the Job Result.
EJobState
Job states (describe FSM)
Definition: app_job.hpp:86
TJobID StartJob(IAppJob &job, const string &engine_name, IEngineParams *params=NULL)
Starts a Job on the specified engine in "passive mode" - no notifications or progress reports will be...
virtual string GetDescr() const =0
Returns a human readable description of the Job (optional)
#define ON_EVENT(type, id, handler)
virtual EJobState Run()=0
Function that does all the useful work, called by the Engine.
#define END_EVENT_MAP()
Ends definition of Command Map.
#define BEGIN_EVENT_MAP(thisClass, baseClass)
Begins definition of Command Map for CEventHandler-derived class.
TJobState GetState() const
@ eUnknown
Definition: app_popup.hpp:72
@ eCanceled
Definition: app_job.hpp:91
@ eCompleted
Definition: app_job.hpp:89
@ eFailed
Definition: app_job.hpp:90
#define MSerial_AsnText
I/O stream manipulators –.
Definition: serialbase.hpp:696
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
bool Empty(void) const THROWS_NONE
Check if CRef is empty – not pointing to any object, which means having a null value.
Definition: ncbiobj.hpp:719
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NcbiEndl
Definition: ncbistre.hpp:548
CNcbiIstream & NcbiGetlineEOL(CNcbiIstream &is, string &str, string::size_type *count=NULL)
Read from "is" to "str" the next line (taking into account platform specifics of End-of-Line)
IO_PREFIX::ofstream CNcbiOfstream
Portable alias for ofstream.
Definition: ncbistre.hpp:500
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
Definition: ncbistre.hpp:439
#define kEmptyStr
Definition: ncbistr.hpp:123
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
Definition: ncbistr.cpp:3461
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string (in-place)
Definition: ncbistr.cpp:3201
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5084
static bool SplitInTwo(const CTempString str, const CTempString delim, string &str1, string &str2, TSplitFlags flags=0)
Split a string into two pieces using the specified delimiters.
Definition: ncbistr.cpp:3554
static string & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
Definition: ncbistr.cpp:3405
@ fSplit_Tokenize
All delimiters are merged and trimmed, to get non-empty tokens only.
Definition: ncbistr.hpp:2508
@ eTrunc_End
Truncate trailing spaces only.
Definition: ncbistr.hpp:2241
void Run(void)
Enter the main loop.
double Elapsed(void) const
Return time elapsed since first Start() or last Restart() call (in seconds).
Definition: ncbitime.hpp:2776
void Start(void)
Start the timer.
Definition: ncbitime.hpp:2765
@ eStart
Start timer immediately after creating.
Definition: ncbitime.hpp:1942
static const char label[]
bool IsInteger(void) const
Check if variant Integer is selected.
TInteger GetInteger(void) const
Get the variant data.
const Tdata & Get(void) const
Get the member data.
const TString & GetString(void) const
Get the variant data.
list< CRef< CBlast4_database_info > > Tdata
bool IsString(void) const
Check if variant String is selected.
@ eBlast4_residue_type_protein
const TData & GetData(void) const
Get the Data member data.
const TFields & GetFields(void) const
Get the variant data.
vector< CRef< CUser_field > > TFields
static CStopWatch sw
FILE * file
static MDB_envinfo info
Definition: mdb_load.c:37
double value_type
The numeric datatype used by the parser.
Definition: muParserDef.h:228
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
std::istream & in(std::istream &in_, double &x_)
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
@ eCanceled
Request canceled.
Declares the CRemoteBlast class.
static CNamedPipeClient * client
C++ I/O stream wrappers to compress/decompress data on-the-fly.
#define _ASSERT
Modified on Sun Apr 14 05:26:15 2024 by modify_doxy.py rev. 669887