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

Go to the SVN repository for this file.

1 /* $Id: gbnative.cpp 102228 2024-04-09 17:35:06Z vasilche $
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: Michael Kimelman, Eugene Vasilchenko
27 *
28 * File Description: GenBank Data loader
29 *
30 */
31 
32 #include <ncbi_pch.hpp>
33 #include <corelib/ncbi_param.hpp>
39 
42 
43 // TODO: remove the following includes
44 #define REGISTER_READER_ENTRY_POINTS 1
45 #ifdef REGISTER_READER_ENTRY_POINTS
47 #endif
48 
50 #include <objtools/error_codes.hpp>
51 
53 
54 #include <objmgr/impl/tse_info.hpp>
60 
62 
63 #include <corelib/ncbithr.hpp>
64 #include <corelib/ncbiapp.hpp>
65 
68 
69 #include <algorithm>
70 
71 
72 #define NCBI_USE_ERRCODE_X Objtools_GBLoader
73 
76 
77 //=======================================================================
78 // GBLoader sub classes
79 //
80 
81 //=======================================================================
82 // GBLoader Public interface
83 //
84 
85 
86 NCBI_PARAM_DECL(string, GENBANK, READER_NAME);
87 NCBI_PARAM_DEF_EX(string, GENBANK, READER_NAME, "",
88  eParam_NoThread, GENBANK_READER_NAME);
89 typedef NCBI_PARAM_TYPE(GENBANK, READER_NAME) TGenbankReaderName;
90 
91 NCBI_PARAM_DECL(string, GENBANK, WRITER_NAME);
92 NCBI_PARAM_DEF_EX(string, GENBANK, WRITER_NAME, "",
93  eParam_NoThread, GENBANK_WRITER_NAME);
94 typedef NCBI_PARAM_TYPE(GENBANK, WRITER_NAME) TGenbankWriterName;
95 
96 #if defined(HAVE_PUBSEQ_OS)
97 static const char* const DEFAULT_DRV_ORDER = "id2:pubseqos";
98 #else
99 static const char* const DEFAULT_DRV_ORDER = "id2";
100 #endif
101 static const char* const DEFAULT_HUP_DRV_ORDER = "pubseqos2:pubseqos";
102 
103 #define GBLOADER_NAME "GBLOADER"
104 #define GBLOADER_HUP_NAME "GBLOADER-HUP"
105 
106 #define DEFAULT_ID_GC_SIZE 10000
107 #define DEFAULT_ID_EXPIRATION_TIMEOUT 2*3600 // 2 hours
108 
110 {
112 public:
114  const CSeq_id_Handle& requested_id);
116 
118  {
119  return *m_Loader;
120  }
121  virtual CGBDataLoader_Native* GetLoaderPtr(void) override;
122 
123  //virtual TConn GetConn(void);
124  //virtual void ReleaseConn(void);
125  virtual CTSE_LoadLock GetTSE_LoadLock(const TKeyBlob& blob_id) override;
126  virtual CTSE_LoadLock GetTSE_LoadLockIfLoaded(const TKeyBlob& blob_id) override;
127  virtual void GetLoadedBlob_ids(const CSeq_id_Handle& idh,
128  TLoadedBlob_ids& blob_ids) const override;
129 
130  virtual operator CInitMutexPool&(void) override { return GetMutexPool(); }
131 
133 
135 
136  virtual bool GetAddWGSMasterDescr(void) const override;
137 
138  virtual EGBErrorAction GetPTISErrorAction(void) const override;
139 
140  friend class CGBDataLoader_Native;
141 
142 private:
144 };
145 
146 
149  const CGBLoaderParams& params,
150  CObjectManager::EIsDefault is_default,
151  CObjectManager::TPriority priority)
152 {
154  CDataLoader::RegisterInObjectManager(om, maker, is_default, priority);
155  return maker.GetRegisterInfo();
156 }
157 
158 
160  const CGBLoaderParams& params)
161  : CGBDataLoader(loader_name, params)
162 {
163  GBLOG_POST_X(1, "CGBDataLoader_Native");
164  x_CreateDriver(params);
165 }
166 
167 
169 {
170  GBLOG_POST_X(2, "~CGBDataLoader_Native");
171  CloseCache();
172 }
173 
174 
177 {
178  return dynamic_cast<const CBlob_id&>(*blob_id);
179 }
180 
181 
183 {
184  unique_ptr<TParamTree> app_params;
185  const TParamTree* gb_params = 0;
186  if ( params.GetParamTree() ) {
187  gb_params = GetLoaderParams(params.GetParamTree());
188  }
189  else {
191  if ( app ) {
192  app_params.reset(CConfig::ConvertRegToTree(app->GetConfig()));
193  gb_params = GetLoaderParams(app_params.get());
194  }
195  }
196 
197  size_t queue_size = DEFAULT_ID_GC_SIZE;
198  if ( gb_params ) {
199  try {
200  string param = GetParam(gb_params, NCBI_GBLOADER_PARAM_ID_GC_SIZE);
201  if ( !param.empty() ) {
202  queue_size = NStr::StringToUInt(param);
203  }
204  }
205  catch ( CException& /*ignored*/ ) {
206  }
207  }
208 
210  if ( gb_params ) {
211  string param =
213  if ( !param.empty() ) {
214  try {
215  Uint4 timeout = NStr::StringToNumeric<Uint4>(param);
216  if ( timeout > 0 ) {
217  m_IdExpirationTimeout = timeout;
218  }
219  }
220  catch ( CException& exc ) {
221  NCBI_RETHROW_FMT(exc, CLoaderException, eBadConfig,
222  "Bad value of parameter "
224  ": \""<<param<<"\"");
225  }
226  }
227  }
228  m_AlwaysLoadExternal = false;
229  if ( gb_params ) {
230  string param =
232  if ( !param.empty() ) {
233  try {
235  }
236  catch ( CException& exc ) {
237  NCBI_RETHROW_FMT(exc, CLoaderException, eBadConfig,
238  "Bad value of parameter "
240  ": \""<<param<<"\"");
241  }
242  }
243  }
244  m_AlwaysLoadNamedAcc = true;
245  if ( gb_params ) {
246  string param =
248  if ( !param.empty() ) {
249  try {
251  }
252  catch ( CException& exc ) {
253  NCBI_RETHROW_FMT(exc, CLoaderException, eBadConfig,
254  "Bad value of parameter "
256  ": \""<<param<<"\"");
257  }
258  }
259  }
260  m_AddWGSMasterDescr = true;
261  if ( gb_params ) {
262  string param =
264  if ( !param.empty() ) {
265  try {
267  }
268  catch ( CException& exc ) {
269  NCBI_RETHROW_FMT(exc, CLoaderException, eBadConfig,
270  "Bad value of parameter "
272  ": \""<<param<<"\"");
273  }
274  }
275  }
277  if ( gb_params ) {
278  string param =
280  if ( !param.empty() ) {
283  }
286  }
289  }
290  else {
291  NCBI_THROW_FMT(CLoaderException, eBadConfig,
292  "Bad value of parameter "
294  ": \""<<param<<"\"");
295  }
296  }
297  }
298 
300  m_InfoManager = new CGBInfoManager(queue_size);
301 
302  // now we create readers & writers
303  if ( params.GetReaderPtr() ) {
304  // explicit reader specified
305  CRef<CReader> reader(params.GetReaderPtr());
306  reader->OpenInitialConnection(false);
307  m_Dispatcher->InsertReader(1, reader);
308  return;
309  }
310 
312  params.GetPreopenConnection();
313  if ( preopen == CGBLoaderParams::ePreopenByConfig && gb_params ) {
314  try {
315  string param = GetParam(gb_params, NCBI_GBLOADER_PARAM_PREOPEN);
316  if ( !param.empty() ) {
317  if ( NStr::StringToBool(param) )
319  else
321  }
322  }
323  catch ( CException& /*ignored*/ ) {
324  }
325  }
326 
327  if ( !gb_params ) {
328  app_params.reset(new TParamTree);
329  gb_params = GetLoaderParams(app_params.get());
330  }
331 
332  if ( !params.GetReaderName().empty() ) {
333  string reader_name = params.GetReaderName();
334  NStr::ToLower(reader_name);
335  if ( NStr::StartsWith(reader_name, "pubseqos") )
336  m_WebCookie = params.GetWebCookie();
337 
338  if ( x_CreateReaders(reader_name, gb_params, params, preopen) ) {
339  if ( reader_name == "cache" ||
340  NStr::StartsWith(reader_name, "cache;") ) {
341  x_CreateWriters("cache", gb_params);
342  }
343  }
344  }
345  else {
346  pair<string, string> rw_name = GetReaderWriterName(gb_params, params);
347  if ( x_CreateReaders(rw_name.first, gb_params, params, preopen) ) {
348  x_CreateWriters(rw_name.second, gb_params);
349  }
350  }
351 }
352 
353 
354 pair<string, string>
355 CGBDataLoader_Native::GetReaderWriterName(const TParamTree* params, const CGBLoaderParams& loader_params) const
356 {
357  pair<string, string> ret;
358  if ( HasHUPIncluded() ) {
359  // use default HUP readers
360  ret.first = DEFAULT_HUP_DRV_ORDER;
361  return ret;
362  }
363  ret.first = GetParam(params, NCBI_GBLOADER_PARAM_READER_NAME);
364  if ( ret.first.empty() ) {
365  ret.first = TGenbankReaderName::GetDefault();
366  }
367  ret.second = loader_params.GetWriterName();
368  if (ret.second.empty()) {
369  ret.second = GetParam(params, NCBI_GBLOADER_PARAM_WRITER_NAME);
370  }
371  if ( ret.second.empty() ) {
372  ret.second = TGenbankWriterName::GetDefault();
373  }
374  if ( ret.first.empty() || ret.second.empty() ) {
375  string method = loader_params.GetLoaderMethod();
376  if ( method.empty() ) {
377  method = x_GetLoaderMethod(params);
378  }
379  if ( method.empty() ) {
380  // fall back default reader list
381  method = DEFAULT_DRV_ORDER;
382  }
383  NStr::ToLower(method);
384  if ( ret.first.empty() ) {
385  ret.first = method;
386  }
387  if ( ret.second.empty() && NStr::StartsWith(method, "cache;") ) {
388  ret.second = "cache";
389  }
390  }
391  NStr::ToLower(ret.first);
392  NStr::ToLower(ret.second);
393  return ret;
394 }
395 
396 
398  const TParamTree* params,
399  const CGBLoaderParams& gb_params,
401 {
402  vector<string> str_list;
403  NStr::Split(str, ";", str_list);
404  size_t reader_count = 0;
405  for ( size_t i = 0; i < str_list.size(); ++i ) {
406  CRef<CReader> reader(x_CreateReader(str_list[i], gb_params, params));
407  if( reader ) {
408  if ( HasHUPIncluded() ) {
409  reader->SetIncludeHUP(true, m_WebCookie);
410  }
411  if ( preopen != CGBLoaderParams::ePreopenNever ) {
413  }
414  m_Dispatcher->InsertReader(i, reader);
415  ++reader_count;
416  }
417  }
418  if ( !reader_count ) {
419  NCBI_THROW(CLoaderException, eLoaderFailed,
420  "no reader available from "+str);
421  }
422  return reader_count > 1 || str_list.size() > 1;
423 }
424 
425 
427  const TParamTree* params)
428 {
429  vector<string> str_list;
430  NStr::Split(str, ";", str_list);
431  for ( size_t i = 0; i < str_list.size(); ++i ) {
433  NCBI_THROW(CObjMgrException, eRegisterError,
434  "HUP GBLoader cannot have cache");
435  }
436  CRef<CWriter> writer(x_CreateWriter(str_list[i], params));
437  if( writer ) {
438  m_Dispatcher->InsertWriter(i, writer);
439  }
440  }
441 }
442 
443 
444 #ifdef REGISTER_READER_ENTRY_POINTS
445 NCBI_PARAM_DECL(bool, GENBANK, REGISTER_READERS);
446 NCBI_PARAM_DEF_EX(bool, GENBANK, REGISTER_READERS, true,
447  eParam_NoThread, GENBANK_REGISTER_READERS);
448 #endif
449 
451 {
453  _ASSERT(manager);
454 
455 #ifdef REGISTER_READER_ENTRY_POINTS
456  if ( NCBI_PARAM_TYPE(GENBANK, REGISTER_READERS)::GetDefault() ) {
460 # ifdef HAVE_PUBSEQ_OS
461  //GenBankReaders_Register_Pubseq();
462 # endif
463  }
464 #endif
465 
466  return manager;
467 }
468 
469 
471 {
473  _ASSERT(manager);
474 
475 #ifdef REGISTER_READER_ENTRY_POINTS
476  if ( NCBI_PARAM_TYPE(GENBANK, REGISTER_READERS)::GetDefault() ) {
478  }
479 #endif
480 
481  return manager;
482 }
483 
484 
485 static bool s_ForceDriver(const string& name)
486 {
487  return !name.empty() && name[name.size()-1] != ':';
488 }
489 
490 
492  const CGBLoaderParams& gb_params,
493  const TParamTree* params)
494 {
496  CReader* ret = manager->CreateInstanceFromList(params, name);
497  if ( !ret ) {
498  if ( s_ForceDriver(name) ) {
499  // reader is required at this slot
500  NCBI_THROW(CLoaderException, eLoaderFailed,
501  "no reader available from "+name);
502  }
503  }
504  else {
505  CReaderParams reader_params;
506  reader_params.SetEnableWGS(gb_params.m_EnableWGS);
507  reader_params.SetEnableSNP(gb_params.m_EnableSNP);
508  reader_params.SetEnableCDD(gb_params.m_EnableCDD);
509  ret->SetParams(reader_params);
510  ret->InitializeCache(m_CacheManager, params);
511  }
512  return ret;
513 }
514 
515 
517  const TParamTree* params)
518 {
520  CWriter* ret = manager->CreateInstanceFromList(params, name);
521  if ( !ret ) {
522  if ( s_ForceDriver(name) ) {
523  // writer is required at this slot
524  NCBI_THROW(CLoaderException, eLoaderFailed,
525  "no writer available from "+name);
526  }
527  }
528  else {
529  ret->InitializeCache(m_CacheManager, params);
530  }
531  return ret;
532 }
533 
534 
536 {
537  if ( CReadDispatcher::CannotProcess(sih) ) {
538  return TBlobId();
539  }
540  CGBReaderRequestResult result(this, sih);
541  CLoadLockBlobIds blobs(result, sih, 0);
543  CFixedBlob_ids blob_ids = blobs.GetBlob_ids();
544  ITERATE ( CFixedBlob_ids, it, blob_ids ) {
545  if ( it->Matches(fBlobHasCore, 0) ) {
546  return TBlobId(it->GetBlob_id().GetPointer());
547  }
548  }
549  return TBlobId();
550 }
551 
553 {
555 }
556 
557 
559 {
560  if ( CReadDispatcher::CannotProcess(idh) ) {
561  return;
562  }
563  CGBReaderRequestResult result(this, idh);
564  CLoadLockSeqIds lock(result, idh);
565  if ( !lock.IsLoaded() ) {
567  }
568  ids = lock.GetSeq_ids();
569 }
570 
571 
574 {
575  SAccVerFound ret;
576  if ( CReadDispatcher::CannotProcess(idh) ) {
577  // no such sequence
578  return ret;
579  }
580  CGBReaderRequestResult result(this, idh);
581  CLoadLockAcc lock(result, idh);
582  if ( !lock.IsLoadedAccVer() ) {
584  }
585  if ( lock.IsLoadedAccVer() ) {
586  ret = lock.GetAccVer();
587  }
588  return ret;
589 }
590 
591 
594 {
595  SGiFound ret;
596  if ( CReadDispatcher::CannotProcess(idh) ) {
597  return ret;
598  }
599  CGBReaderRequestResult result(this, idh);
600  CLoadLockGi lock(result, idh);
601  if ( !lock.IsLoadedGi() ) {
603  }
604  if ( lock.IsLoadedGi() ) {
605  ret = lock.GetGi();
606  }
607  return ret;
608 }
609 
610 
612 {
613  if ( CReadDispatcher::CannotProcess(idh) ) {
614  return string();
615  }
616  CGBReaderRequestResult result(this, idh);
617  CLoadLockLabel lock(result, idh);
618  if ( !lock.IsLoadedLabel() ) {
620  }
621  return lock.GetLabel();
622 }
623 
624 
626 {
627  if ( CReadDispatcher::CannotProcess(idh) ) {
628  return INVALID_TAX_ID;
629  }
630  CGBReaderRequestResult result(this, idh);
631  CLoadLockTaxId lock(result, idh);
632  if ( !lock.IsLoadedTaxId() ) {
634  }
635  TTaxId taxid = lock.IsLoadedTaxId()? lock.GetTaxId(): INVALID_TAX_ID;
636  if ( taxid == INVALID_TAX_ID ) {
637  return CDataLoader::GetTaxId(idh);
638  }
639  return taxid;
640 }
641 
642 
644 {
645  const int kNotFound = (CBioseq_Handle::fState_not_found |
647 
648  if ( CReadDispatcher::CannotProcess(sih) ) {
649  return kNotFound;
650  }
651  TIds ids(1, sih);
652  TLoaded loaded(1);
653  TSequenceStates states(1);
654  GetSequenceStates(ids, loaded, states);
655  return loaded[0]? states[0]: kNotFound;
656 }
657 
658 
659 void CGBDataLoader_Native::GetBulkIds(const TIds& ids, TLoaded& loaded, TBulkIds& ret)
660 {
661  for ( size_t i = 0; i < ids.size(); ++i ) {
662  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
663  continue;
664  }
665  CGBReaderRequestResult result(this, ids[i]);
666  m_Dispatcher->LoadBulkIds(result, ids, loaded, ret);
667  return;
668  }
669 }
670 
671 
672 void CGBDataLoader_Native::GetAccVers(const TIds& ids, TLoaded& loaded, TIds& ret)
673 {
674  for ( size_t i = 0; i < ids.size(); ++i ) {
675  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
676  continue;
677  }
678  CGBReaderRequestResult result(this, ids[i]);
679  m_Dispatcher->LoadAccVers(result, ids, loaded, ret);
680  return;
681  }
682 }
683 
684 
685 void CGBDataLoader_Native::GetGis(const TIds& ids, TLoaded& loaded, TGis& ret)
686 {
687  for ( size_t i = 0; i < ids.size(); ++i ) {
688  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
689  continue;
690  }
691  CGBReaderRequestResult result(this, ids[i]);
692  m_Dispatcher->LoadGis(result, ids, loaded, ret);
693  return;
694  }
695 }
696 
697 
698 void CGBDataLoader_Native::GetLabels(const TIds& ids, TLoaded& loaded, TLabels& ret)
699 {
700  for ( size_t i = 0; i < ids.size(); ++i ) {
701  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
702  continue;
703  }
704  CGBReaderRequestResult result(this, ids[i]);
705  m_Dispatcher->LoadLabels(result, ids, loaded, ret);
706  return;
707  }
708 }
709 
710 
711 void CGBDataLoader_Native::GetTaxIds(const TIds& ids, TLoaded& loaded, TTaxIds& ret)
712 {
713  for ( size_t i = 0; i < ids.size(); ++i ) {
714  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
715  continue;
716  }
717  CGBReaderRequestResult result(this, ids[i]);
718  m_Dispatcher->LoadTaxIds(result, ids, loaded, ret);
719 
720  // the ID2 may accidentally return no taxid for newly loaded sequences
721  // we have to fall back to full sequence retrieval in such cases
722  bool retry = false;
723  for ( size_t i = 0; i < ids.size(); ++i ) {
724  if ( loaded[i] && ret[i] == INVALID_TAX_ID ) {
725  loaded[i] = false;
726  retry = true;
727  }
728  }
729  if ( retry ) {
730  // full sequence retrieval is implemented in base CDataLoader class
731  CDataLoader::GetTaxIds(ids, loaded, ret);
732  }
733 
734  return;
735  }
736 }
737 
738 
739 static const bool s_LoadBulkBlobs = true;
740 
741 
743 {
744  if ( CReadDispatcher::CannotProcess(sih) ) {
745  return kInvalidSeqPos;
746  }
747  CGBReaderRequestResult result(this, sih);
748  CLoadLockLength lock(result, sih);
749  if ( !lock.IsLoadedLength() ) {
751  }
752  return lock.IsLoaded()? lock.GetLength(): 0;
753 }
754 
755 
757  TSequenceLengths& ret)
758 {
759  for ( size_t i = 0; i < ids.size(); ++i ) {
760  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
761  continue;
762  }
763  CGBReaderRequestResult result(this, ids[i]);
764  m_Dispatcher->LoadLengths(result, ids, loaded, ret);
765  return;
766  }
767 }
768 
769 
772 {
773  STypeFound ret;
774  if ( CReadDispatcher::CannotProcess(sih) ) {
775  return ret;
776  }
777  CGBReaderRequestResult result(this, sih);
778  CLoadLockType lock(result, sih);
779  if ( !lock.IsLoadedType() ) {
781  }
782  if ( lock.IsLoadedType() ) {
783  ret = lock.GetType();
784  }
785  return ret;
786 }
787 
788 
790  TSequenceTypes& ret)
791 {
792  for ( size_t i = 0; i < ids.size(); ++i ) {
793  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
794  continue;
795  }
796  CGBReaderRequestResult result(this, ids[i]);
797  m_Dispatcher->LoadTypes(result, ids, loaded, ret);
798  return;
799  }
800 }
801 
802 
804  TSequenceStates& ret)
805 {
806  if ( !s_LoadBulkBlobs ) {
807  CDataLoader::GetSequenceStates(ids, loaded, ret);
808  return;
809  }
810  for ( size_t i = 0; i < ids.size(); ++i ) {
811  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
812  continue;
813  }
814  CGBReaderRequestResult result(this, ids[i]);
815  m_Dispatcher->LoadStates(result, ids, loaded, ret);
816  return;
817  }
818  /*
819  set<CSeq_id_Handle> load_set;
820  size_t count = ids.size();
821  _ASSERT(ids.size() == loaded.size());
822  _ASSERT(ids.size() == ret.size());
823  CGBReaderRequestResult result(this, ids[0]);
824  for ( size_t i = 0; i < count; ++i ) {
825  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
826  continue;
827  }
828  CLoadLockBlobIds blobs(result, ids[i], 0);
829  if ( blobs.IsLoaded() ) {
830  continue;
831  }
832  // add into loading set
833  load_set.insert(ids[i]);
834  }
835  if ( !load_set.empty() ) {
836  result.SetRequestedId(*load_set.begin());
837  m_Dispatcher->LoadSeq_idsBlob_ids(result, load_set);
838  }
839  // update sequence states
840  for ( size_t i = 0; i < count; ++i ) {
841  CReadDispatcher::SetBlobState(i, result, ids, loaded, ret);
842  }
843  */
844 }
845 
846 
849 {
850  SHashFound ret;
851  if ( CReadDispatcher::CannotProcess(sih) ) {
852  return ret;
853  }
854  CGBReaderRequestResult result(this, sih);
855  CLoadLockHash lock(result, sih);
856  if ( !lock.IsLoadedHash() ) {
858  }
859  if ( lock.IsLoadedHash() ) {
860  ret = lock.GetHash();
861  }
862  return ret;
863 }
864 
865 
867  TSequenceHashes& ret, THashKnown& known)
868 {
869  for ( size_t i = 0; i < ids.size(); ++i ) {
870  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
871  continue;
872  }
873  CGBReaderRequestResult result(this, ids[i]);
874  m_Dispatcher->LoadHashes(result, ids, loaded, ret, known);
875  return;
876  }
877 }
878 
879 
881 {
882  TRealBlobId blob_id = GetRealBlobId(id);
884  CLoadLockBlobVersion lock(result, blob_id);
885  if ( !lock.IsLoadedBlobVersion() ) {
887  }
888  return lock.GetBlobVersion();
889 }
890 
891 
894  const TTSE_LockSet& tse_set)
895 {
896  TTSE_Lock best;
897  bool conflict=false;
898 
899  CGBReaderRequestResult result(this, handle);
900 
901  ITERATE(TTSE_LockSet, sit, tse_set) {
902  const CTSE_Info& tse = **sit;
903  TRealBlobId rbid = GetRealBlobId(tse);
904  CLoadLockBlob blob(result, GetRealBlobId(tse));
905  _ASSERT(blob);
906 
907  /*
908  if ( tse.m_SeqIds.find(handle) == tse->m_SeqIds.end() ) {
909  continue;
910  }
911  */
912 
913  // listed for given TSE
914  if ( !best ) {
915  best = *sit; conflict=false;
916  }
917  else if( !tse.IsDead() && best->IsDead() ) {
918  best = *sit; conflict=false;
919  }
920  else if( tse.IsDead() && best->IsDead() ) {
921  conflict=true;
922  }
923  else if( tse.IsDead() && !best->IsDead() ) {
924  }
925  else {
926  conflict=true;
927  //_ASSERT(tse.IsDead() || best->IsDead());
928  }
929  }
930 
931 /*
932  if ( !best || conflict ) {
933  // try harder
934  best.Reset();
935  conflict=false;
936 
937  CReaderRequestResultBlob_ids blobs = result.GetResultBlob_ids(handle);
938  _ASSERT(blobs);
939 
940  ITERATE ( CLoadInfoBlob_ids, it, *blobs ) {
941  TBlob_InfoMap::iterator tsep =
942  m_Blob_InfoMap.find((*srp)->GetKeyByTSE());
943  if (tsep == m_Blob_InfoMap.end()) continue;
944  ITERATE(TTSE_LockSet, sit, tse_set) {
945  CConstRef<CTSE_Info> ti = *sit;
946  //TTse2TSEinfo::iterator it =
947  // m_Tse2TseInfo.find(&ti->GetSeq_entry());
948  //if(it==m_Tse2TseInfo.end()) continue;
949  CRef<STSEinfo> tinfo = GetTSEinfo(*ti);
950  if ( !tinfo )
951  continue;
952 
953  if(tinfo==tsep->second) {
954  if ( !best )
955  best=ti;
956  else if (ti != best)
957  conflict=true;
958  }
959  }
960  }
961  if(conflict)
962  best.Reset();
963  }
964 */
965  if ( !best || conflict ) {
966  _TRACE("CGBDataLoader::ResolveConflict("<<handle.AsString()<<"): "
967  "conflict");
968  }
969  return best;
970 }
971 
972 
974 {
976  if ((it->m_Type & cache_type) != 0) {
977  return true;
978  }
979  }
980  return false;
981 }
982 
983 
985  time_t access_timeout)
986 {
988  if ((it->m_Type & cache_type) != 0) {
989  it->m_Cache->Purge(access_timeout);
990  }
991  }
992 }
993 
994 
996 {
997  // Reset cache for each reader/writer
999  m_CacheManager.GetCaches().clear();
1000 }
1001 
1002 
1003 //=======================================================================
1004 // GBLoader private interface
1005 //
1007 {
1008 }
1009 
1010 
1012 {
1013  switch(choice) {
1016  // whole bioseq
1017  return fBlobHasAllLocal;
1020  // everything except bioseqs & annotations
1021  return fBlobHasCore;
1023  // seq data
1026  // SeqFeatures
1027  return fBlobHasIntFeat;
1029  // SeqGraph
1030  return fBlobHasIntGraph;
1032  // SeqGraph
1033  return fBlobHasIntAlign;
1035  // all internal annotations
1036  return fBlobHasIntAnnot;
1044  // external annotations
1047  // orphan annotations
1048  return fBlobHasOrphanAnnot;
1050  // everything
1051  return fBlobHasAll;
1052  default:
1053  return 0;
1054  }
1055 }
1056 
1057 
1060 {
1061  TBlobContentsMask mask = 0;
1062  if ( details.m_NeedSeqMap.NotEmpty() ) {
1063  mask |= fBlobHasSeqMap;
1064  }
1065  if ( details.m_NeedSeqData.NotEmpty() ) {
1066  mask |= fBlobHasSeqData;
1067  }
1069  TBlobContentsMask annots = 0;
1070  switch ( DetailsToChoice(details.m_NeedAnnots) ) {
1071  case eFeatures:
1072  annots |= fBlobHasIntFeat;
1073  break;
1074  case eAlign:
1075  annots |= fBlobHasIntAlign;
1076  break;
1077  case eGraph:
1078  annots |= fBlobHasIntGraph;
1079  break;
1080  case eAnnot:
1081  annots |= fBlobHasIntAnnot;
1082  break;
1083  default:
1084  break;
1085  }
1087  mask |= annots;
1088  }
1090  mask |= (annots << 1);
1091  }
1093  mask |= (annots << 2);
1094  }
1095  }
1096  return mask;
1097 }
1098 
1099 
1102 {
1103  return x_GetRecords(sih, x_MakeContentMask(choice), 0);
1104 }
1105 
1106 
1109  const SRequestDetails& details)
1110 {
1111  return x_GetRecords(sih, x_MakeContentMask(details), 0);
1112 }
1113 
1114 
1116 {
1117  return true;
1118 }
1119 
1120 
1123 {
1124  TRealBlobId blob_id = GetRealBlobId(id);
1125 
1127  CLoadLockBlob blob(result, blob_id);
1128  if ( !blob.IsLoadedBlob() ) {
1129  m_Dispatcher->LoadBlob(result, blob_id);
1130  }
1131  _ASSERT(blob.IsLoadedBlob());
1132  return blob.GetTSE_LoadLock();
1133 }
1134 
1135 
1136 namespace {
1137  struct SBetterId
1138  {
1139  int GetScore(const CSeq_id_Handle& id1) const
1140  {
1141  if ( id1.IsGi() ) {
1142  return 100;
1143  }
1144  if ( !id1 ) {
1145  return -1;
1146  }
1147  CConstRef<CSeq_id> seq_id = id1.GetSeqId();
1148  const CTextseq_id* text_id = seq_id->GetTextseq_Id();
1149  if ( text_id ) {
1150  int score;
1151  if ( text_id->IsSetAccession() ) {
1152  if ( text_id->IsSetVersion() ) {
1153  score = 99;
1154  }
1155  else {
1156  score = 50;
1157  }
1158  }
1159  else {
1160  score = 0;
1161  }
1162  return score;
1163  }
1164  if ( seq_id->IsGeneral() ) {
1165  return 10;
1166  }
1167  if ( seq_id->IsLocal() ) {
1168  return 0;
1169  }
1170  return 1;
1171  }
1172  bool operator()(const CSeq_id_Handle& id1,
1173  const CSeq_id_Handle& id2) const
1174  {
1175  int score1 = GetScore(id1);
1176  int score2 = GetScore(id2);
1177  if ( score1 != score2 ) {
1178  return score1 > score2;
1179  }
1180  return id1 < id2;
1181  }
1182  };
1183 }
1184 
1185 
1188 {
1189  TTSE_LockSet ret;
1190  TIds ids = bioseq.GetId();
1191  sort(ids.begin(), ids.end(), SBetterId());
1192  ITERATE ( TIds, it, ids ) {
1193  if ( GetBlobId(*it) ) {
1194  // correct id is found
1195  TTSE_LockSet ret2 = GetRecords(*it, eExtAnnot);
1196  ret.swap(ret2);
1197  break;
1198  }
1199  else if ( it->Which() == CSeq_id::e_Gi ) {
1200  // gi is not found, do not try any other Seq-id
1201  break;
1202  }
1203  }
1204  return ret;
1205 }
1206 
1207 
1210  const SAnnotSelector* sel,
1211  TProcessedNAs* processed_nas)
1212 {
1213  return x_GetRecords(idh, fBlobHasExtAnnot|fBlobHasNamedAnnot, sel, processed_nas);
1214 }
1215 
1216 
1219  const SAnnotSelector* sel,
1220  TProcessedNAs* processed_nas)
1221 {
1222  TTSE_LockSet ret;
1223  TIds ids = bioseq.GetId();
1224  sort(ids.begin(), ids.end(), SBetterId());
1225  ITERATE ( TIds, it, ids ) {
1226  if ( GetBlobId(*it) ) {
1227  // correct id is found
1228  TTSE_LockSet ret2 = GetExternalAnnotRecordsNA(*it, sel, processed_nas);
1229  ret.swap(ret2);
1230  break;
1231  }
1232  else if ( it->Which() == CSeq_id::e_Gi ) {
1233  // gi is not found, do not try any other Seq-id
1234  break;
1235  }
1236  }
1237  return ret;
1238 }
1239 
1240 
1243  const SAnnotSelector* sel,
1244  TProcessedNAs* processed_nas)
1245 {
1246  bool load_external = m_AlwaysLoadExternal;
1247  bool load_namedacc =
1249  if ( load_external || load_namedacc ) {
1250  TBlobContentsMask mask = 0;
1251  if ( load_external ) {
1253  }
1254  if ( load_namedacc ) {
1256  }
1257  return x_GetRecords(idh, mask, sel, processed_nas);
1258  }
1259  else {
1260  return CDataLoader::GetOrphanAnnotRecordsNA(idh, sel, processed_nas);
1261  }
1262 }
1263 
1264 
1268  const SAnnotSelector* sel,
1269  TProcessedNAs* processed_nas)
1270 {
1271  TTSE_LockSet locks;
1272 
1273  if ( mask == 0 || CReadDispatcher::CannotProcess(sih) ) {
1274  return locks;
1275  }
1276 
1277  if ( (mask & ~fBlobHasOrphanAnnot) == 0 ) {
1278  // no orphan annotations in GenBank
1279  return locks;
1280  }
1281 
1282  CGBReaderRequestResult result(this, sih);
1283  m_Dispatcher->LoadBlobs(result, sih, mask, sel);
1284  CLoadLockBlobIds blobs(result, sih, sel);
1285  if ( !blobs.IsLoaded() ) {
1286  return locks;
1287  }
1288  _ASSERT(blobs.IsLoaded());
1289 
1290  CFixedBlob_ids blob_ids = blobs.GetBlob_ids();
1291  if ( (blob_ids.GetState() & CBioseq_Handle::fState_no_data) != 0 ) {
1292  if ( (mask & fBlobHasAllLocal) == 0 ||
1293  blob_ids.GetState() == CBioseq_Handle::fState_no_data ) {
1294  // only external annotatsions are requested,
1295  // or default state - return empty lock set
1296  return locks;
1297  }
1298  NCBI_THROW2(CBlobStateException, eBlobStateError,
1299  "blob state error for "+sih.AsString(),
1300  blob_ids.GetState());
1301  }
1302 
1303  ITERATE ( CFixedBlob_ids, it, blob_ids ) {
1304  const CBlob_Info& info = *it;
1305  const CBlob_id& blob_id = *info.GetBlob_id();
1306  if ( info.Matches(mask, sel) ) {
1307  CLoadLockBlob blob(result, blob_id);
1308  if ( !blob.IsLoadedBlob() ) {
1309  continue;
1310  }
1311  CTSE_LoadLock& lock = blob.GetTSE_LoadLock();
1312  _ASSERT(lock);
1313  if ( lock->GetBlobState() & CBioseq_Handle::fState_no_data ) {
1314  NCBI_THROW2(CBlobStateException, eBlobStateError,
1315  "blob state error for "+blob_id.ToString(),
1316  lock->GetBlobState());
1317  }
1318  if ( processed_nas ) {
1319  if ( auto annot_info = info.GetAnnotInfo() ) {
1320  for ( auto& acc : annot_info->GetNamedAnnotNames() ) {
1321  CDataLoader::SetProcessedNA(acc, processed_nas);
1322  }
1323  }
1324  }
1325  locks.insert(lock);
1326  }
1327  }
1328  result.SaveLocksTo(locks);
1329  return locks;
1330 }
1331 
1332 
1335 {
1337 
1338  CGBReaderRequestResult result(this, sih);
1339  SAnnotSelector sel;
1340  sel.IncludeNamedAnnotAccession("NA*");
1341  CLoadLockBlobIds blobs(result, sih, &sel);
1342  m_Dispatcher->LoadSeq_idBlob_ids(result, sih, &sel);
1343  _ASSERT(blobs.IsLoaded());
1344 
1345  CFixedBlob_ids blob_ids = blobs.GetBlob_ids();
1346  if ( (blob_ids.GetState() & CBioseq_Handle::fState_no_data) != 0) {
1347  if ( blob_ids.GetState() == CBioseq_Handle::fState_no_data ) {
1348  // default state - return empty name set
1349  return names;
1350  }
1351  NCBI_THROW2(CBlobStateException, eBlobStateError,
1352  "blob state error for "+sih.AsString(),
1353  blob_ids.GetState());
1354  }
1355 
1356  ITERATE ( CFixedBlob_ids, it, blob_ids ) {
1357  const CBlob_Info& info = *it;
1358  if ( !info.IsSetAnnotInfo() ) {
1359  continue;
1360  }
1361  CConstRef<CBlob_Annot_Info> annot_info = info.GetAnnotInfo();
1363  annot_info->GetNamedAnnotNames()) {
1364  names.insert(*jt);
1365  }
1366  }
1367  return names;
1368 }
1369 
1370 
1373  const string& named_acc)
1374 {
1376 
1377  CGBReaderRequestResult result(this, sih);
1378  SAnnotSelector sel;
1379  if ( !ExtractZoomLevel(named_acc, 0, 0) ) {
1381  }
1382  else {
1383  sel.IncludeNamedAnnotAccession(named_acc);
1384  }
1385  CLoadLockBlobIds blobs(result, sih, &sel);
1386  m_Dispatcher->LoadSeq_idBlob_ids(result, sih, &sel);
1387  _ASSERT(blobs.IsLoaded());
1388 
1389  CFixedBlob_ids blob_ids = blobs.GetBlob_ids();
1390  if ( (blob_ids.GetState() & CBioseq_Handle::fState_no_data) != 0 ) {
1391  if ( blob_ids.GetState() == CBioseq_Handle::fState_no_data ) {
1392  // default state - return empty name set
1393  return names;
1394  }
1395  NCBI_THROW2(CBlobStateException, eBlobStateError,
1396  "blob state error for "+sih.AsString(),
1397  blob_ids.GetState());
1398  }
1399 
1400  ITERATE ( CFixedBlob_ids, it, blob_ids ) {
1401  const CBlob_Info& info = *it;
1402  if ( !info.IsSetAnnotInfo() ) {
1403  continue;
1404  }
1405  CConstRef<CBlob_Annot_Info> annot_info = info.GetAnnotInfo();
1407  annot_info->GetNamedAnnotNames() ) {
1408  names.insert(*jt);
1409  }
1410  }
1411  return names;
1412 }
1413 
1414 
1416 {
1417  auto id = chunk->GetChunkId();
1418  if ( id == kMasterWGS_ChunkId ) {
1419  CWGSMasterSupport::LoadWGSMaster(this, chunk);
1420  }
1421  else {
1424  GetRealBlobId(chunk->GetBlobId()),
1425  id);
1426  }
1427 }
1428 
1429 
1431 {
1432  // filter out WGS master and sort chunks
1434  for ( auto& it : chunks ) {
1435  auto chunk_id = it->GetChunkId();
1436  if ( chunk_id == kMasterWGS_ChunkId ) {
1438  }
1439  else {
1440  chunks_to_load[GetRealBlobId(it->GetBlobId())].push_back(chunk_id);
1441  }
1442  }
1443  CReadDispatcher::TBlobChunkIds chunk_ids(chunks_to_load.begin(),
1444  chunks_to_load.end());
1446  m_Dispatcher->LoadChunks(result, chunk_ids);
1447 }
1448 
1449 
1451 {
1455  ITERATE(TTSE_LockSets, tse_set, tse_sets) {
1456  const CSeq_id_Handle& id = tse_set->first;
1457  if ( CReadDispatcher::CannotProcess(id) ) {
1458  continue;
1459  }
1460  ids.push_back(id);
1461  }
1463 
1464  NON_CONST_ITERATE(TTSE_LockSets, tse_set, tse_sets) {
1465  const CSeq_id_Handle& id = tse_set->first;
1466  if ( CReadDispatcher::CannotProcess(id) ) {
1467  continue;
1468  }
1469  CLoadLockBlobIds blob_ids_lock(result, id, 0);
1470  CFixedBlob_ids blob_ids = blob_ids_lock.GetBlob_ids();
1471  ITERATE ( CFixedBlob_ids, it, blob_ids ) {
1472  const CBlob_Info& info = *it;
1473  const CBlob_id& blob_id = *info.GetBlob_id();
1474  if ( info.Matches(mask, 0) ) {
1475  CLoadLockBlob blob(result, blob_id);
1476  _ASSERT(blob.IsLoadedBlob());
1477  /*
1478  if ((blob.GetBlobState() & CBioseq_Handle::fState_no_data) != 0) {
1479  // Ignore bad blobs
1480  continue;
1481  }
1482  */
1483  tse_set->second.insert(blob.GetTSE_LoadLock());
1484  }
1485  }
1486  }
1487 }
1488 
1489 
1490 static
1491 bool x_IsCDDBlob(const CBlob_Info& blob_info)
1492 {
1493  // must have external annotations
1494  if ( !blob_info.Matches(fBlobHasExtAnnot, 0) ) {
1495  return false;
1496  }
1497  // must have CDD name in annot info
1498  if ( !blob_info.IsSetAnnotInfo() ) {
1499  return false;
1500  }
1501  const char* kCDDAnnotName = "CDD";
1502  for ( auto name : blob_info.GetAnnotInfo()->GetNamedAnnotNames() ) {
1503  if ( NStr::EqualNocase(name, kCDDAnnotName) ) {
1504  return true;
1505  }
1506  }
1507  for ( auto annot_info : blob_info.GetAnnotInfo()->GetAnnotInfo() ) {
1508  if ( annot_info->IsSetName() &&
1509  NStr::EqualNocase(annot_info->GetName(), kCDDAnnotName) ) {
1510  return true;
1511  }
1512  }
1513  return false;
1514 }
1515 
1516 
1517 static bool x_IsEmptyCDD(const CTSE_Info& tse)
1518 {
1519  // check if delayed TSE chunk is loaded
1520  if ( tse.x_NeedsDelayedMainChunk() ) {
1521  // not loaded yet, cannot tell if its empty
1522  return false;
1523  }
1524  // check core Seq-entry content
1525  auto core = tse.GetTSECore();
1526  if ( !core->IsSet() ) {
1527  // wrong entry type
1528  return false;
1529  }
1530  auto& seqset = core->GetSet();
1531  return seqset.GetSeq_set().empty() && seqset.GetAnnot().empty();
1532 }
1533 
1534 
1536 {
1537  //return CDataLoader::GetCDDAnnots(id_sets, loaded, ret);
1539  vector<CSeq_id_Handle> best_ids;
1541  // first select ids that we can process
1542  for ( auto& id_set : id_sets) {
1543  SBetterId score_func;
1544  CSeq_id_Handle best_id;
1545  int best_score = -1;
1546  for ( auto& id : id_set ) {
1547  if ( CReadDispatcher::CannotProcess(id) ) {
1548  continue;
1549  }
1550  int score = score_func.GetScore(id);
1551  if ( score > best_score ) {
1552  best_score = score;
1553  best_id = id;
1554  }
1555  }
1556  best_ids.push_back(best_id);
1557  if ( best_id ) {
1558  ids.push_back(best_id);
1559  }
1560  }
1561  if ( ids.empty() ) {
1562  return;
1563  }
1564  // load blob_ids
1566 
1567  // select CDD blobs and load them
1568  CReadDispatcher::TBlobInfos blobs_to_load;
1569  for ( auto& id : best_ids ) {
1570  if ( !id ) {
1571  continue;
1572  }
1573  CLoadLockBlobIds blob_ids_lock(result, id, 0);
1574  CFixedBlob_ids blob_ids = blob_ids_lock.GetBlob_ids();
1575  ITERATE ( CFixedBlob_ids, it, blob_ids ) {
1576  const CBlob_Info& info = *it;
1577  if ( !x_IsCDDBlob(info) ) {
1578  continue;
1579  }
1580  const CBlob_id& blob_id = *info.GetBlob_id();
1581  CLoadLockBlob blob(result, blob_id);
1582  if ( !blob.IsLoadedBlob() ) {
1583  blobs_to_load.push_back(info);
1584  }
1585  }
1586  }
1587  if ( !blobs_to_load.empty() ) {
1588  m_Dispatcher->LoadBlobs(result, blobs_to_load);
1589  }
1590 
1591  CReadDispatcher::TChunkIds main_chunk;
1592  main_chunk.push_back(CTSE_Chunk_Info::kDelayedMain_ChunkId);
1593 
1594  // select CDD blobs and load their delayed TSE chunks
1595  CReadDispatcher::TBlobChunkIds chunks_to_load;
1596  for ( auto& id : best_ids ) {
1597  if ( !id ) {
1598  continue;
1599  }
1600  CLoadLockBlobIds blob_ids_lock(result, id, 0);
1601  CFixedBlob_ids blob_ids = blob_ids_lock.GetBlob_ids();
1602  ITERATE ( CFixedBlob_ids, it, blob_ids ) {
1603  const CBlob_Info& info = *it;
1604  if ( !x_IsCDDBlob(info) ) {
1605  continue;
1606  }
1607  const CBlob_id& blob_id = *info.GetBlob_id();
1608  CLoadLockBlob blob(result, blob_id);
1609  _ASSERT(blob.IsLoadedBlob());
1610  // may be not loaded yet
1611  if ( blob.GetTSE_LoadLock()->x_NeedsDelayedMainChunk() ) {
1612  chunks_to_load.push_back(make_pair(blob_id, main_chunk));
1613  }
1614  }
1615  }
1616  if ( !chunks_to_load.empty() ) {
1617  m_Dispatcher->LoadChunks(result, chunks_to_load);
1618  }
1619 
1620  // now collect all non-empty CDD blobs
1621  for ( size_t i = 0; i < id_sets.size(); ++i ) {
1622  auto& id = best_ids[i];
1623  if ( !id ) {
1624  continue;
1625  }
1626  CLoadLockBlobIds blob_ids_lock(result, id, 0);
1627  CFixedBlob_ids blob_ids = blob_ids_lock.GetBlob_ids();
1628  ITERATE ( CFixedBlob_ids, it, blob_ids ) {
1629  const CBlob_Info& info = *it;
1630  if ( !x_IsCDDBlob(info) ) {
1631  continue;
1632  }
1633  const CBlob_id& blob_id = *info.GetBlob_id();
1634  CLoadLockBlob blob(result, blob_id);
1635  _ASSERT(blob.IsLoadedBlob());
1636  if ( !x_IsEmptyCDD(*blob.GetTSE_LoadLock()) ) {
1637  ret[i] = blob.GetTSE_LoadLock();
1638  }
1639  loaded[i] = true;
1640  break;
1641  }
1642  }
1643 }
1644 
1645 
1646 #if 0
1647 class CTimerGuard
1648 {
1649  CTimer *t;
1650  bool calibrating;
1651 public:
1652  CTimerGuard(CTimer& x)
1653  : t(&x), calibrating(x.NeedCalibration())
1654  {
1655  if ( calibrating ) {
1656  t->Start();
1657  }
1658  }
1659  ~CTimerGuard(void)
1660  {
1661  if ( calibrating ) {
1662  t->Stop();
1663  }
1664  }
1665 };
1666 #endif
1667 
1668 
1670 {
1671  //TWriteLockGuard guard(m_LoadMap_Lock);
1672  //m_LoadMapBlob.erase(GetBlob_id(*tse_info));
1673 }
1674 
1675 
1678  const CSeq_id_Handle& requested_id)
1679  : CReaderRequestResult(requested_id,
1680  loader->GetDispatcher(),
1681  loader->GetInfoManager()),
1682  m_Loader(loader)
1683 {
1684 }
1685 
1686 
1688 {
1689 }
1690 
1691 
1693 {
1694  return m_Loader;
1695 }
1696 
1697 
1699 {
1700  CGBDataLoader::TBlobId id(new TKeyBlob(blob_id));
1701  return GetLoader().GetDataSource()->GetTSE_LoadLock(id);
1702 }
1703 
1704 
1706 {
1707  CGBDataLoader::TBlobId id(new TKeyBlob(blob_id));
1709 }
1710 
1711 
1713  TLoadedBlob_ids& blob_ids) const
1714 {
1715  CDataSource::TLoadedBlob_ids blob_ids2;
1718  blob_ids2);
1719  ITERATE(CDataSource::TLoadedBlob_ids, id, blob_ids2) {
1720  blob_ids.push_back(m_Loader->GetRealBlobId(*id));
1721  }
1722 }
1723 
1724 
1727 {
1728  if ( type == GBL::eExpire_normal ) {
1729  return m_Loader->GetIdExpirationTimeout();
1730  }
1731  else {
1733  }
1734 }
1735 
1736 
1737 bool
1739 {
1740  return m_Loader->GetAddWGSMasterDescr();
1741 }
1742 
1743 
1745 {
1746  return m_Loader->GetPTISErrorAction();
1747 }
1748 
1749 
1750 /*
1751 bool CGBDataLoader::LessBlobId(const TBlobId& id1, const TBlobId& id2) const
1752 {
1753  const CBlob_id& bid1 = dynamic_cast<const CBlob_id&>(*id1);
1754  const CBlob_id& bid2 = dynamic_cast<const CBlob_id&>(*id2);
1755  return bid1 < bid2;
1756 }
1757 
1758 
1759 string CGBDataLoader::BlobIdToString(const TBlobId& id) const
1760 {
1761  const CBlob_id& bid = dynamic_cast<const CBlob_id&>(*id);
1762  return bid.ToString();
1763 }
1764 */
1765 
1767  ECacheType cache_type)
1768 {
1769  SReaderCacheInfo info(cache, cache_type);
1770  //!!! Make sure the cache is not registered yet!
1771  m_Caches.push_back(info);
1772 }
1773 
1774 
1776  const TCacheParams* params)
1777 {
1779  if ((it->m_Type & cache_type) == 0) {
1780  continue;
1781  }
1782  if ( it->m_Cache->SameCacheParams(params) ) {
1783  return it->m_Cache.get();
1784  }
1785  }
1786  return 0;
1787 }
1788 
1789 
1791 
1792 // ===========================================================================
1793 
1795 
ncbi::TMaskedQueryRegions mask
const TId & GetId(void) const
Blob state exceptions, used by GenBank loader.
const TAnnotInfo & GetAnnotInfo(void) const
const TNamedAnnotNames & GetNamedAnnotNames(void) const
const CConstRef< CBlob_Annot_Info > & GetAnnotInfo(void) const
bool IsSetAnnotInfo(void) const
bool Matches(TContentsMask mask, const SAnnotSelector *sel) const
static CBlob_id * CreateFromString(const string &str)
Definition: blob_id.cpp:84
string ToString(void) const
Get string representation of blob id.
Definition: blob_id.cpp:67
CTSE_LoadLock GetTSE_LoadLock(const TBlobId &blob_id)
CTSE_LoadLock GetTSE_LoadLockIfLoaded(const TBlobId &blob_id)
vector< TBlobId > TLoadedBlob_ids
void GetLoadedBlob_ids(const CSeq_id_Handle &idh, TLoadedTypes types, TLoadedBlob_ids &blob_ids) const
TState GetState(void) const
TRegisterInfo GetRegisterInfo(void)
Definition: gbloader.hpp:454
virtual void GetChunk(TChunk chunk) override
Definition: gbnative.cpp:1415
virtual TTSE_LockSet GetRecords(const CSeq_id_Handle &idh, EChoice choice) override
Request from a datasource using handles and ranges instead of seq-loc The TSEs loaded in this call wi...
Definition: gbnative.cpp:1101
virtual void GetTaxIds(const TIds &ids, TLoaded &loader, TTaxIds &ret) override
Definition: gbnative.cpp:711
static CRef< TReaderManager > x_GetReaderManager(void)
Definition: gbnative.cpp:450
TBlobContentsMask x_MakeContentMask(EChoice choice) const
Definition: gbnative.cpp:1011
CReader * x_CreateReader(const string &names, const CGBLoaderParams &gb_params, const TParamTree *params=0)
Definition: gbnative.cpp:491
CGBDataLoader_Native(const string &loader_name, const CGBLoaderParams &params)
Definition: gbnative.cpp:159
virtual void GetSequenceTypes(const TIds &ids, TLoaded &loader, TSequenceTypes &ret) override
Definition: gbnative.cpp:789
virtual TBlobVersion GetBlobVersion(const TBlobId &id) override
Definition: gbnative.cpp:880
virtual void GetSequenceHashes(const TIds &ids, TLoaded &loader, TSequenceHashes &ret, THashKnown &known) override
Definition: gbnative.cpp:866
virtual void GetAccVers(const TIds &ids, TLoaded &loader, TIds &ret) override
Definition: gbnative.cpp:672
virtual TTSE_LockSet GetExternalAnnotRecordsNA(const CSeq_id_Handle &idh, const SAnnotSelector *sel, TProcessedNAs *processed_nas) override
Definition: gbnative.cpp:1209
virtual void GC(void) override
Definition: gbnative.cpp:1006
virtual TTSE_LockSet GetDetailedRecords(const CSeq_id_Handle &idh, const SRequestDetails &details) override
Request from a datasource using handles and ranges instead of seq-loc The TSEs loaded in this call wi...
Definition: gbnative.cpp:1108
virtual void GetSequenceStates(const TIds &ids, TLoaded &loader, TSequenceStates &ret) override
Definition: gbnative.cpp:803
virtual void GetIds(const CSeq_id_Handle &idh, TIds &ids) override
Definition: gbnative.cpp:558
virtual void GetBulkIds(const TIds &ids, TLoaded &loader, TBulkIds &ret) override
Definition: gbnative.cpp:659
virtual void DropTSE(CRef< CTSE_Info > tse_info) override
Definition: gbnative.cpp:1669
virtual TTSE_Lock ResolveConflict(const CSeq_id_Handle &handle, const TTSE_LockSet &tse_set) override
Resolve TSE conflict *select the best TSE from the set of dead TSEs.
Definition: gbnative.cpp:893
virtual bool CanGetBlobById(void) const override
Definition: gbnative.cpp:1115
virtual TSeqPos GetSequenceLength(const CSeq_id_Handle &sih) override
Request for a length of a sequence.
Definition: gbnative.cpp:742
virtual void GetChunks(const TChunkSet &chunks) override
Definition: gbnative.cpp:1430
virtual TNamedAnnotNames GetNamedAnnotAccessions(const CSeq_id_Handle &idh) override
Definition: gbnative.cpp:1334
CRef< CGBInfoManager > m_InfoManager
Definition: gbnative.hpp:241
static TRegisterLoaderInfo RegisterInObjectManager(CObjectManager &om, const CGBLoaderParams &params, CObjectManager::EIsDefault is_default=CObjectManager::eDefault, CObjectManager::TPriority priority=CObjectManager::kPriority_NotSet)
Definition: gbnative.cpp:147
void x_CreateDriver(const CGBLoaderParams &params)
Definition: gbnative.cpp:182
void PurgeCache(TCacheType cache_type, time_t access_timeout=0) override
Definition: gbnative.cpp:984
CInitMutexPool m_MutexPool
Definition: gbnative.hpp:238
CWriter * x_CreateWriter(const string &names, const TParamTree *params=0)
Definition: gbnative.cpp:516
static CRef< TWriterManager > x_GetWriterManager(void)
Definition: gbnative.cpp:470
virtual void GetGis(const TIds &ids, TLoaded &loader, TGis &ret) override
Definition: gbnative.cpp:685
void x_CreateWriters(const string &str, const TParamTree *params)
Definition: gbnative.cpp:426
virtual TTSE_LockSet GetOrphanAnnotRecordsNA(const CSeq_id_Handle &idh, const SAnnotSelector *sel, TProcessedNAs *processed_nas) override
new Get*AnnotRecords() methods
Definition: gbnative.cpp:1242
virtual int GetSequenceState(const CSeq_id_Handle &idh) override
Request for a state of a sequence.
Definition: gbnative.cpp:643
CGBReaderCacheManager m_CacheManager
Definition: gbnative.hpp:244
TTSE_LockSet x_GetRecords(const CSeq_id_Handle &idh, TBlobContentsMask sr_mask, const SAnnotSelector *sel, TProcessedNAs *processed_nas=0)
Definition: gbnative.cpp:1266
virtual STypeFound GetSequenceTypeFound(const CSeq_id_Handle &sih) override
Definition: gbnative.cpp:771
virtual TTaxId GetTaxId(const CSeq_id_Handle &idh) override
Request for a taxonomy id of a sequence.
Definition: gbnative.cpp:625
CRef< CReadDispatcher > m_Dispatcher
Definition: gbnative.hpp:240
virtual SGiFound GetGiFound(const CSeq_id_Handle &idh) override
Definition: gbnative.cpp:593
virtual TBlobId GetBlobIdFromString(const string &str) const override
Definition: gbnative.cpp:552
void CloseCache(void) override
Definition: gbnative.cpp:995
virtual TTSE_LockSet GetExternalRecords(const CBioseq_Info &bioseq) override
Request from a datasource set of blobs with external annotations.
Definition: gbnative.cpp:1187
virtual ~CGBDataLoader_Native(void)
Definition: gbnative.cpp:168
virtual void GetLabels(const TIds &ids, TLoaded &loader, TLabels &ret) override
Definition: gbnative.cpp:698
virtual string GetLabel(const CSeq_id_Handle &idh) override
Request for a label string of a sequence.
Definition: gbnative.cpp:611
virtual void GetSequenceLengths(const TIds &ids, TLoaded &loader, TSequenceLengths &ret) override
Definition: gbnative.cpp:756
virtual void GetCDDAnnots(const TSeqIdSets &id_sets, TLoaded &loaded, TCDD_Locks &ret) override
Definition: gbnative.cpp:1535
virtual SHashFound GetSequenceHashFound(const CSeq_id_Handle &idh) override
Definition: gbnative.cpp:848
virtual TTSE_Lock GetBlobById(const TBlobId &id) override
Definition: gbnative.cpp:1122
bool x_CreateReaders(const string &str, const TParamTree *params, const CGBLoaderParams &gb_params, CGBLoaderParams::EPreopenConnection preopen)
Definition: gbnative.cpp:397
virtual SAccVerFound GetAccVerFound(const CSeq_id_Handle &idh) override
Definition: gbnative.cpp:573
virtual TBlobId GetBlobId(const CSeq_id_Handle &idh) override
Definition: gbnative.cpp:535
virtual void GetBlobs(TTSE_LockSets &tse_sets) override
Definition: gbnative.cpp:1450
TRealBlobId x_GetRealBlobId(const TBlobId &blob_id) const override
Definition: gbnative.cpp:176
pair< string, string > GetReaderWriterName(const TParamTree *params, const CGBLoaderParams &loader_params) const
Definition: gbnative.cpp:355
bool HaveCache(TCacheType cache_type=fCache_Any) override
Definition: gbnative.cpp:973
Uint4 TExpirationTimeout
Definition: gbloader.hpp:380
bool m_AddWGSMasterDescr
Definition: gbloader.hpp:472
TExpirationTimeout m_IdExpirationTimeout
Definition: gbloader.hpp:468
TRealBlobId GetRealBlobId(const TBlobId &blob_id) const
Definition: gbloader.cpp:717
bool GetAddWGSMasterDescr(void) const
Definition: gbloader.hpp:407
bool m_AlwaysLoadExternal
Definition: gbloader.hpp:470
EGBErrorAction GetPTISErrorAction(void) const
Definition: gbloader.hpp:423
string m_WebCookie
Definition: gbloader.hpp:475
bool HasHUPIncluded(void) const
Definition: gbloader.hpp:417
static string x_GetLoaderMethod(const TParamTree *params)
Definition: gbloader.cpp:208
TExpirationTimeout GetIdExpirationTimeout(void) const
Definition: gbloader.hpp:381
static string GetParam(const TParamTree *params, const string &param_name)
Definition: gbloader.cpp:665
EGBErrorAction m_PTISErrorAction
Definition: gbloader.hpp:474
static TParamTree * GetLoaderParams(TParamTree *params)
Definition: gbloader.cpp:637
bool m_AlwaysLoadNamedAcc
Definition: gbloader.hpp:471
CReaderCacheManager::TCacheType TCacheType
Definition: gbloader.hpp:372
const string & GetLoaderMethod(void) const
Definition: gbloader.hpp:117
CReader * GetReaderPtr(void) const
Definition: gbloader.cpp:142
EPreopenConnection GetPreopenConnection(void) const
Definition: gbloader.hpp:153
const TParamTree * GetParamTree(void) const
Definition: gbloader.hpp:144
CNullable< bool > m_EnableCDD
Definition: gbloader.hpp:228
CNullable< bool > m_EnableSNP
Definition: gbloader.hpp:226
const string & GetWebCookie(void) const
Definition: gbloader.hpp:168
const string & GetWriterName(void) const
Definition: gbloader.hpp:135
CNullable< bool > m_EnableWGS
Definition: gbloader.hpp:227
const string & GetReaderName(void) const
Definition: gbloader.hpp:126
virtual ICache * FindCache(ECacheType cache_type, const TCacheParams *params)
Definition: gbnative.cpp:1775
virtual TCaches & GetCaches(void)
Definition: gbnative.hpp:104
virtual void RegisterCache(ICache &cache, ECacheType cache_type)
Definition: gbnative.cpp:1766
CReaderRequestResult TParent
Definition: gbnative.cpp:111
CInitMutexPool & GetMutexPool(void)
Definition: gbnative.cpp:132
virtual TExpirationTime GetIdExpirationTimeout(GBL::EExpirationType type) const override
Definition: gbnative.cpp:1726
virtual EGBErrorAction GetPTISErrorAction(void) const override
Definition: gbnative.cpp:1744
CGBDataLoader_Native & GetLoader(void)
Definition: gbnative.cpp:117
CRef< CGBDataLoader_Native > m_Loader
Definition: gbnative.cpp:143
virtual bool GetAddWGSMasterDescr(void) const override
Definition: gbnative.cpp:1738
virtual CTSE_LoadLock GetTSE_LoadLock(const TKeyBlob &blob_id) override
Definition: gbnative.cpp:1698
virtual CGBDataLoader_Native * GetLoaderPtr(void) override
Definition: gbnative.cpp:1692
virtual void GetLoadedBlob_ids(const CSeq_id_Handle &idh, TLoadedBlob_ids &blob_ids) const override
Definition: gbnative.cpp:1712
CGBReaderRequestResult(CGBDataLoader_Native *loader, const CSeq_id_Handle &requested_id)
Definition: gbnative.cpp:1677
virtual CTSE_LoadLock GetTSE_LoadLockIfLoaded(const TKeyBlob &blob_id) override
Definition: gbnative.cpp:1705
TData GetAccVer(void) const
bool IsLoadedAccVer(void) const
TData GetBlob_ids(void) const
bool IsLoadedBlobVersion(void) const
TData GetBlobVersion(void) const
bool IsLoadedBlob(void) const
CTSE_LoadLock & GetTSE_LoadLock(void)
bool IsLoadedGi(void) const
static TGi GetGi(const TData &data)
bool IsLoadedHash(void) const
static int GetHash(const TData &data)
bool IsLoadedLabel(void) const
TData GetLabel(void) const
TData GetLength(void) const
bool IsLoadedLength(void) const
TData GetSeq_ids(void) const
bool IsLoadedTaxId(void) const
TData GetTaxId(void) const
static CSeq_inst::TMol GetType(const TData &data)
bool IsLoadedType(void) const
Data loader exceptions, used by GenBank loader.
Base class for all object manager exceptions.
CObjectManager –.
void LoadStates(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TStates &ret)
void ResetCaches(void)
Definition: dispatcher.cpp:250
void LoadBlobSet(CReaderRequestResult &result, const TIds &seq_ids)
void LoadChunks(CReaderRequestResult &result, const TBlobId &blob_id, const TChunkIds &chunk_ids)
void LoadSeq_idLabel(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
void LoadGis(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TGis &ret)
void LoadBlobVersion(CReaderRequestResult &result, const TBlobId &blob_id, const CReader *asking_reader=0)
void InsertReader(TLevel level, CRef< CReader > reader)
Definition: dispatcher.cpp:173
void LoadBulkIds(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TBulkIds &ret)
CReader::TChunkIds TChunkIds
Definition: dispatcher.hpp:67
void LoadLabels(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TLabels &ret)
void LoadSeq_idGi(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
void InsertWriter(TLevel level, CRef< CWriter > writer)
Definition: dispatcher.cpp:184
void LoadSequenceType(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
void LoadAccVers(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TIds &ret)
void LoadSequenceHash(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
void LoadLengths(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TLengths &ret)
vector< pair< CBlob_id, TChunkIds > > TBlobChunkIds
Definition: dispatcher.hpp:119
void LoadTaxIds(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TTaxIds &ret)
void LoadHashes(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, THashes &ret, TKnown &known)
bool HasReaderWithHUPIncluded() const
Definition: dispatcher.cpp:239
void LoadTypes(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TTypes &ret)
void LoadSeq_idTaxId(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
vector< CBlob_Info > TBlobInfos
Definition: dispatcher.hpp:118
void LoadSeq_idSeq_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
vector< CSeq_id_Handle > TIds
Definition: dispatcher.hpp:69
void LoadBlobs(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, TContentsMask mask, const SAnnotSelector *sel)
void LoadSeq_idAccVer(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
void LoadSequenceLength(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
void LoadSeq_idBlob_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const SAnnotSelector *sel)
void LoadChunk(CReaderRequestResult &result, const TBlobId &blob_id, TChunkId chunk_id)
void LoadBlob(CReaderRequestResult &result, const CBlob_id &blob_id)
static bool CannotProcess(const CSeq_id_Handle &sih)
Definition: dispatcher.cpp:261
vector< SReaderCacheInfo > TCaches
void SetEnableCDD(CNullable< bool > enable)
Definition: reader.hpp:68
void SetEnableWGS(CNullable< bool > enable)
Definition: reader.hpp:63
void SetEnableSNP(CNullable< bool > enable)
Definition: reader.hpp:58
virtual TExpirationTime GetIdExpirationTimeout(GBL::EExpirationType type) const
vector< CBlob_id > TLoadedBlob_ids
GBL::CInfo_Base::TExpirationTime TExpirationTime
void OpenInitialConnection(bool force)
Definition: reader.cpp:168
virtual void InitializeCache(CReaderCacheManager &cache_manager, const TPluginManagerParamTree *params)
Definition: reader.cpp:1390
virtual void SetIncludeHUP(bool include_hup=true, const string &web_cookie=NcbiEmptyString)
Definition: reader.cpp:1401
virtual void SetParams(const CReaderParams &params)
Definition: reader.cpp:1408
TBlobId GetBlobId(void) const
TChunkId GetChunkId(void) const
CConstRef< CSeq_entry > GetTSECore(void) const
Definition: tse_info.cpp:557
TBlobState GetBlobState(void) const
Definition: tse_info.hpp:834
bool x_NeedsDelayedMainChunk(void) const
Definition: tse_info.cpp:1407
bool IsDead(void) const
Definition: tse_info.hpp:855
definition of a Culling tree
Definition: ncbi_tree.hpp:100
static void LoadWGSMaster(CDataLoader *loader, CRef< CTSE_Chunk_Info > chunk)
Definition: wgsmaster.cpp:553
virtual void InitializeCache(CReaderCacheManager &cache_manager, const TPluginManagerParamTree *params)
Definition: writer.cpp:107
BLOB cache read/write/maintenance interface.
Definition: icache.hpp:64
const_iterator begin() const
Definition: map.hpp:151
const_iterator end() const
Definition: map.hpp:152
Definition: map.hpp:338
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
void swap(this_type &m)
Definition: set.hpp:102
static const struct name_t names[]
static const char * str(char *buf, int n)
Definition: stats.c:84
#define NCBI_GBLOADER_PARAM_PTIS_ERROR_ACTION
#define NCBI_GBLOADER_PARAM_ID_GC_SIZE
#define NCBI_GBLOADER_PARAM_ADD_WGS_MASTER
#define NCBI_GBLOADER_PARAM_PREOPEN
#define NCBI_GBLOADER_PARAM_READER_NAME
#define NCBI_GBLOADER_PARAM_ID_EXPIRATION_TIMEOUT
#define NCBI_GBLOADER_PARAM_WRITER_NAME
#define NCBI_GBLOADER_PARAM_PTIS_ERROR_ACTION_REPORT
#define NCBI_GBLOADER_PARAM_ALWAYS_LOAD_NAMED_ACC
#define NCBI_GBLOADER_PARAM_PTIS_ERROR_ACTION_IGNORE
#define NCBI_GBLOADER_PARAM_ALWAYS_LOAD_EXTERNAL
#define NCBI_GBLOADER_PARAM_PTIS_ERROR_ACTION_THROW
static bool x_IsCDDBlob(const CBlob_Info &blob_info)
Definition: gbnative.cpp:1491
USING_SCOPE(objects)
static bool s_ForceDriver(const string &name)
Definition: gbnative.cpp:485
static const char *const DEFAULT_HUP_DRV_ORDER
Definition: gbnative.cpp:101
static const bool s_LoadBulkBlobs
Definition: gbnative.cpp:739
static const char *const DEFAULT_DRV_ORDER
Definition: gbnative.cpp:99
NCBI_PARAM_DECL(string, GENBANK, READER_NAME)
static bool x_IsEmptyCDD(const CTSE_Info &tse)
Definition: gbnative.cpp:1517
NCBI_PARAM_DEF_EX(string, GENBANK, READER_NAME, "", eParam_NoThread, GENBANK_READER_NAME)
#define DEFAULT_ID_GC_SIZE
Definition: gbnative.cpp:106
#define DEFAULT_ID_EXPIRATION_TIMEOUT
Definition: gbnative.cpp:107
typedef NCBI_PARAM_TYPE(GENBANK, READER_NAME) TGenbankReaderName
#define GBLOG_POST_X(err_subcode, x)
Definition: gbnative.hpp:86
static CNcbiApplicationGuard InstanceGuard(void)
Singleton method.
Definition: ncbiapp.cpp:133
const CNcbiRegistry & GetConfig(void) const
Get the application's cached configuration parameters (read-only).
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define INVALID_TAX_ID
Definition: ncbimisc.hpp:1116
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
SStrictId_Tax::TId TTaxId
Taxon id type.
Definition: ncbimisc.hpp:1048
const TSeqPos kInvalidSeqPos
Define special value for invalid sequence position.
Definition: ncbimisc.hpp:878
string
Definition: cgiapp.hpp:687
#define _TRACE(message)
Definition: ncbidbg.hpp:122
#define NCBI_RETHROW_FMT(prev_exception, exception_class, err_code, message)
The same as NCBI_RETHROW but with message processed as output to ostream.
Definition: ncbiexpt.hpp:745
#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
#define NCBI_THROW2(exception_class, err_code, message, extra)
Throw exception with extra parameter.
Definition: ncbiexpt.hpp:1754
#define NCBI_THROW_FMT(exception_class, err_code, message)
The same as NCBI_THROW but with message processed as output to ostream.
Definition: ncbiexpt.hpp:719
static TParamTree * ConvertRegToTree(const IRegistry &reg, NStr::ECase use_case=NStr::eNocase)
Reconstruct param tree from the application registry.
CConstRef< CSeq_id > GetSeqId(void) const
bool IsGi(void) const
string AsString(void) const
const CTextseq_id * GetTextseq_Id(void) const
Return embedded CTextseq_id, if any.
Definition: Seq_id.cpp:169
vector< TSeqPos > TSequenceLengths
virtual EChoice DetailsToChoice(const SRequestDetails::TAnnotSet &annots) const
vector< CTSE_Lock > TCDD_Locks
vector< CSeq_id_Handle > TIds
virtual TTSE_LockSet GetOrphanAnnotRecordsNA(const CSeq_id_Handle &idh, const SAnnotSelector *sel, TProcessedNAs *processed_nas)
new Get*AnnotRecords() methods
CBlobIdKey TBlobId
static void SetProcessedNA(const string &na, TProcessedNAs *processed_nas)
vector< bool > THashKnown
CDataSource * GetDataSource(void) const
Definition: data_loader.cpp:92
vector< TGi > TGis
virtual void GetTaxIds(const TIds &ids, TLoaded &loaded, TTaxIds &ret)
Bulk request for taxonomy ids of a set of sequences.
TRange m_NeedSeqData
Definition: data_loader.hpp:96
EChoice
main blob is blob with sequence all other blobs are external and contain external annotations
vector< TIds > TBulkIds
static bool IsRequestedAnyNA(const SAnnotSelector *sel)
vector< CSeq_inst::TMol > TSequenceTypes
vector< vector< CSeq_id_Handle > > TSeqIdSets
virtual TTaxId GetTaxId(const CSeq_id_Handle &idh)
Request for a taxonomy id of a sequence.
EIsDefault
Flag defining if the data loader is included in the "default" group.
TAnnotSet m_NeedAnnots
Definition: data_loader.hpp:97
vector< bool > TLoaded
Bulk loading interface for a small pieces of information per id.
vector< string > TLabels
TAnnotBlobType m_AnnotBlobType
Definition: data_loader.hpp:98
static void RegisterInObjectManager(CObjectManager &om, CLoaderMaker_Base &loader_maker, CObjectManager::EIsDefault is_default, CObjectManager::TPriority priority)
Register the loader only if the name is not yet registered in the object manager.
Definition: data_loader.cpp:53
virtual void GetSequenceStates(const TIds &ids, TLoaded &loaded, TSequenceStates &ret)
Bulk request for states of a set of sequences.
vector< TTaxId > TTaxIds
vector< int > TSequenceStates
vector< int > TSequenceHashes
vector< TChunk > TChunkSet
@ eExtFeatures
external features
@ eExtAnnot
all external annotations
@ eExtAlign
external aligns
@ eAll
all blobs (main and external)
@ eSequence
seq data
@ eBlob
whole main
@ eOrphanAnnot
all external annotations if no Bioseq exists
@ eGraph
graph annotations from main blob
@ eCore
?only seq-entry core?
@ eAnnot
all annotations from main blob
@ eBioseq
main blob with complete bioseq
@ eAlign
aligns from main blob
@ eBioseqCore
main blob with bioseq core (no seqdata and annots)
@ eExtGraph
external graph annotations
@ eFeatures
features from main blob
string CombineWithZoomLevel(const string &acc, int zoom_level)
Combine accession string and zoom level into a string with separator.
SAnnotSelector & IncludeNamedAnnotAccession(const string &acc, int zoom_level=0)
bool ExtractZoomLevel(const string &full_name, string *acc_ptr, int *zoom_level_ptr)
Extract optional zoom level suffix from named annotation string.
@ eParam_NoThread
Do not use per-thread values.
Definition: ncbi_param.hpp:418
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
bool NotEmpty(void) const
Definition: range.hpp:152
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
static bool StringToBool(const CTempString str)
Convert string to bool.
Definition: ncbistr.cpp:2821
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 bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
Definition: ncbistr.hpp:5412
static unsigned int StringToUInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to unsigned int.
Definition: ncbistr.cpp:642
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
Definition: ncbistr.hpp:5353
static string & ToLower(string &str)
Convert string to lower case – string& version.
Definition: ncbistr.cpp:405
bool IsSetAccession(void) const
Check if a value has been assigned to Accession data member.
bool IsGeneral(void) const
Check if variant General is selected.
Definition: Seq_id_.hpp:877
bool IsLocal(void) const
Check if variant Local is selected.
Definition: Seq_id_.hpp:775
bool IsSetVersion(void) const
Check if a value has been assigned to Version data member.
@ e_Gi
GenInfo Integrated Database.
Definition: Seq_id_.hpp:106
const TSet & GetSet(void) const
Get the variant data.
Definition: Seq_entry_.cpp:124
const TSeq_set & GetSeq_set(void) const
Get the Seq_set member data.
Definition of all error codes used in objtools libraries.
EExpirationType
Definition: info_cache.hpp:78
@ eExpire_normal
Definition: info_cache.hpp:79
int i
static MDB_envinfo info
Definition: mdb_load.c:37
constexpr auto sort(_Init &&init)
EIPRangeType t
Definition: ncbi_localip.c:101
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
Multi-threading – classes, functions, and features.
int TBlobContentsMask
Definition: blob_id.hpp:202
EGBErrorAction
Definition: blob_id.hpp:205
@ eGBErrorAction_ignore
Definition: blob_id.hpp:206
@ eGBErrorAction_report
Definition: blob_id.hpp:207
@ eGBErrorAction_throw
Definition: blob_id.hpp:208
@ kMasterWGS_ChunkId
Definition: blob_id.hpp:148
@ fBlobHasSeqData
Definition: blob_id.hpp:158
@ fBlobHasNamedFeat
Definition: blob_id.hpp:168
@ fBlobHasNamedAnnot
Definition: blob_id.hpp:178
@ fBlobHasCore
Definition: blob_id.hpp:155
@ fBlobHasExtGraph
Definition: blob_id.hpp:166
@ fBlobHasIntAnnot
Definition: blob_id.hpp:172
@ fBlobHasAll
Definition: blob_id.hpp:200
@ fBlobHasExtFeat
Definition: blob_id.hpp:160
@ fBlobHasOrphanAnnot
Definition: blob_id.hpp:181
@ fBlobHasExtAnnot
Definition: blob_id.hpp:175
@ fBlobHasIntAlign
Definition: blob_id.hpp:162
@ fBlobHasIntFeat
Definition: blob_id.hpp:159
@ fBlobHasAllLocal
Definition: blob_id.hpp:196
@ fBlobHasNamedAlign
Definition: blob_id.hpp:169
@ fBlobHasIntGraph
Definition: blob_id.hpp:165
@ fBlobHasSeqMap
Definition: blob_id.hpp:157
@ fBlobHasExtAlign
Definition: blob_id.hpp:163
@ fBlobHasNamedGraph
Definition: blob_id.hpp:170
Helper classes and templates to implement plugins.
const char kCDDAnnotName[]
void GenBankReaders_Register_Cache(void)
void GenBankWriters_Register_Cache(void)
void GenBankReaders_Register_Id1(void)
Definition: reader_id1.cpp:792
void GenBankReaders_Register_Id2(void)
Definition: reader_id2.cpp:416
CRef< objects::CObjectManager > om
Better replacement of GetAccVer(), this method should be defined in data loaders, GetAccVer() is left...
Better replacement of GetGi(), this method should be defined in data loaders, GetGi() is left for com...
Better replacement of GetSequenceHash(), this method should be defined in data loaders,...
Better replacement of GetSequenceType(), this method should be defined in data loaders,...
SAnnotSelector –.
SRegisterLoaderInfo –.
Definition: type.c:6
#define _ASSERT
else result
Definition: token2.c:20
Modified on Sun Apr 14 05:26:43 2024 by modify_doxy.py rev. 669887