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

Go to the SVN repository for this file.

1 /* $Id: gbnative.cpp 103039 2024-08-26 15:21:55Z 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  int sat_key,
537  int sub_sat) const
538 {
539  CRef<CBlob_id> blob_id(new CBlob_id);
540  blob_id->SetSat(sat);
541  blob_id->SetSatKey(sat_key);
542  blob_id->SetSubSat(sub_sat);
543  return TBlobId(blob_id);
544 }
545 
546 
548 {
549  if ( CReadDispatcher::CannotProcess(sih) ) {
550  return TBlobId();
551  }
552  CGBReaderRequestResult result(this, sih);
553  CLoadLockBlobIds blobs(result, sih, 0);
555  CFixedBlob_ids blob_ids = blobs.GetBlob_ids();
556  ITERATE ( CFixedBlob_ids, it, blob_ids ) {
557  if ( it->Matches(fBlobHasCore, 0) ) {
558  return TBlobId(it->GetBlob_id().GetPointer());
559  }
560  }
561  return TBlobId();
562 }
563 
565 {
567 }
568 
569 
571 {
572  if ( CReadDispatcher::CannotProcess(idh) ) {
573  return;
574  }
575  CGBReaderRequestResult result(this, idh);
576  CLoadLockSeqIds lock(result, idh);
577  if ( !lock.IsLoaded() ) {
579  }
580  ids = lock.GetSeq_ids();
581 }
582 
583 
586 {
587  SAccVerFound ret;
588  if ( CReadDispatcher::CannotProcess(idh) ) {
589  // no such sequence
590  return ret;
591  }
592  CGBReaderRequestResult result(this, idh);
593  CLoadLockAcc lock(result, idh);
594  if ( !lock.IsLoadedAccVer() ) {
596  }
597  if ( lock.IsLoadedAccVer() ) {
598  ret = lock.GetAccVer();
599  }
600  return ret;
601 }
602 
603 
606 {
607  SGiFound ret;
608  if ( CReadDispatcher::CannotProcess(idh) ) {
609  return ret;
610  }
611  CGBReaderRequestResult result(this, idh);
612  CLoadLockGi lock(result, idh);
613  if ( !lock.IsLoadedGi() ) {
615  }
616  if ( lock.IsLoadedGi() ) {
617  ret = lock.GetGi();
618  }
619  return ret;
620 }
621 
622 
624 {
625  if ( CReadDispatcher::CannotProcess(idh) ) {
626  return string();
627  }
628  CGBReaderRequestResult result(this, idh);
629  CLoadLockLabel lock(result, idh);
630  if ( !lock.IsLoadedLabel() ) {
632  }
633  return lock.GetLabel();
634 }
635 
636 
638 {
639  if ( CReadDispatcher::CannotProcess(idh) ) {
640  return INVALID_TAX_ID;
641  }
642  CGBReaderRequestResult result(this, idh);
643  CLoadLockTaxId lock(result, idh);
644  if ( !lock.IsLoadedTaxId() ) {
646  }
647  TTaxId taxid = lock.IsLoadedTaxId()? lock.GetTaxId(): INVALID_TAX_ID;
648  if ( taxid == INVALID_TAX_ID ) {
649  return CDataLoader::GetTaxId(idh);
650  }
651  return taxid;
652 }
653 
654 
656 {
657  const int kNotFound = (CBioseq_Handle::fState_not_found |
659 
660  if ( CReadDispatcher::CannotProcess(sih) ) {
661  return kNotFound;
662  }
663  TIds ids(1, sih);
664  TLoaded loaded(1);
665  TSequenceStates states(1);
666  GetSequenceStates(ids, loaded, states);
667  return loaded[0]? states[0]: kNotFound;
668 }
669 
670 
671 void CGBDataLoader_Native::GetBulkIds(const TIds& ids, TLoaded& loaded, TBulkIds& ret)
672 {
673  for ( size_t i = 0; i < ids.size(); ++i ) {
674  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
675  continue;
676  }
677  CGBReaderRequestResult result(this, ids[i]);
678  m_Dispatcher->LoadBulkIds(result, ids, loaded, ret);
679  return;
680  }
681 }
682 
683 
684 void CGBDataLoader_Native::GetAccVers(const TIds& ids, TLoaded& loaded, TIds& ret)
685 {
686  for ( size_t i = 0; i < ids.size(); ++i ) {
687  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
688  continue;
689  }
690  CGBReaderRequestResult result(this, ids[i]);
691  m_Dispatcher->LoadAccVers(result, ids, loaded, ret);
692  return;
693  }
694 }
695 
696 
697 void CGBDataLoader_Native::GetGis(const TIds& ids, TLoaded& loaded, TGis& ret)
698 {
699  for ( size_t i = 0; i < ids.size(); ++i ) {
700  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
701  continue;
702  }
703  CGBReaderRequestResult result(this, ids[i]);
704  m_Dispatcher->LoadGis(result, ids, loaded, ret);
705  return;
706  }
707 }
708 
709 
710 void CGBDataLoader_Native::GetLabels(const TIds& ids, TLoaded& loaded, TLabels& ret)
711 {
712  for ( size_t i = 0; i < ids.size(); ++i ) {
713  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
714  continue;
715  }
716  CGBReaderRequestResult result(this, ids[i]);
717  m_Dispatcher->LoadLabels(result, ids, loaded, ret);
718  return;
719  }
720 }
721 
722 
723 void CGBDataLoader_Native::GetTaxIds(const TIds& ids, TLoaded& loaded, TTaxIds& ret)
724 {
725  for ( size_t i = 0; i < ids.size(); ++i ) {
726  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
727  continue;
728  }
729  CGBReaderRequestResult result(this, ids[i]);
730  m_Dispatcher->LoadTaxIds(result, ids, loaded, ret);
731 
732  // the ID2 may accidentally return no taxid for newly loaded sequences
733  // we have to fall back to full sequence retrieval in such cases
734  bool retry = false;
735  for ( size_t i = 0; i < ids.size(); ++i ) {
736  if ( loaded[i] && ret[i] == INVALID_TAX_ID ) {
737  loaded[i] = false;
738  retry = true;
739  }
740  }
741  if ( retry ) {
742  // full sequence retrieval is implemented in base CDataLoader class
743  CDataLoader::GetTaxIds(ids, loaded, ret);
744  }
745 
746  return;
747  }
748 }
749 
750 
751 static const bool s_LoadBulkBlobs = true;
752 
753 
755 {
756  if ( CReadDispatcher::CannotProcess(sih) ) {
757  return kInvalidSeqPos;
758  }
759  CGBReaderRequestResult result(this, sih);
760  CLoadLockLength lock(result, sih);
761  if ( !lock.IsLoadedLength() ) {
763  }
764  return lock.IsLoaded()? lock.GetLength(): 0;
765 }
766 
767 
769  TSequenceLengths& ret)
770 {
771  for ( size_t i = 0; i < ids.size(); ++i ) {
772  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
773  continue;
774  }
775  CGBReaderRequestResult result(this, ids[i]);
776  m_Dispatcher->LoadLengths(result, ids, loaded, ret);
777  return;
778  }
779 }
780 
781 
784 {
785  STypeFound ret;
786  if ( CReadDispatcher::CannotProcess(sih) ) {
787  return ret;
788  }
789  CGBReaderRequestResult result(this, sih);
790  CLoadLockType lock(result, sih);
791  if ( !lock.IsLoadedType() ) {
793  }
794  if ( lock.IsLoadedType() ) {
795  ret = lock.GetType();
796  }
797  return ret;
798 }
799 
800 
802  TSequenceTypes& ret)
803 {
804  for ( size_t i = 0; i < ids.size(); ++i ) {
805  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
806  continue;
807  }
808  CGBReaderRequestResult result(this, ids[i]);
809  m_Dispatcher->LoadTypes(result, ids, loaded, ret);
810  return;
811  }
812 }
813 
814 
816  TSequenceStates& ret)
817 {
818  if ( !s_LoadBulkBlobs ) {
819  CDataLoader::GetSequenceStates(ids, loaded, ret);
820  return;
821  }
822  for ( size_t i = 0; i < ids.size(); ++i ) {
823  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
824  continue;
825  }
826  CGBReaderRequestResult result(this, ids[i]);
827  m_Dispatcher->LoadStates(result, ids, loaded, ret);
828  return;
829  }
830  /*
831  set<CSeq_id_Handle> load_set;
832  size_t count = ids.size();
833  _ASSERT(ids.size() == loaded.size());
834  _ASSERT(ids.size() == ret.size());
835  CGBReaderRequestResult result(this, ids[0]);
836  for ( size_t i = 0; i < count; ++i ) {
837  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
838  continue;
839  }
840  CLoadLockBlobIds blobs(result, ids[i], 0);
841  if ( blobs.IsLoaded() ) {
842  continue;
843  }
844  // add into loading set
845  load_set.insert(ids[i]);
846  }
847  if ( !load_set.empty() ) {
848  result.SetRequestedId(*load_set.begin());
849  m_Dispatcher->LoadSeq_idsBlob_ids(result, load_set);
850  }
851  // update sequence states
852  for ( size_t i = 0; i < count; ++i ) {
853  CReadDispatcher::SetBlobState(i, result, ids, loaded, ret);
854  }
855  */
856 }
857 
858 
861 {
862  SHashFound ret;
863  if ( CReadDispatcher::CannotProcess(sih) ) {
864  return ret;
865  }
866  CGBReaderRequestResult result(this, sih);
867  CLoadLockHash lock(result, sih);
868  if ( !lock.IsLoadedHash() ) {
870  }
871  if ( lock.IsLoadedHash() ) {
872  ret = lock.GetHash();
873  }
874  return ret;
875 }
876 
877 
879  TSequenceHashes& ret, THashKnown& known)
880 {
881  for ( size_t i = 0; i < ids.size(); ++i ) {
882  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
883  continue;
884  }
885  CGBReaderRequestResult result(this, ids[i]);
886  m_Dispatcher->LoadHashes(result, ids, loaded, ret, known);
887  return;
888  }
889 }
890 
891 
893 {
894  TRealBlobId blob_id = GetRealBlobId(id);
896  CLoadLockBlobVersion lock(result, blob_id);
897  if ( !lock.IsLoadedBlobVersion() ) {
899  }
900  return lock.GetBlobVersion();
901 }
902 
903 
906  const TTSE_LockSet& tse_set)
907 {
908  TTSE_Lock best;
909  bool conflict=false;
910 
911  CGBReaderRequestResult result(this, handle);
912 
913  ITERATE(TTSE_LockSet, sit, tse_set) {
914  const CTSE_Info& tse = **sit;
915  TRealBlobId rbid = GetRealBlobId(tse);
916  CLoadLockBlob blob(result, GetRealBlobId(tse));
917  _ASSERT(blob);
918 
919  /*
920  if ( tse.m_SeqIds.find(handle) == tse->m_SeqIds.end() ) {
921  continue;
922  }
923  */
924 
925  // listed for given TSE
926  if ( !best ) {
927  best = *sit; conflict=false;
928  }
929  else if( !tse.IsDead() && best->IsDead() ) {
930  best = *sit; conflict=false;
931  }
932  else if( tse.IsDead() && best->IsDead() ) {
933  conflict=true;
934  }
935  else if( tse.IsDead() && !best->IsDead() ) {
936  }
937  else {
938  conflict=true;
939  //_ASSERT(tse.IsDead() || best->IsDead());
940  }
941  }
942 
943 /*
944  if ( !best || conflict ) {
945  // try harder
946  best.Reset();
947  conflict=false;
948 
949  CReaderRequestResultBlob_ids blobs = result.GetResultBlob_ids(handle);
950  _ASSERT(blobs);
951 
952  ITERATE ( CLoadInfoBlob_ids, it, *blobs ) {
953  TBlob_InfoMap::iterator tsep =
954  m_Blob_InfoMap.find((*srp)->GetKeyByTSE());
955  if (tsep == m_Blob_InfoMap.end()) continue;
956  ITERATE(TTSE_LockSet, sit, tse_set) {
957  CConstRef<CTSE_Info> ti = *sit;
958  //TTse2TSEinfo::iterator it =
959  // m_Tse2TseInfo.find(&ti->GetSeq_entry());
960  //if(it==m_Tse2TseInfo.end()) continue;
961  CRef<STSEinfo> tinfo = GetTSEinfo(*ti);
962  if ( !tinfo )
963  continue;
964 
965  if(tinfo==tsep->second) {
966  if ( !best )
967  best=ti;
968  else if (ti != best)
969  conflict=true;
970  }
971  }
972  }
973  if(conflict)
974  best.Reset();
975  }
976 */
977  if ( !best || conflict ) {
978  _TRACE("CGBDataLoader::ResolveConflict("<<handle.AsString()<<"): "
979  "conflict");
980  }
981  return best;
982 }
983 
984 
986 {
988  if ((it->m_Type & cache_type) != 0) {
989  return true;
990  }
991  }
992  return false;
993 }
994 
995 
997  time_t access_timeout)
998 {
1000  if ((it->m_Type & cache_type) != 0) {
1001  it->m_Cache->Purge(access_timeout);
1002  }
1003  }
1004 }
1005 
1006 
1008 {
1009  // Reset cache for each reader/writer
1011  m_CacheManager.GetCaches().clear();
1012 }
1013 
1014 
1015 //=======================================================================
1016 // GBLoader private interface
1017 //
1019 {
1020 }
1021 
1022 
1024 {
1025  switch(choice) {
1028  // whole bioseq
1029  return fBlobHasAllLocal;
1032  // everything except bioseqs & annotations
1033  return fBlobHasCore;
1035  // seq data
1038  // SeqFeatures
1039  return fBlobHasIntFeat;
1041  // SeqGraph
1042  return fBlobHasIntGraph;
1044  // SeqGraph
1045  return fBlobHasIntAlign;
1047  // all internal annotations
1048  return fBlobHasIntAnnot;
1056  // external annotations
1059  // orphan annotations
1060  return fBlobHasOrphanAnnot;
1062  // everything
1063  return fBlobHasAll;
1064  default:
1065  return 0;
1066  }
1067 }
1068 
1069 
1072 {
1073  TBlobContentsMask mask = 0;
1074  if ( details.m_NeedSeqMap.NotEmpty() ) {
1075  mask |= fBlobHasSeqMap;
1076  }
1077  if ( details.m_NeedSeqData.NotEmpty() ) {
1078  mask |= fBlobHasSeqData;
1079  }
1081  TBlobContentsMask annots = 0;
1082  switch ( DetailsToChoice(details.m_NeedAnnots) ) {
1083  case eFeatures:
1084  annots |= fBlobHasIntFeat;
1085  break;
1086  case eAlign:
1087  annots |= fBlobHasIntAlign;
1088  break;
1089  case eGraph:
1090  annots |= fBlobHasIntGraph;
1091  break;
1092  case eAnnot:
1093  annots |= fBlobHasIntAnnot;
1094  break;
1095  default:
1096  break;
1097  }
1099  mask |= annots;
1100  }
1102  mask |= (annots << 1);
1103  }
1105  mask |= (annots << 2);
1106  }
1107  }
1108  return mask;
1109 }
1110 
1111 
1114 {
1115  return x_GetRecords(sih, x_MakeContentMask(choice), 0);
1116 }
1117 
1118 
1121  const SRequestDetails& details)
1122 {
1123  return x_GetRecords(sih, x_MakeContentMask(details), 0);
1124 }
1125 
1126 
1128 {
1129  return true;
1130 }
1131 
1132 
1135 {
1136  TRealBlobId blob_id = GetRealBlobId(id);
1137 
1139  CLoadLockBlob blob(result, blob_id);
1140  if ( !blob.IsLoadedBlob() ) {
1141  m_Dispatcher->LoadBlob(result, blob_id);
1142  }
1143  _ASSERT(blob.IsLoadedBlob());
1144  return blob.GetTSE_LoadLock();
1145 }
1146 
1147 
1148 namespace {
1149  struct SBetterId
1150  {
1151  int GetScore(const CSeq_id_Handle& id1) const
1152  {
1153  if ( id1.IsGi() ) {
1154  return 100;
1155  }
1156  if ( !id1 ) {
1157  return -1;
1158  }
1159  CConstRef<CSeq_id> seq_id = id1.GetSeqId();
1160  const CTextseq_id* text_id = seq_id->GetTextseq_Id();
1161  if ( text_id ) {
1162  int score;
1163  if ( text_id->IsSetAccession() ) {
1164  if ( text_id->IsSetVersion() ) {
1165  score = 99;
1166  }
1167  else {
1168  score = 50;
1169  }
1170  }
1171  else {
1172  score = 0;
1173  }
1174  return score;
1175  }
1176  if ( seq_id->IsGeneral() ) {
1177  return 10;
1178  }
1179  if ( seq_id->IsLocal() ) {
1180  return 0;
1181  }
1182  return 1;
1183  }
1184  bool operator()(const CSeq_id_Handle& id1,
1185  const CSeq_id_Handle& id2) const
1186  {
1187  int score1 = GetScore(id1);
1188  int score2 = GetScore(id2);
1189  if ( score1 != score2 ) {
1190  return score1 > score2;
1191  }
1192  return id1 < id2;
1193  }
1194  };
1195 }
1196 
1197 
1200 {
1201  TTSE_LockSet ret;
1202  TIds ids = bioseq.GetId();
1203  sort(ids.begin(), ids.end(), SBetterId());
1204  ITERATE ( TIds, it, ids ) {
1205  if ( GetBlobId(*it) ) {
1206  // correct id is found
1207  TTSE_LockSet ret2 = GetRecords(*it, eExtAnnot);
1208  ret.swap(ret2);
1209  break;
1210  }
1211  else if ( it->Which() == CSeq_id::e_Gi ) {
1212  // gi is not found, do not try any other Seq-id
1213  break;
1214  }
1215  }
1216  return ret;
1217 }
1218 
1219 
1222  const SAnnotSelector* sel,
1223  TProcessedNAs* processed_nas)
1224 {
1225  return x_GetRecords(idh, fBlobHasExtAnnot|fBlobHasNamedAnnot, sel, processed_nas);
1226 }
1227 
1228 
1231  const SAnnotSelector* sel,
1232  TProcessedNAs* processed_nas)
1233 {
1234  TTSE_LockSet ret;
1235  TIds ids = bioseq.GetId();
1236  sort(ids.begin(), ids.end(), SBetterId());
1237  ITERATE ( TIds, it, ids ) {
1238  if ( GetBlobId(*it) ) {
1239  // correct id is found
1240  TTSE_LockSet ret2 = GetExternalAnnotRecordsNA(*it, sel, processed_nas);
1241  ret.swap(ret2);
1242  break;
1243  }
1244  else if ( it->Which() == CSeq_id::e_Gi ) {
1245  // gi is not found, do not try any other Seq-id
1246  break;
1247  }
1248  }
1249  return ret;
1250 }
1251 
1252 
1255  const SAnnotSelector* sel,
1256  TProcessedNAs* processed_nas)
1257 {
1258  bool load_external = m_AlwaysLoadExternal;
1259  bool load_namedacc =
1261  if ( load_external || load_namedacc ) {
1262  TBlobContentsMask mask = 0;
1263  if ( load_external ) {
1265  }
1266  if ( load_namedacc ) {
1268  }
1269  return x_GetRecords(idh, mask, sel, processed_nas);
1270  }
1271  else {
1272  return CDataLoader::GetOrphanAnnotRecordsNA(idh, sel, processed_nas);
1273  }
1274 }
1275 
1276 
1280  const SAnnotSelector* sel,
1281  TProcessedNAs* processed_nas)
1282 {
1283  TTSE_LockSet locks;
1284 
1285  if ( mask == 0 || CReadDispatcher::CannotProcess(sih) ) {
1286  return locks;
1287  }
1288 
1289  if ( (mask & ~fBlobHasOrphanAnnot) == 0 ) {
1290  // no orphan annotations in GenBank
1291  return locks;
1292  }
1293 
1294  CGBReaderRequestResult result(this, sih);
1295  m_Dispatcher->LoadBlobs(result, sih, mask, sel);
1296  CLoadLockBlobIds blobs(result, sih, sel);
1297  if ( !blobs.IsLoaded() ) {
1298  return locks;
1299  }
1300  _ASSERT(blobs.IsLoaded());
1301 
1302  CFixedBlob_ids blob_ids = blobs.GetBlob_ids();
1303  if ( (blob_ids.GetState() & CBioseq_Handle::fState_no_data) != 0 ) {
1304  if ( (mask & fBlobHasAllLocal) == 0 ||
1305  blob_ids.GetState() == CBioseq_Handle::fState_no_data ) {
1306  // only external annotatsions are requested,
1307  // or default state - return empty lock set
1308  return locks;
1309  }
1310  NCBI_THROW2(CBlobStateException, eBlobStateError,
1311  "blob state error for "+sih.AsString(),
1312  blob_ids.GetState());
1313  }
1314 
1315  ITERATE ( CFixedBlob_ids, it, blob_ids ) {
1316  const CBlob_Info& info = *it;
1317  const CBlob_id& blob_id = *info.GetBlob_id();
1318  if ( info.Matches(mask, sel) ) {
1319  CLoadLockBlob blob(result, blob_id);
1320  if ( !blob.IsLoadedBlob() ) {
1321  continue;
1322  }
1323  CTSE_LoadLock& lock = blob.GetTSE_LoadLock();
1324  _ASSERT(lock);
1325  if ( lock->GetBlobState() & CBioseq_Handle::fState_no_data ) {
1326  NCBI_THROW2(CBlobStateException, eBlobStateError,
1327  "blob state error for "+blob_id.ToString(),
1328  lock->GetBlobState());
1329  }
1330  if ( processed_nas ) {
1331  if ( auto annot_info = info.GetAnnotInfo() ) {
1332  for ( auto& acc : annot_info->GetNamedAnnotNames() ) {
1333  CDataLoader::SetProcessedNA(acc, processed_nas);
1334  }
1335  }
1336  }
1337  locks.insert(lock);
1338  }
1339  }
1340  result.SaveLocksTo(locks);
1341  return locks;
1342 }
1343 
1344 
1347 {
1349 
1350  CGBReaderRequestResult result(this, sih);
1351  SAnnotSelector sel;
1352  sel.IncludeNamedAnnotAccession("NA*");
1353  CLoadLockBlobIds blobs(result, sih, &sel);
1354  m_Dispatcher->LoadSeq_idBlob_ids(result, sih, &sel);
1355  _ASSERT(blobs.IsLoaded());
1356 
1357  CFixedBlob_ids blob_ids = blobs.GetBlob_ids();
1358  if ( (blob_ids.GetState() & CBioseq_Handle::fState_no_data) != 0) {
1359  if ( blob_ids.GetState() == CBioseq_Handle::fState_no_data ) {
1360  // default state - return empty name set
1361  return names;
1362  }
1363  NCBI_THROW2(CBlobStateException, eBlobStateError,
1364  "blob state error for "+sih.AsString(),
1365  blob_ids.GetState());
1366  }
1367 
1368  ITERATE ( CFixedBlob_ids, it, blob_ids ) {
1369  const CBlob_Info& info = *it;
1370  if ( !info.IsSetAnnotInfo() ) {
1371  continue;
1372  }
1373  CConstRef<CBlob_Annot_Info> annot_info = info.GetAnnotInfo();
1375  annot_info->GetNamedAnnotNames()) {
1376  names.insert(*jt);
1377  }
1378  }
1379  return names;
1380 }
1381 
1382 
1385  const string& named_acc)
1386 {
1388 
1389  CGBReaderRequestResult result(this, sih);
1390  SAnnotSelector sel;
1391  if ( !ExtractZoomLevel(named_acc, 0, 0) ) {
1393  }
1394  else {
1395  sel.IncludeNamedAnnotAccession(named_acc);
1396  }
1397  CLoadLockBlobIds blobs(result, sih, &sel);
1398  m_Dispatcher->LoadSeq_idBlob_ids(result, sih, &sel);
1399  _ASSERT(blobs.IsLoaded());
1400 
1401  CFixedBlob_ids blob_ids = blobs.GetBlob_ids();
1402  if ( (blob_ids.GetState() & CBioseq_Handle::fState_no_data) != 0 ) {
1403  if ( blob_ids.GetState() == CBioseq_Handle::fState_no_data ) {
1404  // default state - return empty name set
1405  return names;
1406  }
1407  NCBI_THROW2(CBlobStateException, eBlobStateError,
1408  "blob state error for "+sih.AsString(),
1409  blob_ids.GetState());
1410  }
1411 
1412  ITERATE ( CFixedBlob_ids, it, blob_ids ) {
1413  const CBlob_Info& info = *it;
1414  if ( !info.IsSetAnnotInfo() ) {
1415  continue;
1416  }
1417  CConstRef<CBlob_Annot_Info> annot_info = info.GetAnnotInfo();
1419  annot_info->GetNamedAnnotNames() ) {
1420  names.insert(*jt);
1421  }
1422  }
1423  return names;
1424 }
1425 
1426 
1428 {
1429  auto id = chunk->GetChunkId();
1430  if ( id == kMasterWGS_ChunkId ) {
1431  CWGSMasterSupport::LoadWGSMaster(this, chunk);
1432  }
1433  else {
1436  GetRealBlobId(chunk->GetBlobId()),
1437  id);
1438  }
1439 }
1440 
1441 
1443 {
1444  // filter out WGS master and sort chunks
1446  for ( auto& it : chunks ) {
1447  auto chunk_id = it->GetChunkId();
1448  if ( chunk_id == kMasterWGS_ChunkId ) {
1450  }
1451  else {
1452  chunks_to_load[GetRealBlobId(it->GetBlobId())].push_back(chunk_id);
1453  }
1454  }
1455  CReadDispatcher::TBlobChunkIds chunk_ids(chunks_to_load.begin(),
1456  chunks_to_load.end());
1458  m_Dispatcher->LoadChunks(result, chunk_ids);
1459 }
1460 
1461 
1463 {
1467  ITERATE(TTSE_LockSets, tse_set, tse_sets) {
1468  const CSeq_id_Handle& id = tse_set->first;
1469  if ( CReadDispatcher::CannotProcess(id) ) {
1470  continue;
1471  }
1472  ids.push_back(id);
1473  }
1475 
1476  NON_CONST_ITERATE(TTSE_LockSets, tse_set, tse_sets) {
1477  const CSeq_id_Handle& id = tse_set->first;
1478  if ( CReadDispatcher::CannotProcess(id) ) {
1479  continue;
1480  }
1481  CLoadLockBlobIds blob_ids_lock(result, id, 0);
1482  CFixedBlob_ids blob_ids = blob_ids_lock.GetBlob_ids();
1483  ITERATE ( CFixedBlob_ids, it, blob_ids ) {
1484  const CBlob_Info& info = *it;
1485  const CBlob_id& blob_id = *info.GetBlob_id();
1486  if ( info.Matches(mask, 0) ) {
1487  CLoadLockBlob blob(result, blob_id);
1488  _ASSERT(blob.IsLoadedBlob());
1489  /*
1490  if ((blob.GetBlobState() & CBioseq_Handle::fState_no_data) != 0) {
1491  // Ignore bad blobs
1492  continue;
1493  }
1494  */
1495  tse_set->second.insert(blob.GetTSE_LoadLock());
1496  }
1497  }
1498  }
1499 }
1500 
1501 
1502 static
1503 bool x_IsCDDBlob(const CBlob_Info& blob_info)
1504 {
1505  // must have external annotations
1506  if ( !blob_info.Matches(fBlobHasExtAnnot, 0) ) {
1507  return false;
1508  }
1509  // must have CDD name in annot info
1510  if ( !blob_info.IsSetAnnotInfo() ) {
1511  return false;
1512  }
1513  const char* kCDDAnnotName = "CDD";
1514  for ( auto name : blob_info.GetAnnotInfo()->GetNamedAnnotNames() ) {
1515  if ( NStr::EqualNocase(name, kCDDAnnotName) ) {
1516  return true;
1517  }
1518  }
1519  for ( auto annot_info : blob_info.GetAnnotInfo()->GetAnnotInfo() ) {
1520  if ( annot_info->IsSetName() &&
1521  NStr::EqualNocase(annot_info->GetName(), kCDDAnnotName) ) {
1522  return true;
1523  }
1524  }
1525  return false;
1526 }
1527 
1528 
1529 static bool x_IsEmptyCDD(const CTSE_Info& tse)
1530 {
1531  // check if delayed TSE chunk is loaded
1532  if ( tse.x_NeedsDelayedMainChunk() ) {
1533  // not loaded yet, cannot tell if its empty
1534  return false;
1535  }
1536  // check core Seq-entry content
1537  auto core = tse.GetTSECore();
1538  if ( !core->IsSet() ) {
1539  // wrong entry type
1540  return false;
1541  }
1542  auto& seqset = core->GetSet();
1543  return seqset.GetSeq_set().empty() && seqset.GetAnnot().empty();
1544 }
1545 
1546 
1548 {
1549  //return CDataLoader::GetCDDAnnots(id_sets, loaded, ret);
1551  vector<CSeq_id_Handle> best_ids;
1553  // first select ids that we can process
1554  for ( auto& id_set : id_sets) {
1555  SBetterId score_func;
1556  CSeq_id_Handle best_id;
1557  int best_score = -1;
1558  for ( auto& id : id_set ) {
1559  if ( CReadDispatcher::CannotProcess(id) ) {
1560  continue;
1561  }
1562  int score = score_func.GetScore(id);
1563  if ( score > best_score ) {
1564  best_score = score;
1565  best_id = id;
1566  }
1567  }
1568  best_ids.push_back(best_id);
1569  if ( best_id ) {
1570  ids.push_back(best_id);
1571  }
1572  }
1573  if ( ids.empty() ) {
1574  return;
1575  }
1576  // load blob_ids
1578 
1579  // select CDD blobs and load them
1580  CReadDispatcher::TBlobInfos blobs_to_load;
1581  for ( auto& id : best_ids ) {
1582  if ( !id ) {
1583  continue;
1584  }
1585  CLoadLockBlobIds blob_ids_lock(result, id, 0);
1586  CFixedBlob_ids blob_ids = blob_ids_lock.GetBlob_ids();
1587  ITERATE ( CFixedBlob_ids, it, blob_ids ) {
1588  const CBlob_Info& info = *it;
1589  if ( !x_IsCDDBlob(info) ) {
1590  continue;
1591  }
1592  const CBlob_id& blob_id = *info.GetBlob_id();
1593  CLoadLockBlob blob(result, blob_id);
1594  if ( !blob.IsLoadedBlob() ) {
1595  blobs_to_load.push_back(info);
1596  }
1597  }
1598  }
1599  if ( !blobs_to_load.empty() ) {
1600  m_Dispatcher->LoadBlobs(result, blobs_to_load);
1601  }
1602 
1603  CReadDispatcher::TChunkIds main_chunk;
1604  main_chunk.push_back(CTSE_Chunk_Info::kDelayedMain_ChunkId);
1605 
1606  // select CDD blobs and load their delayed TSE chunks
1607  CReadDispatcher::TBlobChunkIds chunks_to_load;
1608  for ( auto& id : best_ids ) {
1609  if ( !id ) {
1610  continue;
1611  }
1612  CLoadLockBlobIds blob_ids_lock(result, id, 0);
1613  CFixedBlob_ids blob_ids = blob_ids_lock.GetBlob_ids();
1614  ITERATE ( CFixedBlob_ids, it, blob_ids ) {
1615  const CBlob_Info& info = *it;
1616  if ( !x_IsCDDBlob(info) ) {
1617  continue;
1618  }
1619  const CBlob_id& blob_id = *info.GetBlob_id();
1620  CLoadLockBlob blob(result, blob_id);
1621  _ASSERT(blob.IsLoadedBlob());
1622  // may be not loaded yet
1623  if ( blob.GetTSE_LoadLock()->x_NeedsDelayedMainChunk() ) {
1624  chunks_to_load.push_back(make_pair(blob_id, main_chunk));
1625  }
1626  }
1627  }
1628  if ( !chunks_to_load.empty() ) {
1629  m_Dispatcher->LoadChunks(result, chunks_to_load);
1630  }
1631 
1632  // now collect all non-empty CDD blobs
1633  for ( size_t i = 0; i < id_sets.size(); ++i ) {
1634  auto& id = best_ids[i];
1635  if ( !id ) {
1636  continue;
1637  }
1638  CLoadLockBlobIds blob_ids_lock(result, id, 0);
1639  CFixedBlob_ids blob_ids = blob_ids_lock.GetBlob_ids();
1640  ITERATE ( CFixedBlob_ids, it, blob_ids ) {
1641  const CBlob_Info& info = *it;
1642  if ( !x_IsCDDBlob(info) ) {
1643  continue;
1644  }
1645  const CBlob_id& blob_id = *info.GetBlob_id();
1646  CLoadLockBlob blob(result, blob_id);
1647  _ASSERT(blob.IsLoadedBlob());
1648  if ( !x_IsEmptyCDD(*blob.GetTSE_LoadLock()) ) {
1649  ret[i] = blob.GetTSE_LoadLock();
1650  }
1651  loaded[i] = true;
1652  break;
1653  }
1654  }
1655 }
1656 
1657 
1658 #if 0
1659 class CTimerGuard
1660 {
1661  CTimer *t;
1662  bool calibrating;
1663 public:
1664  CTimerGuard(CTimer& x)
1665  : t(&x), calibrating(x.NeedCalibration())
1666  {
1667  if ( calibrating ) {
1668  t->Start();
1669  }
1670  }
1671  ~CTimerGuard(void)
1672  {
1673  if ( calibrating ) {
1674  t->Stop();
1675  }
1676  }
1677 };
1678 #endif
1679 
1680 
1682 {
1683  //TWriteLockGuard guard(m_LoadMap_Lock);
1684  //m_LoadMapBlob.erase(GetBlob_id(*tse_info));
1685 }
1686 
1687 
1690  const CSeq_id_Handle& requested_id)
1691  : CReaderRequestResult(requested_id,
1692  loader->GetDispatcher(),
1693  loader->GetInfoManager()),
1694  m_Loader(loader)
1695 {
1696 }
1697 
1698 
1700 {
1701 }
1702 
1703 
1705 {
1706  return m_Loader;
1707 }
1708 
1709 
1711 {
1712  CGBDataLoader::TBlobId id(new TKeyBlob(blob_id));
1713  return GetLoader().GetDataSource()->GetTSE_LoadLock(id);
1714 }
1715 
1716 
1718 {
1719  CGBDataLoader::TBlobId id(new TKeyBlob(blob_id));
1721 }
1722 
1723 
1725  TLoadedBlob_ids& blob_ids) const
1726 {
1727  CDataSource::TLoadedBlob_ids blob_ids2;
1730  blob_ids2);
1731  ITERATE(CDataSource::TLoadedBlob_ids, id, blob_ids2) {
1732  blob_ids.push_back(m_Loader->GetRealBlobId(*id));
1733  }
1734 }
1735 
1736 
1739 {
1740  if ( type == GBL::eExpire_normal ) {
1741  return m_Loader->GetIdExpirationTimeout();
1742  }
1743  else {
1745  }
1746 }
1747 
1748 
1749 bool
1751 {
1752  return m_Loader->GetAddWGSMasterDescr();
1753 }
1754 
1755 
1757 {
1758  return m_Loader->GetPTISErrorAction();
1759 }
1760 
1761 
1762 /*
1763 bool CGBDataLoader::LessBlobId(const TBlobId& id1, const TBlobId& id2) const
1764 {
1765  const CBlob_id& bid1 = dynamic_cast<const CBlob_id&>(*id1);
1766  const CBlob_id& bid2 = dynamic_cast<const CBlob_id&>(*id2);
1767  return bid1 < bid2;
1768 }
1769 
1770 
1771 string CGBDataLoader::BlobIdToString(const TBlobId& id) const
1772 {
1773  const CBlob_id& bid = dynamic_cast<const CBlob_id&>(*id);
1774  return bid.ToString();
1775 }
1776 */
1777 
1779  ECacheType cache_type)
1780 {
1781  SReaderCacheInfo info(cache, cache_type);
1782  //!!! Make sure the cache is not registered yet!
1783  m_Caches.push_back(info);
1784 }
1785 
1786 
1788  const TCacheParams* params)
1789 {
1791  if ((it->m_Type & cache_type) == 0) {
1792  continue;
1793  }
1794  if ( it->m_Cache->SameCacheParams(params) ) {
1795  return it->m_Cache.get();
1796  }
1797  }
1798  return 0;
1799 }
1800 
1801 
1803 
1804 // ===========================================================================
1805 
1807 
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:1427
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:1113
virtual void GetTaxIds(const TIds &ids, TLoaded &loader, TTaxIds &ret) override
Definition: gbnative.cpp:723
static CRef< TReaderManager > x_GetReaderManager(void)
Definition: gbnative.cpp:450
TBlobContentsMask x_MakeContentMask(EChoice choice) const
Definition: gbnative.cpp:1023
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:801
virtual TBlobVersion GetBlobVersion(const TBlobId &id) override
Definition: gbnative.cpp:892
virtual void GetSequenceHashes(const TIds &ids, TLoaded &loader, TSequenceHashes &ret, THashKnown &known) override
Definition: gbnative.cpp:878
virtual void GetAccVers(const TIds &ids, TLoaded &loader, TIds &ret) override
Definition: gbnative.cpp:684
virtual TTSE_LockSet GetExternalAnnotRecordsNA(const CSeq_id_Handle &idh, const SAnnotSelector *sel, TProcessedNAs *processed_nas) override
Definition: gbnative.cpp:1221
virtual void GC(void) override
Definition: gbnative.cpp:1018
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:1120
virtual void GetSequenceStates(const TIds &ids, TLoaded &loader, TSequenceStates &ret) override
Definition: gbnative.cpp:815
virtual void GetIds(const CSeq_id_Handle &idh, TIds &ids) override
Definition: gbnative.cpp:570
virtual void GetBulkIds(const TIds &ids, TLoaded &loader, TBulkIds &ret) override
Definition: gbnative.cpp:671
virtual void DropTSE(CRef< CTSE_Info > tse_info) override
Definition: gbnative.cpp:1681
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:905
virtual bool CanGetBlobById(void) const override
Definition: gbnative.cpp:1127
virtual TSeqPos GetSequenceLength(const CSeq_id_Handle &sih) override
Request for a length of a sequence.
Definition: gbnative.cpp:754
virtual void GetChunks(const TChunkSet &chunks) override
Definition: gbnative.cpp:1442
virtual TNamedAnnotNames GetNamedAnnotAccessions(const CSeq_id_Handle &idh) override
Definition: gbnative.cpp:1346
CRef< CGBInfoManager > m_InfoManager
Definition: gbnative.hpp:244
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:996
CInitMutexPool m_MutexPool
Definition: gbnative.hpp:241
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:697
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:1254
virtual int GetSequenceState(const CSeq_id_Handle &idh) override
Request for a state of a sequence.
Definition: gbnative.cpp:655
CGBReaderCacheManager m_CacheManager
Definition: gbnative.hpp:247
TTSE_LockSet x_GetRecords(const CSeq_id_Handle &idh, TBlobContentsMask sr_mask, const SAnnotSelector *sel, TProcessedNAs *processed_nas=0)
Definition: gbnative.cpp:1278
virtual STypeFound GetSequenceTypeFound(const CSeq_id_Handle &sih) override
Definition: gbnative.cpp:783
virtual TTaxId GetTaxId(const CSeq_id_Handle &idh) override
Request for a taxonomy id of a sequence.
Definition: gbnative.cpp:637
CRef< CReadDispatcher > m_Dispatcher
Definition: gbnative.hpp:243
virtual SGiFound GetGiFound(const CSeq_id_Handle &idh) override
Definition: gbnative.cpp:605
virtual TBlobId GetBlobIdFromString(const string &str) const override
Definition: gbnative.cpp:564
void CloseCache(void) override
Definition: gbnative.cpp:1007
virtual TTSE_LockSet GetExternalRecords(const CBioseq_Info &bioseq) override
Request from a datasource set of blobs with external annotations.
Definition: gbnative.cpp:1199
virtual ~CGBDataLoader_Native(void)
Definition: gbnative.cpp:168
virtual void GetLabels(const TIds &ids, TLoaded &loader, TLabels &ret) override
Definition: gbnative.cpp:710
virtual string GetLabel(const CSeq_id_Handle &idh) override
Request for a label string of a sequence.
Definition: gbnative.cpp:623
virtual void GetSequenceLengths(const TIds &ids, TLoaded &loader, TSequenceLengths &ret) override
Definition: gbnative.cpp:768
virtual void GetCDDAnnots(const TSeqIdSets &id_sets, TLoaded &loaded, TCDD_Locks &ret) override
Definition: gbnative.cpp:1547
virtual SHashFound GetSequenceHashFound(const CSeq_id_Handle &idh) override
Definition: gbnative.cpp:860
virtual TBlobId GetBlobIdFromSatSatKey(int sat, int sat_key, int sub_sat) const override
Definition: gbnative.cpp:535
virtual TTSE_Lock GetBlobById(const TBlobId &id) override
Definition: gbnative.cpp:1134
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:585
virtual TBlobId GetBlobId(const CSeq_id_Handle &idh) override
Definition: gbnative.cpp:547
virtual void GetBlobs(TTSE_LockSets &tse_sets) override
Definition: gbnative.cpp:1462
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:985
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:696
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:1787
virtual TCaches & GetCaches(void)
Definition: gbnative.hpp:104
virtual void RegisterCache(ICache &cache, ECacheType cache_type)
Definition: gbnative.cpp:1778
CReaderRequestResult TParent
Definition: gbnative.cpp:111
CInitMutexPool & GetMutexPool(void)
Definition: gbnative.cpp:132
virtual TExpirationTime GetIdExpirationTimeout(GBL::EExpirationType type) const override
Definition: gbnative.cpp:1738
virtual EGBErrorAction GetPTISErrorAction(void) const override
Definition: gbnative.cpp:1756
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:1750
virtual CTSE_LoadLock GetTSE_LoadLock(const TKeyBlob &blob_id) override
Definition: gbnative.cpp:1710
virtual CGBDataLoader_Native * GetLoaderPtr(void) override
Definition: gbnative.cpp:1704
virtual void GetLoadedBlob_ids(const CSeq_id_Handle &idh, TLoadedBlob_ids &blob_ids) const override
Definition: gbnative.cpp:1724
CGBReaderRequestResult(CGBDataLoader_Native *loader, const CSeq_id_Handle &requested_id)
Definition: gbnative.cpp:1689
virtual CTSE_LoadLock GetTSE_LoadLockIfLoaded(const TKeyBlob &blob_id) override
Definition: gbnative.cpp:1717
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:1503
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:751
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:1529
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:2812
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:3452
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:5414
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:5355
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[]
Definition: psg_cdd.hpp:85
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 Wed Sep 04 15:02:24 2024 by modify_doxy.py rev. 669887